akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int n, x, a[30]; bool dp[1000001], prime[1000001];
int main() {
	for(int i = 2; i <= 1000000; i++) prime[i] = true;
	for(int i = 2; i <= 1000; i++) {
		if(!prime[i]) continue;
		for(int j = i * i; j <= 1000000; j += i) prime[j] = false;
	}
	while(scanf("%d%d", &n, &x), n) {
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		for(int i = 0; i < x; i++) dp[i + 1] = false; dp[0] = true;
		for(int i = 1; i <= x; i++) {
			for(int j = 0; j < n; j++) {
				if(i - a[j] >= 0) dp[i] = dp[i] || dp[i - a[j]];
			}
		}
		bool flag = false;
		for(int i = x; i >= 1; i--) {
			if(dp[i] && prime[i]) {
				printf("%d\n", i); flag = true; break;
			}
		}
		if(!flag) printf("NA\n");
	}
}

Measured memory_bytes: 4528
import fractions

def prime_factorize(n):
    a = {}
    while n % 2 == 0:
        if 2 in a:
            a[2] += 1
        else:
            a[2] = 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f in a:
                a[f] += 1
            else:
                a[f] = 1
            n //= f
        else:
            f += 2
    if n != 1:
        if n in a:
            a[n] += 1
        else:
            a[n] = 1
    return a

A,B = map(int,input().split())

G = fractions.gcd(A,B)

F = prime_factorize(G)

print(len(F) + 1)


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

int main(){
    ll r,D,x;
    cin >> r >> D >> x;
    rep(i,10){
        x = r*x - D;
        cout << x <<endl;
    }
}

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair


void solve()
{
    string s;
    cin >> s;
    if(s[1] == s[2] && (s[0] == s[1] || s[2] == s[3]))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll k,s;
    cin>>k>>s;
    ll ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int z=s-i-j;
            if(z>=0 && z<=k){
                ans+=1;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
    int N;
    string W[100];
    cin>>N;
    for(int i=0;i<N;i++){
        if(i==0){
            cin>>W[i];
            continue;
        }

        cin>>W[i];
        if(W[i-1][W[i-1].length()-1]!=W[i][0]){
            cout<<"No"<<endl;
            return 0;
        }

        for(int j=0;j<i;j++){
            if(W[i]==W[j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}

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

int main() {
  double n,k,ans=0;
  cin >> n >> k;
  for(int i = 1;i <= n;i++) {
    double score = i;
    double j = 1;
    while(score < k){
      j=j*2;
      score = score*2;
    };
    ans+=(1/j);
  };
  ans=ans/n;
  cout << fixed << setprecision(12);
  cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, merge
from collections import defaultdict
import sys
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N, Q = map(int, line_input())
    events = []
    for _ in range(N):
        s, t, x = map(int, line_input())
        events.append((s-x, 1, x))
        events.append((t-x, -1, x))
    for _ in range(Q):
        d = int(single_input())
        events.append((d, 2, d))
    events = sorted(events)

    constructions = []
    under_construction = defaultdict(bool)
    ans = ''
    for _, flag, coord in events:
        if flag == 1:
            heappush(constructions, coord)
            under_construction[coord] = True
        elif flag == -1:
            under_construction[coord] = False
        else:
            while constructions:
                x = heappop(constructions)
                if under_construction[x]: # x is the minimum coordinate under construction
                    heappush(constructions, x)
                    ans += str(x) + '\n'
                    break
            else: # no constructions
                ans += '-1\n'
    print(ans)
    
if __name__ == "__main__":
    solve()

Measured memory_bytes: 100864
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  double a[n];
  double sum = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  sum /= 4*m;
  sort(a,a+n);
  if(a[n-m] >= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	string s; cin >> s;

	cout << ((s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ? "Bad" : "Good" )<< endl;

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int min_diff = 753;
  
  for (int i = 0; i < S.length() - 2; i++) {
    string s = S.substr(i, 3);
    int n = stoi(s);
    
    min_diff = min(min_diff, abs(753 - n));
  }
  
  cout << min_diff << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	string s;
	cin>>s;
	ll cnt1=0,cnt0=0;
	for(ll i=0;i<s.length();i++)
	if(s[i]=='0')
	cnt0++;
	else
	cnt1++;
	cout<<2*min(cnt0,cnt1);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007
//ワーシャルフロイド
void warshall_floyd(vector<vector<ll>> &d,int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin >> h >> w;
    vector<vector<ll>> A(10,vector<ll>(10,0));
    vector<vector<ll>> Wall(h,vector<ll>(w,0));
    REP(i,10){
        REP(j,10){
            cin >> A[i][j];
        }
    }
    warshall_floyd(A,10);
    ll cnt= 0;
    REP(i,h){
        REP(j,w){
            ll a;
            cin >> a;
            if(a!=-1) cnt+= A[a][1];
        }
    }
    cout << cnt << endl;
}

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

typedef long long ll;
const int N = 2e5;
ll nc2[N+100];
int cnt[N+100],a[N+100];

int main()
{
	for(int i=0;i<=N;i++){
		nc2[i] = 1ll*i*(i-1);
		nc2[i]/=2;
	}
	int n;
	scanf("%d",&n);
	ll ans = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		ans += nc2[cnt[i]];
	}
	for(int i=1;i<=n;i++){
		int cur = cnt[a[i]];
		printf("%lld\n",ans-nc2[cur]+nc2[cur-1]);
	}
}


Measured memory_bytes: 6844
n,m = map(int,input().split())
a = []
for i in range(n):
    li = list(map(int,input().split()))	
    a.append(li)
c =[]
for i in range(m):
    li = list(map(int,input().split()))	
    c.append(li)

for i in range(n):
    k = 1
    l = abs(a[i][0]-c[0][0])+abs(a[i][1]-c[0][1])
    for j in range(m):
        if l > abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]):
            l = abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
            k = j+1
    print(k)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	static int popCount(String x){
		int cnt = 0;
		for(char c : x.toCharArray()){
			if(c == '1'){
				++cnt;
			}
		}
		return cnt;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String X = sc.next();
		int popCount = popCount(X);
		int memo[] = new int[popCount + 2];
		memo[0] = 0;
		for(int i = 1 ; i < memo.length ; ++i){
			int cnt = 0;
			int x = i;
			while(x != 0){
				int p = Integer.bitCount(x);
				x = x % p;
				++cnt;
			}
			memo[i] = cnt;
		}
		int mods[][] = new int[N][3];
		mods[0][0] = 1;
		mods[0][1] = 1;
		mods[0][2] = 1;
		for(int i = 1 ; i < N ; ++i){
			if(popCount > 0){
				mods[i][0] = (mods[i - 1][0] * 2) % popCount;				
			}
			mods[i][1] = (mods[i - 1][1] * 2) % (popCount + 1);
			if(popCount > 1){
				mods[i][2] = (mods[i - 1][2] * 2) % (popCount - 1);				
			}
		}
		int M[] = new int[3];
		for(int i = 0 ; i < N ; ++i){
			if(X.charAt(i) == '1'){
				M[1] = (mods[N - 1 - i][1] + M[1]) % (popCount + 1);
				if(popCount > 0){
					M[0] = (mods[N - 1 - i][0] + M[0]) % popCount;					
				}
				if(popCount > 1){
					M[2] = (mods[N - 1 - i][2] + M[2]) % (popCount - 1);					
				}

			}
		}
		for(int i = 0 ; i < N ; ++i){
			int c = X.charAt(i) == '1' ? 1 : 0;
			if(c == 0){
				int mod = M[1];
				mod = (mod + mods[N - 1 - i][1]) % (popCount + 1);				
				System.out.println(memo[mod] + 1);
			}else{
				if(popCount == 1){
					System.out.println(0);
				}else{
					int mod = M[2];
					mod = (mod - mods[N - 1 - i][2] + popCount - 1) % (popCount - 1);								
					System.out.println(memo[mod] + 1);					
				}
			}
		}
	}
}


Measured memory_bytes: 66800
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RangeUpdateQuery {
	int n;
	vector<int>d;
	RangeUpdateQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	void update(int a, int b, int x = -1, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;

		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			if (x >= 0)d[k] = x;
			return;
		}
		else {
			if (d[k] != INF)d[2 * k] = d[2 * k + 1] = d[k], d[k] = INF;
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
	int find(int i) {
		update(i, i + 1);
		return d[n + i];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeUpdateQuery ruq(n);
	rep(z, 0, q) {
		int com; cin >> com;
		if (com) {
			int i; cin >> i;
			cout << ruq.find(i) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			ruq.update(s, t+1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
  cin>>a;
	if(a.sz==3)
		rev(a);
	cout<<a<<endl;
}

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

using namespace std;

const int N = 110;
int n, k, cnt[N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d %d", &n, &k);
	
	for (int i = 0; i < k; i++){
		int d;
		scanf("%d", &d);
		for (int j = 0; j < d; j++){
			int x;
			scanf("%d", &x);
			cnt[x]++;
		}
	}

	int ans = 0;

	for (int i = 1; i <= n; i++){
		ans += (cnt[i] == 0);
	}

	printf("%d\n", ans);

	return 0;
}

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

int n,m,k;
int mp[10][10];
int main(){
    cin >> n >> m >> k;getchar();
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            mp[i][j] = (getchar() == '#');
        }
        getchar();
    }

    int ans = 0;

    for(int i = 0;i < (1<<n);i++){
        for(int j = 0;j < (1<<m);j++){
            int sum = 0;
            for(int x = 0;x < n;x++){
                for(int y = 0;y < m;y++){
                    sum += (mp[x][y] & ((i>>x)&1) & ((j>>y)&1));
                }
            }
            if(sum == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
//abc102
int main(){
    bool flag = true;
    string s;
    int cnt=0;
    cin >> s;
    if(s[0] != 'A') flag = false;

    for(int i=1;i<s.size();i++){
        if(isupper(s[i])){
            if(s[i] == 'C') cnt++;
            if(i == 1 || i == s.size()-1 || s[i] != 'C') flag = false;
        }
    }
    if(flag && (cnt == 1)) cout << "AC" << endl;
    else cout << "WA" << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

bool isprime(int x){
    for(int i = 2; i*i <= x; i++){
        if(x % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    int x; cin>>x;
    while(1){
        if(isprime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define endl '\n'

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

int count(int x){
	int res=0;
	while(x){
		++res;
		x-=x&-x;
	}
	return res;
}

vector<vector<ii>> test;
vector<int> h;
bitset<20> vis;
bool ok=true;

void dfs(int x){
	if(vis[x])
		return;
	vis[x]=true;
	for(auto &u:test[x]){
		if(u.ss==1 && h[u.ff]==0){
			h[u.ff]=1;
			dfs(u.ff-1);
		}
		else if(u.ss==0&&h[u.ff]==0)
			h[u.ff]=2;
		else if(u.ss==1&&h[u.ff]==2)
			ok=false;
		else if(u.ss==0&&h[u.ff]==1)
			ok=false;
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n,ans=0;
	cin>>n;
	test = vector<vector<ii>>(n,vector<ii>());
	for(int i=0;i<n;++i){
		int a;
		cin>>a;
		test[i].resize(a);
		for(int j=0;j<a;++j){
			cin>>test[i][j].ff>>test[i][j].ss;
		}
	}
	for(int i=0;i<(1<<n);++i){
		h = vector<int>(n+1,0);
		ok = true;
		for(int j=0;j<n;++j){
			if((i&(1<<j))!=0){
				h[j+1]=1;
				for(int k=0;k<sz(test[j]);++k){
					if(test[j][k].ss == 1 && h[test[j][k].ff]==0)
						h[test[j][k].ff]=1;
					else if(test[j][k].ss==0 && h[test[j][k].ff]==0)
						h[test[j][k].ff]=2;
				}
			}	
		}
		vis.reset();
		//cout<<"ok e="<<ok<<" ";
		for(int j=0;j<n;++j){
			if(h[j+1]==1){
				dfs(j);
			}
		}
		//cout<<"i="<<i<<" ok="<<ok<<endl;
		if(ok && count(i) > count(ans))
			ans=i;
	}
	cout<<count(ans)<<endl;
	return 0;
}

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

int main() {
    string a,b,aa;
    int yes;
    cin>>a>>b;
    aa=a+a;
    if (string(aa).find(b) != string::npos) 
    { yes=1; }
    else yes=0;
   if(a.size()!=b.size()) yes=0;
   if (yes==1) 
    { cout<<"Yes"<<endl; }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    auto as = readln.split.to!(long[]);

    auto af = as[0];
    int x;
    while (af%2 == 0) {
        af /= 2;
        ++x;
    }
    foreach (a; as[1..$]) {
        int y;
        while (a%2 == 0) {
            a /= 2;
            ++y;
        }
        if (x != y) {
            writeln(0);
            return;
        }
    }

    auto d = as[0] / 2;
    foreach (a; as[1..$]) {
        d = d / gcd(d, a/2) * a/2;
        if (d > M) {
            writeln(0);
            return;
        }
    }
    writeln(M/d - M/(d*2));
}

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

int main(){
  long long int A0, B0, C0;
  long long int K;
  long long int MAX = 1;
  for(int i=0; i<18; ++i){
    MAX *= 10;
  }
  cin >> A0 >> B0 >> C0 >> K;
  if(abs(A0 - B0) > MAX){
    cout << "Unfair" << endl;
    return 0;
  }
  if(K%2==0){
    cout << A0 - B0 << endl;
  }else{
    cout << B0 - A0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        String str = sc.next();
        int a_counter = 0;
        int b_counter = 0;
        
        
        for(int i = 0; i < 3; ++i) {
            char c = str.charAt(i);
            if(c == 'A') ++a_counter;
            else ++b_counter;
        }
        
        if((a_counter > 0) && (b_counter >0)) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- f
  unless (all (==0) xs) $ do
    solve xs <$> f >>= print
    main
  where f = map read <$> words <$> getLine
  
solve :: [Int] -> [Int] -> Int
solve [a, b, c, d, e] [na, nb, nc] | hl >= d = hl * e + sum' bs
                                   | otherwise = min (sum' ls) (d * e + sum' (f d ls))
  where (as, bs) = partition (\(x,_) -> x >= e) ls
        ls = sortBy (flip compare) [(a,na),(b,nb),(c,nc)]
        hl = (sum . map snd) as
        sum' = sum . map (\(x, y) -> x * y)
        f _ [] = []
        f x ((y,z):zs) | x >= z = f (x-z) zs
                       | otherwise = (y, z-x) : zs



Measured memory_bytes: 4088
#include<iostream>
#include<string>
using namespace std;
int main()
{
    long long n,i;
    string s;
    cin>>n>>s;
    if(n%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        for(i=0;i<=(n/2)-1;i++)
        {
            if(s[i]!=s[i+(n/2)])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    string s;
    cin>>n>>s;
    bool f=true;
    if(n%2)f=false;
    else rep(i,n/2){
        if(s[i]!=s[i+n/2])f=false;
    }
    Yes(f);
}

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

int a,b,k;

int main()
{
	scanf("%d%d%d",&a,&b,&k);
	int i,d=__gcd(a,b),cnt=0;
	for(i=d;i;--i)
	{
		if(d%i==0) ++cnt;
		if(cnt==k)
		{
			printf("%d\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int W, a, b;
	scanf("%d %d %d", &W, &a, &b);

	if (abs(a - b) <= W) return !printf("0\n");
	return !printf("%d\n", abs(abs(a - b) - W));
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

MOD=10**9+7
n,k=map(int,input().split())

if k>=n-1:
  k=n-1

inv_table = [0]+[1]
for i in range(2,k+1):
  inv_table+=[inv_table[MOD%i]*(MOD-int(MOD/i))%MOD]

comb_sum=1
fact=1
comb1=1
comb2=1
for i in range(1,k+1):
  comb1=(comb1*(n-i+1)*inv_table[i])%MOD
  comb2=(comb2*(n-i)*inv_table[i])%MOD
  comb=(comb1*comb2)%MOD
  comb_sum+=comb

print(comb_sum%MOD)

Measured memory_bytes: 11052
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadInts();
            var coin = 0;
            var ans = 0;
            while (coin<abc[2])
            {
                ans++;
                coin += abc[0];
                if (ans % 7 == 0)
                {
                    coin += abc[1];
                }
            }
            WriteLine(ans);
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }


        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        public static void debuglist(List<int> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debuglist(List<string> x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(int[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
        public static void debugarray(string[] x)
        {
            foreach (var item in x)
            {
                WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 17976
# 09-Computation-Min_Max_and_Sum.py

# ????°????????????§??????????¨????
# n ????????´??° ai(i=1,2,...n)?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

# Input
# ??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai ????????????????????§?????????????????????
# Output
# ????°????????????§??????????¨????????????????????????§????????????????????????????????????

# Constraints
# 0<n???10000
# ???1000000???ai???1000000
# Sample Input
# 5
# 10 1 5 4 17
# Sample Output
# 1 17 37

num_min = 1000001
num_max = -1000001
num_sum = 0
num = int(input())

# a = []
# a = [ *map(int,input().split() ) ]
a = input().split()

for i in range(num):
	a[i]=int(a[i])

for i in range(num):
	if a[i]<num_min:
		num_min = a[i]

	if a[i]>num_max:
		num_max = a[i]

	num_sum+=a[i]

print("{0} {1} {2}".format(num_min,num_max,num_sum) );

Measured memory_bytes: 8420
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<=8&&b<=8)
		{
			System.out.println("Yay!");
		}
		else
		{
			System.out.println(":(");
		}
		
	}
}

Measured memory_bytes: 21076
#include <stdio.h>

/*


square1001 は、電光掲示板に整数 1 が表示されているのを見ました。
 彼は、電光掲示板に対して、以下の操作 A, 操作 B をすることができます。
•操作 A： 電光掲示板に表示する整数を「今の電光掲示板の整数を 2 倍にしたもの」に変える。
•操作 B： 電光掲示板に表示する整数を「今の電光掲示板の整数に K を足したもの」に変える。

square1001 は、操作 A, 操作 B 合計で N 回 行わなければなりません。 
そのとき、N 回の操作後の、電光掲示板に書かれている整数として考えられる最小の値を求めなさい。

2^n-2^(n+1)がKを上回ったらKを足すようにしたほうが小さくなる。
整数をAnsとおく。初期値が1。
で、2^n=Ans,2^(n+1)=Ans*2だから、結局Ans>Kということ。
その手順で最小の数を作れば十分。
*/

int main(void) {
	// your code goes here
	
	int N,K,Ans=1;
	scanf("%d",&N);
	scanf("%d",&K);
	
	for(int i=0;i<N;i++){
		if( Ans <= K)
			Ans*=2;
		else	
			Ans+=K;
	}
	
	printf("%d\n",Ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int f(int x){
    int res = 0;
    while(x%2==0&&x>=1){
        x/=2;
        res++;
    }
    return res;
}

ll gcd(int a,int b){
    int c;
    while(a%b){
        c = b;
        b = a%b;
        a = c;
    }
    return b;
}

ll lcm(int a,int b){
    return a/gcd(a,b)*b;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        a[i]/=2;
    }
    int t = f(a[0]);
    rep(i,n){
        if(f(a[i])!=t){
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;
    ll l  = 1;
    rep(i,n){
        l = lcm(l,a[i]);
        if(l>m){
            cout << 0 << endl;
            return 0;
        }
    }
    m/=l;
    int ans = (m+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int n,k,i,j,w[7] = {0};
	int s[10][7] = {
		{0,1,1,1,1,1,1},
		{0,0,0,0,1,1,0},
		{1,0,1,1,0,1,1},
		{1,0,0,1,1,1,1},
		{1,1,0,0,1,1,0},
		{1,1,0,1,1,0,1},
		{1,1,1,1,1,0,1},
		{0,1,0,0,1,1,1},
		{1,1,1,1,1,1,1},
		{1,1,0,1,1,1,1}
		};
	while(scanf("%d",&n),n != -1){
		for(i = 0;i <= 6;i++){w[i] = 0;}
		for(i = 1;i <= n;i++){
			scanf("%d",&k);
			for(j = 0;j <= 6;j++){
				if(s[k][j] != w[j]){
					printf("1");
				}
				else{
					printf("0");
				}
				w[j] = s[k][j];
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>

using namespace std;

int main()
{
	int n,T,c,t;
	int a[1001]={1001};
	cin>>n>>T;
	int min=1001;
	for(int i=0;i<n;i++)
	{
		cin>>c>>t;
		a[c]=t;
		if(a[c]<=T&&c<min)
			min=c;
	}
	if(min==1001)
		 cout<<"TLE"<<endl;
	else cout<<min<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  int a;
  cin >> a;
  if(a <= 111) cout << 111 << endl;
  else if(a <= 222) cout << 222 << endl;
  else if(a <= 333) cout << 333 << endl;
  else if(a <= 444) cout << 444 << endl;
  else if(a <= 555) cout << 555 << endl;
  else if(a <= 666) cout << 666 << endl;
  else if(a <= 777) cout << 777 << endl;
  else if(a <= 888) cout << 888 << endl;
  else if(a <= 999) cout << 999 << endl;

}


Measured memory_bytes: 256
from bisect import bisect_right

n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [0] * (n + 1)
h = [0] * (n + 1)
s = [0] * (n + 1)

for i, (f, g) in enumerate(xh):
    x[i], h[i] = f, g
x[n] = 10 ** 10 + 1
ans = 0
for i in range(n):
    if i > 0:
        s[i] += s[i - 1]
    h[i] -= s[i]
    if h[i] > 0:
        num = 0 - - h[i] // a
        ans += num
        s[i] += num * a

        j = bisect_right(x, x[i] + d * 2)
        s[j] -= num * a
print(ans)


Measured memory_bytes: 62724
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n), b(n);
	rep(i, n) cin >> a[i], b[i] = a[i];
	sort(all(a));
	int mx = a[a.size() - 1];
	rep(i, n){
		if(b[i] == mx){
			cout << a[a.size() - 2] << endl;
		}
		else cout << a[a.size() - 1] << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 500001
 
struct node{
  struct node *parent;
  struct node *left;
  struct node *right;
  int key;
};
 
typedef struct node Node;
Node *root,*NIL;
 
void Insert(int id){
  Node *x,*y,*z;
  y = NIL;
  x = root;
 
  z = (Node *)malloc(sizeof(Node));
  z->key = id;
  z->left = NIL;
  z->right = NIL;
   
  while(x!=NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
 
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
   
};
void Inorder(Node *id){
  if(id==NIL)return;
 
  Inorder(id->left);
  printf(" %d",id->key);
 
  Inorder(id->right);
};
void Preorder(Node *id){
  if(id==NIL)return;
 
  printf(" %d",id->key);
   
  Preorder(id->left);
  Preorder(id->right);
};
int Find(Node *id, int key){
  int count = 0;
  if(id==NIL){
    //printf("no\n");
    return 0;
  }
  if(key==id->key){
    //printf("yes\n");
    //count++;
    return 1;
  }
  if(key < id->key){
  count += Find(id->left,key);
  }
  else count +=  Find(id->right,key);
  return count;
   
};
int main(){
 
  int i,j,n,id,find,count=0,judge;
  char order[MAX];
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){ //parent
    scanf("%s",order);
    if(strcmp(order,"insert")==0){
      scanf("%d",&id);
      Insert(id);
    }
    else if(strcmp(order,"find")==0){
      scanf("%d",&find);
      judge = Find(root,find);
      if(judge == 1){
    printf("yes\n");
      }
      else{
    printf("no\n");
      }
    }
    else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++)
  {
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[n-1];
}


Measured memory_bytes: 3996
/**
*    author:  velengel
*    created: 12.06.2020 17:35:29
*    to run & test the code, type below command.
*    cptest abc000_a
**/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n);++i)
#define each(i, mp) for(auto& i:mp)
typedef long long ll;
using namespace std;

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

  ll a;
  double b;
  cin >> a >> b;
  ll b_ = b * 100+0.5;
  cout << ll(a * b_) / 100 << endl;

  return 0;
}

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

string solver(string s) {
    int length = s.size();
    //cout << s << endl;
    if (s.substr(max(0, length-5)) == "dream") return s.substr(0, length-5);
    else if (s.substr(max(0, length-5)) == "erase") return s.substr(0, length-5);
    else if (s.substr(max(0, length-6)) == "eraser") return s.substr(0, length-6);
    else if (s.substr(max(0, length-7)) == "dreamer") return s.substr(0, length-7);
    else return "false";
}

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

    while (1) {
        if (S.size() == 0) {cout << "YES" << endl; break;}
        else if (S == "false") {cout << "NO" << endl; break;}
        S = solver(S);
    }
}

Measured memory_bytes: 512
from heapq import heapify, heappush, heappop

X, Y, Z = map(int, input().split())
W = X+Y+Z
ABCs = [tuple(map(int, input().split())) for _ in range(W)]

ABCs.sort(key=lambda x: x[0]-x[1])

sumBCs = [0] * W
sumB = sumC = 0
PQ = []
for i in range(W):
    A, B, C = ABCs[i]
    heappush(PQ, (B-C, i))
    sumB += B
    if len(PQ) > Y:
        _, j = heappop(PQ)
        A, B, C = ABCs[j]
        sumB -= B
        sumC += C
    sumBCs[i] = sumB+sumC

sumACs = [0] * W
sumA = sumC = 0
PQ = []
for i in reversed(range(W)):
    A, B, C = ABCs[i]
    heappush(PQ, (A-C, i))
    sumA += A
    if len(PQ) > X:
        _, j = heappop(PQ)
        A, B, C = ABCs[j]
        sumA -= A
        sumC += C
    sumACs[i] = sumA+sumC

ans = 0
for i in range(Y-1, W-X):
    sumABC = sumBCs[i] + sumACs[i+1]
    ans = max(ans, sumABC)

print(ans)


Measured memory_bytes: 41600
#include<stdio.h>
int main(void){
  int a,b,n;
	scanf("%d",&n);
	for(a = 1; a <= 9; a++){
	  for(b = 1; b <= 9; b++){
	  	if(n == a*b){
	  		printf("Yes");
	  		return 0;
	  	}
	  }
	}
	printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

ll solve (ll x) {
    if (x <= 2) {
        return x;
    }
    x-= 2;
    return x % 3 + 2 + solve(x / 3);
}

/*********************GoodLuck***********************/
int main () {
    IOS();

    ll n;
    cin >> n;
    cout << solve(n+1) - 1<< endl;
}



Measured memory_bytes: 3200
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
int main() {
    quick
int n,cur=1,x,m; cin>>n; m=n;
while(m--){
    cin>>x;
    if(x==cur){cur++;}
}
if(cur==1){cout<<-1;}
else{cout<<n-(cur-1);}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k) ans += p[i];

  cout << ans << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+60;
int n,q;
int a[maxn],c[maxn],vis[maxn],num[maxn];
struct data
{
    int l,r,pos;
    bool friend operator<(const data& x,const data& y)
    {
        return x.r<y.r;
    }
}e[maxn];
int lowbit(int x)
{
    return x&(-x);
}
void updata(int i,int k)
{
    while(i<=n)
    {
        c[i]+=k;
        i+=lowbit(i);
    }

}
int getsum(int i)
{
    int res=0;
    while(i>0)
    {
        res+=c[i];
        i-=lowbit(i);
    }
    return res;
}
int main()
{
    cin>>n>>q;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=q;++i)  cin>>e[i].l>>e[i].r,e[i].pos=i;
    sort(e+1,e+q+1);
    int next=1;
    for(int i=1;i<=q;++i)
    {
        for(int j=next;j<=e[i].r;j++)
        {
            if(vis[a[j]]) updata(vis[a[j]],-1);
            updata(j,1);
            vis[a[j]]=j;
        }
         next=e[i].r+1;
            num[e[i].pos]=getsum(e[i].r)-getsum(e[i].l-1);
    }
    for(int i=1;i<=q;++i) cout<<num[i]<<endl;
    return 0;
}

Measured memory_bytes: 17404
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n)
  {
    ll a;
    cin >> a;
    while (a % 2 == 0)
    {
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
int c[2]={0,1};
int main( ){
    int n,i = 0,k,t;
    int re[3000]={0};
    cin>>n;
    if(n == 0){
    	printf("0\n");
    	return 0;
    }
	while(n != 0){
		k = n % (-2);
		t = n / (-2);
		if(k < 0){
			k -= (-2);
			t++;
		}
		i++;
		n = t;
		re[i] = c[k];
	}
    for (;i >= 1;i--){
        cout<<re[i];
    } 
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <queue>

using namespace std;

vector<vector<int>> to;
vector<bool> used;

void dfs(int x) {
	if (!used[x]) {
		used[x] = true;
		for (auto y: to[x]) {
			dfs(y);
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;

	int x, y, z;

	to.assign(n, vector<int>());
	for (int i = 0; i < m; i++) {
		cin >> x >> y >> z;
		x--;
		y--;

		to[x].emplace_back(y);
		to[y].emplace_back(x);
	}

	int ans = 0;
	used.assign(n, false);

	for (int i = 0; i < n; i++) {
		if (used[i]) {
			continue;
		}
		ans++;

		dfs(i);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8832
#!/usr/bin/env python3

def solve(a,b,k):
    l = []
    for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
    return(l[-k])

def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 18:38:36 2020

@author: Paras
"""

n = int(input())
stocks = list(map(int, input().split()))
yens = 1000
curr_stocks = 0

for i in range(n-1):
    if stocks[i+1]>stocks[i]:
        yens=(yens//stocks[i])*(stocks[i+1])+(yens-((yens//stocks[i])*stocks[i]))

print(yens)        

Measured memory_bytes: 9184
#include<iostream>

using namespace std;

int main(void)
{
  int a,b,c;
  cin>>a>>b>>c;
  
  int sum1=a+b,sum2=b+c,sum3=c+a;
  int min=sum1;
  if(min>sum2){min=sum2;}
  if(min>sum3){min=sum3;}
  
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 384
class Segtree():
    INT_MIN=-10**9
    ZERO=0

    def __init__(self,n):
        self.max_index=0
        self.n=1
        while self.n<n:
            self.n=self.n*2
        self.ary=[[self.ZERO,i] for i in xrange(2*self.n-1)]

    def max_update(self,k,a):
        k+=self.n-1
        self.ary[k][0]+=a
        while k>0:
            k=(k-1)/2
            self.ary[k][0]=max(self.ary[k*2+1][0],self.ary[k*2+2][0])
            if self.ary[k*2+1][0]>self.ary[k*2+2][0]:
                self.ary[k][1]=self.ary[k*2+1][1]
            elif self.ary[k*2+1][0]<self.ary[k*2+2][0]:
                self.ary[k][1]=self.ary[k*2+2][1]
            else:
                self.ary[k][1]=min(self.ary[k*2+1][1],self.ary[k*2+2][1])


n,q=map(int,raw_input().split())
par=Segtree(n)
for i in xrange(q):
    a,v=map(int,raw_input().split())
    a-=1
    par.max_update(a,v)
    print par.ary[0][1]-(par.n-1)+1,par.ary[0][0]

Measured memory_bytes: 288296
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = ReadLine();

        var sum = N.ToCharArray()
                   .Select(c => int.Parse(c.ToString()))
                   .Sum();
        if (int.Parse(N) % sum == 0) {
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 11220