akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }

void main() {
    const ip = readln.split.to!(ulong[]);
    const w = ip[0], h = ip[1], x = ip[2], y = ip[3];

    double eps = 1e-9;

    writefln("%f %d", cast(double)(w*h)/2, (diff(cast(double)w/2, cast(double)x) < eps && diff(cast(double)h/2, cast(double)y) < eps) ? 1 : 0);

}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    map<char, ll> mp;
    string s;
    cin >> s;

    bool ok = (s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]);
    cout << (ok ? "Yes" : "No") << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
int a[maxn],b[maxn],c[maxn];
int par[maxn];
vector<int> init_g[maxn],g[maxn];
inline void init(int n){
	for(int i=1;i<=n;i++)
		par[i]=i;
}
int find(int x){
	if(par[x]==x) return x;
	return par[x]=find(par[x]);
}
ll sum[maxn],dp[maxn];
bool vis[maxn];
int ord[maxn];
inline bool cmp(const int& lhs,const int& rhs){
	return c[lhs]<c[rhs];
}
void dfs(int u){
	sum[u]=b[u];
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		dfs(v);
		sum[u]+=sum[v];
	}
	dp[u]=sum[u]+c[u];
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		dp[u]=min(dp[u],sum[u]-sum[v]+max((ll)c[u],dp[v]));
	}
}
int main(){
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	init(n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		c[i]=max(a[i]-b[i],0);
		ord[i]=i;
	}
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		init_g[u].push_back(v);
		init_g[v].push_back(u);
	}
	sort(ord+1,ord+1+n,cmp);
	for(int i=1;i<=n;i++){
		int u=ord[i];
		vis[u]=true;
		for(int j=0;j<(int)init_g[u].size();j++){
			int v=init_g[u][j];
			if(vis[v]){
				v=find(v);
				if(u!=v){
					g[u].push_back(v);
					par[v]=u;
				}
			}
		}
	}
	dfs(ord[n]);
	printf("%lld\n",dp[ord[n]]);
	return 0;
}

Measured memory_bytes: 19708
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    int a[n+1];
    for(int i=1;i<=n;i++)
        a[i]=(l+i-1);
    int b[n+1];
    for(int i=1;i<=n;i++)
        b[i]=abs(a[i]);
    auto count=min_element(b+1, b+n+1)-b;
    cout<<accumulate(a+1, a+n+1, 0)-*(count+a)<<endl;
    return 0;

}


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

int main(){
    using namespace std;
    string s;
    cin >> s;
    auto N = s.size();
    unsigned long ans{0}, ans2{0};
    for(unsigned long i = 0; i < N; ++i)ans += (i ^ s[i]) & 1;
    for(unsigned long i = 0; i < N; ++i)ans2 += !((i ^ s[i]) & 1);
    cout << min(ans, ans2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,w;
  int wi,v;
  
  cin >> n >> w;
  
  vector <int>W[4];
  int w1;
  cin >> w1 >> v;
  W[0].push_back(v);
  REP(i,n-1){
    cin >> wi >> v;
    W[wi-w1].push_back(v);
  }
  
  REP(i,4){
    sort(W[i].begin(),W[i].end());
    reverse(W[i].begin(),W[i].end());
  }
  
/*  REP(i,4){
    REP(j,W[i].size()){
      cout << W[i][j];
    }
    cout << endl;
  }
  */
  
  // 重さの決め打ち
  ll ans = 0;
  REP(a,W[0].size()+1){
    REP(b,W[1].size()+1){
      REP(c,W[2].size()+1){
        REP(d,W[3].size()+1){
          if(a*w1+b*(w1+1)+c*(w1+2)+d*(w1+3) > w) continue;
          ll sum = 0;
          REP(i,a){
            sum += W[0][i];
          }
          REP(i,b){
            sum += W[1][i];
          }
          REP(i,c){
            sum += W[2][i];
          }
          REP(i,d){
            sum += W[3][i];
          }
          ans = max(ans,sum);
        }
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main()
{
  int N;
  int i;
  cin >> N;
  vector<pair<int,pair<string,int>>> SP(N);
  for(i=0;i<N;i++)cin >> SP[i].second.first >> SP[i].second.second;
  for(i=0;i<N;i++)SP[i].first = i+1;
  sort(SP.begin(),SP.end(),[](pair<int,pair<string,int>> a,pair<int,pair<string,int>> b) {return (a.second.second > b.second.second);});
  stable_sort(SP.begin(),SP.end(),[](pair<int,pair<string,int>> a,pair<int,pair<string,int>> b) {return (a.second.first < b.second.first);});
  for(i=0;i<N;i++)cout << SP[i].first << endl;
}

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

using namespace std;


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
        cin >> p.at(i);
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += p.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(void) {
  int n, m, p, i, j, min;
  scanf("%d%d%d", &n, &m, &p);
  int d[m];
  for(i = 0; i < m; ++i) {
    scanf("%d", &d[i]);
    d[i] -= p;
    if(d[i] < 0) d[i] += n;
  }
  sort(d, d + m);
  min = n - d[0] > d[m - 1] ? d[m - 1] : n - d[0];
  for(i = 0; i < m; ++i) {
    if(d[i]) {
      if(i != m - 1 && min > 2 * d[i] + n - d[i + 1]) min = 2 * d[i] + n - d[i + 1];
      if(i && min > 2 * (n - d[i]) + d[i - 1]) min = 2 * (n - d[i]) + d[i - 1];
    }
  }
  printf("%d\n", min * 100);
  return 0;
}


Measured memory_bytes: 2764
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb1=new StringBuilder();
		StringBuilder sb2=new StringBuilder();
		String b=" ",n="\n";
        String[] rc=br.readLine().split(b);
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[][] h=new int[r+1][c+1];
        
        for(int i=0;i<r;i++){
        	String[] row=br.readLine().split(b);
        	for(int j=0;j<c;j++){
        		h[i][j]=Integer.parseInt(row[j]);
        		sb1.append(h[i][j]+b);
        		h[i][c]+=h[i][j];
        		h[r][j]+=h[i][j];
        		h[r][c]+=h[i][j];
        		if(i==r-1) sb2.append(h[r][j]+b);
        	}
        	sb1.append(h[i][c]+n);
        }
        sb2.append(h[r][c]);
        System.out.print(sb1);
        System.out.println(sb2);
	}
}

Measured memory_bytes: 25580
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define MAX 100001
#define MOD 1000000007
using namespace std;

int dp[3001][3001][2];

void play(int s,int e,int turn,int* a)
{
    if(dp[s][e][turn] != -1)
        return;
    if(s==e)
    {
        dp[s][e][turn] = a[s];
        dp[s][e][turn^1] = 0;
        return;
    }
    play(s+1,e,turn^1 , a);
    play(s,e-1,turn^1 , a);

    if(dp[s+1][e][turn] + a[s] > dp[s][e-1][turn] + a[e])
    {
        dp[s][e][turn] = dp[s+1][e][turn] + a[s];
        dp[s][e][turn^1] = dp[s+1][e][turn^1];
    }
    else
    {
        dp[s][e][turn] = dp[s][e-1][turn] + a[e];
        dp[s][e][turn^1] = dp[s][e-1][turn^1];
    }
    return;
}

 
int32_t main()
{
    int n;
    cin>>n;
    int*a = new int[n];
    for(int i=0;i<n;++i)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));

    play(0,n-1,0,a);

    cout<< dp[0][n-1][0] - dp[0][n-1][1] <<endl;


    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, a[101], b[101], c[101], d[101];
int v;
vector<int> G[201];
int match[201];
bool used[201];
void adde(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		int u = G[v][i];
		int w = match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bina(){
	int res = 0;
	memset(match, -1, sizeof(match));
	for(int v=0;v<2*n;v++){
		if(match[v]<0){
			memset(used, 0, sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<n;i++){
		cin >> c[i] >> d[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]<c[j]&&b[i]<d[j]){
				adde(i, j+n);
			}
		}
	}
	cout << bina() << endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Bits

import qualified Data.ByteString.Char8 as C
import Data.List

-- AOJ DSL_2_B Range Sum Query (RSQ)
main = do
  [n,q] <- get
  cxys <- replicateM q get
  mapM_ print $ sol n cxys

get = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

sol :: Int -> [[Int]] -> [Int]
sol n cxys = reverse $ runST $ initBIT n >>= f cxys []

f :: [[Int]] -> [Int] -> BIT s -> ST s [Int]
f [] rs _ = return rs
f ([0,x,y]:ts) rs b = add x y b >> f ts rs b
f ([1,x,y]:ts) rs b = seg x y b >>= \r -> f ts (r:rs) b

-- | Binary Indexed Tree - Implements mutable binary indexed trees
type BIT s = STUArray s Int Int

-- | Construct a new binary indexed tree on the indexes 1 through n. 
initBIT :: Int -> ST s (BIT s)
initBIT n = newListArray (1,n) $ repeat 0

-- | Compute the sum of all indexes 1 through i, inclusive. Takes O(logn). 
atBIT :: Int -> BIT s -> ST s Int
atBIT i bit = f i 0
  where
  f 0 v = return v
  f i v = f (i-i.&.(-i)) . (+v) =<< readArray bit i

-- | Increment the value at index i. Takes O(logn). 
add :: Int -> Int -> BIT s -> ST s ()
add i v bit = do
  (_, u) <- getBounds bit
  let
    f i = when (i<=u) $ do
      writeArray bit i . (+v) =<< readArray bit i
      f (i+i.&.(-i))
  f i

-- | Compute the segment sum of all indexes [l..r]. Takes O(logn). 
seg :: Int -> Int -> BIT s -> ST s Int
seg l r bit = liftM2 subtract (atBIT (l-1) bit) (atBIT r bit)

-- | Initialize BIT with a list 
mkBIT :: [Int] -> ST s (BIT s)
mkBIT as = do
  bit <- initBIT (length as)
  zipWithM (\i a -> add i a bit) [1..] as
  return bit


Measured memory_bytes: 106492
S = input()
T = input()

if len(set(S)) != len(set(T)):
    print("No")
    exit()

D = {}
for s, t in zip(S, T):
    if s not in D:
        D[s] = t
    elif D[s] != t:
        print("No")
        exit()

print("Yes")


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



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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n,m;
    cin>>n>>m;

    vector<int> r(n+1);

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        r[a]++;
        r[b]++;
    }

    for(int i=1;i<=n;i++){
        cout<<r[i]<<endl;
    }

}


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

int fie[5][5];
int o_fie[5][5]={
    -1,-1,0,-1,-1,
    -1,1,2,3,-1,
    4,5,6,7,8,
    -1,9,10,11,-1
    -1,-1,0,-1,-1,
};

int ox[12],oy[12],zx[2],zy[2],zcnt;
int res;
bool flag;

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

void dfs(int v,int dist,int pd,int pu){
    if(dist==0){
        flag=true;
        res=min(res,v);
        return;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<2;j++){
            if(pu==j && (pd+2)%4==i)continue;
            int nx=zx[j]+dx[i],ny=zy[j]+dy[i];
            if(nx>=0 && nx<5 && ny>=0 && ny<5){
                if(fie[nx][ny]<=0)continue;
                int ch=fie[nx][ny];
                int ndist=dist;
                ndist-=abs(ox[ch]-nx)+abs(oy[ch]-ny);
                swap(fie[nx][ny],fie[zx[j]][zy[j]]);
                ndist+=abs(ox[ch]-zx[j])+abs(oy[ch]-zy[j]);
                zx[j]+=dx[i];
                zy[j]+=dy[i];
                if(v+1+ndist<=res)dfs(v+1,ndist,i,j);
                zx[j]-=dx[i];
                zy[j]-=dy[i];
                swap(fie[nx][ny],fie[zx[j]][zy[j]]);
            }
        }
    }
}
int dist;

int main(void){
    for(int i=0;i<5;i++){
        for(int j=abs(2-i);j<=4-abs(2-i);j++){
            ox[o_fie[i][j]]=j;
            oy[o_fie[i][j]]=i;
        }
    }
    while(1){
        memset(fie,-1,sizeof(fie));
        dist=0;
        zcnt=0;
        for(int i=0;i<5;i++){
            for(int j=abs(2-i);j<=4-abs(2-i);j++){
                scanf("%d",&fie[j][i]);
                if(fie[j][i]==-1)return 0;
            }
        }
        for(int i=0;i<5;i++){
            for(int j=abs(2-i);j<=4-abs(2-i);j++){
                int v=fie[j][i];
                if(v==0){
                    zx[zcnt]=j;
                    zy[zcnt++]=i;
                }else dist+=abs(ox[v]-j)+abs(oy[v]-i);
            }
        }
        if(dist>20){
            printf("NA\n");
        }else{
            int i=0;
            flag=false;
            res=20;
            dfs(0,dist,-1,-1);
            if(flag){
                printf("%d\n",res);
            }
            if(!flag)printf("NA\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3140
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.flip();
	reversed.flip();
	int x, n, t;
    scanf("%d %d", &x, &n);
	if (n == 0) {
		printf("%d", x);
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &t);
		bits.reset(t);
		reversed.reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
        printf("%d", x);
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
 	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
        printf("%d", rV);
	} else if (d2 < d1) {
		printf("%d", lV);
	} else {
		printf("%d", min(rV, lV));
	}
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+2;
int N, K, h[MAXN], dp[MAXN];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> K;
	for(int i = 1;i<=N;i++) cin >> h[i];
	memset(dp, 0x3f, sizeof(dp));
	dp[1] = 0;
	for(int i = 1;i<=N;i++){
		for(int j = 1;j<=K;j++){
			if(i+j<=N)dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout << dp[N] << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(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 modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <pint> adj[N];

void solve() 
{
    int a, b, c;
    cin>>a>>b>>c;

    int k;
    cin>>k;

    int req = 0;

    while(b <= a)
    {
        b = 2*b;
        req++;
    }

    while(c <= b)
    {
        c = 2*c;
        req++;
    }

    if(req <= k)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }



}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15536
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int par[100020];
int find(int x){if(par[x]!=x)return par[x]=find(par[x]);return x;}
void unite(int x, int y){par[find(x)]=find(y);}
bool same(int x, int y){return find(x)==find(y);}

typedef struct{
    int len;
    int x;
    int y;
} pass_t;

typedef struct {
    int x;
    int i;
} x_t;

typedef struct{
    int y;
    int i;
} y_t;

int sortx(const void *a, const void *b){return ((x_t*)a)->x-((x_t*)b)->x;}
int sorty(const void *a, const void *b){return ((y_t*)a)->y-((y_t*)b)->y;}
int sortp(const void *a, const void *b){return ((pass_t*)a)->len-((pass_t*)b)->len;}

int main(void){
    for(int i=0;i<100020;i++){par[i]=i;}
    long long ans=0;
    int n;
    scanf("%d",&n);
    x_t x[n];
    y_t y[n];
    pass_t pass[n*2];
    for (int i=0; i<n; i++){
        scanf("%d%d",&x[i].x,&y[i].y);
        x[i].i=i;
        y[i].i=i;
    }
    qsort (x,n,sizeof(x_t),sortx);
    qsort (y,n,sizeof(y_t),sorty);
    for (int i=0; i<n-1; i++){
        pass[i].len=x[i+1].x-x[i].x;
        pass[i].x=x[i].i;
        pass[i].y=x[i+1].i;
    }
    for (int i=0; i<n-1; i++){
        pass[i+n-1].len=y[i+1].y-y[i].y;
        pass[i+n-1].x=y[i].i;
        pass[i+n-1].y=y[i+1].i;
    }
    qsort (pass,(n-1)*2,sizeof(pass_t),sortp);
    for (int i=0; i<(n-1)*2; i++){
        if (same(pass[i].x,pass[i].y)==false){
            ans+=pass[i].len;
            unite(pass[i].x,pass[i].y);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7660
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b) / 2 == a) {
		cout << c << "\n";
	}
	else if ((a + c) / 2 == a) {
		cout << b << "\n";
	}
	else {
		cout << a << "\n";
	}

	return 0;
}

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

int main(void){
	int x;

	while(cin>>x){
		if(x%2 == 1){
			cout<<(int)(2*pow(3,x/2)-1)<<endl;
		}
		else{
			int tmp = 2*pow(3,(x-1)/2)-1;
			cout<<((tmp-1)/4*6+2)<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,d,x,a;
    cin>>n>>d>>x;
    for(int i=0;i<n;i++){
        cin>>a;
        x += (d+a-1)/a;
    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public static long loop;

    static string s;

    static string output;

    public static void Main(string[] args)
    {
        loop = 0;

        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        //string[] input = null;

        // 文字列の入力
        s = Console.ReadLine();
    }

    static void Proc()
    {
        string text = string.Empty;

        for(int idx = 0; idx < s.Length; idx++)
        {
            string key = s.Substring(idx, 1);
            switch (key)
            {
                case "0":
                case "1":
                    text += key;
                    break;

                case "B":
                    if (text.Length > 0)
                    {
                        text = text.Substring(0, text.Length - 1);
                    }
                    break;

            }
        }

        output = text.ToString();
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
        output = string.Empty;
    }
}


Measured memory_bytes: 11092
//##Moh_K_Imar .......
//27/08/2020  ...  8.28
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a;
    cin>>a;
    if(a=="ARC")cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    
    return 0;
}



Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

const int N = 301;

double dp[N][N][N];
// dp[x][y][z] = x 3s, y 2s, z 1s , (n-x-y-z) 0s

// dp[x][y][z] = (1 + p3 * dp[x-1][y+1][z] + p2 * dp[x][y-1][z+1] + p1 * dp[x][y][z-1]) / (1 - p0);

int main(){
	int n;
	cin>>n;
	
	int cnt[4] = {0};
	
	for(int i = 0; i< n; i++){
		int x;
		cin>>x;
		cnt[x]++;
	}
	
	dp[0][0][0] = 0;
	
	for(int three = 0; three <= n; three++){
		for(int two = 0; two <= n; two++){
			for(int one = 0; one <= n; one++){
				int zero = n - three - two - one;
				if(zero == n){
					continue;
				}
				if(one + two + three > n){
					continue;
				}
				
				double val = 1;
				// pick 3
				if(three > 0) val += (1.0 * three / n) * dp[three-1][two+1][one];
				// pick 2
				if(two > 0) val += (1.0 * two / n) * dp[three][two-1][one+1];
				// pick 1
				if(one > 0) val += (1.0 * one / n) * dp[three][two][one-1];
				
				dp[three][two][one] = val / (1 - 1.0 * zero / n);
				
			}
		}
	}
	
	cout<<setprecision(9);
	cout<<fixed;
	cout<<dp[cnt[3]][cnt[2]][cnt[1]];
	return 0;
}

Measured memory_bytes: 111168
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll n;
    vector<ll> arr(5, 0);
    cin >> n;
    for(ll& val: arr)
        cin >> val;
    ll m = *min_element(arr.begin(), arr.end());
    ll bandwidth = 1+(n-1)/m;
    cout << bandwidth-1+5 << endl;
    return 0;
}




Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    int t = X / D;
    X -= min(t, K) * D;
    K -= min(t, K);
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << abs(X - D) << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int as,bs;
  char s[101];
  while(cin>>s){
    if(s[0]=='0') break;
    as = 0;
    bs = 0;
    for(int i=1;i<strlen(s);i++){
      if(s[i]=='A') as++;
      else bs++;
    }
    if(as>bs) as++;
    else bs++;
    cout << as << ' ' << bs << endl;
  }
  return 0;
}

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

int main() {
  int n;
  long long k;
  int ans;

  cin >> n>>k;

  k--;

  vector<int> a(n,0);
  vector<int> b;
  vector<int> t(n,0);
  int p=0;

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

  int j=0;
  for(int i=1;i<=n;i++) {
    if(t[j]!=0) {p=t[j];break;}
    b.push_back(a[j]);
    t[j] = i;
    j = a[j];
  }

  if(k>b.size()) {
    int l=p-1;
    int r=b.size()-l;
    ans=b[l+(k-l)%r];
  }
  else {ans=b[k];}

  cout << ans+1 << endl;

  return 0;
}


Measured memory_bytes: 5884
def merge(a, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = a[left:left + n1] + [SENTINEL]
    R = a[mid:mid + n2] + [SENTINEL]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    count += right - left

def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)

SENTINEL = 1000000001
n = int(input())
a = list(map(int, input().strip().split()))
count = 0
merge_sort(a, 0, len(a))
print(' '.join(map(str, a)))
print(count)

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

int gcd (int x, int y) {
	if (x < y) {
		int tmp = x;
		x = y;
		y = tmp;
	}
	if (x%y == 0) {
		return y;
	} else {
		return gcd (y, x%y);
	}
}

int main(int argc, char const* argv[])
{
	int x, y;
	cin >> x >> y;
	cout << gcd (x, y) << endl;
	return 0;
}


Measured memory_bytes: 1160
#include<stdio.h>
int main()
{ 
  int a,b,c;
  scanf("%d",&a);
  b=a%10;
  c=a/10;
  if(b==9)
    printf("Yes\n",a);
  else
    if(c==9)
      printf("Yes\n",a);
    else
      printf("No\n",a);
  return 0;   
}


Measured memory_bytes: 128
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	a := string(slice[0])
	b := string(slice[1])
	A, _ := strconv.Atoi(a)
	B, _ := strconv.Atoi(b)
	fmt.Printf("%d\n", A*B)
}


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

int n,ans;
int a[100001];

int partition(int p,int r){
	int temp;
	int x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i=i+1;
			temp =a[i];
			a[i]=a[j];
			a[j]=temp;
		}
	}
	i=i+1;
	temp =a[i];
	a[i]=a[r];
	a[r]=temp;
	return i;
}

int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	ans=partition(0,n-1);
	for(int i=0;i<n-1;i++){
		if(ans==i){
			cout<<"["<<a[i]<<"]"<<" ";
		}else{
			cout<<a[i]<<" ";
		}
	}
	cout <<a[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 3372
#-*-coding:utf-8-*-
from collections import deque

ans = 0

def dfs(v, n, used, linked_list):
    global ans
    if len(used) == n:
        ans += 1
        return
    else:
        for next_v in linked_list[v]:
            if next_v not in used:
                used.append(next_v)
                dfs(next_v, n, used, linked_list)
                used.remove(next_v)
        return

def main():
    global ans
    n, m = map(int, input().split())
    linked_list = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        linked_list[a].append(b)
        linked_list[b].append(a)
    used = [1]
    dfs(1, n, used, linked_list)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
struct Trie {
    int lch = -1, rch = -1;
};
vector<Trie> trieTree;

ll L;

ll dfs(int v, int depth) {
    ll ret = 0;
    if (trieTree[v].lch == -1 && trieTree[v].rch == -1) {
        return 0;
    } else if (trieTree[v].lch != -1 && trieTree[v].rch != -1) {
        ret = dfs(trieTree[v].lch, depth + 1) ^ dfs(trieTree[v].rch, depth + 1);
    } else {
        ret = (L - depth) & -(L - depth);
        if (trieTree[v].lch == -1) {
            ret ^= dfs(trieTree[v].rch, depth + 1);
        } else {
            ret ^= dfs(trieTree[v].lch, depth + 1);
        }
    }
    return ret;
}

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

    cin >> N >> L;
    trieTree.push_back(Trie());
    rep(i, 0, N) {
        string s;
        cin >> s;
        int cur = 0;
        rep(j, 0, s.size()) {
            if (s[j] == '0') {
                if (trieTree[cur].lch == -1) {
                    trieTree[cur].lch = trieTree.size();
                    cur = trieTree.size();
                    trieTree.push_back(Trie());

                } else {
                    cur = trieTree[cur].lch;
                }

            } else {
                if (trieTree[cur].rch == -1) {
                    trieTree[cur].rch = trieTree.size();
                    cur = trieTree.size();
                    trieTree.push_back(Trie());
                } else {
                    cur = trieTree[cur].rch;
                }
            }
        }
    }

    if(dfs(0,0) == 0){
        cout << "Bob" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 4304
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool maki[2][1000],niko[2][100],umi[2][10];
    memset(maki,0,sizeof(maki));
    memset(niko,0,sizeof(niko));
    memset(umi,0,sizeof(umi));
    ll n,ans=0,num=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        
        umi[(i+1)&1][s[i]-'0']=true;
        if(num>=1){
            niko[(i+1)&1][s[i]-'0']=true;
        }
        if(num==2){
            maki[(i+1)&1][s[i]-'0']=true;
        }
        if(s[i]-'0'==0)num++;
        for(int j=99;j>=0;j--){
            if(maki[i&1][j]||niko[i&1][j]){
                maki[(i+1)&1][j*10+(s[i]-'0')]=true;
            }
            if(j<10&&umi[i&1][j]){
                niko[(i+1)&1][j*10+(s[i]-'0')]=true;
            }
        }
        for(int j=0;j<1000;j++){
            if(j<10){
                if(umi[i&1][j])umi[(i+1)&1][j]=true;
                if(niko[i&1][j])niko[(i+1)&1][j]=true;
                if(maki[i&1][j])maki[(i+1)&1][j]=true;
            }
            else if(j<100){
                if(niko[i&1][j])niko[(i+1)&1][j]=true;
                if(maki[i&1][j])maki[(i+1)&1][j]=true;
            }
            else{
                if(maki[i&1][j])maki[(i+1)&1][j]=true;
            }
                    
        }
    }
    int m=n&1;
    for(int i=0;i<1000;i++){
        if(maki[m][i]){
            ans++;
        }
    }

cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int k,n,a[200001],i,L[200001],g;
    scanf("%d %d",&k,&n);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i = 1 ; i <= n-1 ; i++)
    {
        L[i] = a[i+1] - a[i];
    }
    L[n] = a[1] + k - a[n];
    g = L[1];
    for(i = 1 ; i <= n ; i++)
    {
        if(L[i] > g)
        {
            g = L[i];
        }
    }
    printf("%d\n",k - g);
    return 0;

}

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

int main(){
  int n,m;
  string s[150],t[150];
  cin >> n;
  int i;
  for(i=0;i<n;i++){
    cin >> s[i];
  }
  cin >> m;
  int j;
  for(j=0;j<m;j++){
    cin >> t[j];
  }
  int p[150]={};
  int k;
  for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      if(s[k]==s[i]){
        p[k]++;
      }
    }
    for(j=0;j<m;j++){
      if(s[k]==t[j]){
        p[k]--;
      }
    }
  }
  sort(p,p+n+1);
  cout << p[n] << endl;
}


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

int main() {
	int N;
	cin >> N;
	if (N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13 || N == 17) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 998244353;

struct Node
{
	int l , r;
}seg[12];
int cmp(Node a , Node b){	return a.l < b.l;}

ll dp[NMAX] , dp_sum[NMAX];

ll cal(int l , int r)
{
	return (dp_sum[r] - dp_sum[l - 1] + MOD )%MOD;
}
int main(int argc, char const *argv[])
{
	int n , k;
	scanf("%d%d",&n,&k);
	for(register int i = 1;i <= k;i++)
		scanf("%d%d",&seg[i].l,&seg[i].r);
	sort(seg + 1, seg + 1 + k, cmp);
	dp[1] = dp_sum[1] = 1;
	for(register int i = 2;i <= n;i++)
	{
		for(register int j = 1;seg[j].l < i && j <= k;j++)
			dp[i] = (dp[i] + cal(max(1 , i - seg[j].r) , i - seg[j].l) + MOD)%MOD;
		dp_sum[i] = (dp[i] + dp_sum[i - 1] + MOD)%MOD;
	}
	// for(register int i = 1;i <= n;i++)
	// 	printf("%lld%c",dp[i],i == n?'\n':' ' );
	printf("%lld\n",dp[n] );
	return 0;
}

Measured memory_bytes: 6948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 2001

void swap(int &a, int &b)
{
    int t = a;
    a = b;
    b = t;
}

void solve()
{
    int n;
    cin >> n;
    int a[n], b[n], cnt[n + 1];
    s(cnt, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        cnt[b[i]]++;
    }
    for (int i = 0; i <= n; i++)
    {
        if (cnt[i] > n)
        {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
    reverse(b, b + n);
    int l = 0, r = n - 1;
    for (int i = 0; i < n; i++)
    {
        if (b[i] == a[i])
        {
            if (b[l] != a[i] && b[i] != a[l])
            {
                swap(b[i], b[l]);
                l++;
            }
            else
            {
                swap(b[i], b[r]);
                r--;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << b[i] << " ";
    }
    cout << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int t;
  double a = 0;
  vector<int> v;
  for(int i = 0; i < n; ++i){
    cin >> t;
    a += t;
    v.push_back(t);
  }
  
  int p = (int)round(a/n);
  
  int res = 0;
  
  for(int i = 0; i < n; ++i){
  	res += pow(v[i] - p, 2);
  }
  
  cout << res << endl;
  
  return 0;
  
}

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

public class Main {
	public static void main(String args[]) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int A = sc.nextInt();
		int B = sc.nextInt();
		for(int i=1;i<=3;i++) {
			if (A!=i && B!= i) out.println(i);
		}



		out.flush();
	}


}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}



Measured memory_bytes: 20564
#include <stdio.h>
void output(int A[], int Max); //出力をする関数
void insertionSort(int A[], int Max); //並べ直す関数
int main(){

  int i , N , A[100];

  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  insertionSort(A , N);

  return 0;
}

void output(int A[] , int Max){
  int i;

  for(i = 0; i < Max; i++){
    if(i>0 && i<Max) printf(" ");
    printf("%d",A[i]);
  }
}

void insertionSort(int A[] , int Max){
  int i, v, j;

  for(i = 0; i < Max; i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j + 1] = v;
    output(A , Max);
    printf("\n");
  }
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const int EPS = 1E-10;

vii star;
vii photo;
vii dz;
map<pii, bool> hm;
int x, y;
int m, n;

int main()
{
  while(cin >> m, m){
    star.clear();
    photo.clear();
    dz.clear();
    hm.clear();
    rep(i, m){
      cin >> x >> y;
      star.pb(mp(x, y));
    }
    cin >> n;
    rep(i, n){
      cin >> x >> y;
      photo.pb(mp(x, y));
      hm[mp(x, y)] = true;
    }
    rep(i, m) dz.pb(mp(star[i].first - star[0].first, star[i].second - star[0].second));

    rep(i, n){
      pii res = mp(photo[i].first - star[0].first, photo[i].second - star[0].second);
      rep(j, m) if(!hm[mp(photo[i].first + dz[j].first, photo[i].second + dz[j].second)]) res = pii(-1, -1);
      if(res != mp(-1, -1)) cout << res.first << ' ' << res.second << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 12468
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
	int H,W;
	cin >> H >> W;
	string S[H][W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
		  if (S[i][j] == "snuke") {
				char c = 'A' + j;
				int s = i+1;
				cout << c << s << endl;
			}
		}
	}
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<char> S(N);
    for(int i = 0; i < N; i++){
        cin >> S[i];
        if(S[i] == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

const int MAXN = 5002;
const uint64_t MOD = 1e9 + 7;

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    /*
    vector<uint64_t> cur_num(MAXN);
    vector<uint64_t> num_z;
    cur_num[0] = 1;
    num_z.push__back(cur_num[0]);
    for (int t = 1; t < MAXN; ++t) {
        vector<uint64_t> new_num(MAXN, 0);
        for (int i = 0; i < MAXN - 1; ++i) {
            new_num[i] += cur_num[i + 1];
        }
        for (int i = 1; i < MAXN; ++i) {
            new_num[i] += 2 * cur_num[i - 1];
        }
        new_num[0] += cur_num[0];

        for (auto& x : new_num) x %= MOD;

        cur_num.swap(new_num);
        num_z.push__back(cur_num[0]);
    }

    int n;
    cin >> n;
    vector<vector<uint64_t>> dp(n + 1, vector<uint64_t>(k, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
    }
    */
    int n;
    cin >> n;

    vector<int64_t> dp(n + 2, 0);
    dp[0] = 1;
    for (int t = 1; t <= n; ++t) {
        vector<int64_t> new_dp(n + 2, 0);
        new_dp[0] = dp[0] + 2 * dp[1];
        for (int i = 1; i <= t; ++i) {
            new_dp[i] = dp[i - 1] + 2 * dp[i + 1];
        }
        for (int i = 0; i < n + 2; ++i) {
            dp[i] = new_dp[i] % MOD;
        }
    }
    string s;
    cin >> s;
    cout << dp[s.size()];
}


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

using namespace std;

int main()
{
    int n;
    int d;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> d;
        a[i]=d/10;
    }
    int mx=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        mx=max(mx,a[i]+i);
        if(mx<=i)flag=false;
    }
    reverse(a,a+n);
    mx=0;
    for(int i=0;i<n;i++){
        mx=max(mx,a[i]+i);
        if(mx<=i)flag=false;
    }
    if(flag)puts("yes");
    else puts("no");
    return 0;
}



Measured memory_bytes: 4200
#include <stdio.h>
#include <string.h>
char s[101];
 int main(void) {
 scanf("%s", s);
 int res = 0;
 int n = strlen(s);
 for (int i = 0; i < n; i++) {
 if (s[i] != s[n - 1 - i]) res++;
 }
 printf("%d\n", res / 2);
 }

Measured memory_bytes: 128
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

template<typename T> T gcd(T x, T y) {
  while (y > 0){
    T tmp = x % y;
    x = y;
    y = tmp;
  }
  return x;
}

template<typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0) return 0;
  else return x * y / gcd(x, y);
}


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

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  if (n == 1) {
    if (a[0] == k) {
      cout << "POSSIBLE" << endl;
      return 0;
    } else {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }

  sort(a.begin(), a.end());

  if (a.back() < k) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  int g = a[0];
  for (int i = 0; i < n; ++i) {
    if (a[i] == k) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
    g = gcd(g, a[i]);
  }

  if (k % g == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int A, B;
	double T;
	cin >> A >> B >> T;
	int count = 0;
	T += 0.5;
	int i = 1;
	int tmp = A;
	while ( tmp < T ) {
		
		count += B;

		
		i++;
		tmp = A * i;
	}

	cout << count << endl;

	return 0;
}

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

using namespace std;

int n, m;
int vis[100005];
int fr[100005], to[100005];
vector <int> adj[100005];
int a[100005];
int swp[100005];
int dad[100005], id[100005];

void dfs(int u) {
    swp[u] = a[u];
    for (auto x: adj[u]) {
        int v = u ^ fr[x] ^ to[x];
        if (vis[v]) continue;
        vis[v] = 1;
        dad[v] = u;
        id[v] = x;
        dfs(v);
        swp[u] ^= swp[v];
    }
}

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> fr[i] >> to[i];
        a[fr[i]] ^= 1;
        adj[fr[i]].push_back(i);
        adj[to[i]].push_back(i);
    }
    if (m & 1) return cout << "-1" << endl, 0;
    vis[1] = 1;
    dfs(1);
    for (int i = 1; i <= n; ++i) if (swp[i]) {
        int x = id[i];
        swap(fr[x], to[x]);
    }
    for (int i = 1; i <= m; ++i) cout << fr[i] << ' ' << to[i] << endl;
    return 0;
}


Measured memory_bytes: 14336