akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  vector<int> sum(M);
  REP(i, A) cin >> a[i];
  REP(i, B) cin >> b[i];
  int minA = 10000000, minB = 10000000;
  int ans = *min_element(all(a)) + *min_element(all(b));

  REP(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    sum[i] = a[x - 1] + b[y - 1] - c;
    ans = min(ans, sum[i]);
  }

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

Measured memory_bytes: 1408
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	int K; cin >> K;
	string S; cin >> S;
	if (S.size() <= K) cout << S << endl;
	else {
		string T;
		rep(i, K)T += S[i];
		cout << T + "..." << endl;
	}
}

Measured memory_bytes: 10972
<?php
while(($max = trim(fgets(STDIN))) !== '') {
    $max = intval($max);
    if ($max === 1) {
        echo 0 . "\n";
        continue;
    }
    $prime_list = array_fill(2, $max-1, true);
    for ($i=2; $i*$i <= $max; $i++) {
        if(isset($prime_list[$i])) {
            for ($j=$i*2; $j <= $max; $j+=$i) {
                unset($prime_list[$j]);
            }
        }
    }
    echo count($prime_list) . "\n";
}

Measured memory_bytes: 124400
# coding: utf-8
# Your code here!

line = input().split( )
line = [int(s) for s in line]
x = input().split( )
x = [int(a) for a in x]
y = input().split( )
y = [int(b) for b in y]
word = []
cx = max(x)
cy = min(y)
for z in range(line[2]+1, line[3] + 1):
    if z > cx and z <= cy:
        word.append(1)
    else:
        word.append(0)
if 1 in word:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
N = int(input())
M = [[i for i in input().split()] for i in range(N)]
C = 0

for i in range(N):
    if M[i][1] == 'JPY':
        C += int(M[i][0])
    elif M[i][1] == 'BTC':
        C += float(M[i][0])*380000

print(C)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//D

int main(void) {
	string s;
	int n,k;
	cin >> n >> k >> s;
	char nextChr = s[0];
	int count0 = 0, count1 = 0;
	vector<int> ruiseki0 = vector<int>();
	vector<int> ruiseki1 = vector<int>();
	ruiseki0.push_back(0);
	ruiseki1.push_back(0);
	char formerChr = nextChr;
	//if (formerChr == '0')count0++; else count1++;
	rep(0, n) {
		if(i < n)nextChr = s[i + 1];
		else nextChr = formerChr;
		if (formerChr == nextChr) {
			if (formerChr == '0')count0++; else count1++;	
		}
		else {
			//if (count0 == 0 && count1 == 0) {
				if (formerChr == '0')count0++; else count1++;
			//}
			if (formerChr == '0') {
					int last = ruiseki0[ruiseki0.size() - 1];
					ruiseki0.push_back(count0 + last);
				
				count0 = 0;
			}
			else {
					int last = ruiseki1[ruiseki1.size() - 1];
					ruiseki1.push_back(count1 + last);
				
				count1 = 0;
			}
		}
		formerChr = nextChr;
	}
	if (count0 != 0) {
			int last = ruiseki0[ruiseki0.size() - 1];
			ruiseki0.push_back(count0 + last);
		
	}
	if (count1 != 0) {
			int last = ruiseki1[ruiseki1.size() - 1];
			ruiseki1.push_back(count1 + last);
		
	}

	int ans = 0;
	if (ruiseki0.size() <= k) {
		cout << n << endl;
	}
	else {
		if (s[0] == '0') {
			for (int i = 0; i + k < ruiseki0.size(); i++) {
				int size = ruiseki1.size() - 1;
				int l, r;
				l = i == 0 ? 0 : i - 1;
				if (i + k >= ruiseki1.size())r = i + k - 1; 
				else r = i + k;
				ans = max(ans, ruiseki0[i + k] - ruiseki0[i] + ruiseki1[r] - ruiseki1[l]);
			}

		}
		else {
			for (int i = 0; i + k < ruiseki0.size(); i++) {
				int size = ruiseki1.size() - 1;
				int l, r;
				l = i;
				r = i + k + 1;
				if (r == ruiseki1.size())r = i + k;
				ans = max(ans, ruiseki0[i + k] - ruiseki0[i] + ruiseki1[r] - ruiseki1[l]);
			}
		}
		
		

		cout << ans << endl;

	}
	
}

Measured memory_bytes: 1020
k,n=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")]
# maxDist=arr[0]+min(k-arr[-1],arr[-1]) 
maxDist=arr[0]+k-arr[-1]
# maxDist=max(arr)-min(arr)
for i in range(n-1):
    maxDist=maxDist if arr[i+1]-arr[i] <=maxDist else arr[i+1]-arr[i]
print(k-maxDist)

Measured memory_bytes: 31560
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
//09062355704
int f(int a,int b,int c){
	int out=b*60+c;
	a-=b/12;
	if(a<0)a+=60;
	if(a%5)return -1;
	out+=a/5*3600;
	return out;
}
signed main(){
	int n;
	while(cin>>n,n){
		vvi in(n,vi(3));
		rep(i,n)rep(j,3)cin>>in[i][j];
		vi dp(43200,-inf);
		rep(i,n){
			vi t;
			rep(j,60){
				sort(all(in[i]));
				do{
					int a=f(in[i][0],in[i][1],in[i][2]);
					if(a+1)t.pb(a);
				}while(next_permutation(all(in[i])));
				rep(k,3)(in[i][k]+=1)%=60;
			}
//			show1d(t);
			vi ndp(43200,-inf);
			rep(j,43200)rep(k,t.size())if(i==0||dp[j]+inf){
				if(i==0){
					ndp[t[k]]=t[k];
					continue;
				}
				int mi=dp[j],ma=j;
				cmin(mi,t[k]);
				cmax(ma,t[k]);
				cmax(ndp[ma],mi);
			}
			dp=ndp;
		}
		int mi=inf,it;
		rep(i,43200)if(mi>i-dp[i]){
			mi=i-dp[i];
			it=i;
		}
		printf("%02d:%02d:%02d %02d:%02d:%02d\n",dp[it]/3600,dp[it]%3600/60,dp[it]%60,it/3600,it%3600/60,it%60);
	}
}











Measured memory_bytes: 3808
st = gets.chomp.split("")
x = st.size - 1
count = 0
e = 0

loop do
if e >= x
  puts count
  exit
else
  if st[e] != st[x]
    count += 1
    e += 1
    x -= 1
  else
    e += 1
    x -= 1
  end
end
end


Measured memory_bytes: 3836
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
YN=['Yes','No']
inf=float('inf')
input=lambda: sys.stdin.readline().rstrip()

ans=0

q=[]
for i in input():
    if i=='B':
        if q:
            q.pop()
    else:
        q+=[i]

print(''.join(q))


Measured memory_bytes: 38512
N = int(input())
robot = []
for _ in range(N):
  r = []
  x, l = map(int, input().split())
  a = x + l - 1
  b = x - l
  r += [a, b]
  robot.append(r)
Robot = sorted(robot)

robot_count = [Robot[0]]
for i in range(1, N):
  if Robot[i][1] > robot_count[-1][0]:
    robot_count.append(Robot[i])

print(len(robot_count))

Measured memory_bytes: 23004
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int n;
	scanf("%i",&n);
	char s[n+1];
	scanf("%s",&s);
	int r=0;
	for(int i=0;i<n;i++)
	{
		if(i<=n-3 && s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')	r++;
	}
	printf("%i",r);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long ans = 0, b = 0;
	char c;
	while ((c = getchar()) != EOF) {
		if (c == 'W') {
			ans += b;
		} else {
			b++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
n = int(input())    #Taro cardの枚数
card=[[0]*13 for _ in range(4)]
for i in range(n):
    t, num=map(str, input().split())
    if t=="S": card[0][int(num)-1] += 1
    elif t=="H": card[1][int(num)-1] += 1
    elif t=="C": card[2][int(num)-1] += 1
    elif t=="D": card[3][int(num)-1] += 1

for i in range(4):
    for j in range(13):
        if card[i][j]==0:
            if i == 0: print("S", j+1)
            elif i == 1:print("H", j+1)
            elif i == 2:print("C", j+1)
            elif i == 3:print("D", j+1)


Measured memory_bytes: 5616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <fstream>
#define EPS 1e-10
   
using namespace std;
typedef long long int ll;
 
const double PI=acos(-1.0);

double add(double a, double b){
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
   
struct P{
    double x, y;
    P() {}
    P(double x, double y): x(x), y(y){
    }
    P operator+ (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator- (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator* (double d){
        return P(x*d, y*d);
    }
    double dot(P p){
        return add(x*p.x, y*p.y);
    }
    double det(P p){
        return add(x*p.y, -y*p.x);
    }
    bool operator< (const P& p) const{
        if(abs(x-p.x)>EPS){
            return x<p.x;
        }else{
            return y<p.y-EPS;
        }
    }
};
   
bool on_seg(P p1, P p2, P q){
    return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
   
P intersection(P p1, P p2, P q1, P q2){
    return p1+(p2-p1)*((q2-q1).det(q1-p1) / (q2-q1).det(p2-p1));
}
  
int main()
{
	int c=1;
    while(1){
		int n;
		scanf("%d", &n);
		if(n==0) return 0;
		P p[50];
		for(int i=0; i<n; i++){
			double x, y;
			scanf("%lf %lf", &x, &y);
			p[i]=P(x, y);
		}
		double area=0;
		for(int i=0; i<n-1; i++){
			area+=(p[i].det(p[i+1]));
		}
		area+=(p[n-1].det(p[0]));
		area=(-area*0.5);
		printf("%d %.1lf\n", c, area);
		c++;
    }
    return 0;
}


Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int A, B;
	cin >> A >> B;
	int an;
	an = max(A + B, A - B);
	an = max(an, A * B);
	cout << an;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 何分割するか */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long h = scanner.nextLong(), w = scanner.nextLong();
			long[] s = new long[N];
			System.out.println(Math.min(getResult(h, w, s, N), getResult(w, h, s, N)));
		}
	}

	/**
	 * https://atcoder.jp/contests/abc062/submissions/7236184 を参考に作成<br/>
	 * h,wとw,hの組合せで計算
	 * 
	 * @param h 高さ
	 * @param w 幅
	 * @param s 結果の配列
	 * @param n 何分割するか
	 * @return 結果の最大値と最小値の差分
	 */
	private static long getResult(final long h, final long w, final long[] s, int n) {
		if (1 == n) {
			s[N - n] = h * w;
			return Arrays.stream(s).max().getAsLong() - Arrays.stream(s).min().getAsLong();
		}
		if ((0 == (h % n)) || (0 == (w % n))) {
			IntStream.range(N - n, N).forEach(i -> s[i] = h * w / n);
			return Arrays.stream(s).max().getAsLong() - Arrays.stream(s).min().getAsLong();
		} else {
			return IntStream.rangeClosed(-(n - 1), (n - 1)).mapToLong(i -> {
				s[N - n] = (h / n + i) * w;
				return Math.min(getResult(h - h / n - i, w, s, n - 1), getResult(w, h - h / n - i, s, n - 1));
			}).min().getAsLong();
		}
	}
}


Measured memory_bytes: 36804
#include<cstdio>
#include<queue>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
const int MAXN = 200005;
const int MAXM = 2000005;
struct edge{
    int to;
    edge *nxt;
}edges[MAXM], *adj[4*MAXN], *ecnt = &edges[0];
char s[MAXN];
void addedge(int u, int v) {
    edge *p = (++ecnt);
    p->to = v, p->nxt = adj[u], adj[u] = p;
}
int indeg[4*MAXN + 5];
int main() {
    int N, M;
    scanf("%d%d", &N, &M);
    scanf("%s", s+1);
    for(int i=1;i<=M;i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if( a == b ) {
            addedge(a+N, a+2*N);
            addedge(a+3*N, a);
        }
        else {
            if( s[a] == s[b] ) {
                addedge(a+N, b);
                addedge(b+N, a);
                addedge(a+3*N, b);
                addedge(b+N, a+2*N);
                addedge(b+3*N, a);
                addedge(a+N, b+2*N);
                addedge(a+3*N, b+2*N);
                addedge(b+3*N, a+2*N);
            }
            else {
                addedge(a, b+N);
                addedge(b, a+N);
                addedge(a+2*N, b+N);
                addedge(b, a+3*N);
                addedge(b+2*N, a+N);
                addedge(a+2*N, b+N);
                addedge(a+2*N, b+3*N);
                addedge(b+2*N, a+3*N);
            }
        }
    }
    for(int i=1;i<=4*N;i++) {
        for(edge *p=adj[i];p!=NULL;p=p->nxt)
            indeg[p->to]++;
    }
    queue<int>que;
    for(int i=1;i<=4*N;i++)
        if( !indeg[i] ) que.push(i);
    int cnt = 0;
    while( !que.empty() ) {
        cnt++;
        int f = que.front(); que.pop();
        for(edge *p=adj[f];p!=NULL;p=p->nxt) {
            indeg[p->to]--;
            if( !indeg[p->to] ) que.push(p->to);
        }
    }
    if( cnt == 4*N ) puts("No");
    else puts("Yes");
}

Measured memory_bytes: 36224
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], i = line[1];

            Console.WriteLine(N + 1 - i);
        }
    }
}


Measured memory_bytes: 13268
# coding: utf-8
# Your code here!
N=int(input())

lis=[]

temp=6
while temp<=N:
    lis.append(temp)
    temp*=6

temp=9
while temp<=N:
    lis.append(temp)
    temp*=9

lis.sort(reverse=True)

dp=[10**9]*(N+1)
dp[0]=0

for item in lis:
    for i in range(N+1):
        if dp[i]!=10**9:
            if i+item<=N:
                dp[i+item]=min(dp[i]+1,dp[i+item])
            
ans=10**10
for index,item in enumerate(dp):
    ans=min(ans,item+N-index)
print(ans)



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

using namespace std;

char str[10];

int main()
{
    cin>>str;
    int sum=0;
    int len=strlen(str);
    for(int i=0;i<len;i++)
    {
        sum+=str[i]-48;
    }
    if(sum==1) sum*=10;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int num[200];
	int n;
	scanf("%d", &n);
	int i;
	for(i = 0; i < n; i++)
	{
		scanf("%d", num + i);
	}
	int operation = 0;
	for(i = 0; i < n; i++)
	{
		if(num[i] % 2 == 0)
		{
			num[i] /= 2;
		}
		else
		{
			break;
		}
		if(i == n - 1)
		{
			operation++;
			i = -1;
			continue;
		}
	}
	printf("%d\n", operation);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

	int w, h, i, j;

	while(1){

		scanf("%d %d", &w, &h);
		if(w == 0 && h == 0)
			break;
		for(i = 1; i <= w; i++){

			for(j = 1; j <= h; j++){
				if((i != 1 && j !=1) &&((i != w) && (j != h)))
					printf(".");
				else 
					printf("#");
			}
			printf("\n");
		}
			printf("\n");
	}
 
 return 0;

}

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

const double EPS = 1e-8, PI = acos(-1);

inline bool eq(double a, double b) {
  return fabs(b - a) < EPS;
}

struct Point {
  double x, y;
  Point() {}
  Point(double x, double y) : x(x), y(y) {}
  Point operator+(const Point &b) const {
    return Point(x + b.x, y + b.y);
  }
  Point operator-(const Point &b) const {
    return Point(x - b.x, y - b.y);
  }
  Point operator*(const double b) const {
    return Point(x * b, y * b);
  }
  Point operator*(const Point &b) const {
    return Point(x * b.x - y * b.y, x * b.y + y * b.x);
  }
  Point operator/(const double b) const {
    return Point(x / b, y / b);
  }
  bool operator<(const Point &b) const {
    return x != b.x ? x < b.x : y < b.y;
  }
  bool operator==(const Point &b) const {
    return eq(x, b.x) && eq(y, b.y);
  }
  double norm() {
    return x * x + y * y;
  }
  double arg() {
    return atan2(x, y);
  }
  double abs() {
    return sqrt(norm());
  }
  Point rotate(double theta) {
    return Point(cos(theta) * x - sin(theta) * y, sin(theta) * x + cos(theta) * y);
  }
  Point rotate90() {
    return Point(-y, x);
  }
  friend ostream &operator<<(ostream &os, Point &p) {
    return os << "(" << p.x << "," << p.y << ")";
  }
  friend istream &operator>>(istream &is, Point &a) {
    return is >> a.x >> a.y;
  }
};

double cross(const Point &a, const Point &b) {
  return a.x * b.y - a.y * b.x;
}

double dot(const Point &a, const Point &b) {
  return a.x * b.x + a.y * b.y;
}

struct Line {
  Point a, b;

  Line(){};

  Line(Point a, Point b) : a(a), b(b){};

  friend ostream &operator<<(ostream &os, Line &p) {
    return os << "(" << p.a.x << "," << p.a.y << ") to (" << p.b.x << "," << p.b.y << ")";
  }

  friend istream &operator>>(istream &is, Line &a) {
    return is >> a.a.x >> a.a.y >> a.b.x >> a.b.y;
  }
};

Point Projection(const Line &l, const Point &p) {
  double t = dot(p - l.a, l.a - l.b) / (l.a - l.b).norm();
  return l.a + (l.a - l.b) * t;
}
Point Reflection(const Line &l, const Point &p) {
  return p + (Projection(l, p) - p) * 2.0;
}

int main() {
  double x_1, y_1, x_2, y_2, x_q, y_q;
  while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x_1, &y_1, &x_2, &y_2, &x_q, &y_q)) {
    Line l(Point(x_1, y_1), Point(x_2, y_2));
    Point r(x_q, y_q);
    Point p = Reflection(l, r);
    printf("%.10f %.10f\n", p.x, p.y);
  }
}

Measured memory_bytes: 3232
N,W = map(int,input().split())

w = []
v = []

for i in range(N):
	a,b = map(int,input().split())
	w.append(a)
	v.append(b)
V = max(v)

dp = [[float("inf")]*(N*V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
	for sum_v in range(N*V+1):
		if sum_v - v[i] >=0:
			dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])

		dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])


for sum_v in range(N*V+1):
	if dp[N][sum_v] <= W:
		ans = sum_v
print(ans)


Measured memory_bytes: 314488
s = input()
s = s.replace("dream", "D")
s = s.replace("erase", "E")
s = s.replace("Der", "D")
s = s.replace("Er", "E")

s = list(set(s))
ok = True
for i in range(len(s)):
    if s[i] not in ["D","E"]:
        ok = False
print("YES" if ok else "NO")

Measured memory_bytes: 9068
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> A(n, 0);
    vector<int> B(n, 0);
    vector<int> C(n-1, 0);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> B[i];
    }
    for(int i = 0; i < n-1; i++) {
        cin >> C[i];
    }
    int ans = accumulate(B.begin(), B.end(), 0);
    for(int i = 1; i < n; i++) {
        if (A[i] == A[i-1]+1)
            ans += C[A[i-1]-1];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int L[2*n];
    for(int i=0; i<2*n; i++){
        cin>>L[i];
    }
    sort(L,L+2*n);
    int sum=0;
    for(int i=0; i<n; i++){
        sum+=L[2*i];
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        StringBuilder strb = new StringBuilder();

        int set = 0;
        for(int k = 1 ; (M-2*k+1 >= 1) && (set < M) ; k++ ){
            strb.append(""+k+" "+(M-k+1)+"\n");
            set++;
        }
        for(int k = 1 ; (M-2*k+2 >= 1) && (set < M) ; k++ ){
            strb.append(""+(M+k)+" "+(2*M-k+2)+"\n");
            set++;
        }

        System.out.println(strb.toString());
    }
}


Measured memory_bytes: 48220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll p,q,r,s;
    ll ans=b-a+1;
    if((a%c)==0)
    {
        p=a;
    }
    else if((a%c)!=0)
    {
        p=a+c-(a%c);
    }
    if((b%c)==0)
    {
        q=b;
    }
    else if((b%c)!=0)
    {
        q=b-(b%c);
    }
  //  cout<<q<<" "<<p<<endl;
    ll temp1=(q-p)/c+1;
    if((q-p)>=0)
    {
        ans-=temp1;
    }
    if((a%d)==0)
    {
        p=a;
    }
    else if((a%d)!=0)
    {
        p=a+d-(a%d);
    }
    if((b%d)==0)
    {
        q=b;
    }
    else if((b%d)!=0)
    {
        q=b-(b%d);
    }
   // cout<<p<<" "<<q<<endl;
    ll temp2=(q-p)/d+1;
    if((q-p)>=0)
    {
        ans-=temp2;
    }
    ll g=(c*d)/(__gcd(c,d));
    if((a%g)==0)
    {
        p=a;
    }
    else if((a%g)!=0)
    {
        p=a+g-(a%g);
    }
    if((b%g)==0)
    {
        q=b;
    }
    else if((b%g)!=0)
    {
        q=b-(b%g);
    }
  //  cout<<q<<" "<<p<<endl;
    ll temp3=(q-p)/g+1;
    if((q-p)>=0)
    {
        ans+=temp3;
    }
    cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if((l[i]+l[j] > l[k]) && (l[j]+l[k] > l[i]) && (l[k]+l[i] > l[j]) && (l[i] != l[j]) && (l[j] != l[k]) && (l[k] != l[i])) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
package main

import (
	"bufio"
	. "fmt"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, m, v, w int
	Fscan(in, &n, &m)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}
	vis := make([]bool, n+1)
	ans := make([]int, n+1)
	q := []int{1}
	vis[1] = true
	c := 1
	for len(q) > 0 {
		v, q = q[0], q[1:]
		for _, w := range g[v] {
			if !vis[w] {
				vis[w] = true
				c++
				ans[w] = v
				q = append(q, w)
			}
		}
	}
	if c < n {
		Fprint(out, "No")
		return
	}
	Fprintln(out, "Yes")
	for _, v := range ans[2:] {
		Fprintln(out, v)
	}
}


Measured memory_bytes: 17476
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<double,int> P;
int main(void)
{
	int n,i,j,x1,x2,p1,nn,sum[100001];
	P pp[100001];
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%lf",&pp[i].first);
		pp[i].second=i;
	}
	pp[n].first=10.0;	pp[n].second=n;
	sort(pp,pp+n+1);
	p1=0;	x1=0;	x2=0;	
	for(i=1;i<=n;i++)	{
		if(pp[i].first!=pp[i-1].first)	{
			for(j=p1;j<i;j++)	{
				nn=pp[j].second;
//				printf("nn=%d\n",nn);
				sum[nn]=x1*3+x2;
			}
			p1=i;	x1=i;	x2=0;
		}
		else {
			x2++;
		}
	}
	for(i=0;i<n;i++)	printf("%d\n",sum[i]);
	return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> x(m + 1);
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		vector<int> a(k);
		for (int j = 0; j < k; j++)
		{
			cin >> a.at(j);
			x.at(a.at(j))++;
		}
	}
	int count = 0;
	for (int i = 0; i < m + 1; i++)
	{
		if (x.at(i) == n)
		{
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

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

int main()
{

    int N,X;
    cin >> N >> X;

    int L[110];
	REP(i,N) cin >> L[i];



	lint ans=1;
	lint d=0;

	REP(i,N){
		if(X<d+L[i]) break;
		d+=L[i];
		ans ++;
	}


	cout << ans << endl;





}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
using namespace std;
int main()
{
    int N;
    cin >> N;
    cout << (N - (N % 3)) / 3 << endl;
}

Measured memory_bytes: 3636
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var H = one[0];
  var W = one[1];
  var size = 10;
  var kyori = new Array(size);
  for(var i = 0; i < size; i++){
    kyori[i] = nextIntArray();
  }
  
  for(var k = 0; k < size; k++){
    for(var i = 0; i < size; i++){
      for(var j = 0; j < size; j++){
        if(kyori[i][j] > kyori[i][k] + kyori[k][j]){
           kyori[i][j] = kyori[i][k] + kyori[k][j];
        }
      }
    }
  }
  myerr(kyori);
  var output = 0;
  for(var i = 0; i < H; i++){
    var list = nextIntArray();
    for(var j = 0; j < W; j++){
      var index = list[j];
      if(index != -1){
         output += kyori[index][1];
      }
    }
  }
  myout(output);
}

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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

	string a, b;
	cin >> a >> b;

	int res = 0;
	for (int i = 0; i < a.size(); ++i)
		if (a[i] != b[i])
			++res;

	cout << res;	

	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    string S;
    cin >> S;
    
    int cnt0 = 0;
    int cnt1 = 0;
    rep(i,S.size()){
        if(S[i] == '0') ++cnt0;
        else ++cnt1;
    }
    
    cout << min(cnt0,cnt1)*2 << endl;
}


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

using namespace std;
typedef long long ll;
ll num[9][9];
void init(int n){
	for(int i=1;i<=n;i++){
		int x=i;
		vector<int> now;
		while(x){
			now.push_back(x%10);
			x/=10; 
		}
		int siz=(int)now.size();
		num[now[0]][now[siz-1]]++;
	}
}
int main(){
	int n;
	cin>>n;
	memset(num,0,sizeof(num));
	init(n);
	long long ans=0;
	for(int fi=1;fi<=9;fi++){
		for(int la=1;la<=9;la++){
			ans+=num[fi][la]*num[la][fi]; 
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin>>S;
bool a=false;
int s=S.size();
for(int i=0; i<s; i++){
if(i%2==0&&S.at(i)=='L'){
a=true;
break;
}
else if(i%2==1&&S.at(i)=='R'){
a=true;
break;
}
}
if(a==true){
cout<<"No"<<endl;
}
else
cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()

sum = 0
for i in range(N):
    for j in range(i+1,N):
        sum+= bisect_left(Lmat, Lmat[i]+Lmat[j]) - j - 1
        x = 1 + 1
print(sum)


Measured memory_bytes: 3316
import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)*(-1)
for i in range(102):
    ll = np.append(ll,int(i))
    
for j in p:
    ll= ll[~(ll == j)]

if len(ll) == 0:
    print(x)
    exit()
# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))


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

int main()
{
    int a, b, c, k; cin >> a >> b >> c >> k;
    int m = max({a, b, c});
    cout << (a + b + c) + (m << k) - m << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    int min = Integer.MAX_VALUE;
    int index = 0;
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      list.add(i + 1 + L - 1);
      if (min > Math.abs(list.get(i))) {
        min = Math.abs(list.get(i));
        index = i;
      }
    }
    System.out.println(list.stream().mapToInt(x -> x).sum() - list.get(index));
  }
}


Measured memory_bytes: 26836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

// a と b の最大公約数を求める
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// a と b の最小公倍数を求める
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int N;
ll t[100];

int main() {
	cin >> N;
	REP(i, N) scanf("%lld", t + i);
	
	ll ans = 1;
	REP(i, N) ans = lcm(ans, t[i]);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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




int main(){
    
    int A,B,C;
    cin >> A >> B >> C;
    
    cout << min(B/A , C) << endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, M, X, ans = INT_MAX;
    cin >> N >> M >> X;
    VL C(N);
    VVL A(N, VL(M));
    rep(i, 0, N){
        cin >> C[i];
        rep(j, 0, M) cin >> A[i][j];
    }

    rep(j, 0, M){
        ll u = 0;
        rep(i, 0, N){
            u += A[i][j];
        }
        if(u < X){
            cout << -1 << endl;
            return 0;
        }
    }

    for(ll bit = 0; bit < (1 << N); ++bit){
        vector<ll> S;
        for(ll i = 0; i < N; ++i){
            if(bit & (1 << i)){
                S.pb(i);
            }
        }
        ll flag = true;
        ll coin = 0;
        for(ll i : S){
           coin += C[i];
        }
        rep(j, 0, M){
            ll u = 0;
            for(ll i : S){
                u += A[i][j];
            }
            if(u < X) flag = false;
        }
        if(flag) ans = min(ans, coin);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define Fo(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(x)          x.begin(),x.end()
#define rall(x)         x.rbegin(),x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x,0,sizeof(x))
#define tr(it, a)       for(auto it=a.begin();it!=a.end();it++)
#define pii             pair<int,int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y)/gcd(x,y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x) {cout<<x;}
void __print(float x) {cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x) {cout <<'\''<<x<<'\'';}
void __print(const char *x) {cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f=0;cout<<'{';for(auto &i:x)cout<<(f++?",":""),__print(i);cout<<"}";}void _print(){cout<<"]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base,int exp) {int res=1;base%=mod;while(exp>0){if(exp&1)res=(res*base)%mod;base=(base*base)%mod;exp=exp>>1;}return res;}
int inv(int x) {return power(x,mod-2)%mod;}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N=1e6+6,M=N;
int i,j;

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




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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int N;
  cin>>N;
  if(N%2==1)cout<<(N/2)+1<<endl;
  else cout<<N/2<<endl;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main(){
  int n;
  cin >> n;
  for(double i = 1; i<=50000; i++){
    if(int(i*1.08) == n){
      cout<<int(i)<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*; 
import java.math.*;
import java.util.*;
public class Main {  //~IQEmperor~ 
	public static void main(String[] args) {
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int R = 0;
		int ans = 0;
		String S = I.next();
		for (int i = 0; i < 3; i++) {
			if (S.charAt(i)=='R') {
				R++;
				ans=R;
			}else {
				R=0;
			}
		}
		O.pln(ans);
		//O.pln("ZERO");
	}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	string s, t;
	cin >> s >> t;


	bool key = false;

	for (int i = s.size() -t.size(); i >= 0; i--) {
		rep(j, 0, t.size()) {
			if (s[i + j] != t[j] && s[i + j] != '?') {
				break;
			}
			if (j == t.size() - 1) {
				key = true;
				rep(k, 0, t.size()) {
					s[i + k] = t[k];
				}
				break;
			}
		}
		if (key)break;
	}

	if (!key) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	rep(i, 0, s.size()) {
		if (s[i] == '?') {
			cout << 'a';
		}
		else {
			cout << s[i];
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#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,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  A--;B--;C--;D--;
  string s;
  cin >> s;
  bool f=true;
  for(int i=min(A,B);i<max(C,D);i++){
    if(s[i]=='#' and s[i+1]=='#') f=false;
  }
  if(f==false){
    cout << "No" << endl;
    return 0;
  }
  if(A<B and D<C){
    f=false;
    for(int i=B;i<=D;i++){
      if(s[i-1]=='.' and s[i]=='.' and s[i+1]=='.') f=true;
    }
  }
  if(B<A and C<D){
    f=false;
    for(int i=A;i<=C;i++){
      if(s[i-1]=='.' and s[i]=='.' and s[i+1]=='.') f=true;
    }
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else{
        ll temp = (k-a);
        if(temp<=b) cout<<a;
        else{
            temp-= b;
            cout<<(a-temp);
        }
    }
}




Measured memory_bytes: 3632