akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld                long long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define debug(x)        cerr << #x << " = " << x << endl;
//Bitwise 
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =          0.000001;
ll mod       =          998244353;   //(1e9+7)
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=1e5+5;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}

int main(){ 
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	rep(i,1,6){
		int temp;
		cin>>temp;
		if(temp==0){
			 cout<<i<<endl;
			 exit(0);
		}
	}
	return 0;
}

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

int main(void)
{
    int l, r;

    cin >> l >> r;
    if (l == r)
        cout << "a == b" << endl;
    else if (l > r)
        cout << "a > b" << endl;
    else
        cout << "a < b" << endl;
    return 0;
}

Measured memory_bytes: 3092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Simple {
    long N, M;
    void Solve() {
        //input
        N = io.Long;
        M = io.Long;
        //cal
        var ans=(long)(100*(N-M)+1900*M)*Math.Pow(2,M);
        //ret
        Console.WriteLine(ans);
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() { Solve(); io.writeFlush(); }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
n,m = map(int,input().split())
a_list=[list(map(str,input().split())) for _ in range(m)]

seikai_list = ['0'] * n
seikai_count = 0
penalty_count_list = [0] * n

for i in range(m):
    q_number = int(a_list[i][0]) - 1
    # 正解数について
    if seikai_list[q_number] == '0' and a_list[i][1] == 'AC':
        seikai_count += 1
        seikai_list[q_number] = '1'
    # ペナルティについて
    if seikai_list[q_number] == '0' and a_list[i][1] == 'WA':
        penalty_count_list[q_number] += 1 

penalty_count = 0
for i in range(n):
    if seikai_list[i] == '1':
        penalty_count += penalty_count_list[i]

print(seikai_count, penalty_count)

Measured memory_bytes: 33700
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    ll sum = 0;
    int j = 0;
    priority_queue<ll> small;
    priority_queue<ll, vi, greater<ll> > big;
    ll num = INT64_MAX;
    ll msum = 0, psum = 0;
    while(q--) {
        int tt;
        cin >> tt;
        if(tt == 1) {
            ll a, b;
            cin >> a >> b;
            sum += b;
            if(j == 0) {
                num = a;
                j++;
                continue;
            }
            if((1&j) == 0) {
                if(small.top() > a) {
                    num = small.top();
                    small.pop();
                    small.push(a);
                    msum += a-num;
                } else if(big.top() < a) {
                    num = big.top();
                    big.pop();
                    big.push(a);
                    psum += a-num;
                } else num = a;
            } else {
                if(num > a) swap(a, num);
                small.push(num);
                big.push(a);
                msum += num;
                psum += a;
            }
            j++;
        }
        else {
            ll que = sum+psum-msum;

            cout << (j&1 ? num:small.top()) << ' ' << que << endl;
        }
    }
}

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
using namespace std;

int main(){
	string s;
	while(cin>>s){
		int l=s.length();
		cout<<s[0];
		cout<<l-2;
		cout<<s[l-1]<<endl;
	}
	return 0;
}

	


		

	





		

	




Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if i==0: continue
    if A[i]==A[i-1]+1:
        ans += C[A[i-1]-1]


print(ans)


Measured memory_bytes: 3060
if __name__ == "__main__":
    N,M = map(int,input().split())
    H = list(map(int,input().split()))
    is_good_arr = [True for i in range(N)]
    for i in range(M):
        A,B = map(lambda i: int(i)-1,input().split())
        if H[A] > H[B]:
            is_good_arr[B] = False
        elif H[B] > H[A]:
            is_good_arr[A] = False
        else:
            is_good_arr[A],is_good_arr[B] = False,False
    print(sum(is_good_arr))

Measured memory_bytes: 20036
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
using pii = pair<int,int>;
using vi = vector<int>;
constexpr int INF = 0x7fffffff;

constexpr int beki2(int n){
    int p = 1;
    while (p < n) p <<= 1;
    return p;
}

struct SegTree
{
    vi dat;
    const int N;

    SegTree(int n): N(beki2(n)), dat(N*2+1, INF) {}

    void update(int i, int v)
    {
        dat[i+=N-1] = v;
        while (i > 0) {
            i = (i-1) / 2;
            dat[i] = min(dat[i*2+1], dat[i*2+2]);
        }
    }

    int query(int a, int b, int k, int l, int r) 
    {
        if (r <= a || b <= l) return (INF);
        if (a <= l && r <= b) return (dat[k]);
        int mid = (l+r) / 2;
        return min(
                query(a,b, k*2+1, l, mid),
                query(a,b, k*2+2, mid, r)
        );
    }

    int query(int a, int b) { return query(a,b, 0, 0, N); }
};

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

   int n, q;
   cin >> n >> q;
   SegTree seg(n);

   int com, x, y;
   while (q--) {
       cin >> com >> x >> y;
       if (com == 0) {
           seg.update(x, y);
       } else {
           outl( seg.query(x, y+1) );
       }
   }
}




Measured memory_bytes: 35816
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N, M, i, sum=0;
  scanf("%d %d", &N, &M);
  vector<int> v(M);
  vector<int> v2(M-1);
  for (i=0; i<M; i++) {
    scanf("%d", &v[i]);
  }
  sort(v.begin(), v.end());
  for (i=0; i<M-1; i++) {
    v2[i] = (v[i]-v[i+1])*-1;
  }
  sort(v2.begin(),v2.end());
  reverse(v2.begin(),v2.end());
  for (i=N-1; i<v2.size(); i++) {
    sum+=v2[i];
  }
  printf("%d\n", sum);
}

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>g;
vector<edge>edges;
vector<Pll>v;
map<string, LL>ma;
multiset<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000], d[200000];
string str[110000], ss;
bool f[110000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
int main() {
	cin >> n >> m;
	for (int i = max(-1000000LL, m - n); i < min(1000000LL, m + n-1); i++) {
		if (cnt)cout << " ";
		cout << i + 1;
		cnt++;
	}
	cout << endl;
	return 0;
}


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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

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

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited = true;

    REP(i,N){
        if(visited[i]==false)
            all_visited = false;
    }

    if(all_visited)
        return 1;
    
    int ret = 0;
    REP(i,N){
        if(graph[v][i]==false)  continue;
        if(visited[i])  continue;

        visited[i]=true;
        ret+=dfs(i,N,visited);
        visited[i]=false;
    }
    return ret;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    REP(i,M){
        cin >> a[i] >> b[i];
        graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = true;
    }

    bool visited[nmax];
    REP(i,N){
        visited[i] = false;
    }

    visited[0]=true;
    cout << dfs(0,N,visited) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define mod 1000000007
#define inf 999999999

int main(){
  int a[3];
  int k;
  cin >> a[0] >> a[1] >> a[2];
  cin >> k;
  sort(a,a+3);
  rep(i,k) a[2]*=2;
  long long ans = 0;
  rep(i,3) ans+=a[i];
  cout << ans << endl;
  return 0;
}


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


int main(){
    ll W, H, x, y;
    cin >> W >> H >> x >> y;


    cout << fixed << setprecision(11);
    cout << double(W)*double(H)/2 << " " << (2*x==W && 2*y==H);

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]),
            b = Integer.parseInt(line[1]),
            c = Integer.parseInt(line[2]);
        
        int colors = 1;
        if(b!=a) colors++;
        if(c!=a && c!=b) colors++;
        System.out.println(colors);
    }
}


Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> x(5);
    int id = -1;
    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
        if(x[i]==0){
            id = i + 1;
        }
    }
    cout << id << endl;

    return 0;
}

Measured memory_bytes: 3608
n,x=map(int,input().split())
a=list(map(int,input().split()))
asum=sum(a)

if a[0]>x:
    a[0]=x
    
for i in range(n-1):
    if a[i]+a[i+1]>x:
        a[i+1]=x-a[i]
        
asum=asum-sum(a)
print(asum)

Measured memory_bytes: 14540
import java.util.*;

public class Main {
	/*
	boolean[] furui() {
		boolean[] tab = new boolean[100000001];
		tab[0] = tab[1] = true;
		for (int i = 2; i <= tab.length/2; i++) {
			if (tab[i]) continue;
			for (int j = i + i; j < tab.length; j+=i) {
				tab[j] = true;
			}
		}
		return tab;
	}*/

	boolean isPrime(int x) {
		if (x==2) return true;
		if (x < 2 || x % 2 == 0) return false;
		for (int i = 3; i <= Math.sqrt(x); i += 2) {
			if (x % i == 0) return false;
		}
		return true;
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] ary = new int[n];
		for (int i = 0; i < n; i++) {
			ary[i] = scan.nextInt();
		}
		//boolean[] table = furui();
		int count = 0;
		for (int i = 0; i < ary.length; i++) {
			/*
			if (table[ary[i]] == false) {
				count++;
				System.out.println(ary[i]);
			}*/
			if (isPrime(ary[i])) {
				count++;
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 42788
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i=0;i<values.length;i++){
            values[i]=i+1;
        }
        for(int i=0;i<n;i++){
            String str=sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0])-1;
            int b = Integer.parseInt(ab[1])-1;
            int temp=values[a];
            values[a]=values[b];
            values[b]=temp;

        }
        for(int i=0;i<values.length;i++){
            System.out.printf("%d\n",values[i]);
        }
    }
}




    

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

// #define multitest 1
#define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int p, q, r;
	cin >> p >> q >> r;
	cout << p + q + r - max(p, max(q, r));
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------
int N;
vector<string> S;

int dfs(int v,int w,char ope='_'){
    int res = 0;
    if(ope == '_'){
        res = dfs(1,1,S[0][0]);
    }else if(ope == '*'){
        res = 1;
        while(v < N){
            if(S[v].size() <= w){
                return res;
            }
            if(S[v][w] == '.'){
                v++;
                continue;
            }
            if(S[v][w] == '*'){
                res *= dfs(v+1,w+1,'*');
            }else if(S[v][w] == '+'){
                res *= dfs(v+1,w+1,'+');
            }else{
                res *= S[v][w]-'0';
            }
            v++;
        }
    }else{
        res = 0;
        while(v < N){
            if(S[v].size() <= w){
                return res;
            }
            if(S[v][w] == '.'){
                v++;
                continue;
            }
            if(S[v][w] == '*'){
                res += dfs(v+1,w+1,'*');
            }else if(S[v][w] == '+'){
                res += dfs(v+1,w+1,'+');
            }else{
                res += S[v][w] - '0';
            }
            v++;
        }
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(cin >> N){
        if(N == 0) break;
        S.resize(N);
        for(int i=0; i<N; i++){
            cin >> S[i];
        }
        if(N == 1){
            cout << S[0] << enld;
            continue;
        }
        cout << dfs(0,0) << enld;
    }

    return 0;
}



Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include <iterator>

using namespace std;

int main(void){
  int N;

  cin >> N;
  vector<int> A(N);
  vector<int> his(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }

  sort(A.begin(),A.end(),greater<int>());

  for(int i=0;i<N;i++){
    ////cout << A[i] << endl;
    his[i]=0;

  }
  int cnt=0;
  ////cout << (int)( 1 << 8 ) << endl;
  long long target= (long long)( 1 << 30 );

  int i=0;
  int mid=0;

  while(target > 1){
    target = (target >> 1);
    //cout << "target:" << target << endl;
    if(A[i] < target) continue;
    for( ;A[i]> target && i < A.size();i++){
      //cout << "i:" << i << endl;
      if(his[i]) continue;
        auto low = distance(A.begin(),lower_bound(A.begin()+mid,A.end(),2*target-A[i],greater<long long>()));
        auto up = distance(A.begin(),upper_bound(A.begin()+mid,A.end(),2*target-A[i],greater<long long>()));
        //cout << low << "," << up << endl;
        for ( ; (his[ low ] || low == i) && low < up; low++);
        //cout << "low:" << low << endl;
        if(low == up) continue;
        cnt++;
        his[i]=1;
        his[low]=1;
      }
      mid=0;
      for ( ; A[i] == target; i++) if (!his[i]) mid++;
      cnt += mid/2;

  }

  cout << cnt << endl;
  return 0;
}


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

void solve(){
	int dp[100000+5];
	int n, k; cin>>n>>k;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	dp[0]=0;
	for (int i = 1; i < n; ++i)
	{
		dp[i] = 2'000'000'000;
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
			}
		}
	}
	cout<<dp[n-1]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
int main(){
    int n;
    cin >> n;
    int val;
    rep(i,n){
        cin >> val;
        if(val%2==0){
            if(val%3!=0 && val%5!=0){
                cout << "DENIED" <<endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,d,e,f,g;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    e=a*b;
    f=c*d;
    g=a*b;
    if(e>f){
        printf("%d\n",e);
    }
    else if(e<f){
        printf("%d\n",f);
    }
    else if(e==f){
        printf("%d\n",g);
    }
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""

import sys
from math import isinf

sys.setrecursionlimit(int(1e5))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def Tarjan(current, low, disc, scc_stack, in_scc_stack):
    global timer
    disc[current] = low[current] = timer
    timer += 1

    # visited[current] = True
    in_scc_stack[current] = True
    scc_stack.append(current)

    current_scc_set = set()
    for adj in adj_table[current]:
        if isinf(disc[adj]):
            Tarjan(adj, low, disc, scc_stack, in_scc_stack)
            low[current] = min(low[current], low[adj])

        elif in_scc_stack[adj]:
            low[current] = min(low[current], disc[adj])

    scc_candidate = -1
    if disc[current] == low[current]:
        while scc_candidate != current:
            scc_candidate = scc_stack.pop()
            current_scc_set.add(scc_candidate)
            # visited[scc_candidate] = False
            in_scc_stack[scc_candidate] = False

        init_scc_sets_list.append(current_scc_set)

    return None


def scc():
    disc = [float('inf')] * vertices
    low = [float('inf')] * vertices
    # visited = [False] * vertices
    scc_stack = list()
    in_scc_stack = [False] * vertices

    for v in range(vertices):
        if isinf(disc[v]):
            Tarjan(v, low, disc, scc_stack, in_scc_stack)

    return init_scc_sets_list


def solve():
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in scc_sets_list:
            if (ele1 in each) and (ele2 in each):
                flag = True
                break
        if flag:
            print('1')
        else:
            print('0')

    return scc_sets_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    timer = 0
    init_scc_sets_list = []
    scc_sets_list = scc()
    solve()

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
 * want to move some number of stones from first to second pile
 * s.t. remains at least one stone in first
 * and resulting xor of entire array is 0
 */

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vl a(n);
  rep(i,0,n) cin >> a[i];

  ll exc = 0;
  rep(i,2,n) exc ^= a[i];

  ll c = a[0] + a[1];
  ll cum = c-exc;
  if (cum<0 or cum%2!=0) {
    return cout << -1 << '\n', 0;
  }

  ll nd = cum/2;
  vector<pair<ll,ll>> opt, nopt;
  opt.eb(a[0], a[1]);
  rep(i,0,50) {
    ll d = (nd>>i)&1ll;
    for (auto [x, y]: opt) {
      ll x0 = (x>>i)&1ll;
      ll y0 = (y>>i)&1ll;
      bool ad=  true;
      if (d and not (x0 and y0)) ad=false;
      if (!d and (x0 and y0)) ad = false;
      if (ad) {
        nopt.eb(x,y);
      }

      if ((1ll<<i) >= x) continue;
      ll nx = x-(1ll<<i);
      ll ny = y+(1LL<<i);
      if (!d and not ((nx>>i)&1ll and (ny>>i)&1ll)) nopt.eb(nx, ny);
      if (d and ((nx>>i)&1ll and (ny>>i)&1ll)) nopt.eb(nx, ny);
    }
    swap(opt,nopt);
    nopt.clear();
    /*
    ll a0 = (a[0]>>i)&1ll;
    ll a1 = (a[1]>>i)&1ll;
    cerr << i << ' ' << d << ' ' << a0 << ' ' << a1 << '\n';
    if (d and not (a0 and a1)) return cout << -1 << '\n', 0;
    if (not d and (a0 and a1)) {
      a[1] += (1ll<<i); 
      a[0] -= (1ll<<i);
    }
    */
  }


  ll ans = -1;
  for (auto [x,y]: opt) {
    if ((x^y) == exc and x != 0 and x <= a[0] and y==a[1]+(a[0]-x)) {
      if (ans==-1 or a[0]-x<ans) ans=a[0]-x;
    }
  }

  cout << ans << '\n';

//  cerr << a[0] << ' ' << a[1] << '\n';
//  cout << orig-a[0] << '\n';
}

Measured memory_bytes: 527188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
  
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  
  if(X>Y){
    int swap = X;
    X = Y;
    Y = swap;
  }
  int count[N];
  int min_distance, distance2, distance3;
  for(int i=0;i<N;i++){
    count[i] = 0;
  }
  for(int i=1;i<=N-1;i++){
    for(int j=i+1;j<=N;j++){
      distance2 = abs(i-X)+1+abs(j-Y);
      distance3 = abs(i-Y)+1+abs(j-X);
      min_distance = min(distance2, distance3);
      min_distance = min(min_distance, j-i);
      count[min_distance]++;
    } 
  }
  for(int i=1;i<N;i++){
    cout << count[i] << endl;
  }
    
}

Measured memory_bytes: 256
#include <stdio.h>
 
void find3(int n);
  
int main(void) {
    int n;
      
    scanf("%d",&n);
    find3(n);
     
    printf("\n");
    return 0;
}
 
void find3(int n)
{
    int i;
     
    for(i=1;i<=n;i++){
        if(i % 3 == 0)
            printf(" %d",i);
        else if (i % 10 == 3)
            printf(" %d",i);
        else if (i % 100 / 10 == 3)
            printf(" %d",i);
        else if (i % 1000 / 100 == 3)
            printf(" %d",i);
        else if (i / 1000 == 3)
            printf(" %d",i);
        else{}
         
    }
}

Measured memory_bytes: 600
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;



int main() {

	string s;

	cin >> s;
	s[3] = '8';
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<int> a(N);
	rep(i,N) cin>> a[i],a[i]--;

	V<int> ans;
	while(!a.empty()){
		int N = a.size();
		int match = -1;
		rep(i,N) if(a[i] == i) match = i;
		if(match == -1){
			cout<<-1<<endl;
			return 0;
		}
		ans.pb(match);
		V<int> na;
		rep(i,N) if(i!=match) na.pb(a[i]);
		a = na;
	}
	reverse(all(ans));
	for(int v: ans) cout<<v+1<<endl;
}


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


int main(void){
	int x1, x2, y1, y2; cin >> x1 >> x2 >> y1 >> y2;

	cout << y1 + x2 - y2 << " " << y2 - x1 + y1 << " " << x1 + x2 - y2 << " " << x2 - x1 + y1 << endl;

	return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr1[25];
ll arr2[25];
ll arr3[25];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr1[i]);
	}
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr2[i]);
	}
	for(int j = 0; j < N - 1; j++) {
		scanf("%lld", &arr3[j]);
	}
	ll sum = 0;
	for(int i = 0; i < N; i++) {
		if(i == 0) {
			sum += arr2[arr1[0] - 1];
			// cout << arr2[arr1[0] - 1] << "this\n";
		}
		else if(arr1[i] - arr1[i - 1] == 1){
			sum += arr2[arr1[i] - 1];
			sum += arr3[arr1[i - 1] - 1];
			// cout << arr2[arr1[i] - 1] << " " << arr3[arr1[i - 1] - 1] << "that\n";
		}
		else {
			sum += arr2[arr1[i] - 1];
			// cout << arr2[arr1[i] - 1] << " now\n";
		}
	}
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

typedef long long int llint;

int main()
{
  int a, b;
  cin>> a >> b;

  if(a < 9 && b < 9) cout<< "Yay!" <<endl;
  else               cout<< ":(" <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
#include<map>
#define ll long long
using namespace std;
int main(){
	char c;
  cin>>c;
  char d=char(((int) c)+1);
  cout<<d<<endl;
}

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

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  using namespace chrono_literals;
  chrono::high_resolution_clock clock;
  auto be = clock.now();
  int D;
  cin >> D;
  array<int, 26> c;
  for (auto& e : c) cin >> e;
  vector<array<int, 26>> d(D);
  for (auto& r : d)
    for (auto& e : r) cin >> e;
  auto eval = [&](vector<int> t) {
    int S = 0;
    array<int, 26> last = {};
    for (int i = 0; i < D; ++i) {
      S += d[i][t[i]];
      last[t[i]] = i + 1;
      for (int j = 0; j < 26; ++j) S -= c[j] * (i + 1 - last[j]);
    }
    return S;
  };

  mt19937 mt(random_device{}());
  uniform_int_distribution<int> dist_type(0, 25), dist_day(0, D - 1);
  vector<int> t(D);
  generate(begin(t), end(t), [&]() { return dist_type(mt); });
  int S = eval(t);
  while (clock.now() - be < 1900ms) {
    int day = dist_day(mt);
    int prv = t[day];
    t[day] = dist_type(mt);
    if (eval(t) > S) continue;
    t[day] = prv;
  }
  for (const auto& e : t) cout << (e + 1) << '\n';
}


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

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int A() {
	int s, w;
	scani(s);
	scani(w);

	if (s <= w) {
		printf("unsafe");
	}
	else {
		printf("safe");
	}

	return 0;
}

int Main() {
	int a, b, c, d;
	scani(a);
	scani(b);
	scani(c);
	scani(d);
	bool flg = false;
	while (0 < a && 0 < c) {
		if (flg) {
			a -= d;
		}
		else {
			c -= b;
		}
		flg = !flg;
	}
	YesNo(0 < a);
	return 0;
}

int main()
{
	Main();
	return 0;
}


Measured memory_bytes: 3828
import java.util.*;
public class Main{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if(s.charAt(s.length()-1)=='s')
    System.out.println(s+"es");
    else
      System.out.println(s+"s");
  }
}

Measured memory_bytes: 26960
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N=int(input())
  l=LI()

  l.sort()
  l.append(inf)

  c=0
  a=l[0]
  cnt=1
  for x in l[1:]:
    if a==x:
      cnt+=1
    else:
      if a<cnt:
        c+=cnt-a
      elif a==cnt:
        pass
      else:
        c+=cnt
      a=x
      cnt=1

  print(c)

main()
# print(main())


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

int main(){
	int A, B;
	cin >> A >> B;
	int ans = max(A - 2*B, 0);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
    /*
    int n;
    cin >> n;
    int h[n] , ans[n];
    for (int i=0; i<n; i++)
        cin >> h[i];
    ans[0]=0 , ans[1]=abs(h[1]-h[0]);
    for (int i=2; i<n; i++)
    {
        ans[i] = min(abs(h[i]-h[i-1])+ans[i-1] , abs(h[i]-h[i-2])+h[i-2]);
    }
    cout << ans[n-1] << "\n";
    */

    /*
    int n,k;
    cin >> n >> k;
    int h[n] , ans[n];
    for (int i=0; i<n; i++)
        cin >> h[i];
    ans[0]=0 , ans[1]=abs(h[1]-h[0]);
    for (int i=2; i<n; i++)
    {
        ans[i]=1e9;
        for (int j=i-1; j>=max(0,i-k); j--)
            ans[i] = min(ans[i] , abs(h[i]-h[j])+ans[j]);
    }
    cout << ans[n-1] << "\n";
    */

    /*
    int n,m,tmp,mod=1e9+7;
    cin >> n >> m;
    char arr[n][m]={};
    int ans[n][m]={};
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
            cin >> arr[i][j];
    }

    ans[0][0]=1;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            if(!i&&!j) continue;
            if (arr[i][j]=='#') {ans[i][j]=0; continue;}
            if (i) ans[i][j] = (ans[i][j]+ans[i-1][j])%mod;
            if (j) ans[i][j] = (ans[i][j]+ans[i][j-1])%mod;
        }
    }
    cout << ans[n-1][m-1] << "\n";
    */

    int n,tmp;
    cin >> n;
    int arr[n][3] , ans[n][3]={};
    for (int i=0; i<n; i++)
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];

    ans[0][0]=arr[0][0] , ans[0][1]=arr[0][1] , ans[0][2]=arr[0][2];

    for (int i=1; i<n; i++)
    {
        for (int j=0; j<3; j++)
        {
            for (int k=0; k<3; k++)
            {
                if (j==k) continue;
                ans[i][j] = max(ans[i][j] , ans[i-1][k]+arr[i][j]);
            }
        }
    }
    cout << max(ans[n-1][0] , max(ans[n-1][1] , ans[n-1][2]));



    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;



int main(){
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    vector<vector<ll>> c(10, vector<ll>(10));
    for(ll i=0;i<10;i++){
     for(ll j=0;j<10;j++){
         cin>>c[i][j]
     ;}
    ;}
    for(ll i=0;i<10;i++){
     for(ll j=0;j<10;j++){
         for(ll k=0;k<10;k++){
             c[j][k]=min(c[j][k],c[j][i]+c[i][k])
         ;}
     ;}
    ;}
    ll ans=0;
    vector<vector<ll>> A(H, vector<ll>(W));
    for(ll i=0;i<H;i++){
     for(ll j=0;j<W;j++){
         cin>>A[i][j];
         if(A[i][j]==-1){continue;}
         else{ans+=c[A[i][j]][1];}
     ;}
    ;}
    cout<<ans<<endl;

    return 0;
}


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

vector<int> A;
int N;
bool exist = true;
#define MOD 1000000007
long long cn = 1;

int main(){
  cin >> N;

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

  /*Nが奇数なら、Aはすべて偶数であり、偶数であるならば、Aはすべて奇数となる*/
  /*また同じ数は必ず2個あり、1個または3個以上存在する時点でアウト*/
  /*というのも情報が左右の存在数の差であり、方向属性がなく、対称性を持つから*/

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

  int i = 0;
  if(N % 2 == 1 && A[0] == 0){ //奇数個なら最小は0のはず
    i++;
    if(N == 1) ; //1個なら明らか
    else if(A[1] == 0) exist = false; //0が二つ存在するのはあり得ない
  }
    

  while(i < N && exist){
    if(A[i] == A[i+1] && i % 2 != A[i]) i += 2;
    else exist = false;
  }

  if(!exist) cout << 0 << endl;
  else { 
    int n = N / 2;
    for(int i = 0; i < n; i++)
      cn = (cn * 2) % MOD;
    cout << cn << endl;
  }

  return 0;
      
}

  

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

int main(void)
{
	char s[250];
	int l;
	int i;
	int count = 0;

	scanf("%s", s);
	while (1) {
		count = 0;
		l = strlen(s);
		s[l - 1] = '\0';
		if (1 == (l % 2))
		{
			for (i = 0; i < ((l - 1) / 2); i++)
			{
				if (s[i] == s[i + ((l - 1) / 2)])
					count++;
			}

		}
		if (count == ((l - 1) / 2))
			break;
	}

	printf("%d", l - 1);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main
{

    //------------stack-------------
    static class Stack
    {
	int[] stack = new int[100];
	int head=0;
	
	void push(int n)
	{
	    stack[head]=n;
	    head++;
	}
	
	int pop()
	{
	    head--;
	    int i=stack[head];
	    return i;
	}
    }
    
    //-----------Main---------------
    public static void main(String args[])
    {
	Scanner sc = new Scanner(System.in);
	Main.Stack stack = new Main.Stack();
	String s;
	int x, y;
	int i, j, k;

	i=0;
	while(sc.hasNext())
	    {
		//Read number
		if(sc.hasNextInt()==true)
		    {
			stack.push(sc.nextInt());
		    }
		//Read operand
		else
		    {
			s=sc.next();
			//+
			if(s.equals("+")==true)
			    {
				x=stack.pop();
				y=stack.pop();
				stack.push(y+x);
			    }
		
			//-
			else if(s.equals("-")==true)
			    {
				x=stack.pop();
				y=stack.pop();
				stack.push(y-x);
			    }
			//*
			else if(s.equals("*")==true)
			    {				
				x=stack.pop();
				y=stack.pop();
				stack.push(y*x);
			    }
			//else if(s.equals(null)==true)break;
		    }
	    }
    
    
	//print
	System.out.println(stack.stack[0]);
	sc.close();
    
    }

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define mp make_pair
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
    char c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

const int MAX_N = 1e5 + 5;
const int INF = 0x3f3f3f3f;

int G[500][500];

int main()
{
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int n;
    Read(n);
    set<int> s;
    for(int i=1; i<500; i++) s.insert(i*(i-1)/2);
    if(n == 1) {
        puts("Yes");
        printf("2\n");
        printf("1 1\n");
        printf("1 1\n");
    } else if(s.find(n) != s.end()) {
        puts("Yes");
        int k = int(sqrt(n*2)) + 1;
        printf("%d\n", k);
        int cnt = 0;
        for(int i=1; i<=k; i++) {
            for(int j=1; j<=k; j++) {
                if(i!=j && !G[i][j] && !G[j][i]) {
                    G[i][j] = G[j][i] = ++cnt;
                }
            }
        }
        for(int i=1; i<=k; i++) {
            printf("%d", k-1);
            for(int j=1; j<=k; j++) {
                if(i != j) printf(" %d", G[i][j]);
            }
            puts("");
        }
    } else puts("No");

    return 0;
}


Measured memory_bytes: 2304
N = int(input())
a = list(map(int,input().split()))
a_sum = [0]
tmp = 0
for i in range(1,N+1):
  tmp = a_sum[i-1] + a[i-1]
  a_sum.append(tmp)
ans = 10**30
x,y = 0,0
for i in range(1,N):
  x = a_sum[i]
  y = a_sum[N] - x
  ans = min(ans,abs(x-y))
print(ans)

Measured memory_bytes: 30540
a,b,c = map(int,input().split())
k = int(input())
i = 0
while b <= a:
    b *= 2
    i += 1
    if i > k:
        break
while c <= b:
    c *= 2
    i += 1
    if i > k:
        break
if i <= k:
    print('Yes')
else:
    print('No')


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<202020> uf;

int A[201010],B[201010];
int num[101010],odd[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>A[i]>>B[i], A[i]--, B[i]--;
		uf(A[i]*2,B[i]*2+1);
		uf(A[i]*2+1,B[i]*2);
	}
	FOR(i,N) {
		num[uf[i*2]/2]++;
		if(uf[i*2]==uf[i*2+1]) odd[uf[i*2]/2]++;
	}
	
	ll hoge[3]={};
	FOR(i,N) {
		if(num[i]==1) hoge[0]++;
		if(num[i]>=2 && odd[i]) hoge[1]++;
		if(num[i]>=2 && odd[i]==0) hoge[2]++;
	}
	
	ll ret=hoge[0]*hoge[0]+2*hoge[0]*(N-hoge[0]);
	ret += 2*hoge[2]*hoge[2];
	ret += hoge[1]*hoge[1];
	ret += 2*hoge[1]*hoge[2];
	cout<<ret<<endl;
	
	
	
	/*
	
	FOR(x,M) FOR(y,M) {
		uf(A[x]*N+A[y],B[x]*N+B[y]);
		uf(A[x]*N+B[y],B[x]*N+A[y]);
		uf(B[x]*N+A[y],A[x]*N+B[y]);
		uf(B[x]*N+B[y],A[x]*N+A[y]);
	}
	set<int> S;
	FOR(i,N*N) {
		_P("%d:",i);
		FOR(x,N*N) if(uf[x]==i) _P("(%d,%d)",x/N+1,x%N+1);
		_P("\n");
	}
	*/
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int h,n;
    cin >> h >> n;
    int sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256