akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

string M[8];

bool inF(int y, int x) {
  return 0<=x && x<8 && 0<=y && y<8;
}

int main() {

  while(cin>>M[0]) {
    for(int i=1; i<8; i++) cin >> M[i];
    
    char res = '#';
    
    for(int i=0; i<8; i++) {
      for(int j=0; j<8; j++) {
	if(M[i][j]-'0') {
	  
	  if(inF(i+1, j+1) && M[i+1][j+1]-'0') {
	    if(inF(i+2, j+1) && M[i+2][j+1]-'0') {
	      res = 'F'; goto end;
	    } else if(inF(i+1, j+2) && M[i+1][j+2]-'0') {
	      res = 'E'; goto end;
	    } else {
	      res = 'A'; goto end;
	    }
	  }
	  
	  if(inF(i+3, j) && M[i+3][j]-'0') {
	    res = 'B'; goto end;
	  }

	  if(inF(i, j+3) && M[i][j+3]-'0') {
	    res = 'C'; goto end;
	  }

	  if(inF(i+1, j-1) && M[i+1][j-1]-'0') {
	    if(inF(i, j+1) && M[i][j+1]-'0') {
	      res = 'G'; goto end;
	    } else {
	      res = 'D'; goto end;
	    }
	  }
	}
      }
    }
    end:
    cout << res << endl;
  }
  return 0;
}

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

int main()
{
    int n;
    cin>>n;
    map <string,int> mp;

    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++; 
    }

    int mx=0;

    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
       if(itr->second>mx)
       {
           mx = itr->second;
       }
    }

    for(auto itr=mp.begin();itr!=mp.end();itr++)
    {
        if(itr->second==mx)
        {
            cout<<itr->first<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	Graph G(N);
	vector<int> deg(N, 0);
	for (int i = 0; i < N; ++i)
	{
		ll a, b; cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
		++deg[a]; ++deg[b];
	}

	queue<int> que;
	for (int i = 0; i < N; ++i)
		if (deg[i] == 1) que.push(i);

	vector<bool> is_pushed(N, false);

	while (!que.empty())
	{
		int v = que.front(); que.pop();
		is_pushed[v] = true;

		for (auto nv : G[v])
		{
			--deg[nv];
			if (deg[nv] == 1) que.push(nv);
		}
	}

	int Q; cin >> Q;
	for (int i = 0; i < Q; ++i)
	{
		int a, b; cin >> a >> b; --a, --b;
		if (!is_pushed[a] && !is_pushed[b]) std::cout << 2 << std::endl;
		else std::cout << 1 << std::endl;
	}
}



Measured memory_bytes: 8624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define md 998244353
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res)*(x))%mod;
        }
        x=((x)*(x))%mod;
        y=y/2;
    }
    return res;
}
 




 
  
int main(){
 
  /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

    ll n,k;

    sfl(n);sfl(k);

    ll tot=power(k,n),ans=0,prev=0,c[200005];
      mst(c,0);
    for(int i=k;i>=1;i--){

        ll x=(k/i);

        ll y=power(x,n);

        

        y=(y-c[i]+mod)%mod;
      

        ans=(ans+i*y);
        ans%=mod;

      for(int j=1;j*j<=i;j++){

          if(i%j==0){

              c[j]=(c[j]+y)%mod;

              if(j*j!=i){
                  c[i/j]=(c[i/j]+y)%mod;
              }
          }
      }

        

    }


    

    pf(ans);


   return 0;
 
  
 
    
 }

Measured memory_bytes: 5368
n = int(input())
a = []
b = []
for i in range(n):#h:高さ
    pi, qi = map(int, input().split())
    a.append(pi)
    b.append(qi)

ans = 0
tmp = 0
for i in reversed(range(n)):
    if a[i] % b[i] != 0:
        ans += b[i] - (a[i] % b[i])
    if i != 0:
        a[i - 1] += ans
print(ans)

Measured memory_bytes: 15016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m = 1e9+7,b;
 
int main(){
	b = 1;
	int n;
	cin >> n;
	for(int i = 1;i<=n;i++){
		b*=i;
		b%=m;
	}
	cout<<b<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(m)]
ls.sort(key=lambda x: x[1])

ans = 0
idx = 0
for l in ls:
    if idx <= l[0]:
        idx = l[1]
        ans += 1

print(ans)



Measured memory_bytes: 64472
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int x,y,way;
double W,H,sum;
scanf("%lf%lf%d%d",&W,&H,&x,&y);



if(x*2==W && y*2==H){
  way=1;
}

else{
way=0;
}

sum=W*H/2;

printf("%f %d\n",sum,way);

}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
vector<int> wyn;
void f(int A, int B, int n, int dod)
{
    //cout << A << " " << B << " " << n << " " << dod << "\n";
    //cout << "hum\n";
    int czy=0;
    for (int i=0; i<n; i++)
    {
        if ((A^B)==(1<<i))
            czy=i+1;
    }
    vector<int> v;
    for (int i=0; i<n; i++)
    {
        if ((dod&(1<<i))==0 && i+1!=czy)
            v.push_back(i);
    }
    v.push_back(czy-1);
    //cout << n << " " << v.size() << "kk\n";
    //cout << czy << "\n";
    //cout << "grum\n";
    int akt=A;
    for (int i=1; i<(1<<v.size()); i++)
    {
        //cout << akt << " ";
        wyn.push_back(akt);
        for (int j=v.size()-1; j>=0; j--)
        {
            if (i%(1<<j)==0)
            {
                akt=akt^(1<<v[j]);
                //cout << j << "j ";
                break;
            }
        }
    }
    //cout << "pum\n";
    wyn.push_back(akt);
    //cout << akt;
}
void bf(int A, int B, int n, int dod)
{
    vector<int> spis;
    int czy=0;
    for (int i=0; i<=17; i++)
    {
        if (((A^B)&(1<<i))!=0)
        {
            czy++;
            spis.push_back(i);
        }
    }
    //cout << A << " " << B << " " << n << "\n";
    //cout << czy << '\n';
    if (czy==1)
        f(A, B, n, dod);
    else
    {
        //cout << (1<<spis[0]) << " " << (1<<spis[1]) << "\n";
        bf(A, B^(1<<spis[0])^(1<<spis[1]), n, dod+(1<<spis[0]));
        int pomdod=dod;
        for (int i=2; i<spis.size(); i++)
            pomdod+=(1<<spis[i]);
        f(B^(1<<spis[1]), B, n, dod+(1<<spis[0]));
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int A, B;
    cin >> A >> B;
    int czy=0;
    for (int i=0; i<=17; i++)
    {
        if (((A^B)&(1<<i))!=0)
        {
            czy++;
            //roz[i]=1;
        }
    }
    if (czy%2==0)
    {
        cout << "NO";
        return 0;
    }
    cout << "YES\n";
    bf(A, B, n, 0);
    for (int i=0; i<(1<<n); i++)
        cout << wyn[i] << " ";
}


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

int nums[2000100];
int left;
int right;
int n;
char str[1024];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%s", str);
    if( str[0] == 'i' ) {
      int t;
      scanf("%d", &t);
      nums[right] = t;
      right += 1;
    }
    else {
      int t;
      switch( str[6] ) {
      case '\0' :
        scanf("%d", &t);
        for(int j = right - 1; j >= left; --j) {
          if( nums[j] == t ) {
            nums[j] = -1;
            break;
          }
        }
        break;
      case 'F' :
        do {
          right -= 1;
        } while( left < right - 1 and nums[right] == -1 );
        break;
      case 'L' :
        do {
          left += 1;
        } while( left + 1 < right and nums[left-1] == -1 );
        break;
      }
    }
  }
  int i;
  for(i = right - 1; i >= left; --i) {
    if( nums[i] != -1 ) {
      printf("%d", nums[i]);
      break;
    }
  }
  for(i = i - 1; i >= left; --i) {
    if( nums[i] != -1 ) {
      printf(" %d", nums[i]);
    }
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 7064
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))

ans = sum(s)

s.sort()

if ans % 10 != 0:
    print(ans)
else:
    f = [x for x in s if x % 10 != 0]
    if len(f) == 0:
        print(0)
    else:
        print(ans - min(f))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#define mod 1e9+7
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a;
  vector<int> dp(1<<21);
  dp[0]=1;
  vector<deque<int>> listj(22);
  for(int k=0;k<(1<<(n));k++)
  {
    int j=0,tmp=k;
    while(tmp>0){j+=tmp%2;tmp/=2;}
    listj[j].push_back(k);
  }

  for(int i=1;i<n+1;i++)
  {
    for(int j=0;j<n;j++)
    {
      cin>>a;
      if(!a)continue;
      for(int k:listj[i-1])
      {
        if((k & (1<<j)))continue;
        int kn;
        kn=k+(1<<j);
        {
          dp[kn]+=dp[k];
          if(dp[kn]>=mod)dp[kn]-=mod;
        }
      }
    }


  }
  cout<<dp[(1<<n)-1]<<endl;

  return 0;

}


Measured memory_bytes: 17152
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R1, R2;
    cin >> R1 >> R2;
    cout << fixed << setprecision(10);
    cout << R1 * R2 / (R1 + R2) << endl;
    return 0;
}

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

int main() {
    int k, s;
    cin >> k >> s;
    int ans=0;
    rep(i,k+1) {
        rep(j,k+1) {
            int v=s-i-j;
            if(0<=v&&v<=k)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 300005;
int A[MAXN];
long long int v1[MAXN], v2[MAXN];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < 3*n; ++i)
	{
		scanf("%d", &A[i]);
	}
	vector <int> S;
	make_heap(S.begin(), S.end());
	long long int tot = 0;
	for (int i = 0; i < 3*n; ++i)
	{
		A[i]*=-1;
		S.push_back(A[i]);
		push_heap(S.begin(), S.end());
		tot+=A[i];
		if(S.size() > n)
		{
			tot-=S.front();
			pop_heap(S.begin(), S.end());
			S.pop_back();
		}
		v1[i] = -tot;
	}
	S.clear();
	tot = 0;
	for (int i = 3*n - 1; i >= 0; --i)
	{
		A[i]*=-1;
		S.push_back(A[i]);
		push_heap(S.begin(), S.end());
		tot+=A[i];
		if(S.size() > n)
		{
			tot-=S.front();
			pop_heap(S.begin(), S.end());
			S.pop_back();
		}
		v2[i] = tot;
	}
	long long int ans = v1[n-1] - v2[2*n];
	for (int i = n-1; i < 2*n; ++i)
	{
		ans = max(ans, v1[i] - v2[i+1]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, k, s;
	cin >> n >> k >> s;

	while (k-- && n--)
		cout << s << " \n"[n==0];

	const int inf = 1e9;
	while (n--)
		cout << ((s==inf) ? 1 : (s+1)) << " \n"[n==0];

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int n, q;
vector<vi> adj;
vll score;

void dfs(int v, int par)
{
    if (par!=-1) score[v] += score[par];
    for(auto u:adj[v]){
        if (u==par) continue;
        dfs(u, v);
    }
}
//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>q;
    adj.resize(n+1);
    rep(i,n-1){
        int a,b; cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    score.resize(n+1, 0);
    while(q--){
        int p,x; cin>>p>>x;
        score[p]+=x;
    }
    dfs(1, -1);
    FOR(i,1,n){
        cout<<score[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()


const int mod = 1e9 + 7;
const int N = 2e5 + 6;
int arr[N];

void solve()
{
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		int data;
		cin >> data;
		if(k <= data)cnt++;
	}
	cout << cnt << endl;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}          

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){

    ll x;
    cin >> x;
    bitset<32> bs(x);

    // Inversion: change the state of each bit to the opposite state
    // 0 -> 1 , 1 -> 0
    bitset<32> inv = ~bs;
    // Logical left shift: shift left by 1
    bitset<32> left = (bs << 1);
    // Logical right shift: shift right by 1
    bitset<32> right = (bs >> 1);

    cout << bs << '\n';
    cout << inv << '\n';
    cout << left << '\n';
    cout << right << '\n';
}



Measured memory_bytes: 3168
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n,m; cin >> n >> m;
  vector<vector<int>> s(m);
  rep(i,m){
    int k; cin >> k;
    rep(j,k){
      int a; cin >> a; a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(m); rep(i,m) cin >> p[i];
  
  ll res = 0;
  for(int bit = 0; bit < (1<<n); bit++){ //1<<nというのはn^2を表す。(1をn回左シフトする)
    bool ok = true;
    for(int i = 0; i < m; i++){
      int con = 0;
      for(auto v:s[i]){ //各電球のスイッチ候補を取り出す
        if(bit & (1<<v)) con++; //もし今のスイッチのパターンでv個目のスイッチが押されていたらカウントする
      }
      if(con % 2 != p[i]) ok = false;//もしこのスイッチの偶奇の判定がNGだったら
    }
    if(ok) res++;
  }
  cout << res << endl;
  return 0;
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  string s;cin>>s;
  set<char> se;for(char p:s)se.insert(p);
  if(se.count('N')^se.count('S'))fin("No");
  if(se.count('E')^se.count('W'))fin("No");
  fin("Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<int> makePrimes(int n) { // [2,n]
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    rep(p, 2, sqrt(n) + 2) if (pr[p]) for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    rep(p, 2, n + 1) if (pr[p]) res.push_back(p);
    return res;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    auto vp = makePrimes(N + 2);
    int ans = 0;
    int n = vp.size();
    rep(i, 0, n - 1) if (vp[i + 1] - vp[i] == 2) ans++;
    cout << ans * 2 << endl;

}


Measured memory_bytes: 45872
#include <bits/stdc++.h>
using namespace std;
int h,w;
string g[600];
bool rose(int i,int j){
	return 0<=i&&i<h&&0<=j&&j<w&&g[i][j]=='#';
}
int main(){
	cin>>h>>w;
	for(int i=h;i--;) cin>>g[i];
	vector<tuple<int,int,int>> ts;
	for(int i=0;i<=h;i++) for(int j=0;j<=w;j++){
		int a=rose(i-1,j-1),b=rose(i-1,j),c=rose(i,j-1),d=rose(i,j);
		if(a==b && a==d && a!=c) ts.emplace_back(i,j,1);
		if(a==c && a==d && a!=b) ts.emplace_back(i,j,-1);
	}
	sort(begin(ts),end(ts),[&](tuple<int,int,int> t1,tuple<int,int,int> t2){
		int a,b,x,c,d,y; tie(a,b,x,c,d,y)=tuple_cat(t1,t2);
		return a*(c+d)!=c*(a+b)?a*(c+d)<c*(a+b):x<y;
	});
	int res=0,cnt=1;
	for(auto t:ts) res=max(res,cnt+=get<2>(t));
	cout<<res<<endl;
}

Measured memory_bytes: 3364
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int neven, nodd;
  neven = nodd = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    if (ai % 2 == 0) {
      neven++;
    } else {
      nodd++;
    }
  }

  if ((nodd == 1 and neven == 0) or
      (nodd % 2 == 0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return EXIT_SUCCESS;
}



Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp2 = input[1].split(" ");
	var ans = 0;

	for (i = 0; i < parseInt(input[0]); i++) {
		ans += parseInt(tmp2[i]);
	}
	
	ans /= parseInt(input[0]);
	var answer = 0;
	var min = 1000;

	for (i = 0; i < parseInt(input[0]); i++) {
		var diff = Math.abs(ans - parseInt(tmp2[i]));
		
		if (diff < min) {
			min = diff;
			answer = i;
		}
	}
	
	//出力
	console.log('%d', answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define M 1046527/* your task*/
#define L 14
#define NIL (-1)

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
	else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;/* your task */; }
int h2(int key){ return  1 + (key%(M-1));/* your task */; }

int find(char str[])
{
long long key, i,h;
	key = getKey(str);
	for(i=0;;i++)
	{
		h=(h1(key)+i * h2(key)) % M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0) return 0;
	}
	return 0;
    /* your task */

}

int insert(char str[])
{
	long long key,i,h;
	key = getKey(str);
	for(i=0; ; i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0) return 1;
		else if(strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
    /* your task */

}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


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


int main() {
  ll x, k, d, ans;
  cin >>  x >> k >> d;
  if(x<0) x *= -1;
  if(x/d>=k) ans = x - d*k;
  else {
    k -= x/d;
    x %= d;
    if(k%2==0) ans = x;
    else ans = d-x;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  map<int, char> ALPHABETS;

  for (int i = 0; i < 26; i++) {
    ALPHABETS[i+'A'] = char('A' + i);
  }
  for (int i = 26; i < 52; i++) {
    ALPHABETS[i+'A'] = char('A' + i-26);
  }

  for (int i = 0; i < S.size(); i++) {
    cout << ALPHABETS[S[i]+N];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<set>
#include<map>

using namespace std;
long long int h,w,n, cnt[12];
map<pair<long long,long long>, int> m, check;
queue<pair<int , int> > Q;

void solve(){
    long long x,y;
    while(!Q.empty()){
        x=Q.front().first;
        y=Q.front().second;
        Q.pop();
        if(check[make_pair(x,y)]==0){
            cnt[m[make_pair(x,y)]]++;
            check[make_pair(x,y)]++;
        } 
    }
    cnt[0] = (h-2)*(w-2);
    for(int i=1;i<=9;i++){
        cnt[0]-=cnt[i];
    }
    for(int i=0;i<=9;i++){
        cout << cnt[i] << endl;
    }
}

int main(){
    cin >> h >> w >> n;
    long long x,y;
    for(int i=0;i<n;i++){
        cin >> x >> y;x--;y--;
        for(long long j=-1;j<=1;j++){
            for(long long k=-1;k<=1;k++){
                if(0<=x+j && x+j <=h-1 && 0<= y+k && y+k <=w-1){
                    m[make_pair(x+j, y+k)]++;
                    if(1<=x+j && x+j <=h-2 && 1<= y+k && y+k <=w-2){
                        Q.push(make_pair(x+j, y+k));
                    }
                }
            }
        }
    }
    solve();
}


Measured memory_bytes: 113040
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
  public class problem
  {
    public static void Main(string[] args)
    {
      string s=Console.ReadLine();
      string output="";
      int slength=0;
      for(int i=0;i<s.Length;i++)
      {
        if(s[i]=='0') output+="0";
        else if(s[i]=='1') output+="1";
        else 
        {
          if(slength!=0) output=output.Remove(slength-1);
        }
        slength=output.Length;
      }
      Console.WriteLine(output);
    }
  }
}


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

int main(){
  int a,b,c,d;
  int AB,BC,AC;
  scanf("%d %d %d %d",&a,&b,&c,&d);

  AB = abs(a-b);
  BC = abs(b-c);
  AC = abs(a-c);

  if(AC <= d){
    printf("Yes");
  }else if(AB <= d && BC <= d){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


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

using namespace std;

int main(){

	int n,x;
	cin >> n >> x;
	vector<int> m(n, 0);
	int minn = 1001;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		minn = min(minn, m[i]);
	}
	cout << n + (x - accumulate(m.begin(), m.end(), 0)) / minn << endl;
}

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




int main()
{
	char str[ 64 ] ;
	scanf( "%s" ,str ) ;



	int i = strlen( str ) ;
	while( i-- )
	{
		printf( "%c" ,str[ i ] ) ;
	}


	puts( "" ) ;



	return 0 ;
}

Measured memory_bytes: 524
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct dish {
	ll A, B, C;
	bool operator < (const dish& b) {
		return C > b.C;
	}
};
dish D[100010];
int main() 
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i].A >> D[i].B;
		D[i].C = D[i].A + D[i].B;
	}
	ll l[2] = { 0 };
	sort(D, D + N);
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			l[0] += D[i].A;
		}
		else {
			l[1] += D[i].B;
		}
	}
	cout << l[0] - l[1] << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(a>=b)cout << "delicious" << endl;
  else if(b-a<=x)cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[200005];

int main() {
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> P[i];
    }
    double ans = 0;
    double sm = 0;
    ll s = 0;
    REP(i, N) {
        sm += (double) (P[i] * (P[i] + 1) / 2) / ((double) P[i]);
        if (i - s >= K) {
            sm -= (double) (P[s] * (P[s] + 1) / 2) / ((double) P[s]);
            s++;
        }
        ans = std::max(ans, sm);
    }
    cout << OF64 << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int n; cin >> n; 
    int h[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin >> h[i][j];
        }
    }
    for(int i=0;i<3;i++)
    {
        dp[0][i]=h[0][i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+h[i][j];
            }
            else if(j==1)
            {
                dp[i][j]=max(dp[i-1][j-1],dp[i-1][j+1])+h[i][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+h[i][j];
            }
        }
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
#include<iostream>


using namespace std;

int main() {
	string S;
	cin >> S;
	
	string s = "";

	for (int i = 0; i < S.length() / 2; i++) {
		s += "hi";
		if (S == s) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;


}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000000
void maxHeapify(int);
int left(int);
int right(int);
void swap(int,int);

int n,heap[MAX];

int main(){	
	int i;

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&heap[i]);
	}

	for(i=n/2;i>=1;i--){
	maxHeapify(i);
	}


	for(i=1;i<=n;i++){
		printf(" %d",heap[i]);
	}
	printf("\n");

	return 0;
}

void maxHeapify(int i){
	int l,r,largest;

	l = left(i);
	r = right(i);

	if(l <= n && heap[l] > heap[i]) largest = l;
	else largest = i;

	if(r <= n && heap[r] > heap[largest]) largest = r;

	if(largest != i){
		swap(i,largest);
		maxHeapify(largest);
	}
}

int left(int i){
	return 2 * i;
}

int right(int i){
	return 2 * i + 1;
}

void swap(int a,int b){
int temp;

temp = heap[a];
heap[a] = heap[b];
heap[b] = temp;

}

Measured memory_bytes: 2556
#include <cstdio>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	   int X,Y,Z,sum=0;
	for(X=0;X<=a;X++)
	 for(Y=0;Y<=a;Y++)
	{	   Z=b-X-Y;
	if(Z>=0&&Z<=a)
	{sum=sum+1;
	}
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  int count = 0;
  
  rep(i, N){
    cin >> h[i];
    if(h[i] >= K) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int n,x=0,max=0,i;
    char s[100];
    scanf("%d %s",&n,s);
    for(i=0;i<n;i++){
        if(s[i]=='I') x++;
        else x--;
        if(x>max) max=x;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
/*Bismillahir Rahmanir Rahim*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector <long long> vll;
typedef pair<int, int> pii;
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Macro Start-*-*-*-*-*-*-*--*-*-*-*-*/

#define Faster_IO              ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F                      first
#define S                      second
#define pb                     push_back
#define MP                     make_pair
#define sf                     scanf
#define pf                     printf
#define PI                     (2*acos(0))
#define to_radian(degree)      ((pi/180)*degree)
#define to_degree(radian)      ((180/pi)*radian)
#define SQ(a)                  (a)*(a)
#define SORT(x)                sort(x.begin(),x.end())
#define rSORT(x)               sort(x.rbegin(),x.rend())
#define SetPrint(a,x)          cout<<fixed<<setprecision(x)<<a<<endl
#define show(vec)              for (int i=0; i<vec.size(); i++)cout << vec[i] << " ";
#define lines                  cout <<"\n" <<"---------------" << "\n";
#define YES                    printf("YES\n")
#define NO                     printf("NO\n")
#define Yes                    printf("Yes\n")
#define No                     printf("No\n")
#define testcase(n)            int n; cin >> n; while(n--)
#define lcm(a,b)               ((a / __gcd(a,b) ) * b)
#define gcd(a,b)               __gcd(a,b)
#define all(vec)               vec.begin(), vec.end()
#define SUM(vec)               accumulate(vec.begin(), vec.end(), 0)
#define gcin(str)              getline(cin, str)
///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Macro END-*-*-*-*-*-*-*--*-*-*-*-*/

///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Template Start-*-*-*-*-*-*--*-*-*-*-*/

//template <class T> T isPrime(T n){if(n<=1)return 0;for(long long i=2;i*i<=n; i++)if(n%i==0)return 0;return 1;}
//template <class T> T bigmod(T X, T n, T M) {if (n==0) return 1;if (n%2) return ((X%M) * bigmod(X,n-1,M)) %M;else {long long int d = bigmod(X,n/2, M);return ((d%M) * (d%M))%M;}}

///*-*-*-*-*-*-*-*-*-*-*-*-*-*-Template END-*-*-*-*-*-*-*--*-*-*-*-*/


int main()
{
    Faster_IO
    #ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    #endif

    int k, n;
    vi v;
    cin >> n >> k;
    while(n--)
    {
        int a;
        cin >> a;
        v.pb(a);
    }

    SORT(v);
    
    ll sum=0;

    for (int i = 0; i < k; ++i)
    {
        sum+=v[i];
    }

    cout << sum << "\n";

    return 0;
}


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

#define ll long long int
#define vi vector<int>
#define ii pair< int , int >
#define vii vector<ii>
#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)
int MAX(int a, int b){return (a > b) ? a:b;}
int MIN(int a, int b){return (a < b) ? a:b;}
int ABS(int x){return (x > 0) ? x:-x;}
int left(int x){return (x<<1);}
int right(int x){return (x<<1)+1;}
int lsone(int x){return (x&(-x));}

const int maxn = 1e5 + 5;
int n, k, h[maxn];
int ans[maxn];
bool found[maxn];

int dp(int pos){
	if(pos == n) return 0;
	if(found[pos]) return ans[pos];
	found[pos] = true;
	ans[pos] = 2e9;
	for(int i = 1; i <= k && pos+i <= n; i++){
		ans[pos] = min(ans[pos], dp(pos+i) + abs(h[pos]-h[pos+i]));
	}
	return ans[pos];
}

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%d", &h[i]);
	}
	printf("%d\n", dp(1));
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y, std::vector<long long> z){
    LL ans = 0;
    REP(idx, 8){
        VLL scores;
        REP(i, N) {
            scores.PB(x[i] * (idx < 4 ? 1 : -1) + y[i] * ((idx/2)%2==0 ? 1 : -1) + z[i] * (idx % 2 == 0 ? 1 : -1));
        }

        sort(ALL(scores));
        LL memo = 0;
        REP(i, M) {
            memo += scores[N-1-i];
        }

        ans = max(ans, memo);
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> z(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&z[i]);
    }
    solve(N, M, std::move(x), std::move(y), std::move(z));
    return 0;
}


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

using namespace std;

int A[2000];
int n, q, m;
int t=0;

bool solve(int j){
	if (j==n) return false;
	t += A[j];
	if (t==m) return true;
	if (t<m){
		if (solve(j+1)) return true;
	}
	t -= A[j];
	return solve(j+1);
}

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> A[i];
	sort(A, A+n, [](int a,int b){return a>b;});
	cin >> q;
	for (int i=0;i<q;i++) {
		t = 0;
		cin >> m;
		cout << (solve(0) ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define lli long long int
#define timesave ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;


void solve(int t_case)
{
    lli n;
    cin >> n;

    lli val = n + (n*n) + (n*n*n);

    cout << val << "\n";
}
 
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //timesave;

    int tc = 1, t_case = 1;
    //cin >> tc;
    while(tc--) solve(t_case++);
 
    return 0;
}

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

static const ll MOD=1000000007;

int main() {
    string s;
    cin >> s;
    int n=s.size();
    vector<vector<ll>> dp;
    for (int i=0;i<n+1;i++) {
        vector<ll> v(13);
        dp.push_back(v);
    }
    dp[0][0]=1;
    for (int i=0;i<n;i++) {
        if (s[i]=='?') {
            for (int j=0;j<13;j++) {
                for (int k=0;k<10;k++) {
                    dp[i+1][(j*10+k)%13]+=dp[i][j];
                    dp[i+1][(j*10+k)%13]%=MOD;
                }
            }
        } else {
            for (int j=0;j<13;j++) {
                dp[i+1][(j*10+(s[i]-'0'))%13]+=dp[i][j];
                dp[i+1][(j*10+(s[i]-'0'))%13]%=MOD;
            }
        }
    }
    cout << dp[n][5] << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int a = 0;
  for (int i = 0 ; i < M ; i++) {
  int x;
  cin >> x;
  a += x;
  }
  
  if ( a <= N ) {
  cout << N - a << endl;
  }
  
  else {
  cout << "-1" << endl;
  }
}
  
    

  

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, W; cin >> n >> W;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; i++) cin >> v.at(i) >> w.at(i);
    
    vector<vector<int>> dp(n + 1, vector<int>(W + 1, 0));
    // dp[i][j] は、(i - 1)番目までの品物を、重さj以下の制限の下で入れた際に価値合計の最大値
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= W ; j++) {
            if (w.at(i) > j) dp.at(i + 1).at(j) = dp.at(i).at(j);
            else dp.at(i + 1).at(j) = max(dp.at(i).at(j - w.at(i)) + v.at(i), dp.at(i).at(j));
        }
    }
    
    cout << dp.at(n).at(W) << endl;
    
    return 0;
}



Measured memory_bytes: 6752
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;

int main() {
	LL A, B;
	cin >> A >> B;
	for (int i = 0; i <= 9; i++) {
		LL tmp = B * 10 + i;
		if (tmp * 8 / 100 == A) {
			cout << tmp << "\n";
			return 0;
		}
	}
	printf("-1\n");
}

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

int main() {
  long long n;
  cin >> n;
  
  vector<long long> v,w;
  
  for(long long i=0; i<n; i++){
    long long a;
    cin >> a;
    v.push_back(a);
    w.push_back(a);
  }
  
  sort(v.begin(), v.end());
  long long high = v[n/2+1];
  
  for(auto p: w)
    cout << ((p<v[n/2]) ? v[n/2] : v[n/2-1]) << endl;
    
}

Measured memory_bytes: 5476
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define INF 100000000
#define uint unsigned int
#define MOD 1e9+7
using namespace std;


int main() {
	int A, B, K;
	cin >> A >> B >> K;
	int cmn_div = 0;
	for (int k = 0 , div = max(A,B) ; k <  K ; div--) {

		if (A % div == 0 && B % div == 0) {
			cmn_div = div;
			k++;
		}
		else {
			continue;
		}
	}

	cout << cmn_div << endl;
}


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

class MainClass : Scanner
{
    static void Main()
    {
        var (A, B) = ReadTuple<int,int>();
        var S = RString();
        var ss = S.Split("-");
        bool frag = true;
        if (ss.Length != 2) frag = false;
        else if (ss[0].Length == A && ss[1].Length == B)
        {

        }
        else frag = false;
        WriteLine(frag?"Yes":"No");
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27480
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const int MAX_V = 1e5;
const int MAX_N = 1e5;
const int MAX_E = 1e6;
struct edge {int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

edge es[MAX_E];
int V, E;

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n) {
	rep(i, 0, n) {
		par[i] = i;
		depth[i] = 0;
	}
}

// 木の根を求める
int find(int x) {
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(depth[x] < depth[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}

int kruskal() {
	sort(es, es + E, comp);
	init(V);
	int res = 0;
	rep(i, 0, E) {
		edge e = es[i];
		if(!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

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

	cin >> V;

	vector<pair<ll, ll> > vx, vy;

	rep(i, 0, V) {
		int x, y;
		cin >> x >> y;
		vx.push_back(make_pair(x, i));
		vy.push_back(make_pair(y, i));
	}
	vsort(vx);
	vsort(vy);

	E = 0;
	rep(i, 0, V - 1) {
		int a, b, c, d;
		a = vx[i].first;
		c = vx[i + 1].first;
		int dx = abs(a - c);
		es[E].u = vx[i].second;
		es[E].v = vx[i + 1].second;
		es[E].cost = dx;
		E++;
		/*
		es[E].u = vx[i + 1].second;
		es[E].v = vx[i].second;
		es[E].cost = dx;
		E++;
		*/
		
		b = vy[i].first;
		d = vy[i + 1].first;

		int dy = abs(b - d);
		es[E].u = vy[i].second;
		es[E].v = vy[i + 1].second;
		es[E].cost = dy;
		E++;
		/*
		es[E].u = vy[i + 1].second;
		es[E].v = vy[i].second;
		es[E].cost = dy;
		E++;
		*/
	}


	cout << kruskal() << endl;
}


Measured memory_bytes: 7652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int d = sc.NextInt();

        int start = Math.Max(a, c);
        int end = Math.Min(b, d);

        int answer = start < end ? end - start : 0;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int a[200005], b[200005], n;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++) scanf("%d", a+i), b[i] = a[i];
	sort(b, b+n);
	int m1 = b[n/2-1], m2 = b[n/2];
	for (int i = 0;i < n;i++)
		if (a[i] <= m1) printf("%d\n", m2);
		else printf("%d\n", m1);
	return 0;
}


Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int [] nums = new int[a];
		for (int i = 0; i <a; i++) {
			int ai = s.nextInt();
			nums[i]=ai;
		}
		Arrays.sort(nums);
		double fix = nums[0];
		for (int i = 1; i <a; i++) {
			fix = (fix+nums[i])/2;
		}
		System.out.println(fix);
		

	}

}


Measured memory_bytes: 21716
j = list(map(int, input().split()))
counter = 0
j.sort()

if (j[0] >= 3):
  print((j[0] - 2) * (j[1] - 2))
elif (j[0] == 2):
  print(0)
elif (j[0] == 1):
  if j[1] == 1:
    print(1)
  else:
    print(j[1] - 2)

Measured memory_bytes: 3064
from bisect import bisect_left
from itertools import accumulate

def resolve():
    def getCount(x):
        cnt = 0
        for a in A:
            # X未満の個数
            idx = bisect_left(A, x - a)
            # X以上の個数
            cnt += N - idx
        # X以上を使う！と決めた時、M個以上になるか
        return cnt >= M

    N, M = map(int, input().split())
    A = sorted(map(int, input().split()))

    ng = 10 ** 9
    ok = 0
    # X以上を使う！と決めるとX以上の個数が自明にわかる。
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if getCount(mid):
            ok = mid
        else:
            ng = mid

    # M個以上あることがわかれば、Mよりも余分な数(同じ値が複数ある場合)
    # はすべてXである事がわかるため、差分だけ引けば良い。
    B = [0] + list(accumulate(A))
    ans = 0
    cnt = 0
    for i in range(N):
        idx = bisect_left(A, ok - A[i])
        ans += B[N] - B[idx] + A[i] * (N - idx)
        cnt += N - idx

    rest = (cnt - M) * ok
    print(ans - rest)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 20712
#include<stdio.h>
 
int main(void) {
int n;
int x;
int num;
int min = 1000001;
int max = -1000001;
long total = 0;
 
scanf("%d", &n);
for (x = 0; x < n; x++) {
scanf("%d", &num);
if (min > num) min = num;
if (max < num) max = num;
total += num;
}
printf("%d %d %ld\n", min, max, total);
 
return (0);
}

Measured memory_bytes: 600