akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> v;
    rep(i, n) {
        int enter;
        cin >> enter;
        v.pb(enter);
    }
    sort(all(v));
    int ans = 0;
    rep(i, k) {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main(){
  char s[101],t[101];
  scanf("%s %s",s,t);
  int i,j,len;
  len=strlen(s);
  for(i=0;i<len;i++){
    if(strcmp(s,t)==0){
      puts("Yes");
      return 0;
    }
    else{
      char a=s[len-1];
      for(j=len-1;j>0;j--)
        s[j]=s[j-1];
      s[0]=a;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
H = list(map(int, input().split()))
W = list(map(int, input().split()))
H.sort(reverse=True)
W.sort(reverse=True)
H.append(0)
W.append(0)

mod = 10 ** 9 + 7
j = 0
k = 0
ans = 1
for i in reversed(range(1, N*M+1)):
    if H[j] > i or W[k] > i:
        print(0)
        exit()
    elif H[j] == i and W[k] == i:
        j += 1
        k += 1
    elif H[j] == i:
        ans = (ans * k) % mod
        j += 1
    elif W[k] == i:
        ans = (ans * j) % mod
        k += 1
    else:
        tmp = max(j * k - N * M + i, 0)
        ans = (ans * tmp) % mod
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
int n;
int arr[100005];
int main(){
	cin>>n;
	vector<int>dp(n+5,INF);
	for(int i=1; i<=n; i++) cin>>arr[i];
	dp[1] = 0;
	for(int i=1; i<=n; i++){
		dp[i+1] = min(dp[i+1],abs(arr[i]-arr[i+1])+dp[i]);
		dp[i+2] = min(dp[i+2],abs(arr[i]-arr[i+2])+dp[i]);
	}
	cout<<dp[n];
}

Measured memory_bytes: 4048
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

template < typename T > std::string to_string( const T& n )
    {
        std::ostringstream stm ;
        stm << n ;
        return stm.str() ;
    }

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	int a, b;
	cin >> a >> b;
	int ans = 0;
	
	FOR(i, a, b+1) {
	
		string s=to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) {
			ans++;
		}
	}

	
	ANS(ans);


	return 0;
}



Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 3e3+2;


ll fx(vl a, ll median)
{
    ll y = 0;
    rep(i, 1, a.size())
        y += abs(a[i] - median);
    return y; 
}

void solve()
{
    int n;
    scn(n);

    set<ll> s;
    vl a(n+1); 

    rep(i, 1, n+1) {
        lscn(a[i]); a[i] -= i;
        s.insert(a[i]);
    }

    sort(a.begin()+1, a.end());

    ll sum1 = fx(a, a[(n+1)/2]);
    lprin(sum1);
} 

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 15680
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
wv = [inpl() for _ in range(n)]
rwv = wv[::-1]
udp = [[0] * t for _ in range(n)]
ddp = [[0] * t for _ in range(n)]

for i in range(n-1):
    w,v = wv[i]
    for j in range(t):
        if j < w:
            udp[i+1][j] = udp[i][j]
        else:
            udp[i+1][j] = max(udp[i][j], udp[i][j-w] + v)
res = udp[n-1][t-1] + wv[n-1][1]

for i in range(n-1):
    w,v = rwv[i]
    for j in range(t):
        if j < w:
            ddp[i+1][j] = ddp[i][j]
        else:
            ddp[i+1][j] = max(ddp[i][j], ddp[i][j-w] + v)
    res = max(res,ddp[n-1][t-1] + wv[0][1])
# print(res)
for i in range(1,n-1):
    u = i; d = n-i-1
    mx = 0
    for j in range(t):
        tmp = udp[u][j] + ddp[d][t-1-j]
        mx = max(mx, tmp)
    res = max(res, mx + wv[i][1])
print(res)

Measured memory_bytes: 188788
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	long long int l[90];
	int n;

	cin >> n;

	l[0] = 2;
	l[1] = 1;
	FOR(i, 2, n) {
		l[i] = l[i - 1] + l[i - 2];
	}
	cout << l[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int D, G, p[11], c[11];
  cin >> D >> G;
  for(int i = 0; i < D; ++i){
    cin >> p[i] >> c[i];
  }

  int ans = 1e9;
  for(int mask = 0; mask < (1 << D); ++mask){
    int s = 0, num = 0, rest_max = -1;
    for(int i = 0; i < D; ++i){
      if(mask >> i & 1){
        s += 100 * (i+1) * p[i] + c[i];
        num += p[i];
      }else{
        rest_max = i;
      }
    }
    if(s < G){
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if(need >= p[rest_max]){
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 S=[int(input())for _ in[0]*N]
 p=b=1
 for i in range(M):
  d=int(input())
  p+=d
  if N<=p:
   if b:print(-~i);b=0
   continue
  p+=S[~-p]
  if(N<=p)*b:print(-~i);b=0


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
const long long INF = 2*1e18;

//累積和は関数化しておくと脳へのダメージが少ない
vector<long long> A,Al,Ar;
//regist:累積和に使うvectorを登録する
void regist(vector<long long> D){
    A=D;
    Al=D;
    for(long long i=0;i<((long long)D.size())-1;i++){
        Al[i+1]=Al[i]+D[i+1];
    }
    Ar=D;
    for(long long i=((long long)D.size())-2;i>=0;i--){
        Ar[i]=Ar[i+1]+D[i];
    }
}

//accu:l,l+1,...,rの総和(modを貫通してl>rでも総和にする、
//l=rだとA[l]を返しl=r+1だと全体の和になる)
long long accu(long long l,long long r){
    if(l<=r){
        if(l==0){
            return Al[r];
        }else{
            return Al[r]-Al[l-1];
        }
    }else{
        return Al[r]+Ar[l];
    }
}

//sum:そのまんま総和
long long sum(void){
    return Ar[0];
}
//累積和ここまで


signed main(void){
    
    long long N,K,a;
    vector<long long> P,C;
    
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> a;
        a--;
        P.push_back(a);
    }
    for(int i=0;i<N;i++){
        cin >> a;
        C.push_back(a);
    }
    
    //まずはループごとに分解する
    //visited:過去にそれを含むループが調べられているか
    vector<bool> visited(N,false);
    long long Ans = -INF;
    
    for(int i=0;i<N;i++){
        if(visited[i])continue;
        long long k = i;
        vector<long long> now={};
        while(1){
            if(visited[k])break;
            visited[k]=true;
            now.push_back(C[k]);
            k = P[k];
        }
        //これでnowはiを含むループ全体になった
        
        //念の為空のときは避けておく
        //多分使われてないと思うけどね　ゼロ割り怖すぎる
        if(now.size()==0)continue;
        regist(now);
        
        long long S = sum();
        
        if(S<=0){
            //ループ総和が負のときは1~min(K,L)の中に最大がある
            long long num=-INF;
            long long L = now.size();
            for(long long i=0;i<L;i++){
                for(long long j=0;j<L;j++){
                    long long s;
                    if(i<=j){
                        s = j-i+1;
                    }else{
                        s = L-(i-j-1);
                    }
                    //sは区間に含まれる要素の数
                    if(s<=K){
                        num = max(num,accu(i,j));
                        //accuはi~jまでの和
                    }
                }
            }
            Ans = max(Ans,num);
            
        }else{
            //ループ総和が正のときはK-L+1~Kに総和がある
            //負のときと実装が若干違う　どちらでもよし
            long long num = -INF;
            long long L = now.size();
            for(long long i=0;i<L;i++){
                for(long long s=max(1ll,K-L+1);s<=K;s++){
                    long long temp = accu(i,(i+s-1)%L);
                    temp += S*((s-1)/L);
                    //tempはi,i+1,...,i+s-1の和
                    num = max(num,temp);
                }
            }
            Ans = max(Ans,num);
        }
        
    }
    cout << Ans << endl;
    
    return 0;
}


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

int main() {
  int n, h[3] = {};

  for(int i = 0; i < 10; i++) {
    cin >> n;
    for(int j = 0; j < 3; j++) {
      if(n > h[j]) swap(n, h[j]);
    }
  }

  for(int i = 0; i < 3; i++) cout << h[i] << endl;
}

	
	

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Grid = vector<vector<int>>;
const ll INF = 10011032323450010;
const ld PI = 3.14159265358979323846;



int main() {
     
    int R,G,B,N,div,count=0;
    cin>>R>>G>>B>>N;
    rep(r,N/R +1){
        rep(g,(N-r*R)/G +1){
            div=(N-r*R-g*G)/B;
            if(B*div==N-r*R-g*G){
                count++;
            }

        }
    }
    cout<<count<<endl;


return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    //cout<<1;
    int n;
    cin>>n;
    int cpy=n;
    int ans=0;
    while(cpy>=500)
    {
        int rem=cpy/500;
        ans+=(rem*1000);
        cpy=cpy-(500*rem);
    }
    while(cpy>=5)
    {
        int rem=cpy/5;
        ans+=(rem*5);
        cpy=cpy-(5*rem);
    }
    cout<<ans<<endl;
}

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

lis=[0,0,0,0]

for i in range(n):
    si=input()
    if si=="AC":
        lis[0]+=1
    elif si=="WA":
        lis[1]+=1
    elif si=="TLE":
        lis[2]+=1
    else:
        lis[3]+=1

print("AC x ",lis[0])
print("WA x ",lis[1])
print("TLE x ",lis[2])
print("RE x ",lis[3])


Measured memory_bytes: 9208
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long s = 0;
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      s = (s ^ a[i]);
    }
    for(int i = 0; i < n; i++) {
      System.out.print(s ^ a[i]);
      System.out.print(" ");
    }
  }
}

Measured memory_bytes: 63824
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[1][0], 10)
	const c = parseInt(args[2][0], 10)
	const d = parseInt(args[3][0], 10)
	console.log(Math.min(a, b) + Math.min(c, d))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9420
#include<stdio.h>
#include<string.h>
#include<math.h>
typedef struct{
  int x;
  int y;
}cdnt;

const double PI=atan(1.0)*4;

int main(void){
  cdnt p[400],pre,save;
  short flg[400];
  int n,i,j,inner,outer,det;
  double mtheta,theta,mr,r,sum;
  while(scanf("%d",&n) && n){
    memset(flg,0,sizeof(flg));
    sum=0;
    pre.x=0;
    pre.y=1;
    for(i=0;i<n;i++) scanf("%d %d",&p[i].x,&p[i].y);
    for(i=0;i<n;i++){
      //printf("i:%d\n",i);
      mtheta=10;
      mr=4096;
      det=0;
      //printf("pre:(%d %d)\n",pre.x,pre.y);
      for(j=0;j<n;j++){
	if(!flg[j]){
	  inner=pre.x*p[j].x+pre.y*p[j].y;
	  outer=pre.y*p[j].x-pre.x*p[j].y;
	  //printf("%d in:%d,out:%d\t",j,inner,outer);
	  theta=atan2(outer,inner);
	  r=hypot(p[j].x,p[j].y);
	  //printf("%d (%d %d),theta:%f,r:%f\t",j,p[j].x,p[j].y,theta,r);
	  //if(theta<0) theta=2*PI-theta;
	  if(theta<mtheta || (theta==mtheta && mr>r)){
	    mtheta=theta;
	    mr=r;
	    det=j;
	  }
	}
	//puts("ok");
      }
      //puts("complete");
      //printf("det:%d\n",det);
      flg[det]=1;
      pre.x=p[det].x;
      pre.y=p[det].y;
      for(j=0;j<n;j++){
	p[j].x-=pre.x;
	p[j].y-=pre.y;
      }
      sum+=mr;
    }
    printf("%.1f\n",sum);
  }
  return 0;
}

Measured memory_bytes: 728
# Python3 implementation of the approach
# Function to find the number of divisors
# of all numbers in the range [1,n]
def findDivisors(n):
    # List to store the count
    # of divisors
    div = [0 for i in range(n + 1)]

    # For every number from 1 to n
    for i in range(1, n + 1):

        # Increase divisors count for
        # every number divisible by i
        for j in range(1, n + 1):
            if j * i <= n:
                div[i * j] += 1
            else:
                break

    # Print the divisors
    return div

    # Driver Code


if __name__ == "__main__":
    n = int(input())
    print(sum(findDivisors(n-1)))

# This code is contributed by
# Vivek Kumar Singh


Measured memory_bytes: 147604
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define int long long
#define INF 10000000000000000LL
typedef pair<int,int> pii;
struct edge { int to, cost;};
class Dijkstra{
private:
    vector< vector<edge> > g;
    vector<int> h;
public:
    Dijkstra(){};
    Dijkstra(int size,vector<int> in){
        g.resize(size);
        h = in;
    }

    vector<pii> dist;//cost, height

    void add(int a, int b, int c){//無向辺
        edge e1 = {b, c}, e2 = {a, c};
        g[a].push_back(e1);
        g[b].push_back(e2);//有向辺の場合はここをコメントアウトする
    }

    void calc(int s, int x){
        priority_queue<pii, vector<pii>, greater<pii> > q;
        int n = g.size();
        dist = vector<pii>(n,pii(INF,0));
        dist[s] = pii(0,x);
        q.push(pii(dist[s].first, s));

        while(!q.empty()){
            pii p = q.top();
            q.pop();
            int now = p.second;
            if(dist[now].first < p.first)continue; //更新されていたら何もしない
            int height = dist[now].second;
            int cost = dist[now].first;
            //cout << now << " " << height << " " << cost << endl;
            for(int i = 0; i < g[now].size(); i++){
                int ne = g[now][i].to, c = g[now][i].cost;
                int nc = cost + c, nh = height - c;
                if(height - c > h[ne]){
                    nc = cost + (height - h[ne]);
                    nh = h[ne];
                }else if(nh < 0){
                    if(height - nh > h[now])continue;
                    nc = cost + c - nh;
                    nh = 0;
                }
                if(dist[ne].first > nc || (dist[ne].first == nc && dist[ne].second > nh)){
                    dist[ne] = pii(nc, nh);
                    q.push(pii(dist[ne].first, ne));
                }
            }
        }
    }

};

signed main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    Dijkstra dij(n,h);
    for(int i = 0; i < m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        dij.add(a, b, c);
        dij.add(b, a, c);
    }
    dij.calc(0,x);
    int ans = dij.dist[n-1].first + (h[n-1] - dij.dist[n-1].second);
    if(ans < INF)cout << ans << endl;
    else cout << -1 << endl;
}



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

using namespace std;
const int N=100+10;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
int n,m;

struct abc
{
    int c,t;
};

abc a[N];
vector<abc>p;

bool cmp(abc a,abc b)
{
    return a.c<b.c;
}

int main()
{
    cin>>n>>m;
    bool flag=false;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].c>>a[i].t;
        if(a[i].t<=m)
        {
            p.push_back(a[i]);
            flag=true;
        }
    }
    if(flag==false)
    {
        puts("TLE");
        return 0;
    }
    else
    {
        sort(p.begin(),p.end(),cmp);
        cout<<p[0].c<<endl;
        return 0;

    }

    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    int a,b;
    cin>>a>>b;
    if(a<=5){
        cout << 0 << endl;
    }else if(6<=a && a<=12){
        cout << b/2 << endl;
    }else{
        cout <<b << endl;
    }
}


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

struct DATA{
        int id;
        double sales;
};

int main()
{

        while(1){
                int n;
                cin >> n;
                if(!n) break;
                
                list<struct DATA> sales_list;
                for(int i=0; i<n; i++){
                        int id;
                        double p, q;
                        cin >> id >> p >> q;
                        int flag = 0;
                        for(list<struct DATA>::iterator i=sales_list.begin(); i!=sales_list.end(); i++){
                                if(i->id==id){
                                        i->sales += p*q;
                                        flag = 1;
                                        break;
                                }
                        }
                        if(!flag){
                                struct DATA d;
                                d.id = id;
                                d.sales = p*q;
                                sales_list.push_back(d);
                        }
                }
                
                int flag = 0;
                for(list<struct DATA>::iterator i=sales_list.begin(); i!=sales_list.end(); i++){
                        if( i->sales >= 1000000 ){
                                cout << i->id << endl;
                                flag = 1;
                        }
                }
                if(!flag) cout << "NA" << endl;
        }

        return 0;
}        
                        

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
constexpr int MOD = 1000000007;

int main()
{
  std::ios::sync_with_stdio(false);
  long N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> A[i];
    }
    for(ll i=N-2;i>=0;i--)
    {
        sum[i] = (sum[i+1] + A[i+1]) % MOD;
        //cerr << sum[i] << endl;
    }

    ll total = 0;
    for(size_t i=0;i<N-1; i++)
    {
        total += (A[i] * sum[i]) %MOD;
        total %= MOD;
    }
    cout << total << endl;
  return 0;
}


Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long int ll;
ll dp[105][N];
ll w[105];
 ll v[105];
ll solve(ll i,ll W,ll n)
{
if(W<0)
return -100000000000000;
if(i>n)
return 0;
if(dp[i][W]!=-1)
return dp[i][W];
ll ans=0;
ans=max(v[i]+solve(i+1,W-w[i],n),ans);
ans=max(ans,solve(i+1,W,n));
return dp[i][W]=ans;
}
int main()
{
 ll n,W;
cin>>n>>W;
memset(dp,-1,sizeof(dp));
for(int i=1;i<=n;i++)
cin>>w[i]>>v[i];
cout<<solve(1,W,n);
}


Measured memory_bytes: 82304
#include <stdio.h>

int main(void){
	int n,x,i,j,k;
	int count=0;	
	
	while(1){
		scanf("%d%d",&n,&x);
		if(n==0 && x==0){
			break;
		}else{
			for(i=1;i<=n-2;i++){
				for(j=i+1;j<=n-1;j++){
					for(k=j+1;k<=n;k++){
						if(x==i+j+k){
						count++;
						}
					}
				}	
			}
			printf("%d\n",count);
			count=0;	
		}
	}
	
	return 0;
}


Measured memory_bytes: 2100
n, m = map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

for i in range(10 ** n):
    a = str(i)
    if len(a) != n:
        continue
    ans = True
    for s,c in sc:
        if int(a[s-1]) != int(c):
            ans = False
    if ans:
        print(a)
        exit()    
print('-1')

Measured memory_bytes: 3060
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int sum=0,mx=0;
	int n;cin>>n;
	FER(i,0,n){
		int k;cin>>k;
		mx=max(mx,k);
		sum+=k;
	}
	if(mx<sum-mx)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  priority_queue<int> q;
  for (int i=0; i<N; i++){
    int a;
    cin >> a;
    q.push(a);
  }

  for (int i=0; i<M; i++){
    int a = q.top();
    q.pop();
    q.push(a/2);
  }
  long long ans = 0;
  for (int i=0; i<N; i++){
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int K;
	scanf("%d", &K);
	set<string> dct;
	for (string::iterator i = s.begin(); i != s.end(); ++i){
		string word;
		word.push_back(*i);
		for (string::iterator j = i + 1; j != i + K + 1 && j - 1 != s.end(); ++j){
				dct.insert(word);
				word.push_back(*j);
			}
	}
	set<string>::iterator it = dct.begin();
	for (int i = 1; i < K; ++i) it++;
	cout << *it << endl;
	return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	vector<int> adj[60];
	int a, b;
	REP(i, M) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}


	REP(i, N) {
		cout << adj[i + 1].size() << endl;
	}


	return 0;
}

Measured memory_bytes: 256
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()

l = int(math.sqrt(N+1))
a = 1
b = N
for i in range(l, 1, -1):
    if N % i == 0:
        a = i
        b = N // i
        break
print(a + b - 2)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(b-a>x){
        printf("dangerous\n");
    }
    else if(b-a>0&&b-a<=x){
        printf("safe\n");
    }
    else if(b-a<=0){
        printf("delicious\n");
    }
    return 0;
}

Measured memory_bytes: 128
al = [list(map(int, input().split())) for i in range(3)]
al = sum(al, [])
n = int(input())
bl = [int(input()) for i in range(n)]
check = [0 for i in range(9)]
 
for b in bl:
    if b in al:
        check[al.index(b)] = 1
 
if [1,1,1] in [check[:3], check[3:6], check[6:], check[0:7:3], check[1:8:3], check[2:9:3], check[0:9:4], check[2:8:2]]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define NMAX 100005

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    cout<<s;
    if(s.back()=='s')
        cout<<'e';
    cout<<'s';
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int b[500000];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	rep(i, n) {
		b[a[i] - 1] = i + 1;
	}
	rep(i, n) {
		cout << b[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2432
s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
# 最長の文字数を求める
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1], dp[i + 1][j])

# print(dp[-1][-1]) # 最長文字数
i, j = len(s), len(t)

ans = []
while i > 0 and j > 0:
    if s[i - 1] == t[j - 1] and dp[i][j] == dp[i - 1][j - 1] + 1:
        ans.append(s[i - 1])
        i -= 1
        j -= 1
    else:
        if dp[i - 1][j] == dp[i][j]:
            i -= 1
        else:
            j -= 1
print(*reversed(ans), sep='')


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

int main() {
	int N, K, l[50] = {},ans=0;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> l[i];
	}
	sort(l, l + N);
	for (int i = N-1; i >= N-K; i--)
	{
		ans += l[i];
	}
	cout << ans;
	return 0;
}

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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, i;
	cin >> n >> i;
	cout << n - i + 1 << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



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

int main(){
  int n, x;
  cin >> n >> x;
  int m[110];
  for (int i = 0; i < (n); ++i) cin >> m[i];
  
  int ans = n;
  for (int i = 0; i < (n); ++i){
    x -= m[i];
  }
  sort(m, m+n);
  ans = ans + x/m[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math

def get_digits(n):
    return len(str(n))

n = int(input())

ans = len(str(n))
for i in range(1, round(math.sqrt(n)) + 1):
    if n % i == 0:
        f = get_digits(int(n / i))
        if ans > f:
            ans = f
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exist(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;

int main(){
    ll N, X, D; cin >> N >> X >> D;
    if(X==0 && D==0) {
        cout << 1 << endl;
        return 0;
    }
    if(D==0) {
        cout << N+1 << endl;
        return 0;
    }
    if(X==0) {
        cout << N*(N-1)/2+1 << endl;
        return 0;
    }
    if(D<0) {
        D *= -1;
        X *= -1;
    }
    map< ll, vector<pair<ll,pair<int,int> > > > event; // n*X+m*D, 開始か終了, 番号 
    REP(i,(int)N+1) {
        ll idx;
        if(X>=0) idx = (ll)i*X%D;
        else idx = ((i*(-X)+D-1)/D*D+i*X)%D; 
        event[idx].push_back(make_pair((ll)i*X+(ll)i*(i-1)/2*D, make_pair(0,i)));
        event[idx].push_back(make_pair((ll)i*X+(ll)i*(N-1)*D-(ll)i*(i-1)/2*D, make_pair(1,i)));
    }
    for(auto &p:event) sort(all(p.se));
    ll ans = 0;
    set<int> not_finished;
    for(auto &p:event) {
        ll kaisi;
        for(auto e:p.se){
            ll num = e.first;
            int flg = e.second.first;
            int idx = e.second.second;
            if(flg==0) {
                if(not_finished.empty()) kaisi = num;
                not_finished.insert(idx);
                continue;
            }
            else {
                not_finished.erase(idx);
                if(not_finished.empty()) ans += (num-kaisi)/D+1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25216
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    private static int[] points;
    private static NeighborList[] neighbors;

    private static class NeighborList {
        ArrayList<Integer> nl;
        public NeighborList() {
            nl = new ArrayList<Integer>();
        }
    }

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] mainParams = scanner.nextLine().split(" ");
        int paramN = Integer.parseInt(mainParams[0]);
        int paramQ = Integer.parseInt(mainParams[1]);
        points = new int[paramN];
        neighbors = new NeighborList[paramN + 1];

        for (int i = 0; i < paramN + 1; i++) {
            neighbors[i] = new NeighborList();
        }

        for (int i = 0; i < paramN - 1; i++) {
            String[] data = scanner.nextLine().split(" ");
            neighbors[Integer.parseInt(data[0])].nl.add(Integer.parseInt(data[1]));
            neighbors[Integer.parseInt(data[1])].nl.add(Integer.parseInt(data[0]));
        }

        for (int i = 0; i < paramQ; i++) {
            String[] data = scanner.nextLine().split(" ");
            points[Integer.parseInt(data[0]) - 1] += Integer.parseInt(data[1]);
        }

        scanner.close();

        addCountToPoint(1, 0);

        String[] outs = new String[points.length];
        for (int i = 0; i < points.length; i++) {
            outs[i] = String.valueOf(points[i]);
        }

        System.out.println(String.join(" ", outs));
    }

    private static void addCountToPoint(int pointId, int p) {
        ArrayList<Integer> nei = neighbors[pointId].nl;
        for (int i = 0; i < nei.size(); i++) {
            int neId = nei.get(i);
            if (neId == p) continue;
            points[neId - 1] += points[pointId - 1];
            addCountToPoint(neId, pointId);
        }
    }
}

Measured memory_bytes: 371528
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, K;
  cin>>H>>W>>K;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  int tmp;
  int ans = 0;
  for(int bit1=0;bit1<(1<<H);++bit1){
    for(int bit2=0;bit2<(1<<W);++bit2){
      tmp = 0;
      for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
          if(((bit1&(1<<i))!=0) || ((bit2&(1<<j))!=0)) continue;
          if(S[i][j]=='#') tmp++;
        }
      }
      if(tmp==K) ans++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
int main(){
    int n; cin >> n;
    rep(i,3){
        if(n%10==7){
            cout << "Yes" << endl;
            return 0;
        }
        n/=10;
    }
    cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define N 505
using namespace std;

int n, m, used[N];
vector<int> G[N];

int dfs(int x){
  
  if(used[x]) return 0;
  used[x]=1;
  
  int res=0;

  for(int i=0;i<G[x].size();i++) res+=dfs(G[x][i]);
  
  return res+G[x].size()-1;
}

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

  int ans=0;
  
  for(int i=0;i<n;i++)
    if(!used[i]) ans+=dfs(i)+1;
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    size_t aIndex = text.find_first_of('A');
    size_t zIndex = text.find_last_of('Z');

    cout << zIndex - aIndex + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {

    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        n: u64,
    }
    let mut m:u64 = 1;
    if n % 1000 == 0 {
        m = n / 1000;
    }else{
        m = n / 1000 + 1;
    }
    let ans = m*1000 -n;

    println!("{}", ans)
}


Measured memory_bytes: 2140
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points =
    k.times.map do
      c, a, b = gets.split
      a = a.to_i; b = b.to_i
      case c
      when 'xy'
        [a, b, 0]
      when 'yz'
        [0, a, b]
      when 'xz'
        [a, 0, b]
      end
    end
  ans = n * n * n - k * n
  cross = []
  cross_double = []
  points.combination(2).each do |a, b|
    c = a.zip(b)
    if c.any?{ |p, q| p == q }
      cp = c.map{ |p, q| [p, q].max }
      unless cp.any?{ |p| p == 0 }
        unless cross.include?(cp)
          cross << cp
          ans += 1
        else
          unless cross_double.include?(cp)
            cross_double << cp
            ans += 1
          end
        end
      end
    end
  end
  puts ans
end

Measured memory_bytes: 8832
#include <stdio.h>

int main(void) {
	int a[80];
	int b[80];
	int result[80];
	int ketaagari;
	int i,j;
	int max;
	int temp[80];
	char in;
	int overflow;
	int count,kazu;
	scanf("%d",&kazu);
	while(getchar()!='\n');
	for(count=0;count<kazu;count++) {
		for(i=0;i<80;i++) {
			a[i]=0;b[i]=0;
		}
		i=0;
		overflow=0;
		while((in=getchar())!='\n') {
			temp[i]=in-'0';
			i++;
			if(i>80) {
				overflow=1;
				while(getchar()!='\n');
				break;
			}
		}
		if(overflow==0) {
			for(j=0;j<i;j++)a[j]=temp[i-j-1];
		}
		i=0;
		while((in=getchar())!='\n') {
			temp[i]=in-'0';
			i++;
			if(i>80) {
				overflow=1;
				while(getchar()!='\n');
				break;
			}
		}
		if(overflow==0) {
			for(j=0;j<i;j++)b[j]=temp[i-j-1];

			for(i=0,ketaagari=0,max=0;i<80;i++) {
				result[i]=(a[i]+b[i]+ketaagari)%10;
				ketaagari=(a[i]+b[i]+ketaagari)/10;
				if(result[i]!=0)max=i;
			}
			if(ketaagari)overflow=1;
		}
		if(overflow==0) {
			for(i=max;i>=0;i--)printf("%d",result[i]);
			printf("\n");
		} else printf("overflow\n");
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"math"
)

func main(){
	var N int
	fmt.Scan(&N)

	acc := 0.0
	max := -100.0

	for i:=0; i<N; i++{
		var tmp float64
		fmt.Scan(&tmp)

		max = math.Max(float64(max), tmp)
		acc += tmp
	}

	acc -= max / 2.0

	fmt.Println(int(acc))
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
signed main(){
	ll a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int a,b,k;
  	cin>>a>>b>>k;
  	for (int i=0;i<k;i++) {
    	if (i%2==0) a=a/2,b+=a;
      	else b/=2,a+=b;
    }
  cout<<a<<" "<<b;
}


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

int main() {
	string s;
	while(true){
		cin >> s;
		if(s == "-") break;
		int n;
		cin >> n;
		for(int i = 0; i < n; ++i){
			int h;
			cin >> h;
			s = s.substr(h) + s.substr(0, h);
		}
		cout << s << endl;
	}
	return 0;
}

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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    vector<ll> cost = {0, 0, 0};
    cin >> cost[0] >> cost[1] >> cost[2];
    string t;
    cin >> t;
    ll total = 0;
    string hands = "spr";
    for (ll i = 0; i < k; i++) {
        string sub;
        for (ll j = i; j < t.size(); j += k) {
            sub += t[j];
        }
        vector<ll> total_sub = {0, 0, 0};
        for (char c : sub) {
            vector<ll> new_total_sub = {0, 0, 0};
            for (ll pred = 0; pred <= 2; pred++) {
                for (ll curr = 0; curr <= 2; curr++) {
                    if (pred == curr) continue;
                    ll score = total_sub[pred];
                    if (c == hands[curr]) score += cost[curr];
                    new_total_sub[curr] = max(new_total_sub[curr], score);
                }
            }
            total_sub = new_total_sub;
        }
        total += *max_element(all(total_sub));
    }
    cout << total;

    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    string s;
    cin >> s;
    int c = 0;
    int ans = 0;
    REP(i, s.size()) {
        if (s[i] == 'A' | s[i] == 'C' | s[i] == 'G' | s[i] == 'T') {
            c++;
            ans = max(c, ans);
        } else {
            c = 0;
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3652