akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


#define ll long long
#define scan(x) scanf("%lld",&x)

const ll mod=1e9+7;

using namespace std;

ll dp[101][5][5][5],n;

ll func(ll x, ll prev1, ll prev2 , ll prev3)
{
    if(x>=n)
        return 1;
    ll &ret= dp[x][prev1][prev2][prev3];
    if(ret!=-1)
        return ret;
    ll ans=0;
    for(ll i=1;i<=4;i++)
    {
        if(i==2)
        {
            if((prev1==3)&&(prev2==1))
                continue;

        }
        if(i==3)
        {
            if((prev1==2)&&(prev2==1))
                continue;
             if((prev1==1)&&(prev2==2))
                continue;

            if((prev2==2)&&(prev3==1))
                continue;

            if((prev3==1)&&(prev1==2))
                continue;

        }

        ans+= func(x+1,i,prev1,prev2)%mod;
        ans%=mod;


    }
    return ret=ans;

}


int main()
{
    memset(dp,-1,sizeof dp);
    ll i,j,k,l,m;
    cin >> n;
    cout << func(0,0,0,0);
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<functional>
#include<iterator>
#include<math.h>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	string l,r;
	int ans=0;
	for(int i=1;i<s.size();i++){
		set<char> ls,rs;
		l = s.substr(0,i);
		for(int j=0;j<l.size();j++){
			ls .insert(l[j]);
		}
		r = s.substr(i);
		for(int j=0;j<r.size();j++){
			rs .insert(r[j]);
		}
		int cnt=0;
		for(auto itr=ls.begin();itr != ls.end();itr++){
			if(rs.find(*itr) != rs.end()) cnt++;
		}
		if( ans < cnt) ans = cnt;
	}
		
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using Point = pair<int, int>;
const int INF = (int)1e9;
string S;
ll res = 0;

int main(void){
    cin >> S;
    int len = S.size();
        
    for(int i = 0; i < (1<<(len-1)); i++){
        int num = 1;
        for(int j = 0; j < len; j++){
            res += (ll) num * (S[len - 1 - j] - '0');

            if(i & (1<<j)){
                num *= 10;
            }else{
                num = 1;
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

class UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    UnionFind(int n){
        init(n);
    }
    void init(int n){
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
        rank.assign(n, 0);
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int N, M;
    cin >> N >> M;

    UnionFind uf(N + M);
    for(int i=0;i<N;i++){
        int K;
        cin >> K;
        for(int j=0;j<K;j++){
            int lang;
            cin >> lang;
            uf.unite(i, N + lang - 1);
        }
    }

    for(int i=0;i<N;i++){
        if(!uf.same(0, i)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using l1 = long long;
#define rep(i,n) for(int i=0,i<(n);++i)

int main(){
    set<string> a;
    int n;
    cin>>n;
    string memo;
    for(int i=0;i<n;i++){
        cin>>memo;
        a.insert(memo);
    }

    cout<<a.size()<<endl;

    return 0;

}

Measured memory_bytes: 19212
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder str = new StringBuilder(br.readLine());
        int n = Integer.parseInt(br.readLine());
        String[] operation;
        int ope1, ope2;

        for (int i = 0; i < n; i++) {
            operation = br.readLine().split(" ");
            ope1 = Integer.parseInt(operation[1]);
            ope2 = Integer.parseInt(operation[2]) + 1;

            if (operation[0].equals("print")) {
                System.out.println(str.substring(ope1, ope2));
            } else if (operation[0].equals("reverse")) {
                String reverse = new StringBuilder(str.substring(ope1, ope2)).reverse().toString();
                str.replace(ope1, ope2, reverse);
            } else {
                str.replace(ope1, ope2, operation[3]);
            }
        }
    }
}

Measured memory_bytes: 24504
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 5005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,m;
vector<int> G[SIZE];
int indeg[SIZE];
bool used[SIZE];
vector<int> tsort;

bool T;

void bfs(int s){
	queue<int> q; //入次数0の頂点
	q.push(s);
	used[s] = true;
	while(!q.empty()){
		if(q.size()>=2)T = true;
		int u = q.front();q.pop();
		tsort.push_back(u);
		for(int i=0;i<G[u].size();i++){
			int v = G[u][i];
			indeg[v]--;
			if(indeg[v]==0 && !used[v]){
				q.push(v);
				used[v] = true;
			}
		}
	}
}



int main()
{
	scanf("%d%d",&n,&m);
	int a,b;
	T = false;
	for(int i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		indeg[b]++;
	}
	vector<int> S; //start
	for(int i=1;i<=n;i++){
		if(indeg[i]==0)S.push_back(i);
	}

	//tsort
	for(int i=0;i<S.size();i++)bfs(S[i]);
	for(int i=0;i<tsort.size();i++)printf("%d\n",tsort[i]);
	if(S.size()>1 || T)puts("1");
	else puts("0");

	return 0;
}



Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  int fz = 1;
  set<int> bs;
  REP(i,N){
	int x;
	cin >> x;
	if(x < fz-1)
	  cout << "No" << endl;
	else{
	  //cout <<x <<"->"<<fz << " " << SZ(bs)<<endl;
	  if(x == fz-1 && SZ(bs) > x){
		cout << "No" << endl;
		continue;
	  }
	  if(bs.count(0)){
		cout << "No" << endl;
		continue;
	  }
	  
	  cout << "Yes" << endl;
	  if(x == fz){
		bs.insert(fz);
		while(bs.count(fz)) ++fz;
	  }
	  else{
		int i;
		for(i=x;i>=0;--i){
		  if(bs.count(i)){
			bs.erase(i);
		  }
		  else
			break;
		}
		if(fz == i)
		  fz = i+1;
		else
		  fz = min(fz, i+1);
		bs.insert(i);
	  }
	}
  }

  return 0;
}

Measured memory_bytes: 14832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(a-c) <= d || (abs(a-b)<=d && abs(b-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 1000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
    int x,d=0;
    cin>>x;
    for(int i=0;i<=x;i++){
        if(i*(i+1)/2>=x){
            d=i;
            break;
        }
    }
    cout<<d<<endl;
    return 0;
}












Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8')

lines = input.split('\n')
N = lines.shift() * 1
A = lines.shift().split(' ')
B = lines.shift().split(' ')
ans = 0
C = Array(A.length).fill(0)
over = 0
for (i=0; i<N; i++) {
    C[i] = Math.min(A[i]*1, B[i]*1 + over)
    a = A[i] * 1 - over
    if (a > 0) {
        if (B[i] * 1 - a > 0) {
            over = B[i] * 1 - a
        } else {
            over = 0
        }
    } else {
        over = B[i] * 1
    }
}
C[i] = Math.min(A[i]*1, over)
console.log(C.reduce((a, b) => a + b, 0))

Measured memory_bytes: 31076
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int main()
{
	long long n, s = 0;	
	
	scanf("%lld", &n);
	s = n / 11;
	n %= 11;
	s *= 2;
	if (n > 0){
		s++;
	} 
	if (n > 6){
		s++;
	}
	printf("%lld\n", s);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    
    int n,ans;
    char w[100][11];
    ans=0;
    
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%s",w[i]);

    for(int i=1; i<n; i++){
        
        if(w[i-1][strlen(w[i-1])-1]!=w[i][0])
            ans=1;
            
        for(int j=0; j<i; j++){
            if(strcmp(w[j],w[i])==0)
                ans=1;
        } 
    }
    if(ans==0)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

int main() {
  int  i,j;
  int A, B;
  cin >> A >> B ;
  int ret;
  string strA;
  while(A<=B){
    strA=to_string(A);
    if (strA[0]==strA[4]&&strA[1]==strA[3])ret++;
    A++;
  }
  cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, M; cin >> N >> M;
    cout << ((N+M) * (N+M-1)) / 2 - (N * M) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

int N, M;
vector<int> v[100000];
int S, T;
int dist[100000][3];
const int INF = 1000000000;

int main() {
  cin >> N >> M;
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--;y--;
    v[x].push_back(y);
  }
  cin >> S >> T;
  S--;T--;
  rep(i, N) {
    rep(j, 3) {
      dist[i][j] = INF;
    }
  }
  queue<P> que;
  que.push(make_pair(S, 0));
  dist[S][0] = 0;
  while(que.size()) {
    P p = que.front();
    que.pop();
    // cout << p.first << " " << p.second << endl;

    rep(i, v[p.first].size()) {
      // cout << v[p.first][i] << endl;
      if(dist[v[p.first][i]][(p.second+1) % 3] > dist[p.first][p.second] + 1) {
        dist[v[p.first][i]][(p.second+1) % 3] = dist[p.first][p.second] + 1;
        P np = make_pair(v[p.first][i], (p.second + 1) % 3);
        que.push(np);
        // cout << np.first << " " << np.second << endl;
      }
    }
  }
  if(dist[T][0] == INF) cout << -1 << endl;
  else cout << dist[T][0] / 3 << endl;
  // rep(i, N) {
  //   rep(j, v[i].size()) {
  //     cout << v[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  return 0;
}

Measured memory_bytes: 10244
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int a,b;
	cin>>a>>b;
	if((a+b)%2==0)cout<<(a+b)/2;
	else cout<<"IMPOSSIBLE";



}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;cin >> N;
    vector<int> a(N);
    for(int i = 0; i<N; i++){
        cin >> a[i]; 
    }
    int max = a[0];
    long long int ans = 0;
    for(int i=0; i<N; i++){
        if(a[i]<=max){
            ans += max - a[i];
        }
        else{
            max = a[i];
        }
    }
    cout << ans; 
}

Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int a[3];
for(int i=0;i<3;i++)
    cin >> a[i];
    sort(a,a+3);
if(a[0]!=a[1])cout << a[0] <<endl;
else cout <<a[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

int n, m; // number of nodes, edges

vvi edge;
vvi g;
vi prenum;
vi lowest;
vi parent;
int timer;

void lowlink_dfs(int u, int prev) {
  prenum[u] = timer;
  lowest[u] = timer;
  timer += 1;

  for (auto v : g[u]) {
    if (prenum[v] < 0) {
      parent[v] = u;
      lowlink_dfs(v, u);
      lowest[u] = min(lowest[u], lowest[v]);
    } else if (v != prev) {
      lowest[u] = min(lowest[u], prenum[v]);
    }
  }
}

void lowlink() {
  prenum.assign(n, -1);
  lowest.assign(n, 0);
  parent.assign(n, 0);
  timer = 0;
  lowlink_dfs(0, -1);
}

bool is_bridge(int x, int y) {
  return (prenum[x] < lowest[y] || prenum[y] < lowest[x]);
}

// call after lowlink()
set<pii> bridge() {
  set<pii> ret;
  rep (i, m) {
    int x = edge[i][0];
    int y = edge[i][1];
    if (is_bridge(x, y)) {
      if (x > y) {
        swap(x, y);
      }
      ret.insert(make_pair(x, y));
    }
  }
  return ret;
}


int main() {
  scanf("%d %d", &n, &m);
  edge.assign(m, vi(2, 0));
  g.resize(n);
  rep (i, m) {
    int s, t;
    scanf("%d %d", &s, &t);
    if (s > t) {
      swap(s, t);
    }
    edge[i][0] = s;
    edge[i][1] = t;
    g[s].push_back(t);
    g[t].push_back(s);
  }
  sort(all(edge));
  lowlink();
  auto ans = bridge();
  for (auto p : ans) {
    printf("%d %d\n", p.first, p.second);
  }

  return 0;
}

Measured memory_bytes: 7276
#include<stdio.h>
long long n,a[111111],b[111111],ans=0;
int main(){
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&a[i],&b[i]);
    a[i]%=b[i];
  }
  for(int i=n-1;i>=0;i--){
    a[i]=(a[i]+ans)%b[i];
    if(a[i]>0){
      ans+=b[i]-a[i];
    }
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	string s;
	cin >> s;
	V w(n + 2, 0);
	V e(n + 2, 0);
	rep1(i, n) {
		if (s[i - 1] == 'W') w[i]++;
		w[i] += w[i - 1];
	}
	for (int i = n; i >= 1; i--) {
		if (s[i - 1] == 'E') e[i]++;
		e[i] += e[i + 1];
	}
	int ans = upper;
	rep1(i, n) {
		chmin(ans, w[i - 1] + e[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3076
// finish date: 2019/2/9

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
//#define input(name)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

int K, N;
string S;


ll dfs(int pos, int tmpK, bool flag = false) {
    if (tmpK == 0) {
        return (ll) 1;
    }
    if (pos >= N) {
        return (ll) 0;
    }
    ll ans = 0;
//    0にする
    bool is0 = ((S[pos] - '0') == 0);
    ans += dfs(pos + 1, tmpK, flag | !is0);
    if (flag) {
        ans += 9 * dfs(pos + 1, tmpK - 1, true);
    } else {
        //0以外
        int n = (S[pos] - '0') - 1;
        if (n > 0) {
            ans += n * dfs(pos + 1, tmpK - 1, true);
        }
        if (S[pos] - '0' != 0) {
            ans += dfs(pos + 1, tmpK - 1, false);
        }
    }
    return ans;

}

int main() {
    cin >> S >> K;
    N = S.length();
    vi arr;
    ll ans = dfs(0, K);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string ToString ( int x )
{
	string s = "";
	
	while ( x )
	{
		s += ((x % 10) + '0');
		x /= 10;
	}

	reverse(s.begin(), s.end());

	return s;
}

int main ( void )
{
	int n;

	while ( cin >> n, n )
	{
		string s1, s2;
		cin >> s1;

		for (int i = 0; i < n; ++i)
		{
			char c = s1[0];
			int counter = 0;

			s1 += 'x';
			s2 = "";

			for (int j = 0; j < s1.size(); ++j)
			{
				if ( c != s1[j] )
				{
					// cout << ToString(counter) << ' ' << c << endl;
					s2 += ToString(counter) + c;
					c = s1[j];
					counter = 1;
				}
				else
					++counter;
			}
			s1 = s2;
		}

		cout << s1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

Vi costu;
Vi costv;
    
void dfs1(int now,int past,Ki &G){
    //debug(past+1);
    //debug(now+1);
    if(past==-1){
        costu[now]=0;
    }
    else{
        //debug(costu[past]);
        costu[now]=costu[past]+1;
    }
    for(int next: G[now]){
        if(next==past) continue;
        dfs1(next,now,G);
    }
}


void dfs2(int now,int past,Ki &G){
    //debug(past+1);
    //debug(now+1);
    if(past==-1){
        costv[now]=0;
    }
    else{
        //debug(costv[past]);
        costv[now]=costv[past]+1;
    }
    for(int next: G[now]){
        if(next==past) continue;
        dfs2(next,now,G);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,u,v;
    cin>>n>>u>>v;
    Ki G(n);
    u--;
    v--;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    costu.resize(n,INF);
    costu[u]=0;
    dfs1(u,-1,G);
    costv.resize(n,INF);
    costv[v]=0;
    dfs2(v,-1,G);
    ll ans=0;
    rep(i,n){
        if(costu[i]>costv[i]) continue;
        ans=max(ans,costv[i]-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 71040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC143_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string takoN = Console.ReadLine();
            string[] deliciouses = Console.ReadLine().Split(' ');
            int len = deliciouses.Length;
            int sum = 0;

            for(int i = 0; i<len -1; i++)
            {
                for(int j = i + 1; j < len ; j++)
                {
                    sum += int.Parse(deliciouses[i]) * int.Parse(deliciouses[j]);
                }
            }
            Console.Write(sum.ToString());
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    while (sc.hasNext()) {
        val a = Array(4, { sc.nextInt() })
        val b = Array(4, { sc.nextInt() })
        var (hit, blow) = Pair(0, 0)
        for ((i, n) in a.withIndex()) {
            if (b[i] == n) hit++
            else if (b.contains(n)) blow++
        }
        println("$hit $blow")
    }
}


Measured memory_bytes: 29220
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  char c;cin>>c;
  cout<<char(++c)<<endl;
  return 0;
}



Measured memory_bytes: 256
(setq s(concatenate 'list(read-line)))
(setq ans(floor(1-(length s))2))
(princ(loop
  (setq l t)
  (loop for i from 0 to (1- ans)do(setq l(and l(char=(nth i s)(nth(+ i ans)s)))))
  (if l(return (* ans 2)))
  (decf ans)))


Measured memory_bytes: 14308
#include <iostream>
#include <string>
using namespace std;

int main()
{
	char str[512];
	while(cin >> str)
	{
		int r=0;
		while(str[r])
		{
			if(str[r]=='@')
			{
				for(int i=0; i<str[r+1]-'0'; i++)
				{
					cout << str[r+2];
				}
				r+=3;
			}
			else
			{
				cout << str[r];
				r+=1;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>

using namespace std;

void boost() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    boost();
    int n;
    cin >> n;
    map <string, int> mp;
    vector <string> v;
    int maxi = 0;
    for (int i = 0; i < n; ++ i) {
        string str;
        cin >> str;
        if (mp[str] == 0) v.push_back(str);
        mp[str] ++;
        maxi = max(maxi, mp[str]);
    }
    vector <string> ans;
    for (int i = 0; i < v.size(); ++ i) {
        if (mp[v[i]] == maxi) ans.push_back(v[i]);
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); ++ i) cout << ans[i] << endl;
}


Measured memory_bytes: 27120
#教室内の位置は右*中央
#問題は「Restrictive Filesystem」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2152)
#ところでコメントを今までより詳しく書くことにしました(説明が簡単なので)

while(True):
    #とりあえず複数のデータセットに対して行えるようにします
    N = int(input())
    #終了判定
    if N == 0:
        quit()

    #方針として、ヒントにもあるように[識別子,[セクタ範囲]]というデータ構造を作ります(以下の「data」)
    #工夫として、例えばセクタ3、4、5に同じ数字が入っている時、セクタ範囲を[3,6]とします
    #これによって、その範囲に同じ数字がいくつ入っているかをカウントするのが容易になります
    #また、これとは別に、Nullになっているセクタの範囲を記したデータ構造を作ります(以下の「emp」)
    #empに空のセクタを集めておくことで、どのセクタにどの識別子を入れているかの判別が簡単になり、
    #なおかつdeleteした時の空セクタを簡単に取り扱うことができます
    #commandはせいぜい10000個なのでセクタ範囲の分割もせいぜい10000個であり、これで間に合うことがわかります(最大でソートのO(NlogN))
    #以下実装

    data = []
    emp = [[0,1+10**9]] #empは最初セクタ0~セクタ10**9。
    for _____ in range(N): #N回の命令。
        tmp = input().split()
        if tmp[0] == "W":#書き込みの時
            c,k = int(tmp[1]),int(tmp[2]) #cが識別子、kが個数
            while(k): #empのうち、セクタ範囲が小さい順から順番に入れていけばいいことがわかります
                      #この操作のために、empが増えた時にはsortし、常にセクタ範囲が小さい順になるようにします
                      #入りきらなかった場合は、とりあえずその分を入れて残りを入れればいいので、whileループを回します
                if (emp[0][1]-emp[0][0]) > k: #最初の空な範囲のなかに識別子が全て入ってしまうとき。
                    data.append([c,[emp[0][0],emp[0][0]+k]]) #dataに書き込んだ分を追加
                    emp[0] = [emp[0][0]+k,emp[0][1]] #代わりにempの最初のセクタ範囲が入れた分だけ減ります
                    break
                else:
                    data.append([c,emp[0]])
                    k -= (emp[0][1]-emp[0][0])
                    del(emp[0])
        elif tmp[0] == "D": #消すとき
            emp += [i[1] for i in data if i[0] == int(tmp[1])] #消したい識別子と一致するような範囲を全てempに足します
            data = [i for i in data if i[0] != int(tmp[1])] #dataは消したい識別子以外の識別子の範囲だけになります
            emp.sort() #empの範囲が小さい順になるようにsort。ちなみに理屈から分かる通り範囲がかぶることはないので安心です
        else: #読み込みの時
            ans = True
            s = int(tmp[1]) #sは読み込みたいセクタ範囲
            for i in data:
                if i[1][0]<=s<i[1][1]: #sが空でないdataのセクタとして書いてあればその識別子を書いておしまいです
                    print(i[0])
                    ans = False
                    break
            if ans: #どこにも書いてなければ-1を書いて終わり。
                print(-1)
    print() #データセットごとに改行。



Measured memory_bytes: 6760
#include <stdio.h>
#include <math.h>
double calc(int tA,int vA,int tB,int vB){
	return (double)(tA*vA+tB*vB)/(vA+vB);
}
int main(){
	int T,D,tA,tB,dA,dB,iA,iB;
	scanf("%d%d%d%d%d%d",&T,&D,&tA,&tB,&dA,&dB);
	double r=1<<30;
	for(iA=0;iA*dA<=D;iA++)for(iB=0;iA*dA+iB*dB<=D;iB++){
		double t=fabs(T-calc(tA,iA*dA,tB,iB*dB));
		if(r>t)r=t;
	}
	printf("%f\n",r);
	return 0;
}

Measured memory_bytes: 632
while true
  n = gets.chomp.to_i
  break if n == 0
  sum_x, sum_y = 0, 0
  n.times do |i|
    x, y = gets.chomp.split(" ").map(&:to_i)
    sum_x, sum_y = x > y ? [sum_x + x + y, sum_y] : y > x ? [sum_x, sum_y + x + y] : [sum_x + x, sum_y + y]
  end
  puts "#{sum_x} #{sum_y}"
end

Measured memory_bytes: 6104
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K;
    R(N,K);
    string s;R(s);
    int cnt=0;
    for(int i=0,j;i<SZ(s);i=j){
        for(j=i+1;j<SZ(s)&&s[j]==s[i];j++);
        cnt++;
    }
    cnt=max(1,cnt-2*K);
    W(N-cnt);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

using namespace std;

int main() {
    int h, n,tmp=0,a=0;
    cin>>h>>n;
    for (int i = 0; i < n; i++) {
        tmp = 0;
        cin >> tmp;
        a += tmp;
    }
    if (a >= h) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b+c || b==a+c || c==a+b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,m;
    cin>>n>>m;
    map<char,int> ma;
    REP(i,n){
        string t;
        cin>>t;
        REP(j,m){
            ma[t[j]]++;
        }
    }
    int a=0,b=0,c=0;
    for(char i='a';i<='z';i++){
        a+=ma[i]/4;
        b+=ma[i]%4/2;
        c+=ma[i]%2;
    }
    if(n%2&&m%2){
        if(a>=(n-1)*(m-1)/4&&c==1){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else if(n%2||m%2){
        if(m%2)swap(n,m);
        a-=(n-1)/2*(m/2);
        if(a>=0&&a*2+b>=m/2){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        if(b==0&&c==0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<7000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> {
        val m = readInt; isPrime(m)
      }
    })
  }
}

Measured memory_bytes: 69088
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int a[10010], b[10010];
int dp[10010];
int main(){
    int h, n;
    cin >> h >> n;
    rep(i, 0, n) cin >> a[i] >> b[i];
    rep(i, 0, 10010) dp[i] = INF;
    dp[0] = 0;
    rep(i, 0, h){
        rep(j, 0, n){
            if(h < i + a[j]) dp[h] = min(dp[h], dp[i] + b[j]);
            else dp[i+a[j]] = min(dp[i+a[j]], dp[i] + b[j]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;

int main ()
{
   int x,y;
   cin>>x>>y;
   if(x==y && x==2)
        cout<<"Yes"<<endl;
   else if(x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12)

   {
      if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12)
      cout<<"Yes"<<endl;
     else
      cout<<"No"<<endl;
   }
   else if(x==4 || x==6 || x==9|| x==11)
   {
       if(y==4 || y==6 || y==9|| y==11)
        cout<<"Yes"<<endl;
       else
        cout<<"No"<<endl;

   }
   else
    cout<<"No"<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;cw--;dh--;dw--;
  vector<vector<char>> s(h, vector<char>(w));
  vector<vector<int>> d(h, vector<int>(w,-1));
  rep(i,h) rep(j,w) cin >> s[i][j];
  queue<P> q, mq;
  q.push(make_pair(ch,cw));
  mq.push(make_pair(ch,cw));
  d[ch][cw] = 0;
  while (!q.empty() || !mq.empty()){
    while(!q.empty()) {
      P p = q.front(); q.pop();
      mq.push(p);
      int i = p.first, j = p.second;
      vector<int> di = {-1, 0, 1, 0};
      vector<int> dj = {0, 1, 0, -1};

      rep(k,4) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (0 <= ni && ni < h && 0 <= nj && nj < w && s[ni][nj] == '.' && d[ni][nj] == -1) {
          d[ni][nj] = d[i][j];
          q.push(make_pair(ni,nj));
        }
      }
    }
    while(!mq.empty()) {
      P mp = mq.front(); mq.pop();
      int i = mp.first, j = mp.second;

      for (int x = -2; x<=2; x++) {
        for (int y = -2; y<=2; y++) {
          if ((x==0 && y==0) || (x==-1 && y==0) || (x==0&&y==1) || (x==1&&y==0) || (x==0&&y==-1)) continue;
          else {
            int ni = i + x;
            int nj = j + y;
            if (0 <= ni && ni < h && 0 <= nj && nj < w && s[ni][nj] == '.' && d[ni][nj] == -1) {
              d[ni][nj] = d[i][j]+1;
              q.push(make_pair(ni,nj));
            }
          }
        }
      }
    }
  }
  cout << d[dh][dw] << endl;
  return 0;
}

Measured memory_bytes: 8552
A,B,C = map(int,input().split(' '))
num_list = [A,B,C]
list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)

Measured memory_bytes: 2940
function Main(input) {
  const N = parseInt(input.split(/\n| /)[0].trim());
  const D = parseInt(input.split(/\n| /)[1].trim());
  const XY = input.split(/\n| /).map(n => parseInt(n));
  let result = 0;


  for (i = 1; i <=N; i++){
    let L = Math.sqrt(XY[i*2]**2 + XY[i*2+1]**2);
    if (L <=D){
      result++;
    }
  }
  console.log(result);
  }

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 103252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	string S;
	long long N;
	scanf("%lld",&N);
	cin >> S;
	if (N%2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	bool flg = true;
	rep(i, N/2) {
		if (S[i] != S[i+N/2]) flg = false;
	}
	if (flg) cout << "Yes" << endl; else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

bool isValid(map<char, int> m){
    for(char c = 'a'; c <= 'c'; c++){
        if(m[c] != 1) return false;
    }
    
    return true;
}

int main() {
	string str;
	cin >> str;
	
	map<char, int> m;
	for(int i = 0; i < 3; i++) m[str[i]]++;
	
	if(isValid(m)) cout << "Yes";
	else cout << "No";
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ll MOD(ll x, ll m) {
    ll r = x % m;
    if (r < 0) {
        r += m;
    }
    return r;
}

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }
    if (n == 1) {
        cout << "0\n";
        return;
    }
    SORTREV(a);
    ll res = a[0];
    ll count = 2;
    ll i = 1;
    while (count < n) {
        res += a[i];
        count++;
        if (count >= n)
            break;
        res += a[i];
        count++;
        i++;
    }

    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    //cin.rdbuf()->in_avail()
    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int ans[200000+5],n,vis[200000+5];
vector<int> tr[200000+5];
void add(int rt,int jia)
{
    if(vis[rt])
        return ;
    vis[rt]=1;
    ans[rt]+=jia;
    int len=tr[rt].size();
    for(int i=0;i<len;i++)
        add(tr[rt][i],ans[rt]);
}
int main()
{
    int q;
    int i,x,y;
    scanf("%d %d",&n,&q);
    for(i=1;i<=n-1;i++)
    {
        scanf("%d%d",&x,&y);
        tr[x].push_back(y);
        tr[y].push_back(x);
    }
    for(i=0;i<q;i++)
    {
        scanf("%d%d",&x,&y);
        ans[x]+=y;
    }
    add(1,0);
    for(i=1;i<=n;i++)
        printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 24320
N,K=map(int,input().split())
L=N-K
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def ans(i):
  ret = 0
  if L>=(i-1):
    LL=L-(i-1)
    ret=cmb(K-1,i-1,mod)
    ret=(ret*cmb(i+LL,LL,mod))%mod
  return ret

for i in range(1,K+1):
  print(ans(i))

Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  int N,i,ans=0;
  scanf("%d",&N);
	char S[N+1],T[N+1],A[N*2+1];
	scanf("%s%s",S,T);
	FOR(i,0,N)A[i*2]=S[i],A[i*2+1]=T[i];

  FOR(i,0,N*2)printf("%c",A[i]);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,f[110000],q[510000],he,ta,x,y;
int main(){
	scanf("%d",&n);
	while (n%2==0) n/=2;
	while (n%5==0) n/=5;
	fo(i,0,n-1) f[i]=n;
	q[he=ta=n+n]=1%n;f[1%n]=1;//q[he=ta=n+n]=1
	while (he<=ta){
		x=q[he];he++;
		y=(x*10)%n;
		if (f[x]<f[y]){
			f[y]=f[x];
			q[--he]=y;
		}
		y=(x+1)%n;
		if (f[x]+1<f[y]){
			f[y]=f[x]+1;
			q[++ta]=y;
		}
	}
	//fo(i,0,n-1) printf("%d ",f[i]);
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 105, MAX_M = 105;

int ans[MAX_N][MAX_M];

int main() {
	int n, m;
	scanf(" %d %d", &n, &m);

	int c;
	scanf(" %d", &c);

	char dir = 'd';
	int x = 1, y = 1;

	for(int i = 1; i <= c; i++) {
		int a;
		scanf(" %d", &a);
		
		while(a != 0) {
			ans[x][y] = i;
			a--;

			if(dir == 'd') {
				x++;

				if(x == n + 1) {
					x = n;
					y++;
					dir = 'u';
				}
			}
			else {
				x--;
				
				if(x == 0) {
					x = 1;
					y++;
					dir = 'd';
				}
			}
		}
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			printf("%d ", ans[i][j]);
		}

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 384
class program
{
	static void Main()
	{
		string[] line = System.Console.ReadLine().Split(' ');
		long N = long.Parse(line[0]);
		long K = long.Parse(line[1]);
		long amari = N%K;
		long sa = amari - K;
		if(sa<0){
			sa = sa * -1;
		}
		if(sa>=amari){
			System.Console.WriteLine(amari);
		}else{
			System.Console.WriteLine(sa);
		}
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>

int sellectionSort(int *, int);

int main(){
  int n,i,count;
  int *a;

  scanf("%d",&n);
  if(n < 1 || 100 < n)exit(0);

  a = malloc(n*sizeof(int));
  
  for(i = 0; i < n; i++){
    scanf("%d",a+i);
    if(*(a+i) < 0 || 100 < *(a+i))exit(1);
  }

  count = sellectionSort(a,n);

  printf("%d",*a);
  for(i = 1; i < n; i++){
    printf(" %d",*(a+i));
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}

int sellectionSort(int *a,int n){
  int count,i,j,min,v;

  count = 0;
  
  for(i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(a[j] < a[min]){
        min = j;
      }
    }
    v = a[i];
    a[i] = a[min];
    a[min] = v;
    if(i != min)count++;
  }

  return count;
}



Measured memory_bytes: 2048