akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, P;
string S;
int c[10010];


signed main(){
    cin >> N >> P;
    cin >> S;

    reverse(ALL(S));

    int ans = 0;
    if(P == 2 or P == 5){
        rep(i, 0, N) if((S[i]-'0')%P == 0) ans += N-i;
    }
    else {
        int p10 = 1, m = 0;
        rep(i, 0, N) m += (S[i]-'0')*p10%P, c[m%=P]++, (p10 *= 10) %= P;
        int s = 0;
        p10 = 1;
        rep(i, 0, N) ans += c[s], (s += (S[i]-'0')*p10) %= P, c[s]--, (p10 *= 10) %= P;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll X,Y,Z,K; cin >> X >> Y >> Z >> K;
  vector<ll> A(X); vector<ll> B(Y); vector<ll> C(Z);
  for(ll i = 0; i < X; i++){ 
    cin >> A[i];}
  for(ll j = 0; j < Y; j++){
    cin >> B[j];}
  for(ll k = 0; k < Z; k++){
    cin >> C[k];}
  
  sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());
  reverse(A.begin(),A.end()); reverse(B.begin(),B.end()); reverse(C.begin(),C.end());
  
  vector<ll> AB;
  for(ll i = 0; i < min(X, K) ; i++){
    for(ll j = 0; j < min( Y, K); j++){
      AB.push_back( A[i] + B[j]);}}
  
  sort(AB.begin(),AB.end()); reverse(AB.begin(),AB.end());
 
  vector<ll> ABC;
  
  for(ll j = 0; j < min(X * Y,K); j++){
    for(ll k = 0; k < min( Z, K); k++){
      
      ABC.push_back( AB[j] + C[k]);}}
  
   sort(ABC.begin(), ABC.end()); reverse(ABC.begin(),ABC.end());
  for(ll l = 0; l < K; l++){ 
    cout << ABC[l] << endl; }
  return 0;}
  

Measured memory_bytes: 42984
Sa = input()
Sb = input()
Sc = input()

t = 'a'
while 1:

    if t == 'a':
        if len(Sa) == 0:
            winner = 'A'
            break
        t = Sa[0]
        Sa = Sa[1:]


    elif t == 'b':
        if len(Sb) == 0:
            winner = 'B'
            break
        t = Sb[0]
        Sb = Sb[1:]

    else:
        if len(Sc) == 0:
            winner = 'C'
            break
        t = Sc[0]
        Sc = Sc[1:]


print(winner) 


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int x, y, temp;

  while (1) {
    scanf ("%d %d", &x, &y);
    if (x ==0 && y ==0)
      break;

    if (x > y) {
      temp = x;
      x = y;
      y = temp;
    }
    printf ("%d %d\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

#define ll long long

using namespace std;

// bitcount
int bitcount(ll k) {
	int res = 0;
	while (k) {
		if (k & 1) ++res;
		k >>= 1;
	}
	return res;
}

// kビットグレイコードを生成
vector<ll> graycode(int k) {
	vector<ll> res;
	for (ll v = 0LL; v < (1LL << k); ++v)
		res.push_back(v ^ (v >> 1));
	return res;
}

int h, w;
vector<ll> line, colum; // カルノーマップ
// 0からtまでの経路
vector<pair<ll, ll>> route(pair<ll, ll> t) {
	ll x = t.second, y = t.first;
	vector<pair<ll, ll>> res;
	if (y % 2) {
		for (ll xx = 0; xx < x; ++xx)
			for (ll yy = (xx % 2) ? colum.size() - 1 : 0; yy >= 0 && yy < colum.size(); yy += (xx % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll yy = 0; yy < y; ++yy)
			for (ll xx = (yy % 2) ? line.size() - 1 : x; xx >= x && xx < line.size(); xx += (yy % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll xx = line.size() - 1; xx >= x; --xx)
			for (ll yy = (xx % 2) ? y : colum.size() - 1; yy < colum.size() && yy >= y; yy += (xx % 2) ? 1 : -1)
				res.emplace_back(yy, xx);
	}
	else {
		for (ll yy = 0; yy < y; ++yy)
			for (ll xx = (yy % 2) ? line.size() - 1 : 0; xx >= 0 && xx < line.size(); xx += (yy % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll xx = 0; xx < x; ++xx)
			for (ll yy = (xx % 2) ? colum.size() - 1 : y; yy >= y && yy < colum.size(); yy += (xx % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll yy = colum.size() - 1; yy >= y; --yy)
			for (ll xx = (yy % 2) ? x : line.size() - 1; xx < line.size() && xx >= x; xx += (yy % 2) ? 1 : -1)
				res.emplace_back(yy, xx);
	}
	return res;
}
// cの指す値を取得
ll number(pair<ll, ll> c) {
	return ((colum[c.first] << w) | line[c.second]);
}

signed main() {
	int n; ll a, b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a == b)	cout << "NO" << endl;
		else cout << "YES" << endl << a << " " << b;
	}
	else if (bitcount(a) % 2 == bitcount(b) % 2) {
		cout << "NO" << endl;
	}
	else {
		// カルノーマップを生成
		h = (n + 1) / 2; w = n / 2;
		line = graycode(w); colum = graycode(h);
		// a^bの座標を求める
		pair<ll, ll> c = { -1LL,-1LL };
		for (ll i = 0; i < (1LL << h); ++i)
			for (ll j = 0; j < (1LL << w); ++j)
				if (number({ i,j }) == (a ^ b))
					c = { i,j };
		// 0からa^bのルートを求める
		vector<pair<ll, ll>> r = route(c);
		// 答えの出力
		cout << "YES" << endl;
		for (auto p : r)
			cout << (a ^ number(p)) << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
long long memo[MAXN];

int main(){
	int n, W, wi;
	long long vi;
	scanf("%d %d", &n, &W);
	for (int i = 0; i < n; i++){
		scanf("%d %lld", &wi, &vi);
		for (int j = W - wi; j >= 0; j--)
			memo[j + wi] = max(memo[j + wi], memo[j] + vi);
	}
	printf("%lld\n", memo[W]);
	return 0;
}

Measured memory_bytes: 4556
def main():
    import sys
    from collections import Counter
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    par = [n for n in range(N)]
    rank = [0 for _ in range(N)]

    def find(x):
        if par[x] == x:
            return x
        par[x] = find(par[x])
        return par[x]

    def union(x, y):
        x = find(par[x])
        y = find(par[y])
        if x == y:
            return
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    
    for m in range(M):
        a, b = [int(x)-1 for x in input().strip().split()]
        union(a, b)
    
    for n in range(N):
        find(n)
    
    ans = Counter(par)
    print(max(ans.values()))

if __name__ == '__main__':
    main()

Measured memory_bytes: 33928
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    ans+=min(a,k);
    k-=min(a,k);
    k-=min(k,b);
    ans-=min(k,c);
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    const int NMAX=20;
    vector<int> a(n);
    vector<vector<vector<int>>> xy(NMAX,vector<vector<int>>(NMAX,vector<int>(2)));
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++){
            cin>>xy[i][j][0]>>xy[i][j][1];
            xy[i][j][0]--;
        }
    }
    int maxnum=0;
    for(int bit=0;bit<1<<n;bit++){
        vector<int> ishonest(n,0);
        int sum=0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)) {
                ishonest[i]=1;
                sum++;
            }
        }
        bool flag=true;
        for(int i=0;i<n;i++){
            for(int j=0;j<a[i];j++){
                if(1==ishonest[i]&ishonest[xy[i][j][0]]!=xy[i][j][1]){
                    flag=false;
                }
            }                     
        }  
        if(flag){
                if(maxnum<sum){
                    maxnum=sum;
                }  
            }       
    }
    cout<<maxnum<<endl;
    return 0;
}

Measured memory_bytes: 384
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(N)]

mx=10**9
ans=mx
def dfs(i,tt,level):
    global ans
    if i==N:
        return
    tt+=C[i][0]
    lev=[]
    for j in range(M):
        lev.append(level[j]+C[i][j+1])
    ok=True
    for x in lev:
        if x<X:
            ok=False
            break
    if ok:
        ans=min(ans,tt)
    for j in range(i+1,N):
        dfs(j,tt,lev)
        

for i in range(N):
    dfs(i,0,[0]*M)

if ans==mx:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.0001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	const ll INF = 100100100100;
	ll k, i, j, n, m, r, d[10], md[210][210], least = INF;
	for (i = 0; i < 200; i++) {
		for (j = 0; j < 200; j++) {
			if (i == j) md[i][j] = 0;
			else md[i][j] = INF;
		}
	}
	cin >> n >> m >> r;
	for (i = 0; i < r; i++) {
		cin >> d[i];
		d[i]--;
	}
	for (i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		md[a][b] = c;
		md[b][a] = c;
	}
	for (k = 0; k < n; k++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				md[i][j] = min(md[i][j], md[i][k] + md[k][j]);
			}
		}
	}
	sort(d, d + r);
	do {
		ll cnt = 0;
		for (i = 0; i < r - 1; i++) {
			if (md[d[i]][d[i + 1]] >= INF) {
				cnt = INF;
				break;
			}
			cnt += md[d[i]][d[i + 1]];
		}
		least = min(least, cnt);
	} while (next_permutation(d, d + r));
	cout << least << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <iomanip>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<double> vec(N);

    double bun = 0.0;

    for(int i=0;i<N;i++){

        cin >> vec[i];

        bun += 1.0/vec[i];

    }

    cout << setprecision(9) << 1.0/bun << endl;

    return 0;
}

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

using namespace std;

int32_t main()
{
    char c;
    cin >> c;

    if(c == 'A')
        cout << "T";
    else if(c == 'T')
        cout << "A";
    else if(c == 'C')
        cout << "G";
    else
        cout << "C";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
     
typedef long long Long;

const int N = 3e5 + 233;
int n, a[N];
Long sum[N], f[N];

int main(void) {
  ios::sync_with_stdio(0);
  cin >> n;
  rep (i, n) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    f[i] = f[i - 1] + (i & 1 ? 1 : -1) * a[i];
  }
  if (n % 2 == 0) {
    Long B = 0, W = 0;
    rep (i, n) i & 1 ? B += a[i] : W += a[i];
    cout << max(W, B) << " " << min(W, B) << "\n";
  } else {
    auto check = [] (Long mid) {
		   Long pre = 0;
		   for (int i = 2; i <= n; i += 2) {
		     if (f[i - 1] - pre >= mid)
		       pre = min(pre, f[i]);
		   }
		   return f[n] - pre >= mid;
		 };
    Long l = -1e18, r = 1e18;
    while (l < r) {
      Long mid = l + (r - l + 1) / 2;
      if (check(mid)) l = mid;
      else r = mid - 1;
    }
    Long B = 0, W = 0;
    rep (i, n) i & 1 ? B += a[i] : W += a[i];
    cout << max(B, W + l) << " " << sum[n] - max(B, W + l) << "\n";    
  }
}


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

typedef pair<int, int> ii;
#define st first
#define nd second

const int N = 1505;

int n, m, d[N], check[N];
vector<ii> G[N];
queue<ii> res;
vector<int> trace[N][N];

int main() {
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		G[u].push_back(ii(v, w));
		G[v].push_back(ii(u, w));
	}
	int mx_total = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) d[j] = 1e9;
		d[i] = 0;
		priority_queue<ii, vector<ii>, greater<ii> > pq;
		pq.push(ii(0, i));
		int mx = 0;
		while(pq.size()) {
			int u = pq.top().nd, du = pq.top().st;
			pq.pop();
			mx = max(mx, d[u]);
			if(du != d[u]) continue;
			for(int k = 0; k < G[u].size(); ++k) {
				int v = G[u][k].st, w = G[u][k].nd;
				if(d[v] > du + w) {
					trace[i][v].clear();
					d[v] = du + w;
					pq.push(ii(d[v], v));
				}
				if(d[v] == du + w) trace[i][v].push_back(u);
			}
		}
		if(mx > mx_total) {
			mx_total = mx;
			while(res.size()) res.pop();
		}
		//if(i == 1) cout << d[2] << ' ' << d[3] << ' ' << d[4] << endl;
		if(mx == mx_total) {
			for(int k = 1; k <= n; ++k) if(d[k] == mx) res.push(ii(i, k));
		}
	}
	//cout << mx_total << endl;
	while(res.size()) {
		ii u = res.front(); res.pop();
		//cout << u.st << ' ' << u.nd << endl;
		check[u.nd] = true;
		for(int i = 0; i < trace[u.st][u.nd].size(); ++i) {
			int v = trace[u.st][u.nd][i];
			res.push(ii(u.st, v));
		}
	}
	int cnt = 0;
	for(int i = 1; i <= n; ++i) if(!check[i]) cnt++;
	cout << cnt << '\n';
	for(int i = 1; i <= n; ++i) if(!check[i]) cout << i << '\n';
}


Measured memory_bytes: 163484
/*
	AOJ_0124: League Match Score Sheet
*/
#include	<iostream>
#include	<string>
#include	<algorithm>
#include	<vector>

using namespace std;

class Teams {
private:
	int num;
	string name;
	int score;
public:
	Teams(){
		score = 0;
	}
	Teams(int n, string c, int s){
		num = n;
		name = c;
		score = s;
	}
	void showTeams(void) {
		cout << name << ',' << score << endl;
	}
	bool operator<(const Teams& another) const {
		if (score != another.score) { return score > another.score; }
		return num < another.num;
	}
};

int main(void) {
	int N, c_win, c_draw, c_lose, c_score;
	string c_name;
	bool isDo = false;

	while (1) {
		vector<Teams> T;

		cin >> N;
		if (N == 0) { break; }
		if (isDo == true) { cout << endl; }

		for (int i = 0; i < N; i++) {
			cin >> c_name >> c_win >> c_lose >> c_draw;
			c_score = c_win * 3 + c_draw;
			T.push_back( Teams(i, c_name, c_score) );
		}
		sort(T.begin(), T.end());
		vector<Teams>::iterator it = T.begin();
		while (it != T.end()) {
			it->showTeams();
			it++;
		}
		isDo = true;
	}

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n, k;
    cin>>n>>k;
    ll h[n+5];
    int i;
    FOR0(i, n) cin>>h[i];
    sort(h, h+n);
    ll ans = 0;
    FOR0(i, n-k)
    {
        ans += h[i];
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#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 repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

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

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;

  int N = len(S);
  vector<int> D(N);

  rep(i, N) {
    D[i] = S[i] - '0';
  }

  vector<int> sum(N + 1);
  int base = 1;
  repr(i, N - 1, 0) {
    sum[i] = sum[i + 1] + D[i] * base;
    base = (base * 10) % 2019;
    sum[i] %= 2019;
  }

  map<int, int> m;
  for (auto elem : sum)
    m[elem]++;


  int ans = 0;
  for (auto item : m) {
    auto cnt = item.se;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6740
cnt=[0,1,2,3,4,5,6,7,8,9]
n,k=map(int,input().split())
d=list(map(int,input().split()))
tmp=[]
for i in range(k):
    cnt.remove(d[i])

def digit(x):
    xt=str(x)
    for i in range(len(xt)):
        if not int(xt[i]) in cnt:
            return  False
    return  True
t=n
while t>=n:
    if digit(t):
        print(t)
        exit()
    else:
        t+=1



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

int A,B,C,X;

int slove(){
  int ans = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        int tmp = i * 500 + j * 100 + k * 50;
        if(tmp == X) ans++;
      }
    }
  }
  return ans;
}

int main(){
  scanf("%d%d%d%d", &A, &B, &C, &X);
  int ans = slove();
  printf("%d\n",ans);
  
  return 0;
}

 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll n;

int main(){
	cin>>n;
	ll ans=0;
	for(ll i=1;n-i>i*i;i++){
		if((n-i)%i==0){
			ans+=(n-i)/i;
		}
	}
	cout<<ans<<endl;
}
	

Measured memory_bytes: 256
gets
n  = gets.split(' ').map{|i| i.to_i}
nl = n.length
ct = 0
for i in 0..nl-1
  min = i
  for j in (i+1)..nl-1
    if n[min] > n[j]
      min = j
    end
  end
  if i != min
    n[i], n[min] = n[min], n[i]
    ct += 1
  end
end

puts n.join ' '
puts ct

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
const int P=1e9+7;
int n,a,b,ans,tmp1,tmp2;
int qpow (int a,int b) {
	int res=1;
	while (b) {
		if (b&1) {res=(1ll*res*a)%P;}
		a=(1ll*a*a)%P;
		b>>=1;
	}
	return res;
}
int c (int n,int m) {
	int res=1;
	for (int i=1;i<=m;i++) {
		res=(1ll*res*(n-i+1))%P;
		res=(1ll*res*qpow(i,P-2))%P;
	}
	return res;
}
int main () {
	scanf("%d%d%d",&n,&a,&b);
	ans=qpow(2,n);
	tmp1=c(n,a),tmp2=c(n,b);
	printf("%d\n",((ans-tmp1-tmp2-1)%P+P)%P);
	return 0;
}

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

int main(){
	int x, y, temp;

	while(1){
		cin>>x>>y;
		if(x==0 && y==0) break;
		if(x > y){
			temp = x;
			x = y;
			y = temp;
		}

		cout<<x<<" "<<y<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i * ((n / i) * (n / i + 1) / 2);
    }
    cout << ans << nl;
}

signed main() {
    judge();
    boost;
    solve();
}


Measured memory_bytes: 3644
N = int(input())
R = []
B = []
for _ in range(N):
    R.append(list(map(int,input().split())))
for _ in range(N):
    B.append(list(map(int,input().split())))
B.sort()
flag = [1 for i in range(N)]
ans = 0
for i in range(N):
    MAX = -1
    index = -1
    for j in range(N):
        if flag[j] and R[j][0] < B[i][0] and R[j][1] < B[i][1] and MAX < R[j][1]:
            MAX = R[j][1]
            index = j
    if index == -1:
        continue
    flag[index] = 0
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  int N, S;
  cin >> N;
  S=0;
  vector<int> W(N);
  vector<int> U(N-1);
  vector<int> V(N-1);
  vector<int> X(N-1);
  for (int i=0; i<N; i++) {
    cin >> W[i];
  }
  for (int j=0; j<N; j++) {
    S=S+W[j];
  }
  for (int k=0; k<N-1; k++) {
    U[k]=0;
    V[k]=0;
  }
  for (int l=0; l<N-1; l++) {
    for (int m=0; m<l+1; m++) {
      U[l]=U[l]+W[m];
    }
    V[l]=S-U[l];
  }
  for (int n=0; n<N-1; n++) {
    X[n]=max((U[n]-V[n]),(V[n]-U[n]));
  }
  sort(X.begin(),X.end());
  cout << X[0] << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,n=0,m=0,f=0,i;
    string A;
    cin>>a;
    //a+=-1;
    int S[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int H[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int C[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int D[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    while(n!=a){
        cin>>A;
        cin>>m;
        m+=-1;
        if(A=="S"){
            S[m]=0;
        }else if(A=="H"){
            H[m]=0;
        }else if(A=="C"){
            C[m]=0;
        }else if(A=="D"){
            D[m]=0;
        }
        n++;
    }
    while(f!=13){
        if(S[f]!=0){
            cout<<"S "<<S[f]<<endl;
        }
        f++;
    }
    f=0;
    while(f!=13){
        if(H[f]!=0){
            cout<<"H "<<H[f]<<endl;
        }
        f++;
    }
    f=0;
    while(f!=13){
        if(C[f]!=0){
            cout<<"C "<<C[f]<<endl;
        }
        f++;
    }
    f=0;
    while(f!=13){
        if(D[f]!=0){
            cout<<"D "<<D[f]<<endl;
        }
        f++;
    }
    f=0;
}



Measured memory_bytes: 3124
H,W,K=map(int,input().split())
if W==1:
    print(1)
    exit()
dp=[[0]*W for _ in range(H+1)]

dp[0][0]=1
import itertools
A=list(itertools.product([1,0],repeat=W-1))
#print(A)
B=[]

for a in A:
    flg=True
    for i in range(len(a)-1):
        if a[i+1]==1 and a[i]==1:
            flg=False
    if flg:
        B.append(a)
#print(B)
for h in range(1,H+1):
    for b in B:
        for w in range(W):
            if w==0:
                dp[h][w]+=dp[h-1][w]*(1-b[w])+dp[h-1][w+1]*b[w]
            elif w==W-1:
                dp[h][w]+=dp[h-1][w]*(1-b[w-1])+dp[h-1][w-1]*b[w-1]
            else:
                dp[h][w]+=dp[h-1][w]*(1-b[w-1])*(1-b[w])+dp[h-1][w-1]*b[w-1]+dp[h-1][w+1]*b[w]
#print(dp)
#print(dp[H-1][K-1])
print(dp[H][K-1]%1000000007)


Measured memory_bytes: 42352
#abc076c
import fnmatch,sys

s=raw_input()
t=raw_input()
for i in xrange(len(s)-len(t),-1,-1):
 if fnmatch.fnmatch(t,s[i:i+len(t)]):
  res=s[:i]+t+s[i+len(t):]
  res=res.replace('?','a')
  print res
  sys.exit()
print 'UNRESTORABLE'


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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
	Fastest
	
    string ch;
    
    cin >> ch;
    
    int len = ch.size(), mx = 0;
    
    for(int i = 0; i < len; i++)
    {
		if(ch[i] == 'A' || ch[i] == 'T'  || ch[i] == 'C'  || ch[i] == 'G' )
		{
			int coun = 1;
			
			//cout << ch[i];
			
			for(int j = i+1; j < len; j++)
			{
				if(ch[j] == 'A' || ch[j] == 'T'  || ch[j] == 'C'  || ch[j] == 'G')
				{
					coun++;
					//cout << ch[i];
				}
				else break;
			}
			//cout << endl;
			mx = max(mx, coun);
		}
	}
	
	cout << mx << endl;
	
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())

def dsum(x):
    return sum(map(int,list(str(x))))

ans = INF
for a in range(1,N):
    b = N-a
    ans = min(ans,dsum(a)+dsum(b))

print(ans)


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

int main(){
  string S;
  cin >> S;
  int min=0;

  map<int,int> num;


  for(int i =0; i < S.size(); i++){
    if( num.count((int)S.at(i) - 97) > 0)
      num.at((int)S.at(i) - 97)++;
    else
      num[(int)S.at(i) - 97]=1;
  }

  for(int i=0;i<26;i++){
    if(num.count(i) == 0)
      break;
    else
      min++;
  }

  if(min==26)
    cout << "None" << endl;
  else
    cout << (char)(min+97) << endl;

}


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

#define int long long int 

int32_t main()
{
    string str;
    cin>>str;
    int l=0;
    while(l<str.size() && str[l]!='A')
    l++;
    int r=str.size()-1;
    while(r>=0 && str[r]!='Z')
    r--;
    cout<<r-l+1<<endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) {
        cin >> A[i] >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.rbegin(), B.rend());
    if(N%2) {
        cout << B[N/2] - A[N/2] + 1 << endl;
    } else {
        cout << (B[N/2-1] + B[N/2]) - (A[N/2-1] + A[N/2]) + 1 << endl;
    }
    return 0;
}


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

int main() {
	int n;
	scanf("%d", &n);
	int mi = 1e9 + 10;
	int ma = 0;
	rep(i, n) {
		int a;
		scanf("%d", &a);
		ma = max(ma, a);
		mi = min(mi, a);
	}
	printf("%d\n", ma - mi);
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    string A, B; cin >> A >> B;
    ll ans = 0;
    REP (i, A.size())
        if (A[i] == B[i]) ++ans;

    cout << ans << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double

int main()
{
  ll n,a,b,d;
  cin>>n>>a>>b;
  d=b-a;
  if (d%2) {
    cout << (min(a - 1, n - b) + (d + 1) / 2)<<endl;
  } else {
    cout<<(d/2)<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        final int INF = -(int) 1e6;
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        int[] ABC = new int[3];
        for (int i = 0; i < 3; i++) {
            ABC[i] = sc.nextInt();
            sum += ABC[i];
        }
        //選ばれてないもの(A=0, B=1, C=2)が入る
        int[] s = new int[N];
        for (int i = 0; i < N; i++) {
            String str = sc.next();
            switch (str) {
                case "AB":
                    s[i] = 2;
                    break;
                case "BC":
                    s[i] = 0;
                    break;
                case "AC":
                    s[i] = 1;
                    break;
            }
        }

        if (sum == 0) {
            System.out.println("No");
        } else if (sum == 1) {
            StringBuilder strb = new StringBuilder("Yes\n");
            boolean possible = true;
            for (int i = 0; i < N; i++) {
                int x = next(s[i]);
                int y = next(x);
                if (ABC[s[i]] == 1) {
                    possible = false;
                } else {
                    ABC[x] = 1 - ABC[x];
                    ABC[y] = 1 - ABC[y];
                    strb.append((ABC[x] == 1) ? "ABC".charAt(x) : "ABC".charAt(y));
                    strb.append("\n");
                }
            }
            if (possible) {
                System.out.println(strb.toString());
            } else {
                System.out.println("No");
            }
        } else if (ABC[next(s[0])] == 0 && ABC[next(next(s[0]))] == 0) {
            System.out.println("No");
        } else {
            StringBuilder strb = new StringBuilder("Yes\n");
            for (int i = 0; i < N; i++) {
                int x = next(s[i]);
                int y = next(x);
                int choice = 0;
                if (i < N-1 && ABC[x] == 1 && ABC[y] == 1) {
                    if (s[i + 1] == x) {
                        ABC[x]--;
                        ABC[y]++;
                        choice = y;
                    } else {
                        ABC[x]++;
                        ABC[y]--;
                        choice = x;
                    }
                } else {
                    if (ABC[x] > ABC[y]) {
                        ABC[x]--;
                        ABC[y]++;
                        choice = y;
                    } else {
                        ABC[x]++;
                        ABC[y]--;
                        choice = x;
                    }
                }
                strb.append("ABC".charAt(choice));
                strb.append("\n");
            }
            System.out.println(strb.toString());
        }
    }

    private static int next(int x) {
        return (x + 1) % 3;
    }

    private static boolean isAllNonNegative(int[] vals) {
        boolean result = true;
        for (int val : vals) {
            if (val < 0) {
                result = false;
            }
        }
        return result;
    }
}


Measured memory_bytes: 59932
#include <stdio.h>
#include <memory.h>

char map[21][21];
int sum;
void snake(int x,int y){
    if(map[y][x+1] == '.'){
        sum++;
        map[y][x+1]=0;
        snake(x+1,y);
    }
    if(map[y+1][x] == '.'){
        sum++;
        map[y+1][x]=0;
        snake(x,y+1);
    }
    if(x != 0){
    if(map[y][x-1] == '.'){
        sum++;
        map[y][x-1]=0;
        snake(x-1,y);
    }
    }
    if(y != 0){
    if(map[y-1][x] == '.'){
        sum++;
        map[y-1][x]=0;
        snake(x,y-1);
    }
    }
}

int main(void){
    int w,h,start[2],i,o,sign;
    for(;scanf("%d %d",&w,&h),h;){
        memset(map,0,sizeof(map));
        sum=0;
        sign=0;
        for(i=0;i<h;i++){
            scanf("%s",map[i]);
            if(sign == 0){
                for(o=0;o<w;o++)
                    if(map[i][o] == '@'){
                        sign=1;
                        start[0]=o;
                        start[1]=i;
                    }
            }
        }
        snake(start[0],start[1]);
        printf("%d\n",sum+1);
    }
    return 0;
}

Measured memory_bytes: 632
n = gets.chomp.to_i
d, x = gets.chomp.split(" ").map(&:to_i)
ans = x + n

n.times do
    a = gets.chomp.to_i
    i = 1
    while a*i+1 <= d do
        ans += 1
        i += 1
    end
end

puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  int N;
  cin >> N;
  cout << ((N+1)*N)/2 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {

	string S;
	cin >> S;
	
	vector<int> cnt(2, 0);	//長さ2の配列に答えを入れる。0初期化

	for (int i = 0; i < S.size(); i++)
	{
		// '1' - '0' == 1
		// '0' - '0' == 0
		cnt[S[i] - '0']++;

		//こう書くのが普通
		//if (S[i] == '0') cnt[0]++;
		//else cnt[1]++;
	}

	int ans = min(cnt[0], cnt[1]) * 2;

	cout << ans << endl;
}

Measured memory_bytes: 512
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        a: [usize; m],
    };
    let mut c = vec![0; n + 1];
    for &a_i in a.iter() {
        c[a_i] = 1;
    }
    let mut r = 0;
    for i in x..n {
        r += c[i];
    }
    let mut l = 0;
    for i in 0..x {
        l += c[i];
    }
    let ans = std::cmp::min(l, r);
    println!("{}", ans);
}


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

 int  main() 
{ 
	long long  n;
	cin>>n;
    long long  a[n];
    long long  cnt[200005]={0};
    for(long long  i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    vector<long long > v;
    for(long long  i=0;i<200005;i++){
        long long  z=cnt[i];
        long long  k=(z*(z-1))/2;
        v.push_back(k);
    }
    long long  s=0;
    for(long long  i=0;i<v.size();i++){
        s=s+v[i];
    }
    long long  ans;
    for(long long  i=0;i<n;i++){
        long long  p=cnt[a[i]];
        long long  h=(p*(p-1))/2;
        p=p-1;
        long long  d=(p*(p-1))/2;
        ans=s-h+d;
        cout<<ans<<endl;
        
    }
    return 0;
}
    
    


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

int main() {
  int N, K;
  cin >> N >> K;
  int d, a;
  int count = 0;
  vector<int> A(N+1,0);
  for (int i=0; i<K; i++) {
    cin >> d;
    for (int j=0; j<d; j++) {
      cin >> a;
      A.at(a)++;
    }
  }
  for (int i=1; i<=N; i++) {
    if(A.at(i)==0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    {
        cout << "Possible" << endl;
    }
    else
        cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

from fractions import gcd

def f(i, l, r):
  return r//i - (l-1)//i

cnt = f(c, a, b) + f(d, a, b) - f((c*d)//gcd(c, d), a, b)

print(b - a + 1 - cnt)
  


Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
ll d[200100];
int m;
ll t[200100];
map<ll, ll> ma;

int main(void) {
	cin >> n;
	rep(i, n)	cin >> d[i];
	cin >> m;
	rep(i, m) cin >> t[i];
	rep(i, n) ma[d[i]]++;
	bool f = true;
	rep(i, m) {
		if(ma[t[i]] > 0) ma[t[i]]--;
		else f = false;
	}
	if(f) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 15872
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String b = sc.next();

    if(b.equals("A")){
      System.out.println("T");
    }
    if(b.equals("T")){
      System.out.println("A");
    }
    if(b.equals("C")){
      System.out.println("G");
    }
    if(b.equals("G")){
      System.out.println("C");
    }
  }
}


Measured memory_bytes: 19796
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    cout << ((a == 1)?((b == 2)?3:2):1) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		if (s.substring(s.length() - 1, s.length()).equals("s")) {
			System.out.println(s + "es");

		} else {
			System.out.println(s + "s");
		}

	}
}

Measured memory_bytes: 38384
S = input()
n = len(S)
s = [int(S[i]) for i in range(n)]
def solve(i, su, re):
    if i == n - 1:
        return(su + re * 10 + s[i])
    else:
        return(solve(i + 1, su + re * 10 + s[i], 0) + solve(i + 1, su, re * 10 + s[i]))
print(solve(0,0,0))

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  set<string> list;
  map<string, int> m;
  rep(i, 0, n){
    string s;
    cin >> s;
    list.insert(s);
    if(m.count(s))
      m[s]++;
    else
      m[s] = 1;
  }
  
  int mx = 0;
  
  auto itr1 = list.begin();
  rep(i, 0, list.size()){
    chmax(mx, m[*itr1]);
    itr1++;
  }
  
  auto itr2 = list.begin();
  rep(i, 0, list.size()){
    if(m[*itr2] == mx)
      cout << *itr2 << endl;
    itr2++;
  }
  
  return 0;
  
}

Measured memory_bytes: 34872
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int main() {

	double R; cin >> R;
	double ans = R * 2 * PI;
	cout << fixed << setprecision(10) << ans << endl;
}



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

using namespace std;

#define MAXN 100100

typedef long long ll;

int n;
bool type[MAXN];
string s;

bool check(bool lier, bool eq, char c) {
  if (c == 'o') {
    return ((lier == false && eq) || (lier && eq == false));
  } else {
    return ((lier == false && eq == false) || (lier && eq));
  }
}
  

bool solve() {
  for (int i = 1; i < n - 1; i++) {
    int truth = type[i] ? 0 : 1;
    if (s[i] == 'x') truth = 1 - truth;
    type[i+1] = (truth) ? type[i-1] : !type[i-1];
  }
  if (!check(type[0], (type[n-1] == type[1]), s[0])) return false;
  if (!check(type[n-1], (type[n-2] == type[0]), s[n-1])) return false;
  return true;
}

void Print() {
  for (int i = 0; i < n; i++) {
    if (type[i]) cout << 'W';
    else cout << 'S';
  }
  cout << endl;
}
  
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> s;
  for (int i = 0; i < 4; i++) {
    type[0] = i & 1;
    type[1] = i & 2;
    if (solve()) {
      Print();
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, a[N], x, y, z;
ll ans = 1;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1;i<=n;i++) cin >> a[i];
 	bool tag = true;
 	for(int i=1;i<=n;i++)
 	{
 		int cnt = 0;
 		if(a[i]==x) cnt++;
 		if(a[i]==y) cnt++;
 		if(a[i]==z) cnt++;
 		if(!cnt) 
 		{
 			tag = false;
 			break;
 		}
 		ans = ans*cnt%mod;
 		if(a[i]==x) x++;
 		else if(a[i]==y) y++;
 		else z++;
 	}
 	if(!tag) cout << 0;
 	else cout << ans;
	return 0;
}


Measured memory_bytes: 640
n, q = gets.split.map(&:to_i)
s = gets.chomp

at = [0]
c = 0
for i in (0..s.length - 2)
  at[i+1] = s[i,2] == 'AC' ? c += 1 : c
end

q.times do
  l, r = gets.split.map(&:to_i)
  puts at[r-1] - at[l-1]
 end

Measured memory_bytes: 5372
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
int main()
{
	int n ;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a[3];
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (a[2]*a[2]==a[1]*a[1]+a[0]*a[0]) { cout << "YES"<<endl; }
		else { cout << "NO"<<endl; }
		
		}
	return 0;

}

Measured memory_bytes: 3044
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer a = sn.nextInt();
		Integer b = sn.nextInt();
		Integer c = sn.nextInt();
		
		int x = c - (a - b);
		
		System.out.println((x < 0) ? 0 : x);
	}
	
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int n, ans = 1e9;

int solve(int p) {
	return p ? solve(p / 10) + p % 10 : 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i)
		ans = min(ans, solve(i) + solve(n - i));
	printf("%d", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    char a[60][60];
    int main()
    {
    	int h,w;
    	cin>>h>>w;
    	for(int i=0;i<h;i++)
    		for(int j=0;j<w;j++)
    			cin>>a[i][j];
    	for(int i=0;i<h;i++)
    		for(int j=0;j<w;j++)
    		{
    			bool yes=false;
    			if(a[i][j]=='#')
    			{
    				if(i-1>=0 && a[i-1][j]=='#') yes=true;
    				if(i+1<h  && a[i+1][j]=='#') yes=true;
    				if(j-1>=0 && a[i][j-1]=='#') yes=true;
    				if(j+1<w  && a[i][j+1]=='#') yes=true;
    				if(yes==false)
    				{
    					cout<<"No";
    					return 0;
    				}
    			}
    		}
    	cout<<"Yes";
    	return 0;
    }

Measured memory_bytes: 256