akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 5;
struct node{char ch; int x, y, z;};
vector<node>vec;
void emit(char ch, int x, int y, int z) {
    vec.push_back({ch, x, y, z});
}
bool used[MAXN];
int cnt = 1;
int newtemp() {
    while (used[cnt]) cnt++;
    used[cnt] = 1;
    return cnt;
}
const int up = 30;
int powB[32], pow2[32], p2[32];
int main() {
    int res = 2;
    used[0] = used[1] = used[2] = 1;
    int zero = newtemp(), one = newtemp();
    int A = newtemp();
    int B = newtemp(); 
    emit('+', 0, zero, A);
    emit('+', 1, zero, B);
    emit('+', zero, zero, 0);
    int AplusB = newtemp();
    emit('+', A, B, AplusB);
    emit('<', zero, AplusB, one);
    
    powB[0] = B;
    for (int i = 1; i <= up; i++) {
        powB[i] = newtemp();
        emit('+', powB[i - 1], powB[i - 1], powB[i]);
    }

    pow2[0] = one; 
    for (int i = 1; i <= up; i++) {
        pow2[i] = newtemp();
        emit('+', pow2[i - 1], pow2[i - 1], pow2[i]);
    }
    int cntA = newtemp(), temp = newtemp(), sig1 = newtemp(), sig2 = newtemp(), sig = newtemp();
    for (int k = up; k >= 0; k--) {

        // cntA += 2^k
        emit('+', cntA, pow2[k], temp);
        emit('<', temp, A, sig1);
        emit('<', A, temp, sig2);
        emit('+', sig2, sig2, sig2);
        emit('+', sig1, one, sig1);
        emit('<', sig2, sig1, sig);
        int v1 = newtemp(); // 2^k or 0
        emit('+', sig, zero, v1);
        for (int i = 1; i <= k; i++) emit('+', v1, v1, v1);
        emit('+', cntA, v1, cntA);

        // res += 2^k * B
        p2[0] = newtemp();
        emit('+', zero, sig, p2[0]);
        for (int i = 1; i <= up; i++) {
            p2[i] = newtemp();
            emit('+', p2[i - 1], p2[i - 1], p2[i]);
        }
        int v2 = newtemp(); // 2^k * B or 0
        int t = newtemp(), sigB1 = newtemp(), sigB2 = newtemp(), sigB = newtemp();
        for (int i = up; i >= 0; i--) {
            emit('+', v2, p2[i], t);
            emit('<', t, B, sigB1);
            emit('<', B, t, sigB2);
            emit('+', sigB1, sigB1, sigB1);
            emit('+', sigB1, one, sigB1);
            emit('<', sigB2, sigB1, sigB);
            emit('+', sigB, p2[0], sigB);
            emit('<', one, sigB, sigB);
            int vv = newtemp();
            emit('+', sigB, zero, vv);
            for (int j = 1; j <= i; j++) emit('+', vv, vv, vv);
            emit('+', v2, vv, v2);
        }
        // now v2 == B
        for (int i = 1; i <= k; i++) emit('+', v2, v2, v2);
        emit('+', res, v2, res);
    }

    printf("%d\n", (int)vec.size());
    for (auto item : vec) {
        printf("%c %d %d %d\n", item.ch, item.x, item.y, item.z);
    }
    return 0;
}

Measured memory_bytes: 3776
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N = 1e6 + 6;
const int INF = 1e9;
int main(){
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 1; i <= k; ++ i)
        cout << s << " ";
    for (int i = k + 1; i <= n; ++ i)
        cout << (int)(s == INF ? 1 : INF) << " ";
    cout << endl;
}


Measured memory_bytes: 1280
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
  s = input()
  if s=='AC':
    AC+=1
  elif s=='WA':
    WA+=1
  elif s=='TLE':
    TLE+=1
  else:
    RE+=1
print('AC x',AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Measured memory_bytes: 9196
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string a, b, c; cin >> a >> b >> c;
    if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

string code;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> code;

    REP1 (i,SZ(code) - 1) {
        if (code[i] == code[i-1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }

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


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

int main() {
    int a[3][3],n;
    int ans(0);

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

    cin >> n;

    for(int k=0;k<n;k++){
        int b;
        cin >> b;

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

    for(int i=0;i<3;i++){
        if((a[i][0]+a[i][1]+a[i][2])==0)
            ans = 1;
    }
    
    for(int i=0;i<3;i++){
        if((a[0][i]+a[1][i]+a[2][i])==0)
            ans = 1;
    }

    if((a[0][0]+a[1][1]+a[2][2])==0||(a[0][2]+a[1][1]+a[2][0])==0)
        ans = 1;

    if(ans==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
N = int(input())
List = list(map(int, input().split()))
res = 0
if N >=3:
  for i in range(N-2):
    for j in range(i+1,N-1):
      for k in range(j+1,N):
        if List[i]==List[j] or List[i]==List[k] or List[k]==List[j]:
          pass
        else:
          if List[i]+List[j] > List[k] and List[j]+List[k] > List[i] and List[k]+List[i] > List[j]:
            res += 1
print(res)

Measured memory_bytes: 9208
#include <stdio.h>

int main(void)
{
    char s[5];
    int w[26] = {0};
    scanf("%s", s);
    int i;
    for (i = 0; i < 4; ++i){
        ++w[s[i] - 'A'];
    }

    int cnt = 0;
    for (i = 0; i < 26; ++i) {
        if (w[i] == 2) ++cnt;
    }
    if (cnt == 2)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
import sys
N=int(input())
D=[int(i) for i in input().split()]
L=[0]*13
L[0]=1
for d in D:
    L[d]+=1
for s in L:
    if s>=3:
        print(0)
        sys.exit()
if L[0]>=2 or L[12]>=2:
    print(0)
    sys.exit()
#print(L)
def check(K):
    sta=0
    #end=0
    num=10**9
    ans=10**9
    while sta<24:
        if K[sta]==1:
            ans=min(ans,num)
            num=0
        sta+=1
        num+=1
        #print(num,sta,ans)
    ans=min(num,ans)
    return ans


ans=-1
for s in range(1<<11):
    K=[0]*24
    K[0]=1
    if L[12]==1:
        K[12]=1
    for j in range(11):
        if L[j+1]==0:
            continue
        if L[j+1]==2:
            K[j+1]=1
            K[24-(j+1)]=1
            continue
        if (s&(1<<j)):
            K[j+1]=1
        else:
            K[24-(j+1)]=1
    ans=max(ans,check(K))
print(ans)

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

using namespace std;

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vb vector<bool>
#define vl vector<long>
#define vi vector<int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char dir[] = {'R', 'L', 'D', 'U'};
const int MOD = 1e9 + 7;
int n, m;

int ff(vector<vi> adj)
{
    vb v(n);
    queue<int> q;
    int compcount = 0;
    for(int i = 0; i < n; i++)
    {
        if(v[i]) continue;
        v[i] = 1; compcount++;
        q.push(i);
        while(!q.empty())
        {
            int curr = q.front(); q.pop();
            for(int adjnode : adj[curr])
            {
                if(v[adjnode]) continue;
                v[adjnode] = true;
                q.push(adjnode);
            }
        }
    }
    return compcount - 1;
}

void solve()
{
    cin >> n >> m;

    vector<vi> adj(n);

    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    cout << ff(adj);
}

int main()
{
    fastio

    //ifstream fin(".in");
    //ofstream fout(".out");


    int t = 1;
    //cin >> t;

    while(t-- > 0) solve();
}


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

signed main(void){
    int N,M;
    int a,b;
    std::vector<std::vector<int>> edge;
    
    
    std::cin >> N >> M;
    edge.resize(N);
    for(int i=0;i<M;i++){
        std::cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    
    std::vector<int> Ans(N,-1);
    std::vector<bool> visited(N,false);
    
    std::queue<int> Queue;
    Queue.push(0);
    visited[0]=true;
    
    while(!Queue.empty()){
        int t = Queue.front();
        Queue.pop();
        for(int v:edge[t]){
            if(visited[v])continue;
            Queue.push(v);
            Ans[v]=t;
            visited[v]=true;
        }
    }
    
    for(int i=1;i<N;i++){
        if(Ans[i]==-1){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    
    std::cout << "Yes" << std::endl;
    for(int i=1;i<N;i++){
        std::cout << Ans[i]+1 << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 10160
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
 
using namespace std;
 
int main() {
  string S, ans;
  ans = "No";
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5]){
    ans = "Yes";
  }
  cout << ans << endl;
}

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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

const int maxn = 511;
int n, p[maxn * maxn], dist[maxn][maxn], a[maxn][maxn];

void update(int x, int y)
{
	std::deque<pii> q;
	static int mark[maxn][maxn], timer;
	timer++;
	q.emplace_back(x, y);
	a[x][y] = 0;
	dist[x][y]--;
	while(!q.empty())
	{
		int x = q.front().ff, y = q.front().ss; q.pop_front();
		if(mark[x][y] == timer) continue;
		mark[x][y] = timer;
		if(dist[x-1][y] > dist[x][y] + a[x-1][y])
		{
			dist[x-1][y] = dist[x][y] + a[x-1][y];
			if(a[x-1][y]) q.emplace_back(x-1, y);
			else q.emplace_front(x-1, y);
		}
		if(dist[x+1][y] > dist[x][y] + a[x+1][y])
		{
			dist[x+1][y] = dist[x][y] + a[x+1][y];
			if(a[x+1][y]) q.emplace_back(x+1, y);
			else q.emplace_front(x+1, y);
		}
		if(dist[x][y+1] > dist[x][y] + a[x][y+1])
		{
			dist[x][y+1] = dist[x][y] + a[x][y+1];
			if(a[x][y+1]) q.emplace_back(x, y+1);
			else q.emplace_front(x, y+1);
		}
		if(dist[x][y-1] > dist[x][y] + a[x][y-1])
		{
			dist[x][y-1] = dist[x][y] + a[x][y-1];
			if(a[x][y-1]) q.emplace_back(x, y-1);
			else q.emplace_front(x, y-1);
		}
	}
}

int main()
{
	get1(n);
	for(int i=1; i<=n*n; i++) get1(p[i]);
	
	for(int i=1; i<=n; i++) for(int j=1; j<=n; j++)
	{
		dist[i][j] = std::min(i-1, j-1);
		dist[i][j] = std::min(dist[i][j], std::min(n - i, n - j));
		dist[i][j]++;
		a[i][j] = 1;
	}
	
	LL ans = 0;
	for(int t=1; t<=n*n; t++)
	{
		int i = (p[t] - 1) / n + 1, j = (p[t] - 1) % n + 1;
		ans += dist[i][j] - 1;
		update(i, j);
	}
	printendl(ans);
	return 0;
}

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

int main (void){

	int i=0;
	int number=0;
	int input[100000]={0};
	int count=0;
	int x=0;
	int y=0;
	int flag=0;
	
	scanf("%d",&number);

	for ( i=0; i < number; i++){
		scanf("%d", &input[i]);
		
	}

	i=0;
	x=0;

	while(1){
		flag=0;
		for(x=1; x*x < input[i]; x++){
			if ( (input[i]-x) % (2*x+1) == 0){
				flag=1;
				break;
			}
		}
		
		if(flag){
			count++;
		}
		i++;

		if (i == number){
			break;
		}
	}

	printf("%d\n",number-count );
	

	return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  
  string result;
  
  rep(i, n) {
    result += s[i];
    result += t[i];
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	int A[100];
	int goukei = 0;
	int saishou10 = 1e9;
	rep(i, N) {
		cin >> A[i];
		goukei += A[i];
		if (A[i] % 10) saishou10 = min(saishou10,A[i]);
	}
	if (goukei % 10 == 0) {
		if (saishou10 > 1e8) goukei = 0;
		else goukei -= saishou10;
	}

	co(goukei);

	Would you please return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def solve():
    n, m, k = MI()
    uf = UnionFind(n)

    friends = [0] * n
    for i in range(m):
        a, b = MI1()
        uf.union(a, b)
        friends[a] += 1
        friends[b] += 1
    # print(uf.__str__())
    # print(friends)

    # blocks = [[0] * n for _ in range(n)]

    blocks = {}
    for i in range(k):
        c, d = MI1()
        # blocks[c][d] += 1
        # blocks[d][c] += 1
        blocks.setdefault(c, [])
        blocks[c].append(d)

        blocks.setdefault(d, [])
        blocks[d].append(c)

    # print(blocks)

    ans = [0] * n

    for i in range(n):
        # print(i, uf.size(i))
        block = 0
        # print('  bb', blocks.get(i))
        for bb in blocks.get(i, []):
            # print(bb)
            if uf.same(i, bb):
                # print(idx, bb, uf.find(idx), uf.same(idx, i))
                block += 1
        ans[i] = uf.size(i) - 1 - block - friends[i]
        # print(ans)

    print(' '.join(list(map(str, ans))))

if __name__ == '__main__':
    solve()


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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == b) cout << "Draw\n";
  else if(a == 1) cout << "Alice\n";
  else if(b == 1) cout << "Bob\n";
  else if(a > b) cout << "Alice\n";
  else cout << "Bob\n";
}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

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

    int N;
    cin >> N;

    int max_count = 0;

    map<string, int> scount;
    for (int i = 0; i < N; i++)
    {
        string str;
        cin >> str;

        scount[str]++;
        max_count = max(max_count, scount[str]);
    }

    vector<string> vote;
    for (pair<string, int> el : scount)
    {
        if (el.second == max_count)
        {
            vote.push_back(el.first);
        }
    }

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

    for (string el : vote)
    {
        cout << el << "\n";
    }

    return 0;
}

Measured memory_bytes: 25584
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s[]={"SAT","FRI","THU","WED","TUE","MON","SUN"},c;
  cin>>c;
  for(int i=0;i<7;i++)
  {
    if(c==s[i])
    {
      cout<<i+1<<endl;
    }
  }
  return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int m,d;
    cin>>m>>d;
    int ans=0;
    rep(i,1,m+1){
        int d1,d10;
        rep(j,1,d+1){
            d1=j%10;
            d10=j/10;
            if(d1>=2&&d10>=2&&d1*d10==i)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
typedef long long LL;
LL mod=1e9+7;
LL ppower(LL s)
{
	LL r=1,a=2;
	while(s)
	{
		if(s&1) r=r*a%mod;
			a=a*a%mod;
			s=s>>1;
	}
	return r;
}
int main()
{
	LL a[100005],n,m,resu;
	while(~scanf("%lld",&n))
	{
		memset(a,0,sizeof(a));
		for(LL i=0;i<n;i++)
		{
			scanf("%lld",&m);
			a[m]++;
		}
		LL flag=0;
		if(n&1)
		{
			if(a[0]>1)
				flag=1;
			else
			{
				for(LL i=1;i<n;i++)
				{
					if(a[i]>2||a[i]==1)
						flag=1;
					if(flag)
						break;
				}
			}
			if(!flag)
				resu=ppower(n/2) ;
		}
		else
		{
			if(a[0]>0)
				flag=1;
			else
			{
				for(LL i=1;i<n;i++)
				{
					if(a[i]>2||a[i]==1)
						flag=1;
					if(flag)
						break;
				}
			}
			if(!flag)
				resu=ppower(n/2) ;
		}
		if(flag) printf("0\n");
		else printf("%lld\n",resu);
	}
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, k;
	cin >> n >> k;
	vint a(n);
	int mx = 0;
	rep(i, n) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	if (mx < k) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	int tmp = a[0];
	rep(i, n - 1) {
		while (tmp != 0 && a[i + 1] != 0) {
			if (tmp > a[i + 1]) {
				tmp %= a[i + 1];
			}
			else {
				a[i + 1] %= tmp;
			}
		}
		tmp = max(tmp, a[i + 1]);
	}
	POSSIBLE(k%tmp == 0);
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int cnt = 0;
	for (int ii = 0; ii < N; ++ii){
		double X, Y;
		cin >> X >> Y;
		double dist = sqrt(X*X + Y*Y);
		if (dist <= D){
			cnt++;
		}
	}


	cout << cnt << "\n";

	return 0;
}


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

#define int long long

int n;

int rec(int stage) {
  // 終了条件
  if (stage == 0) {
    return 1;
  }

  int ans = 0;

  for (int i = 1; i <= 3; i++) {
    if (stage - i < 0) continue;
    ans += rec(stage - i);
  }

  return ans;
}

signed main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    int ans = (rec(n) + 3650 - 1) / 3650;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3012
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        String s = sc.next(); String t = sc.next(); int ans = 0;
        for (int i = 0; i < s.length(); i++) if (s.charAt(i) != t.charAt(i)) ans++;
        System.out.println(ans);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 37040
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, q;
   cin >> n ;
   vector<int> v;
   for(int i = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);  
	 }
   cin >> q;
   for(int i  = 0; i < q; i++){
	   int start, end;
	   cin >> start >> end;
	   reverse(v.begin() + start, v.begin() + end);	      
	}
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == n - 1) cout << v[i] << endl;
	  else cout << v[i] <<  " ";
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll> ma(N);
    vector<tuple<ll,ll,ll>>p(M);
    rep(i,M){
        ll P,Y;
        cin>>P>>Y;
        P--;
        p[i]=make_tuple(P,Y,i);
        
    }
    sort(all(p));
    vector<tuple<ll,ll,ll>>ans(M);
    ll cnt=1;
    ll pp=-1;
    rep(i,M){
        if(get<0>(p[i])+1==pp){
            cnt++;
        }else{
            cnt = 1;
        }
        get<0>(ans[i]) = get<2>(p[i]);
        get<1>(ans[i]) = get<0>(p[i])+1;
        get<2>(ans[i]) = cnt;
        pp = get<0>(p[i])+1;
    }
    sort(all(ans));

    rep(i,M){
        cout << setfill('0') << right << setw(6) << get<1>(ans[i]);
        cout << setfill('0') << right << setw(6) << get<2>(ans[i]);
        cout<<endl;
    }


    return 0;
    

}

Measured memory_bytes: 8768
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    int sumgcd = 0;
    
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<n; k++){    
                sumgcd += gcd(gcd(i+1,j+1),k+1);
            }
        }
    }

    cout << sumgcd;

}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
        cin >> A[i] >> B[i] >> C[i];

    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = A[0], dp[0][1] = B[0], dp[0][2] = C[0];
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            if (j == 0) dp[i][j] = A[i] + max(dp[i - 1][1], dp[i - 1][2]);
            if (j == 1) dp[i][j] = B[i] + max(dp[i - 1][2], dp[i - 1][0]);
            if (j == 2) dp[i][j] = C[i] + max(dp[i - 1][0], dp[i - 1][1]);
        }
    }

    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
    return 0;
}

Measured memory_bytes: 6912
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
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))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	cin >> s;

	string ns = "";

	for(int i = 0; i < s.size(); i++)
	{
		if ((s[i] == 'B') &&  ((i < s.size() -1 ) &&(s[i+1] == 'C')) )
		{
			ns+= "D";
			i++;
		}
		else
		{
			ns+= s[i];
		}
		
	}
	//cout << ns << endl;

	ll total = 0;
	ll count_A = 0;
	//int count_D = 0;
	for (int i = 0; i < ns.size(); i++)
	{
		if (ns[i] == 'A')
		{
			count_A++;
		}
		else if (ns[i] == 'D')
		{
			//count_D++;
			total += count_A;
		}
		else
		{
			count_A = 0;
			//count_D = 0;
		}
		

	}
	cout << total << endl;
	
	return 0;
}


Measured memory_bytes: 916
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>

#define RAND(min,max) (rand()%(max-min+1)+min)
#define LOG(log) {printf("%d\n",log);}
#define DEBUG(void) {printf("\nDEBUG %d\n",num_debug);num_debug++;}
char num_debug = 0;

int main(void) {
	srand((unsigned)time(NULL));

	int x;
	int n;
	int angle=-1;
	
	scanf("%d", &x);

	for (n = 1; angle != 0; n++) {
		angle = (x * n)%360;
		//LOG((x * n))
	}

	printf("%d", n-1);

	return 0;
}

Measured memory_bytes: 1736
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#define ll long long int
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll x=7;
    ll flag=0;
    for(ll i=1;i<=n;i++)
    {
        if(x%n==0) {cout<<i<<endl; flag=1; break;}
        else x=((x*10)+7)%n;
    }
    if(flag==0) cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int n,ans = 0,l = 0,r;
    cin>>n;
    vector<char>c(n);
    rep(i,n)cin>>c[i];
    r = n - 1;
    while(true){
        while(c[l] == 'R' && l < n)l++;
        while(c[r] == 'W' && r >= 0)r--;
        if(l >= r)break;
        c[l] = 'R';
        c[r] = 'W';
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ufr[100100],ufp[100100];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufr[i] = 1;
		ufp[i] = i;
	}
}

int ufind(int x){
	if(ufp[x] != x){
		ufp[x] = ufind(ufp[x]);
	}
	return ufp[x];
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return;
	}
	if(ufr[x] > ufr[y]){
		ufp[y] = x;
		ufr[x] += ufr[y];
	}else{
		ufp[x] = y;
		ufr[y] += ufr[x];
	}
}

int main(void){
	int n,m,x,y,z,i,ans=0;
	cin >> n >> m;
	ufinit(n);
	for(i=0; i<m; ++i){
		cin >> x >> y >> z;
		--x; --y;
		unionf(x,y);
	}
	for(i=0; i<n; ++i){
		if(i==ufind(i)){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int N=50005;
int n,i,a,b,c,d,e;
int main()
{
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	a=a*60+b;
	c=c*60+d;
	cout<<max(c-a-e,0); 
}


Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x < r || x > W - r || y < r || y > H - r)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

Measured memory_bytes: 3096
/*input
14 13
158 167 181 147 178 151 179 182 176 169 180 129 175 168
181 150 178 179 167 180 176 169 182 177 175 159 173
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int a[maxn],b[maxn];

int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,n) cin>>a[i],a[i]--;
	REP(i,m) cin>>b[i],b[i]--;
	sort(a,a+n,greater<int>());
	sort(b,b+m,greater<int>());

	REP(i,n-1) if(a[i]==a[i+1]){
		cout<<"0\n";
		return 0;
	}
	REP(i,m-1) if(b[i]==b[i+1]){
		cout<<"0\n";
		return 0;
	}

	int pta=0,ptb=0;
	ll ans=1;
	int space=0;
	for(int i=n*m-1;i>=0;i--){
		while(pta<n&&a[pta]>=i) pta++,space+=ptb;
		while(ptb<m&&b[ptb]>=i) ptb++,space+=pta;
		if(a[pta-1]==i&&b[ptb-1]==i) space--;
		else if(a[pta-1]==i){
			ans=ans*ptb%MOD;
			space--;
		}
		else if(b[ptb-1]==i){
			ans=ans*pta%MOD;
			space--;
		}
		else{
			ans=ans*space%MOD;
			space--;
		}
		if(space<0){
			cout<<"0\n";
			return 0;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s;
    int a, b;
    while(cin >> a >> b) {
        cin >> s;
        bool flag = 1;
        if(s[a] == '-') {
            for(int i = 0; i <= a + b; ++i) {
                if(i == a) continue;
                if(!isdigit(s[i])) {
                    flag = 0;
                    break;
                }
            }
        } else flag = 0;
        cout << (flag ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    REP(i,n) cin >> s[i];

    VVI c(n, VI(m));
    REP(i,n){
        int x = 0;
        REP(j,m){
            if (s[i][j] == '.'){
                c[i][j] += x;
                x++;
            }else{
                x = 0;
            }
        }
        x = 0;
        FORR(j,m-1,0){
            if (s[i][j] == '.'){
                c[i][j] += x;
                x++;
            }else{
                x = 0;
            }
        }
    }
    REP(j,m){
        int x = 0;
        REP(i,n){
            if (s[i][j] == '.'){
                c[i][j] += x;
                x++;
            }else{
                x = 0;
            }
        }
        x = 0;
        FORR(i,n-1,0){
            if (s[i][j] == '.'){
                c[i][j] += x;
                x++;
            }else{
                x = 0;
            }
        }
    }

    int ans = 0;
    REP(i,n) REP(j,m) chmax(ans, c[i][j]);
    ans++;
    cout << ans << endl;


    return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, a, tmp;
	vector<int> flag(3, 0);

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (a % 4 == 0)
			flag[2]++;
		else if (a % 2 == 0)
			flag[1]++;
		else
			flag[0]++;
	}
	cout << (flag[2] + 1 < flag[0] || (flag[2] < flag[0] && flag[1]) ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#define MAXN 305
using namespace std;

int N, ones, twos, threes;
double dp[MAXN][MAXN][MAXN];

int main() {
	cin >> N;
	int t;
	for (int i=0; i<N; i++) {
		cin >> t;
		if (t == 1) ones++;
		else if (t == 2) twos++;
		else threes++;
	}
	double n = N;
	dp[1][0][0] = n;
	for (int k=0; k<=N; k++) {
		for (int j=0; j<=N; j++) {
			for (int i=0; i<=N; i++) {
				if ((i == 0 || i == 1) && j == 0 && k == 0) continue;
				if (i > 0) {
					dp[i][j][k] += (i/n) * dp[i - 1][j][k];
				}
				if (j > 0)
					dp[i][j][k] += (j/n) * dp[i + 1][j - 1][k];
				if (k > 0)
					dp[i][j][k] += (k/n) * dp[i][j + 1][k - 1];
				dp[i][j][k] *= n/(i + j + k);
				dp[i][j][k] += n/(i + j + k);
			}
		}
	}
	cout << fixed << setprecision(12) << dp[ones][twos][threes] << "\n";
}

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

int main(void){
	int n,m;
	int a,b;
	while(cin>>n>>m,n||m){
		int s[101];
		for(int i=0;i<101;i++)s[i]=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			s[a]=s[a]<b?b:s[a];
		}
		cout<<accumulate(s+1,s+m+1,0LL)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3096
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
 
dp = [-1 for j in range(n)]
dp[0]=0
for i in range(n):
    for j in range(min(k,n-i-1)):
        temp = dp[i] + abs(a[i]-a[i+j+1])
        if(dp[i+j+1]==-1 or dp[i+j+1] > temp):
            dp[i+j+1] = temp
print(dp[-1])

Measured memory_bytes: 56544
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    int d = sc.nextInt();

    int ans = (n + 2 * d) / (2 * d + 1);
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 21332
fun main(args: Array<String>) {
    var list = mutableListOf<Int>()
    for (i in 0 until 5) {
        list.add(readLine()!!.toInt())
    }
    val k = readLine()!!.toInt()
    list.sorted()
    println(if (Math.abs(list[0]-list[4]) > k) ":(" else "Yay!")
}


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

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

  int tmp= 0;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(buf==tmp+1) tmp++;
  }

  if(tmp > 0){
    cout << N-tmp << endl; 
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int H, R;
    int height;
    cin >> H >> R;
    height = H+R;
    if (height == 0)
    {
        cout << "0" << endl;
    }
    else if (height > 0)
    {
        cout << "1" << endl;
    }
    else
    {
        cout << "-1" << endl;
    }
}


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	int h, n;
	cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	if (h > sum) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl
use POSIX qw(floor);

my $n = scalar(<STDIN>);

my $s = 0;
my $i = 0;
while( substr($n,$i,1) =~ /^[0-9]$/o ){
  my $j = $& - 0;
  $s += $j;
  $i++;
}

if( ($s % 9) == 0 ){
  print "Yes\n";
} else {
  print "No\n";
}



Measured memory_bytes: 6860
let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    stableSort(inputString[1].split(' '));
});

const stableSort = (arr) => {
  const arrForBubbleSort = [...arr];
  bubbleSort(arrForBubbleSort);

  const arrForSelectionSort = [...arr];
  selectionSort(arrForSelectionSort);

  console.log(arrForBubbleSort.join(' '));
  console.log('Stable'); // bubble sort is always stable
  console.log(arrForSelectionSort.join(' '));
  console.log(arrForSelectionSort.every((v, i) => v === arrForBubbleSort[i]) ? 'Stable' : 'Not stable');
};

const bubbleSort = (arr) => {
  let swapped = true;
  for (let i=0; swapped; i++) {
    swapped = false;
    for (let j=arr.length-1; j>i; j--) {
      const left = arr[j - 1];
      const right = arr[j];
      if (Number(left[1]) > Number(right[1])) {
        arr[j] = left;
        arr[j - 1] = right;
        swapped = true;
      }
    }
  }
};

const selectionSort = (arr) => {
  for (let i=0; i<arr.length; i++) {
    let minj = i;
    for (let j=i; j<arr.length; j++) {
      if (Number(arr[minj][1]) > Number(arr[j][1])) {
        minj = j;
      }
    }
    const a = arr[i];
    const b = arr[minj];
    arr[i] = b;
    arr[minj] = a;
  }
};



Measured memory_bytes: 15360
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <functional>

using namespace std;

static const int M = 20;
static const int N = 50000;
static const int INFTY = (1 << 29);

int main(){
	int n, m;
	int C[21];
	int dp[N + 1];

	cin >> n >> m;
	for (int i = 1; i <= m; ++i) cin >> C[i];
	for (int i = 0; i <= N; ++i) dp[i] = INFTY;

	dp[0] = 0;
	for (int i = 1; i <= m; ++i) {
		for (int j = 0; j + C[i] <= n; ++j) {
			dp[j + C[i]] = min(dp[j + C[i]], dp[j] + 1);
		}
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end() 
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
signed main(){
    speed;
    int n; cin >> n;
    vector<vector<pair<int, int>>> data(n);
    int sz = n;
    rep(j, 0, n) {
        int m; cin >> m;
        vector<pair<int, int>> v(m);
        rep(i, 0, m) {
            int x, y; cin >> x >> y;
            v[i] = {x, y};
        }
        data[j] = v;
    }
    n = sz;
    int ans = 0;
    for(int i = 0; i < (1 << n); i++) {
        vector<int> v(n);
        vector<int> visited(n, -1);
        bool yes = true;
        int k = i;
        int cnt = 0;
        while(k != 0) {
            v[cnt] = k % 2;
            k /= 2;
            cnt++;
        }

        for(int i1 = 0; i1 < n; i1++) {
            if(v[i1]) {
                if(visited[i1] == 0) yes = false;
                for(int j1 = 0; j1 < data[i1].size(); j1++) {
                    int loc = data[i1][j1].first - 1;
                    int condition = data[i1][j1].second;
                    if(visited[loc] == -1 && v[loc] == condition) {
                        visited[loc] = condition;
                    } else {
                        if(visited[loc] != condition || v[loc] != condition) {
                            yes = false;
                        }
                    }
                }
            }
        }
        cnt = 0;
        k = i;
        while(k != 0) {
            cnt += k % 2;
            k /= 2;
        }
        if(yes) {
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636