akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    int v[n];
    int c[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d",&v[i]);
    }
    for(int i=0; i<n; i++)
    {
        scanf("%d",&c[i]);
        if(c[i]<v[i])
        {
            sum+=(v[i]-c[i]);
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val length = readLine()!!.toInt()
    val listB = readLine()!!.split(" ").map { it.toInt() }

    print(abc140c(length, listB))
}

fun abc140c(length: Int, listB: List<Int>): Int {

    //わざわざmutableListにしていたのを単純に足した場合をテスト
    var ans = listB[0]

    when {
        length >= 3 -> {
            for (i in 1 until length - 1) {
                ans += listB[i].coerceAtMost(listB[i - 1])
            }
            ans += listB[length - 2].coerceAtLeast(listB.last())
        }
        else -> ans += listB.last()
    }

    return ans
}

Measured memory_bytes: 37848
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int i,j,k,n,m;
void read(int &x){
	char c;x=0;do c=getchar();while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);
}
void read(ll &x){
	char c;x=0;do c=getchar();while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);
}
int main() {
    string s;
	cin>>n>>s;
	if(n>=3200)cout<<s;
	else cout<<"red";
    //cerr << 1.0*clock()/CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6,a7,b7,A,B,C,D,E,F,G;
  scanf("%d %d",&a1,&b1);
  scanf("%d %d\n",&a2,&b2);
  scanf("%d %d\n",&a3,&b3);
  scanf("%d %d\n",&a4,&b4);
  scanf("%d %d\n",&a5,&b5);
  scanf("%d %d\n",&a6,&b6);
  scanf("%d %d",&a7,&b7);

  A=a1-b1;
  B=a2-b2;
  C=a3-b3;
  D=a4-b4;
  E=a5-b5;
  F=a6-b6;
  G=a7-b7;

  printf("%d\n",A);
  printf("%d\n",B);
  printf("%d\n",C);
  printf("%d\n",D);
  printf("%d\n",E);
  printf("%d\n",F);
  printf("%d\n",G);
 return 0;
}

Measured memory_bytes: 600
import java.util.*;

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

	int n=s.nextInt();
	int a[]=new int[n+1];
	a[1]=1;
	int b[]= {6,9};
	for(int i=2;i<=n;i++) {
		a[i]=Integer.MAX_VALUE;
		a[i]=Math.min(a[i-1]+1,a[i]);
		for(int j=1;j<n&&Math.pow(6, j)<=i;j++) {
			a[i]=Math.min(a[i], a[i-(int)Math.pow(6,j)]+1);
		}
		for(int j=1;j<n&&Math.pow(9, j)<=i;j++) {
			a[i]=Math.min(a[i], a[i-(int)Math.pow(9,j)]+1);
		}
		
	}
	System.out.println(a[n]);
	
}




}


Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<cstring>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	int cnt = 0;
	reps(i,n){
		s = to_string(i);
		if(s.size() % 2 == 1) ++cnt;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#21:06
N,M=map(int,input().split())
l=[]
for i in range(M):
    l.append(list(map(int,input().split())))
first=[]
last=[]
H=[[] for i in range(N)]
for t in l:
    H[t[0]-1].append(t[1])
    H[t[1]-1].append(t[0])
#if H[0][0]==H[N-1][0]
#print(any(N in H[0]))
#for v in H[0]:
if any(N in H[v-1] for v in H[0]):
    #N is exist in first
    #1 to i to N
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

using namespace std;

//#define MD 100010

int main(){
    long int n;
    cin>>n;
    vector<long int> v(n),s(n);
    for(long int i=0;i<n;i++){
        cin>>v[i];
        s[i]=v[i];
    }
    
    sort(s.begin(),s.end());
    
    long int ml=s[n/2-1],mr=s[n/2];
    
    for(long int i=0;i<n;i++){
        if(v[i]>=mr){
            cout<<ml<<endl;
        }else if(v[i]<=ml){
            cout<<mr<<endl;
        }
    }
    
    return 0;
    
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string o, e;
    cin >> o >> e;
    int l = o.size();
    int ll = e.size();
    for(int i = 0; e[i]; i++)
    {
        printf("%c%c",o[i],e[i]);
    }
    ll = l + ll;
    if(ll&1) cout << o[l-1] << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int N;

int main()
{
    int l,m,n,a,b;
    string h,t;
    cin >> N;
    a = b = 0;
    REP(i,N) {
        cin >> h >> t;
        n = min(l = h.size(),m = t.size());
        REP(j,n){
            if (h[j]>t[j]) {
                a+=3;
                break;
            } else if (h[j]<t[j]) {
                b+=3;
                break;
            } else if (j==n-1) {
                if (l==m) {
                    ++a;
                    ++b;
                } else {
                    if (l>m) a+=3;
                    else b+=3;
                }
                break;
            }
        }
    }
    cout << a << " " << b << endl;
    return 0;
}



Measured memory_bytes: 3176
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long ans=0;
		for (long a=1;a<N;++a) {
			long b=N/a;
			if (a*b==N) --b;
			ans+=b;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 35692
#include <cstdio>
using namespace std;

int main() {
    int A, B, C, D, E, F;
    scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);

    int ans = 0, ans_suger = 0;
    for(int p=0; p<40; p++) {
        for(int q=0; q<40; q++) {
            int water = p*100*A + q*100*B;
            if(water == 0 || water > F) continue;
            for(int r=0; r*C*100 <= water*E; r++) {
                for(int s=0; (r*C+s*D)*100 <= water*E; s++) {
                    int suger = r*C + s*D;
                    if(water + suger > F) continue;

                    if(water * E < suger * 100) continue;
                    int tmp = water + suger;
                    if(tmp * ans_suger <= ans * suger) {
                        ans = tmp;
                        ans_suger = suger;
                    }
                }
            }
        }
    }
    printf("%d %d\n", ans, ans_suger);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    ll n; cin >> n;
    int s[4]; 
    rep(i,4) s[i] = 0;
    rep(i, n) {
        string t; cin >> t;
        if(t== "AC") {
            s[0]++;
        } else if (t=="WA") {
            s[1]++;
        } else if (t=="TLE") {
            s[2]++;
        } else if (t=="RE") {
            s[3]++;
        }
    }
    
    cout << "AC x " << s[0] << endl;
    cout << "WA x " << s[1] << endl;
    cout << "TLE x " << s[2] << endl;
    cout << "RE x " << s[3] << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair

 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  

void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 

int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 

int main(){
    IOS;
     generatePrimeFactors(); 
    int n;cin>>n;
    ll cnt=0;
    f(i,1,n){
        int num=n-i;
        cnt+=calculateNoOFactors(num);
    }
    cout<<cnt;
    return 0;  
} 



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


int a[10][10]={0};
int b[10]={0};
int c[10]={0}; 
set<int> number;
set<int> number_memo;
int main() {
  int n,m,light,ans,cnt;
  light=ans=cnt=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int k;
    cin >>k;
    c[i]=k;
    for(int j=0;j<k;j++){
      int tmp;
      cin>>tmp;
      a[i][j]=tmp-1;
    }
  }
  for(int i=0; i<m;i++){
    int tmp;
    cin>>tmp;
    b[i]=tmp;
  }
  for(int bit=0;bit<(1<<n);bit++){
    light=0;
    for(int i=0;i<m;i++){
      for(int j=0;j<c[i];j++){
        if(bit&(1<<a[i][j])) {cnt++;}
      }
      if(cnt%2==b[i]){
      //  cout<<bit<<" "<<i<<endl;
        light++;
      }
      cnt=0;      
    }
    if(light==m){ ans++;}
  }
  cout<<ans<<endl; 
}

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

long long L,R;

using namespace std;

int main(){
    cin >> L >> R;
    if(R - L >= 2018){
        cout << 0 << endl;
        return 0;
    }
    vector<long long> v;
    for(long long i=L;i<=R;i++){
        v.push_back(i%2019);
    }
    long long m = 2018;
    for(int i=1;i<v.size();i++){
        for(int j=0;j<i;j++){
            if(m > (v[i]*v[j])%2019){
                m = (v[i]*v[j])%2019;
            }
        }
    }
    cout << m << endl;
    return 0;
}

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

lis = []
for i in range(1,int((n**0.5) + 1)):
    if n % i == 0:
        lis.append(i)
        if i != n //i:
            lis.append(n//i)
            
lis.sort()
n2 = len(lis)
if n2 % 2 == 0:
    n2 = n2//2
    key = True
else:
    n2 = n2//2
    key = False

if key == True:
    a = lis[n2]
    b = lis[n2 -1]
else:
    a = lis[n2]
    b = lis[n2]
    
print(a-1+b-1)

Measured memory_bytes: 40556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    long long int a[x],b[y],c[z];
    for(int i=0;i<x;i++){cin>>a[i];}
    for(int i=0;i<y;i++){cin>>b[i];}
    for(int i=0;i<z;i++){cin>>c[i];}

    vector<long long int> ab;//先にAとBの食べ合わせを計算
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end());
    reverse(ab.begin(),ab.end());
    //ABについて3000個で枝刈りする。
    ab.resize(3000);
    reverse(ab.begin(),ab.end());

    //ABとCで再計算
    vector<long long int> ans;

    long long int l=0;
    for(int i=0;i<3000;i++){
        l=ab.back();
        ab.pop_back();
        for(int j=0;j<z;j++){
            ans.push_back(l+c[j]);
        }
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<k;i++){
        cout<<ans.back()<<endl;
        ans.pop_back();
    }
    return 0;
}

Measured memory_bytes: 42980
#include <stdio.h>          // printf(), scanf(), fgets()
#include <stdlib.h>         // strtol(), qsort()
#include <stdbool.h>

#define MAX_N 1000
#define MAX_L 80

const char NUL = '\0';

typedef struct trans_tbl
{
	int id;
	int this;
	int last;
} trans_t;

trans_t trans[MAX_N];
int n_trans;

int
cmp_func(const void *l_, const void *r_)
{
	const trans_t *l = (const trans_t*) l_;
	const trans_t *r = (const trans_t*) r_;

	if (l->id < r->id)
		return -1;

	if (l->id > r->id)
		return 1;

	return 0;
}

int
search(int id)
{
	int lb = 0, ub = n_trans;
	while (ub - lb >= 1)
	{
		int mid = (lb + ub) / 2;
		if (trans[mid].id < id)
			lb = mid + 1;

		else if (trans[mid].id > id)
			ub = mid;

		else
			return mid;
	}

	return -1;
}

int
main(int argc, char **argv)
{
	int id;
	int deal;
	char line[MAX_L + 1];
	const char *s;
	char *nextp = NULL;
	int i;

	n_trans = 0;
	while (true)
	{
		fgets(line, sizeof(line), stdin);
		if (line[0] == '\n' || line[0] == NUL)
			break;

		s = line;
		id = strtol(s, &nextp, 10);
		for (i = 0; i < n_trans; ++i)
		{
			if (trans[i].id == id)
				break;
		}

		if (i >= n_trans)
		{
			trans[n_trans].id = id;
			trans[n_trans].this = 1;
			trans[n_trans].last = 0;
			n_trans++;
		}
		else
			trans[i].this++;
	}

	qsort(trans, n_trans, sizeof(trans_t), cmp_func);

	while (scanf("%d,%d", &id, &deal) != EOF)
	{
		i = search(id);
		if (i == -1)
			continue;

		trans[i].last++;
	}

	for (i = 0; i < n_trans; ++i)
	{
		if (trans[i].last != 0)
			printf("%d %d\n", trans[i].id, trans[i].this + trans[i].last);
	}

	return 0;
}

Measured memory_bytes: 612
parseInt(x) = parse(Int, x)

function main()
	n,x = map(parseInt, split(readline()))
	m = n
	total = 0
	while x > 0
		k=0
		while 2^(k+2)-3+(m-k) <= x
			k += 1
		end
		k-=1
		total += 2^(k+1)-1
		x -= 2^(k+2)-3+(m-k)
		if x >= 1
			x -= 1
			total += 1
		end
		m = k
	end
	print(total)
end

main()

Measured memory_bytes: 167096
H,W = map(int,input().split())
A = [input() for _ in range(H)]

visited = [[False for j in range(W)] for i in range(H)]
visited[0][0] = True

x,y = 0,0

while not (x==H-1 and y==W-1):
    if x<H-1 and A[x+1][y]=='#':
        x += 1
        visited[x][y] = True
    elif y<W-1 and A[x][y+1]=='#':
        y += 1
        visited[x][y] = True
    else:
        break
ans = True
for i in range(H):
    for j in range(W):
        if A[i][j] == '#' and not visited[i][j]:
            ans = False

print('Possible' if ans else 'Impossible')

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

int main(){
    int n;
    cin >> n;
    
    int b, f, r, v;
    int m1[4][11], m2[4][11], m3[4][11], m4[4][11];
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 11; j++){
            m1[i][j] = 0;
            m2[i][j] = 0;
            m3[i][j] = 0;
            m4[i][j] = 0;
        }
    }
    
    for(int i = 0; i < n; i++){
        cin >> b >> f >> r  >> v;
        if(b == 1) m1[f][r] += v;
        else if(b == 2) m2[f][r] += v;
        else if(b == 3) m3[f][r] += v;
        else m4[f][r] += v;
    }
    
    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= 10; j++){
            cout << " " << m1[i][j];
        }
        cout << endl;
    }
    cout << "####################" << endl;
    
    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= 10; j++){
            cout << " " << m2[i][j];
        }
        cout << endl;
    }
    cout << "####################" << endl;
    
    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= 10; j++){
            cout << " " << m3[i][j];
        }
        cout << endl;
    }
    cout << "####################" << endl;
    
    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= 10; j++){
            cout << " " << m4[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


struct Event {
  string type;
  int time;
  int id;
  string to_string() {
    stringstream ss;
    ss << "{" << type << "," << time << "," << id << "}";
    return ss.str();
  }
};

int main2() {
  int N = nextInt();
  int Q = nextInt();
  vector<Event> es;
  REP(i, N) {
    int S = nextInt()*2;
    int T = nextInt()*2;
    int X = nextInt()*2;
    es.push_back((Event){"open", S-X-1, X/2});
    es.push_back((Event){"close", T-X-1, X/2});
  }
  REP(i, Q) {
    int D = nextInt()*2;
    es.push_back((Event){ "d", D, i });
  }
  sort(ALL(es), [](const Event&a, const Event& b){
    if (a.time != b.time) return a.time < b.time;
    return a.id < b.id;
  });

  vector<int> ans(Q, -1);

  priority_queue<int> currentX;
  map<int,int> counter;

  for (Event e: es) {
    // cout << e.to_string() << endl;
    if (e.type == "open") {
      const int X = e.id;
      counter[X]++;
      currentX.push(-X);
      // for (auto it = counter.begin(); it != counter.end(); ++it) cout << *it << ","; cout << endl;
    } else if (e.type == "close") {
      const int X = e.id;
      counter[X]--;
      // for (auto it = counter.begin(); it != counter.end(); ++it) cout << *it << ","; cout << endl;
      while (currentX.size() > 0 && counter[-currentX.top()] == 0) {
        currentX.pop();
      }
    } else {
      if (currentX.size() > 0) {
        // cout << "ans=" << -currentX.top() << endl;
        ans[e.id] = -currentX.top();
      }
    }
  }

  REP(i, ans.size()) printf("%d\n", ans[i]);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main()
{
    int a,b,c,d,su,sn;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        su=a*b;
        sn=c*d;
        if(su>=sn)
            printf("%d\n",su);
        else
            printf("%d\n",sn);
    }
    return 0;
}

Measured memory_bytes: 128
H, W, A, B = map(int, open(0).read().split())
MOD = 10**9+7

factorials = [1] * (H + W + 1)
inv_factorials = [1] * (H + W + 1)

for i in range(H + W):
    factorials[i+1] = factorials[i] * (i + 1) % MOD

inv_factorials = list(map(lambda n: pow(n, MOD - 2, MOD), factorials))

def modcomb(m, n, mod):
    return factorials[m] * inv_factorials[n] % MOD * inv_factorials[m - n] % MOD
 
total = modcomb(H + W - 2, W - 1, MOD)
 
for i in range(B):
    total -= modcomb(H - A - 1 + i, i, MOD) * modcomb(A - 1 + W - 1 - i, W - 1 - i, MOD)
    total %= MOD
 
print(total)

Measured memory_bytes: 88896
N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)

Measured memory_bytes: 9188
#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
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long int ull; 
  

vector<ull> allPrimes; 
  

void sieve(int n) 
{ 

    vector<bool> prime(n+1, true); 
  

    for (int p=2; p*p<=n; p++) 
    { 

        if (prime[p] == true) 
        { 

            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  

    for (int p=2; p<=n; p++) 
        if (prime[p]) 
            allPrimes.push_back(p); 
} 

ull factorialDivisors(ull n) 
{ 
    sieve(n);  

    ull result = 1; 

    for (int i=0; i < allPrimes.size(); i++) 
    { 

        ull p = allPrimes[i]; 
        ull exp = 0; 
        while (p <= n) 
        { 
            exp = exp + (n/p); 
            p = p*allPrimes[i]; 
        } 

        result = result*(exp+1)%1000000007; 
    } 

    return result; 
} 

int main() 
{ 
	int n;
	cin>>n;
    cout << factorialDivisors(n)<<endl; 
    return 0; 
} 

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

ll f(ll x){

    // n ^ (n+1) は 1 となるので
    // 1 の数が偶数なら0
    //　　　　 奇数ならcnt ^ x
    ll cnt = (x + 1) / 2;   // (x+1) は 0~x までだから
    ll res = cnt % 2;       // 1 の数からxorを求める
    if(x % 2 == 0){
        res ^= x;
    }
    return res;
}

int main() {

    ll a, b;
    cin >> a >> b;

    ll ans = f(a-1) ^ f(b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val N = io.StdIn.readLine.toInt

  def div(n: Int): Boolean = {
    if (n == 0) return true
    else if (n < 4 || n == 5 || n == 6) return false
    else {
      return div(n - 7) || div(n - 4)
    }
  }

  val out = if (div(N)) "Yes" else "No"

  println(out)
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  int ans = 0;
  for (int i = 0; i < 100; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (h[j] == 0)
        continue;
      h[j]--;
      if (j == n - 1 || h[j + 1] == 0)
      {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
vector<string> node(1010);
vector<vector<int>> G(1010);

ll dfs(int cv){
    vector<ll> children;
    for(auto nv : G[cv]){
        children.emplace_back(dfs(nv));
    }

    ll sum;
    if(node[cv][0] == 'E'){
        sum = 1;
        for(auto i : children){
            (sum *= i) %= MOD;
        }
    }
    else if(node[cv][0] == 'A'){
        sum = 0;
        for(auto i : children){
            (sum += i) %= MOD;
        }
    }
    else{
        sum = 1;
        for(auto i : children){
            (sum *= (i + 1)) %= MOD;
        }
        sum--;
    }

    if(node[cv].size() == 2){
        sum++;
    }

    return sum;
}

int main(){
    int n; cin>>n;
    for(int i=0; i<n; i++){
        cin>>node[i];
    }

    for(int i=0; i<n-1; i++){
        int s, t; cin>>s>>t;
        s--, t--;
        G[s].emplace_back(t);
    }

    cout << dfs(0) << endl;
}


Measured memory_bytes: 3284
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto n = readln.chomp.to!int;
    auto ps = readln.split.to!(int[]);
    
    int cnt;

    if (ps[0] == 1) {
        swap(ps[0], ps[1]);
        cnt++;
    }
    foreach (i; 1..n) if (ps[i] == i+1) {
        swap(ps[i], ps[i+1]);
        cnt++;
    }
    if (ps[$-1] == n) {
        swap(ps[$-1], ps[$-2]);
        cnt++;
    }
    writeln(cnt);
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define gr vector<vector<pii>>
#define fi first
#define se second
#define MOD 998244353
#define MAXN (int)(1E6 + 111)
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    vvi a(3, vi(3));
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    vector<vector<bool>> res(3, vector<bool>(3, false));
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (a[i][j] == x)
                    res[i][j] = true;
    }
    bool ok = false;
    for (int i = 0; i < 3; i++)
        ok |= (res[i][0] && res[i][1] && res[i][2]);
    for (int j = 0; j < 3; j++)
        ok |= (res[0][j] && res[1][j] && res[2][j]);
    ok |= (res[0][0] && res[1][1] && res[2][2]);
    ok |= (res[0][2] && res[1][1] && res[2][0]);
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N;
    cin >>N;
    char s[N+1];
    for(int i=1;i<=N;i++){
        cin >>s[i];
    }
    int ans[N+2];
    ans[0]=0;
    for(int i=1;i<=N;i++){
        if(s[i]=='I'){
            ans[i]=ans[i-1]+1;
        }
        else{
            ans[i]=ans[i-1]-1;
        }
    }
    int Ans=0;
    for(int i=1;i<=N;i++){
        Ans=max(Ans,ans[i]);
    }
    cout <<Ans<<endl;
 return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#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 fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int n, m;
int a[N];
ll dp[110][N];

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int l = max(0, j - a[i]);
			if (!l) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = (inf + dp[i - 1][j] - dp[i - 1][l - 1]) % inf;
		}
		for (int j = 1; j <= m; j++)
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % inf;
	}
	cout << dp[n][m];
}

Measured memory_bytes: 158464
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}



Measured memory_bytes: 3608
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)

S = input()
if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5708
import sys
input = sys.stdin.readline

def dp_fn():
  N, W = map(int, input().split())
  WV = (map(int, input().split()) for _ in range(N))
  
  DP = {0:0}
  
  for w, v in WV:
    keys = sorted(DP.keys(), reverse=True)
    for i in keys:
      j = DP[i]
      if j+w <= W:
        if i+v in DP:
          DP[i+v] = min(DP[i+v], j+w)
        else:
          DP[i+v] = j+w
  return max(DP.keys())
  
print(dp_fn())


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



using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



VI g[100005];
int c[100005];
int d[100005];

void dfs(int p,int i) {
	c[p] = i;
	for (int j : g[p]) {
		if (c[j] == 0) {
			dfs(j, i + 1);
		}
	}
}

void dfs1(int p, int i) {
	d[p] = i;
	for (int j : g[p]) {
		if (d[j] == 0) {
			dfs1(j, i + 1);
		}
	}
}

int ans = 0;

void dfs2(int p,int aa, int i) {
	if (c[p] == d[p])ans = max(ans, i - 1);
	//cout << p << ' ' << i << endl;
	if (c[p] >= d[p])return;
	if (c[p] % 2 == d[p] % 2)ans = max(ans, d[p] - 2);
	else ans = max(ans, d[p] - 2);
	//ans = max(ans, i);
	for (int j : g[p]) {
		if (aa == j)continue;
		dfs2(j,p, i + 1);
	}
}


int main() {

	int n;
	cin >> n;
	int u, v;
	cin >> u >> v;
	u--; v--;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(u, 1);
	dfs1(v, 1);
	dfs2(u,-1, 1);

	/*REP(i, n)cout << c[i] << ' ';
	cout << endl;
	REP(i, n)cout << d[i] << ' ';
	cout << endl;*/

	cout << ans << endl;

	
}

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

    int main()
    {
        ll t,i,n,k,a,b;

            cin>>k>>a>>b;
           ll f=0;
            for(i=a;i<=b;i++)
            {
               if(i%k==0){f=1;break;}
            }
            if(f==0)
            {
                cout<<"NG"<<endl;
            }  else
            {
                cout<<"OK"<<endl;
            }
            //cout<<s<<endl;


        return 0;
    }


Measured memory_bytes: 3596
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int mojiCount = n.length()-2;
		int[] arrays = new int[mojiCount];
		for (int i = 0; i < mojiCount ;i ++) {
			arrays[i] = Integer.parseInt(n.substring(i,i+3));
		}
		int min = 753;
		for (int i = 0; i < mojiCount ;i ++) {
			arrays[i] = Integer.parseInt(n.substring(i,i+3));
			min = Math.min(min,Math.abs(753-arrays[i]));
		}
		System.out.println(min);
		
		

    }
}

Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  cout << fixed;
  cout << setprecision(10);
  double a;
  while(cin >> a){
	  double sum = a;
	  for(int i = 2; i <= 10; i++){
		    if (i & 1) {a = a / 3.0, sum += a;}
		    else {a = a * 2.0, sum += a;}
		}
	 cout << sum << endl;  
	}	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<string>
#include<cassert>

using namespace std;

#define LMAX 10
#define HMAX 128

int now[LMAX],now_hits[HMAX],now_blows[HMAX];
bool used[10];
int L,H,hits[HMAX],blows[HMAX],T[HMAX][LMAX];
bool digs[HMAX][10];
string res;
bool cancel=false;

void dfs(int depth){
  if(cancel)return ;
  if( depth == L ){
    bool ng = false;
    for(int i = 0; i < H; ++i){
      if( now_hits[i] != hits[i] ) ng = true;
      if( now_blows[i] - now_hits[i] != blows[i] ) ng = true;
    }
    if( ng ) return ;
    string s;
    for(int i = 0; i < L; ++i){
      s += '0' + now[i];
    }
    if(res.length()>0)cancel=true;
    res = s;
    return ;
  }
  for(int i = 0; i < 10; ++i){
    int thit[HMAX] = {0,};
    int tblows[HMAX] = {0,};
    bool skip=false;

    if( !used[i] ){
      used[i]=true;
      now[depth]=i;
      for(int j = 0; j < H; ++j){
	if( T[j][depth] == i ){
	  ++now_hits[j];
	  ++thit[j];
	}
	if(now_hits[j] > hits[j]){
	  skip=true;
	  break;
	}
      }
      for(int j = 0; j < H; ++j){
	if( digs[j][i] ){
	  ++now_blows[j];
	  ++tblows[j];
	}
	if(now_blows[j] - now_hits[j] > blows[j]){
	  skip=true;
	  break;
	}
      }
      if(!skip)
	dfs(depth+1);
      for(int j = 0; j < H; ++j){
	now_hits[j] -= thit[j];
	now_blows[j] -= tblows[j];
      }
      used[i]=false;
    }
  }
}

int main()
{
  while(true){
    cin >> L >> H;
    if(cin.eof())break;
    if( L == 0 && H == 0 ) break;
    for(int i = 0; i < HMAX; ++i){
      for(int j = 0; j < 10; ++j){
	digs[i][j] = false;
      }
    }
    for(int i = 0; i < H; ++i){
      string s;
      cin >> s >> hits[i] >> blows[i];
      for(int j = 0; j < (int)s.length(); ++j){
	T[i][j] = s[j]-'0';
	digs[i][ s[j]-'0' ] = true;
      }
    }
    for(int i = 0; i < HMAX; ++i){
      now_hits[i]=0;now_blows[i]=0;
    }
    cancel=false;
    res = "";
    dfs(0);
    if(cancel||res.length()==0){
      cout <<"NO"<<endl;
    }else{
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
  int N, M;
  cin >> N >> M;

  UnionFind uf(N);

  vector<vector<int>> graph(N);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    uf.unite(u, v);
  }

  
  int ans = 0;
  REP(i, N){
    chmax(ans, uf.size(i));
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 11116
from sys import stdin


def get_result(data):
    N, M = data[0]
    A = data[1]
    ans = N - sum(A)
    return ans if ans >= 0 else -1


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int d, n;
    cin >> d >> n;
    if (d == 0)
        d = 1;
    else if (d == 1)
        d = 100;
    else if (d == 2)
        d = 10000;

    ll ans = 0;
    if (n < 100)
    {
        ans = n * d;
    }
    if (n == 100)
    {
        ans = 101 * d;
    }
    c(ans);

    return 0;
}

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

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

  int sum = 1;

  for(int i = 0; i < n; i++){
    if(sum*2 < sum+k){
      sum = sum * 2;
    }else{
      sum = sum + k;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
s = gets.chomp.to_s

if s == "SUN"
  puts 7
elsif s == "MON"
  puts 6
elsif s == "TUE"
  puts 5
elsif s == "WED"
  puts 4
elsif s == "THU"
  puts 3
elsif s == "FRI"
  puts 2
elsif s == "SAT"
  puts 1
end

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

int main(){
    int n, r;
    while(cin >> n >> r){
        vector<int> v(n);
        for(int i = 0; i < n; i++)  v[i] = i;
        while(r-- > 0){
            int c;  cin >> c;
            vector<int> next(n);
            int apos = n/2, bpos = 0, cur = 0;
            while(apos < n || bpos < n/2){
                for(int i = 0; i < c && apos < n; i++){
                    next[cur++] = v[apos++];
                }
                for(int i = 0; i < c && bpos < n/2; i++){
                    next[cur++] = v[bpos++];
                }
            }
            v = next;
        }
        cout << v[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
from math import gcd
k = int(input())
result = 0

# 3つとも等しい数字
for i in range(1, k+1):
    for j in range(i, k+1):
        for m in range(j, k+1):
            if i==j==m:
                result += i
            elif i==j or j==m:
                result += gcd(i, m)*3
            else:
                result += gcd(i, gcd(j,m))*6
print(result)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin.tie(0);
#define F first
#define S second
using namespace std;
typedef long long ll;
ll a,b,c,sum,t;
const ll maxn=200005;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;
ll num;
ll n,k;

int main()
{
    //IOS
    while(cin>>a>>b)
    {
        if(a<b) cout<<"0\n";
        else cout<<"10\n";
    }


}


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

#define BUFSIZE 1024

int main(void)
{
    int N;
    char buf[BUFSIZE];
    char S[BUFSIZE];
    char T[BUFSIZE];

    fgets(buf, BUFSIZE, stdin);
    N = atoi(buf);
    fgets(buf, BUFSIZE, stdin);
    sscanf(buf, "%s %s", S, T);

    int countor = 0;
    for (int i = 0; i < N; i++)
    {
        buf[countor++] = S[i];
        buf[countor++] = T[i];
    }
    buf[countor] = '\0';
    printf("%s\n", buf);
}

Measured memory_bytes: 128
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    const int M = 1e5 + 123;
    vector<int> cnts(M + 1, 0);

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++cnts[x];
    }
    for (int i = 1; i <= M; ++i) {
        cnts[i] += cnts[i - 1];
    }

    int res = 0;
    for (int i = 0; i <= M; ++i) {
        if (cnts[i] * 2 == n) {
            ++res;
        }
    }

    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        for(int i=1;i<=N;i++){
            ans += sc.nextInt()-1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        for(int i = A; i <= B; i++) {
            if(i % K == 0) {
                System.out.println("OK");
                return;
            }
        }


        System.out.println("NG");
    }
}

Measured memory_bytes: 35852
n = int(input())
a = list(map(int, input().split()))


def ok(l, r, on, a):
    n2 = format(a[r], '20b')
    out = -1
    for i in range(20):
        if n2[i]=='1':
            if on[i]<l:
                on[i]=r
            else:
                if out<on[i]:
                    out = on[i]
                on[i]=r
    return out

s = 0
l = 0
r = 0
on = [-1 for i in range(20)]
while True:
    if r==n:
        s += (r-l)*(r-l-1)/2 + r-l
        break
    o = ok(l, r, on, a)
    if o == -1:
        r += 1
    else:
        s += (o-l+1)*(o-l)/2 + o-l+1
        s +=(o-l+1)*(r-o-1)
        l = o+1
        r += 1
        
        
print(int(s))

Measured memory_bytes: 23560
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    A = list(map(lambda x: int(x) - 1, input().split()))

    route = [0]
    visited = set([0])
    now_town = 0
    while True:
        next_town = A[now_town]
        if next_town in visited:
            break
        else:
            visited.add(next_town)
            route.append(next_town)
            now_town = next_town

    loop_start = route.index(next_town)
    loop_len = len(route[loop_start:])
    count_before_loop = len(route) - loop_len
    if K <= count_before_loop:
        ans = route[K] + 1
    else:
        K -= count_before_loop
        r = K % loop_len
        ans = route[loop_start + r] + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32612
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == (h - 1):
            print("#"*w)
        else:
            print("#" + ("."*(w-2)) + "#")
    print()



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int change(int t){
	return t/100*60+t%100;
}

signed main(){
	int n,p,q;
	while(1){
		cin>>n>>p>>q;
		if(!(n|p|q)) break;
		int k,s,e;
		int d[24*60+1]={};
		rep(i,0,n){
			cin>>k;
			rep(j,0,k){
				cin>>s>>e;
				int ts=change(s);
				int te=change(e);
				d[ts]++;
				d[te]--;
			}
		}
		rep(i,1,24*60+1){
			d[i]+=d[i-1];
		}
		int tp=change(p);
		int tq=change(q);
		int now=0,ans=0;
		rep(i,tp,tq){
			if(d[i]!=n){
				now++; ans=max(ans,now);
			}else now=0;
		}
		o(ans);
	}
}

Measured memory_bytes: 1176