akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	aArray, bArray, cArray := make([]int, n), make([]int, n), make([]int, n-1)
	for i := range aArray {
		aArray[i] = nextInt() - 1
	}
	for i := range bArray {
		bArray[i] = nextInt()
	}
	for i := range cArray {
		cArray[i] = nextInt()
	}

	ans := 0
	for i, a := range aArray {
		ans += bArray[a]
		if i > 0 {
			if a-1 == aArray[i-1] {
				ans += cArray[a-1]
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    rep(test,t){
        int n;
        cin>>n;
        vec K(n),L(n),R(n),X(n);
        rep(i,n) cin>>K[i]>>L[i]>>R[i];
        vector<P> A,B;
        ll ans=0;
        rep(i,n){
            if(L[i]>R[i]) A.push_back(P(K[i],i)),ans+=R[i];
            else{
                if(n-K[i]>0) B.push_back(P(n-K[i],i));
                ans+=L[i];
            }
        }
        sort(all(A)),sort(all(B));
        priority_queue<ll,vector<ll>,greater<ll>> que;
        int x=0;
        rep1(i,A.size()){
            while(x<A.size()&&A[x].first<=i) que.push(L[A[x].second]-R[A[x].second]),x++;
            if(i==A.size()) while(x<A.size()) que.push(L[A[x].second]-R[A[x].second]),x++;
            while(que.size()>i) que.pop();
        }
        while(!que.empty()) ans+=que.top(),que.pop();
        x=0;
        rep1(i,B.size()){
            while(x<B.size()&&B[x].first<=i) que.push(R[B[x].second]-L[B[x].second]),x++;
            if(i==B.size()) while(x<B.size()) que.push(R[B[x].second]-L[B[x].second]),x++;
            while(que.size()>i) que.pop();
        }
        while(!que.empty()) ans+=que.top(),que.pop();
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 14504
# coding: utf-8

A, B, K = map(int, input().split())
flag = [False] * max(A, B)

for i in range(len(flag)):
    if (A % (i + 1) == 0) and (B % (i + 1) == 0):
        flag[i] = True
cnt = 0
answer = 0
for i, f in reversed(list(enumerate(flag))):
    if f:
        cnt += 1
        if cnt == K:
            answer = i + 1
            break

print(answer)


Measured memory_bytes: 3060
/*
结论题Orz

设$f(x, y)$表示$(x, y)$辗转相除需要的步数，$fib(i)$表示第$i$个斐波那契数

常识：$f(fib[i], fib[i+1]) = i$。

定义一个数对是“好的”，当且仅当对于$(x, y)$，不存在更小的$x', y'$使得$f(x', y') > f(x, y)$

显然我们需要统计的数对一定是好的数对

定义一个数对是“优秀的”，当且仅当对于$(x, y)$，若$f(x, y) = k$, 满足$x, y \leqslant fib[k+2] + fib[k-1]$

结论！：一个好的数对辗转相除一次后一定是优秀的数对！

证明可以用反证法，也就是我先假设一个$f(a, b) = i$是好的，但是得到的数对$(x, y)$满足$y > fib[k+2] + fib[k-1]$

但是这样我们会得到一个$x' = f[i+2], y' = f[i+2]$满足$f(x', y')>f(a, b)$，所以不成立

那么现在要做的就是求“优秀的”数对的个数。

考虑直接用欧几里得算法的定义递推即可

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define Pair pair<LL, LL> 
#define MP(x, y) make_pair(x, y)
#define fi first 
#define se second 
#define LL long long 
#define int long long 
using namespace std;
const int MAXN = 1e6 + 10, B = 90, mod = 1e9 + 7;
inline LL read() {
	char c = getchar(); LL x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
vector<Pair> v[B + 1];
LL f[B + 1];
void Pre() {
	f[0] = f[1] = 1;
	for(int i = 2; i <= B; i++) f[i] = f[i - 1] + f[i - 2];
	v[1].push_back(MP(1, 2)); v[1].push_back(MP(1, 3)); v[1].push_back(MP(1, 4));
	for(int i = 1; i <= B - 3; i++) {
		for(int j = 0; j < v[i].size(); j++) {
			LL x = v[i][j].fi, y = v[i][j].se;
			LL tmp = x; x = y; y = tmp + y;
			while(y <= f[i + 3] + f[i - 1]) v[i + 1].push_back(MP(x, y)), y += x;
		}
	}
}
main() {
	// freopen("1.in", "r", stdin);
	Pre();
	int Q = read();
	while(Q--) {
		LL x = read(), y = read(), K;
		if(x > y) swap(x, y);
		for(K = 1; f[K + 1] <= x && f[K + 2] <= y; K++);
		cout << K << " ";
		if(K == 1) {cout << x * y % mod << endl; continue;}
		LL ans = 0;
		for(int i = 0; i < v[K - 1].size(); i++) {
			LL a = v[K - 1][i].fi, b = v[K - 1][i].se;
		//	printf("%I64d %I64d\n", a, b);
			if(b <= x) ans += (y - a) / b % mod;
			if(b <= y) ans += (x - a) / b % mod;
			//if(a + b <= x && b <= y) ans++;
			//if(a + b <= y && a <= x) ans++;
			ans %= mod;
		}
		cout << ans % mod<< endl;
	}
	return 0;
}
/*
1
12 11
*/


Measured memory_bytes: 4096
#include<stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=a*1.0/b;
    printf("%d %d %.5lf\n",d,r,f);
    return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>

typedef long long ll;

using namespace std;

int main() {
    int N, flg = 0;
    cin >> N;

    vector<int> data(N);

    // 代入
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }

    // 比較
    for (int i = N - 1; i >= 1; i--) {
        // 比較して単調非減少でない場合
        if (data.at(i-1) > data.at(i)) {
            data.at(i-1) -= 1;
            // i-1番目の数字を-1しても単調非減少出ない場合
            if (data.at(i-1) > data.at(i)) {
                flg = 1;
                break;
            }
        }
    }

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

    

    return 0;
}

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

int g[101][101], d[101], f[101];

int dfs(int id, int t)
{
    if(d[id]) return t;
    d[id]=++t;
    int n=g[id][0];
    for(int i=1; i<=n; i++) {
        t=dfs(g[id][i], t);
    }
    f[id]=++t;
    return t;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++) {
        int id, k;
        cin>>id>>k;
        g[id][0]=k;
        for(int j=1; j<=k; j++) {
            cin>>g[id][j];
        }
    }
    int t=0;
    for(int i=1; i<=n; i++) t=dfs(i, t);
    for(int i=1; i<=n; i++) cout<<i<<' '<<d[i]<<' '<<f[i]<<'\n';
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	map<int, int> a;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		a[b]++;
	}

	cout << a.size() << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int t,d,ta,tb,da,db;
	cin>>t>>d>>ta>>tb>>da>>db;
	double ans=100.0;
	for(int i=0;i*da<=d;i++){
		for(int j=0;j*db<=d;j++){
			if(i+j<1||i*da+j*db>d) continue;
			double tmp=(double)(ta*i*da+tb*j*db)/(double)(i*da+j*db);
			//o(tmp);
			ans=min(ans,fabs((double)t-tmp));
		}
	}
	printf("%.10lf\n",ans);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N, L;
  cin >> N >> L;
  vector<int> A(0);
  for (int i = 1; i <= N; i++) {
    A.push_back(L + i - 1);
  }
  sort(A.begin(), A.end());
  int id = 0, num = abs(A[0]);
  REP(i, A.size()) {
    if (abs(A[i]) < abs(num)) {
      id = i;
      num = A[i];
    }
  }
  int ans = 0;
  REP(i, N) {
    if (i == id) continue;
    ans += A[i];
  }
  cout << ans << endl;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    for (;;) {
        int n; cin >> n;
        int ub = 2000000000, lb = -2000000000;
        if (!n) break;
        vector<string> v(n + 1);
        rep(i, 1, n + 1) cin >> v[i];
        rep(i, 1, n) if (v[i] == v[i + 1] && v[i] == "x") ub = lb - 1;
        rep(i, 1, n + 1) if (v[i] == "x") {
            if (i % 2 == 1) {
                if (i > 1 && v[i - 1] != "x") ub = min(ub, stoi(v[i - 1]) - 1);
                if (i < n && v[i + 1] != "x") ub = min(ub, stoi(v[i + 1]) - 1);
            } else {
                if (i > 1 && v[i - 1] != "x") lb = max(lb, stoi(v[i - 1]) + 1);
                if (i < n && v[i + 1] != "x") lb = max(lb, stoi(v[i + 1]) + 1);
            }
        } else {
            if (i % 2 == 1) {
                if (i > 1 && v[i - 1] != "x" && stoi(v[i]) >= stoi(v[i - 1])) ub = lb - 1;
                if (i < n && v[i + 1] != "x" && stoi(v[i]) >= stoi(v[i + 1])) ub = lb - 1;
            } else {
                if (i > 1 && v[i - 1] != "x" && stoi(v[i]) <= stoi(v[i - 1])) ub = lb - 1;
                if (i < n && v[i + 1] != "x" && stoi(v[i]) <= stoi(v[i + 1])) ub = lb - 1;
            }
        }
        // cout << lb << " " << ub << endl;
        if (ub < lb) {
            cout << "none" << endl;
        } else if (ub == lb) {
            cout << ub << endl;
        } else {
            cout << "ambiguous" << endl;
        }
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    int tmp = 0;
    bool ans = false;
    for(int i = 1;i <= 9;++i){
        if(N % i == 0){
            tmp = N / i;
            if(tmp <= 9)ans = true;
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

}



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

int main() {
    int n; cin >> n;
    int sum = 0;
    int x[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sum += x[i];
    } 
    int p = double(sum*1.0 / n) + 0.5;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += pow((x[i] - p), 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
sl = ["" for _ in range(n)]
for i in range(n):
    sl[i] = input()

m = int(input())
tl = ["" for _ in range(m)]
for i in range(m):
    tl[i] = input()

ans = 0
for blue_word in sl:
    ans = max(ans, (sl.count(blue_word)-tl.count(blue_word)))

print(ans)


Measured memory_bytes: 3060
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

arui = [0]
brui = [0]
for i in range(n):
    arui.append(arui[-1]+a[i])
for i in range(m):
    brui.append(brui[-1]+b[i])

left = 0
right = n+m+1
while left+1 < right:
    mid = (left + right) // 2
    if mid <= n:
        aidx = mid
        bidx = 0
    else:
        aidx = n
        bidx = mid - n
    ok = 0
    while aidx >= 0 and bidx <= m:
        time = arui[aidx] + brui[bidx]
        if time <= k:
            ok = 1
            break
        aidx -= 1
        bidx += 1
    if ok:
        left = mid
    else:
        right = mid

print(left)

Measured memory_bytes: 132644
N = int(input())
S = input()
ans = 0
for i in range(1000):
    res = str(i).zfill(3)
    cnt = 0
    p = res[cnt]
    for s in S:
        if p == s:
            cnt += 1
            if cnt == 3:
                ans += 1
                break
            p = res[cnt]
print(ans)

Measured memory_bytes: 73768
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using ld = long double;
using namespace std;

ld dp[4000][4000];

int main(){
	int n; cin >> n;
	vector<ld> p(n);
	for( auto &k : p ) cin >> k;
	dp[0][0] = 1-p[0];
	dp[0][1] = p[0];
	for( int i = 1; i < n; ++i ){
		for( int j = 0; j <= (i+1); ++j ){
			if( j > 0 ) dp[i][j] += dp[i-1][j-1] * p[i];
						dp[i][j] += dp[i-1][j] * (1-p[i]);
		}
	}
	ld ans = 0.0;
	/*
	for( int j = 0; j <= n-1; ++j ){
		cout << dp[n-2][j] << endl;
	}
	*/
	
	for( int j = 1+(n-n%2)/2; j <= n; ++j ){
		ans += dp[n-1][j];
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 186752
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;

    unordered_map<Int, size_t> hash;
    using pair_type = decltype(hash)::value_type;

    rep(i, 0, N) {
        Int a; cin >> a;

        rep(ai, max(1LL, a-1), a+2) {
            if (hash.find(ai) != hash.end()) ++hash.at(ai);
            else hash[ai] = 1;
        }
    }

    auto maxItr = max_element(hash.begin(), hash.end(),
    [] (const pair_type& a, const pair_type& b) -> bool {
        return (a.second < b.second);
    });

    cout << maxItr->second << endl;
}

Measured memory_bytes: 4260
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // input
            int N = Integer.parseInt(sc.next());
            int ans = 0;
            for (int i = 0; i < N; i++) {
                ans += Integer.parseInt(sc.next()) - 1;
            }
            System.out.println(ans);
        }
    }
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int INF = 100000000;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, a, b, c; cin >> n >> a >> b >> c;
    int l[n];
    for(int i=0;i<n;i++) cin >> l[i];
    int ans = INF;
    for(int bit=0; bit<(1 << (2*n)); bit++){
        int ta = 0, tb = 0, tc = 0;
        int tmp = bit;
        int score = 0;
        for(int i=0;i<n;i++){
            if(tmp %4 == 1){
                if(ta > 0) score += 10; 
                ta += l[i];
            }else if(tmp %4 == 2){
                if(tb > 0) score += 10;
                tb += l[i];
            }else if(tmp %4 == 3){
                if(tc > 0) score += 10;
                tc += l[i];
            }
            tmp /= 4;
        }
        if(ta == 0 || tb == 0 || tc == 0) continue;
        score += abs(ta - a) + abs(tb - b) + abs(tc - c);
        if(score < ans){
            // cout << ta << " " << tb << " " << tc << endl;
        }
        ans = min(score, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int s=sc.nextInt();
    int count=0;
    //for loop to traverse for 0 to k
    for (int x=0;x<=k;x++) {
      for(int y=0;y<=k;y++) {
        int z=s-x-y;
        if(z<=k&&z>=0) {
          count++;
          }
        }
      }
    System.out.println(count);
  }
}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    vector<int> a(N);
    

    int Q; cin >> Q;
    for (int i = 0; i < N; ++i) cin >> a[i];
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21688
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll ans = 0, x = 0;
	int n;
	cin >> n;
	str s;
	cin >> s;
	rep(i, n)
	{
		if (s[i] == 'I')
		{
			x++;
			ans = max(x, ans);
		}
		else
		{
			x--;
			ans = max(x, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>

int main()
{
    int n, x, y;
    scanf("%d %d %d", &n, &x, &y);

    int xx, yy, cnt = 0;
    while (n--)
    {
        scanf("%d %d", &xx, &yy);
        if (xx >= x && yy >= y)
            cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 128
#abc141_d
import heapq

n,m = [int(i) for i in input().split()]
a = [-1 * int(i) for i in input().split()]
heapq.heapify(a)    
#print(a)

for _ in range(m): 
    big = heapq.heappop(a)
    big = int(big/2)    
    heapq.heappush(a, big)
    #print(a)

print(-1*sum(a))


Measured memory_bytes: 14180
#include <cstdio>
#define rep(i,n,m) for(int i = (n); i<(m); i++)

int main(void){
  int n;
  if (!scanf("%d", &n))
    return 0;
  int* array = new int[n]();
  rep(i,1,n+1){
    int input;
    if (!scanf("%d", &input)){
      return 0;
    }
    array[input-1] = i;
  }
  rep(i,0,n){
    printf("%d ", array[i]);
  }
  printf("\n");
  return 0;

}


Measured memory_bytes: 1152
n = int(input())
a = list(map(int, input().split())) 

kabu = 0
money = 1000
for i in range(n):
    if i == n-1:
        money += kabu*a[i]
        kabu = 0
    elif a[i] < a[i+1]:
        if money >= a[i]:
            kabu = money // a[i]
            money = money - a[i]*kabu
    else:
        money += kabu*a[i]
        kabu = 0
    
print(money)

Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define forn(i,a,n) for(int i =a; i < n; i++)
#define fi first
#define se second
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef long long int lli;

int main(){__
    lli n,a,b,c,d,e,f;
    cin >> n;
    cin >> a >> b >> c >> d >> e;
    lli ans = (n)/min({a,b,c,d,e});
    if((n)%min({a,b,c,d,e})) ans++;
    ans+=4;
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int n = 105;

ll M;

int main(){
	ll DC = 0, S = 0;
	cin >> M;
	for(int i = 0; i < M; ++i){
		ll d, c; cin >> d >> c;
		S += d*c; DC += c;
	}
	ll r = DC-1 + S/9 - 1 + ((S%9) > 0);
	cout << r << endl;
}


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

using namespace std;
enum {
	NA = -1, // option is better? C++17
};

struct node {
	int id;
	int parent;
	int right;
	int left;
	int sibling;
	int degree;
	int depth;
	int height;
	string state;

	node():parent(NA),left(NA),right(NA),sibling(NA),degree(NA),depth(NA),height(NA) {
	}
};

void set_depth(vector<node> &v, int id, int depth) {
	v[id].depth = depth;
	if (v[id].left != NA) set_depth(v, v[id].left, depth + 1);
	if (v[id].right != NA) set_depth(v, v[id].right, depth + 1);
	if (v[id].left == NA) // && v[id].right == NA)
		return;
}

int set_height(vector<node> &v, int id) {
	int h1, h2;
	if(v[id].left != NA) h1 = set_height(v, v[id].left) + 1;
	else h1 = 0;
	if (v[id].right != NA) h2 = set_height(v, v[id].right) + 1;
	else h2 = 0;
	return v[id].height = max(h1, h2);
}



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<node> nodes;
	nodes.resize(n);
	node root;

	for (int i = 0; i < n; i++) {
		int id;
		cin >> id;
		nodes[id].id = id; // needed?
		cin >> nodes[id].left >> nodes[id].right;
	}

	// parent setting
	for (int i = 0; i < n; i++) {
		if(nodes[i].left != NA)	nodes[nodes[i].left].parent = nodes[i].id;
		if (nodes[i].right != NA) nodes[nodes[i].right].parent = nodes[i].id;
	}
	// siblings
	for (int i = 0; i < n; i++) {
		if (nodes[i].parent != NA) {
			if (nodes[nodes[i].parent].left != nodes[i].id && nodes[nodes[i].parent].left != NA) 
				nodes[i].sibling = nodes[nodes[i].parent].left;
			else if (nodes[nodes[i].parent].right != nodes[i].id && nodes[nodes[i].parent].right != NA)
				nodes[i].sibling = nodes[nodes[i].parent].right;
		}
		else {
			root = nodes[i];
		}
	}
	// degree
	for (int i = 0; i < n; i++) {
		int degree = 0;
		if (nodes[i].left != NA) degree++;
		if (nodes[i].right != NA) degree++;
		nodes[i].degree = degree;
	}
	// depth
	set_depth(nodes, root.id, 0);

	// height
	set_height(nodes, root.id);

	// state
	for (int i = 0; i < n; i++) {
		if (nodes[i].parent == NA) 
			nodes[i].state = "root";
		else if (nodes[i].left == NA && nodes[i].right == NA)
			nodes[i].state = "leaf";
		else
			nodes[i].state = "internal node";
	}

	for (int i = 0; i < n; i++) {
		cout << "node " << nodes[i].id
			<< ": parent = " << nodes[i].parent
			<< ", sibling = " << nodes[i].sibling
			<< ", degree = " << nodes[i].degree
			<< ", depth = " << nodes[i].depth
			<< ", height = " << nodes[i].height
			<< ", " << nodes[i].state << endl;	
	}

	return 0;
}

Measured memory_bytes: 3192
fn main() {
    let n: usize = {
        let mut n = String::new();
        std::io::stdin().read_line(&mut n).ok();
        n.trim().parse().unwrap()
    };

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let mut line: Vec<String> = line.split_whitespace()
                                   .map(|c|c.to_string())
                                   .collect();
    line.sort();
    line.dedup();
    println!("{}", if n == line.len() { "YES" } else { "NO" });
}

Measured memory_bytes: 16120
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        int[] news = new int[4];
        Arrays.fill(news , 0);
        for(int i = 0 ; i < s.length() ; i++){
            if(s.charAt(i) == 'N') news[0]++;
            if(s.charAt(i) == 'S') news[1]++;
            if(s.charAt(i) == 'W') news[2]++;
            if(s.charAt(i) == 'E') news[3]++;
        }
        boolean ebishu = true;
        if(news[0] == 0 && news[1] != 0){
            ebishu = false;
        }else if(news[0] != 0 && news[1] == 0){
            ebishu = false;
        }else if(news[2] != 0 && news[3] == 0){
            ebishu = false;
        }else if(news[2] == 0 && news[3] != 0){
            ebishu = false;
        }
        if(ebishu){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    n--;
    vector<char> v;
    long long m = 26;
    int count = 0;
    while(1) {
        if(n>=m) {
            n-=m;
            m*=26;
            count++;
        }else {
            break;
        }
    }
    for(int i = 0; i < (count+1); i++) {
        v.push_back(n % 26 + 'a');
        n /= 26;
    }

    for(int i = v.size()-1; i >= 0; i--) {
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3628
#include<cstdio>

int main() {
  int height, width;

  while(true) {
    scanf("%d %d", &height, &width);

    if(height == 0 && width == 0) {
      break;
    }

    for(int i = 0; i < height; i++) {
      for(int j = 0; j < width; j++) {
        printf("#");
      }
      printf("\n");
    }

    printf("\n");
  }
}



Measured memory_bytes: 2600
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	fmt.Scanf("%d %d", &a, &b)
	if isIntegerFrom1To9(a) && isIntegerFrom1To9(b) {

		fmt.Println(a * b)
	} else {
		fmt.Println(-1)
	}
}

func isIntegerFrom1To9(i int) bool {
	if 1 <= i && i <= 9 {
		return true
	}
	return false
}


Measured memory_bytes: 512
N = int(input())
X = list(map(int, input().split()))
ans = 10e9
for i in range(0,max(X)+1):
    tmp = 0
    for j in range(N):
        tmp += (X[j]-i)**2
    if tmp < ans:
        ans = tmp
#    print(tmp)
print(ans)



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  double ans=0;
  ireps(i,1,n){
    ll tmp=i;
    double tmp_a=1.0/n;
    while(tmp<k){
      tmp*=2;
      tmp_a/=2.0;
      // if(i==1) cout<<tmp<<" ";
    }
    ans+=tmp_a;
  }
  coutd(ans);
}

Measured memory_bytes: 256
#再帰関数
N = int(input())
def sft(s):
    if int(s) > N:
        return 0
    cnt = 1 if all(s.count(c)>0 for c in '753') else 0
    for c in '753':
        cnt += sft(s+c)
    return cnt
    
print(sft('0'))

Measured memory_bytes: 55004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int n;
void dod(string s,char c){
    if(s.length()==n){
        cout << s << endl;
        return;
    }
    char d=c+1;
    int z=d-'a';
    rep(i,z){
      string ss=s;
      char x='a'+i;
      ss+=x;
      if(i!=z-1)dod(ss,c);
      else dod(ss,d);
    }
}

int main() {
    cin >> n;
    dod("",'a');

}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int getAbs(int x);

int main(){
    int n;
    cin >> n;
    vector<int> v;
    int vmax = 0;
    for(int i = 0; i < n; i++){
        int vin;
        cin >> vin;
        vmax = max(vmax, vin);
        v.push_back(vin);
    }

    int diffMin = INT32_MAX;
    int vmaxHalf = vmax;
    for(int i = 0; i < n; i++){
        if(diffMin > getAbs(vmax / 2 - v[i])){
            vmaxHalf = v[i];
            diffMin = getAbs(vmax / 2 - v[i]);
        }
    }

    if(vmaxHalf == vmax) vmaxHalf = 0;
    cout << vmax << " " << vmaxHalf << endl;
    return 0;
}

int getAbs(int x){
    return (x > 0)? x : -x;
}

Measured memory_bytes: 892
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    C = Counter(list(map(int, input().split())))

    t = 0
    for k in C.keys():
        t += (C[k] % 2 == 0)

    ans = len(set(C))
    if t % 2 != 0:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20544
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int Maxn = 50;

ll k;
ll a[Maxn];

int main()
{
	cin >> k;
	for (int i = 0; i < Maxn; i++)
		a[i] = Maxn - 1;
	ll add = k / Maxn; k %= Maxn;
	for (int i = 0; i < Maxn; i++)
		a[i] += add;
	for (int i = 0; i < Maxn && k > 0; i++, k--) {
		a[i] += Maxn;
		for (int j = 0; j < Maxn; j++) if (i != j)
			a[j]--;
	}
	cout << Maxn << endl;
	for (int i = 0; i < Maxn; i++)
		cout << a[i] << (i + 1 < Maxn? ' ': '\n');
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

vector<pair<int, ll> > G[100100];
bool C[100100];
bool isvisit[100100];

void dfs(int v, bool color){
    isvisit[v] = true;
    C[v] = color;
    for(int i = 0; i < G[v].size(); i++){
        auto p = G[v][i];
        int next = p.first;
        if(isvisit[next]) continue;
        ll w = p.second;
        bool even = (w%2 == 0);
        if(even) dfs(next, color);
        else dfs(next, !color);
    }
}

int main(){
    int N;
    cin >> N;
    REP(i,N-1){
        int u, v;
        ll w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }

    dfs(0, true);

    REP(i,N){
        bool color = C[i];
        cout << color << endl;
    }

    return 0;
}


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

int main(void)
{
	int n, q, i, j, count = 0;
	int *S, *T;
	
	scanf("%d", &n);
	S = (int*)malloc(n * sizeof(int));
	for(i=0; i<n; i++)
	{
		scanf("%d", &S[i]);
	}
	
	scanf("%d", &q);
	T = (int*)malloc(q * sizeof(int));
	for(i=0; i<q; i++)
	{
		scanf("%d", &T[i]);
	}
	
	for(i=0; i<q; i++)
	{
		for(j=0; j<n; j++)
		{
			if(T[i]==S[j])
			{
				count++;
				break;
			}
		}
	}
	
	printf("%d\n", count);
	
}	


Measured memory_bytes: 2132
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<ll, ll>> XYs(N);
    REP(n, N) cin >> XYs[n].first >> XYs[n].second;

    set<pair<ll, ll>> PQs;
    
    REP(i, N-1) {
        auto xy1 = XYs[i];
        FOR(j, i + 1, N) {
            auto xy2 = XYs[j];
            PQs.insert(mp(xy2.first - xy1.first,
                          xy2.second - xy1.second));
        }
    }

    set<pair<ll, ll>> exist;
    for(auto xy: XYs) {
        exist.insert(xy);
    }

    int max_cnt = 0;
    for(auto pq: PQs) {
        auto p = pq.first;
        auto q = pq.second;

        int cnt = 0;
        for(auto xy: XYs) {
            auto x = xy.first;
            auto y = xy.second;
            
            auto x2 = x + p;
            auto y2 = y + q;
            cnt += (exist.count(mp(x2, y2)));
        }
        max_cnt = max(max_cnt, cnt);
    }

    cout << (N - max_cnt) << endl;

    return 0;
}


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

int main() {
    int a, b, ans = -1;
    cin >> a >> b;
    for(int i = 1; i <= 1000000; i++) {
        if((int)(i * 0.08) == a && (int)(i * 0.10) == b) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  if (n<m) for(int i=0;i<m;i++) cout << n;
  else if (n>m) for(int i=0;i<n;i++) cout << m;
  else  for(int i=0;i<n;i++) cout << m;
  puts("\n");
  
 }

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 211111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

vector<pii> v ;
int ans[N] ;

int main() {
  int n, temp ;
  cin >> n ;

  for(int i = 0 ;i<n ;i++){
    cin >> temp ;
    v.pb(mp(temp,i)) ;
  }

  sort(all(v)) ;

  for(int i = 0 ;i<n ;i++){
    if(i<n/2)ans[v[i].second] =v[n/2].first ; 
    else ans[v[i].second] = v[n/2-1].first ;
  }
  for(int i = 0 ;i<n ;i++)
    cout << ans[i] << endl ;
	
  return 0 ;
}

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

P mp[205];
int main() {
	int N;
	while(scanf("%d",&N),N){
	mp[0]=P(0,0);
	for(int i=1;i<N;i++){
		int n,d;scanf("%d%d",&n,&d);
		switch(d){
			case 0:mp[i]=P(mp[n].first-1,mp[n].second);break;
			case 1:mp[i]=P(mp[n].first,mp[n].second+1);break;
			case 2:mp[i]=P(mp[n].first+1,mp[n].second);break;
			case 3:mp[i]=P(mp[n].first,mp[n].second-1);break;
		}
	}
	int minx=INT_MAX,miny=INT_MAX,maxx=INT_MIN,maxy=INT_MIN;
	rep(i,N){
		minx=min(minx,mp[i].first);
		miny=min(miny,mp[i].second);
		maxx=max(maxx,mp[i].first);
		maxy=max(maxy,mp[i].second);
	}
	printf("%d %d\n",maxx-minx+1,maxy-miny+1);
}
}

Measured memory_bytes: 3140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int main()
{
    int K = in(), T = in();

    vpii a(T);

    rep(i, T) {
        a[i]=MP(in(),i);
    }

    int pre=-1;
    ll ans=0;
    while (a[0].fst > 0) {
        sort(all(a),greater<pii>());

        if (pre==a[0].scd)ans++;
        a[0].fst -= 1;
        pre=a[0].scd;
        if (a[1].fst > 0) {
            a[1].fst-=1;
            pre=a[1].scd;
        }
    }
    printf("%lld\n",ans);
}


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


void solve(long long N, std::vector<long long> A){
    vector<pair<int,int>> tmp(0);
    for(int i=0;i<N;++i){
        tmp.push_back(pair<int,int>(A[i],i));
    }
    sort(tmp.begin(),tmp.end());
    for(int i=0;i<N-1;++i){
        cout<<tmp[i].second + 1<<" ";
    }
    cout<<tmp[N-1].second + 1<<endl;
}


// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2548
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        System.out.println(java.util.stream.Stream.generate(() -> null).limit(scanner.nextInt()).mapToInt(n -> (int)(Math.log(Integer.lowestOneBit(scanner.nextInt())) / Math.log(2))).sum());
    }
}

Measured memory_bytes: 38816
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001


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

void solve(){
    int n;
    cin>>n;
    int a[n];
    vi before(n), after(n);
    rep(i, 0, n) {
        cin>>a[i];
        if(i == 0)
            before[i] = a[i];
        else
            before[i] = gcd(a[i], before[i-1]);
    }
    rev(i, n-1, 0) 
        if(i == n-1)
            after[i] = a[i];
        else
            after[i] = gcd(a[i], after[i+1]);
    int ans = 0;
    rep(i, 1, n-1) {
        ans = max(ans, gcd(before[i-1], after[i+1]));
    }
    cout<<max(ans, (int)max(before[n-2], after[1]))<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 2176
import java.util.*;
class Main{
    static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        dfs("",'a');
    }

    public static void dfs(String s,char ch){
        if(s.length() == n){
            System.out.println(s);
            return;
        }
            
            for(char c = 'a';c<=ch;c++)
                dfs(s+c ,((c == ch)?(char)(ch+1):ch));
    }
}

Measured memory_bytes: 42620
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			String b = sc.next();
			a=a+a;
			int c = a.length();
			int d = b.length();
			String f;
			boolean g=false;
			for(int e=0;e<c-d;++e){
				f=a.substring(e,e+d);
				if(b.equals(f)){
					g=true;
					break;
				}
			}
			if(g){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
	}

}

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

using namespace std;

int main(){
        string x,y,ans;
        cin >> x >> y;
        int lenx,leny;
        lenx = x.size();
        leny = y.size();
        for(int i=0;i<leny;i++){
                ans+=x[i];
                ans+=y[i];
        }
        if(lenx != leny){
                ans += x[lenx-1];
        }
        cout << ans << endl;
        return 0;
        }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[233333];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n,greater<int>());
    long long ans=a[1];
    for(int i=2;i<=n/2;i++)ans+=2*a[i];
    if(n%2)ans+=a[(n+1)/2];
    cout<<ans<<endl;
}


Measured memory_bytes: 4424
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;

int N, W, weights[105];
ll vals[105], dp[100005];


int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> N >> W;
    F0R(i,N) cin >> weights[i+1] >> vals[i+1];

    FOR(i,1,N+1){
        FORd(j,weights[i],W+1){
            dp[j] = max(dp[j], dp[j-weights[i]] + vals[i]);
        }
    }
    cout << dp[W] << newl;










	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class35
    {
        static void Main()
        {
            string S = Console.ReadLine();
            int leng = S.Length;
            string ans = "";
            for(int i = 0; i < leng; i++)
            {
                ans += "x";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int n=0;
	if(a%2!=b%2 || b%2!=c%2 || a%2!=c%2){
		if(a%2==b%2){
			a++;
			b++;
			n++;
		}
		else if(b%2==c%2){
			b++;
			c++;
			n++;
		}else{
			a++;
			c++;
			n++;
		}
	}
	n += (max(max(a,b),c)-a)/2;
	n += (max(max(a,b),c)-b)/2;
	n += (max(max(a,b),c)-c)/2;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 int L = scan.nextInt();
		 
		 int min_abs_taste = L;
		 int apple_pie_taste = 0;
		 
		 for (int i = 0; i < N; i++ ) {
			 apple_pie_taste += L + i;
			 
			 if (Math.abs(L + i) <= Math.abs(min_abs_taste)) {
				min_abs_taste = L + i; 
			 }
		 }
		
		 System.out.println(apple_pie_taste - min_abs_taste);
		 
		 scan.close();
		 
	}

}


Measured memory_bytes: 22996