akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


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

    rep(i,q){
        ll a,b;cin>>a>>b;
        
        if(a<b)swap(a,b);
        
        if(a==b){
            cout<<(a)*2-2<<endl;
        }else{
            double v = a * b;
            ll c = sqrt(v);
            
            if(c*(c+1)<a*b){
                cout<<2*c-1<<endl;
            }else if(c*c==a*b){
                cout<<2*c-3<<endl;
            }else{
                cout<<2*c-2<<endl;
            }
            
            
        }
        
    }
    
    
    return 0;
}


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

int main(){
    string s,ans;
    ans = "hi";

    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]==ans[0]&&s[i+1]==ans[1]){
            i++;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    
    puts("Yes");
}

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

using namespace std;

int main(){
	int N,x=0,y=0,count,a;
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a;
		count=0;
		if(a%4==0) count+=1;
		if(a%2==0) count+=1;
		if(count==1) x+=1;
		if(count==2) y+=1;
	}
	if(y>=N-x-y){
    cout << "Yes" << endl;
  }else if(!x && y== N/2){
    cout << "Yes" << endl;
  }
	else cout << "No" << endl;
}

Measured memory_bytes: 256
//2734　吉原直樹　問0278
import java.util.Scanner;
public class Main{
    int n;
    int x;
    int y;
    int b;
    int p;
    int kin;
    int wari;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int k=0;k<n;k++){
            x = sc.nextInt();
            y = sc.nextInt();
            b = sc.nextInt();
            p = sc.nextInt();
            kin = x * b + y * p;
            if(b>=5 && p>=2){
               kin = (x * b + y * p) * 4 / 5;
            } else {
                if(b<5) {
                    b=5;
                }
                if(p<2){
                    p=2;
                }
                wari = (x * b + y * p) * 4 / 5;
                if(kin>wari){
                kin=wari;
                }
         }
        System.out.println(kin);
     }
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n){
    string ss = s.substr(i, n-i);
    string tt = t.substr(0, n-i);
    if(ss == tt){
      int ans = s.size() + (t.size() - tt.size());
      cout << ans << endl;
      return 0;
    }
  }
  cout << 2*n << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};



int main(){
    int h,w;
    cin >> h >> w;
    int si,sj;
    cin >> si >> sj;
    int ti,tj;
    cin >> ti >> tj;
    si--;sj--;ti--;tj--;

    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    const int INF = 1e9;
    
    vector<vector<int>> dist(h,vector<int>(w,INF));
    deque<P> q;
    dist[si][sj] = 0;
    q.emplace_back(si,sj);

    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];

        q.pop_front();
        if(dist[i][j] != d){
            continue;
        }
        rep(v,4){
            int ni = i + di[v];
            int nj = j + dj[v];
        

            if(ni < 0 || ni >= h || nj < 0 || nj >= w){
                continue;
            }
            if(s[ni][nj] == '#')continue;
            if(dist[ni][nj] <= d){
                continue;
            }

            dist[ni][nj] = d;
            q.emplace_front(ni,nj);
        }

        for(int ei = -2;ei <= 2;ei++){
            for(int ej = -2;ej <= 2;ej++){
                int ni = i + ei;
                int nj = j + ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w){
                    continue;
                }
                if(s[ni][nj] == '#')continue;
                if(dist[ni][nj] <= d + 1)continue;
                dist[ni][nj] = d + 1;
                q.emplace_back(ni,nj);
            }
        }

    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9508
#include <bits/stdc++.h>
#define NMAX 100001

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int firstc=-1,lastp=-1;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='F')
            lastp=i;
        else if(s[i]=='C' && firstc==-1)
            firstc=i;
    }
    if(lastp>=0 && firstc>=0 && lastp>firstc)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Bits

main :: IO ()
main = readLine >>= printRes . solve
    where
        printRes = putStrLn . unwords . map show

solve :: [Int] -> [Int]
solve [m, k] 
    | k >= 2 ^ m = [-1]
    | m == 0 && k == 0 = [0, 0]
    | m == 1 && k == 0 = [0, 0, 1, 1]
    | m `elem` [0, 1] = [-1]
    | otherwise = k : [0..(k - 1)] ++ [(k + 1)..(2 ^ m - 1)] ++ [k] ++ [(2 ^ m - 1), (2 ^ m - 2)..(k + 1)] ++ [(k - 1), (k - 2)..0]

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 3964
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e4 + 5;
const int  M  = 1e9+7;

int c[N][N];

int main(){
	
	for(int i=0;i<N;i++){
		c[i][0] = c[i][i] = 1;
		for(int j=1;j<i;j++){
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) %M;
		}
	}

	int n,m;
	cin>>n>>m;
	vector<int> ret(m+1);
	for(int k=1;k<=m;k++){
		if(n - m< k -1)break;
		ret[k] = (ll)c[m-1][k-1] * c[n-m+1][k] %M;
	}

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


	

	return 0;
}

Measured memory_bytes: 863252
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		ArrayList<Integer> arr=new ArrayList<Integer>();
		for(int j=0;j<n;j++) {
			int h=scn.nextInt();
			arr.add(h);
		}ArrayList<Integer> ans=new ArrayList<Integer>();
		for(int j=0;j<n;j++) {
			ans.add(0);
		}
		for(int j=0;j<n;j++) {
			ans.set(arr.get(j)-1, j+1);
		}
		for(int i=0;i<n;i++) {
			System.out.print(ans.get(i)+" ");
		}
    }
}

Measured memory_bytes: 56156
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);   
    ll x,k,d,t,ans=INF,g,h,a;
    sfl(x),sfl(k),sfl(d);
    a = k;
    t = abs(x)/d;
    t = min(t,k);
    g = x-t*d;
    h = x+t*d;
    a = a-t;
    if(a){
        if(a&1){
            g -= d;
            h += d;   
        }
        else{
            ans = min(ans,abs(g));
            ans = min(ans,abs(h));
            g -= 2*d;
            h += 2*d;
        }
    }
    ans = min(ans,abs(g));
    ans = min(ans,abs(h));
    t++;
    pfl(ans);
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a, b;
  cin >> a >> b;
  string str_a(b-'0', a);
  string str_b(a-'0', b);
  if (str_a < str_b) cout << str_a;
  else cout << str_b;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

int isParotum(string s){
  int i;
  rep(i,(int)s.length()){
    if(s[i] != s[(int)s.length()-i-1])
      return 0;
  }
  return 1;
}

signed main(void)
{
  int i;
  int sum=0;
  in(int,a,b);
  loop(i,a,b+1){
    sum+=isParotum(to_string(i));
  }
  putv(sum);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5;

int a[N];

int main(){
    int k, n;
    scanf("%d %d", &k, &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    int mx = k - a[n - 1] + a[0];
    for(int i = 1 ; i < n ; ++i)
        mx = max(mx, a[i] - a[i - 1]);
    printf("%d\n", k - mx);
}

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

def main():
    sx, sy, tx, ty = map(int, readline().rstrip().split())
    r1 = 'U' * (ty-sy) + 'R' * (tx-sx)
    r2 = 'D' * (ty-sy) + 'L' * (tx-sx)
    r3 = 'L' + 'U' * (ty-sy+1) + 'R' * (tx-sx+1) + 'D'
    r4 = 'R' + 'D' * (ty-sy+1) + 'L' * (tx-sx+1) + 'U'
    print(r1 + r2 + r3 + r4)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    const int mod = 2600000069;
    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    const int mod = 2600000069;
    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector<string> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<vector<int>>a(n, vector<int>(m, 0));
    for (int i =0 ; i < n; i++) {
        for (int j = 0 ;j < m; j++) {
            if (b[i][j] == '#') a[i][j] = 1;
        }
    }
    const int MAXN = 101;
    int dp[MAXN][MAXN];
    for (int i = 0; i < MAXN; i++) for (int j = 0 ; j < MAXN; j++) dp[i][j] = INF;
    dp[0][0] = (a[0][0] ? 1 : 0);
    for (int i = 1; i < n; i++) {
        dp[i][0] = dp[i - 1][0];
        if (a[i][0] != a[i - 1][0] && a[i][0]) dp[i][0]++;
    }
    for (int i = 1; i < m; i++) {
        dp[0][i] = dp[0][i - 1];
        if (a[0][i] != a[0][i - 1] && a[0][i]) dp[0][i]++;
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < m; j++) {
            dp[i][j] = dp[i - 1][j];
            if (a[i][j] != a[i - 1][j] && a[i][j]) dp[i][j]++;
            if (dp[i][j - 1] < dp[i][j]) {
                dp[i][j] = dp[i][j - 1];
                if (a[i][j] != a[i][j - 1] && a[i][j]) dp[i][j]++;
            }
        }
    }
    cout << dp[n - 1][m - 1];
}
/*

*/


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n;
    cin >> n;
    bool ok = true;
    for(ll i = 1; i <= 3500; i++){
        for(ll j = 1; j <= 3500; j++){
            ll c = 1;
            if(4*i*j%n!=0) {
                c = i*j*n/__gcd(i*j, n);
            }
            for(ll k = 1; k <= 3500; k+=c){
                //cout << i << " " << j << " " << k << " " << c<< endl;
                if(4*i*j*k == n*(i*j+j*k+k*i)){
                    cout << i << " " << j << " " << k << endl;
                    ok = false;
                    break;
                }
            }
            if(ok==false) break;
        }
        if(ok == false) break;
    }
    return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

string s;

int main(){
	cin.sync_with_stdio(false);
	cin>>s;
	int flag=0;
	rep(i,s.length()){
		if(flag==0&&s[i]=='C')flag=1;
		if(flag==1&&s[i]=='F')flag=2;
	}
	if(flag==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
R, G, B, N = map(int, input().split())
rgb = []
for i in range(N + 1):
    for j in range(N - (i * R) + 1):
        key = i * R + j * G
        key = N - key
        if key % B == 0 and key / B >= 0:
            rgb.append([i, j, key // B])

#print(rgb)
print(len(rgb))

Measured memory_bytes: 540876
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i, ok = 0;
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		ok = true;
	if (ok)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  
  
  int b=10*(s[5]-'0')+s[6]-'0';
  
	if(b<5){
	cout<<"Heisei"<<endl;
    }else{
	cout<<"TBD"<<endl;
    }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int MX = 100005;
vector<int> parents(MX);
vector<int> in(MX);
vector<vector<int>> tree(MX,vector<int>());
  
int main() {
  int n,m;
  cin >> n >> m;
  rep(i,n-1+m){
    int a,b;
    cin >> a >> b;
    --a; --b;
    tree.at(a).push_back(b);
    in.at(b) ++;
  }
  int parent = 0;
  rep(i,n){
    if(in.at(i) == 0){
      parent = i;
      break;
    }
  }
  parents.at(parent) = -1;
  queue<int> q;
  q.push(parent);
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(auto i:tree.at(now)){
      in.at(i) --;
      if(in.at(i) == 0){
        parents.at(i) = now;
        q.push(i);
      }
    }
  }

  rep(i,n) cout << parents.at(i)+1 << endl;

  return 0;
}



Measured memory_bytes: 7040
#include<bits/stdc++.h>
#include<iostream>
#include<list>
#include<vector>
#include<climits>
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef vector<int> vi;
typedef long long int ll;

int main()
{
    fast_io();
    int n,i,a;
    cin>>n;
    float sum=0.0;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum+=(float)1/(float)a;
    }
    float x=1/sum;
    cout<<x;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


ll nCr(int n, int r)
{
	ll ret=1;

	if(r*2>n) r=n-r;

	for(int i=0;i<r;i++)
	{
		ret=ret*(n-i)/(i+1);
	}
	return ret;
}


int calc_u(int k)
{
	int u=1;
	for(int i=0;i<k;i++) u*=9;
	return u;
}


int main(void)
{
	char n[101+2];
	int k;
	while(scanf("%101[0-9]\n%d\n", n, &k)==2)
	{
		int l=strlen(n);
		vi a(l);

		for(int i=0;i<l;i++) a[i]=n[i]-'0';

		int ans=0;
		for(int i=0;i<l;i++)
		{
			int r=l-i;

			if(r<k) break;
			if(r>k && a[i]>0) ans+=nCr(r-1, k)*calc_u(k);
			for(int j=1;j<a[i];j++)
			{
				ans+=nCr(r-1, k-1)*calc_u(k-1);
			}
			if(a[i]>0)
			{
				k--;
				if(k<=0)
				{
					ans++;
					break;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }else if(b=='T'){
    cout<<'A'<<endl;
  }else if(b=='G'){
    cout<<'C'<<endl;
  }else{
    cout<<'G'<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,ans=0;
	cin>>N;
	int C[N+1]={0};
	for(int i=1;i<=N;i++){
		for(int j=i;j<=N;j+=i)C[j]++;
	}
	for(int i=1;i<N;i++)ans+=C[i];
	cout<<ans;
	return 0;
}

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

int main(){
  int N,sum; cin >> N;
  sum=0;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  vector<int> vek(N);
  for(int i=0;i<N;i++){
    vek.at(i)=i+1;
  }
  if(vec == vek){
    sum++;
  }
   for(int i=0;i<N-1;i++){
     for(int j=i+1;j<N;j++){
       swap(vec.at(i),vec.at(j));
       if(vec == vek){
         sum++;
       }
       swap(vec.at(i),vec.at(j));
     }
   }
  if(sum == 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n,m = map(int,input().split())

A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j in range(m)]

L = []
for i in range(n):
  l = []
  for j in range(m):
    d = abs(A[i][0] - B[j][0]) + abs(A[i][1] - B[j][1])
    l.append(d)
  L.append(l)
  
for i in range(n):
  print(L[i].index(min(L[i]))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans=0;
vector<int> p;

int main() {
    scanf(" %d %d", &n, &k);
    rep(0,n) {
        scanf(" %d", &m);
        p.push_back(m);
    }

    sort(p.begin(), p.end());
    auto it = p.begin();
    rep(0, k) {
        ans += *it;
        it++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3836
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, x;
    cin >> n >> x;
    vi l(n);
    rep(i, n) cin >> l[i];
    
    int c=0;
    int cnt=1;
    rep(i, n){
        c += l[i];
        if (x < c){
            break;
        }else{
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        String str2 = sc.next();
        
        for (int i = 0; i < n; i++) {
            System.out.print(str.charAt(i));
            System.out.print(str2.charAt(i));
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(i&1){
			int cnt=0;
			for(int j=1;j<=sqrt(i);j++){
				if(i%j==0){
					cnt++;
					if(i/j!=j){
						cnt++;
					}
				}
			}
			if(cnt==8){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
h = LI()
dp = [float('INF')]*(N)
dp[0] = 0
for i in range(1,N):
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

Measured memory_bytes: 55008
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::min;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut d = scan.readn::<i64>(n).into_iter().map(|x| min(24 - x, x)).collect::<Vec<_>>();
    d.push(0);
    d.sort();
    let mut d2 = vec![];
    for i in 0..d.len() {
        let mut cans = vec![d[i], 24 - d[i]];
        cans.sort();
        d2.push(cans[i % 2]);
    }
    let mut ret = 1i64 << 60;
    for i in 0..d2.len() {
        for j in i+1..d2.len() {
            let d = (d2[i] - d2[j]).abs();
            ret = min(ret, min(d, 24 - d));
        }
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
s = input()
s_r_l = list(reversed(s))
s_r = ''.join(list(s_r_l))
# print(s_r)
t = str()
d = ['dream','dreamer','erase','eraser']
d_r = []
for i in d:
    i_s_l = list(reversed(i))
    i_s = ''.join(list(i_s_l))
    d_r.append(i_s)
# print(d_r)
while len(s_r)>0:
    judge = [s_r.startswith(i) for i in d_r]
    if any(judge):
        # print(judge)
        target = d_r[judge.index(True)]
        # print(target)
        s_r = s_r[len(target):]
        # print(s_r)
        if len(s_r) == 0:
            print("YES")
    else:
        print("NO")
        break

Measured memory_bytes: 134820
#include<iostream>
#include<sstream>

using namespace std;

int main() {

	int n;
	cin >> n;
	int a;
	int b;
	int c;

	a = n - 700;
	if ((a >= 0) && (a <= 100)) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		b = n % 100;
		b = b - 70;
		if ((b >= 0) && (b <= 10)) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			c = n % 10;
			c = c - 7;
			if (c == 0) {
				cout << "Yes" << endl;
				return 0;
			}
			else {
				cout << "No" << endl;
			}
		}
	}

	return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll N, C;
    cin >> N >> C;
    vector<pair<ll, ll>> V(N);
    REP(i, N) {
        cin >> V[i].first >> V[i].second;
    }
    vector<ll> clockwise, counter, mxClock, mxCounter;
    ll tot = 0, mx = 0;
    REP(i, N) {
        tot += V[i].second;
        clockwise.pb(tot - V[i].first);
        mx = max(mx, clockwise[i]);
        mxClock.pb(mx);
    }
    mx = 0, tot = 0;
    FORD(i, N - 1, 0) {
        tot += V[i].second;
        counter.pb(tot - (C - V[i].first));
        mx = max(mx, counter[N - 1 - i]);
        mxCounter.pb(mx);
    }
    // debug(clockwise);
    // debug(counter);
    // debug(mxClock);
    // debug(mxCounter);

    ll ans = 0, acc = 0;
    REP(i, N) {
        ll sum = clockwise[i];
        // debug(sum);
        if (i < N - 1) {
            auto it = lower_bound(mxCounter.begin(), mxCounter.end() - i - 2, mxCounter[N - i - 2]);
            if (*it - V[i].first > 0) {
                sum += *it - V[i].first;
            }

        }
        // debug(sum);
        ans = max(ans, sum);
    }
    REP(i, N) {
        ll sum = counter[i];
        if (i < N - 1) {
            auto it = lower_bound(mxClock.begin(), mxClock.end() - i - 2, mxClock[N - i - 2]);
            if (*it - (C - V[N - 1 - i].first) > 0) {
                sum += *it - (C - V[N - 1 - i].first);
            }
        }
        // debug(sum);
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7404
#! python.exe
dic = {}
for idx, c in enumerate("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"):
    dic[c] = str(format(idx,'b').zfill(5))

decode = {"101"      : " ", "0101"     : "C", "0110"     : "K", "00110"    : "S",
          "000000"   : "'", "0001"     : "D", "00100"    : "L", "00111"    : "T",
          "000011"   : ",", "110"      : "E", "10011001" : "M", "10011100" : "U",
          "10010001" : "-", "01001"    : "F", "10011110" : "N", "10011101" : "V",
          "010001"   : ".", "10011011" : "G", "00101"    : "O", "000010"   : "W",
          "000001"   : "?", "010000"   : "H", "111"      : "P", "10010010" : "X",
          "100101"   : "A", "0111"     : "I", "10011111" : "Q", "10010011" : "Y",
          "10011010" : "B", "10011000" : "J", "1000"     : "R", "10010000" : "Z"}
#print(dic)
while True:
    try:
        line = input()
    except:
        break
    s = ""
    for c in line:
        s += dic[c]
    ans = ""
    while len(s) > 5 or s.count("1") :
        for key in decode:
            n = len(key)
            if s[0:n] == key:
                ans += decode[key]
                s = s[n:]
                break
#        print(ans, s)
    print(ans)

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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d>> e >> f;
    int wa=0,su=0;

    double rate = 0.0;
    for(int i=0;i<30;i++){
        for(int j=0;j<=30;j++){
            for(int k=0;k<f/c;k++){
                for(int l=0;l<=f/d;l++){
                    int wa1 = 100*a*i+100*b*j;
                    int su1 = c*k+d*l;
                    if((wa1+su1 <= f) && (su1 <= e*(a*i+b*j))){
                        if(su1*100*1.0/(su1+wa1) > rate){
                            wa = wa1;
                            su = su1;
                            rate = su*100*1.0/(su+wa);
                        }
                    }
                }
            }
        }
    }
    if(rate == 0.0) wa = 100*a;
    cout << wa+su <<" "<<su<<endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
t, a = gets.split(' ')
t = t.to_i
a = a.to_i
h = gets.split(' ')

new = []
h.each do |f|
    new << (a - (t - 0.006*f.to_f)).abs
end

print new.index(new.min)+1

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};


int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i < n; ++i)
    {
        ans += ((n - 1)/ i);
    }

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

Measured memory_bytes: 3648
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from re import findall

FIGURE = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}

for line in stdin:
    vs = [FIGURE[s[0]] * len(s) for s in findall('(\w)\1*', line)]
    value = 0
    while vs:
        buf = vs.pop(0)
        if vs and buf < vs[0]:
            value -= buf
        else:
            value += buf
    print(value)

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, i, res;
char t1[105], t2[105], t3[105];
set<char> s;

int main() {
scanf("%d", &n);
scanf("%s", t1);
scanf("%s", t2);
scanf("%s", t3);
res = 0;
for (i=0;i<n;i++) {
	s.clear();
	s.insert(t1[i]);
	s.insert(t2[i]);
	s.insert(t3[i]);
	res += (s.size() - 1);
}
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int a[n + 1];
    int b[n + 1];
    int c[n + 1];
    int S[n + 1][3];

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i + 1]);
        scanf("%d", &b[i + 1]);
        scanf("%d", &c[i + 1]);
    }

    // 初期化
    // 初日の幸福度
    S[1][0] = a[1];
    S[1][1] = b[1];
    S[1][2] = c[1];

    for (int i = 2; i <= n; i++) {
        S[i][0] = (S[i-1][1] > S[i-1][2]) ? S[i-1][1] + a[i] : S[i-1][2] + a[i];
        S[i][1] = (S[i-1][0] > S[i-1][2]) ? S[i-1][0] + b[i] : S[i-1][2] + b[i];
        S[i][2] = (S[i-1][0] > S[i-1][1]) ? S[i-1][0] + c[i] : S[i-1][1] + c[i];
    }
    int ans;
    if (S[n][0] > S[n][1]) {
        if (S[n][0] > S[n][2]) {
            ans = S[n][0];
        } else {
            ans = S[n][2];
        }
    } else {
        if (S[n][1] > S[n][2]) {
            ans = S[n][1];
        } else {
            ans = S[n][2];
        }
    }
    //for (int i = 1; i <= n; i++) {
    //    printf("S[%d][0]: %d\n", i,  S[i][0]);
    //    printf("S[%d][1]: %d\n", i,  S[i][1]);
    //    printf("S[%d][2]: %d\n", i,  S[i][2]);
    //}
    printf("%d\n", ans);
}


Measured memory_bytes: 2560
#include <stdio.h>

int main()
{
	char s[80];
	int i=0;

	scanf("%s",s);
	for (i=0;s[i]!='\0';i++)
		;

	if (i==3){
		if (s[0]=='A' || s[0]=='B'){
			if ((s[0]==s[1]) && (s[1]==s[2]))
				printf("No");
			else
				printf("Yes");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N; cin >> N;
	int ans = N * 100 / 108 + 0.001;
	int tmp1 = ans * 108 / 100 + 0.001;
	int tmp2 = (ans+1) * 108 / 100 + 0.001;
	if (tmp1 == N) {
		cout << ans << endl;
	} else if (tmp2 == N) {
		cout << ans+1 << endl;
	} else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 3604
N = int(input())
As = list(map(int, input().split())) + [0]

ans = 0
num = 1
aPrev = As[0]
for a in As[1:]:
    if a == aPrev:
        num += 1
    else:
        ans += num // 2
        num = 1
    aPrev = a

print(ans)


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

int digitsum(int n)
{
    int sum = 0;
    while(n>0)
    {
        sum += n%10;
        n = n/10;
    }
    return sum;
}

int main()
{
    int n;
    cin >> n;
    int x = digitsum(n);
    if(n%x==0)
    {
        cout << "Yes\n";
    }
    else
        cout << "No\n";
    return 0;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int n,q,p[100010],qzh[100010],l,r;
int main() {
	scanf("%d%d",&n,&q);
	cin>>s;
	for(int i=0;i<s.size();i++)
	if(s[i]=='A'&&s[i+1]=='C')
	p[i+1]=1;
	for(int i=1;i<=n;i++)
	qzh[i]=qzh[i-1]+p[i];
	while(q--)
	{
		scanf("%d%d",&l,&r);
		printf("%d\n",qzh[r-1]-qzh[l-1]);
	}
}

Measured memory_bytes: 1920
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    if N % 1000 == 0:
        print (0)
    else:
        print(1000 - N % 1000)


if __name__ == '__main__':
    main()

Measured memory_bytes: 68812
import java.util.Scanner;
import java.util.Stack;
import java.util.regex.Pattern;

/**
 * ZAKIREN第5章
 *
 * @author K.Yamauchi
 *
 */
public class Main {

	/** 入力用 */
	private static Scanner scan = new Scanner(System.in);

	/**
	 * メイン。
	 * @param args
	 */
	public static void main(String[] args) {

		// 対象文字列の読み込み
		String[] targetArray = scan.nextLine().split(" ");

		// 読み込み終了
		scan.close();
		scan = null;

		// 計算を実行
		int answer = calculation(targetArray);

		// 結果出力
		System.out.println(answer);

	}

	/**
	 * 与えられた逆ポーランド記法の文字列を計算する
	 * @param targetStack
	 */
	private static int calculation(String[] targetArray) {

		// 計算用スタック
		Stack<Integer> targetStack = new Stack<>();

		// 数字の正規表現
		Pattern pattern = Pattern.compile("^[0-9]*$");

		// 計算
		for (int i = 0; i < targetArray.length; i++) {
			if (!pattern.matcher(targetArray[i]).matches()) {

				if (targetArray[i].equals("+")) {
					targetStack.push(targetStack.pop() + targetStack.pop());
				} else if (targetArray[i].equals("-")) {
					targetStack.push(-targetStack.pop() + targetStack.pop());
				} else if (targetArray[i].equals("*")) {
					targetStack.push(targetStack.pop() * targetStack.pop());
				}
			} else {
				targetStack.push(Integer.parseInt(targetArray[i]));
			}
		}

		return targetStack.pop();
	}

}



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

using namespace std;

int main()
{
    int r,D,x2000;
    cin >> r >> D >> x2000;
    int ans = x2000;
    for (int i = 0;i < 10;i++) {
        ans = r*ans-D;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
pair<long long, long long> and_expr(State &a);
pair<long long, long long> term(State &a);
pair<long long, long long> or_expr(State &a) {
	pair<long long, long long> ans = and_expr(a);
	while (*a != '!') {
		if (*a == '|') {
			a++;
			pair<long long, long long> now = or_expr(a);
			pair<long long, long long> next_go = make_pair(0, 0);
			//if 0 - 0
			next_go.first = ans.first + now.first;
			//if 1 - ? or 0 - 1
			next_go.second = min(ans.second, ans.first + now.second);
			ans = next_go;
		}
		else {
			break;
		}
	}
	return ans;
}
pair<long long, long long> and_expr(State &a) {
	pair<long long, long long> ans = term(a);
	while (*a != '!') {
		if (*a == '&') {
			a++;
			pair<long long, long long> now = and_expr(a);
			pair<long long, long long> next_go = make_pair(0, 0);
			//0 - ? or 1 - 0
			next_go.first = ans.first;
			next_go.first = min(next_go.first, ans.second + now.first);
			//1 - 1 is only time to be '1'
			next_go.second = ans.second + now.second;
			ans = next_go;
		}
		else {
			break;
		}
	}
	return ans;
}
pair<long long, long long> term(State &a) {
	if (*a == '(') {
		a++;
		pair<int,int> now = or_expr(a);
		a++;
		return now;
	}
	else if (*a == '?') {
		a++;
		return make_pair(1, 1);
	}
}
int main() {
	string s;
	cin >> s;
	s.push_back('!');
	State hoge = s.begin();
	pair<int, int> ans = or_expr(hoge);
	cout << ans.first << " " << ans.second << endl;
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//入力データを変数で受け取る
		int n = sc.nextInt();

		int a = sc.nextInt();
		int b = sc.nextInt();


		//入力データを処理して、結果を出力
		int d = Math.abs(a - b);
		if(d % 2 == 0) {
			System.out.println("Alice");
		} else {
			System.out.println("Borys");
		}

	}
}


Measured memory_bytes: 35828
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  int n;
  cin>>n;

  int ans = 0;
  int need = 1;
  int v;
  for (int i=0; i<n; i++) {
    cin>>v;
    if (v == need) {
      need++;
    }
    else {
      ans++;
    }
  }

  if (need == 1)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, j, cnt = 1;
    scanf("%d", &n);
    char s[100002];
    scanf("%s", s);
    for (i=1; i<n; i++) {
        if (s[i] != s[i-1]) cnt++;
    }
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define ll long long

//*
//プラキュー（二分ヒープ）（最低限バージョン）
//int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
int PQhikaku(ll*heap,int i,int j){return heap[i]<heap[j];}
void heap_utod(ll*heap,int n){
	if(2*n>heap[0])return;
	int rflag=(2*n+1<=heap[0])&&(PQhikaku(heap,2*n,2*n+1));
	if(PQhikaku(heap,n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heap_utod(heap,2*n+rflag);
	}
}
void heap_dtou(ll*heap,int n){
	if(n==1||PQhikaku(heap,n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heap_dtou(heap,n/2);
}
ll PQpop(ll*heap){
	ll rr=heap[1];
	heap[1]=heap[heap[0]--];
	heap_utod(heap,1);
	return rr;
}
void PQpush(ll*heap,ll n){
	heap[++heap[0]]=n;
	heap_dtou(heap,heap[0]);
}
//*/

ll a[2000010];

int main(){
	char s[10];
	while(scanf("%s",s),s[2]!='d'){
		if(s[0]=='i'){
			int t;
			scanf("%d",&t);
			PQpush(a,t);
		}else{
			printf("%d\n",PQpop(a));
		}
	}
}


Measured memory_bytes: 9532
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    const int mod = 1e9 +7;
    ll n;

    cin>>n;
    vector<ll> a(n+3);

    rep(i,n)
    {
        cin>>a[i];
    }

    vector<ll> bu(n+3);
    
    bu[n-1] = a[n-1];

    for(ll i =n-2;i>=0;i--)
    {
        bu[i] = (bu[i+1]+a[i])%mod;
    }

    ll ans = 0;

    for(ll j=0;j<n-1;j++)
    {
        ans = (ans + a[j]*bu[j+1])%mod;

    }

    cout<<ans<<endl;

}

Measured memory_bytes: 5936