akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int team_num, prob_num, R;
    while(scanf("%d%d%d", &team_num, &prob_num, &R) && team_num){
        bool ac[team_num][prob_num];
        rep(i, team_num)rep(j, prob_num) ac[i][j] = false;
        vector<int> cnt(team_num, 0);
        vector<lint> penalty(team_num, 0);
        lint wa_cnt[team_num][prob_num];
        rep(i, team_num)rep(j, prob_num) wa_cnt[i][j] = 0;

        rep(_, R){
            int tID, pID, time; string message;
            cin >> tID >> pID >> time >> message;
            --tID; --pID;
            if(ac[tID][pID]) continue;
            else if(message == "CORRECT"){
                ac[tID][pID] = true;
                ++cnt[tID];
                penalty[tID] += wa_cnt[tID][pID] * 1200 + time;
            }
            else{
                ++wa_cnt[tID][pID];
            }
        }

        int id[team_num];
        rep(i, team_num) id[i] = i;
        sort(id, id+team_num, [&](const int &i, const int &j){
            if(cnt[i] == cnt[j]){
                if(penalty[i] == penalty[j]) return i < j;
                else return penalty[i] < penalty[j];
            }
            else return cnt[i] > cnt[j];
        });
        rep(i, team_num) printf("%d %d %lld\n", id[i]+1, cnt[id[i]], penalty[id[i]]);
    }
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int a, b;
    cin >> a >> b;
    if (a == 3) {
        if ( b == 1) cout << 2 << endl;
        else if ( b == 2) cout << 1 << endl;

    } else if ( a == 2) {
        if ( b == 1) cout << 3 << endl;
        else if ( b == 3) cout << 1 << endl;
    } else {
        if ( b == 2) cout << 3 << endl;
        else if ( b == 3) cout << 2 << endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}

int gcd(int x, int y){
  return x == 0 ? y : gcd(y%x,x);
}

int main()
{
  int N,X,x[100001],d;
  cin >> N >> X;
  REP(i,N)cin >> x[i];
  REP(i,N)x[i] = abs(x[i]-X);
  d = x[0];
  REP(i,N){
    d = gcd(d,x[i]);
  }
  cout << d << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ((abs(b - a) <= d && abs(c - b) <= d) || (abs(a - c) <= d)) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


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

int main(void)
{
	int n;   //イニング数
	int k=0;
	char SET[8];
	int sum1[50] = {0};
	int sum2 = 0, sum3 = 0;

	scanf("%d", &n);

	while(n){
		scanf("%s", SET);
		if(! strcmp(SET, "HIT")){
			sum3++;
			if(sum3 >= 4){
				sum1[k]++;
				sum3--;
			}

		}else if(! strcmp(SET,"HOMERUN")){
			sum1[k] += sum3;
			sum1[k]++;
			sum3 = 0;

		}else if(! strcmp(SET,"OUT")){
			sum2++;
		}

		if(sum2 == 3){
			sum3 = 0;
			sum2 = 0;
			k++;
			n--;
		}
	}

	for(n = 0; n < k; n++){
		printf("%d\n", sum1[n]);
	}



	return 0;
}


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

int main() {
    int n; cin >> n;
    map<int, int> cnt;
    while (n--) {
        int a; cin >> a;
        cnt[a]++;
    }
    vector<long long> v;
    for (auto &p: cnt) {
        for (int i = 0; i < p.second / 2; i++) v.emplace_back(p.first);
    }
    if (v.size() < 2) return !(cout << 0 << endl);
    sort(v.rbegin(), v.rend());
    cout << v[0] * v[1] << endl;
    return 0;
}


Measured memory_bytes: 4992
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            int n = in.nextInt();
            TreeSet<Segment> set = new TreeSet<>();
            Segment query = new Segment(0, -1);
            set.add(new Segment(0, 0));
            for (int i = 0; i < n; i++) {
                query.l = in.nextInt();
                Segment res = set.floor(query);
                if (res == null) {
                    out.println("No");
                    continue;
                }
                out.println("Yes");
                if (res.r < query.l) {
                    Segment seg = new Segment(res.r + 1, query.l);
                    res.r--;
                    if (!res.isValid()) set.remove(res);
                    set.add(seg);
                } else {
                    set.remove(res);
                    Segment left = new Segment(res.l, query.l - 1);
                    Segment right = new Segment(query.l + 1, res.r);
                    if (left.isValid()) set.add(left);
                    if (right.isValid()) set.add(right);
                }
            }
        }
    }

    private static class Segment implements Comparable<Segment> {
        int l, r;

        Segment(int l, int r) {
            this.l = l;
            this.r = r;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            Segment segment = (Segment) o;

            if (l != segment.l) return false;
            return r == segment.r;
        }

        @Override
        public int hashCode() {
            int result = l;
            result = 31 * result + r;
            return result;
        }

        @Override
        public int compareTo(Segment o) {
            return Integer.compare(l, o.l);
        }

        boolean isValid() {
            return l <= r;
        }
    }
}



Measured memory_bytes: 164444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};


class Edge {
    public:
    int source, target;
    ll cost;
    Edge(int source=0, int target=0, ll cost=0):
    source(source), target(target), cost(cost){}
    bool operator < (const Edge &e) const{
        return cost < e.cost;
    }
};

int kruskal(int N, vector<Edge> edges){
    ll totalCost = 0;
    sort(edges.begin(), edges.end());

    UnionFind uni(N);
    for(int i=0; i<edges.size(); i++){
        Edge e=edges[i];
        if(uni.root(e.source) != uni.root(e.target)){
            totalCost += e.cost;
            uni.connect(e.source, e.target);
        }
    }

    return totalCost;
}

typedef tuple<ll, ll, int> T;

int main(){
    int N; cin >> N;
    vector<T> xy(N), yx(N);
    for(int i=0; i<N; ++i){
        ll x, y; cin >> x >> y;
        xy[i] = make_tuple(x, y, i);
        yx[i] = make_tuple(y, x, i);
    }

    sort(xy.begin(), xy.end());
    sort(yx.begin(), yx.end());

    vector<Edge> edges;
    for(int i=1; i<N; ++i){
        ll x1, y1, x2, y2; int id1, id2;
        tie(x1, y1, id1) = xy[i];
        tie(x2, y2, id2) = xy[i-1];
        edges.push_back(Edge(id2, id1, abs(x1-x2)));

        tie(y1, y2, id1) = yx[i];
        tie(y2, x2, id2) = yx[i-1];
        edges.push_back(Edge(id2, id1, abs(y1-y2)));
    }

    cout << kruskal(N, edges) << endl;

    return 0;
}

Measured memory_bytes: 12524
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){ return b ? gcd(b, a%b): a;}
ll lcm(ll a, ll b){ return a / gcd(a,b) * b;}

int main (){
	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	vector<int> ans(n);
	rep(sv, n){
		vector<int> dist(n, INF);
		queue<int> q;
		auto push = [&](int v, int d){
			if(dist[v] < d) return;
			dist[v] = d;
			q.push(v);
		};

		push(sv, 0);
		while(!q.empty()){
			int v = q.front(); q.pop();
			int d = dist[v];
			if(v-1 >= 0) push(v-1, d+1);
			if(v+1 <= n-1) push(v+1, d+1);
			if(v == x) push(y, d+1);
			if(v == y) push(x, d+1);
		}
		rep(i, n) ans[dist[i]]++;

	}
	rep(i, n) ans[i] /= 2;
	for(int i = 1; i <= n-1; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main(){
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

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

using ll = long long;
using cd = complex<double>;

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

    int n;
    cin >> n;

    vector<int> tt(n);
    map<int, int> frecv;

    for(auto& x : tt)
        cin >> x,
        ++frecv[x];

    if(tt[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    ll ret = 1;
    const ll mod = 998244353;

    for(int i = 1; i < n; ++i)
        ret = (ret * frecv[tt[i] - 1]) % mod;

    cout << ret << endl;




    return 0;
}



Measured memory_bytes: 5376
x ,k , d  = map(int, input().split(" "))

low = (x-k*d)//(2*d)
high = (x+k*d)//(2*d)
amari = (x+k*d)%(2*d)

if high < 0:
  print(abs(x+k*d))
elif low >= 0:
  print(abs(x-k*d))
else:
  print(min(abs(amari-2*d),abs(amari)))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll modpow(ll n, ll x, ll MOD){
	ll ret = 1;
	while(x){
		if(x&1){
			(ret*=n)%=MOD;
		}
		x >>= 1;
		(n*=n)%=MOD;
	}
	return ret;
}
int solve(int k, int MOD){
	if(__gcd(10, MOD) != 1){
		return -1;
	}
	for(int i = 1; i <=k; ++i){
		if(modpow(10, i, MOD) == 1){
			return i;
		}
	}
}
int main(){
	int k;
	cin >> k;
	if(k%7 == 0){
		cout << solve(k, 9*(k/7));
	}
	else{
		cout << solve(k, 9*k);
	}
}


Measured memory_bytes: 3588
a = input()
if a[0] == "R":
    if a[1] == "R":
        if a[2] == "R":
            print("3")
        else:
            print("2")
    else:
        print("1")
elif a[1] == "R":
    if a[2] == "R":
        print("2")
    else:
        print("1")
elif a[2] == "R":
    print("1")
else:
    print("0")

Measured memory_bytes: 9116
#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

void proc(int t, string num) {
    map<int, vector<vector<string>>> m;
    for (int i = 0; i < (1 << num.length() - 1); i++) {
        vector<string> parts;
        string buf;
        for (int j = 0; j < num.length(); j++) {
            buf += num[j];
            if (i & (1 << j)) {
                parts.push_back(buf); buf = "";
            }
        }
        if (buf.size()) parts.push_back(buf);
        // if (any_of(all(parts), [](string s) {return s.size() != 1 && s.front() == '0';})) {
        //     continue;
        // }
        int sum = 0;
        for (auto s : parts) sum += stoi(s);
        if (sum > t) continue;
        m[sum].push_back(parts);
    }
    if (m.empty()) {
        cout << "error" << endl;
    } else if (m.rbegin()->second.size() > 1) {
        cout << "rejected" << endl;
    } else {
        auto p = m.rbegin()->second.front();
        cout << m.rbegin()->first << " ";
        for (int i = 0; i < p.size(); i++) {
            cout << p[i] << " \n"[i + 1 == p.size()];
        }
    }
}

int main() {
    for (;;) {
        int t, num; cin >> t >> num;
        if (!t && !num) break;

        proc(t, to_string(num));
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    ll H; cin >> H;

    ll count = 0;
    while (H > 0){
        H /= 2;
        count++;
    }
    count--;
    if(count==0){
        cout << 1 << endl;
        return 0;
    }
    ll ans = 2;
    while (count > 0){
        ans *= 2;
        count--;
    }
    ans -= 1;
    cout << ans << endl;
}


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

int main(){
    set<int> s;
    int q, op, x;
    cin >> q;

    while(q-- > 0){
        cin >> op >> x;
        if(op == 0){
            s.insert(x);
            cout << s.size() << endl;
        }else{
            cout << s.count(x) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 12476
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<algorithm>
 */
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    int a, b, c, d;
    scanf("%1d%1d%1d%1d", &a, &b, &c, &d);
    int i = 8;
    while (i--) {
        if (a + (i / 4 % 2 ? -b : b) + (i / 2 % 2 ? -c : c) + (i % 2 ? -d : d) == 7) {
            char p[] = {'+', '-'};
            printf("%d%c%d%c%d%c%d=7\n", a, p[i / 4 % 2], b, p[i / 2 % 2], c, p[i % 2], d);
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<int> L(2 * N); rep(i, 0, 2 * N)cin >> L[i];
	sort(L.begin(), L.end());
	int ans = 0;
	for (int k = 0; k < 2 * N; k += 2)ans += L[k];
	cout << ans << endl;

	return 0;
}

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

using namespace std;

long f[222222] = { 1 }, g[222222], d[3333][3333], p = 1e9 + 7;
pair<int, int> a[3333];
inline long inv(int a, int m) {
	long i = 1, j = 0;
	for (int b = m; a > 1; swap(i, j), swap(a, b)) {
		j = (j + b / a * (m - i)) % m;
		b %= a;
	}
	return i;
}
inline int c(int x, int y) {
	return f[x + y] * (g[x] * g[y] % p) % p;
}
int main() {
	int h, w, n;
	cin >> h >> w >> n;
	for (int i = 0; i < h + w; i++)
		f[i + 1] = f[i] * (i + 1) % p;
	g[h + w] = inv(f[h + w], p);
	for (int i = h + w; i; i--)
		g[i - 1] = g[i] * i%p;
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a, a + n);
	a[n] = { h,w };
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < i; j++) {
			d[i][j + 1] = d[i][j];
			if (a[i].second >= a[j].second)
				(d[i][j + 1] += c(a[i].first - a[j].first, a[i].second - a[j].second)*(c(a[j].first - 1, a[j].second - 1) - d[j][j] + p)) %= p;
		}
	}
	cout << (c(h - 1, w - 1) - d[n][n] + p) % p << endl;
	return 0;
}


Measured memory_bytes: 83840
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define ld double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    a%=mod;
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll n;
    cin>>n;
    ll a[n];
    for(int x=0;x<n;x++)cin>>a[x];
    sort(a,a+n);
    ll i=n-2;
    ll su=a[n-1];
    for(int x=n-2;x>=0;x--)
    {
        if(i==0)break;
        su+=a[x];
        --i;
        if(i==0)break;
        su+=a[x];
        --i;
    }
    cout<<su;
}


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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 = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, m; cin >> n >> m;
    Graph g(n);
    REP(i, m){
        ll a, b; cin >> a >> b;
        g[a-1].pb(b-1); g[b-1].pb(a-1);
    }

    bool flag = false; ll cnt = 0;
    for(auto x : g[0]){
        for(auto y : g[x]){
            if(y == n-1) flag = true;
        }
    }
    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

Measured memory_bytes: 12016
#include <iostream>

using namespace std;

struct State {
    char cur;
    State() {
        this->cur = 'A';
    }
    bool move(int n) {
        switch (cur) {
            case 'A':
                switch (n) {
                    case 0:
                        cur = 'X';
                        break;
                    case 1:
                        cur = 'Y';
                        break;
                    default:
                        return false;
                }
                break;
            case 'X':
                if (n == 1) {
                    cur = 'Z';
                } else {
                    return false;
                }
                break;
            case 'Y':
                if (n == 0) {
                    cur = 'X';
                } else {
                    return false;
                }
                break;
            case 'Z':
                switch (n) {
                    case 0:
                        cur = 'W';
                        break;
                    case 1:
                        cur = 'B';
                        break;
                    default:
                        return false;
                }
                break;
            case 'W':
                switch (n) {
                    case 0: 
                        cur = 'B';
                        break;
                    case 1:
                        cur = 'Y';
                        break;
                    default:
                        return false;
                }
                break;
            case 'B':
                switch (n) {
                    case 0:
                        cur = 'Y';
                        break;
                    case 1:
                        cur = 'X';
                        break;
                    default:
                        return false;
                }
                break;
            default:
                return false;
        }
        return true;
    }
};

int main() {
    string s;
    while (cin >> s, s != "#") {
        State st;
        for (int i = 0; i < s.size(); i++) {
            if (!st.move(s[i] - '0')) {
                cout << "No" << endl;
                goto end;
            }
        }
        cout << (st.cur == 'B' ? "Yes" : "No") << endl;
end:;
    }
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = a - b*2;
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
g = [[] for _ in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append([b-1, i])
    g[b-1].append([a-1, i])

que = deque()
que.append([0, 0])

watch = [False] * n
watch[0] = True
color = [0] * (n-1)

while que:
    i, prev_color = que.popleft()
    watch[i] = True
    max_color = 1
    for next, index in g[i]:
        if watch[next]: continue
        watch[next] = True
        if max_color == prev_color:
            max_color += 1
        que.append([next, max_color])
        color[index] = max_color
        max_color += 1

print(max(color))
for ans in color:
    print(ans)


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

int main()
{
    int a, b, c, x, cnt = 0;
    
    cin >> a >> b >> c;
    
    for(x = a; x <= b; x++) {
        if(!(c%x)) cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
    
}


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

vector<string> r1(vector<string> s) {
  vector<string> t = s;
  t[0] = s[0];
  t[1] = s[5];
  t[5] = s[3];
  t[3] = s[1];
  t[4] = s[2];
  t[2] = s[6];
  t[6] = s[4];
  t[7] = s[7];
  return t;
}

vector<string> r2(vector<string> s) {
  vector<string> t = s;
  t[0] = s[1];
  t[1] = s[2];
  t[2] = s[3];
  t[3] = s[0];
  t[4] = s[5];
  t[5] = s[6];
  t[6] = s[7];
  t[7] = s[4];
  return t;
}

vector<string> r3(vector<string> s) {
  vector<string> t = s;
  t[0] = s[5];
  t[5] = s[0];
  t[1] = s[4];
  t[4] = s[1];
  t[2] = s[7];
  t[7] = s[2];
  t[3] = s[6];
  t[6] = s[3];
  return t;
}

int main() {
  for(string s; cin >> s; ) {
    vector<string> v(8, s);
    for(int i = 1; i < 8; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    set<vector<string> > s;
    int res = 0;
    do {
      if(s.count(v)) continue;
      ++res;
      for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < 4; ++j) {
          for(int k = 0; k < 3; ++k) {
            s.insert(v);
            v = r1(v);
          }
          v = r2(v);
        }
        v = r3(v);
      }
    } while(next_permutation(v.begin(), v.end()));
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 6872
n,k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
minus = []
zero = 0
plus = []
for i in a:
    if i < 0:
        minus.append(i)
    elif i == 0:
        zero += 1
    else:
        plus.append(i)
minus.sort()
plus.sort(reverse=True)
len_plus = len(plus)
len_minus = len(minus)
if len_plus + len_minus < k:
    print(0)
    exit()
elif len_plus + len_minus == k:
    ans = 1
    for i in a:
        ans *= i
        ans %= mod
    print(ans)
    exit()
elif len_plus == 0:
    if k % 2:
        if zero:
            print(0)
        else:
            ans = 1
            cnt = 0
            for i in minus[::-1]:
                if cnt == k:
                    break
                ans *= i
                ans %= mod
                cnt += 1
            print(ans)
    else:
        ans = 1
        for i in minus[:k]:
            ans *= i
            ans %= mod
        print(ans)
    exit()
ans = 1
pl = min(k,len_plus - (k-len_plus) % 2)
mi = k-pl
for i in plus[:pl]:
    ans *= i
    ans %= mod
for i in minus[:k-pl]:
    ans *= i
    ans %= mod
for i in range(0,len_minus+1,2):
    if mi+i+1 >= len_minus or pl-i-2 < 0:
        break
    MINUS = minus[mi+i] * minus[mi+i+1]
    PLUS = plus[pl-i-1] * plus[pl-i-2]
    if MINUS < PLUS:
        break
    ans = (ans * MINUS * pow(PLUS, mod-2, mod)) % mod
print(ans)

Measured memory_bytes: 109008
/*
 * atcoder/abc145_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

template<class T> struct BiCoef {
    vector<T> fact_, inv_, finv_;
    constexpr BiCoef() {}
    constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
        init(n);
    }
    constexpr void init(int n) noexcept {
        fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
        for(int i = 2; i < n; i++){
            fact_[i] = fact_[i-1] * i;
            inv_[i] = -inv_[MOD%i] * (MOD/i);
            finv_[i] = finv_[i-1] * inv_[i];
        }
    }
    constexpr T com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fact_[n] * finv_[k] * finv_[n-k];
    }
    constexpr T fact(int n) const noexcept {
        if (n < 0) return 0;
        return fact_[n];
    }
    constexpr T inv(int n) const noexcept {
        if (n < 0) return 0;
        return inv_[n];
    }
    constexpr T finv(int n) const noexcept {
        if (n < 0) return 0;
        return finv_[n];
    }
};

/*
 * op個の(1, 2), (2, 1)を組み合わせて(x, y)を作る組み合わせ数を求める問題.
 * 一度のopでx+yは3増えるので、
 * op = (x+y)/3
 * このうち(1, 2)の個数をaとするとb=op-aなので、aで全探索
 * a + 2 * b = x and 2 * a + b = yでなければ0.
 * opCa
 */
int x, y, op;
BiCoef<mint> bc;
void solve() {
  cin >> x >> y;
  if ((x+y)%3!=0) {
    cout << 0 << endl;
    return;
  }
  op = (x + y) / 3;
  bc.init(op+1);
  mint total = 0;
  for (int a=0; a<=op; a++) {
    int b = op-a;
    if (a + 2 * b != x or 2 * a + b != y) continue;
    total += bc.com(op, a);
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
long long h,w,tot;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w;
	if((h==1)||(w==1)){
		cout<<1<<endl;
		return 0;
	}
	tot=(h/2LL)*w;
	if(h%2LL==1LL)
		tot+=(long long)(w+1)/2LL;
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 int main() {
 long long A, B;
 cin >> A >> B;
 if(A % 2 != B % 2) {
 cout << "IMPOSSIBLE" << endl;
 } else {
 cout << (A + B) / 2 << endl;
 }
 return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int a[100];
int cnt[101];

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) cnt[a[i]]++;
    sort(a, a+n);
    int M = a[n-1];
    if (a[0] < (M+1)/2) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (M%2 == 0) {
        if (cnt[M/2] != 1) {
            cout << "Impossible" << endl;
            return 0;
        }
    } else {
        if (cnt[(M+1)/2] != 2) {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    for (int i = (M+1)/2+1; i <= M; i++) {
        if (cnt[i] < 2) {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llt long long int
using namespace std;
const int mod = 1e9 + 7;
int main()
{
 	int a;
 	scanf("%d",&a);
 	int dp[2001];
 	dp[0] = 1;
 	for(int i = 1; i <= a; ++i)
 	{
 		llt t = 0;
 		for(int j = 3; j <= i; ++j)
 		{
 			t+=dp[i-j];
 		}
 		dp[i] = t%mod;
 	}
 	printf("%d\n", dp[a]);
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  while(1){
  int n,x; cin >> n >> x;
  if(n==0 && x==0) break;
  int ans = 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) ans++;
      }
    }
  }
  cout << ans << endl;
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    char s;
    cin >> a >> s >> b;
    if (s == '+') {
        cout << a + b;
    } else {
        cout << a - b;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from collections import deque
def dfs(root):
    visited = [False] * n
    queue = deque([(0, root)])
    longest = (-1, -1)
    while queue:
        total_weight, node = queue.popleft()
        if visited[node]:
            continue
        visited[node] = True
        longest = max(longest, (total_weight, node))
        for w, t in edges[node]:
            if not visited[t]:
                queue.append((total_weight + w, t))
    return longest
n = int(readline())
edges = [set() for _ in range(n)]
for _ in range(n - 1):
    s, t, w = map(int, readline().split())
    edges[s].add((w, t))
    edges[t].add((w, s))
_, ln = dfs(0)
ld, _ = dfs(ln)
print(ld)

Measured memory_bytes: 58016
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cassert>

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define rep(i, N) for (i=0;i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;


int main() {
	int N;
	int64_t min=inf, max=-inf;
	cin >> N;

	int i;
	rep(i, N) {
		int64_t t;
		cin >> t;
		if (t < min) min = t;
		if (t > max) max = t;
	}

	cout << llabs(min-max) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue
#include <stack>			//std::stack

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	int n = 0, q = 0;
	std::cin >> n >> q;
	std::queue<std::string> Qname;
	std::queue<int> Qtime;
	std::vector<std::string> Aname;
	std::vector<int> Atime;

	for (int i = 0; i < n; i++) {
		std::string name;
		int time = 0;
		std::cin >> name >> time;
		Qname.push(name);
		Qtime.push(time);
	}

	int total = 0;
	while (!Qname.empty()) {
		if (Qtime.front() - q > 0) {
			Qtime.push(Qtime.front() - q);
			Qtime.pop();
			Qname.push(Qname.front());
			Qname.pop();
		}
		else {
			Atime.push_back(Qtime.front() + total);
			total += Qtime.front() - q;
			Qtime.pop();
			Aname.push_back(Qname.front());
			Qname.pop();
		}
		total += q;
	}

	for (int i = 0; i < n; i++) {
		std::cout << Aname[i] << " " << Atime[i] << std::endl;
	}

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int x;

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

  scanf("%d", &x);
  if(x >= 30)
    puts("Yes");
  else 
    puts("No");



  return 0;
}


Measured memory_bytes: 3744
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i in range(N):
    if i-1>=0:
        dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i-2>=0:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

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

int main() {
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  vector<int>num(26);
  for(int i=0;i<26;i++) num[i]=50;
  for(int i=0;i<n;i++){
    vector<int>sub(26);
    int l=s[i].size();
    for(int j=0;j<l;j++) sub[s[i][j]-'a']++;
    for(int j=0;j<26;j++) num[j]=min(num[j],sub[j]);
  }
  for(int i=0;i<26;i++){
    char x='a'+i;
    for(int j=0;j<num[i];j++) cout<<x;
  }   
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// ダブリング見様見真似実装
// https://www.hamayanhamayan.com/entry/2019/08/07/204315

func main() {
	S := nextLine()
	N := len(S)
	ans := make([]int, N)
	dp := make([][]int, 18)
	for i := 0; i < 18; i++ {
		dp[i] = make([]int, N+1)
	}
	// 1回移動したときの移動先マスの位置
	for i := 0; i < N; i++ {
		if S[i] == 'R' {
			dp[0][i] = i + 1
		}
		if S[i] == 'L' {
			dp[0][i] = i - 1
		}
	}
	// i回移動したときのマス
	// 高々10^5文字で、途中でループするので、偶数回でかつ10^5より大きくなった段階で切る
	for i := 0; i < 17; i++ {
		for j := 0; j < N; j++ {
			dp[i+1][j] = dp[i][dp[i][j]]
		}
	}
	for i := 0; i < N; i++ {
		ans[dp[17][i]]++
	}
	// fmt.Println(dp)
	fmt.Println(strings.Trim(fmt.Sprint(ans), "[]"))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 20000
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;

typedef long long LL;
typedef double DL;

const int INF = 2147483647;

int n,ans;

inline int getint()
{
    int ret = 0,f = 1;
    char c = getchar();
    while (c < '0' || c > '9') 
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
        ret = ret * 10 + c - '0',c = getchar();
    return ret * f;
}

int main()
{
    #ifdef AMC
        freopen("AMC1.txt","r",stdin);
//        freopen("AMC2.txt","w",stdout);
    #endif
    n = getint();
    for (int i = 1; i <= n; i++)
    {
    	int x = getint();
    	while (x % 2 == 0)
    	{
    		ans++;
    		x /= 2;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
while True:
  n = int(input())
  if n == 0:
    break
  a = 0
  max_c = -200000
  while n > 0:
    i = int(input())
    a += i
    if max_c < a:
      max_c = a
    if a <= 0:
      a = 0
    n -= 1
  print(max_c)

Measured memory_bytes: 7576
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {       
                    String line = reader.readLine();
                    String[] strAry = line.split(" ");
                    int a = Integer.parseInt(strAry[0]);
                    int b = Integer.parseInt(strAry[1]);
                    int c = Integer.parseInt(strAry[2]);

                    int d = 0, e = 0;

                    if(a > b){
                        d = a;
                        a = b;
                        b = d;
                    }

                for(int i = a; i <= b; i++){
                    if(c % i == 0){
                        e += 1;
                    }
                }

                System.out.println(e);
                
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,i; 
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  int j,count=0,maxi=a.at(0);
  for(i=0;i<n;i++){
    if(maxi>=a.at(i)){
      count++;
      maxi=a.at(i);
    }
  }
  cout << count;
}

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

int main(void){
    long int x, i, max = 0, count = 0;

    cin >> x;
    long int h[x];

    for(i = 0; i < x ; i++)
        cin >> h[i];

    for(i = 0; i < x-1; i++){
        if(h[i] >= h[i+1]){
            count++;
        }else{
            count = 0;
        }

        if(count > max)
            max = count;
    }

    printf("%ld", max);
}


Measured memory_bytes: 1024
N, L = gets.chomp.split(" ").map{|str| str.to_i}
a = gets.chomp.split(" ").map{|str| str.to_i}
possible = false
final = 0
for i in 0..N-2
	if a[i] + a[i + 1] >= L
		possible = true
		final = i + 1
	end
end
if possible
	puts "Possible"
	(1..final - 1).each{|i| puts i}
	(final..N - 1).reverse_each{|i| puts i}
else
	puts "Impossible"
end

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

int main() {
  int n,d,x;
  cin>>n>>d>>x;

  int c = 0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    c += (d-1)/a + 1;
  }

  cout << c + x << endl;

  return 0;
}


Measured memory_bytes: 256
#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;
    ll FULL = 1'000'000'000'000'000'000;
    
    
    bool zeroflg = false;
    vector<ll> A;
    rep(i,N){
        ll x;
        cin >> x;
        if(x==0) zeroflg=true;
        A.push_back(x);

    }
    
    if(zeroflg){
        //cout << "0" << endl;
        cout << 0 << endl;
        return 0;
    }
    
    ll ans=1;
    bool ansflg = true;
    rep(i,N){
        //ll ret = ans;
        ans *= A[i];
        if(ans > FULL || ans%A[i] != 0 || ans < A[i]){
            ansflg = false;
            break;
        }
    }
    
    if(ansflg){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    
}


Measured memory_bytes: 4320
#include <string>
#include <functional>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <numeric>

using namespace std;
#define pi 3.14159265

int gcd(int m, int n)
{
	// 引数に０がある場合は０を返す
	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, M, n, m;
	string S, T;
	cin >> N >> M;
	cin>>S >> T;

	long long L = 0;
	L = N*M/gcd(N, M);
	n = L / N;
	m = L / M;
	j = n*m / gcd(n, m);

	for (i = 0; i < L/j; i++) {
		if(S[i*m])
		if ((S[i*m] != T[i*n])&&T[i*n]) {
			cout << -1 << endl; return 0;
		}
	}

	cout << L << endl;
	return 0;
}

Measured memory_bytes: 512
package main 

import (
        "fmt"
        "strconv"
)

func main () {
        var a, b, s string
        var an, x  int
        fmt.Scan(&a,&b)
        s = a + b
        x, _ = strconv.Atoi(s)
        for i := 1 ; i < x ; i++ {
                ii := i * i
                if x  ==  ii {
                        an += 1 
                        break 
                }
        }
        if an != 0 {
                fmt.Println("Yes")
        }  else if  an == 0 {
                fmt.Println("No")
        }
}


Measured memory_bytes: 512