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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

int cnts[100005];

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

const int MAX_V = 2000005;

mint fac[MAX_V];
mint inv[MAX_V]; 

void initFact() {
  fac[0] = 1;
  inv[0] = 1;
  for (int i = 1; i <= MAX_V; i++) {
    fac[i] = (fac[i - 1] * i);
    inv[i] = fac[i].inv();
  }
}

mint combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * inv[k] * inv[n - k];
}

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

  long x, y;
  cin >> x >> y;

  if ((2*x - y) % 3 || (2*y - x) % 3) {
    cout << 0 << endl;
  } else {
    long a = (2*x - y) / 3;
    long b = (2*y - x) / 3;

    initFact();
    mint res = combi(a+b, a);
    cout << res.x << endl;
  }


  // cout << (isOk?"Yes":"No") << endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int penalty[n + 1];
    memset(penalty, 0, sizeof penalty);
    bool pass[n + 1];
    memset(pass, false, sizeof pass);
    while(m--)
    {
        int id;
        cin >> id;
        string v;
        cin >> v;
        if(v == "AC")
        {
            pass[id] = true;
        }
        else
        {
            if(!pass[id])
            {
                penalty[id]++;
            }
        }
    }
    int a = 0, b = 0;
    for(int i = 0;i <= n;i++)
    {
        if(pass[i])
        {
            a++;
            b += penalty[i];
        }
    }
    cout << a << " " << b ;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;
int cnt[110];
int main(){
    int i,j,n,k;
    cin >> n >> k;
    for(i=0;i<k;i++){
        int d; cin >> d;
        for(j=0;j<d;j++){
            int x; cin >> x; x--; cnt[x]++;
        }
    }
    int ans = 0;
    for(i=0;i<n;i++){
        if(cnt[i]==0) ans++;
    }
    cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> a(3*n);
  rep(i,3*n) cin>>a[i];
  sort(a.begin(),a.end());
  int e = 3*n-1;
  ll ans=0;
  rep(i,n) {
    ans+=a[e-1];
    e-=2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import numpy as np
N,M,X = map(int,input().split())
C = np.repeat(0, N)
A = np.repeat(0, N*M).reshape(N,M)
for i in range(N):
    x = list(map(int, input().split()))
    C[i] = x[0]
    A[i,:] = x[1:]

ans = np.inf

for _ in range(1<<N):
    # print(format(_, 'b').zfill(H+W))
    choices = [i for i,v in enumerate(format(_, 'b').zfill(N)) if v == '1']
    points = A[choices,:].sum(axis=0)
    if sum(points < X) == 0:
        ans = min(ans, sum(C[choices]))

ans = [ans, -1][np.isinf(ans)]
print(ans)

Measured memory_bytes: 27512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    string s="abcdefghijklmnopqrstuvwxyz";
    cin>>c;
    //cout<<c+1;
    cout<<s[c-96];    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll h,w,n;
cin>>h>>w>>n;
ll ans=0;
if(h>w){
if(n%h==0){
ans = n/h;}
else{
ans = n/h +1;}}
else{
if(n%w==0){
ans = n/w;}
else{
ans = n/w +1;}}
cout << ans << endl;}


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

int main() {
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  int C = 1;
  int T = 0;
  while (true) {
    C = B.at(C-1);
    T++;
    if (C == 2) break;
    if (T > N) {
      T = -1;
      break;
    }
  }
  cout << T << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


int main(){
	int A, B, C;
	cin >> A >> B >> C;
	int K;
	cin >> K;

	while(true){
		if(A >= B){
			B *= 2;
			K--;
		}
		else break;
	}
	while(true){
		if(B >= C){
			C *= 2;	
			K--;
		}
		else break;
	}

	if(K<0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}



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

#define int long long
#define mod 1000000007

using namespace std;

int32_t main()
{
    int n;
    cin >> n;

    if(n%2 == 0)
        cout << (n/2)*(n/2) << endl;
    else
        cout << (n/2+1)*(n/2) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
      	int cnt = 0;
      	int a,b;
      	boolean nzj = true;
		
      	for(int i = 0;i < n && nzj;i++){
          a = sc.nextInt();
          b = sc.nextInt();
          if(a == b) cnt++;
          else cnt = 0;
          if(cnt == 3) nzj = false;
        }
      	
		if(!nzj) System.out.println("Yes");
      	else System.out.println("No");
	}
}

Measured memory_bytes: 36152
// Problem : B - Papers, Please
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;cin>>n;
while(n--)
{
	int x;cin>>x;
	if(x%2==0)
	{
		if(x%3==0 || x%5==0)
		continue;
		else
		{
			cout<<"DENIED";
			return;
		}
	}
}
cout<<"APPROVED";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


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

int main() {
  int n;
  cin>>n;
  if(n==1){
    cout<<"1"<< endl;
    return 0;
  }
  int a=0;
  while(n>0){
    n=n/2;
    a++;
  }
  int b=1;
  for(int i=1;i<a;i++){
    b=b*2;
  }
  cout<<b<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int b[n - 1];
  int ans = 0;
  int a[n - 1];
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n - 1; i++) {
    a[i] = b[i];
    if (i == 0) {
      ans += a[i];
      continue;
    }
    if (b[i - 1] < b[i]) {
      a[i] = b[i - 1];
    }
    ans += a[i];
  }
  cout << ans + b[n - 2];
}

Measured memory_bytes: 256
w[100000],c,n,k,g,i,l,m,r=1e9;
f(p)
{
    c=1;g=0;
    for(i=0;i<n;)
    {
        if(g+w[i]<=p)
        {
            g+=w[i++];
        }
        else
        {
            if(g>0)c++;
            else return k+1; 
            g=0;
        }
    }
    return c;
}
 
main(){for(scanf("%d%d",&n,&k);i<n;scanf("%d",w+i++));
while(l<r){m=(l+r)/2;if(f(m)>k)l=m+1;else r=m;}for(m--;;m++){if(f(m)<=k)break;}printf("%d\n",m);exit(0);}
 

Measured memory_bytes: 2216
n, W = list(map(int, input().split()))
data = []
for _ in range(n):
    w, v = list(map(int, input().split()))
    data.append((w, v))

V = sum([v for _, v in data])
dp = [[float("inf")] * (V + 1) for i in range(n + 1)]
dp[0][0]= 0

for i in range(1, n+1):
    w, v = data[i-1]
    for j in range(V + 1):        
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(max([i for i, x in enumerate(dp[-1]) if x != "inf" and x <= W]))


Measured memory_bytes: 307912
X = int(input())

import numpy as np

J = np.zeros(X+1, dtype="bool")
# J[i] は、 i円の買い物ができるときにTrue, できないとFalse
J[0] = True
J[1:100] = False
J[100:106] = True
for i in range(106, X+1):
    if J[i - 100] or J[i - 101] or J[i - 102] or J[i - 103] or J[i - 104] or J[i - 105]:
        J[i] = True
    else:
        J[i] = False

if J[X] == True:
    print("1")
else:
    print("0")

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

int main()
{
  int N, X;
  int m[1001];
  int res=0;
  cin >> N >> X;

  rep(i,N) cin >> m[i];

  rep(i,N){
    X-=m[i];
    res++;
  }

  sort(m, m+N);

  res += X/m[0];

  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, d;
	cin >> n >> d;
	int val = d * 2 + 1;
	if(n%val == 0) cout << n / val << endl;
	else cout << n / val + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const long long MOD = 1e9 + 7;
int inv(int a)
{
	return a==1?1:(long long)(MOD-MOD/a)*inv(MOD%a)%MOD;
}
long long C(long long n,long long m)
{
	if(m<0)return 0;
	if(n<m)return 0;
	if(m>n-m)m=n-m;
	long long up=1,down=1;
	for(long long i=0;i<m;i++)
	{
		up=up*(n-i)%MOD;
		down=down*(i+1)%MOD;
	}
	return up*inv(down)%MOD;
}
int main()
{
	int x,y,t;
	cin >> x >> y;
	long long m=(2*x-y)/3 + (2*y-x)/3;
	long long n=min((2*x-y)/3,(2*y-x)/3);
	if((2*x-y)%3!=0||(2*y-x)%3!=0){
		cout << 0 << endl;
	}
	else{
		cout << C(m,n) << endl;
	}
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

typedef pair<int, char> PC;

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

    cout << (e - a > k ? ":(" : "Yay!") << endl;

}



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

public class PaizaPj
{
    

    public static void Main()
    {
        // 読込
        int N = int.Parse(Console.ReadLine().Trim());
        var P = Console.ReadLine().Trim().Split(' ').ToList();
        var Q = Console.ReadLine().Trim().Split(' ').ToList();

        var origPerm = new List<string>(P);
        origPerm.Sort();

        string p = "";
        string q = "";
        string orig = "";
        for (int i = 0; i < N; i++)
        {
            p += P[i];
            q += Q[i];
            orig += origPerm[i];
        }

        var perms = Perms(orig);

        int pIdx = perms.FindIndex(s => s.Equals(p));
        int qIdx = perms.FindIndex(s => s.Equals(q));

        Console.WriteLine(Math.Abs(pIdx - qIdx));

        //Console.ReadLine();
    }

    static List<string> Perms(string s)
    {
        if (s.Length == 1) return new List<string>() { s };
        // ↑は以下でもよい
        // if (s.Length == 0) return new List<string>() { "" };

        var ret = new List<string>();
        for (int i = 0; i < s.Length; i++)
        {
            // 1. s[i] を除いたグループで順列を作る(再帰)
            foreach (string t in Perms(s.Remove(i, 1)))
            {
                // 2. 先頭に s[i] をつけると
                //    s[i] が先頭の順列が出来る(長さ s.Length の順列)
                ret.Add(s[i] + t);
            }
        }
        return ret;
    }


}


Measured memory_bytes: 24896
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
bitset<N>a[N],dp1[N],dp2[N];
int n;
char s[N];
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<i;j++)
            if(s[j]=='1')
            a[i].set(j,1),a[j].set(i,0);
            else a[j].set(i,1),a[i].set(j,0);
    }
    for(int i=1;i<=n;i++) dp1[i].set(i),dp2[i].set(i);
    for(int i=2;i<=n;i++)
        for(int l=1;l+i-1<=n;l++)
    {
        int r=l+i-1;
        if((dp1[r]&dp2[l+1]&a[l]).count()) dp1[r].set(l,1);
        if((dp1[r-1]&dp2[l]&a[r]).count()) dp2[l].set(r,1);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(dp1[n][i]&dp2[1][i]) ans++;
    printf("%d\n",ans);
}


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

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

    vector<int> value(N);
    vector<int> cost(N);
    for (int i = 0; i < N; i++) cin >> value[i];
    for (int i = 0; i < N; i++) cin >> cost[i];

    int diff = 0;
    for (int i = 0; i < N; i++) {
        if (value[i] > cost[i]) {
            diff += value[i] - cost[i];
        }
    }
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

int main()
{
  vector<int> x(5);
  for (int i = 0; i < 5; i++)
  {
    cin >> x[i];
  }
  for (int i = 0; i < 5; i++)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3628
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> plus;
	vector<int> minus;
	REP( i, N )
	{
		int x;
		cin >> x;
		if( x >= 0 )
		{
			plus.push_back( x );
		}
		else
		{
			minus.push_back( - x );
		}
	}
	sort( plus.begin(), plus.end() );
	sort( minus.begin(), minus.end() );
	int ans = 1e9;
	for( int i = 0; i <= K; ++i )
	{
		int plusNum = i;
		int minusNum = K - i;
		if( plusNum <= plus.size() && minusNum <= minus.size() )
		{
			int p = plusNum > 0 ? plus[ plusNum - 1 ] : 0;
			int m = minusNum > 0 ? minus[ minusNum - 1 ] : 0;

			int time = min( p, m ) * 2 + max( p, m );
			ans = min( ans, time );
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main(){
   int N,n,Cards[4][14];
   char m;

   for(int s=0; s<4; s++)
   	for(int t=1; t<=13; t++)
   		Cards[s][t] = 0;

   cin >> N;

   for(int i=0; i<N; i++){
   	cin >> m >> n;

   	if(m == 'S') Cards[0][n] = 1;
   	if(m == 'H') Cards[1][n] = 1;
   	if(m == 'C') Cards[2][n] = 1;
   	if(m == 'D') Cards[3][n] = 1;

   }

   for(int s=0; s<4; s++){
   	for(int t=1; t<=13; t++){
   		if(Cards[s][t]) continue;
   		if(s == 0) m = 'S';
   		if(s == 1) m = 'H';
   		if(s == 2) m = 'C';
   		if(s == 3) m = 'D';

   		cout << m << " " << t << endl;
   	}
   }

   return 0;

}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int A, B, C;
    std::cin >> A >> B >> C;

    if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
        std::cout << 0 << std::endl;
    }else if(A == B && B == C){
        std::cout << -1 << std::endl;
    }else{
        int t = 0;
        while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
            int AA = B / 2 + C / 2,
                BB = A / 2 + C / 2,
                CC = A / 2 + B / 2;
            A = AA;
            B = BB;
            C = CC;

            ++t;
        }

        std::cout << t << std::endl;
    }
}


Measured memory_bytes: 256
/*input
333
*/

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

int main() {
  string s[] = 
    {"pon", "pon", "hon", 
     "bon", "hon", "hon", 
     "pon", "hon", "pon", 
     "hon"};
  int n;
  cin >> n;
  cout << s[n%10] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
int a, b;
cin >> a >> b;
int add,sub,mul,ans;
add=a+b;
sub=a-b;
mul=a*b;
ans=add;
if(ans<sub){
  ans=sub;
}
if(ans<mul){
  ans=mul;
}
cout << ans<< endl;
}

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

int main(){
    int t1,t2,r1,r2;
    cin>>t1>>t2>>r1>>r2;

    if(r1 == -1 || r2 == -1){
        if(t1 < t2) cout<<"Alice"<<endl;

        else if(t1 > t2) cout<<"Bob"<<endl;

        else cout<<"Draw"<<endl;

    }
 
    else if(r1 > r2) cout<<"Alice"<<endl;

    else if(r1 < r2) cout<<"Bob"<<endl;

    else cout<<"Draw"<<endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  string s;
  cin >> s;
  int sta=0;
  for(auto c:s) if(sta==0&&c=='C' || sta==1&&c=='F') ++sta;
  cout << (sta<2 ? "No" : "Yes") << endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    string S;
    cin >> N >> S;

    ll B = 0;
    REP(i, N) B += (S[i] - '0');
    vvl pow2(2, vl(N, 0));

    REP(b, 2){
        ll val = 1;
        ll M = (b==0 ? B+1 : B-1);
        REP(i, N){
            if(M != 0){
                pow2[b][N-i-1] = val;
                val *= 2;
                val %= M;
            }else{
                pow2[b][N-i-1] = 0;
            }
        }
    }

    vl sum(2);
    REP(b, 2){
        ll val = 0;
        ll M = (b==0 ? B+1 : B-1);
        REP(i, N){
            val += (S[i]-'0') * pow2[b][i];
            if(M !=0 ) val %= M;
        }
        sum[b] = val;
    }

    auto G = [](ll x){
        ll cnt = 0;
        while(x>0){
            ll bi = __builtin_popcountll(x);
            x = x % bi;
            cnt++;
        }
        return cnt;
    };

    vector<ll> res(N);
    REP(i, N){
        ll M, X;
        if(S[i]=='0'){
            M = B+1;
            X = sum[0] + pow2[0][i];
            X %= M;
        }else{
            M = B-1;
            if(M != 0){
                X = sum[1] - pow2[1][i];
                X = ((X%M)+M)%M;
            }else{
                X = 0;
            }
        }
        dump(B)
        if(S[i]=='1' and B==1) res[i] = 0;
        else res[i] = G(X) + 1;
    }

    REP(i, N) cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 8344
#include<iostream>
using namespace std;
typedef long long ll;
 
ll n,k;
ll w[100000];
 
bool check(int x){
  ll cost=0,cnt=0;
  for(ll i=0;i<n;i++){
    cost+=w[i];
    while(cost>x){
      cost=w[i];
      cnt++;
      if(cnt==k)return false;
    }
  }
  return true;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(ll i=0;i<n;i++)cin>>w[i];
  ll l=0,r=1000000000LL,m,kq;
  while(l<=r){
    m=(l+r)/2;
    if(check(m))
    {kq = m; r=m-1;}
    else l=m+1;
  }
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,a = 1e9,b;
cin >> n;
for(int i = 0; i < n; i++){
   cin >> b;
   long long cnt = 0;
   while(b % 2 == 0){
       b /= 2;
       cnt++;
   }
   a = min(a,cnt);
}
cout << a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int K, X;
	scanf("%d %d", &K, &X);
	// X-K+1 -- X+K-1
	for (int i = 0; i < 2 * K - 1; i++) {
		printf("%d ", X - K + 1 + i);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	int temp=0;
	while(cin>>a)
	{
		if(a=='C')
		{
			temp=1;
		}
		if(temp==1&&a=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
n, m, l = map(int,input().split())
A = [[0]*m for i in range(n)]
B = [[0]*l for i in range(m)]
C = [[0]*l for i in range(n)]

for i in range(n):
    A[i] = list(map(int,input().split()))

for j in range(m):
    B[j] = list(map(int,input().split()))

for i in range(n):
    for j in range(m):
        for k in range(l):
            C[i][k] += A[i][j] * B[j][k]

C_str = [[str(x) for x in y] for y in C]

for i in range(n):
    li = C_str[i]
    print(" ".join(li))



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

class BinaryNode{
public:
	int left, right;
};

class BinaryTree{
public:
	int num;
	vector<BinaryNode> tree;
	vector<int> parent;
	
	BinaryTree(int _num){
		num = _num;
		tree.resize(num);
		parent.resize(num);
		for(int i=0;i<num;++i)parent[i] = -1;
	}
	
	int top(){
		for(int i=0;i<num;++i){
			if(parent[i] == -1){
				return i;
			}
		}
	}
	
	void preorder(int n){
		BinaryNode cur = tree[n];
		cout<<" "<<n;
		if(cur.left != -1){
			preorder(cur.left);
		}
		if(cur.right != -1){
			preorder(cur.right);
		}
	}
	void inorder(int n){
		BinaryNode cur = tree[n];
		if(cur.left != -1){
			inorder(cur.left);
		}
		cout<<" "<<n;
		if(cur.right != -1){
			inorder(cur.right);
		}
	}
	void postorder(int n){
		BinaryNode cur = tree[n];
		if(cur.left != -1){
			postorder(cur.left);
		}
		if(cur.right != -1){
			postorder(cur.right);
		}
		cout<<" "<<n;
	}
};


int main() {
	int n, id, left, right, top=-1;
	cin>>n;
	BinaryTree bTree = BinaryTree(n);
	for(int i=0;i<n;++i){
		cin>>id>>left>>right;
		
		bTree.tree[id].left = left;
		bTree.tree[id].right = right;
		if(left+1)bTree.parent[left] = id;
		if(right+1)bTree.parent[right] = id;
	}
	
	top = bTree.top();
	
	cout<<"Preorder"<<endl;
	bTree.preorder(top);
	cout<<endl;
	cout<<"Inorder"<<endl;
	bTree.inorder(top);
	cout<<endl;
	cout<<"Postorder"<<endl;
	bTree.postorder(top);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1200
r, g, b, n = [int(i) for i in input().split()]

r, g, b = sorted([r, g, b])

ans = 0
divb = int(n / b)
for i in range(divb+1):
    remain_n1 = n - b * i
    divg = int(remain_n1 / g)
    for j in range(divg+1):
        remain_n2 = remain_n1 - g * j
        if remain_n2 % r == 0:
            ans += 1

print(ans)

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

int main() {
  string S; cin >> S;
  map<char, int> cnt_map;
  string ans = "";
  
  for (int i = 0; i < S.size(); ++i) ++cnt_map[S[i]];
  
  for (char c = 'a'; c <= 'z'; ++c) {
    if (cnt_map[c] == 0) {
      ans = c;
      break;
    }
  }
  
  if (ans.empty()) ans = "None";
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;

int n;
long long a[100011];
long long MOD=1000000007;

int main()
{
    int i,j,k;
    int xx;
    
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    long long r=0;
    long long ans=1;
    for(i=1;i<=n;i++)
    {
        r++;
        if(r*2-1>a[i])
        {
            ans=ans*r%MOD;
            r--;
        }
    }
    while(r!=0)
    {
        ans=ans*r%MOD;
        r--;
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 1024
package main

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

type Card struct {
	mark  string
	value int
}

func (self Card) Equal(other Card) bool {
	return self.mark == other.mark && self.value == other.value
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	cards, err := nextCards(n, sc)
	if err != nil {
		panic(err)
	}
	copied := make([]Card, len(cards))
	copy(copied, cards)
	quickSort(cards)
	sortedByMerge, _ := mergeSort(copied)
	if isEqualCards(cards, sortedByMerge) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
	for _, card := range cards {
		fmt.Printf("%s %d\n", card.mark, card.value)
	}
}

func quickSort(cards []Card) {
	if len(cards) > 1 {
		q := partition(cards, 0, len(cards)-1)
		quickSort(cards[:q])
		quickSort(cards[q+1:])
	}
}

func partition(cards []Card, p int, r int) int {
	// fmt.Printf("before: %v\n", cards)
	k := p - 1
	v := cards[r].value
	for i := p; i < r; i++ {
		if cards[i].value <= v {
			k++
			cards[i], cards[k] = cards[k], cards[i]
		}
	}
	k++
	cards[r], cards[k] = cards[k], cards[r]
	// fmt.Printf("after: %v\n", cards)
	return k
}

func mergeSort(elems []Card) ([]Card, int) {
	length := len(elems)
	if length == 1 {
		return elems, 0
	}
	mid := length / 2
	left, countL := mergeSort(elems[:mid])
	right, countR := mergeSort(elems[mid:])
	sorted, countS := merge(left, right)
	return sorted, (countL + countR + countS)
}

func merge(xs, ys []Card) ([]Card, int) {
	sorted := make([]Card, 0)
	count := 0
	for len(xs) > 0 && len(ys) > 0 {
		if xs[0].value <= ys[0].value {
			sorted = append(sorted, xs[0])
			xs = xs[1:]
		} else {
			sorted = append(sorted, ys[0])
			ys = ys[1:]
		}
		count++
	}
	if len(xs) > 0 {
		sorted = append(sorted, xs...)
		count += len(xs)
	} else if len(ys) > 0 {
		sorted = append(sorted, ys...)
		count += len(ys)
	}
	return sorted, count
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextCard(sc *bufio.Scanner) (Card, error) {
	mark := nextText(sc)
	value, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	return Card{mark, value}, nil
}

func nextCards(n int, sc *bufio.Scanner) ([]Card, error) {
	ns := make([]Card, n)
	for i, _ := range ns {
		x, err := nextCard(sc)
		if err != nil {
			return nil, err
		}
		ns[i] = x
	}
	return ns, nil
}

func isEqualCards(x []Card, y []Card) bool {
	if len(x) != len(y) {
		return false
	}
	for i := 0; i < len(x); i++ {
		if !x[i].Equal(y[i]) {
			return false
		}
	}
	return true
}



Measured memory_bytes: 19460
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#define mx 100005
using namespace std;
int dp[mx],h[mx],n,p;
void min_cost(int i,int k)
{
    if(i>=n)
        return;
        int l=0;
    for(int j=i-1; j>=0; j--)
    {
        l++;
        if(l>k)
        {
            //k = p;
            break;
        }
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    min_cost(i+1,k);
}
int main()
{
    int i,k;
    cin>>n>>k;
    p = k;
    for(i=0; i<n; i++)
        dp[i] = 1e9+5;
    for(i=0; i<n; i++)
        cin>>h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    min_cost(2,k);
    //for(i=0; i<n; i++)
        //cout<<dp[i]<<" ";
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
/*
** 本题用分治法
** 此题值得深思，用以理解分治法的精髓
*/

# include <cstdio>

const int maxn = 20 + 2;
int n, a[maxn], q;

int solve(int i, int m) {
	if (m == 0)
		return 1;
	if (i >= n)
		return 0;
	// 把一个大问题分解成两个小问题。第一个表示不选择a[i]，第二个表示选择a[i]作为m的一部分
	int res = solve(i+1, m) || solve(i+1, m-a[i]); 
	return res;
}

int main() {
	// freopen("infile", "r", stdin);
	// freopen("outfile", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int m; scanf("%d", &m);
		if (solve(0, m)) 
			printf("yes\n");
		else
			printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define rep(i,n) for(int i= 0; i < (n); i++)
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int outlet = 1;
    while (outlet < b){
        --outlet;
        outlet += a;
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    char s[4];
    scanf("%s", s);
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if (s[i] == 'o') ans++;
    }
    printf("%d\n", 700 + 100 * ans);

}

Measured memory_bytes: 128
N,K=map(int, input().split())
H=list(map(int,input().split()))
count=0
H.sort(reverse=True)
#print(H)
i=K
#print(i)
while i<len(H):
    count=count+H[i]
    i=i+1
    #print(i)

print(count)

Measured memory_bytes: 26764
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
template <class _T> void tp_getPrimes(_T targ, std::map<_T, _T>& primes)
{
	_T target = targ;
	_T i = 2;
	while ((i * i) <= target) {
		if ((target % i) == 0) {
			target /= i;

			if (primes.find(i) == primes.end()) {
				primes[i] = 1;
			}
			else {
				primes[i] = primes[i] + 1;
			}
		}
		else {
			i++;
		}
	}
	if (target == 1) {
		//	なにもしない
	}
	else if (primes.find(target) == primes.end()) {
		primes[target] = 1;
	}
	else {
		primes[target] = primes[target] + 1;
	}


#if 0
	printf("Target: %d equals\n", targ);
	for (auto it = primes.begin(); it != primes.end(); it++) {
		printf("%d ^ %d\n", it->first, it->second);
	}
#endif
}


static void ABC100C_M3orD2();

#if 1
int main()
{
	ABC100C_M3orD2();
	fflush(stdout);
	return 0;
}
#endif

static void ABC100C_M3orD2()
{
	int N;
	get1int(N);

//	auto seqA = new LLONG[N];
	LLONG num, evenCnt = 0;
	for (int i = 0; i < N; i++) {
		get1int<LLONG>(num);
		std::map<LLONG, LLONG> primes;
		tp_getPrimes<LLONG>(num, primes);
		auto it = primes.find(2);
		if (it != primes.end()) {
			evenCnt += it->second;
		}
	}
	printf("%lld\n", evenCnt);
//	delete[] seqA;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
import math


a = input()
a = int(a)
count = 0
for l in range(1, a + 1):
    for m in range(1, a + 1):
        x = math.gcd(l, m)
        for n in range(1, a + 1):
            count += math.gcd(x,n)

print(count)

Measured memory_bytes: 9144
#include<stdio.h>
#include<string.h>
main(){
  char pan[1001];
  int i,a;
  fgets(pan,sizeof(pan),stdin);
  a=strlen(pan);
  pan[a-1]='\0';
  for(i=0;i<=a-6;i++){
    if(pan[i]=='a'){
      if(pan[i+1]=='p'){
	if(pan[i+2]=='p'){
	  if(pan[i+3]=='l'){
	    if(pan[i+4]=='e'){
	      pan[i]='p';
	      pan[i+1]='e';
	      pan[i+2]='a';
	      pan[i+3]='c';
	      pan[i+4]='h';
	    }
	  }
	}
      }
    }
    else{
    if(pan[i]=='p'){
      if(pan[i+1]=='e'){
	if(pan[i+2]=='a'){
	  if(pan[i+3]=='c'){
	    if(pan[i+4]=='h'){
	      pan[i]='a';
	      pan[i+1]='p';
	      pan[i+2]='p';
	      pan[i+3]='l';
	      pan[i+4]='e';
	    }
	  }
	}
      }
    }
    }
  }
  printf("%s\n",pan);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 999999999
using namespace std;

int G[110][110] = {};
int mini[110];
int used[110];

void dijkstra(int n)
{
    //init
    for(int i = 0;i < n;i++){
        mini[i] = INF;
        used[i] = 0;
    }
    mini[0] = 0;

    while(true)
    {
        int v = -1;
        for(int i = 0;i < n;i++){
            if(!used[i] && (v == -1 || mini[i] < mini[v])) v = i;
        }
        if(v == -1) break;
        used[v] = 1;

        for(int i = 0;i < n;i++){
            mini[i] = min(mini[i], mini[v]+G[v][i]);
        }
    }
}

int main()
{
    int n;
    int u, k, v, c;

    cin >> n;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++) G[i][j] = INF;
    }

    for(int i = 0;i < n;i++){
        cin >> u >> k;
        for(int j = 0;j < k;j++){
            cin >> v >> c;
            G[u][v] = c; //uiとviをつなぐコストがci
        }
    }
    dijkstra(n);
    
    for(int i = 0;i < n;i++) printf("%d %d\n", i, mini[i]);
    
    return 0;
}


Measured memory_bytes: 3240
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		int sum = 0;
		int min = Integer.MAX_VALUE;
		for(int i=0; i<N; i++) {
			int s = sc.nextInt();
			sum += s;
			if(s%10 != 0 && s < min) {
				min = s;
			}
		}
		
		if(sum%10 != 0) {
			System.out.println(sum);
		} else {
			sum -= min;
			if(sum < 0) {
				System.out.println(0);
			} else {
				System.out.println(sum);
			}
		}
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22996
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
ll inf(1e18);
#define mod ll(1e9+7)
//#define mod ll(998244353)
#define ff first
#define ss second
ll power(ll a,ll b)
{
	if(!b)
		return 1;
	ll dp=power(a,b/2)%mod;
	
	if(b&1) return (((dp*dp)%mod)*a)%mod;
	
	return (dp*dp)%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test=1;
    //cin>>test;

    while(test--)
    {
		ll a,b;
		string str;
		cin>>a>>str;
		b=(str[0]-'0')*100+(str[2]-'0')*10+str[3]-'0';
		cout<<(a*b)/100;
	}
	return 0;
}


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

using namespace std;

//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif

typedef int intt;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define fs first 
#define sd second 
#define mp make_pair    
#define endl "\n"

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)

#define infll (ll)1e14
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-6

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int n,k;
int a[100001];
int dp[100001];

int solve(int i){
    if(i == n-1 )return 0;
    if(~dp[i])return dp[i];
    int &r = dp[i];
    r = infll;
    fore(j,1,k+1){
        if(i+j < n){
            r = min(r,(abs(a[i]-a[i+j])+solve(i+j))); 
        }
    }
    return r;
}


int32_t main(int32_t argc, char const *argv[]){
    FIN;
    mm(dp,-1);
    cin>>n>>k;
    fore(i,0,n)cin>>a[i];
    cout<<solve(0);



    return 0;
}



















Measured memory_bytes: 4992
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] N = Console.ReadLine().Split();
            int K = int.Parse(N[0]);
            int X = int.Parse(N[1]);
            if(K*500>=X)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

using namespace std;

const int MAXN = 1e5 + 15;

int N, M;

long long int result;

priority_queue<int> items;

int main() {

	scanf("%d%d", &N, &M);

	for( int value, i=0 ; i < N ; i++ ) {
		scanf("%d", &value);
		items.push(value);
	}

	while (M > 0) {

		int value = items.top();
		items.pop();

		items.push(value / 2);
		M--;
	}

	while (!items.empty()) {
		result += items.top();
		items.pop();
	}

	printf("%lld\n", result);
	return 0;
}

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

int main()
{
  int t,n,h,preH;
  int max,min;
  cin>>t;
  while(cin>>n){
    cin>>preH;
    max=0;
    min=0;
    while(--n>0){
      cin>>h;
      if(max<h-preH)max=h-preH;
      if(h-preH<min)min=h-preH;
      preH=h;
    }
    cout<<max<<" "<<-min<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=1e6+5;
const int P=924844033;
long long Inv,g[N],f[N],fac[N],inv[N];
int n,m,now,len,v[N],r[N],si[N],nex[N],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
long long C(int n,int m){
	return fac[n]*inv[m]%P*inv[n-m]%P;
}
long long fsp(long long x,int y){
	long long ans=1;
	while(y){
		if(y&1)	ans=ans*x%P;
		x=x*x%P,y>>=1;
	}
	return ans;
}
void NTT(long long *d,int f){
	for(int i=1;i<n;i++)
		if(i<r[i])	swap(d[i],d[r[i]]);
	for(int i=1;i<n;i<<=1){
		int wn=fsp(5,(P-1)/(i<<1));
		if(f)	wn=fsp(wn,P-2);
		for(int j=0;j<n;j+=i<<1){
			long long w=1;
			for(int k=0;k<i;k++,w=w*wn%P){
				int x=d[j+k],y=w*d[i+j+k]%P;
				d[j+k]=(x+y)%P,d[i+j+k]=(x-y+P)%P;
			}
		}
	}
	if(f)	for(int i=0;i<n;i++)	d[i]=d[i]*Inv%P;
}
void dfs(int x,int fa){
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa)	dfs(v[i],x),si[x]+=si[v[i]];
	si[x]++,++f[n-si[x]];
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa) ++f[si[v[i]]];
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		addedges(x,y),addedges(y,x);
	}	dfs(1,1),inv[0]=fac[0]=1,f[0]=0;
	for(int i=1;i<=n;i++)	fac[i]=fac[i-1]*i%P;
	for(int i=1;i<=n;i++)	inv[i]=fsp(fac[i],P-2);
	for(int i=0;i<=n;i++)	f[i]=f[i]*fac[i]%P;
	for(int i=0;i<=n;i++)	g[i]=inv[i];
	for(m=n;(1<<len)<=n+n;++len);
	n=1<<len,Inv=fsp(n,P-2),reverse(f,f+n);
	for(int i=1;i<n;i++)	r[i]=(r[i>>1]>>1)|((i&1)<<(len-1));
	NTT(f,0),NTT(g,0);
	for(int i=0;i<n;i++)	f[i]=f[i]*g[i]%P;
	NTT(f,1),reverse(f,f+n);
	for(int i=1;i<=m;i++)	printf("%lld\n",(m*C(m,i)-f[i]*inv[i]%P+P)%P);
	return 0;
}


Measured memory_bytes: 47744