akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
void fastios() { ios_base::sync_with_stdio(0); cin.tie(0); }

static const int N = 10005;

struct vertex {
	int id;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

struct edge {
	int end;
	int w;
};

int main() {
	fastios();
	int n;
	cin >> n;
	vector<vector<edge>> E(N);
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(i, k) {
			int v, c;
			cin >> v >> c;
			E[u].push_back({ v,c });
		}
	}

	priority_queue<vertex> pq;
	vi color(N, 0), dist(N, 0);
	pq.push({ 0,0 });
	int cnt = 0;
	while (pq.size() > 0) {
		if (cnt == n) break;
		vertex v = pq.top();
		pq.pop();
		if (color[v.id] == 1) continue;
		dist[v.id] = v.d;
		color[v.id] = 1;
		cnt++;
		Loop(j, E[v.id].size()) {
			if (color[E[v.id][j].end] != 1) {
				pq.push({ E[v.id][j].end, dist[v.id] + E[v.id][j].w });
			}
		}
	}
	Loop(i, n) {
		cout << i << " " << dist[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 9880
import math

def is_sankaku(v):
    x = (math.sqrt(8*v + 1) - 1 ) / 2
    return x == int(x)

def check(lst):
    for i,v in enumerate(lst):
        if v != i + 1:
            return False
        elif i == len(lst)-1:
            return True

while 1:
    N = int(input())
    if N == 0:break
    lst = list(map(int,input().split()))
    if not is_sankaku(sum(lst)):
        print(-1)
        continue

    result = -1
    for count in range(10000):
        if check(lst):
            result = count 
            break
        spam = len(lst)
        lst = [x-1 for x in lst if x-1 > 0]
        lst.append(spam)
        
    print(result)

Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N >> A;
  if (A >= 499) {
    cout << "Yes" << endl;
  }
  else if (A >= N) {
    cout << "Yes" << endl;
  }
  else if (N>=500 && N%500<=A) {
    cout << "Yes" << endl;
  }
  else if (N>=500 && N%500>=A) {
    cout << "No" << endl;
  }
}

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

#define ll long long



using namespace std;
using Graph = vector<vector<int>>;
Graph G;
vector<int> count;

void dfs(int par, int now, int val){
    count[now] += val;
    for(auto child : G[now]){
        if(child == par) continue;
        dfs(now, child, count[now]);
    }

}

int main(){

    int N,Q;
    cin >> N >> Q;

    G.resize(N);
    count.resize(N);

    int a,b,p,x;

    for(int i=0;i<N-1;i++){
        cin >> p >> x;
        p--; x--;
        G[p].push_back(x);
        G[x].push_back(p);
    }
    for(int i=0;i<Q;i++){
        cin >> a >> b;
        a--;
        count[a] += b;
    }

    dfs(-1,0,0);
    for(int i=0;i<N;i++){
        cout << count[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 23552
import numpy as np
from numba import njit

@njit('(i4[::1],)', cache=True)
def f(A):
  N = len(A)
  cnt = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        cnt += (A[k] < A[i] + A[j])
  return cnt

N = int(input())
A = np.int32(input().split())
A.sort()
print(f(A))


Measured memory_bytes: 106492
import sys
N,M=map(int,input().split())
A=list(map(int,input().split()))
n=[0,2,5,5,4,5,6,3,7,6]
num=[0]*8
for a in A:
    num[n[a]]=max(num[n[a]],a)
nums=[]
for i in range(8):
    if num[i]: nums.append((i,num[i]))
#print(nums)
dp=[0]*(N+1)
for x,y in nums:
    try: dp[x]=1
    except IndexError: break
if nums[0][0]==N:
    print(nums[0][1])
    sys.exit()
for i in range(nums[0][0]+1,N+1):
    t=dp[i]
    for x,y in nums:
        if i-x>0:
            if dp[i-x]:
                t=max(t,dp[i-x]+1)
    if t:dp[i]=t
#print(dp)
nums.sort(key=lambda x:-x[1])
match=N
digit=dp[N]
for _ in range(dp[N]):
    if digit==1:
        for x,y in nums:
            if x==match:
                print(y)
                break
        break
    for x,y in nums:
        if dp[match-x]==digit-1:
            print(y,end='')
            match-=x
            digit-=1
            break
    

Measured memory_bytes: 4260
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i, n):
        if l[i] != l[j]:
            for k in range(j, n):
                if l[i] != l[k]:
                    if l[j] != l[k]:
                        if max(l[i], l[j], l[k]) < (l[i] + l[j] + l[k])/2:
                            ans += 1
print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; int M; cin >> N >> M;
  // M = G * (a_1 / G + ... a_N / G)
  // M = G * (1 + 1 + ... + 1 + c_N)
  bool is_prime = 1;
  for (int i = 2; (ll)i * i <= M; i++) {
    if (M % i == 0) {
      is_prime = 0;
      break;
    }
  }

  if (N == 1 && is_prime) {
    cout << M << "\n";
    return 0;
  }
  else if (is_prime) {
    cout << 1 << "\n";
    return 0;
  }

  for (int c_N = 1; ; c_N++) {
    if (M % (N - 1 + c_N) == 0) {
      auto G = M / (N - 1 + c_N);
      cout << G << "\n";
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	string str;
	cin>>str;
	ll i,n = str.length(), su = 0;
	for(i=0;i<n;i++)
	{
		su = (su + (str[i]-'0'))%9;
	}
	if(su%9==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

#define MOD 1000000007
int N;

bool is_prime(int x) {
  for (int i=2; i<=sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int factors(int x, int p) {
  int c = 0;
  while (x % p == 0) {
    x /= p;
    c++;
  }
  return c;
}

int main() {
  cin >> N;
  long long m = 1;
  for (int p=2; p<=1000; p++) {
    if (!is_prime(p)) continue;
    int c = 0;
    for (int t=1; t<=N; t++) {
      c += factors(t, p);
    }
    m = (m*(c+1)) % MOD;
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 105;
int main(){
	int a[N];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int key,j;
	for(int i=0;i<n;i++){
		key = a[i];
		j = i-1;
		while(j>=0&&a[j]>key){
			a[j+1]=a[j];
			j--;
		}
		a[j+1] = key;
		for(int i=0;i<n;i++){
			if(i<n-1)
				cout<<a[i]<<" ";
			else
				cout<<a[i]<<endl;
		}
	}
	return 0;
} 


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

int main() {
    int A, B, P;
    cin >> A >> B;

    bool flg = false;

    for (int i = 1; i <= 10000; i++) {
        if (i * 0.08 >= A && i * 0.08 < A + 1) {
            if (i * 0.1 >= B && i * 0.1 < B + 1) {
                flg = true;
                P = i;
                break;
            }
        }
    }

    if (flg == false) {
        cout << -1 << endl;
    } else {
        cout << P << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005,mod=1e9+7;
#define inf 0x7fffffff
vector<int>G[N];
int vis[N][3];
int dis[N][3];
int S,T;
struct node
{
    int id,dis;
};
queue<node>q;
void dijstra()
{

    for(int i=1;i<=N-5;i++)
        for(int j=0;j<3;j++)
            dis[i][j]=inf,vis[i][j]=0;
    q.push({S,0});
    dis[S][0]=0;
    while(!q.empty())
    {
        int u=q.front().id;
        int d=q.front().dis;
        q.pop();
        if(vis[u][d])continue;
        vis[u][d]=1;
        for(auto v:G[u])
        {
            int len=(d+1)%3;
            if(dis[v][len]>dis[u][d]+1)
            {
                dis[v][len]=dis[u][d]+1;
                q.push({v,len});
            }

        }
    }
}
int main()
{
    int n,m,u,v;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
    }
    scanf("%d%d",&S,&T);
    dijstra();
    if(dis[T][0]==inf)
        puts("-1");
    else
        printf("%d\n",dis[T][0]/3);
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>

using namespace std;


int main()
{
  string s ="ABC";
  int n;
  cin >> n ;
  string t;
  cin >> t;
  int ans = 0;
  for(int i = 0;i < t.size() - 2;i++)
  {
	string k = t.substr(i,3);
    if(k == s)ans++;
    k.clear();
  }
  cout << ans ;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N; cin >> N;
    int Nsave = N;
    int S = N % 10;
    N /= 10;
    while (N != 0) {
        S += N % 10;
        N /= 10;
    }
    if (Nsave % S == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;


double dot_product(xy_t a, xy_t b){
        return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b){
        return (conj(a)*b).imag();
}
int main(){
        xy_t o,a,b;
        double sum = 0,x,y;
        scanf("%lf,%lf", &x, &y);
        o = xy_t (x, y);
        scanf("%lf,%lf", &x, &y);
        a = xy_t (x, y) - o;
        b = a;
        while(~scanf("%lf,%lf", &x, &y)){
                a = xy_t (x, y) - o;
                sum += cross_product(a,b) / 2.0;
                b = a;
        }
        printf("%.6f\n", abs(sum));
return 0;
}

Measured memory_bytes: 1244
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr),out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr),out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int n,k;

bool proc(vector<int>& a,int t){
    vector<int> c(k,0);
    int cnt = 0;
    REP(i,n){
        if(a[i]<=k){
            int temp = a[i]-1;
            if(c[temp]==0){
                cnt++;
            }
            c[temp]++;
        }
        if(i-t>=0){
            int temp = a[i-t]-1;
            if(temp<k){
                if(c[temp]==1){
                    cnt--;
                }
                c[temp] = max(c[temp]-1,0);
            }
            
        }
        if(cnt==k){
            return true;
        }
        
        
    }
    return false;
}

int main(){
    cin >> n >> k;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    int lb = -1,ub = n+1;
    while(ub-lb>1){
        int mid = (lb+ub)/2;
        if(proc(a,mid)){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    if(ub>n){
        put(0);
    }else{
        put(ub);
    }
    return 0;
}



Measured memory_bytes: 3612
a=int(input())

u = int(a /100)
l = a%100

if (1 <= u <=12 and 1 <= l <= 12):
    print("AMBIGUOUS")
elif (a == 0 or (u == 0 and l > 12) or (l == 0 and u > 12) or (l > 12 and u > 12)):
    print("NA")
elif (1 <= u <= 12):
    print("MMYY")
else:
    print("YYMM")

Measured memory_bytes: 3060
X,Y=map(int,input().split())
ans=0
if X==1:
    ans+=300000
elif X==2:
    ans+=200000
elif X==3:
    ans+=100000
if Y==1:
    ans+=300000
elif Y==2:
    ans+=200000
elif Y==3:
    ans+=100000
if X==1 and Y==1:
    ans+=400000
print(ans)

Measured memory_bytes: 3316
from collections import deque
S=deque(input())
Q=int(input())
ans=0
for i in range(Q):
    q=input()
    if q[0]=='2':
        if ans%2==0:
            if q[2]=='1':
                S.appendleft(q[4])
            else:
                S.append(q[4])
        else:
            if q[2]=='1':
                S.append(q[4])
            else:
                S.appendleft(q[4])
    else:
        ans+=1
S="".join(S)
print(S if ans%2==0 else S[::-1])

Measured memory_bytes: 13960
#include <cstdio>
#include <algorithm>

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  int res = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    scanf("%d", &x);
    res += std::min(K-x, x);
  }
  res *= 2;
  printf("%d\n", res);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq


def solve(N: int, M: int, A: "List[int]"):
    heapq.heapify(A)
    while M > 0:
        d = heapq.heappop(A)
        d = -(-d//2)
        heapq.heappush(A, d)
        M -= 1
    print(-sum(A))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [-int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    else if(b==0) return 1;
    else if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    else return (rui(a,b-1)*a)%mod;
}

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

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

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){

    int N,K;cin>>N>>K;
    make();
    cout<<comb(K,N)<<endl;
}




Measured memory_bytes: 5436
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  string S;
  cin>>S;
  if(S=="zyxwvutsrqponmlkjihgfedcba"){
    cout<<-1<<endl;
  }else{
    int L=S.size();
    if(L!=26){
      char C='a';
      bool used[26];
      fill(used,used+26,0);
      FOR(i,0,L){
        used[S[i]-C]=true;
      }
      int j=0;
      while(used[j]==true){
        j++;
      }
      char a=C+j;
      cout<<S<<a<<endl;
    }else{
      int j=L-1;
      while(S[j-1]>S[j]){
        j--;
      }
      char mi=S[j-1];
      char ma=S[j];
      FOR(k,j+1,L){
        if(mi<S[k]&&S[k]<ma){
          ma=S[k];
        }
      }
      FOR(i,0,j-1){
        cout<<S[i];
      }
      cout<<ma<<endl;
    }
  }
  return 0;
}


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

int main(){
  int a[4];

  for(int i=0;i<4;++i)
    cin >> a[i];

  cout << (a[0] + a[1] + a[2] + a[3])/60 << endl << (a[0] + a[1] + a[2] + a[3])%60 << endl;
  
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int a, b;
    cin >> a >> b;
    if (b%a == 0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 3600
import math

a, b, h, m = [int(x) for x in input().split()]

h %= 12
m %= 60

theta_hour = 360 * (h/12)
theta_min = 360 * (m/60)
theta_hour += (m/2)

# print(theta_hour, theta_min)

x1 = a * math.cos((theta_hour * math.pi) / 180)
x2 = b * math.cos((theta_min * math.pi) / 180)
# print(x1, x2)
y1 = a * math.sin((theta_hour * math.pi) / 180)
y2 = b * math.sin((theta_min * math.pi) / 180)
# print(y1, y2)

print(math.sqrt((x2 - x1)**2 + (y2 - y1)**2))

Measured memory_bytes: 62472
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int N;
    cin>>N;
    vector<int> B(N);
    REP(i,N) cin>>B[i];
    int ans = B[0]+B[N-2];
    REP(i,N-2) ans += min(B[i],B[i+1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

class Node {
    Integer id;
    Node parent;
    Node left;
    Node right;
}

class Main {
    static Map<Integer, Node> nodes = new HashMap<>();
    static Node root;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            Integer id = sc.nextInt();
            Integer leftId = sc.nextInt();
            Integer rightId = sc.nextInt();
            Node node = createNode(id);
            node.left = createChildrenNode(node, leftId);
            node.right = createChildrenNode(node, rightId);
        }
        Node root = findRoot();
        System.out.println("Preorder");
        System.out.println(preParse(root));
        System.out.println("Inorder");
        System.out.println(inParse(root));
        System.out.println("Postorder");
        System.out.println(postParse(root));
    }

    public static String preParse(Node node) {
        if (node == null) {
            return "";
        }
        return " " + node.id + preParse(node.left) + preParse(node.right);
    }

    public static String inParse(Node node) {
        if (node == null) {
            return "";
        }
        return inParse(node.left) + " " + node.id + inParse(node.right);
    }

    public static String postParse(Node node) {
        if (node == null) {
            return "";
        }
        return postParse(node.left) + postParse(node.right) + " " + node.id;
    }

    public static Node createChildrenNode(Node node, Integer childrenId) {
        if (childrenId == -1) {
            return null;
        }
        Node childrenNode = createNode(childrenId);
        childrenNode.parent = node;
        return childrenNode;
    }

    public static Node createNode(Integer id) {
        Node node = nodes.get(id);
        if (node == null) {
            node = new Node();
            node.id = id;
            node.parent = null;
            nodes.put(id, node);
        }

        return node;
    }

    public static Node findRoot() {
      return nodes.values().stream().filter(node -> node.parent == null).collect(Collectors.toList()).get(0);
    }
}



Measured memory_bytes: 32112
#include<stdio.h>
#include <string.h>
int main()
{
    int n,b=0,l;
    char s[101][101],k[1000];
    int i,j;
    char t[101];
    scanf("%d%d",&n,&l);
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            strcpy(t,s[i]);
            if(strcmp(s[i],s[j])<b){
                strcpy(s[i],s[j]);
                strcpy(s[j],t);
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%s",s[i]);
    }
    return 0;
}

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

int main(void) {
    long n, k;
    cin >> n >> k;

    map<long, long> m;
    for(long i=0; i<n; i++) {
        long a, b;
        cin >> a >> b;
        m[a] += b;
    }

    long r = 0;
    for(long i=0; i<=30; i++) {
        long mk = (k>>i<<i)-1;
        if(mk < 0) continue;
        long rr = 0;
        for(auto &t: m) {
            long a, b;
            tie(a, b) = t;
            if((a|mk) == mk)
                rr += b;
        }
        r = max(r, rr);
    }
    {
        long mk = k;
        long rr = 0;
        for(auto &t: m) {
            long a, b;
            tie(a, b) = t;
            if((a|mk) == mk)
                rr += b;
        }
        r = max(r, rr);
    }
    cout << r << endl;
}


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

 int main() {
     int A;
     cin>>A;

     int r=A%10;
//hon, 2,4,5,7,9
//pon, 0,1,6,8,
//bon, 3
     if(r==2 || r==4 || r==5 || r==7 || r==9){cout<<"hon";}
     if(r==0 || r==1 || r==6 || r==8){cout<<"pon";}
     if(r==3){cout<<"bon";}

 }

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>

int partition(int,int[],int,int);
void printArray(int,int[]);

int main(int argc, char** argv) {
    int size;
    scanf("%d\n", &size);
    int array[size];
    for(int i = 0; i < size; i++)
        scanf("%d", &array[i]);
    
    int loc = partition(size,array,0,size-1);
    for(int i = 0; i < size; i++){
        if(i == size-1)
            printf("%d\n", array[i]);
        else if(i == loc)
            printf("[%d] ", array[i]);
        else
            printf("%d ", array[i]);
    }
    return (EXIT_SUCCESS);
}

int partition(int size, int array[size], int start, int end){
    int compare = array[end];
    int temp;
    int i = start - 1;
    for(int j = start; j < end; j++){
        if(array[j] <= compare){
            i += 1;
            temp = array[i];
            array[i] = array[j];
            array[j] = temp;
        }
    }
    temp = array[i+1];
    array[i+1] = array[end];
    array[end] = temp;
    return i+1;
}

void printArray(int size, int a[size]){
    for(int i = 0; i < size; i++){
        if(i != size - 1)
            printf("%d ", a[i]);
        else printf("%d\n", a[i]);
    }
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define INFTY (1<<30)

int n,m;
vector<int> T(50001,INFTY);
vector<int> C(20);

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

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>C[i];
    }

    cout<<getTheNumberOfCoin()<<endl;
}


Measured memory_bytes: 3092
using System;
using System.Linq;

namespace _1124
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                int[] days = new int[200];
                for (int i = 0; i < x[0]; i++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    for (int j = 1; j <= a[0]; j++)
                    {
                        days[a[j]]++;
                    }
                }
                int ret = 0; int max = x[1];
                for (int i = 0; i < 200; i++)
                {
                    if (days[i] > max)
                    {
                        ret = i; max = days[i];
                    }
                    else if (ret == 0 && days[i] >= max)
                    {
                        ret = i; max = days[i];
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}


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

int n, d[100004];

int main() {
	cin>>n;
	for(int i = 0;i<n;i++)	cin>>d[i];
	sort(d, d+n);
	cout<<d[n/2] - d[n/2-1];
	return 0;
}

Measured memory_bytes: 640
N = int(input())
max = 0
max_i = N + 1
max_sc = 0
for i in range(N):  
    tmp = int(input())
    if tmp > max:
        max_sc = max
        max = tmp
        max_i = i
    elif tmp > max_sc:
        max_sc = tmp
for i in range(N):
    if i == max_i:
        print(max_sc)
    else:
        print(max)

Measured memory_bytes: 4540
import heapq 
import math

N = int(input())
transport = list(int(input()) for _ in range(5))
#heapq.heapify(transport)

#min_trans  = heapq.heappop(transport)
min_trans  = min(transport)
#print(transport)
#print(min_trans)

print(math.ceil(N / min_trans + 4))



Measured memory_bytes: 3060
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");
	var anagrams = new Array(tmp);
	var count = {};
	var alphabet = new Array(10);
	var answer = 0;
	for(var i=0;i<tmp;i++){
      alphabet = input[i+1].split("");
      alphabet.sort();
      anagrams[i] = alphabet.join("");
      if( anagrams[i] in count){
        answer += count[anagrams[i]];
        count[anagrams[i]]++;
      }else{
        count[anagrams[i]] = 1;
      }
    }
	console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using ll = long long;

ll a[100010];
ll one[64],zero[64];

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

    ll n,k;cin>>n>>k;

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

    ll cnt=0;
    for(ll i=k;i!=0;cnt++)i/=2;

    for(int i=0;i<n;i++)
    {
        ll ba=a[i];

        for(int j=0;j<cnt;j++)
        {
            if(ba%2)one[j]++;
            else zero[j]++;

            ba/=2;
        }
    }

    ll x=0;

    for(ll i=cnt-1,j=pow(2,i);i>=0;i--,j/=2)
    {
        if(zero[i]>one[i])
        {
            if(k>=x+j)x+=j;
        }
    }

    ll ans=0;

    for(int i=0;i<n;i++)ans+=(a[i]^x);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 4760
#include<iostream>
using namespace std;
int main(){
int a,b;
char o;
cin>>a>>o>>b;
while(o!='?'){
if(o=='+')cout<<a+b<<endl;
if(o=='-')cout<<a-b<<endl;
if(o=='/')cout<<a/b<<endl;
if(o=='*')cout<<a*b<<endl;
cin>>a>>o>>b;
}
return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

class UnionFind {
    vector<LL> parent;
    vector<LL> member;

    int root(LL x) {
        if(x == parent[x]) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

public:
    UnionFind(LL N) {
        parent.resize(N);
        REP(i, N) {
            parent[i] = i;
        }
        member.resize(N);
        fill(ALL(member), 1);
    }

    bool same(LL x, LL y) {
        return root(x) == root(y);
    }

    LL size(LL x) {
        return member[root(x)];
    }

    void unite(LL x, LL y) {
        if(root(x) == root(y)) {
            return;
        }
        member[root(y)] += member[root(x)];
        parent[root(x)] = root(y);
    }

    void print() {
        for(auto i : parent) {
            cout << i << " ";
        }
        cout << endl;
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<pair<int, int>> frie(M);
    vector<pair<int, int>> block(K);
    UnionFind uf(N + 1);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        frie[i] = make_pair(a, b);
        uf.unite(a, b);
    }
    REP(i, K) {
        int c, d;
        cin >> c >> d;
        block[i] = make_pair(c, d);
    }
    vector<int> neighbor_and_blocked(N + 1, 0);
    vector<int> friends(N + 1, 0);
    for(auto b : block) {
        if(uf.same(b.first, b.second)) {
            neighbor_and_blocked[b.first]++;
            neighbor_and_blocked[b.second]++;
        }
    }
    for(auto f : frie) {
        friends[f.first]++;
        friends[f.second]++;
    }
    FOR(i, 1, N + 1) {
        cout << uf.size(i) - neighbor_and_blocked[i] - friends[i] - 1 << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 5120
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
#define maxn 200010
int n,m;
map<int,int> mp;
main()
{
    scanf("%d",&n);
    int x;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(mp.find(x)==mp.end())mp[x]=1;
        else mp[x]++;
    }
    scanf("%d",&m);
    bool flag=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&x);
        if(!flag)continue;
        if(mp[x]>0)mp[x]--;
        else flag=0;
    }
    puts(flag ? "YES" : "NO");
    return 0;
}


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

int a[88][88];
bitset<25600> b[80][80];
int main() {
    int o = 12800;
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> a[i][j];
    int x;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> x, a[i][j] = abs(a[i][j] - x);
    b[0][0][o] = 1;
    b[0][0] = b[0][0] << a[0][0] | b[0][0] >> a[0][0];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i)
                b[i][j] |= b[i - 1][j] << a[i][j] | b[i - 1][j] >> a[i][j];
            if(j)
                b[i][j] |= b[i][j - 1] << a[i][j] | b[i][j - 1] >> a[i][j];
        }
    }
    int r = o;
    for(int i = 0; i < o + o; i++)
        if(b[h - 1][w - 1][i])
            r = min(r, abs(i - o));
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 20224
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

int a,b;
string s,t;

int main()
{
  cin>>a>>b;
  rep(i,b) s.pb(a+'0');
  rep(i,a) t.pb(b+'0');
  if(s<t) cout<<s<<endl;
  else cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,p;
	string s;
	cin >> n >> p >> s;
	if(p==2 || p==5){
		ll ans = 0;
		REP(i,n) if((s[n-i-1]-'0')%p==0) ans += n-i;
		cout << ans << '\n';
		return 0;
	}

	vector<ll> val(p, 0);
	ll ten = 1;
	ll cur = 0;
	val[cur]++;
	REP(i,n){
		cur = (cur + (s[n-i-1] - '0')*ten) % p;
		ten = (ten * 10) % p;
		val[cur]++;
	}
	ll ans = 0;
	REP(i,p) ans += val[i] * (val[i]-1) / 2;
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 720
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int lunner[3]={};
        int points = 0;
        int outs = 0;
        string ss;
        while(cin>>ss)
        {
            if(ss=="HOMERUN")
            {
                points++;
                rep(i,3){ if(lunner[i]==1){lunner[i]=0;points++;}}
                continue;
            }
            if(ss=="HIT")
            {
                if(lunner[2]==1){points++;continue;}
                if(lunner[1]==1){lunner[2]=1;continue;}
                if(lunner[0]==1){lunner[1]=1;continue;}
                if(lunner[0]==0){lunner[0]=1;continue;}
            }
            if(ss=="OUT"){outs++;}



            if(outs == 3)break;
        }
        cout << points << endl;
    }

    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a, b;

    while (true) {
      a = scanner.nextInt();
      b = scanner.nextInt();
      if (a == 0 && b == 0) break;
      for (int i = 0; i < a; ++i) {
        for (int j = 0; j < b; ++j) System.out.printf("#");
        System.out.println();
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 59864
#include<iostream>
using namespace std;
int main()
{
    int a,b,i,sum1,sum2;
    cin>>a>>b;
    sum1=0;
    sum2=0;
    for(i=a-1;i>0;i--){
        sum1=sum1+i;
    }
    for(i=b-1;i>0;i--){
        sum2=sum2+i;
    }
    cout<<sum1+sum2;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i*4+j*7 == N {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

	    String a= gs();
	    String s= gs();
	    String c= gs();


        System.out.print("A"+s.charAt(0) + "C");
        
	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 38540
#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RI(a, b);
  printf((a % 2 == 0 || b % 2 == 0) ? "Even" : "Odd");
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int x = 1;
  for (int i = 0; i < N; i++) {
    if (x*2 < x+K) {
      x *= 2;
    }
    else {
      x += K;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc141_a solver = new abc141_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc141_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();

            if (S.compareTo("Sunny") == 0) {
                out.println("Cloudy");
                return;
            }
            if (S.compareTo("Cloudy") == 0) {
                out.println("Rainy");
                return;
            }
            if (S.compareTo("Rainy") == 0) {
                out.println("Sunny");
                return;
            }


        }

    }
}



Measured memory_bytes: 22228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


bool is_match(char a, char b){
    return (a == '?' || b == '?' || a == b);
}

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

    int A = a.size();
    int B = b.size();
    int C = c.size();

    //vector<bool> ab(10000, true);
    //vector<bool> bc(10000, true);
    //vector<bool> ac(10000, true);

    bool ab[10000] = {true};REP(i, 10000) ab[i] = true;
    bool ac[10000] = {true};REP(i, 10000) ac[i] = true;
    bool bc[10000] = {true};REP(i, 10000) bc[i] = true;

    REP(i, A)REP(j, B) if (!is_match(a[i], b[j])) ab[i - j + 5000] = false; 
    REP(i, A)REP(j, C) if (!is_match(a[i], c[j])) ac[i - j + 5000] = false; 
    REP(i, B)REP(j, C) if (!is_match(b[i], c[j])) bc[i - j + 5000] = false; 
    
    int M = 2001;
    int ans = 3 * M;
    rep(i, -2*M, 2*M)rep(j, -2*M, 2*M)if (ab[i + 5000] && ac[j + 5000] && 0 <= (i - j + 5000) && (i - j + 5000) < 10000  && bc[j - i + 5000]){
        int r = max(A, max(i + B, j + C));
        int l = min(0, min(i, j));
        ans = min(ans, r - l);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc153/tasks/abc153_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll H,A; cin >> H >> A;
    res = (H+A-1)/A;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		BigInteger x = sc.nextBigInteger();
		BigInteger a = new BigInteger("100");
		
		BigInteger val = new BigInteger("101");
		BigInteger div = new BigInteger("100");
		int c=0;
		while( x.compareTo(a) > 0) {
			c++;
			a = a.multiply(val).divide(div);
		}
		
		System.out.println(c);

	}

}



Measured memory_bytes: 37044
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

// auto mod int
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[309][90009];
mint dp2[309][90009];

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  dp[0][0]=1;
  rep(i,n){
    rep(j,sum+1){
      dp[i+1][j]+=dp[i][j]*2;
      if(j+a[i]<=sum){
        dp[i+1][j+a[i]]+=dp[i][j];
      }
    }
  }
  dp2[0][0]=1;
  rep(i,n){
    rep(j,sum+1){
      dp2[i+1][j]+=dp2[i][j];
      if(j+a[i]<=sum){
        dp2[i+1][j+a[i]]+=dp2[i][j];
      }
    }
  }
  mint s1=0,s2=0;
  rep2(j,(sum+1)/2,sum+1){
    s1+=dp[n][j];
  }
  if(sum%2==0)s2=dp2[n][sum/2];
  mint ans=1;
  rep(i,n)ans*=3;
  ans-=s1*3;
  ans+=s2*3;
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 434944