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

#define HashConst 128
#define HashMax 128456903

long long int powerdiv(long long int a, int b){
	if (b == 0) return 1;
	if (b == 1) return a;
	if (b == 2) return a*a % HashMax;
	if (b % 2 == 0) {
		long long int dum = powerdiv(a, b/2);
		return dum * dum % HashMax;
	}
	if (b % 2 != 0) {
		long long int dum = powerdiv(a, (b - 1)/2);
		return (dum * dum % HashMax) * a % HashMax;
	}
	return 0;
}

long long int modP(long long int a){
	long long int res = a % HashMax;
	if (res < 0) return res + HashMax;
	return res;
}

void RabinKarp(vector< vector<char> > T, vector< vector<char> > P, int H, int W, int R, int C){
	
	if (H < R || W < C) return;

	long long int hashconst1 = powerdiv(HashConst, R * C - C);
	long long int hashconst2 = powerdiv(HashConst, C);
	long long int hashconst3 = powerdiv(HashConst, C - 1);

	long long int P_Hash = 0;
	for (int i = 0; i < R; i++){
		for (int j = 0; j < C; j++){
			P_Hash = modP(P_Hash * HashConst + P[i][j]);
		}
	}

	long long int T_Hash_Top = 0;

	for (int i = 0; i < R; i++){
		for (int j = 0; j < C; j++){
			T_Hash_Top = modP(T_Hash_Top * HashConst + T[i][j]);
		}
	}

	long long int T_Hash = T_Hash_Top;

	for (int i = 0; i < H - R + 1; i++){
		for (int j = 0; j < W - C + 1; j++){
			long long int minusdif = 0;
			long long int plusdif = 0;
			if (j == 0){
				if (i != 0){
					for (int k = 0; k < C; k++){
						minusdif = modP(minusdif * HashConst + T[i - 1][k]);
						plusdif = modP(plusdif * HashConst + T[i + R - 1][k]);
					}
					T_Hash = modP((T_Hash_Top - modP(minusdif * hashconst1)) * hashconst2 + plusdif);
					T_Hash_Top = T_Hash;
				}
			}else{
				for (int k = 0; k < R; k++){
					minusdif = modP(minusdif * hashconst2 + T[i + k][j - 1]);
					plusdif = modP(plusdif * hashconst2 + T[i + k][j + C - 1]);
				}
				T_Hash = modP((T_Hash - modP(minusdif * hashconst3)) * HashConst + plusdif);
			}
			if (T_Hash == P_Hash) cout << i << " " << j << endl;
			//cout <<T_Hash<<endl;
		}
	}
}

int main(){
	int H, W, R, C;
	
	cin >> H >> W;
	vector< vector<char> > Field(H, vector<char>(W, 0));
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			scanf(" %c", &Field[i][j]);
		}
	}
	cin >> R >> C;
	vector< vector<char> > Pattern(R, vector<char>(C, 0));
	for (int i = 0; i < R; i++){
		for (int j = 0; j < C; j++){
			scanf(" %c", &Pattern[i][j]);
		}
	}
	
	RabinKarp(Field, Pattern, H, W, R, C);
			
	return 0;
}


Measured memory_bytes: 6772
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110000;
vector<pi64> e[2][maxn];
int vis[2][maxn];
i64 val[2][maxn];

bool dfs(int h, int v, i64 p, i64 &p1, i64 &p2) {
    if (p < -1e12 || p > 1e12) return false;
    if (!vis[h][v]) {
//        cerr << h << ' ' << v << ' ' << p << '\n';
        val[h][v] = p;
        vis[h][v] = 1;
        uin((h ? p1 : p2), p);
    } else return val[h][v] == p;
    if (val[h][v] != p) return false;
    for (auto w: e[h][v]) {
        if (!dfs(h ^ 1, w.fi, w.se - p, p1, p2)) return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int r, c, n;
    cin >> r >> c >> n;
    forn(i, n) {
        int x, y, w;
        cin >> x >> y >> w;
        --x; --y;
        e[0][x].pb(mp(y, w));
        e[1][y].pb(mp(x, w));
    }

    bool ok = true;
    forn(i, r) {
        if (vis[0][i]) continue;
        i64 p1 = 1e18, p2 = 1e18;
        if (!dfs(0, i, 0, p1, p2) || p1 + p2 < 0) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 19200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main()
{
	int i;
	long long int N;
	int keta = 0;
	long long int tasikame = 0;
	long long int ketaketa = 1;
	int kotae = 0;

	scanf("%llu", &N);
	unsigned long long int m = N;
	while (m != 0) {
			m /= 10;
			keta++;
			tasikame += 9 * ketaketa;
			ketaketa *= 10;
	}
	ketaketa /= 10;

	while (tasikame > N) {
		tasikame -= 1 * ketaketa;
	}
	while (tasikame != 0) {
		kotae += tasikame % 10;
		tasikame /= 10;
	}

	printf("%u", kotae);
	return 0;
}
/*受け取るｎ１６けたもある時は、unsigned long long int で宣言して、%lluで受け取る。*/

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
// #define endl '\n' 
#define pb push_back             
#define fi first 
#define se second 
#define pll pair<long long, long long> 
#define all(v) v.begin(), v.end() 
  
using namespace std; 
   
typedef long long int ll; 
   
mt19937 rnd(1337); 

ostream& operator<< (ostream& a, const pll& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

ostream& operator<< (ostream &a, const vector<ll>& b) {
    for (auto& k : b) cout << k << " ";
    return a;
}

ostream& operator<< (ostream &a, const vector<pll>& b) {
    for (auto& k : b) cout << k << " ";
    return a;
}

#ifdef HOME 
  #define dbg(x) cout << #x << " : " << (x) << '\n';
#else
  #define dbg(x)
#endif                 
   
const ll INF = (ll)1e18; 
const ll MOD = 1000 * 1000 * 1000 + 7, MOD2 = 274876858367;                                                                                    
const ll maxn = (ll)1e5 + 10, L = 10;

ll cnt[4];
  
int main() { 
  #ifdef HOME 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
  #else 
    ios_base::sync_with_stdio(0); cin.tie(0); 
    //freopen("olympiad.in", "r", stdin); 
    //freopen("olympiad.out", "w", stdout); 
  #endif    
  ll n;
  cin >> n;

  while (n--) {
    string s;
    cin >> s;
    if (s == "AC")
      ++cnt[0];
    else if (s == "WA")
      ++cnt[1];
    else if (s == "TLE")
      ++cnt[2];
    else if (s == "RE")
      ++cnt[3];
  }
  cout << "AC x " << cnt[0];
  cout << "\nWA x " << cnt[1];
  cout << "\nTLE x " << cnt[2];
  cout << "\nRE x " << cnt[3];
  return 0;                    
} 















                  

Measured memory_bytes: 3592
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '+')a++;
		if (s[i] == '-')b++;
	}
	cout << a - b << 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);                 
         
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int ans = 0;
        
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                 int Z = S - x - y;
                 if(Z >= 0 && Z <= K)
                       ans++;
            }            
        }
        
        System.out.println(ans);
       
    }            
}
        
        
        

Measured memory_bytes: 21972
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:24:34 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
a = na()

ans = 0
flag = True
while flag:
    for i in range(N):
        if a[i] % 2 == 1:
            flag = False
        else:
            a[i] //= 2
    if flag:
        ans += 1
    else:
        break

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> X(N);
  for (int i = 0; i < N; i++) {
    cin >> get<0>(X.at(i)) >> get<1>(X.at(i));
    get<1>(X.at(i)) = 100 - get<1>(X.at(i));
    get<2>(X.at(i)) = i + 1;
  }
  sort(X.begin(), X.end());
  for (int i = 0; i < N; i++) {
    cout << get<2>(X.at(i)) << endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int flag=1;
  while(true) {
    if(flag) {
      C -= B;
      if(C<=0) {
	cout << "Yes" << endl;
	break;
      }
    } else {
      A -= D;
      if(A<=0) {
	cout << "No" << endl;
	break;
      }
    }
    flag = 1-flag;
  }
  return 0;
}


Measured memory_bytes: 3636
import math
import collections

N = int(input())

pre = []
for x in range(1, 101):
    max_y = int(math.sqrt(10000 - x * x))
    for y in range(1, max_y + 1):
        max_z = int(math.sqrt(10000 - x * x - y * y))
        for z in range(1, max_z + 1):
            pre.append(x * x + y * y + z * z + x * y + y * z + z * x)

count = collections.Counter(pre)

for i in range(1, N + 1):
    if i not in count:
        print(0)
    else:
        print(count[i])

Measured memory_bytes: 30372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll A, B, N; cin >> A >> B >> N;
    if (N >= B-1) {
        cout << (A*(B-1))/B - A*((B-1)/B) << endl;
        return 0;
    }
    cout << (A*N)/B - A*(N/B) << endl;

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        map<char, int> cnt;
        REP(i, n) {
            char c;
            cin >> c;
            cnt[c] ++;
        }
        ll ans = 1;
        for (auto it : cnt) {
            ans = ans * (it.second + 1) % MOD;
        }
        cout << (ans + MOD - 1) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// Atcoder
  // Practice Problems
  // C - GCD on Blackboard
  #include <bits/stdc++.h>
  #include <iostream>
  #include <map>
  #include <queue>
  #include <set>
  #include <string>   
  #include <vector>
  #include <numeric>
  using namespace std;
  typedef long long int ll;
  typedef pair<ll, int> PLI;
  typedef pair<int, int> PII;
  const ll mxsize = 1e5 + 5;
  #define fastIO                                                                 \
    ios_base::sync_with_stdio(false);                                            \
    cin.tie(NULL);                                                               \
    cout.tie(NULL);
  
  /******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
  
  ll pow(ll x, ll n) {
    if (n == 0)
      return 1ll;
    ll temp;
    temp = pow(x, n / 2);
    if (n % 2 == 0)
      return temp * temp;
    else
      return x * temp * temp;
  }

  ll gcd(ll a, ll b) {
    if (b == 0)
      return a;
    return gcd(b, a % b);
  }

  int sum_digit(int val) {
    if (val < 0)
      return -1;
    if (val == 0)
      return 0;
    int ans = 0;
    while (val > 0) {
      ans = ans + val % 10;
      val = val / 10;
    }
    return ans;
  }

  ll count_div(ll l, ll r, ll val) {
    if (l % val == 0)
      return (((r / val) - (l / val)) + 1);
    else
      return ((r / val) - (l / val));
  }

  int powmod(int x, int y, int m) {
    int res = 1;
    // x = x % mod;
    while (y > 0) {
      if (y & 1)
        res = (res * x) % m;
      cout << res << endl;
      y = y / 2;
      cout << x << endl;
      x = (x * x) % m;
    }
    // cout << res << endl;
    return res;
  }
  /******************************************** CODE STARTS FROM HERE *************************************************/ 
  
  int main()
  {
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i = 0 ; i < n ; i++) cin >> arr[i];
    ll left[n + 1] = {0};
    ll right[n + 1] = {0};
    for(ll i = 0 ; i < n ; i++) left[i + 1] = gcd(left[i] , arr[i]);
    for(ll i = n - 1 ; i >= 0 ; i--) right[i] = gcd(right[i + 1] , arr[i]);
    ll ans = 1;
    for(int i = 0 ; i < n ; i++)
    {
      ll  l = left[i];
      ll r = right[i + 1];
      ans = max(ans , gcd(l , r));
    } 
    cout << ans;
  }

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>

using namespace std;

int num[10];

bool isEnd() {
    int zero = 0, two = 0;
    for (int i=1; i<=9; ++i) {
        if (num[i] == 0) zero ++;
        if (num[i] == 2) two ++;
    }
    return zero == 8 && two == 1;
}

bool dfs() {
    bool ok;
    if (isEnd()) return true;
    for (int i=1; i<=7; ++i) {
        if (num[i] && num[i+1] && num[i+2]) {
            num[i] --; num[i+1] --; num[i+2] --;
            ok = dfs();
            num[i] ++; num[i+1] ++; num[i+2] ++;
            if (ok) return true;
        }
    }
    for (int i=1; i<=9; ++i) {
        if (3 <= num[i]) {
            num[i] -= 3;
            ok = dfs();
            num[i] += 3;
            if (ok) return true;
        }
    }
    return false;
}

int main() {
    string s;
    while (cin >> s) {
        memset(num, 0, sizeof num);
        for (int i=0; i<13; ++i) num[s[i] - '0'] ++;
        bool fst = true;
        bool ok;
        for (int i=1; i<=9; ++i) {
            if (4 <= num[i]) continue;
            num[i] ++;
            ok = dfs();
            num[i] --;
            if (ok) {
                cout << (fst ? "" : " ") << i;
                fst = false;
            }
        }
        if (fst) {
            cout << 0 << endl;
        } else {
            cout << endl;
        }
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int count=0;
  int ans=0;
  rep(i,N){
    int a, b;
    cin >> a >> b;
    if (a==b) {
      count++;
      if (count==3) {
      ans=1;
      break;
      }
    }
    else {
      count=0;
    }
  }

  if (ans==1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

int main() {
    int n,k,d;
    cin>>n>>k;
    vector<int>dp(n+1);
    for(int i=0;i<k;++i) {
        cin>>d;
        int x;
        while(d--) {
            cin>>x;
            dp[x]++;
        }
    }
    int res=0;
    for(int i=1;i<=n;++i) {
        if(dp[i] == 0)
            res++;
    }
    cout<<res;
}


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

int main() {
    int a;
    cin >> a;
    int x,y,z;
    x = a / 100;
    y = (a - x * 100) / 10;
    z = a - x * 100 - y * 10;
    cout << x + y + z;
}

Measured memory_bytes: 3624
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

def score(T):
    last=[-1]*26
    v=0
    for d in range(D):
        v+=s[d][T[d]-1]
        last[T[d]-1]=d
        for i in range(26):
            v-=c[i]*(d-last[i])
    return v

import random
best=0

for x in range(4000):
    if x==0:
        tmp=[random.randint(1, 26) for _ in range(D)]
        tbest=tmp
    else:
        tmp=[random.randint(1, 26) for _ in range(D)]
    sc=score(tmp)
    if (10**6+sc)>best:
        tbest=tmp
        best=10**6+sc
    else:
        continue


for t in tbest:
    print(t)

Measured memory_bytes: 85180
using System;
using System.Collections.Generic;
class Solve{
    public long H;
    public long W;
    public int N;
    public long[] a;
    public long[] b;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        long[] sort;
        int[] ans = new int[9];
        long[] all = new long[9*N];
        int sum = 0;
        int count = 0;
        for(int i=0;i < 9;i++){
            ans[i] = 0;
        }
        for(int i=0;i < N;i++){
            for(int j = -1;j < 2;j++){
                if(b[i]+j < W-1 && b[i]+j > 0){
                    for(int k = -1;k < 2;k++){
                        if(a[i]+k < H-1 && a[i]+k > 0){
                            all[count] = (b[i]+j)*H+a[i]+k;
                            count++;
                        }
                    }
                }
            }
        }
        sort = new long[count];
        for(int i=0;i < count;i++){
            sort[i] = all[i];
        }
        Array.Sort(sort);
        for(int i = 0;i < count-1;i++){
            int c = 1;
            while(i < count-1 && sort[i] == sort[i+1]){
                i++;
                c++;
            }
            if(i == count-2){
                ans[0]++;
            }
            ans[c-1]++;
        }
        for(int i=0;i < 9;i++){
            sum += ans[i];
        }
        Console.WriteLine((H-2)*(W-2)-sum);
        for(int i=0;i < 9;i++){
            Console.WriteLine(ans[i]);
        }
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        H = int.Parse(str[0]);
        W = int.Parse(str[1]);
        N = int.Parse(str[2]);
        a = new long[N];
        b = new long[N];
        for(int i = 0;i < N;i++){
            str = Console.ReadLine().Split(' ');
            a[i] = int.Parse(str[0])-1;
            b[i] = int.Parse(str[1])-1;
        }
    }    
}

Measured memory_bytes: 22576
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
#include<set>
#include<cctype>
#include<iomanip>
using namespace std;

struct p{
int h;
int w;
int n;
bool flag=false;
};
int main(){
ios::sync_with_stdio(false);
/***
#ifdef ONLINE_JUDGE
#else
    freopen("1.txt", "r", stdin);
#endif
***/
int totalValue=0;
    int commonPart,Apart,Bpart;
    int priceA,priceB,priceMix;

    scanf("%d%d%d",&priceA,&priceB,&priceMix);
    scanf("%d%d",&Apart,&Bpart);

    commonPart=(Apart<Bpart?Apart:Bpart);
    if(2*priceMix<priceA+priceB)
    {
        totalValue=priceMix*2*commonPart;
    }
    else
    {
        totalValue=commonPart*(priceA+priceB);
    }
    if( (Apart-commonPart)*priceA+(Bpart-commonPart)*priceB
            < (Apart-commonPart+Bpart-commonPart)*priceMix*2 )
    {
        totalValue+=(Apart-commonPart)*priceA+(Bpart-commonPart)*priceB;
    }
    else
    {
        totalValue+=(Apart-commonPart+Bpart-commonPart)*priceMix*2;
    }
    printf("%d\n",totalValue);
    return 0;

}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		String[] fiz = new String[10001];
		for (int i = 1; i <= 10000; i++) {
			if (i % 15 == 0)
				fiz[i] = "FizzBuzz";
			else if (i % 5 == 0)
				fiz[i] = "Buzz";
			else if (i % 3 == 0)
				fiz[i] = "Fizz";
			else
				fiz[i] = String.valueOf(i);
		}
		while (true) {
			int m = scanner.nextInt();
			int n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			Deque<Integer> deque = new ArrayDeque<Integer>();
			for (int i = 1; i <= m; i++) {
				deque.offer(i);
			}
			for (int i = 1; i <= n; i++) {
				String str = scanner.next();
				if (deque.size() == 1)
					continue;
				int a = deque.poll();
				if (str.equals(fiz[i])) {
					deque.offer(a);
				}
			}
			int size = deque.size();
			PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
			pq.addAll(deque);
			for (int i = 0; i < size; i++) {
				System.out.print(pq.poll());
				System.out.print(i == size - 1 ? '\n' : ' ');
			}

		}
	}
}

Measured memory_bytes: 70752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long steps = 0;
		long level;
		
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		
		level = a[0];
		
		for(int i = 0; i < n -1; i++) {
			if(level > a[i + 1]) {
				steps += (level - a[i + 1]);
			} else {
				level = a[i + 1];
			}
		}
		
		System.out.println(steps);
	}

}

Measured memory_bytes: 51400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(x) cout << (x) << "\n";
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n";
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i];
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int dsum(ll n){
    int sum = 0;
    while(n){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int msd(ll n){
    while(true){
        if(n < 10) return n;
        n /= 10;
    }
    return 0;
}

int digit(ll n){
    int ans = 1;
    while(n >= 10){
        ans ++;
        n /= 10;
    }
    return ans;
}


vector<ll> p10 {
    1ll,
    10ll,
    100ll,
    1000ll,
    10000ll,
    100000ll,
    1000000ll,
    10000000ll,
    100000000ll,
    1000000000ll,
    10000000000ll,
    100000000000ll,
    1000000000000ll,
    10000000000000ll,
    100000000000000ll,
    1000000000000000ll,
};

ll snuke(ll n){
    if(n < 9) return n+1;
    int m = msd(n), d = digit(n);
    ll ans = n+1;
    // dsum(a) == s なる a > n で最小のもの
    for(int s = 10; s <= 135; s ++){
        ll a = p10[s/9]-1 + s%9 * p10[s/9];
        while(a <= n) a += p10[d-1];
        //cout << "> " << a << "\n";
        if(ans * dsum(a) > a * dsum(ans)) ans = a;
    }

    return ans;
}

int main(void){
    Cin(int, k);
    ll s = 0;
    For(i, k){
        Cout(s = snuke(s));
        // printf("%lld : %.3f\n", s = snuke(s), (double) s / dsum(s));
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

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

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1; 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    string s;
    cin >> s;
    int N = s.size();
    int sum = 0;
    int res = 0;
    for (int i = 0; i < N; i++) {
        char c = s[i];
        int d = c-'0';
        sum += d;
        res = max(res, sum-1+ 9*(N-1-i));
    }
    res = max(res, sum);
    cout << res << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll a[60],b[60],c[60],d[60];
ll n,m,q;
ll ans=0;
void solve(vector<int>&nums,int idx)
{
	if(nums.size()==n)
	{
		// for(int i=0;i<n;i++)
		// cout<<nums[i]<<" ";
		// cout<<"\n";
		ll res=0;
		for(int i=0;i<q;i++)
		{
			if(nums[b[i]-1]-nums[a[i]-1]==c[i])
			res+=d[i];
		}
		ans=max(ans,res);
		return;
		
	}
	for(int i=idx;i<=m;i++)
	{
		nums.push_back(i);
		solve(nums,i);
		nums.pop_back();
	}
	
}

int main() {
	// your code goes here
     //ll n,m,q;
     ans=0;
     cin>>n>>m>>q;
     
     for(int i=0;i<q;i++)
     cin>>a[i]>>b[i]>>c[i]>>d[i];
     vector<int>nums;
     solve(nums,1);
     cout<<ans;
	return 0;
}

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

int count;
int w,h;
int x,y;
char map[20][20];

void tannkenn(int x,int y);

int main()
{
	while(cin>>w>>h,w&&h){
	count=0;
	for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> map[i][j];
				if(map[i][j]=='@'){
					x=i;
					y=j;
				}
			}
	}

	tannkenn(x,y);
	cout<<count<<endl;
	}
	return 0;
}

void tannkenn(int x,int y)
{
	count++;
	map[x][y]='#';

	if(x+1<h && map[x+1][y]=='.')
		tannkenn(x+1,y);
	if(y+1<w && map[x][y+1]=='.')
		tannkenn(x,y+1);
	if(x-1>=0 && map[x-1][y]=='.')
		tannkenn(x-1,y);
	if(y-1>=0 && map[x][y-1]=='.')
		tannkenn(x,y-1);
}

Measured memory_bytes: 1184
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
  char x[1000],y[10];
  int sum=0;
  cin>>y;
  for(int i=0;i<strlen(y);i++)y[i]=tolower(y[i]);
  while(1){
    cin>>x;
    if(strcmp(x,"END_OF_TEXT")==0)break;
    for(int i=0;i<strlen(x);i++)x[i]=tolower(x[i]);
    if(strcmp(x,y)==0)sum++;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1144
#c
N,M,K = map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ruia = [0]*N
ruia[0]=A[0]
for i in range(1,N):
    ruia[i]=ruia[i-1]+A[i]
ruia=[0]+ruia

ruib = [0]*M
ruib[0]=B[0]
for i in range(1,M):
    ruib[i]=ruib[i-1]+B[i]

import bisect

ans=0
for i,r in enumerate(ruia):
    nokori =K-r
    if nokori>=0:
        n_nokori = bisect.bisect(ruib,nokori)
        ans = max(ans,i+n_nokori)
#     print(i,r,nokori,n_nokori,ans)
print(ans)

Measured memory_bytes: 117868
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
const MAXN=100000
var sg [MAXN+10]int
var g [MAXN+10][]int
func dfs(now,fa int) int{
	if len(g[now])==1 && g[now][0]==fa {
		return 0
	}
	sg:=0
	for _,v:=range g[now] {
		if v!=fa {
			sg^=1+dfs(v,now)
		}
	}
	return sg
}
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n:=IO.ReadInt()
	for i:=1; i<n; i++ {
		a,b:=IO.ReadInt(),IO.ReadInt()
		g[a]=append(g[a],b)
		g[b]=append(g[b],a)
	}
	if dfs(1,0)!=0 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
	cout.Flush()
}


Measured memory_bytes: 32000
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 510;
int n, m, q, sum[N][N];



int main()
{
    scanf("%d%d%d", &n, &m, &q);
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= m; i++){
        int x, y;
        scanf("%d%d", &x, &y);
        sum[x][y]++;
    }
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j++)
            sum[i][j] += sum[i][j-1];
    for (int i = 1; i <= q; i++){
        int x, y, ret = 0;
        scanf("%d%d", &x, &y);
        for (int j = x; j <= y ;j++)
            ret += sum[j][y];
        printf("%d\n", ret);
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdlib>
#define MAX_SIZE 1001


int main()
{
    bool isRun = true;
    int len;
    int resA, resB;
    int playerA, playerB;
    while(isRun) {
        std::scanf("%d", &len);
        if (len == 0) {
            isRun = false;
        } else {
            resA = resB = 0;
            for (int i = 0; i < len; i++) {
                std::scanf("%d %d", &playerA, &playerB);
                if (playerA > playerB) resA += playerA + playerB;
                else if (playerA < playerB) resB += playerA + playerB;
                else if (playerA == playerB) {
                    resA += playerA; resB += playerB;
                }
            }
            std::printf("%d %d\n", resA, resB);
        }
    }
    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
   int a,b;cin>>a>>b;
   cout<<max(0,a-b-b)<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),N=1<<n,m=s.nextInt();
		long[] v=new long[N];
		Arrays.fill(v,Integer.MAX_VALUE);

		for(int i=0;i<m;++i){
			int w=s.nextInt();
			int f=0;
			for(int k=s.nextInt();k>0;--k)
				f|=1<<(s.nextInt()-1);
			v[f]=Math.min(v[f],w);
		}

		if(n<5)
			System.err.println(Arrays.toString(v));
		for(int i=2;i<N;++i) {
			for(int j=1;j<i;++j) {
				v[i|j]=Math.min(v[i|j],v[i]+v[j]);
			}
			if(n<5)
				System.err.println(Arrays.toString(v));
		}
		System.out.println(v[N-1]==Integer.MAX_VALUE?-1:v[N-1]);
	}
}


Measured memory_bytes: 33488
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}

func main() {
	io := newIo()
	n := io.nextInt()

	dic := map[int]int{}
	for range make([]struct{}, n) {
		a := io.nextInt()
		dic[a-1]++
		dic[a]++
		dic[a+1]++
	}
	ans := 0
	for _, cnt := range dic {
		ans = max(ans, cnt)
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 4; i++)
            {
                var tn = ReadInts();
                switch (tn[0])
                {
                    case 1:
                        WriteLine(6000 * tn[1]);
                        break;
                    case 2:
                        WriteLine(4000 * tn[1]);
                        break;
                    case 3:
                        WriteLine(3000 * tn[1]);
                        break;
                    case 4:
                        WriteLine(2000 * tn[1]);
                        break;
                    default:
                        break;
                }
            }
        }

        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); }
    }
}



Measured memory_bytes: 17936
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#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  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
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_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ll arr[n];
	input(arr,n);	
	sort(arr,arr+n);
	
	ld ans=(arr[0]+arr[1])/2.0;

	for(ll i=2;i<n;i++)
		ans=(ans/2.0+arr[i]/2.0);
	
	cout<<fixed<<" "<<setprecision(10)<<ans;
}

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

#define ll long long

using namespace std;

int main()
{
	int n;
	cin>>n;
	int p = 1000;
	int ret = n%p;
	if(ret==0)
		cout<<"0";
	else
	{
		ret = 1000-ret;
		cout<<ret;
	}
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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




int main(){
    int N, M, a, b; std::cin >> N >> M;
    std::vector<int> cnt(N, 0);
    for(int i(0); i < M; ++i){
        std::cin >> a >> b;
        ++cnt[a-1]; ++cnt[b-1];
    }
    bool okay(true);
    for(int i(0); i < N; ++i){
        if(cnt[i] % 2) okay = false;
    }
    std::cout << (okay ? "YES" : "NO") << std::endl;
    return 0;
}


Measured memory_bytes: 640
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h))
    cnt = 2 **a
    ans = (1-2**a)//(1-2)
    print(ans+cnt)
    
if __name__=='__main__':
    main()


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

using namespace std;

int main() {

	int x;
	cin >> x;

	int y = 360;
	while (1) {
		if (y % x == 0) {
			cout << y / x << endl;
			return 0;
		}
		y += 360;
	}

	return 0;

}

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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  for (int i = 1; i < N + 1; i++) {
    cin >> V[i] >> W[i];
  }
  vector<vector<int>> dp(min(N, 1 << 10) + 1, vector<int>(100001, 0));
  for (int i = 1; i < min(N, 1 << 10) + 1; i++) {
    int x = i / 2;
    for (int j = 0; j < 100001; j++) {
      dp[i][j] = dp[x][j];
      if (j - W[i] >= 0) {
        chmax(dp[i][j], dp[x][j - W[i]] + V[i]);
      }
    }
  }

  function<int(int, int)> rec = [&](int v, int l) {
    if (v < (1 << 10) + 1) return dp[v][l];
    int res = rec(v / 2, l);
    if (l - W[v] >= 0) chmax(res, rec(v / 2, l - W[v]) + V[v]);
    return res;
  };

  int Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int v, l;
    cin >> v >> l;
    cout << rec(v, l) << '\n';
  }
  return 0;
}


Measured memory_bytes: 407384
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define it vector<int>::iterator
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	vi a(m),b(m);
	rep(i,m)cin>>a[i]>>b[i];
	vector<bool>h(n+1,0);
	h[2]=true;
	rep(i,n-1){
		vector<bool>t(n+1,true);
		rep(j,m)if(!h[a[j]])t[b[j]]=false;
		rep(j,n){
			if(t[j+1]&&!h[j+1]){
				h[j+1]=true;
				cout<<j+1<<endl;
				break;
			}
		}
	}
	cout<<2<<endl;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

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

	int n; cin >> n;
	vi a(n);
	REP(i, n) cin >> a[i];

	REP2(i, 1, n) {
		REP(i, n - 1) {
			cout << a[i] << " ";
		}
		cout << a[n - 1] << "\n";
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}

	REP(i, n - 1) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T>
struct Dinic{
  struct edge{int to;T cap,rev;bool hoge,re;};
  const T Inf = 1e9;
  int V;
  std::vector<std::vector<edge>>G;
  std::vector<int> level;
  std::vector<int> iter;
  Dinic(int n):G(n),level(n),iter(n),V(n){}
  void addEdge(int from, int to, T cap, bool hoge){
    G[from].push_back((edge){to, cap, (T)G[to].size(),hoge,false});
    G[to].push_back((edge){from, 0, (T)G[from].size()-1,hoge,true});
  }
  
  void bfs(int s){
    std::fill(level.begin(),level.end(),-1);
    std::queue<int>que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
      int v = que.front();
      que.pop();
      for(int i = 0;i < G[v].size();i++){
	edge &e = G[v][i];
	if(e.cap>0 && level[e.to] < 0){
	  level[e.to] = level[v]+1;
	  que.push(e.to);
	}
      }
    }
  }
  
  T dfs(int v,int t,T f){
    if(v == t)return f;
    for(int &i = iter[v];i < G[v].size();i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
	T d = dfs(e.to, t ,std::min(f,e.cap));
	if(d > 0){
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    } 
    return 0;
  }

  T execution(int s, int t){
    T flow = 0;
    while(true){
      bfs(s);
      if(level[t] < 0)return flow;
      std::fill(iter.begin(),iter.end(),0);
      //memset(iter_,0,sizeof(iter_));
      T f;
      while((f = dfs(s,t,Inf))>0){
	flow += f;
      }
    }
  }
};

map<pair<int,int>,int>ma;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  Dinic<int>dinic(n);
  for(int i=0;i<m;i++){
    int f,t;cin>>f>>t;
    f--;t--;
    ma[mp(f,t)] = i+1;
    dinic.addEdge(f,t,1,false);
    dinic.addEdge(t,f,1,true);
  }
  int s,t;cin>>s>>t;
  s--;t--;
  cout<<dinic.execution(s,t)<<endl;
  set<int> ans;
  for(int i=0;i<n;i++){
    for(int j=0;j<dinic.G[i].size();j++){
      if(dinic.G[i][j].cap > 0){
	if(dinic.G[i][j].re == true || (dinic.G[i][j].hoge == true)){
	  if(ma[mp(i,dinic.G[i][j].to)] != 0){
	    ans.insert(ma[mp(i,dinic.G[i][j].to)]);
	  }
	}
      }
    }
  }
  cout<<ans.size()<<endl;
  for(auto a:ans)cout<<a<<endl;
  return 0;
}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A+B>=C) {
    cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }
}


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

int main()
{
    while (1)
    {
        int N, M;
        cin >> N >> M;
        if (N == 0 || M == 0)
        {
            break;
        }
        long long C[M];
        for (int i = 0; i < M; i++)
        {
            cin >> C[i];
        }
        long long x[N];
        for (int i = 0; i < N; i++)
        {
            cin >> x[i];
        }
        vector<vector<long long>> dp(N + 1, vector<long long>(256, 100000000000));
        dp[0][128] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= 255; j++)
            {
                for (int k = 0; k < M; k++)
                {
                    long long tmp = x[i] - j - C[k];
                    if (j + C[k] < 0)
                    {
                        tmp = x[i];
                        dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + tmp * tmp);
                    }
                    else if (j + C[k] > 255)
                    {
                        tmp = x[i] - 255;
                        dp[i + 1][255] = min(dp[i + 1][255], dp[i][j] + tmp * tmp);
                    }
                    else
                    {
                        dp[i + 1][j + C[k]] = min(dp[i + 1][j + C[k]], dp[i][j] + tmp * tmp);
                    }
                }
            }
        }
        long long ans = 100000000000;
        for (int i = 0; i <= 255; i++)
        {
            ans = min(ans, dp[N][i]);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 43868
import fractions
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])


    return arr

A,B = map(int,input().split())
print(len(factorization(fractions.gcd(A,B)))+1)
     

Measured memory_bytes: 5048