akhauriyash/Code-Regression huggingface dataset:
# 素因数分解 - 試し割り法
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

ans = 0

for num, cnt in factorization(n):
    if num != 1:
        tmp = 1
        while True:
            cnt -= tmp
            if cnt >= 0:
                ans += 1
                tmp += 1
            else:
                break

print(ans)

Measured memory_bytes: 9420
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const ll INF = 1LL << 30;

int main() {
    ll N, W;
    cin >> N >> W;
    vl w(N), v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }
    vvl dp(N + 1, vl(N * 1000 + 1, INF));
    for (int i = 0; i < N + 1; ++i) {
        dp[i][0] = 0;
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N * 1000 + 1; ++j) {
            if (j - v[i] >= 0)
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    ll ret = 0;
    for (ll i = 0; i < N * 1000 + 1; ++i) {
        if (dp[N][i] <= W)
            ret = max(ret, i);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 80256
# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# Ruby 1st Try
DICT = Array.new(101,0)
for j in 1..101 do
    divideCounter = 0
    nowNumber = j
    while true
        oddFlag = false
        modNumber = nowNumber % 2
        if modNumber !=0
            oddFlag = true
        end
        if oddFlag
            break
        end
        nowNumber = nowNumber / 2
        divideCounter = divideCounter+1
    end
    DICT[j] = divideCounter
end
N = gets.chomp.to_i
answer = -1
min = -1
N.downto(1) { |j|
    if min < DICT[j]
        min = DICT[j]
        answer = j
    end
}
puts(answer)

Measured memory_bytes: 3836
#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);
  
  for (int i = 0; i < n; ++i) {
    int k, p;
    scanf("%d %d", &k, &p);
    
    if (k % p) { printf("%d\n", k % p); }
    else { printf("%d\n", p); }
  }
  
  return 0;
}

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

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, a, b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int passed = 0;
    int passed_oversea = 0;
    for (int i=0; i<n; i++){
        if (s[i]=='a' and passed < a+b){
            puts("Yes");
            passed++;
        }
        else if (s[i]=='b' and passed < a+b and passed_oversea<b){
            puts("Yes");
            passed++;
            passed_oversea++;
        }
        else {
            puts("No");
        }
    }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n)
  vpll A(n);
  FOR(i,0,n){
    ci(A[i].fi);
    A[i].se=n/(i+1);
  }
  
  //REV(A);
  vll B(n);
  ll now=0;
  
  for(ll i=n-1;i>=0;i--){
      ll sum=0;
      FOR(j,1,1+A[i].se){
        //sum+=A[(j+1)*(n-i)-1].fi;
        sum+=B[(i+1)*j-1];
      }
      
      if(sum%2!=A[i].fi){
        B[i]++;
        now++;
      }
      
    }
  
  co(now)
    FOR(i,0,n){
    if(B[i]!=0){
    cout<<i+1<<" ";
  }
  }
  cout<<" "<<endl;
}

Measured memory_bytes: 5504
#include<iostream>

int main(void) {
    int R;
    std::cin >> R;
    if (R < 1200) {
        std::cout << "ABC" << std::endl;
    } else if (R < 2800) {
        std::cout << "ARC" << std::endl;
    } else {
        std::cout << "AGC" << std::endl;
    }
    return 0;
}


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

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


int main() {
	int n; cin >> n;
	vector<	int>a(n), l(n), r(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n-1; i++) l[i + 1] = gcd(l[i], a[i]);
	for (int i = n-1; i >= 1; i--) r[i - 1] = gcd(r[i], a[i]);
	
	int ans = 1;
	for (int i = 0; i < n; i++) {
		ans = max(ans, gcd(l[i], r[i]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int t, n, k, a, b;
vector<int> vec[2][200009];
long long ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> t;
	while (t--) {
		cin >> n;
		ans = 0;
		for (int i = 1; i <= n; i++) {
			vec[0][i].clear();
			vec[1][i].clear();
		}
		for (int i = 1; i <= n; i++) {
			cin >> k >> a >> b;
			if (a < b) {
				vec[1][k + 1].pb(b - a);
			}
			else if (a > b) {
				vec[0][k].pb(a - b);
			}
			ans += min(a, b);
		}
		int cnt = 0;
		multiset<int> w;
		for (int i = n; i > 0; i--) {
			//cnt++;
			//sort(vec[0][i].begin(), vec[0][i].end());
			//reverse(vec[0][i].begin(), vec[0][i].end());
			int sz = vec[0][i].size();
			for (int j = 0; j < sz; j++) {
				w.insert(vec[0][i][j]);
			}
			if (w.empty()) continue;
			auto p = w.end();
			p--;
			ans += *p;
			w.erase(p);
		}
		w.clear();
		for (int i = 0; i <= n; i++) {
			int sz = vec[1][i].size();
			for (int j = 0; j < sz; j++) {
				w.insert(vec[1][i][j]);
			}
			if (w.empty()) continue;
			auto p = w.end();
			p--;
			ans += *p;
			w.erase(p);
		}
		cout << ans << E;
	}
	//system("pause");
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans=0;
    for(int i = 0; i < s.size(); i++) {
        ans += (int)s[i]-48;
        ans %= 9;
    }

    if(ans%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

const int64_t MAX_N = 100005;
int64_t N;
int64_t vals[MAX_N];

int main() {
	scanf("%lld", &N);
	for (int64_t i = 0; i < N; ++i) {
		scanf("%lld", vals + N - i - 1);
	}
	int64_t min = 2, max = 2;
	for (int64_t i = 0; i < N; ++i) {
		max = (max / vals[i] + 1) * vals[i] - 1;
		min = ((min / vals[i]) + !!(min % vals[i])) * vals[i];
	}
	if (min > max) printf("-1\n");
	else printf("%lld %lld\n", min, max);
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;

    vec v(2019);
    vec vnext(2019);
    int cnt = 0;
    rep (i, s.length()) {
        int num = s[i] - '0';
        if (i > 0) {
            vnext = vec(2019);
            rep (j, 2019) {
                int rem = (j * 10 + num) % 2019;
                vnext[rem] += v[j];
            }
        }
        vnext[num]++;
        v = vnext;
        cnt += v[0];
    }
    print(cnt);

    return 0;
}


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

using namespace std;

int n;
map<string, int> mp;

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

    cin >> n;

    for(int i = 1; i <= n; i++){
        string s; cin >> s;

        mp[s]++;
    }

    int mx = 0;

    for(auto &k : mp){
        mx = max(mx, k.second);
    }

    for(auto &k : mp){
        if(mx == k.second) cout << k.first << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string str;
	cin >> str;

	if(str[0] == str[1] || str[0] == str[2] || str[1] == str[2])
		cout << "No";
	else
		cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
N = int(input(""))
m = input("")
a = m.split(" ")
a = [int(i) for i in a]

c = []
for i in range(1,N+1):
    if i % 2 == 1 and a[i-1] % 2 == 1:
        c.append(i)
print(len(c))

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

int n,u,k,v;
int g[102][102];
int d[102];
int sn[102];
int cnt=0;
int x,siz;

queue<int>q;

int main(){
  cin>>n;
  memset(g,0,sizeof(g));
  for(int i=1;i<=n;i++){
    cin>>u>>k;
    d[i]=-1;
    sn[i]=0;
    for(int j=1;j<=k;j++){
      cin>>v;
      g[u][v]=1;
    }
  }
  
  q.push(1);

  while(!q.empty()){

    siz=q.size();

    for(int i=0;i<siz;i++){
      
      x=q.front();
      q.pop();
      
      sn[x]=1;
      if(d[x]==-1)d[x]=cnt;
      
      for(int j=1;j<=n;j++){
	
	if(g[x][j]==1 && sn[j]==0){
	  q.push(j);
	}
      
      }

    }

    cnt++;

  }

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

  }

}

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

# 単調非増加である最大数
cnt = 0
N = int(input())
H = [int(s) for s in input().split()]
max_step = 0
for i in range(N-1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        if max_step <= cnt:
            max_step = cnt
        cnt = 0

if max_step <= cnt:
    max_step = cnt

print(max_step)



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

lli n;

int main(void){
	cin >> n;
	vector<lli> a(n);
	lli sum = 0;
	rep(i, n) cin >> a[i], sum+=a[i];
	lli av1, av2;
	av1 = sum/n;
	av2 = sum/n+1;
	lli cost1, cost2;
	cost1 = cost2 = 0;
	rep(i, n){
		cost1 += (a[i]-av1)*(a[i]-av1);
		cost2 += (a[i]-av2)*(a[i]-av2);
	}
	cout << min(cost1, cost2) << endl;

	return 0;
}


Measured memory_bytes: 3604
n = int(input())
s = input().split(" ")
nums = list(map(int, s))
mi = 1000000
ma = -1000000
su = 0
for i in range(n):
    if nums[i] < mi:
        mi = nums[i]
    if nums[i] > ma:
        ma = nums[i]
    su += nums[i]
print(mi,ma,su)

Measured memory_bytes: 8676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
using namespace std;

struct X {
    int i;
    int n;
};

int main()
{
    ll N;
    cin >> N;
/*     for (int i = 1; i < N;++i){
        if (N/i == (N%i)){
            cout << i << endl;
        }
    }
 */
    vector<ll> x;
    // 約数を列挙する
    for (ll i = 1; i*i <= N; ++i) {
        if (N % i == 0) {
            x.push_back(i);
            // N/iも約数となる
            if (i*i != N) {
                x.push_back(N / i);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < x.size(); ++i) {
        // cout << x[i] << endl;
        ll m = x[i] - 1;
        if (m <= 0) continue;
        if (N / m == (N % m)) {
            ans += m;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // 三井住友信託銀行プログラミングコンテスト2019D - Lucky PIN
  // 暗証番号の取り得る値は000から999までの1000通りしかない
  // 1000通り全てを全探索する（1桁ずつ探索するので*3）
  // 3万文字(3*10^4)*3000通り　計算量9*10^7
  int N, ans = 0;
  cin >> N;
  string S;
  cin >> S;
  REP(i, 1000){
    vector<int> tmp(3);
    tmp = {i/100, (i/10)%10, i%10};
    int j = 0, k = 0;
    // j:Sを順に探索していく、k:3文字を順に指定する
    while(j < N && k < 3){
      if(S.at(j) == '0' + tmp.at(k)){
        k++;
      }
      j++;  
    }
    if(k == 3){
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, L;
    cin >> N >> L;
    deque<int> a(N);
    REP(i, N) cin >> a[i];
    int idx = -1;
    REP(i, N-1) {
        if (a[i] + a[i+1] >= L) {
            cout << "Possible" << endl;
            idx = i;
            break;
        }
    }
    if (idx == -1) {
        cout << "Impossible" << endl;
        return 0;
    }

    REP(i, idx) {
        cout << i + 1 << endl;
    }
    REPR(i, N-2) {
        if (i == idx) break;
        cout << i + 1 << endl;
    }
    cout << idx + 1 << endl;
    return 0;
}



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

int main() 
{
    int n;
    cin >> n;
    int tot = 0;
    rep(i,n) {
        int p;
        cin >> p;
        if (i+1 != p) tot++;
    }
    if (tot<=2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline--------------------------------------------
    s = input()
    s = s.replace("hi","")
    print("No" if s else "Yes")
#endline===============================================
if __name__ == "__main__":
    main()

Measured memory_bytes: 66156
/*
    Sk arman Hossain
    University of Barisal

    Problem :
    Solution :
 */
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define N 200001
#define PR pair<ll,ll>
#define sf1(n) cin>>n
#define sf2(n, m) cin>>n>>m
#define sf3(n, m,k ) cin>>n>>m>>k
#define pfn(n) printf("%d\n",n)s
#define pf1(n) printf("%d ",n)
#define pfl1(n) printf("%lld ",n)
#define pfln(n) printf("%lld\n",n)
#define pfu(n) printf("%llu\n",n)
#define pfs(s) printf("%s",s)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define minus1 printf("-1\n")
#define PB push_back
#define PI 3.1415926536
#define VST(v) sort(v.begin(),v.end())
#define VSTcmp(v,cmp) sort(v.begin(),v.end(),cmp)
#define fori(i,n) for(;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define MP make_pair
#define ff first
#define ss second
#define tt third
#define mod 1000000007
#define T(n) printf("test %d\n",n)
int dx[] = {0,0,1,-1,2,2,-2,-2,1,-1,1,-1};
int dy[] = {1,-1,0,0,1,-1,1,-1,2,2,-2,-2};
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;


vector<ll>V,V2,V3;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//    /freopen("1input.txt","r",stdin);
//    /freopen("1output.txt","w",stdout);
    ll tcase=1;
    //sf1(tcase);
    //cin>>tcase;
    for(ll test=1; test<=tcase; test++)
    {
        ll n,ans=0;
        cin>>n;
        for(ll i=1;i<=n;i++){
            ll a;
            cin>>a;
            if(a%2!=0&&i%2!=0)ans++;
        }
        cout<<ans<<"\n";
    }
///*****************************  ALHAMDULILLAH  *****************************/
}





Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
    int k, t;
    scanf("%d %d", &k, &t);
    int i;
    int a[102];
    for (i = 0; i < t; i++)
        scanf("%d", &a[i]);
    int sum = 0, max = 0;
    for (i = 0; i < t; i++)
    {
        if (max < a[i])
            max = a[i];
        sum += a[i];
    }
    sum -= max;
    max -= sum + 1;
    if (max < 0)
        printf("0\n");
    else
        printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 128
/*
Program
Written by "Vaibhav" aka 'ZodiacBestro'
In 2017
*/

#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;
const ll MAXN = 1e6+5;

ll dp[MAXN],dp1[MAXN];

int main()
{
	fast_cin; cin.tie(NULL); cin.tie(NULL);
	string s; cin >> s;
	if ((s[0] == s[1] and s[1] == s[2] ) or (s[1] == s[2] and s[2] == s[3]))
	{
		cout << "Yes" << endl;

	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


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

struct branch{
	int n1,n2,w;
};
bool f(branch i, branch j){
	return (i.w>j.w);
}
int main(){
	while (1){
		int n,i;
		char c;
		cin>>n;
		if(n==0)break;
		vector<int>T(n);
		for(i=0;i<n;i++) T[i]=i;

		branch tmp;
		int m; cin>>m;
		vector<branch>S(m);
		for(i=0;i<m;i++) cin>>S[i].n1>>c>>S[i].n2>>c>>S[i].w;
		sort(S.begin(),S.end(),f);

		int a=0;
		while(S.size()){
			tmp=S.back();
			S.pop_back();
			int b=T[tmp.n1],c=T[tmp.n2];
			if (b!=c){
				for(i=0;i<n;i++)
					if(T[i]==c)T[i]=b;
				a+=tmp.w/100-1;
			}
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int a,b;
    cin >> a >> b;
    if(max(a,b) <= 9)cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n; cin >> n;
	int mill = 1+999*(20*10-5)+333*5;
	for(int i = 0; i < n; ++i){
		int y, m, d; cin >> y >> m >> d;
		int byear = (y-1)/3;
		int ans = d;
		if(y % 3 == 0){
			ans += (m-1)*20;
		}
		else{
			ans += (m-1)*19 + m/2;
		}
		ans += (y -1)*(20*10-5)+byear * 5;
		ans = mill - ans;
		cout << ans << endl;
	}

	return 0;
}

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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	while ( stdin.hasNextDouble() ) {

	    final double minV = stdin.nextDouble();
	    final double t = minV / 9.8;
	    final double y = 4.9 * t * t;
	    for ( int i = 0; i < 100000; i++ ) {
		if ( y <= 5 * i - 5 ) {
		    System.out.println( i );
		    break;
		}
	    }
	}	
    }    
}

Measured memory_bytes: 18628
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int M=1010;
int a,n,t,g,h[M];
float te[M],c[M],minn=0x7fffffff;
int main(){
	scanf("%d %d %d",&n,&t,&a);
	for(int i=1;i<=n;++i) scanf("%d",&h[i]);
	for(int i=1;i<=n;++i) te[i]=t-h[i]*0.006;
	for(int i=1;i<=n;++i) c[i]=abs(te[i]-a);
	for(int i=1;i<=n;++i) {if(c[i]<minn){minn=c[i];g=i;}}
	printf("%d",g);
	return 0;
}


Measured memory_bytes: 256
#DPS F LSC 
s=input()
t=input()
a,b=len(s),len(t)
dp=[[0]*b for _ in range(a)]
c=-1
for i in range(b):
    if s[0]==t[i]:
        c=i
        break
if c>=0:
    for i in range(c,b):
        dp[0][i]=1
c=-1
for i in range(a):
    if t[0]==s[i]:
        c=i
        break
if c>=0:
    for i in range(c,a):
        dp[i][0]=1
for i in range(1,a):
    for j in range(1,b):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1        
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
a-=1
b-=1
ans=""
while a>0 and b>0:
    if dp[a][b]==dp[a-1][b]:
        a-=1
    elif dp[a][b]==dp[a][b-1]:
        b-=1
    else:
        ans+=s[a]
        a-=1
        b-=1
if a==0:
    if dp[0][b]==1:
        ans+=s[0]
elif b==0:
    if dp[a][0]==1:
        ans+=t[0]
print(ans[::-1])

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

int main(){ //ABC 
    /* A */
    int d,t,s;
    cin >> d >> t >> s;
    cout << (((double)d/s<=t)? "Yes":"No") << endl;

    /* B
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        ans += s.at(i) - '0';
    }
    cout << ((ans%9==0)? "Yes":"No") << endl;*/

    /* C 
    int n;
    cin >> n;
    vector<int64_t> a(n);
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    int64_t ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;*/


    return 0;
}

Measured memory_bytes: 3616
use std::error::Error;
use std::io;
use std::process;

fn main() {
    if let Err(_) = run() {
        process::exit(1);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut n = String::new();
    io::stdin().read_line(&mut n)?;
    println!("ABC{}", n);
    Ok(())
}


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

int main()
{
    string stra, strb;
    cin >> stra >> strb;
    for(int i=0;i<stra.length();i++){
        cout << stra.substr(i,1);
        cout << strb.substr(i,1);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
nums = list(map(int,input().split()))
nums = nums[::-1]
judge = "Yes"

for i in range(N-1):
  dev = nums[i+1] - nums[i]
  if dev > 1:
    judge =  "No"
    break
  elif dev == 1:
    nums[i+1] = nums[i+1] - 1
  else:
    continue
    
print(judge)
    

Measured memory_bytes: 14224
n, k = map(int, input().split())
W = [int(input()) for i in range(n)]

left = max(W)
ans = right = 100000 * 100000


def is_ok(P):
    truck = 1
    t_sum = 0
    for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
    return True


while left <= right:
    mid = (left + right) // 2
    if is_ok(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1

print(ans)



Measured memory_bytes: 9560
#!/usr/bin/env python
import itertools


def solve():
    n = int(input())
    cnt = 0
    for i in range(1, 11):
        for res in itertools.product(['3', '5', '7'], repeat=i):
            if int(''.join(res)) > n:
                print(cnt)
                return
            if '3' in res and '5' in res and '7' in res:
                cnt += 1


solve()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    ll x,k,d;cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k) cout<<x-k*d<<endl;
    else{
        k-=x/d;
        x%=d;
        if(k%2==0) cout<<x<<endl;
        else cout<<abs(x-d)<<endl;
    }
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc163_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var M = CIn.ReadInt();
      var A = CIn.ReadIntArray(M);

      var sum = A.Sum();

      Console.WriteLine(sum <= N ? N - sum : -1);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b;
	cin >> a >> b;

	FOR(n,1,10000) {
		if (n*8/100 == a && n*10/100 == b) {
			cout << n << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}



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

int main(){
	while(1){
		string s1,s2;
		cin>>s1;
		if(s1==".")return 0;
		cin>>s2;
		string s11[201],s22[201];
		for(int i=0;i<201;i++){
			s11[i]=".";s22[i]=".";
		}
		s11[0]="";s22[0]="";
		int now1=0,now2=0;
		for(int i=0;i<(int)s1.length();i++){
			if(s1[i]=='"'){
				now1++;
				s11[now1]="";
			}else s11[now1]+=s1[i];
		}
		for(int i=0;i<(int)s2.length();i++){
			if(s2[i]=='"'){
				now2++;
				s22[now2]="";
			}else s22[now2]+=s2[i];
		}
		int d=0;
		for(int i=0;i<201;i++){
			if(s11[i]!=s22[i]){
				if(i&1){
					d++;
				}else d+=2;
			}
		}
		if(d==0)cout<<"IDENTICAL";
		else if(d==1)cout<<"CLOSE";
		else cout<<"DIFFERENT";
		cout<<"\n";
	}
}

Measured memory_bytes: 3212
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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 T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    string s, t;
    int a, b;
    cin >> s >> t >> a >> b;
    string u;
    cin >> u;
    if (s == u) cout << a - 1 << " " << b << endl;
    else cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 256
from collections import deque

a,b = map(int, input().split())
d = deque()
s = deque()
for i in range(a):
    c,g = map(str,input().split())
    d.append(int(g))
    s.append(c)

ans_s = []
ans_num = []
count = 0
while True:
    count += b
    if len(d) == 0:
        break
    e = d.popleft()
    f = s.popleft()
    if e - b <= 0:
        ans_s.append(f)
        count += (e-b)
        ans_num.append(count)
    else:
        d.append(e - b)
        s.append(f)
for i in range(a):
    print(str(ans_s[i]) + ' ' + str(ans_num[i]))
        
        


Measured memory_bytes: 12096
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    now = 1
    check = [0]*N
    ans = 0
    while(1):
    # for k in range(100):
        if now == 2:
            break
        if check[now-1] == 1:
            print(-1)
            return
        else:
            check[now-1] = 1
        now = A[now-1]
        ans += 1
        # print(now)
    print(ans)
    return
        
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 13840
import java.util.*;class Main{public static void main(String[]z){String l="1 4 1 4 1 2 1 2 ",r="";List<Integer>p=new ArrayList<Integer>();int i,j,m,x;for(Scanner s=new Scanner(System.in);s.hasNext();System.out.println(r.substring(0,15))){for(p.clear(),i=8;i-->0;)p.add(s.nextInt());for(m=99999,i=8;i-->0;l=l.substring(2,16)+l.substring(0,2)){for(x=0,j=8;j-->0;)x+=Math.max(0,p.get(j)-l.charAt(2*j)+48);if(m==x)r=r.compareTo(l)<0?r:l;if(m>x){m=x;r=l;}}}}}

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

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

template< typename flow_t >
struct FordFulkerson{
  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
  };

  vector<vector<edge>> graph;
  vector<int> used;
  const flow_t INF;

  FordFulkerson(int V):graph(V),used(V),INF(numeric_limits<flow_t>::max()) {}

  void add_edge(int from,int to,flow_t cap){
    graph[from].push_back((edge){to,cap,(int)graph[to].size(),false});
    graph[to].push_back((edge){from,0,(int)graph[from].size()-1,true});
  }

  flow_t dfs(int now,int t,flow_t f){
    if(now==t) return f;
    used[now]=true;
    for(int i=0;i<graph[now].size();i++){
      edge &e=graph[now][i];
      if(!used[e.to]&&e.cap>0){
        flow_t d=dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          graph[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s,int t){
    flow_t flow=0;
    for(;;){
      for(int i=0;i<graph.size();i++) used[i]=0;

      flow_t f=dfs(s,t,INF);
      if(f>0) flow+=f;
      else return flow;
    }
  }
};

const int N=2000;
const ll INF=1e9;

int main(){
  int R,C;
  cin>>R>>C;
  vector<string> S(R);
  rep(i,R) cin>>S[i];

  FordFulkerson<ll> graph(N);
  int s=R*C,t=s+1;
  int cnt=t+1;
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      if(S[i][j]=='.') continue;
      graph.add_edge(s,i*C+j,1);
      graph.add_edge(i*C+j,t,1);
    }
  }

  int ans=0;
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      if(S[i][j]=='.') continue;
      if(i+1<R&&S[i+1][j]=='#'){
        ans--;
        graph.add_edge(cnt,t,1);
        graph.add_edge(s,cnt,0);
        graph.add_edge(i*C+j,cnt,INF);
        graph.add_edge((i+1)*C+j,cnt,INF);
        cnt++;
      }
      if(j+1<C&&S[i][j+1]=='#'){
        ans--;
        graph.add_edge(cnt,t,0);
        graph.add_edge(s,cnt,1);
        graph.add_edge(cnt,i*C+j,INF);
        graph.add_edge(cnt,i*C+j+1,INF);
        cnt++;
      }
    }
  }

  ans+=graph.max_flow(s,t);
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 3540
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>

using namespace std;

int main()
{
	vector <int> v(5);
	
	for (int i=0; i<5; i++) cin >> v[i];
	
	int res = 100000;
	
	do{
		int cur = 0;
		
		for (int i = 0; i<5; i++)
		{
			cur = cur + v[i];
			if (i == 4)
			{
				break;
			}
			
			else {
				if (v[i]%10 == 0){
					continue;
				}
				else {
					cur = cur + (10- (cur%10));
				}
			}
		}
		
		res = std::min(cur,res);
	}while(std::next_permutation(v.begin(), v.end()));
	
	cout << res << endl;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
ABs = []
for i in range(N):
  a, b = map(int, input().split())
  ABs.append((a, b))
CDs = []
for i in range(M):
  c, d = map(int, input().split())
  CDs.append((c, d))
for a, b in ABs:
  r = -1
  mindist = 1000000000
  for i in range(M):
    c, d = CDs[i]
    dist = abs(c-a)+abs(d-b)
    if dist < mindist:
      r = i
      mindist = dist
  print(r+1)


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

using namespace std;

using i64 = int64_t;
const i64 INF = i64(1e18) + 7;

struct Node{
    Node* c1;
    Node* c2;
    int val, r;
    Node(string& s, int i) : c1(nullptr), c2(nullptr), val(0){
        // parse

        assert(s[i] == '(');
        if(s[i + 1] == '('){
            c1 = new Node(s, i + 1);
            i = c1->r;
        }
        else
            ++i;
        assert(s[i] == ')');
        ++i;

        assert(s[i] == '[');
        ++i;

        for(; s[i] != ']'; ++i){
            val *= 10;
            val += s[i] - '0';
        }

        assert(s[i] == ']');
        ++i;

        assert(s[i] == '(');
        if(s[i + 1] == '('){
            c2 = new Node(s, i + 1);
            i = c2->r;
        }
        else
            ++i;
        assert(s[i] == ')');
        ++i;
        r = i;
    }

    Node(Node* x, Node* y) : c1(nullptr), c2(nullptr), val(0){
        val = x->val + y->val;
        if(x->c1 && y->c1)
            c1 = new Node(x->c1, y->c1);
        if(x->c2 && y->c2)
            c2 = new Node(x->c2, y->c2);
    }

    void output(){
        cout << '(';
        if(c1)
            c1->output();
        cout << ')';
        cout << '[' << val << ']';
        cout << '(';
        if(c2)
            c2->output();
        cout << ')';
    }
};

int main()
{

    string a, b;
    cin >> a >> b;

    Node node_a = Node(a, 0);
    Node node_b = Node(b, 0);

    Node merge = Node(&node_a, &node_b);

    merge.output();
    cout << endl;

    return 0;
}



Measured memory_bytes: 3228
using System;
using System.Collections.Generic;
using System.Text;

namespace _065_Trading
{
	class Program
	{
		static void Main ( string[] args )
		{
			List<int> thisMonth = new List<int> (1001);
			List<int> lastMonth = new List<int> (1001);
			const int Sentinel = 1001;	//??§??¢??????????????§???+1

			//input
			string inputStr;
			while ((inputStr = Console.ReadLine ()) != "")
			{
				string[] split = inputStr.Split (',');
				int item = int.Parse (split[0]);
				thisMonth.Add (item);
			}

			while ((inputStr = Console.ReadLine ()) != null)
			{
				string[] split = inputStr.Split (',');
				int item = int.Parse (split[0]);
				lastMonth.Add (item);
			}

			//process
			thisMonth.Sort ();
			lastMonth.Sort ();
			thisMonth.Add (Sentinel);
			lastMonth.Add (Sentinel);

			StringBuilder output = new StringBuilder (1000);

			int thisIndex = 0;
			int lastIndex = 0;

			int limit = thisMonth.Count - 1;
			int limit2 = lastMonth.Count - 1;

			while (thisIndex < limit && lastIndex < limit2)
			{
				if (thisMonth[thisIndex] == lastMonth[lastIndex])
				{
					int companyNumber = thisMonth[thisIndex];
					int count = 2;

					thisIndex++;
					lastIndex++;

					//??????????????¨??????????????°??????????????????????????§????´¢??????
					while (thisMonth[thisIndex] == companyNumber)
					{
						thisIndex++;
						count++;
					}

					while (lastMonth[lastIndex] == companyNumber)
					{
						lastIndex++;
						count++;
					}

					output.AppendLine (companyNumber + " " + count);
				}
				else if (thisMonth[thisIndex] < lastMonth[lastIndex])
				{
					thisIndex++;
				}
				else
				{
					lastIndex++;
				}
			}

			//output
			Console.Write (output);
		}
	}
}

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  int count_i = 0;
  while(count_i<N){
    string hinaarare;
    cin >> hinaarare;

    if(hinaarare == "Y"){
       cout << "Four" << endl;
       return 0;
    }
    count_i++;
  }
 cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  int k=0;
  rep(i,n){
    if(i<10){k++;}
    if(i>=100&&i<1000){k++;}
    if(i>=10000&&i<100000){k++;}}
  cout<<k<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	/**組み合わせの数を求める問題
	 *1~nまでの数のうち、3つの数をランダムで選び合計がxになる組み合わせは何通りになるかを求める
	 * @param args
	 * n:1~nまでの数　x:合計となる数
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String args[]){

		for(;scan.hasNext();){

			int n = scan.nextInt();
			int x = scan.nextInt();
			
//			int n = Integer.parseInt(args[in]);
//			int x = Integer.parseInt(args[in+1]);

			if(n == 0 && x == 0){
				break;
			}
			int count=0;

			for(int i = 1;i<= n;i++){
				for(int j = i+1;j <= n;j++){
					for(int k = j+1 ;k <= n;k++){
						if(i+j+k == x){				//異なる3種類の数字が入力値を満たしたらカウント
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}


}



Measured memory_bytes: 26396
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    ll n;
    cin >> n;
    ll tmp = LINF;
    for(ll i=1;i<=sqrt(n);i++){
        //cout << floor(n/i) << "   " << n/i << endl;
        if(floor((double)n/i) == (double)n/i){
            if(tmp > i + (n/i)){
                tmp = i + (n/i) - 2;
                //if(i == 1)cout << floor((double)n/i) << ":" << (double)n/i << endl;
                
            }
        }
    }
    
    cout << tmp << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  string v;
  cin>>v;
  int n=v.back()-'0';

  if(n==3){
    cout<<"bon";
  }else if(n==0||n==1||n==6||n==8){
    cout<<"pon";
  }else{
    cout<<"hon";
  }
  cout<<endl;

  return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define mod 1000000009
#define p 666013
using namespace std;

char mat[1010][1010];
int n;
int h[1010];
int hash1[1010][1010];

void get_h(int x)
{
    /// incep de pe linia x
    for (int i(0); i < n; i++) {
        h[i] = mat[x][i] - 'a';
        for (int j((x + 1) % n); j != x; j = (j + 1) % n)
            h[i] = (27LL * h[i] + mat[j][i] - 'a') % mod;
    }
}
int get_main_h(int x)
{
    int ans(h[x]);
    for (int j((x + 1) % n); j != x; j = (j + 1) % n)
        ans = (1LL * p * ans + h[j]) % mod;
    return ans;
}
void get_trans()
{
    for (int i(0); i < n; i++)
        for (int j(i + 1); j < n; j++)
            swap(mat[i][j], mat[j][i]);
}

int main()
{
    cin >> n;
    for (int i(0); i < n; i++)
        for (int j(0); j < n; j++)
            cin >> mat[i][j];

    for (int i(0); i < n; i++) {
        get_h(i);
        for (int j(0); j < n; j++) {
            hash1[i][j] = get_main_h(j);
        }
    }

    get_trans();
    int ans(0);

    for (int i(0); i < n; i++) {
        get_h(i);
        for (int j(0); j < n; j++) {
            if (hash1[j][i] == get_main_h(j))
                ans++;
        }
    }


    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3712
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val member = readLine()!!.split(" ").map { it.toLong() }.sortedDescending().dropLast(n)
    val ans = member.indices.filter { it % 2 != 0 }.map { member[it] }.sum()
    println(ans)
}



Measured memory_bytes: 85256