akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long A, long long B){
	ll res = -999;
	chmax(res, A+B);
	chmax(res, A-B);
	chmax(res, A*B);
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main()
{
    
    int a[3][3];
    bool appear[3][3];
    ref(i,3)
    {
        ref(j,3)
        {
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    int why[n];
    ref(i,n)
    {
        cin>>why[i];
    }
    ref(i,3){
        ref(j,3){
            appear[i][j] = false;
            ref(k,n){
                if(a[i][j] == why[k])
                    appear[i][j] = true;
            }
        }
    }
    string ans = "No";
    ref(i,3) // HORIZONTAL
    {
       if(appear[i][0] and appear[i][1] and appear[i][2])
        ans = "Yes";
    }
    ref(i,3) // VERICAL
    {
       if(appear[0][i] and appear[1][i] and appear[2][i])
        ans = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) // DAIGONAL1
        ans = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) // DAIGONAL2
        ans = "Yes";
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
from math import *
while True:
    n = int(input())
    if(n == 0 ): break
    data = list(map(int,input().split()))  
    a = sum(data) / n
    b = 0
    c = 0
    for i in data:
        b += pow(i-a,2)
    c = sqrt(b/n)
    
    print(c)


Measured memory_bytes: 5692
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
typedef long long int ll;

double arr[3000];
// double dp[3000][3000];
int n;
// double find(int i, int h) {
// 	if (i >= n) {
// 		if (h >= (n + 1) / 2)
// 			return 1;
// 		return 0;
// 	}

// 	if (dp[i][h] > -1)
// 		return dp[i][h];

// 	return dp[i][h] = arr[i] * find(i + 1, h + 1) + (1 - arr[i]) * find(i + 1, h);
// }


int main() {

	fastio;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		// cout << arr[i] << endl;
	}

	// memset(dp, -1, sizeof dp);
	// cout << fixed << setprecision(10) << find(0, 0);
	double dp[n + 1][n + 1];
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j == 0) {
				dp[i][j] = (1.0 - arr[i - 1]) * dp[i - 1][j];
			} else {
				dp[i][j] = arr[i - 1] * dp[i - 1][j - 1] + (1.0 - arr[i - 1]) * dp[i - 1][j];
			}
		}
	}
	double res = 0;
	for (int i = (n + 1) / 2; i <= n ; i++)
		res += dp[n][i];

	cout << fixed << setprecision(10) << res;
	return 0;
}




Measured memory_bytes: 74020
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define REP(i,n) for(int i=0;i<n;i++)
#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 ALL(c) (c).begin(),()c.end() 

#define PI 3.14159265358979323846
const int N = 3e5 + 10;
const int INF=2e9;

int MOD=1e9+7;

void solve() {
       int n,m;
       cin>>n>>m;
       int f1=n+(n-1);
       int f2=m+(m-1);
       int f3=n+m;
       cout<<max({f1,f2,f3});
	
	}  

int32_t main() {
  cool;
  int t = 1;
  while (t--)
	solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 998244353;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
public:
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
const int MAX = 500000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

/* -- template -- */

int main() {
    COMinit();
    int N, M, K; cin >> N >> M >> K;
    mint n = N;
    mint ans = 0;
    mint m = M;

    for(int i = 0; i <= K; ++i) {
        ans += m * (m - 1).pow(N - i - 1) * COM(N-1, i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 15356
#include<bits/stdc++.h>
#define db double
#define ll long long
using namespace std;
const int N=40010,ooo=2e8;
const db eps=1e-10;
int n,nn;
struct Line{
	int a,b,c;
}l[N];
int cmp1(Line t1,Line t2){
//	return t1.k>t2.k;
	return t2.a*t1.b>t1.a*t2.b;
}
int cmp2(Line t1,Line t2){
	if(1LL*t1.a*t2.a*t1.b*t2.b<0) return t2.a*t1.b>t1.a*t2.b;
	return t2.a*t1.b<t1.a*t2.b;
}
db p[N],pp[N];
int get_num(int l,int r){
	if(l>=r) return 0;
	int mid=(l+r)>>1;
	int ans=get_num(l,mid)+get_num(mid+1,r),i=l,j=mid+1;
	for(int k=l;k<=r;k++){
		if((p[i]<=p[j]&&i<=mid)||j>r) pp[k]=p[i++];
		else pp[k]=p[j++],ans+=mid-i+1;
	}
	for(int k=l;k<=r;k++) p[k]=pp[k];
	return ans;
}
int main(){
	db ansx,ansy;
	scanf("%d",&n);
	nn=(n*(n-1)/2+1)/2;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&l[i].a,&l[i].b,&l[i].c);
        if(l[i].b<0){
        	l[i].a*=-1,l[i].b*=-1,l[i].c*=-1;
        }
    }
    sort(l+1,l+n+1,cmp1);
    int maxd=100;
	db left=-ooo,right=ooo,mid;
	int temp;
	for(int _=1;_<=maxd;_++){
		mid=(left+right)/2;
		for(int i=1;i<=n;i++) p[i]=(-1*mid*l[i].a+l[i].c)/l[i].b;
		temp=get_num(1,n);
		if(temp<nn) left=mid;
		else right=mid;
	}
	ansx=left;
	sort(l+1,l+n+1,cmp2);
	left=-ooo,right=ooo;
	for(int _=1;_<=maxd;_++){
		mid=(left+right)/2;
		for(int i=1;i<=n;i++) p[i]=(-1*mid*l[i].b+l[i].c)/l[i].a;
		temp=get_num(1,n);
		if(temp<nn) left=mid;
		else right=mid;
	}
	ansy=left;
	printf("%.10lf %.10lf",ansx,ansy);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define N 300100
#define SHIT {printf("No");return 0;}
using namespace std;
int a[N],n,b[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	for(int i=1;i<=n-2;++i)if(a[i]^i&&a[i+1]^i+1&&a[i+2]^i+2)SHIT;
	if(a[1]^1&&a[2]^2)SHIT;
	if(a[n]^n&&a[n-1]^n-1)SHIT;
	a[n+1]=n+1;
	for(int i=1;i<=n;++i){
		if(a[i]==i&&(i<=2||a[i-2]!=i-2)){
			int T=1;b[1]=a[i-1];
			for(int x=i;x<=n&&a[x]==x;x+=2)b[++T]=a[x+1];
			sort(b+1,b+T+1);
			if(b[1]^i-1||b[T]^i-3+T*2)SHIT;
			int l1=0,l2=0;
			for(int x=i-1;x<=n+1&&(a[x-1]==x-1||x<i);x+=2){
				if(a[x]<=x){
					if(a[x]<l1)SHIT;l1=a[x];
				}
				if(a[x]>=x){
					if(a[x]<l2)SHIT;l2=a[x];
				}
			}
		}
	}
	printf("Yes");
}

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

int grundy(int A, int K) // grundy(A - A/K - 1, K)
{
  if(A < K) return 0;
  int rem = A%K;
  int divm = A/K + 1;
  
  if(rem == 0) return divm-1;
  return grundy( A - ((rem+divm-1)/divm)*divm, K);
}

int main()
{
  int N; scanf("%d", &N);
  int ans = 0;
  for(int i=0; i<N; ++i)
  {
    int A, K; scanf("%d%d", &A, &K);
    ans ^= grundy(A, K);
  }
  if(ans) puts("Takahashi");
  else puts("Aoki");
}

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


int main(){
    int n,k,q;
    cin >> n>>k>>q;
    vector<int> player (n,k-q);
    int a;
    for(int i=0;i<q;i++){
        cin >> a;
        player[a-1]++;
    }
    for(int i=0;i<n;i++){
        if (player[i]<=0){
            cout << "No"<<"\n";
        }else{
            cout << "Yes"<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll X; cin >> X;
  double time = (-1 + sqrt(1+8*X)) / 2;
  cout << ceil(time) << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

def sonzai(path, start, goal):
    for i in path:
        if start in i:
            if start > goal:
                if i[0] == goal:
                    return True
            else:
                if i[1] == goal:
                    return True
    return False

n, m = map(int, input().split())
path = []
for i in range(m):
    a, b = map(int, input().split())
    path.append([a, b])
ans = 0
for i in itertools.permutations(range(2, n + 1)):
    if not sonzai(path, 1, i[0]):
        continue
    for j in range(n - 1):
        if j == n - 2:
            ans += 1
            break
        if not sonzai(path, i[j], i[j + 1]):
            break
print(ans)

Measured memory_bytes: 3064
using System;

class ACBC1208_B
{
    public static void Main()
    {
        var s = Console.ReadLine();
        int len = s.Length, c = 0;
        for(int i = 0;i < len / 2;i++)
        {
            if (s[i] != s[len - 1 - i]) c++;
        }
        Console.WriteLine(c);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cassert>
#include<climits>
#include<cmath>
#include<sstream>
#include<algorithm>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-15)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(long double a,long double b) { return !equals(a,b) && a < b; }
bool LTE(long double a,long double b) { return equals(a,b) || a < b; }
 
double target;
 
/*
  void sternBrocot(long long pl = 0, long long ql = 1, long long pr = 1, long long qr = 0) {
  long long pm = pl + pr, qm = ql + qr;
  long double v = pm / (long double)qm;
  if( equals(v,0.0) ) return;
  if( LT(target,v) ) sternBrocot(pl, ql, pm, qm);
  if( equals(v,target) ) {
  cout << pm << "/" << qm << endl;
  return;
  }
  if( LT(v,target) ) sternBrocot(pm, qm, pr, qr);
  }
*/
struct Data {
  long long pl, ql, pr, qr;
};
 
void sternBrocot() {
  deque<Data> deq;
  deq.push_back((Data){0,1,1,0});
  while( !deq.empty() ) {
    Data data = deq.back(); deq.pop_back();
    long long pm = data.pl + data.pr, qm = data.ql + data.qr;
    long double v = pm / (long double)qm;
    if( equals(v,0.0) ) continue;
    if( LT(target,v) ) {
      deq.push_back((Data){data.pl,data.ql,pm,qm});
    }
    if( equals(v,target) ) {
      cout << pm << "/" << qm << endl;
      break;
    }
    if( LT(v,target) ) {
      deq.push_back((Data){pm,qm,data.pr,data.qr});
    }
  }
}


int main() {
  string s;
  cin >> s;
  if( s.find("(") == string::npos ) {
    int cnt = 0;
    rep(i,(int)s.size()) {
      if( s[(int)s.size()-1-i] == '.' ) break;
      ++cnt;
    }
    ll denom = 1, frac = 0;
    rep(i,cnt) denom *= 10LL;
    rep(i,(int)s.size()) {
      char c = s[i];
      if( c == '.' ) continue;
      frac *= 10;
      frac += (s[i]-'0');
    }
    ll gcd = __gcd(frac,denom);
    frac /= gcd;
    denom /= gcd;
    cout << frac << "/" << denom << endl;
  } else {
    string suffix = "";
    bool f = false;
    rep(i,(int)s.size()) {
      if( s[i] == ')' ) f = false;
      if( f ) suffix += s[i];
      if( s[i] == '(' ) f = true;
    }
    string prefix = "";
    rep(i,(int)s.size()) {
      if( s[i] == '(' ) break;
      prefix += s[i];
    }
    s = prefix;
    rep(i,30) s += suffix;
    stringstream ss;
    ss << s;
    ss >> target;
    sternBrocot();
  }
  return 0;
}

Measured memory_bytes: 3292
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		String str,type;
		while(true){
			str=s.next();
			type=s.next();
			if(type.charAt(0)=='X')break;
			String ret="";
			String[]table=str.split("_");
			switch(type.charAt(0)){
				case 'U':
					if(table.length==1){
						ret=(char)(str.charAt(0)&(~32))+str.substring(1);
					}else{
						for(int i=0;i<table.length;i++){
							ret+=(char)(table[i].charAt(0)&(~32))+table[i].substring(1);
						}
					}
					break;
				case 'L':
					if(table.length==1){
						ret=(char)(str.charAt(0)|(32))+str.substring(1);
					}else{
						ret+=table[0];
						for(int i=1;i<table.length;i++){
							ret+=(char)(table[i].charAt(0)&(~32))+table[i].substring(1);
						}
					}
					break;
				case 'D':
					if(table.length!=1)ret=str;
					else for(int i=0;i<str.length();i++){
						if(i>0&&str.charAt(i)>='A'&&str.charAt(i)<='Z')ret+="_"+(char)(str.charAt(i)|32);
						else ret+=(char)(str.charAt(i)|32);
					}
					break;
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 12000
def inpl(): return [int(i) for i in input().split()]
def hmd(a, b):
    ctr = -1
    while H[ctr+1][a] < b:
        ctr += 1
    vn = H[ctr][a]
    if (vn == b and ctr == 0) or ctr == -1:
        return 1
    return 2**ctr + hmd(vn,b)
N = int(input())
x = inpl() + [10**10]
L = int(input())
H = []
G = [N-1]*N
b = 0
for a in range(N):
    while x[b+1] - x[a] <= L:
        if b == N-1:
            break
        b += 1
    G[a] = b
H.append(G)
while G[0] != N-1:
    G = [G[i] for i in G]
    H.append(G)
H.append([10**10]*N)
Q = int(input())
for _ in range(Q):
    a, b = sorted(inpl())
    print(hmd(a-1,b-1))

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

int main() {
    int s;
    cin >> s;
    vector<bool> v(1'000'000, false);
    int ans = 1;
    for (int a = s; !v[a]; v[a] = true, a = a&1 ? 3*a+1 : a/2, ans++);
    cout << ans << endl;
}


Measured memory_bytes: 384
X = int(input())
items = [100, 101, 102, 103, 104, 105]
lrs = []
for i in range(1,100001):
    l = 100 * i
    r = 105 * i
    lrs.append([l, r])
idx = X // 100
if idx == 0:
    print(0)
    exit()
l, r = lrs[idx - 1]
if X <= r:
    print(1)
else:
    print(0)
    

Measured memory_bytes: 54492
#include <iostream>

int main(int argc, char ** argv) {
  int input, top[3] = {0};
  for (int i = 0; i < 10; i++) {
    std::cin >> input;
    if (input >= top[0]) {
      top[2] = top[1];
      top[1] = top[0];
      top[0] = input;
    }else if (input >= top[1]) {
      top[2] = top[1];
      top[1] = input;
    }else if (input >= top[2]) {
      top[2] = input;
    }
  }

  for (int i = 0; i < 3; i++) {
    std::cout << top[i] << std::endl;
  }
}

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


int w[110],s[110];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>w[i],s[i]=w[i]+s[i-1];
    int ans=12345678;
    for(int i=0;i<=n;++i){
        ans=min(abs(s[i]-(s[n]-s[i])),ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//2016/10/27

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int dice_check(int,int);
void roll_S(void);
void roll_W(void);
void spin(void);
void dice_change(int j);
int dice[100][6]={0},dice_spin[6]={0},now[6]={0};
int i,j,k,l,temp,n;

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

	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d %d %d %d", &dice[i][0],&dice[i][1],&dice[i][2],&dice[i][3],&dice[i][4],&dice[i][5]);
	}


	for(l = 0; l < n; l++)
	{
		dice_check(l,n);

		if (dice_check(l,n) == 1)
		{
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0 ;
}


int dice_check(int l,int n)
{
	for(i = 0; i < 6; i++)
	{
		now[i] = dice[l][i];
	}

	for(i = l+1; i < n; i++)
	{
		for(j = 0; j < 6; j++)
		{
			dice_spin[j] = dice[i][j];
		}

		for(j = 0; j < 6; j++)
		{
			dice_change(j);

			for(k = 0; k < 4; k++)
			{
				spin();

				if (dice_spin[0] == now[0] && dice_spin[1] == now[1] && dice_spin[2] == now[2] && dice_spin[3] == now[3] && dice_spin[4] == now[4] && dice_spin[5] == now[5])
				{
					return 1;
				}
			}
		}
	}
	return 0;

}	


void roll_S(void)
{
	temp = dice_spin[4];
	dice_spin[4] = dice_spin[0];
	dice_spin[0] = dice_spin[1];
	dice_spin[1] = dice_spin[5];
	dice_spin[5] = temp;

}

void roll_W(void)
{
	temp = dice_spin[2];
	dice_spin[2] = dice_spin[0];
	dice_spin[0] = dice_spin[3];
	dice_spin[3] = dice_spin[5];
	dice_spin[5] = temp;
}


void spin(void)
{
	temp = dice_spin[3];
	dice_spin[3] = dice_spin[1];
	dice_spin[1] = dice_spin[2];
	dice_spin[2] = dice_spin[4];
	dice_spin[4] = temp;

}

void dice_change(int j)
{
	switch(j)
	{
		case 0 : break;

		case 1 : roll_S();
				 roll_S();
				 roll_S();
				 break;

		case 2 : roll_W();
				 break;

		case 3 : roll_W();
				 roll_W();
				 roll_W();
				 break;

		case 4 : roll_S();
				 break;

		case 5 : roll_S();
				 roll_S();
				 break;
	}

}

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

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

}

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

int main() {
  int a, b , c, d;
  cin >> a >> b >> c >> d;
  cout << (max(a, b) - min(a, b) <= d && max(b, c) - min(b, c) <= d || max(a, c) - min(a, c) <= d ? "Yes" : "No") << endl; 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n,x;
  cin>>n>>x;
  vector<int> d(n);
  rep(i,n){
    int p;
    cin>>p;
    d[i] = abs(x-p);
  }

  int ans = d[0];
  rep(i,n) ans = __gcd(ans, d[i]);

  cout << ans << endl;

  return 0;
}


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

int main() {
  long long A, B;
  cin >> A >> B;
  long long X = A * B;
  if (A < B) {
    int tmp = A;
    A = B;
    B = tmp;
  }
  int r = A % B;
  while (r != 0) {
    A = B;
    B = r;
    r = A % B;
  }
  cout << X / B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint32_t a, b, c;
    uint32_t sum = 3;
    scanf("%u %u %u", &a, &b, &c);
    if (a == b) sum--;
    if (b == c) sum--;
    if (c == a) sum--;
    if (sum == 0) sum = 1;
    printf("%u\n", sum);
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
int main()
{
	int n[1000], x[1000], num;
	for(int i = 0;; i++)
	{
		std::cin >> n[i] >> x[i];
		if(n[i] == 0 && x[i] == 0)
		{
			num = i;
			break;
		}
	}
	for(int i = 0; i < num; i++)
	{
		int cnt = 0;
		for(int j = 1; j <= n[i] - 2; j++)
		{
			for(int k = j + 1; k <= n[i] - 1; k++)
			{
				for(int l = k + 1; l <= n[i]; l++)
				{
					cnt += j + k + l == x[i] ? 1 : 0;
				}
			}
		}
		std::cout << cnt << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>
int fun(int x)
{
    return x*x;
}
int main()
{
    int n,s[102];
    while(~scanf("%d",&n))
    {
        int i,minn=101,maxx=-101;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&s[i]);
            if(s[i]>maxx)maxx=s[i];
            if(s[i]<minn)minn=s[i];
        }
        int zz,minnn=9999999;
        for(i=minn;i<=maxx;i++)
        {
            int j,sum=0;
            for(j=1;j<=n;j++)
            {
                sum+=fun(s[j]-i);
            }
            if(sum<=minnn)minnn=sum;
        }
        printf("%d\n",minnn);
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define pb push_back
#define st string
#define pairi pair<int,int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
		string s;cin>>s;
		int x=0;
		sidha(i,0,s.size()){
			x+=(s[i]-'0');
		}
		if(x%9==0){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
}


Measured memory_bytes: 3756
N,K,Q = map(int,input().split())
As = []
for _ in range(Q):
	As.append(int(input()))
	
Ss = []
for _ in range(N):
	Ss.append(0)
	
for i in range(Q):
	Ss[As[i]-1] += 1
	#print(Ss)
	
for S in Ss:
	if Q-K < S:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 56664
package main

import (
	"fmt"
)

const DEVIDE int64 = 1000000007
var primeSieve []bool
var primes []int

func main() {
	var n int
	fmt.Scan(&n)
	initPrime(n + 1)
	counter := make(map[int]int)
	for _, prime := range primes {
		counter[prime] = 1
	}
	for i := 2; i <= n; i++ {
		factors := primeFactors(i)
		for _, prime := range factors {
			counter[prime]++
		}
	}
	var answer int64 = 1
	for _, count := range counter {
		answer = answer * int64(count) % DEVIDE
	}
	fmt.Println(answer)
}

func isPrime(number int) bool {
	return primeSieve[number]
}

// 自然数 max 未満の素数の配列をエラトステネスのふるいで求める
func initPrime(max int) {
	primeSieve = make([]bool, max+1)
	primes = make([]int, 1, max)
	primes[0] = 2
	for n := 2; n < max; n++ {
		primeSieve[n] = true
	}
	for n := 2; n < max; n++ {
		if !primeSieve[n] {
			continue
		}
		primes = append(primes, n)
		for m := n * 2; m < max; m += n {
			primeSieve[m] = false
		}
	}
}

func primeFactors(number int) []int {
	if (isPrime(number)) {
		return []int{number}
	}
	factors := make([]int, 0, 10)
	for i := 0; primes[i] <= number; i++ {
		prime := primes[i]
		for number % prime == 0 {
			factors = append(factors, prime)
			number /= prime
		}
	}
	return factors
}


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

int iskaibun(int n) {
	char buffer[100];
	int i,len;
	sprintf(buffer,"%d",n);
	len=strlen(buffer);
	for(i=0;i+i<len;i++) {
		if(buffer[i]!=buffer[len-i-1])return 0;
	}
	return 1;
}

int main(void) {
	int n;
	int i;
	scanf("%d",&n);
	for(i=0;;i++) {
		if(iskaibun(n-i)) {
			printf("%d\n",n-i);
			break;
		}
		if(iskaibun(n+i)) {
			printf("%d\n",n+i);
			break;
		}
	}
	return 0;
}

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

int main() {
	
	//vector<int> a(n);  (a.begin(),a.end())
	//cout << "test" << endl;

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";


	int n,x;
	cin >> n >> x;
	
	int ans=1;
	
	
	vector<int> a(n);
	
	rep(i,n) cin >> a[i];
	
	
	rep(i,n){
		x-=a[i];
		
		if(x<0) break;
		ans++;
		
	}
	
	cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int p,int q){
  int s;
  while(q){
    p%=q;
    s=p;
    p=q;
    q=s;
  }
  return p;
}
int main(){
  int g,p,q;
  while(cin>>p>>q){
    g=gcd(p,q);
    cout<<g<<" "<<p/g*q<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stack>
#include <vector>

int main() {
    int n, q;
    std::cin >> n >> q;

    std::vector<std::stack<int>> Ss(n);
    for (int i = 0; i < q; i++) {
        int op, t;
        std::cin >> op >> t;
        if (op == 0) {
            int x;
            std::cin >> x;
            Ss[t].push(x);
        } else if (op == 1) {
            if (!Ss[t].empty()) {
                std::cout << Ss[t].top() << std::endl;
            }
        } else if (op == 2) {
            if (!Ss[t].empty()) {
                Ss[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4448
#include <bits/stdc++.h>
using namespace std;
typedef pair<int , int> ii;

string s , t;
int DP[3005][3005];
int pre[3005][3005][2];
int N , M;
char a[3005] , b[3005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> s >> t;
    N = s.size();
    M = t.size();
    for(int i = 1; i <= N; ++i){
        a[i] = s[i - 1];
    }
    for(int j = 1; j <= M; ++j){
        b[j] = t[j - 1];
    }
    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= M; ++j){
            for(int k = 0; k < 2; ++k){
                pre[i][j][k] = -1;
            }
        }
    }
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= M; ++j){
            if(a[i] == b[j]){
                if(DP[i][j] < DP[i - 1][j - 1] + 1){
                    DP[i][j] = DP[i - 1][j - 1] + 1;
                    pre[i][j][0] = i - 1;
                    pre[i][j][1] = j - 1;
                }
            }
            else{
                if(DP[i][j] < DP[i - 1][j]){
                    DP[i][j] = DP[i - 1][j];
                    pre[i][j][0] = i - 1;
                    pre[i][j][1] = j;
                }
                if(DP[i][j] < DP[i][j - 1]){
                    DP[i][j] = DP[i][j - 1];
                    pre[i][j][0] = i;
                    pre[i][j][1] = j - 1;
                }
            }
        }
    }
    int dx = N , dy = M;
    string ret = "";
    while(pre[dx][dy][0] != -1){
        int nx = pre[dx][dy][0];
        int ny = pre[dx][dy][1];
        if(nx + 1 == dx && ny + 1 == dy){
            ret += b[dy];
        }
        dx = nx;
        dy = ny;
    }
    reverse(ret.begin() , ret.end());
    cout << ret << endl;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

#define MAX_N 200000
bitset<MAX_N> b(0);

void print_b(const int n) {
    REP(i, n) {
        cerr << b[i];
    }
    cerr << "\n";
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    int cnt = 0;
    REP(i, n) {
        cin >> a[i];
    }
    REPR(i, n) {
        bool cnd = a[i];
        // print_b(n);
        FOR(j, 2, n / (i + 1) + 1) {
            // DBG(j * (i + 1));
            // DBG(cnd);
            cnd ^= b[j * (i + 1) - 1];
        }
        // DBG(i);
        // DBG(cnd);
        if(cnd) {
            b.set(i);
            cnt++;
        }
        else b.reset(i);
    }
    cout << cnt << "\n";
    bool out_flg = false;
    if(cnt > 0) {
        REP(i, n) {
            if(b[i] && !out_flg) {
                cout << i + 1;
                out_flg = true;
            }
            else if(b[i]) cout << " " << i + 1;
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 1792
typedef long long ll;

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

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

const int MAX = 50;
const int inf = 64;
int g[64][64];

int main(){
  const int n = getInt();
  vector<set<int> > a(n);
  vector<int> b(n);
  REP(i,n) a[i].insert(getInt());
  REP(i,n) b[i] = getInt();

  REP(i,MAX+1) REP(j,MAX+1) g[i][j] = inf;
  REP(i,MAX+1) g[i][i] = 0;

  for(int i = 1; i <= MAX; i++)  REP(j,MAX+1) {
    g[j][j % i] = min(g[j][j % i], i);
  }

  REP(k,MAX+1) REP(i,MAX+1) REP(j,MAX+1){
    if(g[i][k] > g[k][j])
      g[i][j] = min(g[i][j], g[i][k]);
  }

  REP(i,n) if(g[*a[i].begin()][b[i]] == inf){
    puts("-1");
    return 0;
  }

  ll ans = 0;

  for(int i = MAX; i >= 1; i--){
    bool use = false;

    REP(j,n) if(a[j].count(b[j]) == 0){
      bool need = true;
      for(int aa : a[j]) {
	if(g[aa][b[j]] < i) need = false;
      }
      if(need) use = true;
    }

    if(use){
      REP(j,n) if(a[j].count(b[j]) == 0){
	set<int> next;

	for(int aa : a[j]) {
	  if(g[aa][b[j]] < i) next.insert(aa);
	  const int t = aa % i;
	  if(g[t][b[j]] < i){
	    next.insert(t);
	  }
	}

	while(next.size() == 0);
	a[j] = next;
      }

      ans += 1ll << i;
    }
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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




int main() {
  ll N; // 変数の宣言
  cin >> N; // 標準入力

  string ans;
  while(N){
    N--;
    ans = ans +char('a'+N%26);
    N = N/26;
  }
  reverse(ans.begin(),ans.end());
  

cout << ans << endl; // 標準出力
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#include <stack>
#include <bitset>
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
void proc(string s) {
  int cnt = 0;
  for (int i = 0; i < s.size()-1; i++) {
    int l = i;
    int r = i+1;
    while (l >= 0 && r < s.size() && s[l] == 'S' && s[r] == 'T') {
      l--;
      r++;
      cnt += 2;
      i = r-1;
    }
  }
  int f_ans = s.size() - cnt;
  // cout << s.size() - cnt << endl;
  stack<int> st;
  for (char c : s) {
    if (c == 'S') {
      st.push(c);
    } else if (c == 'T') {
      if (!st.empty() && st.top() == 'S') {
        st.pop();
      } else {
        st.push(c);
      }
    }
  }
  // cout << st.size() << endl;
  int s_ans = st.size();
  cout << s_ans << endl;
  if (s_ans != f_ans) {
    // cout << s_ans << ":" << f_ans << endl;
  }
}
int main() {
  for (int i = 0; i < 64; i++) {
    bitset<6> b(i);
    string s = "";
    for (int m = 0; m < b.size(); m++) {
      if (b[m]) {
        s += "S";
      } else {
        s += "T";
      }
    }
    // cout << s << endl;
    // proc(s);
  }
  string s;
  cin >> s;
  proc(s);
  return 0;
}


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

int main()
{
  char arr[4];
  for (int i = 0; i < 4; i++)
  {
    cin >> arr[i];
  }
  bool g = true;
  for (int i = 0; i < 3; i++)
  {
    if (arr[i] == arr[i+1]) g = false;
  }
  if (g) cout << "Good";
  else cout << "Bad";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char x[5];
	scanf("%s",x);
	int a,b,c,d;
	a=x[0]-'0';
	b=x[1]-'0';
	c=x[2]-'0';
	d=x[3]-'0';
	if(a-b-c-d==7)
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	else
		if(a-b-c+d==7) 
			printf("%d-%d-%d+%d=7\n",a,b,c,d);	
		else
			if(a-b+c-d==7)
				printf("%d-%d+%d-%d=7\n",a,b,c,d);
			else
				if(a-b+c+d==7) 
					printf("%d-%d+%d+%d=7\n",a,b,c,d);
				else
					if(a+b-c-d==7)
						printf("%d+%d-%d-%d=7\n",a,b,c,d);
					else
						if(a+b-c+d==7) 
							printf("%d+%d-%d+%d=7\n",a,b,c,d);	
						else
							if(a+b+c-d==7)
								printf("%d+%d+%d-%d=7\n",a,b,c,d);
							else
								if(a+b+c+d==7) 
									printf("%d+%d+%d+%d=7\n",a,b,c,d);
		return 0;
				
}

Measured memory_bytes: 128
# ABC082C - Good Sequence (ARC087C)
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    cnt = {}
    for i in lst:
        if i not in cnt:
            cnt[i] = 0
        cnt[i] += 1
    ans = 0
    for i, j in cnt.items():
        if i > j:
            ans += j
        elif i < j:
            ans += j - i
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

const int MAX = 1e5 + 10 ;
const long long mod = 1e9 + 7ll ;
vector< vector<int> >adjlist ;
long long dp[MAX][2] ;
int n ;

long long solve(int parent , int node , int color)
{
    if(adjlist.size() == 1 && parent != -1)
        return 1ll ;
    long long &ret = dp[node][color] ;
    if(ret != -1)
        return ret ;
    ret = 1ll ;
    for(auto &child : adjlist[node])
    {
        if(child == parent)
            continue;
        if(color == 1)
            ret = (ret * solve(node , child , 0)) % mod ;
        else
        {
            long long ways = (solve(node , child , 0) + solve(node , child , 1)) % mod ;
            ret = (ret * ways) % mod ;
        }
    }
    return ret ;
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n ;
    adjlist = vector< vector<int> >(n+2) ;
    for(int i = 0 ; i < n-1 ; ++i)
    {
        int x , y ;
        cin>>x>>y ;
        --x ;
        --y ;
        adjlist[x].push_back(y);
        adjlist[y].push_back(x);
    }
    return cout<<((solve(-1 , 0 , 0) + solve(-1 , 0 , 1)) % mod) % mod<<"\n" , 0 ;
}


Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
struct pr{
	int b,c;
	bool operator<(const pr&a)const{
		return c<a.c;
	}
};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	sort(a.begin(),a.end());
	priority_queue<pr>q;
	for(int i=0;i<m;++i){
		int b,c; cin>>b>>c;
		q.push({b,c});
	}
	int i=0;
	while(i<n&&q.size()){
		int b=q.top().b,c=q.top().c; q.pop();
		while(b&&i<n&&a.at(i)<c){
			a.at(i)=c;
			--b,++i;
		}
		if(b)break;
	}
	cout<<accumulate(a.begin(),a.end(),0L)<<"\n"s;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[114514], b[114514];

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		while (a[i]%2==0) a[i] /= 2, b[i]++;
	}
	cout << accumulate(b,b+n,0ll) << ln;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int w, h; cin >> w >> h;
    char c[w][h];
    for(int i = 0; i < w; ++i) {
        int count = 0;
        for(int j = 0; j < h; ++j) {
            cin >> c[i][j];
            if(c[i][j] == '.') ++count;
        }
        if(count == h) {
            for(int k = 0; k < h; ++k) {
                c[i][k] = 'a';
            }
        }
    }

    for(int i = 0; i < h; ++i) {
        int count = 0;
        for(int j = 0; j < w; ++j) {
            if(c[j][i] == '.' || c[j][i] == 'a') ++count;
        }
        if(count == w) {
            for(int k = 0; k < w; ++k) {
                c[k][i] = 'a';
            }
        }
    }

    for(int i = 0; i < w; ++i) {
        bool flag = 0;
        for(int j = 0; j < h; ++j) {
            if(c[i][j] != 'a') {
                cout << c[i][j];
                flag = 1;
            }
        }
        if(flag) cout << '\n';
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int d,g;
    cin >> d >> g;
    VI p(d), c(d), comp(d);
    REP(i,0,d) cin >> p[i] >> c[i];
    REP(i,0,d) comp[i] = (i+1) * 100 * p[i] + c[i];
    int ans = 1000;
    REP(i,0,1<<d) {
        int score = 0;
        int cnt = 0;
        REP(j,0,d) {
            if (i & (1 << j)) {
                score += comp[j];
                cnt += p[j]; 
            }
        }
        //cerr << i << " " << cnt << " " << score << " " << g << endl;
        RREP(j,0,d) {
            if (g - score <= 0) break;
            if (i & (1 << j)) continue;
            int tmp = min(p[j]-1, ((g - score) + (j + 1) * 100 - 1) / ((j + 1) * 100));
            //dump(j);
            //dump(tmp);
            cnt += tmp;
            score += tmp * (j + 1) * 100;
        }
        //dump(cnt);
        if (g - score <= 0) ans = min(ans, cnt);
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
import bisect
def main():
    N = int(input())
    a = list(map(int, input().split()))
    d = {}
    for i, v in enumerate(a):
        if v in d:
            d[v].append(i)
        else:
            d[v] = [i]
    t = -1
    r = 0
    if 1 not in d:
        return -1
    for i in range(1, N+1):
        if i not in d:
            r += N - 1 - t
            break
        j = bisect.bisect_left(d[i], t)
        if j == len(d[i]):
            r += N - 1 - t
            break
        r += d[i][j] - t - 1
        t = d[i][j]
    return r
print(main())


Measured memory_bytes: 51428
from collections import deque
n, q = map(int, input().split())
queue = deque()
for i in range(n):
    name, time = input().split()
    queue.append({"name": name, "time": int(time)})
t = 0
while len(queue) != 0:
    #print([queue[i]["time"] for i in range(len(queue))])
    head = queue.popleft()
    if head["time"] <= q:
        t += head["time"]
        name = head["name"]
        print("{} {}".format(name, t))
    else:
        queue.append({"name": head["name"], "time": head["time"] - q})
        t += q



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


int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int N = 5;

	//注文してから届くまでの時間
	vector<int> Time = { a, b, c, d, e };

	//順番の並び替え
	vector<int> index = { 0,1,2,3,4 };


	int BestTime = (int)1e9; //←10の9乗(double)

	//indexの中身が
	//0,1,2,3,4
	//0,1,2,4,3
	//:
	//4,3,2,1,0
	//の全探索が出来る！(当然DFSとかで探索して求めてもOK)
	do {
		int NowTime = 0;
		for (int i = 0; i < N; i++)
		{
			//10で割り切れるようになるまで1を足し続ける
			while (NowTime % 10 != 0) NowTime++;
			NowTime += Time[index[i]];
		}
		BestTime = min(NowTime, BestTime);
		
	} while (next_permutation(index.begin(), index.end()));
	
	cout << BestTime << endl;
}



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

#define ll long long
using namespace std;

ll n,k;
ll num[200005]; 
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	sort(num,num+n);
	ll res = 0;
	for(int i=0;i<n-k;i++){
		res+=num[i];
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        if (a < 10) System.out.println(b + 100 * (10 - a));
        else System.out.println(b);
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

char c;

int main() {
    cin >> c;
    cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

class SlidingWindowAggretgation:
    def __init__(self, default, f = min):
        self.default = default
        self.f = f
        self.front_stack = deque()
        self.back_stack = deque()

    def get(self):
        res = self.default
        if self.front_stack:
            res = self.f(res, self.front_stack[-1][1])
        if self.back_stack:
            res = self.f(res, self.back_stack[-1][1])
        return res

    def append(self, x):
        fx = x
        if self.back_stack:
            fx = self.f(self.back_stack[-1][1], x)
        self.back_stack.append((x, fx))

    def popleft(self):
        if not self.front_stack:
            x, fx = self.back_stack.pop()
            self.front_stack.append((x, x))
            while self.back_stack:
                x, fx = self.back_stack.pop()
                fx = self.f(x, self.front_stack[-1][1])
                self.front_stack.append((x, fx))
        self.front_stack.pop()

def solve():
    n = I()
    p = LIR(n)
    p.sort()
    maxl = max([l for (l,r) in p])
    minr = min([r for (l,r) in p])
    ans = max(0, minr-maxl+1)+max([r-l+1 for (l,r) in p])
    swagll = SlidingWindowAggretgation(0,max)
    swagrr = SlidingWindowAggretgation(float("inf"),min)
    for l,r in p:
        swagrr.append(r)
    for l,r in p[:-1]:
        swagll.append(l)
        swagrr.popleft()
        ll = swagll.get()
        rr = swagrr.get()
        k = max(minr-ll+1,0)+max(rr-maxl+1,0)
        if ans < k:
            ans = k
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 76892