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

typedef vector <int> VI;
typedef vector <VI> VVI;

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

int get_x( char c )
{
	if ( c == 'A' || c == 'D' || c == 'G' ) return 0;
	if ( c == 'B' || c == 'E' || c == 'H' ) return 1;
	if ( c == 'C' || c == 'F' || c == 'I' ) return 2;
	return -1;
}

int get_y( char c )
{
	if ( c == 'A' || c == 'B' || c == 'C' ) return 0;
	if ( c == 'D' || c == 'E' || c == 'F' ) return 1;
	if ( c == 'G' || c == 'H' || c == 'I' ) return 2;
	return -1;
}


int main( void )
{
	int n; char s, t, b;
	while ( 1 )
	{
		cin >> n;
		if ( n == 0 ) break;
		cin >> s >> t >> b;

		int sx, sy, gx, gy, ox, oy;
		sx = get_x( s ); sy = get_y( s );
		gx = get_x( t ); gy = get_y( t );
		ox = get_x( b ); oy = get_y( b );

		VVI prev( 3, VI(3,0) ), next;
		prev[sy][sx] = 1;
		for ( int lpc = 0; lpc < n; lpc++ )
		{
			next = VVI( 3, VI( 3, 0 ) );
			for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 3; j++ )
			{
				if ( i == oy && j == ox ) continue;
				int stop = 0;
				for ( int k = 0; k < 4; k++ )
				{
					int nx = j + dx[k];
					int ny = i + dy[k];
					if ( nx < 0 || nx >= 3 || ny < 0 || ny >= 3 )
					{
						stop++;
						continue;
					}
					else if ( nx == ox && ny == oy )
					{
						stop++;
						continue;
					}
					next[i][j] += prev[ny][nx];
				}
				if ( stop ) next[i][j] += prev[i][j] * stop;
			}
			prev = next;
		}

		int sum = 0;
		for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 3; j++ ) sum += next[i][j];

		double answer = (double)next[gy][gx] / (double)sum;

		cout.precision( 8 );
		cout.setf( ios::fixed );
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
int main()
{
    fio;
    ll n, maxx = -1;
    cin >> n;
    string s;
    map <string, ll> m;
    map <string, ll> ::iterator it;
    for(int i = 0; i < n; i ++){
        cin >> s;
        m[s] ++;
    }
    for(it = m.begin(); it != m.end(); it ++)
    {
        maxx = max(it->second, maxx);
    }
    for(it = m.begin(); it != m.end(); it ++)
    {
        if(it->second == maxx){
            cout << it->first << endl;
        }
    }

    return 0;
}


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

using namespace std;

int N, K;
list<int> Digits;

void solve() {
	int deletedCnt, rest;
	list<int>::iterator curPos, nextPos;

	deletedCnt = 0;
	curPos = Digits.begin();
	nextPos = ++Digits.begin();
	while (nextPos != Digits.end()) {
		if (deletedCnt == K) {
			break;
		}
		if (*curPos >= *nextPos) {
			++curPos;
			++nextPos;
			continue;
		}
		++deletedCnt;
		nextPos = Digits.erase(curPos);
		curPos = nextPos;
		if (curPos != Digits.begin()) {
			--curPos;
		}
		else {
			++nextPos;
		}
	}

	rest = N - K;
	for (int i = 0; i < rest; ++i) {
		cout << Digits.front();
		Digits.pop_front();
		//cout << *Digits.begin();
		//Digits.erase(Digits.begin());
	}
	cout << endl;
}

int main() {
	int a;

	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		Digits.push_back(a);
	}
	solve();

	return 0;
}


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

int n;

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

    for(int i=0; i < n; i++){
        dys = 0;
        int y, m, d;
        cin >> y >> m >> d;

        if(y % 3 == 0) dys += (20 - d);
        else if(m % 2 == 1) dys += (20 - d);
        else if(m % 2 == 0) dys += (19 - d);
        if(m+1 == 11){
            y += 1;
            m = 1;
        }
        else m++;

        for(int j = y; j < 1000; j++){
            int month;
            if(j == y) month = m;
            else month = 1;
            while(month <= 10){
                if(j % 3 == 0) dys += 20;
                else if(month % 2 == 0) dys += 19;
                else if(month % 2 == 1) dys += 20;
                month++;
            }
        }

        cout << dys + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3076
#include<cstdio>
int main(){
	int N;
	scanf("%d", &N);
	int buka[N];
	for (int i = 0; i < N; ++i){
		buka[i] = 0;
	}
	for (int i = 1; i < N; ++i){
		int tmp;
		scanf("%d", &tmp);
		buka[tmp-1]++;
	}
	for (int i = 0; i < N; ++i)
	{
		printf("%d\n", buka[i]);
	}
	return 0;
}

Measured memory_bytes: 2508
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, a, b = geta(int)

    if (b - a) & 1 == 0:
        print((b - a) // 2)
    else:
        print(min((a + b - 1) // 2, n - (a + b - 1) // 2))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int a,b;
  cin >> a >> b;
  cout << (a %(2*b+1) > 0 ? (a/(2*b+1) + 1):a/(2*b+1)) << endl;
	return 0;
}


Measured memory_bytes: 256
# Problem B - A to Z String

# input process
s = input()
s_len = len(s)

# initizalization
a_pos = 0
z_pos = 0

# first a search
for i in range(s_len):
    a = s[i]
    if a=='A':
        a_pos = i
        break

# second z search
for i in range(s_len):
    z = s[i]
    if z=='Z':
        z_pos = i

print(z_pos - a_pos + 1)


Measured memory_bytes: 40924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vector<int> d(n);
	rep(i,n) cin >> d[i];
	SORT(d);
	int ans = d[n/2-1]==d[n/2] ? 0 : d[n/2]-d[n/2-1];
	out(ans);
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=42;

char s[N];
ll dp[N][N][N];
ll pd[N][N];
ll pp[N][N][N][N];
int g[N][N],n;

ll gao(int l,int r,int x);

ll gao(int p1,int p2,int p3,int p4) {
	if (pp[p1][p2][p3][p4]!=-1) return pp[p1][p2][p3][p4];
	ll &z=pp[p1][p2][p3][p4];
	z=0;
	rep(p5,p1,p3+1) per(p6,p4,p2+1) if (g[p5][p6]) {
		z+=gao(p1,p3,p5)*gao(p4,p2,p6);
	}
	return z;
}

ll gao(int l,int r,int x) {
	if (dp[l][r][x]!=-1) return dp[l][r][x];
	if (l==x&&r==x) return dp[l][r][x]=1;
	ll &z=dp[l][r][x];
	rep(p1,l,x) rep(p2,p1,x) rep(p3,p1,p2+1) gao(p1,p2,p3);
	rep(p1,x+1,r+1) rep(p2,x+1,r+1) rep(p3,p1,p2+1) gao(p1,p2,p3);
	memset(pd,0,sizeof(pd));
	pd[l][r]=1;
	z=0;
	rep(p1,l,x) per(p2,x+1,r+1) if (pd[p1][p2]) {
		rep(p3,p1,x) per(p4,x+1,p2+1) {
			pd[p3+1][p4-1]+=gao(p1,p2,p3,p4)*pd[p1][p2];
		}
	}
	z=pd[x][x];
//	printf("%d %d %d %lld\n",l,r,x,z);
	return z;
}

int main() {
	memset(dp,-1,sizeof(dp));
	memset(pp,-1,sizeof(pp));
	scanf("%d",&n);
	n*=2;
	rep(i,1,n+1) {
		scanf("%s",s+1);
		rep(j,1,n+1) g[i][j]=s[j]=='1';
	}
	ll ans=0;
	rep(i,2,n+1) if (g[1][i]) ans+=gao(2,n,i);
	printf("%lld\n",ans);
}

Measured memory_bytes: 25216
#include <iostream>
using namespace std;
 
int main(){

    int n, m;

	cin >> n >> m;

    int S = 0;
    int *a;
    a = new int[n];

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

    int count = 0;
    for(int i=0; i<n; i++){
        if((double)a[i] >= (double)S/(4.0*(double)m))
            count += 1;
    }

    if(count >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, curr = 1, ans = 0;
	cin >> a >> b;
	while (curr < b) {
		++ans;
		--curr;
		curr += a;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<b; i++)
#define REP(i, n)    for(int i=0; i<(n); i++)
#define fst first
#define pb push_back
#define mp make_pair
#define ALL(obj) (obj).begin(), (obj).end()
using ul = unsigned long;
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

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

  int N;
  cin >> N;
  vector<int> a(N+1), b(N+1);
  FOR(i, 1, N+1) cin >> b[i];

  bool hantei = false;
  FOR(i, 1, N+1){
    if(b[i]>i){
      hantei = true;
      break;
    }
  }

  if(hantei) cout << -1 << endl;
  else{
    for(int j=N; j>0; j--){
      for(int i=j; i>0; i--){
        if(b[i]==i){
          a[j] = i;
          b.erase(b.begin() + i);
          break;
        }
      }
    }
    FOR(k, 1, N+1) cout << a[k] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int card[5],ans,n,i,l,t,f;
	
	while(scanf(" %d,%d,%d,%d,%d",&card[0],&card[1],&card[2],&card[3],&card[4])!=EOF){
		
		//昇順にソート
		for(i=0;i<4;i++){
			for(l=4;l>i;l--){
				if(card[l-1]>card[l]){
					t=card[l-1];
					card[l-1]=card[l];
					card[l]=t;
				}
			}
		}
		
		//ストレート判定
		for(f=0,i=4;i>0;i--){
			if(i==1 && card[1]==10 && card[0]==1)f=1;
			if(card[i]!=card[i-1]+1)break;
			if(i==1)f=1;
		}
		
		//スリーペア
		if(f==0){
			for(i=0;i<3;i++){
				if(card[i]==card[i+2])f=3;
			}
		}
		
		//ワンペア判定
		if(f==0){
			for(i=0;i<4;i++){
				if(card[i]==card[i+1])f=2;
			}
		}
		
		if(card[0]==card[3] || card[1]==card[4]){
			printf("four card\n");
		}
		else if((card[0]==card[1] && card[2]==card[4]) || card[0]==card[2] && card[3]==card[4]){
			printf("full house\n");
		}
		else if(f==1){
			printf("straight\n");
		}
		else if(f==3){
			printf("three card\n");
		}
		else if((card[0]==card[1] && (card[2]==card[3] || card[3]==card[4])) || (card[1]==card[2] && card[3]==card[4])){
			printf("two pair\n");
		}
		else if(f==2){
			printf("one pair\n");
		}
		else{
			printf("null\n");
		}
		
		
		
	}
	
	
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;

    //あり得る数は高々1000通りなので全部計算できる
    rep(x,1000){
        int keta = 1;
        int nx = x/10;
        //要素1、初期値はxの1の位にする
        vector<int> d(1,x%10);
        while(nx){
            keta ++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if(keta != n) continue;
        bool ok =true;
        reverse(all(d));
        rep(i,m){
            if(d[p[i].first-1] != p[i].second) ok=false;
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    //最後まで見つからなかったら-1
    cout << -1 << endl;
    return 0;


}

Measured memory_bytes: 3580
#include <stdio.h>

#define mod 100000

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

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

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < maxbits; j++)
		{
			dp[(i ^ 1) & 1][j][0][0] = 0;
			dp[(i ^ 1) & 1][j][0][1] = 0;
			dp[(i ^ 1) & 1][j][1][0] = 0;
			dp[(i ^ 1) & 1][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = (dp[i & 1][j][0][0] + dp[i & 1][j][1][0]) % mod;
			int sum1 = (dp[i & 1][j][0][1] + dp[i & 1][j][1][1]) % mod;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[(i ^ 1) & 1][conv[nxt]][0][0] += sum0;
				dp[(i ^ 1) & 1][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[(i ^ 1) & 1][conv[nxt + 1]][1][0] += dp[i & 1][j][0][0];
					dp[(i ^ 1) & 1][conv[nxt + 1]][1][1] += dp[i & 1][j][0][1];

					dp[(i ^ 1) & 1][conv[nxt + 1]][1][0] %= mod;
					dp[(i ^ 1) & 1][conv[nxt + 1]][1][1] %= mod;

					dp[(i ^ 1) & 1][conv[nxt]][1][0] += (sum0 - dp[i & 1][j][0][0] + mod);
					dp[(i ^ 1) & 1][conv[nxt]][1][1] += (sum1 - dp[i & 1][j][0][1] + mod);
				}
				else
				{
					dp[(i ^ 1) & 1][conv[nxt]][1][0] += sum0;
					dp[(i ^ 1) & 1][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[(i ^ 1) & 1][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[(i ^ 1) & 1][conv[nxt]][1][0] += sum0;
				}

				dp[(i ^ 1) & 1][conv[nxt]][1][1] += sum1;
			}

			dp[(i ^ 1) & 1][conv[nxt]][1][0] %= mod;
			dp[(i ^ 1) & 1][conv[nxt]][1][1] %= mod;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= mod;
	}

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

	return 0;
}

Measured memory_bytes: 3408
s = list(input())
t = input()
flag = False
for i in range(len(s)):
    if "".join(s) == t:
        flag = True
        break
    else:
        flag = False
    w = s[0]
    for j in range(len(s)-1):
        s[j] = s[j+1]
    s[-1] = w
if flag:
    print("Yes")
else:
    print("No")

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

bool poor(int a,int b,int c)
{
	if(a==b)return b==c?false:true;
	if(a==c)return a==b?false:true;
	if(b==c)return a==b?false:true;
	return false;
}

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(poor(a,b,c))cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),c=G(r,0),p+=l:(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	

	int mod = 1000000007;

	void solve(){

		ini(n);
		ini(n1);
		int one  =0;
		FOR(i,0,n+1){
			if(i*2+(n-i)*4 == n1)one = 1;
		}
		if(one)out("Yes");
		else out("No");
		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sorti(vi &a) {sort(a.begin(), a.end());}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  sortll(a);
  for (ll i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      NO();
      return 0;
    }
  }
  YES();
}

Measured memory_bytes: 1792
c = list(map(int, input().split()))
c += list(map(int, input().split()))
c += list(map(int, input().split()))

if (c[0]-c[1] == c[3]-c[4] == c[6]-c[7]) and (c[1]-c[2] == c[4]-c[5] == c[7]-c[8]) and (c[0]-c[3] == c[1]-c[4] == c[2]-c[5]) and (c[3]-c[6] == c[4]-c[7] == c[5]-c[8]):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    vector<string> vec(H);
    vector<vector<int>> vec1(H,vector<int>(W));
    vector<vector<int>> vec2(H,vector<int>(W));
    for(int i=0;i<H;i++){
        string S;
        cin>>S;
        vec.at(i)=S;
        int j=0,L=0;
        while(j!=W){
            if(S.at(j)=='#'){
                if(j==0){
                    j++;
                    L=1;
                    continue;
                }
                for(int k=L;k<j;k++){
                    vec1.at(i).at(k)=j-L;
                }
                L=j+1;
                j++;
                continue;
            }
            j++;
            if(j==W){
                for(int k=L;k<j;k++){
                    vec1.at(i).at(k)=j-L;
                }
                break;
            }
        }
    }
    for(int i=0;i<W;i++){
        int j=0,L=0;
        while(j!=H){
            string S=vec.at(j);
            if(S.at(i)=='#'){
                if(j==0){
                    j++;
                    L=1;
                    continue;
                }
                for(int k=L;k<j;k++){
                    vec2.at(k).at(i)=j-L;
                }
                L=j+1;
                j++;
                continue;
            }
            j++;
            if(j==H){
                for(int k=L;k<j;k++){
                    vec2.at(k).at(i)=j-L;
                }
                break;
            }
        }
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans=max(ans,max(0,vec1.at(i).at(j)+vec2.at(i).at(j)-1));
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;
const int MAX = 800000;

ll fac[MAX], finv[MAX], inv[MAX];

void combinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; ++i){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD-inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}


ll com(int n, int k){
    if(n < k) return 0;
    if(n < 0 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(){
    
    combinit();
    ll x, y;
    scanf("%lld%lld", &x, &y);

    if((x+y)%3 or 2*min(x, y) < max(x, y)){
        ppp(0);
        return 0;
    }
    ll xx = (2*x-y)/3, yy = (-x+2*y)/3;
    ppp(com(xx+yy, min(xx, yy))); 
    
    return 0;
}


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

int main() {
  int X,A,B;
  cin>>X>>A>>B;
  for(int i=A;i<=B;i++){
    if(i%X==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

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

int main(){

    int n,m;
    cin >> n >> m;

    vector<vector<int> > a(n,vector<int>(n,1e+9));
    vector<vector<int> > b(n,vector<int>(n,0));
    rep(i,m){
        int s,t,u;
        cin >> s >> t >> u;
        s--;
        t--;
        a[s][t]=u;
        a[t][s]=u;
        b[s][t]=u;
        b[t][s]=u;
    }
    for(int i=0;i<n;i++){
        a[i][i]=0;
    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
            }
        }
    }
    int ans=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(b[i][j]>0){
                if(a[i][j]<b[i][j]){
                    ans++;
                }
            }
        }
    }

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int main(){
    string s;cin>>s;int n=s.length();

    int w;cin>>w;
    for(int i=0;i<n;i+=w){
        cout<<s[i];
    }
    cout<<endl;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

string s;
int k;
int main(){
  cin >> s>>k;
  int i = 0;
  while(k>0){
    if(i==s.size()) break;
    int c = (26-(s[i]-'a'))%26;
    //cout << c << " " << k <<endl;
    if(c<=k){
      s[i] = 'a';
      k-=c;
    }
    i++;
  }
  s[s.size()-1] = s[s.size()-1] + (k%26);
  cout <<s <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
double X;

int main(){
    
    cin>>N;
    
    X = N-N/2;
    
    printf("%.8f\n", X/(double)N);
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll d, a;
vector<pll> v;

int main() {
    cin >> n >> d >> a;
    rep(i, n) {
        ll x, h; cin >> x >> h;
        v.push_back(make_pair(x, h));
    }

    d *= 2;
    sort(v.begin(), v.end());
    ll tot = 0, ans = 0;
    queue<pll> q;
    rep(i, n) {
        ll x = v[i].first;
        ll h = v[i].second;
        while (q.size() && q.front().first < x) {
            tot -= q.front().second;
            q.pop();
        }
        h -= tot;
        if (h > 0) {
            ll num = (h + a - 1) / a;
            ans += num;
            ll dmg = num * a;
            tot += dmg;
            q.push(make_pair(x+d, dmg));
        }
    }
    cout << ans << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int IINF = INT_MAX;
struct Edge { int src,dst,weight; };
struct Data {
  int cur,getBitmask,putBitmask,weight;
  bool operator < ( const Data &data ) const { return weight > data.weight; }
};
int V,E,k,sp,s[6],t[6],mindist[1001][1<<6][1<<6];
int drop[1001], target[1001];
vector<Edge> G[1001];

void compute(){
  rep(i,V) rep(j,(1<<k)) rep(l,(1<<k)) mindist[i][j][l] = IINF;
  mindist[sp][0][0] = 0;
  priority_queue<Data> Q;
  Q.push((Data){sp,0,0,0});
  while( !Q.empty() ) {
    Data data = Q.top(); Q.pop();
    if( data.putBitmask == ((1<<k)-1) ) { cout << data.weight << endl; return; }
    rep(i,G[data.cur].size()){
      int next = G[data.cur][i].dst;
      int getBitmask = data.getBitmask;
      int putBitmask = data.putBitmask;
      if( drop[next] != -1 ) getBitmask |= (1<<drop[next]);
      if( target[next] != -1 && ( ( getBitmask >> target[next] ) & 1) ) putBitmask |= (1<<target[next]);
      if( mindist[next][getBitmask][putBitmask] > data.weight + G[data.cur][i].weight ) {
	mindist[next][getBitmask][putBitmask] = data.weight + G[data.cur][i].weight;
	Q.push((Data){next,getBitmask,putBitmask,data.weight+G[data.cur][i].weight});
      }
    }
  }
  puts("Cannot deliver");
}

int main(){
  memset(drop,-1,sizeof(drop));
  memset(target,-1,sizeof(target));
  cin >> V >> E >> k >> sp;
  --sp;
  rep(i,E) {
    int x,y,w;
    cin >> x >> y >> w;
    --x, --y;
    G[x].push_back((Edge){x,y,w});
    G[y].push_back((Edge){y,x,w});
  }
  rep(i,k) {
    cin >> s[i] >> t[i];
    --s[i], --t[i];
    drop[s[i]] = i;
    target[t[i]] = i;
  }
  compute();
  return 0;
}

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

using namespace std;

// typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x = 0, int y = 0): x(x), y(y) {}
};
const int maxn = 2e5 + 10;
P p[maxn];
int K;

P cal(int x, int y) {
	if (x > y) {
		P p = cal(y, x);
		return P(p.y, p.x);
	}
	if (x < 0) {
		P p = cal(-x, y);
		return P(-p.x, p.y);
	}
	if (x + y == K) return P(0, 0);
	if (x + y >= 2 * K) return P(x, y - K);
	int t = K - (x + y) / 2;
	return P(-t, y - K + x + t);
}
int main(void) {
	cin >> K;
	int x, y;
	cin >> x >> y;
	if (((x + y) & 1) && K % 2 == 0) return puts("-1"), 0;
	int cnt = 0;
	p[++cnt] = P(x, y);

	for (; p[cnt].x || p[cnt].y; ++cnt) {
		p[cnt + 1] = cal(p[cnt].x, p[cnt].y);
	}
	cout << cnt - 1 << endl;
	for (int i = cnt - 1; i >= 1; --i) {
		printf("%d %d\n", p[i].x, p[i].y);
	}

	return 0;
}

Measured memory_bytes: 4096
S = input()
T = input()
D = dict()
f = True
for s, t in zip(S, T):
  if s not in D:
    if t not in D.values():
    	D[s] = t
    else:
      f = False
      break
  elif D[s] != t:
    f = False
    break
print('Yes' if f else 'No')

Measured memory_bytes: 3632
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1){
			System.out.print("Hello World");
			
		} else if(n == 2){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.print(a+b);
		}
	}
}


Measured memory_bytes: 21844
defmodule Main do
  def main do
  
    s=IO.gets("") |> String.trim
  	cond do
      String.contains?(s,"RRR") -> IO.puts("3")
      String.contains?(s,"RR") -> IO.puts("2")
      String.contains?(s,"R") -> IO.puts("1")
      true -> IO.puts("0")
    end  
  end
end


Measured memory_bytes: 30716
import math
A,B,H,M=map(int,input().split())
R1=(H*60+M)*(0.5)
R2=M*6
R=R1-R2
R=abs(R)
if(R>180):
  R=360-R
COS=math.cos(math.radians(R))
ans=A**2+B**2-2*A*B*COS
print(ans**(1/2))

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int N = 200010;
int ans[26];
int a[N];
int n;
ll pos = 0,cnt = 0;

int main () {
	scanf("%d",&n);
	int k = 1;
	for(int i = 1;i <= n;i++) {
		scanf("%d",&a[i]);
		int flag = 1;
        for (int j = 0;j <= 20;j++) {
			if (a[i] & (1<<j)) {
				ans[j]++;
			}
			if (ans[j] > 1) {
				flag = 0;
			}
		}
		if (!flag) {
            pos += cnt;
            while(k < i) {
                int ok = 1;
                for(int j = 0;j <= 20;j++) {
                    ans[j] -= (a[k] & (1<<j)) ? 1 : 0;
                    if(ans[j] > 1) {
                    	ok = 0;
					}
                }
                k++;
                cnt--;
                if (ok) {
                	break;
				} else {
					pos += cnt;
				}
            }
        }
        cnt++;
    }
    printf("%lld\n",pos + ((1 + cnt) * cnt / 2));
	return 0;
}


Measured memory_bytes: 4536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		var S = GetString();
		var num = S.Select(x => (long)(x - '0')).ToArray();
		long N = S.Length;

		long cnt = 0;
		long pow = 1;
		long r = 0;
		var dict = new Dictionary<long, long>();
		dict[0] = 1;
		for(long i = N - 1; i >= 0; i--)
		{
			r = (num[i] * pow + r) % 2019;
			dict.TryGetValue(r, out long c);
			cnt += c;
			dict[r] = c + 1;
			pow = (pow * 10) % 2019;			
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 30848
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>

using namespace std;

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

    int G, ans = 1;
    for (G = 1; G <= sqrt(M); G++) {
        if (M % G == 0) {
            if (M / G >= N)ans = max(ans, G);
            if (G >= N)ans = max(ans, M / G);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	an := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&an[i])
	}
	sort.Ints(an)

	len := 0
	left := 0
	right := 0
	for ; left < n; left++ {
		for ; right < n; right++ {
			lhs := an[left]
			rhs := an[right]
			diff := rhs - lhs
			if diff <= 2 {
				count := right - left + 1
				if len < count {
					len = count
				}
			} else {
				break
			}
		}
	}
	fmt.Println(len)
}


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

bool isPrime(int x) {
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;

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

int main() {
    int N; cin >> N;
    int cur = 2;
    while(N > 0) {
        while(cur % 5 != 2 || !isPrime(cur)) ++cur;
        cout << cur << (N==1 ? '\n' : ' ');
        ++cur;
        --N;
    }
}

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

int main() {
    /* Input */
    int X, Y;
    cin >> X >> Y;
    
    bool flag = false;
    /* Main Logic */
    for (int iTsuru = 0; iTsuru <= X; iTsuru++) {
        if ((iTsuru * 2 + (X - iTsuru) * 4) == Y) {
            flag = true;
            break;
        }
    }

    /* Output */
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,count=0;
  cin >>n;
  int a[n],b[n];
  for(int i=0;i<n;i++){
    cin >>a[i];
    b[i]=a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    if(a[i]!=b[i])count++;
  }
  if(count<=2)cout <<"YES"<<endl;
  else cout <<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n, l[10];
	int a = 0, x, sum = 0;
	scanf("%d", &n);
	l[0] = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &l[i]);
		if(i > 0 && l[i] > l[a]) a = i;
	}
	x = l[a];
	l[a] = 0;
	
	for(int i = 0; i < n; i++){
		sum += l[i];
	}
	if(sum > x) puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int w=Integer.parseInt(st.nextToken());
        int h=Integer.parseInt(st.nextToken());
        int x=Integer.parseInt(st.nextToken());
        int y=Integer.parseInt(st.nextToken());
        int r=Integer.parseInt(st.nextToken());
        if(y<r||x<r||(w-x)<r||(h-y)<r) System.out.println("No");
        else System.out.println("Yes");
    }
}

Measured memory_bytes: 24240
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
int N;
struct edge{
  ll p,q,r,b;
  edge(){}
  edge(ll p,ll q,ll r,ll b) : p(p),q(q),r(r),b(b) {}
};
edge E[102];
int yukuri(ll n,ll m){
  int tmp = max(n,m);
  n = min(n,m);
  m = tmp;
  while( n > 0 ){
    tmp = n;
    n = m%n;
    m = tmp;
  }
  return m;
}
ll solve(ll id){
  ll r,b;
  if(E[id].r == 0)
    r=1;
  else
    r=solve(E[id].r);
  if(E[id].b == 0)
    b=1;
  else
    b=solve(E[id].b);
  ll tp = E[id].p * r * b;
  ll tq = E[id].q * r * b;
  tp /= b;
  tq /= r;
  ll n = yukuri(tp,tq);
  tp/=n; tq/=n;
  b*=tp; r*=tq;
  return b+r;
}
int main(){
  while(scanf("%d",&N),N){
    bool f[102];
    memset(f,0,sizeof(f));
    for(int i=1;i<=N;i++){
      ll p,q,r,b;
      scanf("%lld %lld %lld %lld",&p,&q,&r,&b);
      ll n = yukuri(p,q);
      //      printf("%d %d %d\n",p,q,n);
      p/=n;
      q/=n;
      E[i].p = p; E[i].q = q;
      E[i].r = r; E[i].b = b;
      f[r] = true; f[b] = true;
    }
    int id;
    //    puts("ok");
    for(int i=1;i<=N;i++)
      if(!f[i]) id = i;
    printf("%lld\n",solve(id));
  }
}

Measured memory_bytes: 1192
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

inputs=s()
print ""+inputs[:4]+" "+inputs[4:]+""


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            if (x == 0 && y == 0) break;

            if (x < y) {
                System.out.printf("%d %d\n", x, y);
            } else {
                System.out.printf("%d %d\n", y, x);
            }
        }
    }
}

Measured memory_bytes: 41064
#include<iostream>
#include<queue>
#define rep(i, n) for (int i=0; i<(n); i++)
using namespace std;

static const int N=100;
static const int INF=(1<<12);

int n;
bool M[N][N];
int d[N]; //距離で状態を管理するためcolor不要

void bfs(int s) {
  queue<int> que;
  que.push(s);
  rep(i, n) d[i]=INF;
  d[s]=0;

  while (!que.empty()) {
    int u=que.front();
    que.pop();
    rep(v, n) {
      if (!M[u][v]) continue;
      if (d[v]!=INF) continue;
      d[v]=d[u]+1;
      que.push(v);
    }
  }
}

int main() {
  cin>>n;
  rep(i, n) {
    rep(j, n) {
      M[i][j]=false;
    }
  }
  rep(i, n) {
    int u,k; cin>>u>>k;
    u--;
    rep(i, k) {
      int v; cin>>v;
      v--;
      M[u][v]=true;
    }
  }

  bfs(0);
  rep(i, n) {
      if (d[i]==INF) cout<<i+1<<" "<<-1<<endl;
      else cout<<i+1<<" "<<d[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <map>
#define int long long
typedef long long ll;
using namespace std;

const ll MOD = 1000000007;

ll N, Lmod=1, ans=0;
vector<ll> A, Amod;
map<ll, ll> lcms;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

vector<pair<ll, ll>> soinsuu(ll num) {
    vector<pair<ll, ll>> vs;
    for(int i=2;i*i<=num;i++) {
        ll ic=0;
        while(num%i==0) {
            num /= i;
            ic++;
        }
        vs.push_back(make_pair(i, ic));
    }
    if(num!=1) vs.push_back(make_pair(num, 1));
    return vs;
}

void lcmfunc(){
    for(int i=0;i<N;i++) {
        vector<pair<ll, ll>> p = soinsuu(A[i]);
        for(int j=0;j<p.size();j++) {
            if(lcms[p[j].first]<p[j].second) lcms[p[j].first] = p[j].second;
        }
    }
}

signed main(){
    cin >> N;
    A.resize(N);
    for(int i=0;i<N;i++) cin >> A[i];
    lcmfunc();
    for(map<ll, ll>::iterator it=lcms.begin();it!=lcms.end();it++) {
        pair<ll, ll> p = *it;
        Lmod *= modpow(p.first, p.second, MOD);
        Lmod %= MOD;
    }
    for(int i=0;i<N;i++) {
        ll Lmod1=Lmod;
        Lmod1 *= modinv(A[i], MOD);
        ans += Lmod1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*

*/

struct graph{
	vector<ll> v[200010],c[200010],d;
	void add_edge(int a,int b){
		v[a].push_back(b);
		v[b].push_back(a);
	}
};

struct Dinic{
	const long long INF=1e18+9;
	
	struct edge {
		int to,rev;
		long long cap;
		edge(){}
		edge(int to,long long cap,int rev):to(to),cap(cap),rev(rev){}
	};

	int n;
	vector<vector<edge> > G;
	vector<map<int,int> > M;
	vector<int> level,iter;

	Dinic(){}
	Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
	
	void add_edge(int from,int to,long long cap){
		M[from][to]=G[from].size();
		M[to][from]=G[to].size();
		G[from].push_back(edge(to,cap,G[to].size()));
		// undirected
		G[to].push_back(edge(from,cap,G[from].size()-1));
		// directed
		// G[to].push_back(edge(from,0,G[from].size()-1));
	}
	
	void bfs(int s){
		fill(level.begin(),level.end(),-1);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();que.pop();
			for(int i=0;i<(int)G[v].size();i++){
				edge &e = G[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	
	long long dfs(int v,int t,long long f){
		if(v==t) return f;
		for(int &i=iter[v];i<(int)G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				long long d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	
	long long flow(int s,int t,long long lim){
		long long fl=0;
		for(;;){
			bfs(s);
			if(level[t]<0||lim==0) return fl;
			fill(iter.begin(),iter.end(),0);
			long long f;
			while((f=dfs(s,t,lim))>0){
				fl+=f;
				lim-=f;
			}
		}
	}

	long long flow(int s,int t){
		return flow(s,t,INF);
	}

	//cap==1 only
	bool back_edge(long long s,long long t,long long from, long long to){
		for(long long i=0;i<(long long)G[from].size();i++) {
			edge& e=G[from][i];
			if(e.to==to) {
				if(e.cap==0&&flow(from,to,1)==0) {
					flow(from,s,1);
					flow(t,to,1);
					return 1;
				}
			}
		}
		return 0;
	}
};

bool ok=true;
ll n,m,cnt=0,d6=0;
vector<ll> d4;
graph g;

int main(void){
	cin>>n>>m;
	Dinic f(n+1);
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		g.add_edge(a,b);
		f.add_edge(a,b,1);
	}
	reg(i,1,n){
		if(g.v[i].size()%2==1){//オイラー閉路であることは必要
			ok=false;
			break;
		}
	}
	reg(i,1,n){
		if(g.v[i].size()>=6){
			d6++;
			break;
		}
		if(g.v[i].size()>=4){
			d4.push_back(i);
		}
	}
	if(ok){
		if(d6>0 || d4.size()>2 || (d4.size()==2 && f.flow(d4[0],d4[1])==2)){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 36480
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;
typedef long long ll ;
# define rep (i , n ) for ( int i =0; i < n ; i++)
# define _sort(arg) sort(begin(arg), end(arg))

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

	int N;
	cin >> N;

	std::vector<ll> v;
	for (int i = 0; i < 3 * N; ++i)
	{
		/* code */
		ll tmp;
		cin >> tmp;
		v.push_back(tmp);
	}

	sort(begin(v), end(v));

	ll total = 0;
	for (int i = N; i < 3 * N; i=i+2)
	{
		total += v[i];
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 6384
import math

a, b, x = map(int, input().split())

if (x * 2) / (a * b) <= a:
    print(90 - math.degrees(math.atan((x * 2) / (a * b) / b)))
else:
    print(math.degrees(math.atan(2 * (b - (x / a ** 2)) / a )))



Measured memory_bytes: 2940
def main():
    s = input()
    l = s.split(" ")
    shape_1 = int(l[0]) * int(l[1])
    shape_2 = int(l[2]) * int(l[3])
    if shape_1 == shape_2:
        print(shape_1)
    elif shape_1 > shape_2:
        print(shape_1)
    elif shape_1 < shape_2:
        print(shape_2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,n){
      if(s.at(i) != s.at(n-i-1)) ans++;
  }

  cout << ans/2 << endl;
}

Measured memory_bytes: 256