akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())
cnt = 0

for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()

print(-1, -1, -1)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<map>
#include<ctime>
#define debuglog(x) cerr<<"\tdebug:"<<#x<<endl
#define debug(x) cerr<<"\tdebug:"<<#x<<"="<<(x)<<endl
#define debugg(x,y) cerr<<"\tdebug;"<<(x)<<":"<<#y<<"="<<(y)<<endl
#define debugzu(x,a,b) 	cerr<<"\tdebug:"<<#x<<"=\n\t";for(int i=a;i<b;i++)cerr<<x[i]<<" ";fprintf(stderr,"\n");
#define debugerzu(x,a,b,c,d) 	cerr<<"\tdebug:"<<#x<<"=\n\t";for(int i=a;i<b;i++,fprintf(stderr,"\n\t"))for(int j=c;j<d;j++)cerr<<x[i][j]<<" ";fprintf(stderr,"\n");
#define R register
#define L long
#define LL long long
#define I inline
#define U unsigned
#define START clock_t __start=clock();
#define STOP fprintf(stderr,"\n\nUse Time:%fs\n",((double)(clock()-__start)/CLOCKS_PER_SEC));
using namespace std;
I LL read()
{
	R LL x;R bool f;R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c-'0'; (c=getchar())>='0'&&c<='9'; x=(x<<3)+(x<<1)+c-'0');
	return f?-x:x;
}
#define MAXN 100011
int a[MAXN*2+8];



int main()
{
// 	freopen("agc006_b.in","r",stdin);
// 	freopen("agc006_b.out","w",stdout);
    int n=read(),x=read(),t=1;
    if(x==1||x==2*n-1)
		return printf("No\n"),0;
    printf("Yes\n");
    for(int i=1;i<n-1;i++)
    {
        while(t==x||t==x-1||t==x+1)
			t++;
        printf("%d\n",t++);
    }
    printf("%d\n%d\n%d\n",x-1,x,x+1);
    for(int i=1;i<n-1;i++)
    {
        while(t==x||t==x-1||t==x+1)
			t++;
        printf("%d\n",t++);
    }
	fclose(stdin);
	fclose(stdout);
 	return 0;
}

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

#define MAX 1000

void LCSLength(char *X, char *Y){

    int i,j;
    int m = strlen(X);
    int n = strlen(Y);
    int c[m+1][n+1];

    for( i = 1 ; i <= m ; i++ ){
        c[i][0] = 0;
    }
    for( j = 0 ; j <= n ; j++ ){
        c[0][j] = 0;
    }

    for( i = 1 ; i <= m ; i++ ){
        for( j = 1 ; j <= n ; j++ ){
            if( X[i-1] == Y[j-1] ){
                c[i][j] = c[i-1][j-1] + 1;
            }else if( c[i-1][j] >= c[i][j-1] ){
                c[i][j] = c[i-1][j];
            }else{
                c[i][j] = c[i][j-1];
            }
        }
    }
    

    printf("%d\n",c[i-1][j-1]);

    
}



int main(){

    int n;
    int i;
    char line1[MAX],line2[MAX];

    scanf("%d",&n);

    for( i = 0 ; i < n ; i++ ){
        scanf("%s",line1);
        scanf("%s",line2);
        LCSLength(line1,line2);
    }

    return 0;
}

Measured memory_bytes: 4524
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

static const int MAX_NUM = 100000;

void DFS(int group[], vector<int> vec[], int gnum, int start)
{
    stack<int> S;
    int target;
    int i;
    int tmp;

    S.push(start);
    group[start] = gnum;

    while (S.empty() == false) {
        target = S.top();
        for (i = 0; i < vec[target].size(); i++) {
            if (group[vec[target][i]] == 0) {
                group[vec[target][i]] = gnum;
                S.push(vec[target][i]);
                break;
            }
        }
        if (i == vec[target].size()) {
            S.pop();
        }
    }

    return;
}

void SetupGroup(int group[], vector<int> vec[], int elemnum)
{
    int i;
    int gnum = 0;

    for (i = 0; i < elemnum; i++) {
        if (group[i] == 0) {
            ++gnum;
            DFS(group, vec, gnum, i);
        }
    }
}

int main(void)
{
    int i;
    int num;
    int elemnum;
    int qnum;
    int ele1, ele2;
    vector<int> vec[MAX_NUM];
    int group[MAX_NUM] = {0};

    scanf("%d %d", &elemnum, &num);
    for (i = 0; i < num; i++) {
        scanf("%d %d", &ele1, &ele2);
        vec[ele1].push_back(ele2);
        vec[ele2].push_back(ele1);
    }

    SetupGroup(group, vec, elemnum);

    scanf("%d", &qnum);
    for (i = 0; i < qnum; i++) {
        scanf("%d %d", &ele1, &ele2);
        if (group[ele1] == group[ele2]) {
            printf("yes\n");
        }
        else {
            printf("no\n");
        }
    }
}

Measured memory_bytes: 7424
#!/usr/bin/env python3
# DSL_4_A: Union of Rectangles
# O(N^2)


class Rect:
    def __init__(self, p1, p2):
        self.top_left = p1
        self.bottom_right = p2

    def intersect(self, other):
        xs1, ys1 = self.top_left
        xs2, ys2 = self.bottom_right
        xo1, yo1 = other.top_left
        xo2, yo2 = other.bottom_right

        if xs1 >= xo2:
            return False
        elif xs2 <= xo1:
            return False

        if ys1 >= yo2:
            return False
        elif ys2 <= yo1:
            return False

        return True

    def sub(self, other):
        # assert self.intersect(other), "{} {}".format(self, other)
        xs1, ys1 = self.top_left
        xs2, ys2 = self.bottom_right
        xo1, yo1 = other.top_left
        xo2, yo2 = other.bottom_right
        if xs1 < xo1:
            yield Rect((xs1, ys1), (xo1, ys2))
        if xs2 > xo2:
            yield Rect((xo2, ys1), (xs2, ys2))
        if ys1 < yo1:
            yield Rect((max(xs1, xo1), ys1), (min(xs2, xo2), yo1))
        if ys2 > yo2:
            yield Rect((max(xs1, xo1), yo2), (min(xs2, xo2), ys2))

    def area(self):
        x1, y1 = self.top_left
        x2, y2 = self.bottom_right
        return (x2 - x1) * (y2 - y1)

    def __str__(self):
        return '<Rect({}, {})>'.format(self.top_left, self.bottom_right)


class Rects:
    def __init__(self):
        self.rects = []

    def add(self, rect):
        rects = []
        for r in self.rects:
            if rect.intersect(r):
                rects.extend(r.sub(rect))
            else:
                rects.append(r)
        rects.append(rect)
        self.rects = rects
        # assert self.not_intersect(), self

    def area(self):
        return sum([r.area() for r in self.rects])

    def __str__(self):
        s = '<Rects('
        s += '\n       '.join(str(r) for r in self.rects)
        s += ')>'
        return s

    def not_intersect(self):
        for i in range(len(self.rects)-1):
            for j in range(i+1, len(self.rects)):
                if self.rects[i].intersect(self.rects[j]):
                    return False
        return True


def run():
    n = int(input())
    rects = Rects()
    for _ in range(n):
        x1, y1, x2, y2 = [int(i) for i in input().split()]
        rect = Rect((x1, y1), (x2, y2))
        rects.add(rect)

    print(rects.area())


if __name__ == '__main__':
    run()



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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int answer = INT_MAX;
    for (int i = 0; i <= n - m; i++) {
        int now = 0;
        for (int j = 0; j < m; j++) {
            if (s[i + j] != t[j]) {
                now++;
            }
        }
        /* printf("now = %d\n", now); */
        answer = min(answer, now);
    }
    printf("%d\n", answer);
}


Measured memory_bytes: 3724
N = int(input())
T,A = map(int,input().split())
H = [h for h in map(int,input().split())]
list = []
for _ in H:
    kion = T-(_*0.006)
    sa = abs(A-kion)
    list.append(sa)
list2 = [x for x in list]
list.sort()
best = list[0]
print(list2.index(best)+1)


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

const ll inf = 1LL << 62;
void floydWarshall(vector<vector<ll>>& m) {
  int n = sz(m);
  rep(i,0,n) m[i][i] = min(m[i][i], 0LL);
  rep(k,0,n) rep(i,0,n) rep(j,0,n)
    if (m[i][k] != inf && m[k][j] != inf) {
      auto newDist = max(m[i][k] + m[k][j], -inf);
      m[i][j] = min(m[i][j], newDist);
    }
  rep(k,0,n) if (m[k][k] < 0) rep(i,0,n) rep(j,0,n)
    if (m[i][k] != inf && m[k][j] != inf) m[i][j] = -inf;
}

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

  int h, w;
  cin >> h >> w;

  vector<vector<char>> grid(h, vector<char>(w));
  vvi mat(401, vi(401, inf));
  rep(i,0,h) rep(j,0,w) {
    cin >> grid[i][j];
  }

#define in(i, j) (i >= 0 and i < h and j >= 0 and j < w)
#define id(i, j) (i*w + j)

  rep(i,0,h) {
    rep(j,0,w) {
      if (grid[i][j] != '.') continue;
      rep(di, -1, 2) rep(dj, -1, 2) {
        if (abs(di) + abs(dj) != 1) continue;
        int ni = i+di, nj = j+dj;
        if (not in(ni, nj)) continue;
        if (grid[ni][nj] != '.') continue;
        mat[id(i, j)][id(ni, nj)] = 1;
      }
    }
  }

  floydWarshall(mat);

  ll ans = 0;
  rep(i,0,w*h) {
    rep(j,0,w*h)
    {
      if (mat[i][j] == inf) continue;
      ans = max(ans, mat[i][j]);
    }
  }

  cout << ans << endl;


}

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

void chmin(ll&a, ll b) {
  if (a > b) a = b;
}

int main() {
  int N, W;
  cin >> N >> W;
  ll INF = 10000000000; // Wよりも大きい値
  
  ll w[N+1], v[N+1];
  for (int i = 0; i < N; i++) {
    cin >> w[i+1] >> v[i+1];
  }
  
  ll dp[N+1][100100]; // dp[i][j] i番目まで，価値jが提供できるか，できる場合の最小の重さ
 
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < 100100 ; j++) {
      dp[i][j] = INF;
    }
  }
  
  for (int i = 0; i < N+1; i++) dp[i][0] = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 100100; j++) {
      if(dp[i][j] + w[i+1] <= W) {
        chmin(dp[i+1][j+v[i+1]], dp[i][j] + w[i+1]);
        
      }
      chmin(dp[i+1][j], dp[i][j]);  
    }
  }
    
    int ans = 0;
    for (int i = 0; i < 100100; i++) {
      if (dp[N][i] <= W) ans = i;
  }
      cout << ans << endl;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> V<Z> divisor(Z n) {
  V<Z> res;
  Z i;
  for (i = 1; i * i < n; ++i) if (n % i == 0) res.push_back(i), res.push_back(n / i);
  if (i * i == n) res.push_back(i);
  sort(begin(res), end(res));
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n; cin >> n;
  lint res = 0;
  for (lint q : divisor(n)) {
    lint m = n / q - 1;
    if (q >= m) continue;
    res += m;
  }
  cout << res << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr);
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 

int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    
    priority_queue<pair<ll,ll > >q ;
    
    for(int i = 0;  i <a; i++){
        int x;cin>>x;q.push(mp(x,1));
    }
    for(int i = 0;  i <b; i++){
        int x;cin>>x;q.push(mp(x,2));
    }

    for(int i = 0;  i <c; i++){
        int x;cin>>x;q.push(mp(x,3));
    }
    
    ll ex=0;
    ll ey=0;
    ll ext=0;
    ll res=0;
    while( x+y - ext > 0){
        
        pi p  =q.top();
        if(p.se == 1){
            if(x){
                x--;
                res+=p.fi;
            }
            q.pop();
        }
        
        if(p.se == 2){
            
            if(y){
               y--;
                res+=p.fi;}
             q.pop();
            
            
        }
        
        if(p.se == 3){
            
            
            res +=p.fi;
            ext++;
            q.pop();
            
        }
        
    }
    // cout<<ex<<" "<<ey<<" "<<ext<<endl;
    cout<<res<<endl;
    
}


Measured memory_bytes: 10476
#include <stdio.h>
void Swap(int x[],int l,int r);
void Qsort(int x[],int l,int r);
int main(){
	char c[30];
	int i,j;
	// scanf("%s",&c);
	// for(i=0; i<30; i++)if(c[i]=='\0')break;
	for (i = 0; i < 30; ++i)
	{
		scanf("%c",&c[i]);
		if(c[i]=='\0'||c[i]=='\n'){
			i--;
			break;
		}
	}
	for(j=0; j<=i; j++)printf("%c",c[i-j]);
	printf("\n");
	return 0;
}
void Swap(int x[],int l,int r){
	int temp;
	temp=x[r];
	x[r]=x[l];
	x[l]=temp;
}
void Qsort(int x[],int l,int r){
	int i,j,p;
	i=l;
	j=r;
	p=x[(i+j)/2];
	while(1){
		while(x[i]<p)i++;
		while(x[j]>p)j--;
		if(i>=j)break;
		Swap(x,i,j);
		i++;
		j--;
	}
	if(i-l>1)Qsort(x,l,i-1);
	if(r-j>1)Qsort(x,j+1,r);
}

Measured memory_bytes: 524
$memo = Hash.new({})

def choose(n, x)
  return $memo[n][x] if $memo.fetch(n, {}).fetch(x, nil)

  p = 1
  q = 1
  x.times do |i|
    p *= (n - i)
    q *= (i + 1)
  end

  return $memo[n][x] = (p / q).to_i
end

n = gets.to_i
as = gets.chomp.split.map(&:to_i)

h = Hash.new(0)
as.each { |a| h[a] += 1 }
h.select! { |_, v| v >= 2 }

sum = 0
h.each do |k, v|
  sum += choose(v, 2)
end

as.each do |a|
  res = sum
  if h[a]
    res -= choose(h[a], 2)
    res += choose(h[a] - 1, 2) if h[a] - 1 >= 2
  end
  puts res
end


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

int main()
{
  int a;
  cin >> a;
  int arr[a];
  for (int i = 0; i < a; i++)
  {
      cin >> arr[i];
  }
  sort(arr, arr+a);
  float val = arr[0] + arr[1];
  val /= 2;
  for (int j = 2; j < a; j++)
  {
      val += arr[j];
      val /= 2;
  }
  cout << val;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
list = (1..n).map{x,y=gets.split.map(&:to_i)}
p list.permutation.map{|l|l.each_cons(2).map{|(x1,y1),(x2,y2)|Math.hypot(x1-x2,y1-y2)}.inject(:+)}.inject(:+)/(1..n).inject(:*)


Measured memory_bytes: 2296
x1,y1,x2,y2=map(int,input().split())
dx=abs(x1-x2)
dy=abs(y1-y2)
if x1<x2 and y1<=y2:
    x3=x2-dy
    y3=y2+dx
    x4=x3-dx
    y4=y3-dy
elif x1>=x2 and y1<y2:
    x3=x2-dy
    y3=y2-dx
    x4=x3+dx
    y4=y3-dy
elif x1>x2 and y1>=y2:
    x3=x2+dy
    y3=y2-dx
    x4=x3+dx
    y4=y3+dy
elif x1<=x2 and y1>y2:
    x3=x2+dy
    y3=y2+dx
    x4=x3-dx
    y4=y3+dy
else:
    print("NA")
print(x3,y3,x4,y4)

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

#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define pb push_back
#define pf push_front
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
long N,K,len=1,i,M,ans=1,L,k;
string S;
deque<long>v,s;
inline void solve(void){
  in(N,K,S);
  up(i,1,N-1){
    if(S[i]==S[i-1])len++;
    else{
      v.pb(len);
      len=1;
    }
  }
  v.pb(len);
  if(S[0]=='0')v.pf(0);
  if(S[N-1]=='0')v.pb(0);
  M=v.size();
  s.resize(M+1);
  for(i=0;i<M;i++)s[i+1]=s[i]+v[i];
  for(i=0;i<M;i+=2){
    L=2*K+1+i;
    if(L>=M)L=M;
    chmax(ans,s[L]-s[i]);
  }
  out(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2000
#coding: utf-8
from collections import deque
N, M = map(int, input().split())
dd = {i:[] for i in range(N)}
for i in range(M):
    a, b = map(int, input().split())
    dd[a-1].append(b-1)
    dd[b-1].append(a-1)
ans = [0 for _ in range(N)]
visited = [False for _ in range(N)]
queue = []
for i in range(len(dd[0])):
    queue.append([0, dd[0][i]])
queue = deque(queue)
while queue:
    q = queue.popleft()
    if visited[q[1]]:
        continue
    visited[q[1]] = True
    ans[q[1]] = q[0] + 1
    for v in dd[q[1]]:
        if not visited[v]:
            queue.append([q[1], v])
print("Yes")
print(*ans[1:], sep="\n")


Measured memory_bytes: 125236
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	static class System{
		private static final InputStream in=java.lang.System.in;
		private static final PrintWriter out=new PrintWriter(java.lang.System.out,false);
	}
	public static void main(String[]$){
		new Main().solve();
		System.out.flush();
	}
	static Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt(){return s.nextInt();}
	static long gLong(){return s.nextLong();}
	static long gDouble(){return s.nextLong();}

	static IntStream ints(int n){return REPS(n).map(i->gInt());}
	static Stream<String> strs(int n){return REPS(n).mapToObj(i->s.next());}

	private void solve(){
		int n=gInt(),x=gInt(),y=gInt(),a[]=ints(n).distinct().toArray();

		n=a.length;

		if(n==1)
			System.out.println(Math.abs(a[0]-y));
		else
			System.out.println(Math.max(Math.abs(a[n-1]-y),Math.abs(a[n-2]-a[n-1])));
	}
}

Measured memory_bytes: 29012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 1; i <= n; i++) {
			System.out.println(String.format("Case %d:", i));
			int num = scanner.nextInt();
			int s = 10;
			while (s-- > 0) {
				num = num * num / 100 % 10000;
				System.out.println(num);
			}
		}
	}
}

Measured memory_bytes: 17204
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll k, x; cin >> k >> x;

    RANGE(i, x-k+1, x+k-1) {
        cout << i << " \n"[i==x+k-1];
    }
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      var a = ScanIntArray();
      
      WriteLine(a.Select(_=>div2(_)).Sum());
    }
    static int div2(int num){
      if(num ==0) return 0;
      int res = 0;
      while(true){
        if(num%2==1) return res;
        res++;
        num >>= 1;
      }
    }
  }
    
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 14176
#include <cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
const int N=305;
int n;
long long dis[N][N],ans;

int check(int x,int y) {
	FOR(i,1,n) {
		if(i==x||i==y) continue;
		if(dis[x][y]==dis[x][i]+dis[i][y]) return 0;
		if(dis[x][y]>dis[x][i]+dis[i][y]) return -1;
	}
	return 1;
}
int main() {
	scanf("%d",&n);
	FOR(i,1,n) FOR(j,1,n) scanf("%lld",&dis[i][j]);
	FOR(i,1,n) FOR(j,i+1,n) {
		int opt=check(i,j);
		if(opt<0) return puts("-1"),0;
		if(opt>0) ans+=dis[i][j];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;
int N, K;

long long ch(long long x) {
    x = x%K;
    long long s = N/K + ((x <= N%K && x != 0) ? 1 : 0);
//    cerr << s << " numbers equal " << x << " mod " << K << "\n";
    return s;
}

int main() {
    cin >> N >> K;
    long long ans = 0;
    for(int b = 0; b < K; b++) {
        if((2*b)%K != 0) {
            continue;
        }
//        cerr << "b is " << b << "\n";
        long long x = ch(b)*ch(b)*ch(K-b);
//        cerr << x << "\n";
        ans += x;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
a=int(input())
li = list(map(int,input().split()))

sortedList = sorted(li, reverse=True)

alice = 0
bob = 0
turn = 1

while(len(sortedList)):
  if turn % 2 == 1:
    alice += sortedList.pop(0)
  else:
    bob += sortedList.pop(0)
  
  turn += 1

print(alice - bob)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<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.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i], vec[i]--;

  vector<int> cnt(n, 0);
  rep(i,n) cnt[vec[i]]++;

  vector<int> arr(2*n,0); // arr[i+n] がiを含む個数
  rep(i,n) arr[i]=1;
  rep(i,n){
    rep(j,cnt[i]){
      arr[i+n-j]++;
    }
  }

  int ans = 0;
  repl(i,n,2*n) if(arr[i]==0) ans++;

  rep(_,m){
    int a,b;
    cin>>a>>b;
    a--; b--;

    int prev = vec[a] - cnt[vec[a]] + 1 + n;
    arr[prev]--;
    if(arr[prev] == 0) ans++;
    cnt[vec[a]]--;

    vec[a]=b;
    cnt[b]++;
    int nxt = vec[a] - cnt[b] + 1 + n;
    arr[nxt]++;
    if(arr[nxt] == 1) ans--;

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4608
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

const int N = 1e5 + 5;
ll in[3 * N], foo[3 * N], bar[3 * N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; ++i) scanf("%lld", in + i);

    multiset< ll> st;

    ll s = 0;
    for (int i = 1; i <= 2 * n; ++i) {
        st.insert(in[i]);
        s += in[i];
        if (i > n) {
            ll x = *st.begin();
            s -= x;
            st.erase(st.begin());
        }

        foo[i] = s;
    }

    st.clear();
    s = 0;
    for (int i = 3 * n; i >= 1; i--) {
        st.insert(in[i]);
        s += in[i];
        if (i <= 2 * n) {
            ll x = *(--st.end());
            st.erase(--st.end());
            s -= x;
        }
        bar[i] = s;
    }

    ll res = -1e18;
    for (int i = n; i <= 2 * n; i++) {
        res = max(res, foo[i] - bar[i + 1]);
    }
    cout << res << endl;
}

Measured memory_bytes: 11904
#include<iostream>
using namespace std;
int main(){
    long long int n,m;
	long long int ans = 0;
    cin >> n >> m;
    if(n*2 >  m) {
        ans = m/2;
    } else {
        ans += n;
        m -= n*2;
        ans += m/4;
    }
    cout << ans << endl;
    
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  ll W;
  cin >> n >> W;
  ll w[n], v[n];
  REP(i, n) cin >> w[i] >> v[i];
  vector<ll> vc[4];
  REP(i, n) vc[w[i] - w[0]].push_back(v[i]);
  REP(i, 4) {
    sort(ALL(vc[i]));
    reverse(ALL(vc[i]));
  }
  vector<ll> sum[4];
  REP(i, 4) {
    sum[i].push_back(0);
    ll tmp = 0;
    REP(j, vc[i].size()) {
      sum[i].push_back(tmp + vc[i][j]);
      tmp += vc[i][j];
    }
  }
  ll ans = 0;
  REP(i, sum[0].size()) {
    REP(j, sum[1].size()) {
      REP(k, sum[2].size()) {
        REP(l, sum[3].size()) {
          ll tmp = w[0] * i + (w[0] + 1) * j + (w[0] + 2) * k + (w[0] + 3) * l;
          if (tmp <= W) {
            ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#include <unordered_map> 
#include <cstdio>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n

using namespace std;

// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

// UTILITY FUNCTIONS

// String
char toUpper(const char &c) { return isupper(c) ? c : c - 'a' + 'A'; }
char toLower(const char &c) { return islower(c) ? c : c + 'a' - 'A'; }
bool isvowel(char c){  c = toLower(c);return (c == 'a' or c == 'e' or c == 'i' or c == 'i' or c == 'o' or c == 'u' || c == 'y');}
void toLowerCase(string &s){rep(s.size()){  if (!islower(s[i]))  {    s[i] = tolower(s[i]);  }}}
void toUpperCase(string &s){rep(s.size()) { s[i] = toupper(s[i]); }}
bool ispal(string s){  ll lo, hi;  lo = 0;  hi = s.length() - 1;  while (lo <= hi)  {    if (s[lo] != s[hi])    {      return 0;    }    lo++;    --hi;  }  return 1;}
template <class T>string toString(T n){  string v = "";  while (n)  {    v.pb(n % 10 + '0');    n /= 10;  }  reverse(all(v));  return v;}

// Maths
template <typename t>t gcd(t a, t b){  a = abs(a), b = abs(b);  return ((b == 0) ? a : gcd(b, a % b));}
template <typename t>t lcm(t a, t b) { return (a * (b / gcd(a, b))); }
template <typename T>T modpow(T base, T exp, T modulus){  base %= modulus;  T result = 1;  while (exp > 0)  {    if (exp & 1)      result = (result * base) % modulus;    base = (base * base) % modulus;    exp >>= 1;  }  return result;}
template <typename T>void cumulative(T *a, T *b, T n){  rep(n) { i ? b[i] = b[i - 1] + a[i] : b[i] = a[i]; }}

// Some constants
const int inf = 1e9 + 7;
const double eps = 1e-6;
const double pi = 1.00 * acos(-1.00);

//------------------------------------------------------------------------

void solve(ll testcase){
  string s;
  cin >> s;
  string y = s.substr(2, 2), x = s.substr(0, 2);
  ll foo, bar;
  foo = stoi(x.c_str());
  bar = stoi(y.c_str());
  if(foo > 12 and bar >= 1 and bar <= 12){
    cout << "YYMM\n";
  }else if(bar > 12 and foo >= 1 and foo <= 12){
    cout << "MMYY\n";
  }else if(foo <= 12 and bar <= 12 and foo >= 0 and bar >= 0){
    if(foo == 0 and bar > 0){
      cout << "YYMM\n";
    }else if(bar == 0 and foo > 0){
      cout << "MMYY\n";
    }else if(foo == 0 and bar == 0){
      cout << "NA\n";
    }else
      cout << "AMBIGUOUS\n";
  }else{
    cout << "NA\n";
  }
}

int main()
{
  std::ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef ONLINE_JUDGE
#else
 // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  ll t = 1;
  // cin >> t;
  ll cas = 0;
  while (t--)
  {
    solve(++cas);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> pii;

const int N=1e4+5;
char s[N];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    cin>>s+1;
    for(int i=1;s[i];i++){
        s[i]=(s[i]-'A'+n)%26+'A';
        cout<<s[i];
    }
}


Measured memory_bytes: 256
N,M=map(int,input().split())
S=input()
T=input()
from fractions import gcd
g=gcd(N,M)
r=1
j,k=0,0
for i in range(g):
    if S[j]!=T[k]:
        r=0
    j+=N//g
    k+=M//g
print(M*N//g if r else -1)

Measured memory_bytes: 5304
#include<stdio.h>

int main(void){

int n,count=0,i,j;

scanf("%d",&n);

for(i=1;i<10;i++){
  for(j=1;j<10;j++){
    if(i*j==n){
      count=1;
      break;
    }
  }
if(j!=10){break;}
}

if(count==1){printf("Yes");}
if(count==0){printf("No");}

return 0;
}


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

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

	int sum = 0;
	string a, b;
	cin >> a;
	getchar();
	cin >> b;
	for (int i = 0; i < a.size(); ++i)
	{
		if (a[i] != b[i])
		{
			sum++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3900
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<set>

#define MAX 60

using namespace std;

int N,ans[MAX],remain[14];
bool found;

void rec(int sum,int cnt)
{

  if(found)return;

  if(cnt >= N){
    for(int i=N-1;i>=0;i--){
      if(i != N-1)cout << " ";
      cout << ans[i];
    }
    cout << endl;

    found = true;

    return;
  }

  for(int i=1;i<=13;i++){
    if( remain[i] <= 0 )continue;
    if( ( sum - i ) % i == 0 ){

      remain[i]--;
      ans[cnt] = i;
      rec(sum-i,cnt+1);
      if(found)return;
      remain[i]++;

    }
  }
}

int main(){

  while(cin >> N,N){

    for(int i=0;i<14;i++)remain[i] = 0;

    int c[N+1],sum = 0;
    for(int i=0;i<N;i++){
      cin >> c[i];
      sum += c[i];
      remain[c[i]]++;
    }

    sort(c,c+N);

    found = false;
    rec(sum,0);

    if(!found){
      cout << "No" << endl;
    }
      
  }
  return 0;
}

/*
void rec(int sum,int limit,int *c,int cnt){

  if(found)return;

  if(limit <= 0){

    for(int i=N-1;i>=0;i--){
      if(i != N-1)cout << ' ';
      cout << ans[i];
    }
    cout << endl;

    found = true;

    return;
  }

  for(int i=0;i<limit;i++){
    if( (sum-c[i]) % c[i] == 0){
      ans[cnt] = c[i];

      int sub = c[i];
      swap(c[i],c[limit-1]);
      rec(sum-sub,limit-1,c,cnt+1);
      if(found)return;
      swap(c[i],c[limit-1]);

    }
  }
}
*/

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b,c;
  cin >> a >> b >> c ;
  
  if (b>=(c-1)){
    cout << b+c <<endl;
  }
  else if((a+b)<=(c-1)) {
    cout << a+2*b+1 <<endl;
  }
  else{ 
    cout << b+c << endl;
  }
}

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

int main() {
  int N ,a , b ;
  a = 0;
  b = 0;
  cin >> N ;
  vector<int> vec(N) ;
    for (int i=0; i<N ; i++)
     cin >> vec.at(i) ;
  sort(vec.begin(),vec.end()) ;
  reverse(vec.begin(),vec.end());
  //for (int K=0 ; K<N ; K++)
  //cout << vec.at(K) ;
   

   for (int j=0 ; j<N ; j+=2){
     a += vec.at(j);
     if ((j+1) < N){
     b += vec.at(j+1);
     }
   }
  cout << a - b << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;

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

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

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

  ll ans = 1LL;

  for (int i = 0; i < N; ++i) {
    ll T;
    cin >> T;
    ans = lcm(ans, T);
  }

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

Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    MOD = 10 ** 9 + 7

    two_factor = 1
    res = 0
    for d in range(60):
        odd = 0
        even = 0
        for i in range(N):
            if A[i] & (1<<d) > 0:
                odd += 1
            else:
                even += 1
        res += odd * even % MOD * two_factor % MOD
        two_factor = two_factor * 2 % MOD
    
    print(res%MOD)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 122808
from collections import deque

H, W = map(int, input().split())
N = int(input())
A = []
B = list(map(int,input().split()))
for i in range(N):
    for j in range(B[i]):
      A.append(i)
flg = True
c = []
for k in range(1,H*W+1):
  c.append(A[k-1]+1)
  if k % W == 0:
    if flg:
      for s in c:
        print(s, end = ' ')
    else:
      for s in reversed(c):
        print(s, end = ' ')
    c = []
    print()
    flg = not flg


Measured memory_bytes: 9980
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#define ll long long
#define pii pair <int, int>
#define pll pair <long long, long long>
#define plxy pair <long long, pll>
#define INT_MAX 1e18
#define Keep_calm_You_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
ll n,k,arr[N];
ll dp[N];
ll solve(ll idx)
{
    if(idx==n-1)
        return 0;
    if(dp[idx]!=-1)
        return dp[idx];
    ll choice=INT_MAX;
    for(ll i=1;i<=k;i++)
    {
        if(idx+i<n)
            choice=min(choice,solve(idx+i)+abs(arr[idx+i]-arr[idx]));
    }
    dp[idx]=choice;
    return dp[idx];
}
int main()
{
     Keep_calm_You_are_still_learning
     cin>>n>>k;
     for(ll i=0;i<n;i++)
     {
         cin>>arr[i];
     }
     memset(dp,-1,sizeof(dp));
     cout<<solve(0);
    return 0;
}


Measured memory_bytes: 6528
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(map(int,list(input())))
    z=[None]*10
    for i in range(10):
        for j in range(N-2):
            if S[j]==i:
                 z[i]=j
                 break
    y=[[None]*10 for _ in range(10)]
    for x in range(10):
        if z[x] is not None:
            for i in range(10):
                for j in range(z[x]+1,N-1):
                    if S[j]==i:
                        y[x][i]=j
                        break
    ans=0
    for h in range(10):
        for x in range(10):
            if y[h][x] is not None:
                for i in range(10):
                    for j in range(y[h][x]+1,N):
                        if S[j]==i:
                            ans+=1
                            break
    print(ans)
                

if __name__ == '__main__':
    main()


Measured memory_bytes: 41456
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F(n) for(ll i=1;i<=n;i++)
#define Fab(a,b) for(ll i=a;i<b;i++)
//*max_element(a, a + n)
//cin.ignore(numeric_limits<streamsize>::max(), '\n');


ll t,n;


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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    int a,ans=0;
    cin>>a;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){
            for(int k=1;k<=a;k++){
                ans += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans;
    return 0;
}
  



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

int main(){
  int K,i1,j1,k1,g,g1,g2;
  long long ans=0;
  cin>>K;
  
  for(int i=1;i<K+1;i++){for(int j=1;j<K+1;j++){
    i1=i;j1=j;
    while(1){
      if(i1<j1){
        g1=i1;
        if(j1%i1==0){break;}
        i1=j1%i1;
        j1=g1;
      }else{
        g1=j1;
        if(i1%j1==0){break;}
        j1=i1%j1;
        i1=g1;
      }
    }
    for(int k=1;k<K+1;k++){
      k1=k;g=g1;
      while(1){
        if(k1<g){
        g2=k1;
        if(g%k1==0){ans+=g2;break;}
        k1=g%k1;
        g=g2;
        }else{
          g2=g;
        if(k1%g==0){ans+=g2;break;}
        g=k1%g;
        k1=g2;
        }
      }
    }}}
  cout<<ans;
}
      
    

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, k);
    Cout(n%k ? 1 : 0);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n;cin>>n;
  string s="aaaaaaaaaa";
  set<string> ans;
  rep(a1,0,2){
    
    rep(a2,0,a1+2){
      ll m1=max(a1,a2);
      
      rep(a3,0,m1+2){
        ll m2=max(m1,a3);
        
        rep(a4,0,m2+2){
          ll m3=max(m2,a4);
          
          rep(a5,0,m3+2){
            ll m4=max(m3,a5);
            
            rep(a6,0,m4+2){
              ll m5=max(m4,a6);
              
              rep(a7,0,m5+2){
                ll m6=max(m5,a7);
                
                rep(a8,0,m6+2){
                  ll m7=max(m6,a8);
                  
                  rep(a9,0,m7+2){
                    string tmp=s;
                    tmp[1]+=a1;tmp[2]+=a2;tmp[3]+=a3;
                    tmp[4]+=a4;tmp[5]+=a5;tmp[6]+=a6;
                    tmp[7]+=a7;tmp[8]+=a8;tmp[9]+=a9;
                    ans.insert(tmp.substr(0,n));
                  }
                }
              }
            }

          }
        }
      }
    }
  }
  for(auto u:ans){
    cout<<u<<endl;
  }

}




Measured memory_bytes: 12556
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
typedef vector<pii> vp;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int main() {
	string s, str = "CODEFESTIVAL2016";
	cin >> s;
	
	int ans = 0;
	REP(i, s.size()) if (s[i] != str[i]) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    forn (i, 0, n) 
        cin >> a[i];
    int ans = INT_MAX;
    forn (i, 0, n) {
        int s1 = 0;
        forn (j, 0, i) 
            s1 += a[j];
        int s2 = 0;
        forn (j, i, n) 
            s2 += a[j];
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define all(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  int arr[n];
  rep(i,n)cin>>arr[i];
  int dp[n];
  dp[n-1]=1;
  int ans=1;
  for(int i=n-2;i>=0;i--)
  {
    if(arr[i]>=arr[i+1])dp[i]=dp[i+1]+1;
    else dp[i]=1;
    ans=max(ans,dp[i]);
  }
  cout<<ans-1<<endl;
  return 0;
}


Measured memory_bytes: 1792
from collections import deque

''' Breadth First Search (BFS) '''
def bfs(x):
    q = deque([x])
    visited[x] = True
    while q:
        x = q.popleft()
        for y in adj[x]:
            if not visited[y]:
                q.append(y)
                visited[y] = True
                parent[y] = x

n, m = map(int, input().split())
adj = [[] for _ in range(n + 1)]
parent = [i for i in range(n + 1)]
visited = [False] * (n + 1)

for i in range(m):
  a, b = map(int, input().split())
  adj[a].append(b)
  adj[b].append(a)

bfs(1)
check = True
if i in range(2, n + 1):
  if parent[i] == i:
    check = False
if check:
  print("Yes")
  for i in range(2, n + 1):
    print(parent[i])
else:
  print("No")

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

using ll = long long;

int main() {
	ll A;
	string b;
	cin >> A >> b;
	ll B = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
	ll ans = A * B / 100ll;
	cout << ans << endl;
}

Measured memory_bytes: 3592
# 2019/06/05
# AtCoder Beginner Contest 086 - B

# Input
a, b = input().split()
val = int(a + b)
pval = pow(val, 0.5)

if pval % 1 == 0:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define npos std::string::npos
#define sortv(v) sort(v.begin(), v.end())
typedef long long ll;
using namespace std;
typedef tuple<string, int, int> triplet;
bool mycompare(const triplet &lhs, const triplet &rhs)
{
	if (std::get<0>(lhs) != std::get<0>(rhs)) return std::get<0>(lhs) < std::get<0>(rhs);
    if (std::get<1>(lhs) != std::get<1>(rhs)) return std::get<1>(lhs) > std::get<1>(rhs);
    return std::get<2>(lhs) < std::get<2>(rhs);
}
int main()
{
	int N;
  	cin >> N;
  	vector<triplet> SP(N);
  	for (int i = 0; i < N; i++){
    	string S;
      	int P;
      	cin >> S >> P;
      	SP[i] = make_tuple(S, P, i + 1);
    }
  	sort(SP.begin(), SP.end(), mycompare);
  	for (int i = 0; i < N; i++){
    	cout << get<2>(SP[i]) << endl;
    }
}

Measured memory_bytes: 256
let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =
  if r = 0 then acc
  else
    let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in
    ( if sq_acc_minus_z' <= 0 then
        floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'
      else
        floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)
let floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)

let () = Scanf.scanf "%d %d" @@ fun n m ->
  Printf.printf "%d\n" @@
  if n = 1 then m
  else Array.fold_left (List.fold_left max) 1 @@
    Array.init (floor_sqrt m) @@ fun i ->
      if 0 < m mod (i + 1)
      then []
      else (if m / (i + 1) < n then [] else [i + 1]) @ (if (i + 1) < n then [] else [m / (i + 1)])



Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a; string s;
   cin >> a >> s;
   cout << (a>=3200 ? s : "red") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<ll> > dp1 (n+1, vector<ll> (n+1)) , dp2(n+1, vector<ll> (n+1));
    dp1[1][1] = 1;
    for(int i =1; i<= n; i++)
        dp2[1][i] = (dp2[1][i-1] + dp1[1][i]);
    for(int i =2; i<=n; i++)
    {
        for(int j = 1; j<= i ; j++)
        {
            if(s[i-2] == '<')
                dp1[i][j] = dp2[i-1][j-1];
            else 
                dp1[i][j] = (dp2[i-1][i-1] + (MOD - dp2[i-1][j-1]))%MOD;
            dp2[i][j] = (dp2[i][j-1] + dp1[i][j])%MOD;
        }
    }
    ll ans = 0;
    for(int i = 1; i<= n;i++)
        ans = (ans + dp1[n][i])%MOD;
    cout<<ans<<"\n";
}

Measured memory_bytes: 141184
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var K = long.Parse(ReadLine());

        System.Numerics.BigInteger yen = 100L;

        var year = 0;

        while (yen < K)
        {
            yen = yen * 101L / 100L;

            year++;
        }

        WriteLine(year);
    }
}


Measured memory_bytes: 28016