akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

bool v[1145143];
int main() {
  ll s;
  cin >> s;

  for (int i = 1;; i++) {
    v[s] = 1;
    if (s % 2 == 0)
      s /= 2;
    else
      s = 3 * s + 1;
    if (v[s] == 1) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

len_1 = len([a for a in A if a % 2 == 1])
len_4 = len([a for a in A if a % 4 == 0])

if len_1 <= len_4:
    print('Yes')
elif len_1 + len_4 == len(A) and len_1 == len_4 + 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15020
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

S = input()
T = S[:len(S)//2]
U = S[len(S)//2+1:]
c = 3

def kaibun(L, c):
  for i in range(len(L)//2):
    if L[i] != L[-(i+1)]:
      c -= 1
      print("No")
      exit()
      
kaibun(S, c)
kaibun(T, c)
kaibun(U, c)

if c == 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 13680
#include<stdio.h>
int n;
int list[200001];
long long int abs(long long int x) { return x<0 ? -x : x; }
int main() {
	while (scanf("%d", &n) != EOF) {
		long long int sum = 0;
		for (int i = 0; i<n; i++) {
			scanf("%d", &list[i]);
			sum += list[i];
		}
		long long int sumi = 0;
		long long int ans =1e18;
		for (int i = 0; i<n-1; i++) {
			sumi += list[i];
			long long int tmp = abs(sum - 2 * sumi);
			if (tmp<ans)  ans = tmp;
		}
		printf("%I64d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 896
def solve(N, A, B):
    ans = sum(A)
    for i, attack in enumerate(B):
        delta = min(A[i], attack)
        A[i] -= delta
        attack -= delta
        delta = min(A[i+1], attack)
        A[i+1] -= delta
    return ans - sum(A)

N = int(raw_input())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
print solve(N, A, B)


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Array.ConvertAll(Console.ReadLine().Split(' '), 
               new Converter<string, int>(int.Parse));

        if (inputs.All(v => v >= 1 || v <= 9))
        {
            if(inputs.Distinct().Count() == 2)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13276
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,k;
    cin >> n >> k;
    int A[n];
    REP(i,n) cin >> A[i];
    bool dp[k+1];
    REP(i,A[0]) dp[i] = false;
    FOR(i,A[0],k+1){
        bool flag = false;
        REP(j,n){
            if(i < A[j]) break;
            else{
                if(dp[i - A[j]] == false){
                    flag = true;
                    break;
                }
            }
        }
        dp[i] = flag;
    }

    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;

} 

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b;
	cin>>a>>b;
	if(a<=8 && b<= 8)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int N; cin >> N;

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			for (int k = j+1; k < N; k++) {
				int a = L[i];
				int b = L[j];
				int c = L[k];
				if (a < b + c and b < a + c and c < b + a and a != b and b != c and c != a) {
					ans++;	
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int h, w;
	cin >> h >> w;
	bool ans = false;
	int g = 0;
	whei(char) a(h, hei(char)(w));
	rep(i, 0, h)rep(j, 0, w) {
		cin >> a[i][j];
		if (a[i][j] == '#')g++;
	}
	int dx[2] = { 1,0 };
	int dy[2] = { 0,1 };
	whei(bool) d(h, hei(bool)(w, false));
	d[0][0] = true;
	queue<Pint> que;
	que.push(Pint(0, 0));
	while (!que.empty()) {
		Pint P = que.front();
		que.pop();
		rep(i, 0, 2) {
			int Nx = P.first + dx[i];
			int Ny = P.second + dy[i];
			if (Nx >= h || Ny >= w)continue;
			if (a[Nx][Ny] == '.' || d[Nx][Ny] == true)continue;
			que.push(Pint(Nx, Ny));
			d[Nx][Ny] = true;
		}
	}
	if (d[h-1][w-1]&&g==h+w-1)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const LL inf = 1e15;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,W;
    while (cin >> n >> W) {
        vector<LL> w(n),v(n);
        int maxv = 0;
        FOR(i,0,n) {
            cin >> w[i] >> v[i];
            maxv += v[i];
        }
        vector<LL> dp(maxv+1,inf);
        dp[0] = 0;
        FOR(i,0,n) FORR(j,maxv,v[i]-1) if (dp[j-v[i]] != inf)
            dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
        int ans = 0;
        FOR(i,0,maxv+1) if (dp[i] <= W)
            ans = i;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fname "C"
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << '}' << endl;}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}" << endl;}
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<ll, ii> lii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int N = 200002;
int n, A[N];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    int mx;
    ll ans = 0;
    cin >> A[1];
    mx = A[1];
    FOR(i, 2, n) {
        cin >> A[i];
        if(A[i] < mx) ans += mx - A[i];
        mx = max(mx, A[i]);
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 4392
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>


#define reps(i,f,n) for(int i = f; i <= n; ++i)
#define rep(i,n) reps(i, 0, n-1)

using namespace std;

typedef pair<int,int> PII;
typedef pair<int,PII> PIP;

class edge{
  public:
  int to;
  int cost;
  int ti;
  int ad;
  edge(int a,int b, int c, int d):to(a), cost(b), ti(c), ad(d){};
};

const int INF = 1e8;

int n, m, H, k;
int d[(1<<8)+1];
int s, t;
int kj;
int G[128][32];
int states[1<<8];
int used[1<<8];
int used2[128][32];
int ans;
vector<edge> e[128];
vector<int> pass;

void init(){
  rep(i,32)rep(j,128)G[j][i] = INF;
  rep(i,32)rep(j,128)used2[j][i] = 0;
  rep(i,(1<<8))states[i] = INF;
  rep(i,(1<<8))d[i] = -1;
  rep(i,(1<<8))used[i] = 0;
  rep(i,128)e[i].clear();
  pass.clear();
  ans = INF;
}

void c_state_cost(){
  priority_queue<PII, vector<PII>, greater<PII> > p;
  //state
  p.push(PII(0,0));
  states[0] = 0;

  while(!p.empty()){
    int cost = p.top().first;
    int state = p.top().second;p.pop();
    if(used[state])continue;
    used[state] = 1;
    rep(i,(int)pass.size()){
      int n_state = state | pass[i];
      if( states[n_state] > states[state] + d[i]){
        states[n_state] = states[state] + d[i];
        p.push(PII(states[n_state], n_state));
      }
    }
  }
}

void dijkstra(){
  ans = INF;
  rep(state, (1<<k)){
    if(states[state] == INF) continue;
    // cout << "state " << state << endl;
    rep(i,32)rep(j,128)G[j][i] = INF;
    rep(i,32)rep(j,128)used2[j][i] = 0;

    priority_queue<PIP, vector<PIP>, greater<PIP> > q;
    //cost , hour , pos 
    q.push(PIP(states[state],PII(0, s)));
    G[s][0] = states[state];
    while(!q.empty()){
      int cost = q.top().first;
      int hour = q.top().second.first;
      int pos = q.top().second.second;q.pop();
      // cout << ":cost " << cost << "  :hour " << hour << " :pos  " << pos << endl;

      if(used2[pos][hour])continue;
      used2[pos][hour] = 1;
      if(pos == t){ans = min(ans,cost);break;}
      rep(i,e[pos].size()){
        int to = e[pos][i].to;
        int co = e[pos][i].cost;
        int hou = e[pos][i].ti;
        int n_hour = hour + hou;
        // cout << to << ":" << co << ":" << hou << ":" << endl;
        if((state & (1<<e[pos][i].ad)) > 0) co = 0;
        if(hour+hou > H)continue;
        if(G[to][n_hour] > G[pos][hour] + co){
          G[to][n_hour] = G[pos][hour] + co;
          q.push(PIP(G[to][n_hour], PII(n_hour, to)));
        }
      }
    }
  }
}

int main(){
  int l;
  int a,b,c,h,r,p;
  while(1){
    init();
    cin >> n >> m >> H >> k;
    if( n == 0 && m == 0)break;
    rep(i,m){
      cin >> a >> b >> c >> h >> r;
      a--;b--;r--;
      e[a].emplace_back(edge(b,c,h,r));
      e[b].emplace_back(edge(a,c,h,r));
    }

    cin >> s >> t >> p;
    s--;t--;
    rep(i,p){
      int pa = 0;
      cin >> l >> d[i];
      rep(j,l){
        cin >> kj;
        kj--;
        pa |= 1<<kj;
      }
      pass.push_back(pa);
    }
    c_state_cost();
    dijkstra();
    if(ans == INF)cout << -1 << endl;
    else cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
const long long mod=924844033;
long long n,x,y,sub[222222],coef[222222],jc[222222],injc[222222],sz,cnt,rev[888888],s[888888],t[888888];
vector<long long> gr[222222];
long long binpow(long long a,long long t)
{
	long long res=1,p=a;
	for (long long i=t;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
void Init()
{
	jc[0]=injc[0]=1;
	for (long long i=1;i<=n;i++)
	{
		jc[i]=jc[i-1]*i%mod;
		injc[i]=injc[i-1]*binpow(i,mod-2)%mod;
	}
}
void dfs(long long i,long long fa)
{
	sub[i]=1;
	long long cnt=n-1;
	for (long long j=0;j<gr[i].size();j++)
	{
		long long to=gr[i][j];
		if (to==fa) continue;
		dfs(to,i);
		sub[i]+=sub[to];
		coef[sub[to]]--;cnt-=sub[to];
	}
	if (fa) coef[cnt]--;
}
void ntt(long long c[],long long flag)
{
	for (long long i=0;i<sz;i++)
	{
		if (rev[i]>i) swap(c[i],c[rev[i]]);
	}
	for (long long i=2;i<=sz;i<<=1)
	{
		for (long long j=0;j<sz;j+=i)
		{
			long long w,wn;
			w=1;
			if (flag==1) wn=binpow(5ll,(mod-1)/i);
			else wn=binpow(5ll,(mod-1)-(mod-1)/i);
			for (long long k=j;k<j+i/2;k++)
			{
				long long tmp1=c[k];
				long long tmp2=c[k+i/2]*w%mod;
				c[k]=(tmp1+tmp2)%mod;
				c[k+i/2]=(tmp1-tmp2)%mod;
				w=w*wn%mod;
			}
		}
	}
	if (flag==-1)
	{
		for (long long i=0;i<sz;i++)
		{
			c[i]=c[i]*binpow(sz,mod-2)%mod;
		}
	}
}
void doit()
{
	rev[0]=0;
	for (long long i=1;i<sz;i++)
	{
		rev[i]=(rev[i>>1]>>1)|((i&1)<<(cnt-1));
	}
	ntt(s,1);
	ntt(t,1);
	for (long long i=0;i<sz;i++) s[i]=s[i]*t[i]%mod;
	ntt(s,-1);
}
int main()
{
	scanf("%lld",&n);
	for (long long i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		gr[x].push_back(y);
		gr[y].push_back(x);  
	}
	Init();
	dfs(1,0);
	coef[n]+=n;
	for (long long i=1;i<=n;i++)
	{
		s[i]=coef[i]*jc[i]%mod;
		t[i]=injc[n-i];
	}
	sz=1;
	while(sz<=n+n)
	{
		cnt++;
		sz*=2;
	}
	doit();
	for (long long i=n+1;i<=n+n;i++) printf("%lld\n",((s[i]*injc[i-n]%mod)+mod)%mod);
	return 0;
} 

Measured memory_bytes: 52864
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,a,b,i; cin>>x>>n;  i=1;
    vector<int> v(n); int temp=x; 
    for(int i=0;i<n;i++) cin>>v[i];
    if(find(v.begin(),v.end(),temp)==v.end()){cout<<temp; return 0;}
    while(true){
         a=temp-i; b=temp+i;
         if(find(v.begin(),v.end(),a)==v.end()){
             cout<<a; return 0;
         }
         if(find(v.begin(),v.end(),b)==v.end()){
             cout<<b; return 0;
         }
         i++;
    }
    return 0;
}

Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() 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 main() {
	sc.Split(bufio.ScanWords)
	S := nextStr()
	if S == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}




int32_t main() {
	FIO;



	int d , n ;
	cin >> d >> n ;;

	if (d == 0) {
		if (n == 100) {
			cout << n + 1;
		}
		else {
			cout << n;
		}
	}
	else if (d == 1) {
		if (n == 100) {
			cout << (n + 1) * 100;
		}
		else {
			cout << n * 100;
		}
		// cout << n * 100;
	}
	else {
		if (n == 100) {
			cout << (n + 1) * 10000;
		}
		else {
			cout << n * 10000;
		}
	}




	return 0;
}


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

#define mod 1000000007

int64_t fact(int64_t n){
    int64_t a = 1;
    for(int i=2; i<=n; i++){
        a = a*i%mod;
    }
    return a;
}

int main(){
    int64_t n, m;
    cin >> n >> m;
    if(n==m){
        cout << fact(n) * fact(m) % mod * 2 % mod << endl;
    }else if(fabs(n-m)==1){
        cout << fact(n) * fact(m) % mod << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())

A_list = list(map(int, input().split()))

balls = [0] * (N + 1)

for a in A_list:
	balls[a] += 1

counts = [0] * (N + 1)
total = 0

for i in range(1, N + 1):
	ball = balls[i]
	count = ball * (ball - 1) // 2
	total += count
	counts[i] = count

for i in range(N):
	a = A_list[i]
	ball = balls[a] - 1
	count = ball * (ball - 1) // 2
	print(total - counts[a] + count)


Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,q,b,c,sum=0;cin>>n;
  lvector A(n),num(1e5+1,0);
  rep(i,n) {cin>>A[i];num[A[i]]++;sum+=A[i];}
  cin>>q;
  lvector ans(q+1,0);ans[0]=sum;
  rep(i,q) {
    cin>>b>>c;
    ll v=num[b];
    num[b]=0;num[c]+=v;
    ans[i+1]=ans[i]-(b-c)*v;
  }
  for(ll i=1;i<=q;++i) print(ans[i]);
  return 0;
}

Measured memory_bytes: 5544
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
using namespace std;

int main(int argc, const char *argv[])
{
    int N,M,C;
    cin>>N>>M>>C;
    vector<vector<int> > mat (N+1, vector<int>(M, 0));
    for(int i = 0; i < N+1 ; i ++)
    {
        for(int j = 0; j < M ; j ++)
        {
            cin>>mat[i][j];
        }
    }

    int sum = 0;
    int num = 0;
    for (int i = 1; i < N+1; i++)
    {   sum = C;
        for (int j = 0; j < M; j++)
        {
            sum += mat[0][j]*mat[i][j];
        }

        if(sum > 0)
        {
            num ++;
        }
    }
    cout<<num;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register int
#define deb(x) cerr<<#x<<" = "<<(x)<<'\n';
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
const ll mod = 1e9 + 7;
const int maxn = 3e5 + 10;
ll ans = 1, num[maxn];
int n, k, vis[maxn];
vector <int> g[maxn];

void dfs(int t){
	vis[t] = 1;
	int x = k-2;
	if(t==1) x++;
	if(x<0) x = 0;
	for(auto i : g[t]){
		if(vis[i]) continue;
		num[i] = x;
		dfs(i);
		x--;
	}
}

int main() {
	scanf("%d %d", &n, &k);
	for(int i=0, u, v; i<n-1; i++){
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	num[1] = k;
	dfs(1);
	for(int i=1; i<=n; i++){
		(ans *= num[i]) %= mod;
	}
	
	printf("%lld\n", ans);
}

Measured memory_bytes: 16000
package main

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

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

	nNodes := scanInt(sc)
	nOps := scanInt(sc)

	parents := make([]int, nNodes+1)
	for i := 0; i < nNodes-1; i++ {
		a, b := scanInt(sc), scanInt(sc)
		parents[b] = a
	}

	ops := make([]int64, nNodes+1)
	for i := 0; i < nOps; i++ {
		p, addition := scanInt(sc), scanInt(sc)
		ops[p] += int64(addition)
	}

	counts := make([]int64, nNodes+1)

	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= nNodes; i++ {
		p := parents[i]
		counts[i] = ops[i] + counts[p]
		if i == nNodes {
			fmt.Fprint(w, counts[i])
		} else {
			fmt.Fprintf(w, "%d ", counts[i])
		}
	}
	fmt.Fprintln(w)
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 10240
import java.util.Scanner;

public class Main {
    public static void main (String[] args){

        int A = 5;
        int B = 7;
        int C = 5;

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == A && b == B && c == C){
            System.out.println("YES");
        } else if(a == B && b == C && c == A){
            System.out.println("YES");
        }else if(a == C && b == A && c == B){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

    
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  int n,m,a,b,c;
  cin >> n >> m >> a >> b >> c;
  int step[64][64][128];
  REP(i,64) REP(j,64) REP(k,128) step[i][j][k]=0;
  REP(i,m){
    int u,v;
    cin >> u >> v;
    step[u][v][1]=1;
  }
  REP(k,100) REP(i,n+1) REP(j,n+1) REP(l,n+1){
    step[i][j][k+1]=max(step[i][j][k+1],step[i][l][k]*step[l][j][1]);
  }
  int turns[64];
  REP(i,64) turns[i]=1024;
  turns[n]=0;
  REP(st,100) REP(i,n+1){
    int at=1024,bt=1024,ct=1024;
    REP(j,n+1){
      if(step[i][j][a]) at=min(at,turns[j]+1);
      if(step[i][j][b]) bt=min(bt,turns[j]+1);
      if(step[i][j][c]) ct=min(ct,turns[j]+1);
    }
    turns[i]=min(turns[i],max(at,max(bt,ct)));
  }
  if(turns[1]>1000) cout << "IMPOSSIBLE" << endl;
  else cout << turns[1] << endl;
  return 0;

}

Measured memory_bytes: 5172
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int A , B ;
    cin >> A >> B ;
    int a, b ,ab ;
    a = A % 3 ;
    b = B % 3 ;
    ab = (A + B) % 3 ;

    if(a==0){
        cout << "Possible" << endl;
    }else if (b==0){
        cout << "Possible" << endl;
    }else if(ab == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
  public static void main(String[] args){
    try{
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      int X, Y, Z;
      String[] temp = bf.readLine().split(" ");
      X = Integer.parseInt(temp[0]);
      Y = Integer.parseInt(temp[1]);
      Z = Integer.parseInt(temp[2]);
	  int n = (X-Z)/(Y+Z);
      System.out.println(n);
    } catch(IOException e){}
  }
}
    

Measured memory_bytes: 21204
a,b,c,d = gets.split.map(&:to_i)
if(c>a)
  e = c-a
else
  e = a-c
end

if((e<=d)||(((b-a)<=d)&&((c-b)<=d))&&(b<c)&&(a<b))
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
//const lint MOD = pow(10, 9) + 7;

int main() {
	string str;
	cin >> str;
	int N;
	cin >> N;
	string cmd;
	int a, b;
	string p;
	rep(i, N) {
		cin >> cmd >> a >> b;
		if (cmd == "print") {
			for (int i = a; i <= b; i++) {
				cout << str[i];
			}
			cout << endl;
		}
		else if (cmd == "reverse") {
			char box;
			while (a <= b) {
				box = str[a];
				str[a] = str[b];
				str[b]=box;
				a++;
				b--;
			}
		}
		else {
			cin >> p;
			for (int i = a; i <= b; i++) {
				str[i] = p[i-a];
			}
		}
	}
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int X, Y;
	cin >> X >> Y;

	bool check = false;
	for (int i = 0; i <= X; i++) {
		int foot = i * 2 + (X - i) * 4;
		if (foot == Y) check = true;
	}

	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver(int N, vector<int> &A, vector<ll> &money){

    ll dist_sum = 0;
    vector<int> dist(N+1);

    dist.at(0) = abs(A.at(0));
    dist.at(N) = abs(A.at(N-1));
    dist_sum += dist.at(0);
    dist_sum += dist.at(N);
    for(int i=0; i<N-1; ++i){

        dist.at(i+1) = abs(A.at(i+1) - A.at(i));
        dist_sum += dist.at(i+1);
    }
//    cout << dist_sum << endl; // debug

    for(int i=0; i<N; ++i){
        ll buf;
        buf = dist_sum;
        buf -= (dist.at(i) + dist.at(i+1));
        
        int l, r;
        if(i-1 < 0){
            l = 0;
        }
        else{
            l = A.at(i-1);
        }
        if(i+1 > N-1){
            r = 0;
        }
        else{
            r = A.at(i+1);
        }
//        cout << l << " "s << r << endl;   // debug
        buf += abs(l-r);

        money.at(i) = buf;
    }
    return;
}

int main(){

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

    vector<ll> money(N);
    solver(N, A, money);

    for(int i=0; i<N; ++i){
        cout << money.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> t(n);
	for(int i = 0; i < n; i++) cin >> t[i];
	int sum = accumulate(t.begin(), t.end(), 0);
	int m; cin >> m;
	for(int i = 0; i < m; i++){
		int p, x; cin >> p >> x;
		p--;
		cout << sum - t[p] + x << endl;
	}
	return 0;
}


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

using namespace std;
int n,f[202020],siz[202020];
const int mod = 1e9+7;
long long sum = 0;

inline int getf(int x) {
	if (x == f[x])
		return x;
	return f[x] = getf(f[x]);
}
int m,aa,bb;
int main() {
scanf("%d%d",&n,&m);
for (int i = 1;i <= n; i++) {
	f[i] = i;
	siz[i] = 1;
}
int ans = 1;
for (int i = 1;i <= m; i++) {
	scanf("%d%d",&aa,&bb);
	if (getf(aa) != getf(bb)) {
		siz[f[bb]] += siz[f[aa]];
		ans = max(ans,siz[f[bb]]);
		f[f[aa]] = f[bb];
	}
}
	printf("%d",ans);
	return 0;
}
/*
5
6 14 15 7 12 16 5 4 11 9 3 10 8 2 13 1
4
1 2 3 4 5 6 7 8
*/

Measured memory_bytes: 5356
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;

vector<int> vec;
int dp[3000][3000];

int solve(int i, int j)
{
if(i==j)
{
	return vec[i];
}
if(dp[i][j]!=-1)
	return dp[i][j];
int ans=max(vec[i]-solve(i+1,j),vec[j]-solve(i,j-1));	
return dp[i][j]=ans;	
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	vec.resize(n);
	for(int i=0; i<n; i++)
	{
		cin>>vec[i];
	}
	for(int i=0; i<3000; i++)
	{
		for(int j=0; j<3000; j++)
		{
			dp[i][j]=-1;
		}
	}
	cout<<solve(0,n-1);
	return 0;
}


Measured memory_bytes: 70784
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [list(map(int,input().split())) for _ in range(M)]
Sum = sum(T)
for i in range(M):
  if PX[i][1] > T[PX[i][0]-1]:
    print(Sum + PX[i][1] - T[PX[i][0]-1])
  else:
    print(Sum - (T[PX[i][0]-1] - PX[i][1]))
    

Measured memory_bytes: 3064
#include <iostream>
using namespace std; 
int main(void){

  int n;
  cin >> n;
  for(int i=1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i * j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
	return *(int *)a - *(int *)b;
}
int main(void)
{
	int n;
	int a[100];
	int b[100];
	scanf("%d",&n);
	int i;
	int count = 0;
	int flag = 1;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	qsort(b+1,n,sizeof(b[1]),cmp);
	for(int i = 1;i<=n;i++)
	{
	//	prin
		if(a[i] != b[i])
			count++;
	}
	if(count <= 2)
		printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	N := getStdinInt64()
	var base int64 = 'z' - 'a' + 1

	n := N - 1

	str := ""
	for {
		mod := n % base
		str2 := fmt.Sprintf("%c", 'a'+mod)
		str = str2 + str

		n /= base
		if n == 0 {
			break
		}
		n--
	}
	fmt.Printf("%s\n", str)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1808
/// 01:37 08/09/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll d, t, s;
    cin >> d >> t >> s;
    s = s * t;
    if (s >= d) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

long long dp[100000][3];
const long long MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  int N = S.size();

  if(S[0] == 'A' || S[0] == '?'){
    dp[0][0] = 1;
  }

  long long case_num = 1;
  for(int i = 0; i < N; i++){
    if(S[i] != '?'){
      for(int j = 0; j < 3; j++){
        dp[i][j] = dp[i - 1][j];
      }
      if(S[i] == 'A'){
        dp[i][0] = (dp[i][0] + case_num) % MOD;
      }
      if(S[i] == 'B'){
        dp[i][1] = (dp[i][1] + dp[i - 1][0]) % MOD;
      }
      if(S[i] == 'C'){
        dp[i][2] = (dp[i][2] + dp[i - 1][1]) % MOD;
      }
    } else {
      dp[i][0] = (dp[i - 1][0] * (long long) 3 + case_num) % MOD;
      dp[i][1] = (dp[i - 1][1] * (long long) 3 + dp[i - 1][0]) % MOD;
      dp[i][2] = (dp[i - 1][2] * (long long ) 3 + dp[i - 1][1]) % MOD;

      case_num = (case_num * 3) % MOD;
    }
  }

  cout << dp[N - 1][2] << endl;
  /*
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < N; j++){
      cout << dp[j][i] << " ";
    }
    cout << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 2816
Data = {}

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def addData(pflist):
    for p in pflist:
        if p in Data:
            Data[p]+=1
        else:
            Data[p]=1

MOD = 10**9+7
N = int(input())
for n in range(1,N+1):
    x = prime_factorize(n)
    addData(x)

ans = 1
for v in Data.values():
    ans *= (v+1)
    ans %= MOD
print(ans)

Measured memory_bytes: 3064
000010 IDENTIFICATION                   DIVISION.
000020 PROGRAM-ID.                      MAIN.
000030*
000040 ENVIRONMENT                      DIVISION.
000050*
000060 DATA                             DIVISION.
000070 WORKING-STORAGE                  SECTION.
000080 77 VAL                           PIC 9(3).
000090 77 ANS                           PIC 9.
000100*
000110 PROCEDURE                        DIVISION.
000120 MAIN.
000130     ACCEPT VAL                   FROM SYSIN.
000140     DIVIDE VAL BY 9 GIVING VAL REMAINDER ANS
000150     DISPLAY ANS                  UPON SYSOUT.
000160     STOP RUN.


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

for i in range(N):
    if i%2==0:
        ans[0] += A[i]
    else:
        ans[0] -= A[i]

for i in range(1, N):
    ans[i] = 2*A[i-1]-ans[i-1]

print(*ans)

Measured memory_bytes: 95384
import java.util.Scanner;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(N, A, B));
    }

    private static int solve(int N, int A, int B) {
        return Math.min(N*A, B);
    }
}


Measured memory_bytes: 21844
#!/usr/bin/env python3
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 sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    tree = [list() for i in range(N)]
    for i in range(N - 1):
        tree[A[i] - 1].append(i + 1)

    for i in range(N):
        print(len(tree[i]))


def main():
    solve()


if __name__ == '__main__':
    main()


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

int main()
{
    string s;
    cin >> s;

    vector<bool> f(4); // {n, s, e, w}
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'N') f[0] = true;
        if (s[i] == 'S') f[1] = true;
        if (s[i] == 'E') f[2] = true;
        if (s[i] == 'W') f[3] = true;
    }

    cout << (f[0] ^ f[1] || f[2] ^ f[3] ? "No" : "Yes") << endl;

    return 0;
}


Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// 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; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if (n<=k) cout << n*x << endl;
  else cout << k*x + (n-k)*y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define X first
#define Y second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define SHOWVECTOR(v) {std::cerr << #v << "\t: ";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}}
//math

const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;

void solve(){
	cin >> n;
	int ans = 0;
	FF(i,1,n){
		int cnt = n/i;
		int sum = (i + (cnt*i))*cnt/2;
		ans += sum;
	}
	cout << ans;
}

signed main(){
  //clock_t t1 = clock();  
	IOS
	solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
	return 0;
}

Measured memory_bytes: 3144
# coding: utf-8

import re

def main():
    s = input()
    t = input()
    lt = len(t)
    for i in range(len(s) - lt, -1, -1):
        if re.match(s[i:i + lt].replace("?", "."), t):
            return s[:i].replace("?", "a") + t + s[i + lt:].replace("?", "a")
    return "UNRESTORABLE"


if __name__ == "__main__":
    print(main())


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

#define INF  						1e15
#define EPS   						1e-9
#define MOD 						1000000007
#define Pi 							3.14159265358979323846264338327950288419716939937510

#define umap 						unordered_map
#define uset 						unordered_set
#define fi 							first
#define se 							second
#define ll 							long long 
#define vi 							vector<int>
#define pii 						pair<int,int>
#define vll 						vector<ll>
#define pll							pair<ll,ll>
#define pb 							push_back
#define pob 						pop_back
#define pf 							push_front
#define pof 						pop_front
#define maxE(a,n) 					*max_element(a,a+n);
#define minE(a,n) 					*min_element(a,a+n);
#define all(x) 						x.begin(), x.end()

#define fast 						ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fori(i,a,n) 				for (ll  i=a;i<n;i++)
#define ford(i,a,n) 				for (ll  i=n-1;i>=a;i--)

ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}

using namespace std;


void solve(){

	ll n,d;
	cin>>n>>d;

	ll count = 0;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;

		if(x*x + y*y - d*d <= 0){
			count++;
		}
	}
	cout<<count<<endl;;
	return;

}


int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	fast;
	// ll t;
	// cin>>t;

	// while(t--){
	// 	solve();
	// }

	solve();
}


Measured memory_bytes: 3656
isPrime = [True for i in range(100010)]
# エラトステネスの篩で素数判定
isPrime[0]=isPrime[1]=False
for i in range(2,100010):
    if isPrime[i]:
        j=2
        while i*j<=100000:
            isPrime[i*j]=False
            j+=1
# isSimilar
isSimilar = [True for i in range(100010)]
for i in range(100010):
    if isPrime[i] and isPrime[(i+1)//2]:
        isSimilar[i]=True
    else:
        isSimilar[i]=False
# 累積和を取ります
cnt = [0 for i in range(100010)]
for i in range(1, 100010):
    cnt[i] = cnt[i-1] + [0, 1][isSimilar[i]]
# 入力
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    # cnt[r] - cnt[l-1]が答えです
    print(cnt[r] - cnt[l-1])


Measured memory_bytes: 8088
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    char c;
    cin >> c;

    cout << char(c+1) << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int beki(int b, int k) {
    int ans = 1;
    for (int i = 0; i < k; i++) {
        ans *= b;
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;

    int ans = 1;    
    for (int i = 1; i < n; i++) {
        for (int j = 2; j < n;j++) {
            int tmp;
            tmp = beki(i, j);
            if (tmp <= n)
                ans = max(ans, tmp);
            else
                break;
        }
    }

    cout <<ans << endl;
    return 0;
}


Measured memory_bytes: 256