akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

int main( )
{
	string cards, tmp;
	int m, h;
	
	while( cin>>cards ) {
		if( "-" == cards ) { break; }
	
		cin>>m;
		while( m-- ) {
			cin>>h;
			tmp = cards.substr( 0, h );
			cards = cards.substr( h );
			cards.append( tmp );
		}
		cout<<cards<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int h,w,a,b;
const int mod = 1e9+7;

ll mod_pow(ll x, ll n, ll mod){
  if(n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}

ll fact[222222];
ll inv[222222];

// nCk mod p
ll mod_comb(ll n, ll k){
  return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w >> a >> b;

  // 0 <= x <= h+w-2の
  // x! (mod 10^9+7)のテーブルfact
  // (x!)^(-1) (mod 10^9+7)のテーブルinvを作る
  fact[0] = 1;
  inv[0] = 1;
  for(int i=1;i <= h+w-2;i++){
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod_pow(fact[i],mod-2, mod);
  }

  ll ans = 0;
  for(int i=0;i < w-b;i++){
    ans = (ans+(mod_comb(h-a-1+b+i, h-a-1) * mod_comb(a-1+w-b-1-i, a-1)%mod))%mod;
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def turn(s,sa,sb,sc):
    if s == 'a':
        if len(sa) == 0:
            print('A')
            exit()
        trash = sa[-1]
        sa = sa[:-1:]
    elif s == 'b':
        if len(sb) == 0:
            print('B')
            exit()
        trash = sb[-1]
        sb = sb[:-1:]
    else:
        if len(sc) == 0:
            print('C')
            exit()
        trash = sc[-1]
        sc = sc[:-1:]
    return turn(trash,sa,sb,sc)

sa = readline().decode().rstrip()[::-1]
sb = readline().decode().rstrip()[::-1]
sc = readline().decode().rstrip()[::-1]

trash = sa[-1]
sa = sa[:-1:]

print(turn(trash,sa,sb,sc))

Measured memory_bytes: 9132
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>

int D;
int E;

int main() {
  while(scanf("%d %d", &D, &E), D||E) {
    double diff = 10e10;

    for (int i=0; i<=D; i++) {
      int x = i;
      int y = D - i;

      if (diff > fabs(E - sqrt(x*x + y*y))) {
	diff = fabs(E - sqrt(x*x + y*y));
      }
    }

    printf("%.10g\n", diff);
  }
}

Measured memory_bytes: 3208
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int a[200010];
std::set<int> numSet;
		
int main()
{
	scanf("%d", &n);
	
	numSet.clear();
	bool isAccepted = true;
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));		
		if (numSet.find(a[i]) == numSet.end())
			numSet.insert(a[i]);
		else
			isAccepted = false;
	}
	
	if (isAccepted) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

		
	
	
	return 0;
}


Measured memory_bytes: 10368
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"queue"
#include"map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
struct vert
{
	ll x,y,no;
	bool operator<(const vert & ob)const
	{
		return x<ob.x;
	}
};
struct edge
{
	vert v1,v2;
	ll len;
	bool operator<(const edge & ob)const
	{
		return len<ob.len;
	}
};
bool comp(const vert &ob1,const vert &ob2)
{
	return ob1.y<ob2.y;
}
ll dist(vert u,vert v)
{
	return min(abs(v.x-u.x),abs(v.y-u.y));
}
const ll maxn=1e5+5;
ll pare[maxn];
ll find(ll x)
{
	return x==pare[x]?x:pare[x]=find(pare[x]);
}
void merge(ll x,ll y)
{
	pare[find(x)]=find(y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    vector<vert>vx(n),vy(n);
    for(ll i=0;i<n;++i)
    {
    	ll x,y;cin>>x>>y;
    	vert ob;ob.x=x;ob.y=y;ob.no=i;
    	vx[i]=ob;
    	vy[i]=ob;
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end(),comp);
    vector<edge>ed(2*(n-1));ll in=0;
    for(ll i=1;i<n;++i)
    {
    	 vert u=vx[i-1],v=vx[i];
    	 edge ob;ob.v1=u;ob.v2=v;
    	 ob.len=dist(u,v);
    	 u=vy[i-1];v=vy[i];
    	 edge ob1;ob1.v1=u;ob1.v2=v;
    	 ob1.len=dist(u,v);
    	 ed[in++]=ob;
    	 ed[in++]=ob1;
    }
    for(ll i=0;i<n;++i)    
    {
    	pare[i]=i;
    }
    sort(ed.begin(),ed.end());
    ll ans=0;
    for(ll i=0;i<2*(n-1);++i)
    {
    	edge ob=ed[i];
    	ll v1=ob.v1.no,v2=ob.v2.no;
    	if(find(v1)!=find(v2))
    	{
    		ans+=ob.len;merge(v1,v2);
    	}
    }
    cout<<ans<<'\n';
}











Measured memory_bytes: 16640
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

const SIZE = 4;

board = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline)
  .map(function (line) { return line.split(' ').map(Number); });

goal = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,0]];

function find(num) {
  var i, j, res = [,];
  for (i = 0; i < SIZE; i++) {
    for (j = 0; j < SIZE; j++) {
      if (board[i][j] == num) {
        res[0] = i;
        res[1] = j;
      }
    }
  }
  return res;
}

function switch_board(row1, col1, row2, col2) {
  var tmp = board[row1][col1];
  board[row1][col1] = board[row2][col2];
  board[row2][col2] = tmp;
}

distance = new Array(SIZE*SIZE);
for (i = 0; i < SIZE*SIZE; i++) distance[i] = [-1, -1];

function get_distance() {
  var sum = 0, d = distance, i, j;
  for (i = 0; i < SIZE; i++) {
    for (j = 0; j < SIZE; j++) {
      d[board[i][j]][0] = i;
      d[board[i][j]][1] = j;
    }
  }
  for (i = 0; i < SIZE; i++) {
    for (j = 0; j < SIZE; j++) {
      d[goal[i][j]][0] -= i;
      d[goal[i][j]][1] -= j;
    }
  }
  for (i = 1; i < SIZE*SIZE; i++)
    sum += Math.abs(d[i][0]) + Math.abs(d[i][1]);
  return sum;
}

const INITDIR = 0, N = 1, S = 2, W = 3, E = 4;

function iddfs(step, max, row, col, dir) {
  var i, j;
  //console.log("step=%d, row=%d, col=%d, dir=%d, distance=%d",
  //  step, row, col, dir, get_distance());
  if (step === max) {
    for (i = 0; i < SIZE; i++)
      for (j = 0; j < SIZE; j++)
        if (board[i][j] !== goal[i][j]) return false;
    return true;
  }

  if (step + get_distance() > max) return false;

  if (dir !== W && row > 0) {
    switch_board(row, col, row-1, col);
    if (iddfs(step + 1, max, row-1, col, E)) return true;
    switch_board(row, col, row-1, col);
  }
  if (dir !== E && row < 3) {
    switch_board(row, col, row+1, col);
    if (iddfs(step + 1, max, row+1, col, W)) return true;
    switch_board(row, col, row+1, col);
  }
  if (dir !== S && col > 0) {
    switch_board(row, col, row, col-1);
    if (iddfs(step + 1, max, row, col-1, N)) return true;
    switch_board(row, col, row, col-1);
  }
  if (dir !== N && col < 3) {
    switch_board(row, col, row, col+1);
    if (iddfs(step + 1, max, row, col+1, S)) return true;
    switch_board(row, col, row, col+1);
  }
  return false;
}

rc = find(0);
for (i = 0; i <= 45; i++)
  if (iddfs(0, i, rc[0], rc[1], INITDIR)) break;
console.log(i);

Measured memory_bytes: 16200
n =[]

for _ in range(4):
  n += map(int, input().split())

num = 0
  
for i in range(n[0]+1):
  for j in range(n[1]+1):
    for k in range(n[2]+1):
      total = 50*k + 100*j + 500*i
      if total == n[3]:
        num += 1
        
print(num)

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

  int A,B;cin >> A >> B ;
  if(A >= 13){
    cout << B;
  }else if(6<=A && A<=12){
    cout << B/2;  
  }else{
    cout << 0;
  }
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int c=0,n,m,i,j,maxx=0;
	char a[20];
	char aa[100][20];
	map<int,int> mm;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
		scanf("%s",a);
		int flag=0;
		for(j=0;j<c;j++)
		{
			if(strcmp(a,aa[j])==0)
			{
				flag=1;
				break;
			}
		}
		if(flag)
			mm[j]++;
		else
		{
			mm[c]=1;
			strcpy(aa[c],a);
			c++;
		}
	}
	scanf("%d",&m);
	for(i=0;i<m;i++)
    {
		scanf("%s",a);
		int flag=0;
		for(j=0;j<c;j++)
		{
			if(strcmp(a,aa[j])==0)
			{
				flag=1;
				break;
			}
		}
		if(flag)
			mm[j]--;
	}
	for(i=0;i<c;i++)
	{
		//printf("%d\n",mm[i]);
		maxx=max(maxx,mm[i]);
	}
	printf("%d",maxx);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;


int main(void) {

  string s;
  while(cin >> s){
    if( s == "#" ) break;

    int d1 = 0, d2 = 1;
    for(int i=s.size()-1; i>=0; i--){
      if( s[i] == 'n' ){
        d1 = 2 * d1 - 90;
        if( d1 < 0 ) d1 = 0;
        d2 *= 2;
      }else if( s[i] == 'w' ){
        d1 = 2 * d1 + 90;
        d2 *= 2;
      }
    }
    d2 /= 2;
    while( true ){
      if( !(d1 % 2 == 0 && d2 % 2 == 0) ) break;
      d1 /= 2;
      d2 /= 2;
    }
    if( d2 == 1 ) cout << d1 << endl;
    else cout << d1 << "/" << d2 << endl;

  }

  return 0;
}

// EOF

Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
unsigned long long i,j,n,m,x,k,y,a,b;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n;
    i=1;
    while (i<=n&&i<10)
    {
        cout << i << "\n";
        i++;
    }
    m=9;
    x=10;
    while (i<=n)
    {
        m+=x;
        cout << m << "\n";
        k=m+x;
        y=0;
        while (k>0)
        {
            y+=k%10;
            k/=10;
        }
        a=m+x*10;
        b=0;
        while (a>0)
        {
            b+=a%10;
            a/=10;
        }
        //cout << m+x*10 << " " << y << " " << m+x << " " << b << "\n";
        if ((m+x*10)*y<=(m+x)*b)
        {
            x*=10;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int collatz(int i)
{
  if(i % 2 != 0) return i * 3 + 1;
  else return i / 2;
}
int main(void)
{
  int n, i;
  std::cin >> n;
  if(n == 1 || n == 2) i = 0;
  else for(i = 0; n != 4; i++) n = collatz(n);
  std::cout << i + 4 << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		
		Scanner sin = new Scanner(System.in);
		int n = sin.nextInt();
		if(n<=999) {
			System.out.println("ABC");
		}
		else {
			System.out.println("ABD");
		}
		

	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  string a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  int all_cnt = 0;
  bool exist[N];
  bool exi = false;
  for (int j = 0; j < N; j++) {
    bool all = true;
    exist[j] = false;
    for (int i = 0; i < N; i++) {
      all &= a[i][j] == '#';
      exist[j] |= a[i][j] == '#';
    }
    if (all) all_cnt++;
    exi |= exist[j];
  }
  if (!exi) {
    cout << -1 << '\n';
    return 0;
  }
  const long long INF = LLONG_MAX / 10;
  long long ans = INF;
  for (int i = 0; i < N; i++) {
    long long tmp = 0;
    if (!exist[i]) tmp++;
    for (int j = 0; j < N; j++)
      if (a[i][j] != '#') tmp++;
    tmp += N - all_cnt;
    ans = min(ans, tmp);
  }
  if (ans == INF) ans = -1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3900
n=int(input())
l=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        l[i].append([x,y])
op=['0','1']
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+'0')
        tmp.append(j+'1')
    op=tmp
ans=0
for i in op:
    t=list(i)
    f=0
    for j in range(n):
        if i[j]=='1':
            for k in l[j]:
                if t[k[0]-1]!=str(k[1]):
                    f+=1
    if f==0:
        p=0
        for q in t:
            if q=='1':
                p+=1
        ans=max(ans,p)
print(ans)

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

int N,M,R;
int inf = 1<<29;
int d[201][201] = {{0}};
int A[9] = {0};

void warshall_floyd(){
	for(int k=1;k<=N;k++){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
			}
		}
	}
}

int main(){
	cin >> N >> M >> R;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			if(i!=j) d[i][j] = inf;
		}
	}
	for(int i=1;i<=R;i++){
		cin >> A[i];
	}
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	warshall_floyd();
	int ans = inf;
	sort(A+1,A+R+1);
	do{
		int now = 0;
		for(int i=1;i<=R-1;i++){
			now += d[A[i]][A[i+1]];
		}
		ans = min(now,ans);
	}while(next_permutation(A+1,A+R+1));
	cout << ans << endl;
}

Measured memory_bytes: 384
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	// x - > r to w - r, y -> r to h - r
	int w, h, x, y, r;cin >> w >> h >> x >> y >> r;
	if(x >= r && x <= w - r && y >= r && y <= h - r)puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  int N;
  vector<vector<int>> v;
  cin >> N;
  v.assign(N, vector<int>(3, 0));

  for (auto &&i : v)
  {
    cin >> i.at(0) >> i.at(1) >> i.at(2);
  }

  vector<int> temp = {0, 0, 0};
  v.insert(v.begin(), temp);

  int t_diff = 0,
      l_diff = 0;
  for (int i = 0; i < N; i++)
  {
    t_diff = v[i + 1][0] - v[i][0];
    l_diff = abs(v[i + 1][1] + v[i + 1][2] - (v[i][1] + v[i][2]));

    if (t_diff < l_diff)
    {
      //cout << t_diff << " " << l_diff << endl;
      cout << "No" << endl;
      return 0;
    }

    if (l_diff % 2 == 0 && t_diff % 2 != 0)
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <algorithm>

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define pre(i, a, b) for(int i = a; i >= b; i --)

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int a[maxn][4], dp[maxn][4], n;

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

int main()
{
	n = read();
	rep(i, 1, n)
	{
		rep(j, 1, 3)
		{
			a[i][j] = read();
		}
	}
	rep(i, 1, 3)
	{
		dp[1][i] = a[1][i];
	}
	rep(i, 2, n)
	{
		rep(j, 1, 3)
		{
			rep(k, 1, 3)
			{
				if(k == j)continue; //Á½¸ö»î¶¯²»ÄÜÏàÍ¬ 
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
			}
		}
	}
	int ans = 0;
	rep(i, 1, 3)
	{
		ans = max(dp[n][i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(void)
{
    string str;
    string ans;
    cin >> str;
    if(str[0] >= 'a' && str[0] <= 'z') ans = 'a';
    if(str[0] >= 'A' && str[0] <= 'Z') ans = 'A';
    cout << ans << endl;
    return 0;

}

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

using namespace std;

int main()
{
  int64_t n;

  cin >> n;
  int64_t a,b,cnt;

  b = 0;
  cnt = 0;
  for(int64_t i = 0;
      i < n;
      ++i)
    {
      cin >> a;
      if(a != i + 1)
        {
          ++cnt;
        }
      b = a;
    }

  if(cnt == 2 || cnt == 0)
    {
      cout << "YES" << endl;
    }
  else
    {
      cout << "NO" << endl;
    }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin>>s;
    int n = s.size();
    if(n==2){
        if(s[0] == s[1]) cout<<1<<' '<<2<<endl;
        else cout<<-1<<' '<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n-3;i++){
        if(s[i] == s[i+1]|| s[i] == s[i+2] || s[i+1] == s[i+2] ) {
            cout<<i+1<<' '<< i+2+1<<endl;
            return 0;
        }
    }
    cout<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 512
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
HS=LI()

cnt = 0
res = 0
for i in range(N-1):
    if HS[i+1] <= HS[i]:
        cnt += 1
    else:
        cnt = 0
    res = max(cnt, res)

print(res)

Measured memory_bytes: 14380
#include <stdio.h>

int main(void){
	int N,SUM;
	scanf("%d%d",&N,&SUM);
	SUM /=1000;
	int x,y,z;
	int i,j;
	/*10x + 5y + z = SUM*/
	/*x + y + z = N;*/
	/*z = N - x - y */
	/*10x + 5y + N - x - y = SUM*/
	/*9x + 4y + N = SUM */
	/*9x + 4y = SUM - N*/
	int temp = SUM - N;
	for(i=0;i<=N;i++){
		for(j=0;j<=N;j++){
			if( (i*9 + 4*j) == temp){
				if( (N-i-j)<0)continue;
				printf("%d %d %d",i,j,N-i-j);
				return 0;
			}
		}
	}
	printf("-1 -1 -1");
	return 0;
}

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

using namespace std;

int main(){
    int n, count = 0;
    cin >> n;
    int a[n];
    vector<int> v;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i = 0; i < n;){
        if(a[i] == a[i+1]){
            i+=2;
        }else{
            v.push_back(a[i]);
            i++;
        }
    }
    cout << v.size();


    return 0;
}


Measured memory_bytes: 1276
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int r = int.Parse(s[0]);
        int D = int.Parse(s[1]);
        long x = int.Parse(s[2]);

        for(int i = 0; i < 10; i++)
        {
            x = r * x - D;
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 11092
def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    
    B = []
    for i in range(H):
        for j in range(W):
            if A[i][j] % 2:
                if i < H - 1:
                    B.append(map(str, [i + 1, j + 1, i + 2, j + 1]))
                    A[i][j] -= 1
                    A[i + 1][j] += 1
                    continue
                elif j < W - 1:
                    B.append(map(str, [i + 1, j + 1, i + 1, j + 2]))
                    A[i][j] -= 1
                    A[i][j + 1] += 1
    
    print(len(B))
    for b in B:
        print(" ".join(b))

if __name__ == "__main__":
    main()


Measured memory_bytes: 72668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy";
    }else if(s == "Cloudy"){
        cout << "Rainy";
    }else{
        cout << "Sunny";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main(){
    ll H;
    ll W;
    cin >> H >> W;

    ll sum = H * W;
    if((H == 1) || (W == 1)) sum = 1;
    else if(sum % 2 == 0) sum = sum / 2;
    else sum = sum / 2 + 1;

    cout << sum << endl;

}

Measured memory_bytes: 3516
#include<algorithm> 
#include<cstdio>
#define N 100001
using namespace std;
int b[N],f[N],h[N],i,n,s[N];long long a[N],t;
inline bool cmp(int u,int v){return a[u]<a[v];}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld",a+i),s[b[i]=i]=1;
	sort(b+1,b+n+1,cmp);
	for(i=n;i>1;i--)
	{
		if(s[b[i]]<<1>=n)return 0*puts("-1");
		*a=a[b[i]]-n+(s[b[i]]<<1),f[b[i]]=lower_bound(b+1,b+n+1,0,cmp)-b;
		if(f[b[i]]>n||a[b[f[b[i]]]]!=*a)return 0*puts("-1");
		s[f[b[i]]=b[f[b[i]]]]+=s[b[i]];
	}
	for(i=2;i<=n;i++)t+=h[b[i]]=h[f[b[i]]]+1;
	if(t!=a[b[1]])return 0*puts("-1");
	for(i=2;i<=n;i++)printf("%d %d\n",b[i],f[b[i]]);
	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void dfs(int x, int y, int &sum, vector<string> &field)
{
  field[y][x] = '#';
  sum++;
  for (int i = 0; i < 4; ++i)
  {
    int ny = y + dy[i], nx = x + dx[i];
    if (0 <= ny && ny < field.size() && 0 <= nx && nx < field[0].size() && field[ny][nx] == '.')
    {
      dfs(nx, ny, sum, field);
    }
  }
}

int main()
{
  int w, h;
  while (cin >> w >> h, w || h)
  {
    vector<string> field(h);
    for (auto &e : field)
      cin >> e;
    int sx, sy;
    for (int i = 0; i < h; ++i)
    {
      for (int j = 0; j < w; ++j)
      {
        if (field[i][j] == '@')
        {
          sy = i, sx = j;
          field[i][j] = '#';
        }
      }
    }
    int sum = 0;
    dfs(sx, sy, sum, field);
    cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 8938103643641919514ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g,n,m;
int dx[]={0,-1,0,1,0};
int i,j,k;
struct A{
	int w;
	vector<int> e;
};
A p[100000];
int saiki(int oya,int u){
	if(p[u].e.size()==1)
		return p[u].w;
	int ma=-1,go=0,ii=0;
	for(auto x:p[u].e){
		if(x==oya)
			continue;
		auto y=saiki(u,x);
		go+=y;
		ma=max(ma,y);
		ii++;
	}
	if(ii==1){
		if(p[u].w!=go)
			throw 'c';
		return p[u].w;
	}
	if(go<p[u].w||go>p[u].w*2)
		throw 'a';
	int aa=(go-p[u].w);
	int bb=(ma>go/2)?(go-ma):(go/2);
	if(aa>bb)
		throw 'b';
	return p[u].w-aa;
}
int q[100000];
signed main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>p[i].w;
	}
	for(i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		p[u].e.push_back(v);
		p[v].e.push_back(u);
	}
	try{
		if(n==2){
			if(p[0].w!=p[1].w)
				throw 'd';
		}else{
			for(i=0;p[i].e.size()<=1;i++);
			if(saiki(-1,i))
				throw 'e';
		}
		cout<<"YES"<<endl;
		return 0;
	}catch(char c){
		cout<<"NO"<<endl;
		return 0;
	}
}

Measured memory_bytes: 13184
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
const int Mod=998244353;
int f[410][410][410];
int fac[410],inv[410];
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int fpow(int a,int b)
{
	int ans=1,t=a;
	while(b)
	{
		if(b&1)ans=1ll*ans*t%Mod;
		t=1ll*t*t%Mod;
		b>>=1;
	}
	return ans;
}
void init()
{
	fac[0]=1;
	for(int i=1;i<=400;i++)
		fac[i]=1ll*fac[i-1]*i%Mod;
	inv[400]=fpow(fac[400],Mod-2);
	for(int i=400;i;i--)
		inv[i-1]=1ll*inv[i]*i%Mod;
	return ;
}
int main()
{
	init();
	int n;scanf("%d",&n);
	int S=0,T=0;//sum of A,sum of B-1
	f[0][0][0]=Mod-1;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		for(int x=0;x<=S;x++)
			for(int y=0;y<=T;y++)
			{
				if(!f[i-1][x][y])continue;
				int A=1;
				for(int k=0;k<b;k++)
				{
					add(f[i][x+a][y+k],Mod-1ll*f[i-1][x][y]*A%Mod*inv[k]%Mod);
					A=1ll*A*a%Mod;
				}
				add(f[i][x][y],f[i-1][x][y]);
			}
		S+=a;
		T+=b-1;
	}
	int ans=0;
	for(int x=1;x<=S;x++)
	{
		int mul=1;
		for(int y=0;y<=T;y++)
		{
			mul=1ll*mul*x%Mod;
			ans=(ans+1ll*f[n][x][y]*fac[y]%Mod*fpow(mul,Mod-2))%Mod;
		}
	}
	printf("%d\n",1ll*ans*S%Mod);
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;
const int MAXL = 26;

int dp_mask[1 << MAXL];
int dp[MAXN];

char s[MAXN];

void solve(){
	scanf("%s", &s[0]);
	int n = strlen(s);
	REP(i, 0, 1 << MAXL){
		dp_mask[i] = INF;
	}
	dp_mask[0] = 0;
	for(int i = 0, mask = 0; i < n; i++){
		int ind = s[i] - 'a';
		mask ^= (1 << ind);
		int cur = dp_mask[mask] + 1;
		REP(j, 0, MAXL){
			cur = min(cur, dp_mask[mask ^ (1 << j)] + 1);
		}
		dp[i] = cur;
		dp_mask[mask] = min(dp_mask[mask], cur);
	}
	printf("%d\n", dp[n - 1]);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int n;
string s;
void solve() {
    cin >> n >> s;

    if (n % 2 != 0) { cout << "No" << endn; return; }

    if (s.substr(0, n / 2) == s.substr(n / 2)) { cout << "Yes" << endn; return; }
    else cout << "No" << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(3);
    ll ans=1;
    rep(i,n) {
        int num=0,s=3;
        rep(j,3) {
            if (cnt[j]==a[i]) {
                s=(j<s)?j:s;
                ++num;
            }
        }
        ++cnt[s];
        ans=(ans*num)%MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int d, g;

int cal(vector<int> p,vector<int> c,vector<bool> ju) {
	int num = 0, up = -1, ans = 1e9, co = 0;
	for (int i = 0;i < d;i++) {
		if (ju[i]) {
			num += p[i] * (i + 1) * 100 + c[i];
			co += p[i];
		}
		else
		up = i;
	}
	if (up == -1) {
		if (num >= g)
			return co;
		return ans;
	}
	if (num >= g)
		return co;
	if (num + (up + 1)*p[up] * 100 <= g)
		return ans;
	int la = g - num;
	co += (la + (up + 1) * 100 - 1) / ((up + 1) * 100);
	return co;
}

int gen(int n,vector<int> p,vector<int> c,vector<bool> ju) {
	int ans;
	if (n > -1) {
		ju[n] = false;
		ans = gen(n - 1, p, c,ju);
		ju[n] = true;
		ans = min(ans, gen(n - 1, p, c,ju));
	}
	else {
		ans=cal(p, c, ju);
	}
	return ans;
}

int main() {
	cin >> d >> g;
	vector<int> p(d), c(d);
	for (int i = 0;i < d;i++) {
		cin >> p[i] >> c[i];
	}
	vector<bool> ju(10, false);
	int ans=gen(d - 1, p, c, ju);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int h = sc1.nextInt();
		int w = sc1.nextInt();
		int count = 0;
		int countA = 0;
		int tmpA = 0;
		int tmpB = 0;
		int tmpC = 0;
		int tmpD = 0;
		int[][] map = new int[h][w];
		String array[] = new String[h*w];

		for ( int i = 0 ; i < h ; i++ ) {
			for ( int j = 0 ; j < w ; j++) {
				map[i][j] = sc1.nextInt();
			}
		}

		for ( int i = 0 ; i < h ; i++ ) {
			for ( int j = 0 ; j < w ; j++) {
				if (map[i][j] % 2 != 0) {
					//下チェック
					if (j < w-1) {
						if (map[i][j+1] % 2 != 0) {
							map[i][j]--;
							map[i][j+1]++;
							count++;
							tmpA = i+1;
							tmpB = j+1;
							tmpC = i+1;
							tmpD = j+2;
							array[countA] = tmpA + " " + tmpB + " " + tmpC + " " + tmpD;
							countA++;
							continue;
						}
					}

					//右チェック
					if (i < h-1) {
						map[i][j]--;
						map[i+1][j]++;
						count++;
						tmpA = i+1;
						tmpB = j+1;
						tmpC = i+2;
						tmpD = j+1;
						array[countA] = tmpA + " " + tmpB + " " + tmpC + " " + tmpD;
						countA++;
					}
					else if (j < w-1) {
						map[i][j]--;
						map[i][j+1]++;
						count++;
						tmpA = i+1;
						tmpB = j+1;
						tmpC = i+1;
						tmpD = j+2;
						array[countA] = tmpA + " " + tmpB + " " + tmpC + " " + tmpD;
						countA++;
					}
				}
			}
		}

		System.out.println(count);

		for ( int i = 0 ; i < countA ; i++ ) {
			System.out.println(array[i]);
		}

		//System.out.println();

		//for ( int i = 0 ; i < h ; i++ ) {
		//	for ( int j = 0 ; j < w ; j++) {
		//		System.out.println(map[i][j]);
		//	}
		//}

		sc1.close();

	}

}

Measured memory_bytes: 100468
#include<iostream>

using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
	
int main()
{
	int n,m,p;
	while(cin >> n >> m >> p,n)
	{
		int kyo[n],sum = 0;
		REP(i,n)
		{
			cin >> kyo[i];
			sum += kyo[i];
		}
		if(kyo[m-1] == 0)
		{
			cout << 0 << endl;
			continue;
		}
		
		int ans = (100 - p) * sum / kyo[m-1];
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3000
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (b - 1 + a - 2) / (a - 1) << '\n';
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    int t, f;
    char c;
    string front, end;
    front.clear();
    end.clear();
    int reverse_num = 0;
    for(int i = 0; i < q; i++){
        cin >> t;
        switch (t) {
            case 1:
                reverse_num++;
                break;
            case 2:
                cin >> f;
                cin >> c;
                switch (f) {
                    case 1:
                        if(reverse_num % 2 == 0){
                            front.push_back(c);
                        }else{
                            end.push_back(c);
                        }
                        break;
                    case 2:
                        if(reverse_num % 2 == 0){
                            end.push_back(c);
                        }else{
                            front.push_back(c);
                        }
                        break;
                }
                break;
        }
    }
    if(reverse_num % 2 != 0){
        reverse(end.begin(), end.end());
    }else{
        reverse(front.begin(), front.end());
    }
    string ans;
    if(reverse_num % 2 != 0){
        reverse(s.begin(), s.end());
        ans = end + s + front;
    }else{
        ans = front + s + end;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1348
n = int(input())
w = []
flag = 1

for i in range(n):
    s = input()
    if s in w:
        flag = 0
        break
    else:
        w.append(s)

if flag != 0:
    if w[0][-1] != w[1][0]:
        flag = 0
    for i in range(1, n-1):
        if w[i][-1] != w[i+1][0]:
            flag = 0
            break

if flag == 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
function main(input) {
  const formatted_input = input.split('\n').map(x => parseInt(x));

  var tmp_minimum=0;
  var result = 0;
  for(var i = 0;i<5;i++){
    result+=(formatted_input[i] - formatted_input[i]%10)
    if(formatted_input[i]%10==0){
    }else{
      if(tmp_minimum==0){
        tmp_minimum=formatted_input[i]%10
      }else{
        result+=10;
        tmp_minimum=Math.min(tmp_minimum,formatted_input[i]%10)
      }
    }
  }
  result+=tmp_minimum;

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main() {
	int animal_num = 0;
	int leg_num = 0;
	cin >> animal_num >> leg_num;

	if (leg_num % 2 != 0) {
		cout << "No" << endl;
	} else if (animal_num * 2 > leg_num || animal_num * 4 < leg_num) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}


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

int main() {
    int k,s;
    cin >> k >> s;

    int count = 0;

    for(int i=0; i<=s; i++){
        for(int j=0; j + i<=s; j++){
            int m = s - i - j;
            if(i<=k && j<=k && m<=k){
                count++;
            }
        }
    }
    cout << count << endl;
}

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

using namespace std;

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

    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int count = 0;
    for (auto x:a) {
        if (x * 4 * m >= sum)count++;
    }

    cout << (count >= m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll cnt = 0;
    for(ll i = min(a, b); i >= 1; i--){
        if(a % i == 0 && b % i == 0) cnt++;
        if(cnt == k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int x,y,z;
	while(1){
		scanf("%d %d %d",&x,&y,&z);
		if(x==-1&&y==-1&&z==-1){
			break;
		}
		if(x==-1||y==-1){
			printf("F\n");
			continue;
		}
		if(x+y>=80){
			printf("A\n");
		}
		if(x+y>=65&&x+y<80){
			printf("B\n");
		}
		if(x+y>=50&&x+y<65){
			printf("C\n");
		}
		if(x+y>=30&&x+y<50){
			if(z>=50){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
		if(x+y<30){
			printf("F\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> vW(N+1,0), vE(N+1,0);
    rep(i,N){
        vW[i+1] += vW[i];
        if(S[i] == 'W') vW[i+1]++;
        vE[i+1] += vE[i];
        if(S[i] == 'E') vE[i+1]++;
    }
    int ans = 999999999;
    rep(i,N){
        int now = vW[i] + (vE[N] - vE[i+1]);
        ans = min(now, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec[i];
  }
  int Alice = 0, Bob = 0;

  sort(vec.begin(), vec.end(), greater<int>());
  for(int i = 0; i < n; i++){
    if(i%2==0){
      Alice += vec[i];
    }else{
      Bob += vec[i];
    }
  }
  cout << Alice-Bob << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
ll g(ll g) {
    return (g * (g + 1) / 2);
}
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep1(i, n) ans += i * g(n / i);
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int arr[10];
    for(int i=1;i<=3;i++){
        scanf("%d",&arr[i]);
    }
    sort(arr+1,arr+1+3);
    if (arr[1]==5 && arr[2]==5 && arr[3]==7){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 3756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int A;
    static int B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();

        System.out.println( solve() );
    }

    private static int solve() {
        int diff = B - A;

        int sum = 0;
        for (int i = 0; i < (diff-1); i++) {
            sum += (i+1);
        }
        return sum - A;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 23124
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        maxm         1000005
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N],arr1[N] ;

bitset <maxm>isprime;
vector<long long >primes;
void autop()
{
    isprime.set();
    isprime[0]=isprime[1]=false;
    for(int i=0;i<maxm;i++)
    {
        if(isprime[i])
        {
            primes.push_back(i);
            for(int j=i*2;j<maxm;j+=i)
                isprime[j]=false;
        }
    }
}

int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code
        autop();
        cin>>n;
        for(i=0;i<n;i++) cin>>arr[i];
        mll mp;
        f=0;
        for(k=0;k<n;k++)
        {
               x=arr[k];
             ll num=x;
        for(i=0;primes[i]*primes[i]<=x&&num>1;i++)
        {
           if(num%primes[i]==0){
                     if(mp[primes[i]]==1) f=1;
                     mp[primes[i]]=1;
            while(num%primes[i]==0)
            {
                num=num/primes[i];
            }
           }
        }
        if(num!=1){
             if(mp[num]==1) f=1;
             mp[num]=1;
            }

        }



        if(f==0)
        {
               cout<<"pairwise coprime\n";
               return 0;
        }
         x=0;
        for(i=0;i<n;i++)
               x=__gcd(x,arr[i]);
        if(x==1)
               cout<<"setwise coprime\n";
        else
               cout<<"not coprime\n";


    //code
    return 0;
}




Measured memory_bytes: 63512
#include <iostream>
using namespace std;
bool IsPrime(int x)
{
    int i;

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

    return true;

}


int main(void)
{
	int p,n, COUNT = 0;

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> p;
		if (IsPrime(p))
			COUNT++;
	}

	cout << COUNT << endl;

	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, Y, Z;
  cin >> X >> Y >> Z;
  swap(X, Y);
  swap(X, Z);
  cout << X << " " << Y << " " << Z << endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double W = sc.nextInt();
		double H = sc.nextInt();
		double x = sc.nextInt();
		double y = sc.nextInt();
		sc.close();
		
		double half = H/2;
		double area = half*W;
		System.out.printf("%.8f",area);
		
		if (x==0 && y==0)
			System.out.println(" "+0);
		
		else if (x==W/2 && y==H/2)
			System.out.println(" "+1);
		else
			System.out.println(" "+0);
	}

}


Measured memory_bytes: 23636
/*#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.length();
	if(len==2){
		cout<<s;
	}
	else{
		for(int i=len-1;i>=0;i--){
			cout<<s[i]; 
		}
	}
} 
*/
#include<iostream>
using namespace std;
int main(){
	int a,b,k,count=0;
	cin>>a>>b>>k;
	while(k--){
		count++;
		if(count%2!=0){
			if(a%2!=0){
				a=a-1;
				b=b+a/2;
				a=a/2;
			}
			else{
				b=b+a/2;
				a=a/2;
			}
		}
		else{
			if(b%2!=0){
				b=b-1;
				a=a+b/2;
				b=b/2;
			}
			else{
				a=a+b/2;
				b=b/2;
			}
		}
	}
	cout<<a<<" "<<b;
	return 0;
}  

Measured memory_bytes: 256