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

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

  deque<int> b;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0)b.push_back(a[i]);
    else b.push_front(a[i]);
  }

  for(int i = 0; i < n; i++){
    if(n % 2 == 0){
      cout << b.front();
      b.pop_front();
     }else{
      cout << b.back();
      b.pop_back();
    } 
    if(i < n - 1)cout << " ";
    else cout << endl;
  }
}

Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
vector<int>S;
main()
{
	cin>>N;
	for(int i=0;i<1<<N;i++)
	{
		int s;cin>>s;S.push_back(s);
	}
	sort(S.rbegin(),S.rend());
	vector<int>A;
	A.push_back(S[0]);
	S.erase(S.begin());
	for(int i=0;i<N;i++)
	{
		sort(A.rbegin(),A.rend());
		vector<int>T;
		int id=0;
		for(int j=0;j<1<<i;j++)
		{
			while(id<S.size()&&A[j]<=S[id])
			{
				T.push_back(S[id++]);
			}
			if(id==S.size())
			{
				cout<<"No"<<endl;
				return 0;
			}
			A.push_back(S[id++]);
		}
		while(id<S.size())T.push_back(S[id++]);
		S=T;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3360
N = int(input())
A = [int(x) for x in input().split()]

def col(x):
  if x < 400:
    return 0
  if x < 800:
    return 1
  if x < 1200:
    return 2
  if x < 1600:
    return 3
  if x < 2000:
    return 4
  # 等差かよ
  if x < 2400:
    return 5
  if x < 2800:
    return 6
  if x < 3200:
    return 7
  return 8

cnt = [0] * 9
for a in A:
  cnt[col(a)] += 1

basic = sum([min(x,1) for x in cnt[:8]])
rainbow = cnt[8]

MIN = max(1,basic)
#MAX = min(basic+rainbow,8)
MAX = basic+rainbow
print(MIN,MAX)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<ll,ll>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  string a;
  cin>>a;
  cout<<a[0]<<a[1]<<a[2]<<endl;
}


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

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


Measured memory_bytes: 3616
from itertools import combinations
n = int(input())
arr = list(map(int, input().split()))
count = 0
for i, j, k in combinations(arr, 3):
    if i == j or j == k or k == i:
        continue
    elif (i + j) > k and (j + k) > i and (k + i) > j:
        count += 1
print(count)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes\n";
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No\n";
      return 0;
    }
  }
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main()
{
	int n;
	int i;
	char rank[10000];
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		int ans1,ans2=0;
		for(i=0;i<n;i++)
		{
			int pm,pe,pj;
			int hei;
			cin >> pm >> pe >> pj ;
			hei = (pe+pj+pm)/3;
			if(pm==100||pe==100||pj==100){
				rank[i] ='A';
			}
			else
			if((pe+pm)/2>=90){
				rank[i] ='A';
			}else
			if(hei>=80){
				rank[i] = 'A';
			}else
			if(hei>=70){
				rank[i] = 'B';
			}else
			if(hei>=50&&(pe>=80||pm>=80)){
				rank[i] = 'B';
			}else rank[i] = 'C';
		}
		for(i=0;i<n;i++){
			cout << rank[i] << endl;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=400+5,mod=1e9+7;
typedef long long ll;
int n,arr[N];
ll dp[N][N];
ll solve(int i=1,int j=n){
    if(i==j)return 0;
    ll &ret=dp[i][j];
    if(~ret)return ret;
    ret=1e18;
    ll sum=0;
    for(int a=i;a<=j;a++)sum+=arr[a];

    for(int x=i;x<j;x++)
        ret=min(ret,solve(i,x) + solve(x+1,j) + sum);


    return ret;

}
int main()
{
    Elhabashy
    input();
    cin>>n;
    for(int i=1;i<=n;i++)cin>>arr[i];
    memset(dp,-1,sizeof dp);
    cout<<solve()<<endl;
}


Measured memory_bytes: 4948
H,M=map(int,input().split())
c=0
for i in range(1,H+1):
    S=input().split()
    for j in range(0,M):
        if S[j]=="snuke":
            a=i
            b=j
        else:
            c+=1

print(chr(ord('A')+b) + str(a))

Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input_string = '';

process.stdin.on('data', function(chunk) {
    input_string += chunk;
});

process.stdin.on('end', function() {
    var lines = input_string.split('\n');
    main(lines.slice(0, lines.length-1));
});

//function main(lines) {
//    lines.forEach(function(x) {
//        console.log(Math.pow(parseInt(x), 3));
//    });
//}

var main = function(lines) {
    lines.forEach(function(x) {
        console.log(Math.pow(parseInt(x), 3));
    });
};

Measured memory_bytes: 15796
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

class LIST
{
public:
	LIST(){};
	~LIST() {};
	void Insert(int val);
	LIST* Search(int val);
	void Delete(LIST* l);
	void DeleteFirst();
	void DeleteLast();
	void DeleteValue(int val);
	void Show()const;

	long int value;
	LIST* next = NULL;
	LIST* previous = NULL;

};


int main()
{
	LIST *L=new LIST();
	L->next = L;
	L->previous = L;

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		char str[15];
		int N;
		scanf("%s", str);
		if (str[6] != 'F'&&str[6] != 'L')scanf("%d",&N);
		if (str[0] == 'i')
		{
			L->Insert(N);
		}

		else if (str[6] == 'F')
		{
			L->DeleteFirst();
		}
		else if (str[6] == 'L')
		{
			L->DeleteLast();
		}
		else if (str[0] == 'd')
		{
			L->DeleteValue(N);
		}
	}

	L->Show();
	

	return 0;
}

void LIST::Insert(int val)
{
	LIST *l = new LIST();
	l->value = val;
	l->next = next;
	next->previous = l;
	next = l;
	l->previous = this;
}

LIST* LIST::Search(int val)
{
	LIST *l = next;
	while (l != this&&l->value != val)
	{
		l = l->next;
	}
	return l;
}

void LIST::Delete(LIST* l)
{
	if (l != this)
	{
		l->previous->next = l->next;
		l->next->previous = l->previous;
		delete l;
	}
}

void  LIST::DeleteFirst()
{
	Delete(next);
}
void LIST::DeleteLast()
{
	Delete(previous);
}

void LIST::DeleteValue(int val)
{
	Delete(Search(val));
}

void LIST::Show()const
{
	LIST* l = next;
	while (l->next!=next)
	{
		cout << l->value;
		l = l->next;
		if (l->next != next)
		{
			cout << " ";
		}
	}
	cout << endl;
}

Measured memory_bytes: 34464
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let d: i64 = s.next().unwrap().parse().unwrap();
	let t: i64 = s.next().unwrap().parse().unwrap();
	let s: i64 = s.next().unwrap().parse().unwrap();
	if t * s >= d {
		println!("Yes");
	} else {
		println!("No");
	}
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(r) do{cout<<#r": ";for(const auto &i:r){cout<<i<<" ";}cout<<endl;}while(0)
int main()
{
    int N; cin >> N;
    vector<int> T(N+1), V(N+1);
    REP(i, N) { cin >> T[i+1]; T[i+1] += T[i]; }
    REP(i, N) cin >> V[i];
    V[N] = 0;
    double ans = 0.0;
    int i = 0, v1 = 0, v2 = 0;
    for (int t = 0; t < 2*T[N]; t++, v1 = v2) {
        if (t == 2*T[i+1]) i++;
        bool slowdown = false;
        for (int k = i+1; k < N+1; k++) {
            if (v1 + (2*T[k] - t) * (-1) == 2*V[k]) {
                slowdown = true;
                break;
            }
        }
        v2 = slowdown ? v1 - 1 : v1 == 2*V[i] ? v1 : v1 + 1;
        ans += (v1 + v2) / 8.0;
    }
    cout << setprecision(20) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int a = o[1];
            int b = o[2];

            Console.WriteLine(Calc(n, a, b));
        }
        private static long Calc(int n, int a, int b)
        {
            long total = 0;
            for (int x = 0; x <= 9; ++x)
            {
                for (int y = 0; y <= 9; ++y)
                {
                    for (int z = 0; z <= 9; ++z)
                    {
                        for (int w = 0; w <= 9; ++w)
                        {
                            int num = 1000 * x + 100 * y + 10 * z + w;
                            if (num <= 0 || n < num) { continue; }

                            int sum = x + y + z + w;
                            if( a <= sum && sum <= b)
                            {
                                total += num;
                            }
                        }
                    }
                }
            }
            if( a <= 1 && 1 <= b && 10000 <= n)
            {
                total += 10000;
            }
            return total;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string a = "CODEFESTIVAL2016";
	string b;
	cin >> b;
	int ans = 0;
	rep(i, a.size()) {
		if (a[i] != b[i]) {
			ans ++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
from operator import itemgetter
n,m=map(int,input().split())
h=list(map(int,input().split()))
t=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  if h[a]<=h[b]:
    t[a]=1
  if h[b]<=h[a]:
    t[b]=1
print(n-sum(t))

Measured memory_bytes: 20252
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

const int SIZE = 50;

int main(){
	char c;
	string s;
	int n, max = 0;
	int* table = new int[ SIZE + 1 ]();

	while ( cin >> s ){
		int* input = new int[ SIZE + 1 ]();
		bool isInt = true;
		int cnt = 0;
		istringstream is( s );

		while ( !is.eof() ){
			if ( isInt ){
				is >> n;
				input[ ++cnt ] = n;
			}else{
				is >> c;
			}
			isInt = !isInt;
		}
		if ( cnt > max ){
			max = cnt;
		}

		for ( int i = 0, p = max; i < cnt; ++i, --p ){
			table [ p ] = input[ cnt - i ] + ( table[ p - 1 ] > table[ p ] ? table[ p - 1 ] : table[ p ] );
			
		}

		delete[] input;
	}

	cout << table[ max ] << endl;

	delete[] table;
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
long long H,W,A[10],q;
int p[65536];
struct{int a,b,n,q;}d[900001];

void f(int a,int b){
	int h,t,i;
	if(1<a&&a<H&&1<b&&b<W){
		if(i=p[h=(a+b)&65535]){
			for(;;){
				if(d[i].a==a&&d[i].b==b){
					break;
				}else if(d[i].q){
					i=d[i].q;
				}else{
					d[i=d[i].q=++q].a=a;
					d[i].b=b;
					break;
				}
			}
		}else{
			d[i=p[h]=++q].a=a;
			d[i].b=b;
		}
		--A[t=d[i].n++];
		++A[t+1];
	}
}
int main(){
	int a,b,i,j;
	scanf("%lld%lld%d",&H,&W,&i);
	A[0]=(H-2)*(W-2);
	for(;~scanf("%d%d",&a,&b);)
		for(i=-1;i<=1;++i)
			for(j=-1;j<=1;++j)
				f(a+i,b+j);
	for(i=0;i<=9;++i)printf("%lld\n",A[i]);
	return 0;
}


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

using namespace std;
using ll = long long;

const int N = 3e5 + 5;

mt19937 rnd(51515);

main() {
#ifdef ONPC
  freopen("a.in", "r", stdin);
#endif
  ios :: sync_with_stdio(0);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  cout << (n + k - 1) / k;
  return 0;
}

Measured memory_bytes: 256
s = input()

if s == 'SUN':
  print("7")
  exit()
if s == 'MON':
  print("6")
  exit()
if s == 'TUE':
  print("5")
  exit()
if s == 'WED':
  print("4")
  exit()
if s == 'THU':
  print("3")
  exit()
if s == 'FRI':
  print("2")
if s == 'SAT':
  print("1")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int count = 0;
        
        for(int i=0; i<3; i++){
            if(S.charAt(i) == 'o'){
                count++;
            }
        }
        
        System.out.println(700+count*100);
    }
}


Measured memory_bytes: 35716
#include <iostream>

using namespace std;

int main()
{
    int N,M,C;
    int B[21]={0};
    
    
    cin >> N >> M >>C;
    
    for(int i=0;i<M;i++)
    {
        cin >> B[i];
        
    }
    
    int atemp=0;
    int anstemp=0;
    int ans=0;
    
    for(int j=0;j<N;j++)
    {
        for(int i=0;i<M;i++)
        {
            cin >> atemp;
            anstemp+=atemp*B[i];
        
        }
        anstemp+=C;
        if(anstemp>0)ans+=1;
    anstemp=0;
    
    }
    
    
    
   cout << ans << endl; 
   
   return 0;
}

Measured memory_bytes: 256
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){var e=r.split("\n"),n=t(e[0].split(" ").map(function(r){return Number(r)}),2),o=n[0],u=n[1],i=e[1].split(" ").map(function(r){return Number(r)}),f=new Array(o).fill(2e10);f[0]=0;for(var l=0;l<o;l++)for(var a=1;a<=u&&!(l+a>=o);a++){var c=f[l]+Math.abs(i[l+a]-i[l]);c<f[l+a]&&(f[l+a]=c)}var p=f[o-1];console.log(p)}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 27744
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X[3],Y[3];
double L[4];
double A,R;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,3) cin>>X[i]>>Y[i];
	L[0]=hypot(X[0]-X[1],Y[0]-Y[1]);
	L[1]=hypot(X[1]-X[2],Y[1]-Y[2]);
	L[2]=hypot(X[2]-X[0],Y[2]-Y[0]);
	L[3]=max({L[0],L[1],L[2]});
	A = abs((X[1]-X[0])*(Y[2]-Y[0])-(X[2]-X[0])*(Y[1]-Y[0]))/2.0;
	R=2*A/(L[0]+L[1]+L[2]);
	double X = L[3]/(2+(L[3])/R);
	_P("%.12lf\n",X);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#define INF 1000000007

using namespace std;

int main(void) {
	int N;
	cin >> N;
	map<char,int> memo;
	for (int i = 0; i < N; ++i) {
		char c;
		cin >> c;
		++memo[c];
	}
	long long res = 1;
	for (auto itr = memo.begin(); itr != memo.end(); ++itr) {
		if (itr->second == 1) {
			res *= 2;
		}
		else {
			res *= (itr->second+1);
		}
		res %= INF;
	}
	--res;
	cout << res%INF << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

// int visited[100001];
ll dis[100001];
// int ans;

ll dfs(int i,vector <int> vi[]){

    if(dis[i]!=-1) return dis[i];

    ll temp=0;
    for(auto it:vi[i]){
            temp=max(temp,1+dfs(it,vi));
    }

    return dis[i]=temp;
}

int main(){
    fast;
    int m=1;
    // cin>>m;

    while(m--)
    {
        memset(dis,-1,sizeof(dis));
        int n,m;
        cin>>n>>m;

        int a,b;
        vector <int> vi[n+1];

        for(int i=0;i<m;i++){
            cin>>a>>b;
            vi[a].push_back(b);
        }
        ll maxAns=0;
        // cerr<<"working";
        for(int i=1;i<=n;i++){
            maxAns=max(maxAns,dfs(i,vi));
        }
        cout<<maxAns<<'\n';
    }
}

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

int main() {
	int N,M;
  	cin >> N >> M;
  
  	vector<int> a(N),b(N),c(M),d(M);
  
  	for(int i = 0; i < N; i++) {
    	cin >> a.at(i) >> b.at(i); 
    }
  
  	for(int i = 0; i < M; i++) {
    	cin >> c.at(i) >> d.at(i); 
    }
  
  	for(int i = 0; i < N; i++) {
    	int minimum = abs(a.at(i) - c.at(0)) + abs(b.at(i) - d.at(0));
      	int ans = 1;
      	for(int j = 1; j < M; j++) {
          int minimum2 = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
          if(minimum2 < minimum) {
          	minimum = minimum2;
            ans = j + 1;
          }
        }
      cout << ans << endl;
    }
  	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll solve(string &sr,string &sl,int k = 0,bool statusr = 1,bool statusl = 1,int statusM = 0){
    static ll dp[100][2][2][3];
    static int max_num = 1;
    static int min_num = 0;
    if(!k) memset(dp,-1,sizeof(dp));

    if(k==sr.size()){
        return (statusM==1?1:0);
    }

    ll &res = dp[k][statusr][statusl][statusM];
    if(res!=-1) return res;
    else res = 0;

    int r = (statusr?sr[k]-'0':max_num);
    int l = (statusl?sl[k]-'0':min_num);

    int tmpM = statusM;
    for(int y = 0;y <= r;y ++){
        for(int x = l;x <= y;x ++){
            if(statusM==0 && (x&y)) tmpM = 1;
            if(statusM==0 && (x^y)) tmpM = 2;
            ll cnt = solve(sr,sl,k+1,statusr && y==r,statusl && x==l,tmpM);
            res = (res+cnt)%mod;
        }
    }
    return res;
}
string to_binString(ll num){
    if(!num) return string("0");
    string res;
    while(num){
        if((num & 1)==0)    res = "0"+res;
        else                res = "1"+res;
        num >>= 1;
    }
    return res;
}
int main(){
    ll L,R;
    string sl,sr,s0r,s0l;
    cin >> L >> R;
    sl = to_binString(L);
    sr = to_binString(R);
    while(sr.size()>sl.size()) sl = "0"+sl;
    cout << solve(sr,sl) << 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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,k=1,s=0,n,w,m,min=100000000000,ans=1,max=0;
    string s1,s2;
    cin >> s1 >> s2;
    if (s1.size() > s2.size()){
        m = 2*s1.size();
    }
    else {
        m = 2*s1.size()+1;
    }
    for(int i=1;i<m;i++){
        if(i%2==0){
            cout << s2[a];
            a++;
        }
        else{
            cout << s1[b];
            b++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

struct Node{
	int l, r;
	int num;
	Node(){
		l = r = -1;
	}
};

int number(string& s, int& i){
	int res = 0;
	while(isdigit(s[i])){
		res *= 10;
		res += s[i] - '0';
		i++;
	}
	return res;
}

int dfs(vector<Node>& node, string& s, int l, int r, int& idx){
	if(r - l == 0) return -1;

	int cur = idx;

	int cnt = 0, i = l;
	while(true){
		if(s[i] == '(') cnt++;
		else if(s[i] == ')') cnt--;
		else if(cnt == 0){
			idx++;
			node[cur].l = dfs(node, s, l + 1, i - 1, idx);
			i++;
			node[cur].num = number(s, i);
			i++;
			idx++;
			node[cur].r = dfs(node, s, i + 1, r - 1, idx);
			break;
		}
		i++;
	}
	return cur;
}

string merge(vector<Node>& x, int xi, vector<Node>& y, int yi){
	if(xi == -1 or yi == -1) return "";

	string left = merge(x, x[xi].l, y, y[yi].l);
	string num = to_string(x[xi].num + y[yi].num);
	string right = merge(x, x[xi].r, y, y[yi].r);

	return  "(" + left + ")" + "[" + num + "]" + "(" + right + ")";
}

int main(){
    string a,b;
    cin >> a >> b;

	vector<Node> x(10000), y(10000);
	int idx = 0;
	dfs(x, a, 0, a.size(), idx);
	idx = 0;
	dfs(y, b, 0, b.size(), idx);


	string ans = merge(x,0,y,0);
	cout << merge(x, 0, y, 0) << endl;
}



Measured memory_bytes: 3452
import sys
readline = sys.stdin.readline

def main():
    X, Y, Z, K = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    B = list(map(int, readline().rstrip().split()))
    C = list(map(int, readline().rstrip().split()))
    
    ab = [A[i] + B[j] for i in range(len(A)) for j in range(len(B))]
    ab = sorted(ab, reverse=True)[:K]

    abc = [ab[i] + C[j] for i in range(len(ab)) for j in range(len(C))]
    print(*sorted(abc, reverse=True)[:K], sep='\n')


if __name__ == '__main__':
    main()

Measured memory_bytes: 149744
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
bool dfs(vector<int> data,vector<char>&plus,int i,int sum){
    if(i==3){
        return sum == 7;
    }
    if(dfs(data,plus,i+1,sum+data[i+1])){
        plus.at(i) = '+';
        return true;
    } 
    if(dfs(data,plus,i+1,sum-data[i+1])){
        plus.at(i) = '-';
        return true;
    } 

    return false;
    
}

int main(){
  string S;
  cin >> S;
  vector<int> data(4);
  vector<char> plus(3);
  rep(i,0,4){
      data.at(i) = (int)S.at(i)-48;
  }
  if(dfs(data,plus,0,data.at(0))) {
      rep(i,0,3){
          cout << data.at(i) << plus.at(i);
      }
      cout << data.at(3) << "=7" <<endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a = int(input())
    b = int(input())

    if a > b:
        print("GREATER")
    elif a == b:
        print("EQUAL")
    else:
        print("LESS")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
const int MAX_ROW = 1010;
const int MAX_COL = 1010;
struct BitMatrix {
    int H, W;
    std::bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline std::bitset<MAX_COL>& operator [] (int i) {return val[i];}
};
std::ostream& operator << (std::ostream& s, BitMatrix A) {
    s << std::endl;
    for (int i = 0; i < A.H; ++i) {
        for (int j = 0; j < A.W; ++j) {
            s << A[i][j] << ", ";
        }
        s << std::endl;
    }
    return s;
}
int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        std::swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}
int linear_equation(BitMatrix A, std::vector<int> b, std::vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
void solve(int m) {
  int n, d; cin >> n >> d;
  vvi v(n, vi(m));
  for(int i=0;i<n;++i) {
    for(int j=0;j<m;++j) {
      cin >> v[i][j];
    }
  }
  BitMatrix A(n*m, n*m);
  vi b(n*m);
  for(int i=0;i<n;++i) {
    for(int j=0;j<m;++j) {
      A[i*m+j][i*m+j] = !A[i*m+j][i*m+j];
      b[i*m+j] = v[i][j];
      for(int k=0;k<n;++k) {
        for(int l=0;l<m;++l) {
          if(abs(i-k)+abs(j-l) == d) {
            A[i*m+j][k*m+l] = !A[i*m+j][k*m+l];
          }
        }
      }
    }
  }
  vi res(n*m);
  int result = linear_equation(A, b, res);
  if(result == -1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    int m; cin >> m;
    if(m == 0) break;
    solve(m);
  }
}



Measured memory_bytes: 3428
#include <iostream>
#include <string>
#include <cmath>

#include <string>
#include <cmath>
 
int main(void) {
  int D,N;

  std::cin >> D;
  std::cin >> N;

  /* 1 or 100 or 10000 */

  int base = 0;
  switch (D) {
    case 0:
      base = 1;
      break;
    case 1:
      base = 100;
      break;
    default:
      base = 100*100;
      break;
  }

  if (N >= 100) {
    std::cout << base * (N+1) << std::endl;
  } else {
    std::cout << base * N << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,d,c,sum = 0,keta = 0;
    cin >> m;
    rep(i,m){
        cin >> d >> c;
        sum += d*c;
        keta += c;
    }
    if (sum%9== 0) sum = sum/9-1;
    else sum = sum/9;
    PRINT(sum+keta-1);
}


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

int main(void) {
    long N, inputNum;
    long min = 1000000;
    long max = -1000001;
    long sum = 0;

    cin >> N;

    while(N-- > 0) {
        cin >> inputNum;
        if(max < inputNum)
            max = inputNum;
        if(min > inputNum)
            min = inputNum;
        sum += inputNum;
    }

    cout << min << " " << max << " " << sum << endl;

    return 0;
}

Measured memory_bytes: 3104
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define MSI map<string,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int a,b;
	string op;
	cin >> a>>op>>b;
	if (op.at(0) == '+')
	{
		cout << a + b << endl;
	}
	if (op.at(0) == '-')
	{
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
flag = True
for i in range((len(s)-1)//2):
    if s[i] != s[len(s)-i-1]:
        flag = False
        break
if not flag:
    print('No')
    exit()
else:
    flag1 = True
    flag2 = True
    t = ''
    u = ''
    for i in range((len(s)-1)//2):
        t += s[i]
    for i in range((len(s)-1)//2+1,len(s)):
        u += s[i]
    if len(t)%2 != 0:
        for i in range((len(t)-1)//2):
            if t[i] != t[len(t)-i-1]:
                flag1 = False
                break
    else:
        for i in range(len(t)//2):
            if t[i] != t[len(t)-i-1]:
                flag1 = False
                break
    if len(u)%2 != 0:
        for i in range((len(u)-1)//2):
            if u[i] != u[len(u)-i-1]:
                flag2 = False
                break
    else:
        for i in range(len(u)//2):
            if u[i] != u[len(u)-i-1]:
                flag2 = False
                break
    if flag1 == True and flag2 == True:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3064
n = int(input())
h = [int(i) for i in input().split()]

counter = 0
max = 0

for i in range(1,len(h)):
  
  delta = h[i-1] - h[i]
  
  if 0 <= delta :
    counter += 1
  else :
    if max < counter : max = counter
    counter = 0
    
else:
  if max < counter : max = counter

print(max)

Measured memory_bytes: 14224
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

vector<int> E[1100];
int parent[1100];

vector<int> v1, v2, v3;

void f1(int u){
	v1.push_back(u);
	if(E[u][0] != -1){
		f1(E[u][0]);
	}
	if(E[u][1] != -1){
		f1(E[u][1]);
	}
}

void f2(int u){
	if(E[u][0] != -1){
		f2(E[u][0]);
	}
	v2.push_back(u);
	if(E[u][1] != -1){
		f2(E[u][1]);
	}
}

void f3(int u){
	if(E[u][0] != -1){
		f3(E[u][0]);
	}
	if(E[u][1] != -1){
		f3(E[u][1]);
	}
	v3.push_back(u);
}


int main(){
	
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		parent[i] = -1;
	}
	
	for(int i = 0; i < n; i++){
		int id, c1, c2;
		cin >> id >> c1 >> c2;
		E[id].push_back(c1);
		E[id].push_back(c2);
		if(c1 != -1){
			parent[c1] = id;
		}
		if(c2 != -1){
			parent[c2] = id;
		}
	}
	
	for(int i = 0; i < n; i++){
		if(parent[i] == -1){
			f1(i);
			f2(i);
			f3(i);
			break;
		}
	}
	
	cout << "Preorder" << endl;
	for(int i = 0; i < v1.size(); i++){
		cout << " " << v1[i];
	}
	cout << endl;
	
	cout << "Inorder" << endl;
	for(int i = 0; i < v2.size(); i++){
		cout << " " << v2[i];
	}
	cout << endl;
	
	cout << "Postorder" << endl;
	for(int i = 0; i < v3.size(); i++){
		cout << " " << v3[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
 
int main() {
	int N;
	int x, y, z;
	scanf("%d", &N);
	
	x = N / 100;
	y = (N - (x * 100)) / 10 ;
	z = N % 10;
	if(x == 7 || y == 7 || z == 7){
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
	using namespace std;
	using ll = long long;
	#define forn(i,n) for(int i = 0; i< n;++i)
	int INF = 1e9 + 7;
	ll MOD = 998244353;


	int main(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		int a,b,c,d;
		cin >> a >> b >> c >> d;

		vector<vector<ll>> dp(c+10,vector<ll>(d+10,0));
		
		for(int i = a; i <= c; ++i){
			for(int j = b; j <= d; ++j){
				if(i == a && j == b){
					dp[i][j] = 1;
					continue;
				}
				dp[i][j] = dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1);
				//dp[i][j] %= MOD;
				dp[i][j] = (MOD + dp[i][j] % MOD) % MOD;
			}
		}
		cout << dp[c][d] << endl;
				
	}


Measured memory_bytes: 74112
import numpy as np
steps, limit = map(int, input().split())
heights = [int(height) for height in input().split()]
heights = np.array(heights, np.int)
costs = np.array([0] * steps, np.int)
def search(step, num):
    costs[step] = min(costs[step-num:step] + abs(heights[step-num:step] - heights[step]))
for i in range(1,steps):
    if i < limit:
        search(i, i)
    else:
        search(i, limit)
print(costs[steps-1])

Measured memory_bytes: 23092
<?php
  fscanf(STDIN,"%d",$a);
  $array = explode(" ",fgets(STDIN));
  $cnt = 0;

  for($i=0;$i<$a;$i++)
  {
    $div_num = (int)$array[$i];
    while($div_num % 2 == 0)
    {
      $div_num /= 2;
      $cnt++;
    }
  }
  echo $cnt;

Measured memory_bytes: 5492
#include<iostream>
#include<cmath>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int c(max(a / 2 * 25 + (a % 2 ? 13 : 0), 10 * b));
  cout << (floor(c * 0.08) == a && floor(c * 0.1) == b ? c : -1) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<VI> dp(n + 1, VI(n + 1, 0));
    FOR(i, 0, n)FOR(j, i + 1, n) {
        if (s[i] != s[j])continue;
        dp[i + 1][j + 1] = dp[i][j] + 1;
        chmin(dp[i + 1][j + 1], j - i);
    }

    int ans = 0;
    eFOR(i, 0, n)eFOR(j, 0, n)chmax(ans, dp[i][j]);
    cout << ans << "\n";
}


Measured memory_bytes: 98176
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/

#include <set>
#include <map>
#include <list>
#include <queue>
#include <ctime>
#include <deque>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <chrono>
#include <random>
#include <cassert>
#include <complex>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <fstream>
#include <climits>
#include <stdio.h>
#include <cstring>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
//#include<bits/stdc++.h>
using namespace std;
 
int         cinn()              {int x; scanf("%d", &x); return x;}
long long   scll()              {long long x; scanf("%lld", &x); return x;}
double      scd()               {double x; scanf("%lf", &x); return x;}
void        coutt(int x)        {printf("%d ", x);}
 
#define  scll                   scll()
#define  gcd(a,b)               __gcd(a,b)
#define  lcm(a,b)               (a*b)/gcd(a,b)
#define  PI                     acos(-1.0)
#define  vi                     std::vector<int>
#define  vll                    std::vector<ll>
#define  vit                    vector<int> :: iterator
#define  sit                    set<int> :: iterator
#define  mpsi                   std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  ld                     long double
#define  ull                    unsigned long long int
#define  min3(a,b,c)            min(a,min(b,c))
#define  min4(a,b,c,d)          min(d,min(a,min(b,c)))
#define  max3(a,b,c)            max(a,max(b,c))
#define  max4(a,b,c,d)          max(d,max(a,max(b,c)))
#define  nl                     printf("\n");
#define  no                     printf("No");
#define  yes                    printf("Yes");
#define  F                      first
#define  S                      second

typedef pair<int,int> ii;
typedef std::vector<ii> vii;
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 1e6 + 5;
const int nn           = 4e5 + 5;



int solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	int x = max3(a,b,c);
	set<int>s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size()==2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

int main()
{
    int test = 1, tc = 0;
    //scanf("%d", &test);
   // (void)getchar();
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,t,a,i,index=1;
        double min,c;
        scanf("%d%d%d",&n,&t,&a);
        int h[n];
        for(i=0;i<n;i++)
                scanf("%d",&h[i]);

        min=a-(double)h[0]*0.006;
        if(min<0)min=-min;
        for(i=1;i<n;i++){
                c=a-(t-(double)h[i]*0.006);
                if(c<0) c=-c;
                if(min>c){ min=c;index=i+1;}
        }
        printf("%d\n",index);
        return 0;
}


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

#define int long long
#define ld long double

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>b;i--)

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

void solve()
{
       int n;
       cin>>n;
       if(n%1000==0)
       {
              cout<<0;
       }
       else
       {
              cout<<(1000-n%1000);
       }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
    {
           solve();
    }
    return 0;
}

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

const double pi = 3.1415926535;
/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y % x, x);
}

ll powM(ll x, ll y, ll m) {
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}

map<long long, long long> factorize(long long n) {
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}
/* **********END OF TEMPLATE*********** */
int main() {
	FAST();
	cout << setprecision(20);
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double thetam = m * 6 ;

	double thetah = h * 30 + (m * 30) / 60;
	// cout << thetah << ' ' << thetam << endl;
	double diff = (thetah - thetam) * pi / 180;
	// if (diff > pi) {
	// 	diff = 2 * pi - diff;
	// }
	double ans = a * a + b * b - 2 * a * b * cos(diff);

	cout << sqrt(ans) << endl;
	return 0;
}

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

int main(){
    int a, b, c;
    int k;
    cin >> a >> b >> c >> k;
    int ans=0;
    int aux;
    for(int i = 0; i < k; i++){
        int aux = max(a,b);
        aux = max(aux,c);
        if(aux == a){
            a = 2*aux;
        }else if(aux == b){
            b = 2*aux;
        }else if(aux == c){
            c = 2*aux;
        }
    }
    cout << a+b+c << endl;
    return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll k,q;
    cin>>k>>q;
    ll p[k];
    for(int i=0;i<k;i++) cin>>p[i];
    while(q--){
        ll n,x,m;
        cin>>n>>x>>m;
        n--;
        ll mod = m;
        ll d[k];
        ll cnt = 0;
        ll sum = 0;
        ll eq = 0;
        for(int i=0;i<k;i++){
            d[i] = p[i] % m;
            sum += d[i];
            if(d[i]==0)eq++;
            if(sum >= m){
                sum -= m;
                cnt++;
            }
        }
        ll now = x % m;
        ll cycle = n/k;
        ll ans = cnt * cycle;
        ll ret = cycle * sum;
        ans += ret / m;
        ret %= m;
        ret += now;
        eq *= cycle;
        if(ret >= m)ans++;
        ret %= m;
        if(n%k){
            ll end = n%k;
            for(int i=0;i<end;i++){
                ret += d[i];
                if(d[i]==0)eq++;
                if(ret >= m){
                    ret -= m;
                    ans++;
                }
            }
        }
        cout << n-ans-eq << "\n";
    }
}
// 224489796
// 214285714
// 559523809

// 489795918
// 642857143
// 440476190

Measured memory_bytes: 384
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int x1=sc.nextInt();
    int x2=sc.nextInt();
    int x3=sc.nextInt();
    int x4=sc.nextInt();
    int x5=sc.nextInt();
    if(x1==0)
      System.out.println(1);
     if(x2==0)
      System.out.println(2);
      if(x3==0)
      System.out.println(3);
     if(x4==0)
      System.out.println(4);
     if(x5==0)
      System.out.println(5);
  }
}
 
    

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

using namespace std;

#define pii pair<ll,ll>
#define ll long long
#define s second
#define f first

int n,m;
pii a[100005];
ll mn=LLONG_MAX,mx=-1;
bool cmp(pii a,pii b){
 return a.f<b.f;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<m;++i){
    cin >> a[i].f >> a[i].s;
    mn=min(a[i].s,mn);
    mx=max(a[i].f,mx);
  }
  //cout << mn << " " << mx << endl;
  cout << max(0ll,mn-mx+1);
  return 0;
}


Measured memory_bytes: 1792
n=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  for j in range(i+1,n):
    l=j;r=n
    while abs(l-r)>1:
      mid=(r+l)//2
      if L[i]<L[j]+L[mid] and L[j]<L[i]+L[mid] and L[mid]<L[i]+L[j]:
        l=mid
      else: r=mid
    ans+=l-j
print(ans)

Measured memory_bytes: 73876
let () =
  let rec loop () = 
    let h, w = Scanf.scanf "%d %d\n" (fun h w -> h, w) in
    if h = 0 && w = 0 then ()
    else
      (print_endline (Bytes.make w '#');
      for _ = 2 to h-1 do
        let s = Bytes.make w '.' in
        (Bytes.set s 0 '#'; Bytes.set s (w-1) '#';
        print_endline s;)
      done;
      print_endline (Bytes.make w '#');
      print_endline "";
      loop ())
  in loop ()

Measured memory_bytes: 2300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if (a <= 8 && b <= 8) {
				System.out.println("Yay!");
			} else {
				System.out.println(":(");
			}
		}

	}

}


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

template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 3e5 + 233;
int n, m, ans = 0, tot = 0;
int col[N], inq[N], deg[N][2];
vector <int> g[N];
char str[N];

main(void) {
  read(n); read(m);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i ++)
    col[i] = str[i] - 'A';
  for (int i = 1; i <= m; i ++) {
    int x, y; read(x); read(y);
    g[x].push_back(y);
    g[y].push_back(x);
    deg[x][col[y]] ++;
    deg[y][col[x]] ++;
  }
  queue <int> q;
  for (int i = 1; i <= n; i ++)
    if (!(deg[i][0] && deg[i][1]))
      q.push(i), inq[i] = true;
  while (!q.empty()) {
    int u = q.front(); q.pop(); ++ tot;
    for (int i : g[u]) {
      -- deg[i][col[u]];
      if (!(deg[i][0] && deg[i][1])
          && !inq[i])
        q.push(i), inq[i] = true;
    }
  }
  puts(tot != n ? "Yes" : "No");
}


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

using namespace std; 

int main() {
	int n, k; 
	string str; 
	cin >> n >> k; 
	cin >> str; 
	str[k - 1] = str[k - 1] + 32; 
	cout << str << endl; 
	return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String str = sc.next();
		
		String left = str.substring(0, k-1);
		String right = str.substring(k,n);
		
		String low = String.valueOf(str.charAt(k-1));
		low = low.toLowerCase();
		
		System.out.println(left+low+right);
	}
}


Measured memory_bytes: 23764