akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S, T;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	cin >> N;
	cin >> S >> T;
	string Ans;
	for (i = 0; i < N; i++) {
		Ans.push_back(S[i]);
		Ans.push_back(T[i]);
	}
	cout << Ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = Integer.valueOf(sc.nextLine());
			if(n==0) break;
			
			int[][] cost = new int[200][200];
			for(int i=0;i<200;i++) Arrays.fill(cost[i], Integer.MAX_VALUE);
			ArrayList<String> list = new ArrayList<String>();
			int p, q, r;
			for(int i=0;i<n;i++){
				String[] s = sc.nextLine().replace('^', ' ').split(" ");
				if(list.contains(s[1])==false) list.add(s[1]);
				if(list.contains(s[5])==false) list.add(s[5]);
				p = list.indexOf(s[1]);
				q = list.indexOf(s[5]);
				r = Integer.valueOf(s[4]);
				cost[q][p] = r;
				cost[p][q] = -r;
			}
			
			boolean flag = false;
			int m = list.size();
			for(int i=0;i<m;i++) cost[i][i] = 0;
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					for(int k=0;k<m;k++){
						if(cost[j][i]!=Integer.MAX_VALUE && cost[i][k]!=Integer.MAX_VALUE){
							if(cost[j][k]==Integer.MAX_VALUE){
								cost[j][k] = cost[j][i]+cost[i][k];
							}else if(cost[j][k] != cost[j][i]+cost[i][k]){
								flag = true;
								k = m;
								j = m;
								i = m;
							}
						}
					}
				}
			}
			
			if(flag==false) System.out.println("Yes");
			else System.out.println("No");
		}	
	}	
}

Measured memory_bytes: 55496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    string S;
    cin >> S;
    N = S.size();
    rep(i,N){
        if(S[i] == '?'){
            S[i] = 'D';
        }
    }
    /*
    ll ans = 0;
    rep(i,N){
        if(S[i] == 'D')ans++;
    }
    rep(i,N-1){
        if(S.substr(i,2) == "PD")ans++;
    }*/
    cout << S << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int , int>
#define psi pair <string , int >
#define pll pair <ll , ll>
#define pi 3.14159265358979323846
using namespace std;
int main()
{
    int n , x;
    cin >> n;
    vector < int > v(n , 0);
    for(int i = 0 ; i < (n - 1) ; i++)
    {
        cin >> x;
        --x;
        v[x]++;
    }
    for(int i = 0 ; i < n ; i++) cout << v[i] << '\n';
    ///code here
    return 0;
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

const vi dx={1,0,-1,0},dy={0,1,0,-1};

void set_frame(vector<string>& vstr,string s){
    vector<string> t(vstr.size()+2,"");
    rep(i,vstr[0].size()+2){
        t[0] += s;
    }
    t[vstr.size()+1] = t[0];
    rep(i,vstr.size()){
        t[i+1] = vstr[i];
        t[i+1] = s + t[i+1] + s; 
    }
    vstr = t;
}

void print_vvi(vvi vvi){
    int s = vvi[0].size();
    rep(i,vvi.size()){
        rep(j,s){
            cout << vvi[i][j] << " ";
        }
        cout<< "\n";
    }
}

int main(){

    int h,w;
    cin>>h>>w;
    vc<string> s(h);
    rep(i,h)cin>>s[i];

    set_frame(s,"#");

    queue<tuple<int,int,int>> que;
    vvi checked(h+2,vi(w+2));

    int max=0;
    repa(i,1,h+2){
        repa(j,1,w+2){
            if(s[i][j]=='.'){
                que.emplace(i,j,0);
                vvi(h+2,vi(w+2,0)).swap(checked);
                while(!que.empty()){
                    int y,x,c;
                    tie(y,x,c)=que.front();que.pop();
                    if(checked[y][x]==1)continue;
                    checked[y][x]=1;
                    if(max<c)max=c;
                    rep(k,4){
                        if(s[y+dy[k]][x+dx[k]]=='.')que.emplace(y+dy[k],x+dx[k],c+1);
                    }
                }
            }
        }
    }

    cout<<max<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
const vector<int> dir = { 0, 1, 0, -1 };
int Q, x;
int main() {
	cin >> Q;
	while (Q--) {
		vector<int> a(10);
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				cin >> x; a[i] |= x << j;
			}
		}
		for (int i = 0; i < 1 << 10; i++) {
			vector<int> b = a, c(10); c[0] = i;
			for (int j = 0; j < 10; j++) {
				if (i & (1 << j)) {
					for (int k = 0; k < 4; k++) {
						int tx = dir[k], ty = j + dir[k ^ 1];
						if (0 <= tx && tx < 10 && 0 <= ty && ty < 10) {
							b[tx] ^= 1 << ty;
						}
					}
					b[0] ^= 1 << j;
				}
			}
			for (int j = 0; j < 9; j++) {
				c[j + 1] = b[j];
				for (int k = 0; k < 10; k++) {
					if (b[j] & (1 << k)) {
						for (int l = 0; l < 4; l++) {
							int tx = j + 1 + dir[l], ty = k + dir[l ^ 1];
							if (0 <= tx && tx < 10 && 0 <= ty && ty < 10) {
								b[tx] ^= 1 << ty;
							}
						}
						b[j + 1] ^= 1 << k;
					}
				}
			}
			if (b[9] == 0) {
				for (int j = 0; j < 10; j++) {
					for (int k = 0; k < 10; k++) {
						if (k) cout << ' ';
						cout << ((c[j] & (1 << k)) ? 1 : 0);
					}
					cout << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int i,j;
  long k,n,ans[55];
  const long lim=1e16+1000;
  cin >> k;
  n=2;
  while (n*lim<k) n++;
  for (i=0;i<n;i++) ans[i]=k/n+n-1;
  k%=n;
  for (i=0;i<k;i++){
    ans[i%n]+=n+1;
    for (j=0;j<n;j++) ans[j]--;
  }
  cout << n << endl;
  for (i=0;i<n;i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
S=input()
N=len(S)

def gg1(T):
    t=T[::-1]
    if T==t:
        a=0
        return a
    else:
        a=1
        return a

def gg2(R):
    r=(N-1)/2
    r=int(r)
    R1=R[:r]
    R2=R1[::-1]
    if R1==R2:
        b=0
        return b
    else:
        b=1
        return b

def gg3(Q):
    q=(N+3)/2-1
    q=int(q)
    Q1=Q[q:N+1]
    Q2=Q1[::-1]
    if Q1==Q2:
        c=0
        return c
    else:
        c=1
        return c

d=gg1(S)+gg2(S)+gg3(S)
if d==0:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
typedef long long lli;

lli solve(vector<lli> v) {
  sort(v.begin(), v.end(), greater<lli>());
  lli res = 0;
  for(lli i = 0, sum = 0, cnt = 0; i+2 < v.size(); ++i) {
    if(v[i+1]+v[i+2] > v[i]) {
      sum += v[i+1]+v[i+2]+v[i];
      i += 2;
      ++cnt;
      if(cnt == 2) {
        res = max(res, sum);
        break;
      }
    }
  }

  for(int i = 0; i+5 < v.size(); ++i) {
    for(int k = 0; k < (1<<6); ++k) {
      if(__builtin_popcount(k) != 3) continue;
      vector<lli> a, b;
      for(int j = 0; j < 6; ++j) {
        if(k & (1<<j)) a.push_back(v[i+j]);
        else b.push_back(v[i+j]);
      }
      if(a[1]+a[2] > a[0] && b[1]+b[2] > b[0]) {
        res = max(res, a[0]+a[1]+a[2]+b[0]+b[1]+b[2]);
        i = k = 1<<28;
        break;
      }
    }
  }

  return res;
}

int main() {
  int N;
  while(cin >> N) {
    vector<lli> v(N);
    for(int i = 0; i < N; ++i) cin >> v[i];
    cout << solve(v) << endl;
  }
  return 0;
}

Measured memory_bytes: 2592
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<bool> grundy(K + 1);
    rep(i, 1, K + 1) {
        rep(j, N) {
            if (a[j] <= i) {
                if (!grundy[i - a[j]]) grundy[i] = true;
            }
            else break;
        }
    }

    write(grundy[K] ? "First" : "Second");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){                        
	int a;
	cin>>a;
	vector<int> v(a);
	int m[a];
	bool c=0;
	for(int i=0;i<a;i++){
		cin>>m[i];
		
	}
	/*
	for(int i=0;i<a;i++){
		if(m[i]%2==0 && (m[i]%3==0 || m[i]%5==0)){
			c=1;
		}
		if(m[i]%2==0 && (m[i]%3!=0 || m[i]%5!=0)){
			c=0;
			break;
		}
	}
	if(c==1) cout<<"APPROVED";
	else cout<<"DENIED"; */

	for(int i=0;i<a;i++){
		if(m[i]%2==0){
			v.push_back(m[i]);		
		}
	}
	for(int i=0;i<(int)v.size();i++){
		if(v[i]%3==0 || v[i]%5==0) c = true;
		else if(v[i]%3!=0 || v[i]%5!=0){ c = false; break;}
	}
	if(c==true) cout<<"APPROVED";
	else cout<<"DENIED";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        map<string, int> item;
        for(int i=0; i<n; ++i){
            string name;
            int cost;
            cin >> name >> cost;
            item[name] = cost;
        }

        int m;
        cin >> m;
        vector<vector<string> > recipe(m);
        for(int i=0; i<m; ++i){
            string s;
            int k;
            cin >> s >> k;
            recipe[i].resize(k+1);
            recipe[i][0] = s;
            for(int j=1; j<=k; ++j)
                cin >> recipe[i][j];
        }

        for(int i=0; i<m; ++i){
            for(int j=0; j<m; ++j){
                int cost = 0;
                for(unsigned k=1; k<recipe[j].size(); ++k)
                    cost += item[recipe[j][k]];
                item[recipe[j][0]] = min(item[recipe[j][0]], cost);
            }
        }

        string s;
        cin >> s;
        cout << item[s] << endl;
    }
}

Measured memory_bytes: 0
n = int(input())
b_list = list(map(int, input().split()))
q = int(input())
a_list=[0]*100000
for i in b_list :
  a_list[i-1]+=1
count=sum(b_list)
for i in range(q):

  b, c = map(int, input().split())
  count+=(c-b)*a_list[b-1]
  print(count)

  a_list[c - 1] +=a_list[b-1]
  a_list[b - 1] = 0

Measured memory_bytes: 20832
A, B, C = map(int, input().split())
K = int(input())

K2 = 0
if B>A:#緑>赤
    if C>B:#青>緑
        pass
    else:#緑>青
        while B>=C:
            C = C*2
            K2 = K2 +1
            if C>B:
                break
else:#赤>緑
    while A>=B:
        B = B*2
        K2 = K2 +1
        if B>A:
            break
    if C>B:#青>緑
        pass
    else:#緑>青
        while B>=C:
            C = C*2
            K2 = K2 +1
            if C>B:
                break

if K2 > K:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    ll N,M;
    cin>>N>>M;
    int X[M+1];
    FOR(i,1,M){
    	cin>>X[i];
    }
    sort(X+1,X+M+1);
    ll Y[M+1];
    FOR(i,1,M-1){
    	Y[i]=X[i+1]-X[i];
    }
    sort(Y+1,Y+M);
    ll ans=0;
    if(N-M>=0) cout<<0<<endl;
    else{
    	FOR(i,1,M-N){
    		ans+=Y[i];
    	}
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
H = int(input())
W = int(input())
N = int(input())

if H >= W:
    if N % H == 0:
        ans = int(N / H)
    else:
        ans = int(N / H) + 1
else:
    if N % W == 0:
        ans = int(N / W)
    else:
        ans = int(N / W) + 1

print(ans)

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 100000;
int n;
i64 a[MAX_N];
i64 b[MAX_N];

int main()
{
  cin >> n;
  i64 aSum = 0, bSum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    aSum += a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    bSum += b[i];
  }

  if (aSum < bSum) {
    cout << -1 << endl;
    return 0;
  }

  int res = 0;
  vl excess;
  i64 shortage = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= b[i]) excess.push_back(a[i]-b[i]);
    else {
      shortage += b[i] - a[i];
      res++;
    }
  }

  sort(excess.begin(),excess.end());

  for (auto it = excess.rbegin(); it != excess.rend() && shortage > 0; it++) {
    shortage -= *it;
    res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2936
def gap i
  c = 0
  until i % 10 == 0
    i = i.succ
    c += 1
  end
  return c
end

a = [ ]
a.push gets.to_i # donburi
a.push gets.to_i # kare-
a.push gets.to_i # pasta
a.push gets.to_i # ra-men
a.push gets.to_i # hanba-gu

a.sort_by!{ |t| gap(t) }

sum = a.inject(:+)
a.pop
sum += a.map{ |x| gap(x) }.inject(:+)

p sum


Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N,K;
    int sum = 0;

    cin >> N >> K;

    vector<int> p(N);

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

    sort(p.begin(),p.end());

    for(int i = 0; i < K ; i++){
         sum = p[i] + sum;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;

int main(){
    ios;
    int w, v, a, b;
    cin>>a>>v;
    cin>>b>>w;
    cin>>n;
    if(w>=v) return cout<<"NO", 0;
    int s = abs(a-b);
    n -= s/(v-w);
    if(s%(v-w)) n--;
    if(n<0) return cout<<"NO", 0;
    cout<<"YES";
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ((A+B) >(C+D)) {
    cout << "Left" << endl;
  }
  else if ((A+B) < (C+D)) {
    cout << "Right" << endl;
  }
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var whn = ReadIntArray();
            var w = whn[0];
            var h = whn[1];
            var n = whn[2];
            var left = 0;
            var right = w;
            var bottom = 0;
            var top = h;

            for (var i = 0; i < n; i++)
            {
                var xya = ReadIntArray();
                var x = xya[0];
                var y = xya[1];
                var a = xya[2];
                switch (a)
                {
                    case 1: left = Math.Max(left, x); break;
                    case 2: right = Math.Min(right, x); break;
                    case 3: bottom = Math.Max(bottom, y); break;
                    case 4: top = Math.Min(top, y); break;
                }
            }

            var width = Math.Max(right - left, 0);
            var height = Math.Max(top - bottom, 0);
            Console.WriteLine(width * height);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13268
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B) = read!(u32, u32);
    let ok = A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0;

    println!("{}", if ok { "Possible" } else { "Impossible" })
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[101][4][4][4];
void solve()
{
  int n;
  cin >> n;
  dp[0][3][3][3] = 1;

  for(int len = 0; len <= n; ++len)
  {
    for(int i1 = 0; i1 < 4; ++i1) 
    {
      for(int i2 = 0; i2 < 4; ++i2) 
      {
        for(int i3 = 0; i3 < 4; ++i3) 
        {
          if (dp[len][i1][i2][i3].x == 0) continue;

          for(int c = 0; c < 4; ++c)
          {
            // cut
            if (c == 2 && i1 == 1 && i2 == 0) continue;
            if (c == 1 && i1 == 2 && i2 == 0) continue;
            if (c == 2 && i1 == 0 && i2 == 1) continue;
            if (c == 2 && i2 == 1 && i3 == 0) continue;
            if (c == 2 && i1 == 1 && i3 == 0) continue;

            dp[len + 1][c][i1][i2] += dp[len][i1][i2][i3];
          }
        }
      }
    }
  }
  mint ans = 0;
  for(int i1 = 0; i1 < 4; ++i1) 
  {
    for(int i2 = 0; i2 < 4; ++i2) 
    {
      for(int i3 = 0; i3 < 4; ++i3) 
      {
        ans += dp[n][i1][i2][i3];
      }
    }
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;
typedef pair<int,int> P;

signed main() {
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];

        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[n+10];
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;

            for (int j = 1; j <= k; j++) {
                if (i - j < 0)
                    break;
                int cost = Math.abs(h[i] - h[i-j]);
                dp[i] = Math.min(cost + dp[i-j], dp[i]);
            }
        }

        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 54328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll t[800005],lazy[800005];
void build(p2 arr[], ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v] = arr[tl].second;
    } else {
        ll tm = (tl + tr) / 2;
        build(arr, v*2, tl, tm);
        build(arr, v*2+1, tm+1, tr);
    }
}
void push(ll v) {
    t[v*2] += lazy[v];
    lazy[v*2] += lazy[v];
    t[v*2+1] += lazy[v];
    lazy[v*2+1] += lazy[v];
    lazy[v] = 0;
}

void update(ll v, ll tl, ll tr, ll l, ll r, ll addend) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v] -= addend;
        lazy[v] -= addend;
    } else {
        push(v);
        ll tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), addend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
    }
}
ll get(ll v, ll tl, ll tr, ll pos) {
    if (tl == tr) {
        return t[v];
    }
    push(v);
    ll tm = (tl + tr) / 2;
    if (pos <= tm) 
        return get(v*2, tl, tm, pos);
    else
        return get(v*2+1, tm+1, tr, pos);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d,a,res=0;
    cin>>n>>d>>a;
    p2 v[n+1];
    for(ll i=1;i<=n;i++){
        cin>>v[i].first>>v[i].second;
        v[i].second=ceil(1.0*v[i].second/a);
    }
    sort(v+1,v+n+1);
    build(v,1,1,n);
    for(ll i=1;i<=n;i++){
        ll val=get(1,1,n,i);
        if(val<=0)
        continue;
        res+=val;
        ll l=i,r=n;
        while(l<=r){
            ll m=(l+r)/2;
            if(v[m].first<=v[i].first+2*d)
            l=m+1;
            else
            r=m-1;
        }
        update(1,1,n,i,r,val);
    }
    cout<<res;
} 


Measured memory_bytes: 15616
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>


#define rep(i,n) for(int i = 0; i < n; ++i)
#define X first
#define Y second

#define MP(x,y) make_pair(x,y)
using namespace std;
typedef pair<int,int> PII;

int main(void){
  int n;
  int w, d, t, in;
  PII p;

  while(1){
    cin >> n >> w >> d;
    if(n == 0 && w == 0)break;
    PII ta;
    queue<PII> q;
    q.push(MP(w,d));
    rep(jk, n){
      cin >> in >> t;
      in--;
      int tmp = q.size();
      rep(i,tmp){
        if(i == in) ta = q.front();
        else q.push(q.front());
        q.pop();
      }
      t %= (ta.X*2 + ta.Y*2);
      if( ta.X + ta.Y < t) t-=(ta.X+ta.Y);

      if( t < ta.X){
        int ti = ta.X - t;
        if( t > ti) swap(t, ti);
        q.push(MP(t, ta.Y));
        q.push(MP(ti, ta.Y));
      }else{
        t -= ta.X;
        int ti = ta.Y - t;
        if( t > ti)swap(t, ti);
        q.push(MP(ta.X, t));
        q.push(MP(ta.X, ti));
      }
    }
    vector<int> ans;
    while(!q.empty()){
      ans.push_back(q.front().X * q.front().Y);q.pop();
    }
    sort(ans.begin(), ans.end());
    rep(i, ans.size()){
      if(i != 0)cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;

int main(void)
{
	int N;
	cin >> N;
	
	vector<bool> flag(N, true); 
	for(int i=0; i<N; i++)
	{
		int p;
		cin >> p;

		if(p == i+1)
			flag[i] = false;
	}

	int ret = 0;
	for(int i=0; i<N-1; i++)
	{
		if(flag[i] == false)
		{
			flag[i] = flag[i+1] = true;
			ret++;
		}
	}
	if(flag[N-1] == false)
		ret++;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,input().split())
    a = 2*(x2 - x1)
    b = 2*(y2 - y1)
    c = x2**2 + y2**2 - x1**2 -y1**2
    d = 2*(x3 - x1)
    e = 2*(y3 - y1)
    f = x3**2 + y3**2 - x1**2 -y1**2
    x = (c*e - f*b)/(a*e - b*d)
    y = (c*d - f*a)/(b*d - e*a)
    r = math.sqrt((x1 - x)**2 + (y1 - y)**2)
    x = round(x,3)
    y = round(y,3)
    r = round(r,3)
    if x == -0.0:
        x = 0.0
    if y == -0.0:
        y = 0.0
    print("{0:.3f}".format(x),end = ' ')
    print("{0:.3f}".format(y),end = ' ')
    print("{0:.3f}".format(r))

Measured memory_bytes: 7756
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define oset tree < int ,  null_type ,  less ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define endl '\n'
#define int long long int
#define db long double
#define str string
#define mod 1000000007
#define ff first
#define ss second
#define PQi priority_queue<int>
#define Vi vector<int>
#define Si set<int>
#define Li list<int>
#define mk make_pair
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define For(i,s,n) for(int i=s;i<n;i++)
#define mat2D(T,r,c) vector<vector<int> > T(r,vector<int>(c))
#define vec2D vector<vector<int> >
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define getVal(x) {int val;cin>>val;x.pb(val);}
#define debug(x) {for(auto i :x) cout << i << " ";cout << endl;}

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	For(i, 0, n)
	cin >> a[i];
	bool ok = true;
	For(i, 0, n) {
		if (a[i] == i + 1)
			ok = false;
	}
	if (ok) {
		cout << 0;
	} else {
		int ans = 0;
		For(i, 0, n - 1) {
			if (a[i] == i + 1) {
				swap(a[i], a[i + 1]);
				ans++;
			}
		}
		if (a[n - 1] == n) {
			swap(a[n - 2], a[n - 1]);
			ans++;
		}
		cout << ans;
	}

}

int32_t main() {
	fastIO;
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
# endif
	solve();
	return 0;
}

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

int main()
{
    int a,b;
    int n,i,ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        ans=ans+(abs(a-b)+1);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion

A, B = ri_()
print('Possible' if A % 3 ==0 or B % 3 == 0 or (A + B) % 3 == 0 else 'Impossible')

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

int main () {
  int n;
  int mi = 1e9 + 1, ma = 0;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    mi = min(a, mi);
    ma = max(a, ma);
  }
  cout << ma - mi << endl;
  return 0;
}


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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};


int main() {
    int N;
    string S;
    cin>>N>>S;
    vector<int> ruiseki1(N+1,0),ruiseki2(N+1,0); //0~i-1までのうちEの人,Wの人

    for (int i = 0; i < N; ++i) {
        if(S[i]=='E'){
            ruiseki1[i+1]=ruiseki1[i]+1;
            ruiseki2[i+1]=ruiseki2[i];
        }else{
            ruiseki1[i+1]=ruiseki1[i];
            ruiseki2[i+1]=ruiseki2[i]+1;
        }
    }
    int ans=N+10;
    for (int i = 0; i < N; ++i) {
        ans=min(ans,ruiseki2[i]+ruiseki1[N]-ruiseki1[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3076
<?php
fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $k);
if ($k <= $a) {
    echo $k.PHP_EOL;
} elseif ($k <= $a + $b) {
    echo $a.PHP_EOL;
} else {
    echo $a - ($k - $a - $b).PHP_EOL;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define ff first
#define tcase int _; cin>> _; for( ; _; --_)
#define ss second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	for(;exp; exp>>=1){
		if(exp % 2 == 1) total = mod(((mod(total, m)) * (mod(base, m))), m);
		base= mod((mod(base, m) * mod(base, m)), m);
	}
	return total;
}

void solve(){
    int n;
    cin >> n;
    n-=3; 

    int c[2001];
    c[0] = c[1] = 1;

    for(int i = 2; i <= 2000; ++i) c[i] = mod(i * c[i- 1],MOD);
    int ans = 0;
    for(int i = 0; n >= 0; ++i){
        int k = mod(c[n + i] * mod(fexp(c[n], MOD-2, MOD) * fexp(c[i], MOD-2, MOD), MOD), MOD);
        ans = mod(ans + k, MOD);
        n-=3;
    }
    cout<< ans<< endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3600
#include <stdio.h>
void swap(int *x, int *y)
{
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
 
int main(void) {
    int x,y;
 
    scanf("%d %d",&x,&y);
 
    if(x<y)
        swap(&x, &y);
 
    while (y) {
        x = x % y;
        swap(&x, &y);
    }
 
    printf("%d\n",x);
 
    return 0;
}
 

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
      int N;
      cin >> N;

      vector<int> vec(N+1);
      for (int i=0; i<=N; i++)
            vec[i] = 0;
      for (int i=1; i <= N; i++){
            for (int j=1; j*i<=N; j++){
                  vec[i*j] += 1;
            }
      }
      int count = 0;
      for (int i=1; i<=N; i++){
            if (vec[i] == 8 && i % 2 == 1)
                  count += 1;
            //cout << i << ": " << vec[i] << endl;
      }
      
      cout << count << endl;
      exit(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    vector<int> a(3);
    rep(i,3)cin >> a[i];
    sort(a.begin(),a.end());
    int aa = a[2]-(a[2]+1)/2;
    int bb = a[2]-a[2]/2;
    //cout << aa-bb << endl;
    cout << abs(a[0]*a[1]*(aa-bb)) << endl;
}



Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;



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

	ll sum = 0;
	ll currentSum;
	string currentStr;
	for (int i = 0; i < pow(2, s.size()-1); i++)
	{
		currentSum = 0;
		currentStr = "";
		// 00, 01, 10, 11 (|S|=3)
		for (int j = 0; j < s.size()-1; j++)
		{
			currentStr.push_back(s[j]);
			if (i & (1 << (s.size() - 1 - 1 - j))) {
				currentSum += stoll(currentStr);
				currentStr = "";
			}
		}
		currentStr.push_back(s[s.size() - 1]);
		currentSum += stoll(currentStr);

		sum += currentSum;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long int ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define deb(x) cout<<"Debug\t"<<#x<<"="<<x<<endl;
#define deb2(x,y) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<endl;
#define deb4(x,y,z,w) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<"\t"<<#w<<"="<<w<<endl;
#define mod 1000000007
#define vi vector<ll>
#define pll pair<ll,ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define pb push_back 
#define pf push_front
#define pll pair<ll,ll>

int main()
{
    ios;
    ll t,i,j,n,x,y,m,temp,ans,sum,mini,k,diff,maxi;string s;bool flag;
    t=1;
    //cin>>t;    
    while(t--)
    {
        cin>>x>>y;
        cout<<x*y<<endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int>a(100010);
    ll ans =0;
    rep(i,n){
        int x;
        cin >>x;
        ans+=x;
        a[x]++;
    }
    int q;
    cin >>q;
    rep(i,q){
        ll b,c;
        cin >>b>>c;
        ans = ans - b * a[b] + c * a[b];
        a[c]+=a[b];
        a[b] =0;
        cout<< ans <<endl;
    }
}



Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	string s;
	int k;
	cin>>n>>s>>k;
	for(int i=0;i<n;i++){
		if(s[i] == s[k-1]){
			cout<<s[i];
		}else{
			cout<<'*';
		}
	}
	cout<<endl;


	return 0;
}


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

using namespace std;

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

    //重複関係などを調べやすい。
    map<int, int> seen;
    //現在調べているところを記録。今はスタートとその次の部分を調べているから1を代入する。
    int i = 1;
    //訪れた場所に数を入れておくことで要素を見つけやすくなる。
    seen[s] = i;
    i++;

    while(true){
        //計算
        //sに代入していく。
        if(s%2 == 0){
            s /= 2;
        }
        else{
            s = 3*s + 1;
        }

        //もし指定したキーがすでに存在していたら、（要素を持つキーとして存在していたら)iを答えとして出す。
        
        if(seen.count(s) > 0){
            cout << i;
            return 0;
        }

        //訪れた場所を記録する。
        seen[s] = i;
        i++;
    }
}


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

#define ll long long

ll f(ll a, ll b)
{
  if (a > b)
    return f(b, a);

  ll d = b / a;
  if (b % a == 0)
    return (2 * d - 1) * a;
  else
    return 2 * d * a + f(b % a, a);
}

int main()
{
  ll n, x;
  cin >> n >> x;
  ll a = x, b = n - x;
  cout << a + b + f(a, b) << endl;
  return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.in", "r", stdin);
    int rez = 0, n, x;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &x);
        while(x % 2 == 0)
        {
            rez++;
            x /= 2;
        }
    }
    printf("%d", rez);
    return 0;
}


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


using namespace std;


int main(){
	int N;
	cin >> N;
	int num1=0;
	int num2=0;
	vector<int> max_pos;
	max_pos.push_back(0);
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a>num1){
			num2=num1;
			num1=a;
			max_pos.erase(max_pos.begin()+1, max_pos.end());

			max_pos[0]=i;
		}else if(a==num1){
			max_pos.push_back(i);
		}else if(a>num2){
			num2=a;
		}

	}
	int d=0;
	for(int i=0;i<N;i++){
		if(i==max_pos[d]){
			if(max_pos.size()>1){
				cout << num1 << endl;
				d++;
			}else{
				cout << num2 << endl;
			}
		}else{
			cout << num1 << endl;
		}

	}
			
	return 0;

}

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

using namespace std;

#define ll long long
#define fi first
#define se second
const int maxn = 1e6 + 10, INF = 1000000009;

ll a[maxn];
bool flg = false;
vector<pair<int,ll> > E[maxn];

void init() {
    for(int i = 0;i < maxn;i++) a[i] = INF;
}
int n,m;
bool vis[maxn];

void dfs(int idx) {

    for(int i = 0;i < E[idx].size();i++) {
        int to = E[idx][i].fi;
        int v = E[idx][i].se;
        if(vis[to]) continue;
        if(a[to] != INF) {
            if(a[to] - a[idx] != v) {
                flg = true;
                return ;
            } else {
               // dfs(to);
                if(flg) return;
            }
        } else {
            a[to] = a[idx] + v;
            dfs(to);
            if(flg) return;
        }
    }
    vis[idx] = true;
    if(flg) return;

}
int L[maxn];
int main(){
    ios_base::sync_with_stdio(0);

	cin>>n>>m;
	for(int i = 0;i < m;i++) {
        int l,r,d;cin>>l>>r>>d;
        L[i] = l;
        E[l].push_back(make_pair(r,d));
        E[r].push_back(make_pair(l,-d));
	}
	for(int i = 0;i < n;i++) {
        if(E[L[i]].size() >= 1) {
            if(vis[L[i]]) continue;
            init();
            a[L[i]] = 0;
            dfs(L[i]);
            if(flg) break;
        }
	}
	if(flg) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
    return 0;
}


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

int main()
{
	int a = 0;
	int b = 0;

	scanf("%d %d", &a, &b);

	if (a < b)
	{
		printf("a < b\n");
	}
	if (a > b)
	{
		printf("a > b\n");
	}
	if (a == b)
	{
		printf("a == b\n");
	}


	return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n; cin >> n;
    float sum = 0;
    int a[110];
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    int temp = round(sum / n);
    int rel = 0;
    rep(i, n){
        rel += pow((a[i] - temp),2.0);
    }
    cout << rel << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    map<int64,int64> mp;
    for (int64 x=1; x*x<=n; x++) {
        for (int64 y=1; y*y<=n; y++) {
            for (int64 z=1; z*z<=n; z++) {
                int64 i = x*x + y*y + z*z + x*y + y*z + z*x;
                mp[i]++;
            }
        }
    }

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

Measured memory_bytes: 5480
S = input()
first = int(S[:2])
last = int(S[2:])

is_month_first = False
is_month_last = False

if first <= 12 and first > 0:
    is_month_first = True
if last <= 12 and last > 0:
    is_month_last = True

if is_month_first and is_month_last:
    print("AMBIGUOUS")
elif not is_month_first and not is_month_last:
    print("NA")
else:
    if is_month_first:
        print("MMYY")
    else:
        print("YYMM")

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

bool is_prime(int num) {
    // naive
    if (num == 2) {
        return true;
    } else if (num % 2 == 0) {
        return false;
    }

    for (int i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

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

    int loop;
    cin >> loop;
    int count = 0;

    rep(i, loop) {
        int num;
        cin >> num;
        if (is_prime(num)) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3164
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,q=map(int,readline().split())
s=readline().decode('utf-8')
dic={}
c=0
for idx, i in enumerate(s, 1):
  if i=='C' and s[idx-2]=='A':
    c+=1
  dic[idx]=c
lst=map(int,read().split())
lr=list(zip(lst,lst))

for l,r in lr:
  print(dic[r]-dic[l])
  

Measured memory_bytes: 38676
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int x, n; cin >> x >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    rep(i, 110){
        bool flagm=false;
        bool flagp=false;
        for(int y: a){
            if(x+i==y){
                flagp=true;
                if(x-i==y){
                    flagm=true;
                }
            }
            else if(x-i==y){
                flagm=true;
                if(x+i==y){
                    flagp=true;
                }
            }
        }
        if(flagm==false){
            out(x-i);
            return 0;
        }
        else if(flagp==false){
            out(x+i);
            return 0;
        }
    }
    out(x);
}


Measured memory_bytes: 3624
import math , sys
N = int( input() )

X = []
for i in range(N):
    A , B = list(map(int, input().split()))
    X.append([i , A-B , A , A+B])


X.sort(key=lambda x: x[3])

Y = X[0]
Ri = Y[-1]
ans = 1

j=0

for i in range(1,N):
    Y = X[i]
    if Y[1] >= Ri:
        ans+=1
        Ri = Y[-1]
print(ans)


Measured memory_bytes: 94440
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;

bool Dislike[10];

bool isNG(int N)
{
    while(N)
    {
        if (Dislike[N%10]) return true;
        N /= 10;
    }
    return false;
}

void solve()
{
    int N;
    cin >> N;
    int K;
    cin >> K;

    REP0(i, N)
    {
        int d;
        cin >> d;
        Dislike[d] = true;
    }

    while (isNG(N))
    {
        N++;
    }

    cout << N << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256