akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans,a[20000001];
int check1(int i,int j,int x){return a[i]<=x&&a[j]<=x;}
int check2(int i,int j,int x){return a[i]>x&&a[j]>x;} 
int check(int x)
{
    for(int i=0;i<n-1;i++)
	{
        if(check2(n+i,n+i+1,x)||check2(n-i,n-i-1,x))return 0;
        if(check1(n+i,n+i+1,x)||check1(n-i,n-i-1,x))return 1;
    }
    return check1(1,1,x);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2-1;i++)scanf("%d",&a[i]);
	int l=1,r=n*2-1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))	r=mid-1,ans=mid;
		else			l=mid+1;
	}
	printf("%d",ans);return 0; 
}

Measured memory_bytes: 1024
K, N = map(int, input().split())
A = list(map(int, input().split()))

dist = [0] * N

for i in range(N - 1):
    dist[i] = A[i + 1] - A[i]

dist[N - 1] = (K - A[N - 1]) + A[0]

max_dist = max(dist)
print(K - max_dist)


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

using namespace std;

int i, n, cnt[1000]; string a;
long long ans = 0;

int main()
{
    cin >> a;
    for(i=0; i<a.size(); ++i)
    {
        ans += i - cnt[a[i]];
        ++cnt[a[i]];
    }

    cout << ans + 1 << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int A[200005];
int cnt[200005];

vector<pair<int,int> >vec;
map<int,int>mp;

int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	int i;

	for(i=0;i<N;i++){
	scanf(" %d",&A[i]);
	cnt[A[i]]++;
	}

	for(i=1;i<=N;i++){
		vec.push_back(make_pair(cnt[i],i));
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());

	for(i=0;i<K;i++){
		mp[vec[i].second]=1;
	}
	int ans=0;
	for(i=0;i<N;i++){
		if(mp[A[i]]==0){ans++;}
	}
	printf("%d\n",ans);

return 0;
}

Measured memory_bytes: 12784
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// 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(long long 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())show1d(v[__]);}
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;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n,m;
    string s;
    cin>>n>>s>>m;
    rep(i,n)if(s[i]-s[m-1])s[i]='*';
    cout<<s<<endl;
    
}


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

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		foreach (var t in tList)
		{
			if(sList.BinarySearch(t) > -1) count++;
		}
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => int.Parse(c)).ToList();
	}
}

Measured memory_bytes: 20708
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}





int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin >> n;
	int a[n];

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

	ll x = 1000;

	rep(i, 0, n - 1)
	if (a[i] < a[i + 1])
		x = x % a[i] + (x / a[i]) * a[i + 1];

	cout << x << endl;


	return 0;
}







Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	char y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll a,b;
int main(){
	a=read(),b=read();
	if((a+b)%2==1)puts("IMPOSSIBLE");
	else print((a+b)/2);
	return 0;
}

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

int main() {
  int i, K, x;
  ll N, A, B, count, min=LLONG_MAX;
  
  cin >> N;
  
  for(A=1;A*A<N+1;A++){
    if(N%A==0){
      B=N/A;
      for(count=0;B>0;count++){
        B/=10;
      }
    }
    if(min>count) min=count;
  }
  
  cout << count;
}

Measured memory_bytes: 3640
N = int(input())
word = input().strip()

Wcnt = [0 for _ in range(N+2)]
for i in range(1, N+1):
    Wcnt[i] = Wcnt[i-1]
    if word[i-1] == 'W':
        Wcnt[i] += 1

Ecnt = [0 for _ in range(N+2)]
for i in range(N, 0, -1):
    Ecnt[i] = Ecnt[i+1]
    if word[i-1] == 'E':
        Ecnt[i] += 1


print(min([Wcnt[i-1]+Ecnt[i+1] for i in range(1,N+1)]))


Measured memory_bytes: 29740
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int A, B;
	cin >> A >> B;

	int exist=(A*B & 1);
	
	cout << (exist ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
 
int n,i,j,k,x,sum = 0; char b[300][300];
 
scanf("%d",&n); 
 
for(i = 0; i < n; i++){
  scanf("%s",b[i]);
}
 
for(k = 0; k < n; k++){
x = 1;
for(i = 0; i < n && x == 1; i++){
 for(j = 0; j < n && x == 1; j++){
if(b[ (i+k) % n][ j ] != b[ (j+k) % n ][ i ])  x = 0; 
 }
}
sum += x*n;
}
 
printf("%d",sum);
return 0;
}

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

prob = {i: 0 for i in range(1, n+1)}
ac, wa = 0, 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and prob[p] >= 0:
        prob[p] += 1
    elif prob[p] >= 0:
        ac += 1
        wa += prob[p]
        prob[p] = -1

print(ac, wa)


Measured memory_bytes: 15084
#include <vector>
#include <iostream>
#include <cassert>
using namespace std;
int n, m, deg[100005];
vector<int> g[100005];

bool vis[100005];
void dfs(int u, int bad) {
    vis[u] = 1;
    for (int v : g[u]) {
        if (!vis[v] && v != bad) {
            dfs(v, bad);
        }
    }
}

int main() {
    // freopen("data.txt", "r", stdin);
    cin >> n >> m;
    if (n == 1) {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        ++deg[a];
        ++deg[b];
    }
    for (int i = 1; i <= n; ++i) {
        if (deg[i] & 1) {
            cout << "No\n";
            return 0;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (deg[i] > 4) {
            cout << "Yes\n";
            return 0;
        }
    }
    int cnt4 = 0;
    for (int i = 1; i <= n; ++i)
        if (deg[i] == 4) ++cnt4;
    if (cnt4 == 0 || cnt4 == 1) {
        cout << "No\n";
        return 0;
    }
    if (cnt4 > 2) {
        cout << "Yes\n";
        return 0;
    }
    // cnt4 == 2
    int a;
    for (int i = 1; i <= n; ++i)
        if (deg[i] == 4) a = i;
    int b = a + 1;
    if (b == n + 1) b = 1;
    assert(a != b);
    dfs(b, a);
    for (int i = 1; i <= n; ++i) {
        if (i != a && !vis[i]) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 7168
H,W,A,B=map(int,input().split())

mod=10**9+7

#繰り返し二乗法
def great_power(x, y):
    if   y == 0:
      return 1
    elif y == 1:
      return x % mod
    elif y % 2 == 0:
      return great_power(x, y//2)**2 % mod
    else:
      return great_power(x, y//2)**2 * x % mod
#階乗計算
factorial=[1]
for i in range(1,H+W):
    factorial.append(factorial[i-1]*i %mod)
#逆元計算
inverse=[0]*(H+W)
inverse[H+W-1] = great_power(factorial[H+W-1], mod-2)
for i in range(H+W-2, -1, -1):
    inverse[i] = inverse[i+1] * (i+1) % mod
#combination計算
def nCr(n,r):
  return factorial[n] * inverse[r] * inverse[n-r] % mod

ans=0
for i in range(B+1,W+1):
  ans=(ans+nCr(H-A-1+i-1,i-1) * nCr(A-1+W-i, W-i)) %mod
print(ans)

Measured memory_bytes: 20908
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL jc[300002];
LL quickmi(LL b,LL p,LL k)
{
	if(!p)return 1;
	LL ans=1,tmp=b;
	while(p)
	{
		if(p&1)ans=ans*tmp%k;
		tmp=tmp*tmp%k;
		p>>=1;
	}
	return ans%k;
}
LL C(LL n,LL m,LL k)
{
	if(n<m)return 0;
	return jc[n]*quickmi(jc[m]%k,k-2,k)%k*quickmi(jc[n-m]%k,k-2,k)%k;
}
LL Lucas(LL n,LL m,LL k)
{
	if(!m)return 1;
	return C(n%k,m%k,k)*Lucas(n/k,m/k,k)%k;
}
LL h,w,a,b,p;
LL ans;
int main()
{
	jc[0]=1;p=1e9+7;
	scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
	if(h<w)
	{
		swap(h,w);
		swap(a,b);
	}
	for(LL i=1;i<=h+w;i++)jc[i]=jc[i-1]*i%p;
	if(Lucas(b-1,b-1,p)==0)
	{
		ans=(Lucas(w-b-1+h-1,w-b-1,p)+ans)%p;
	}
	for(int i=0;i<=h-a-1;i++)
	{
		ans=(ans+Lucas(b-1+i,b-1,p)*Lucas(w-b-1+h-1-i,w-b-1,p))%p;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 998244353;
#define MAX 3100

ll dp[MAX][MAX]={};
signed main(){
  init_io();
  ll a,b,c,d,ans=0;
  cin >> a >> b >> c >> d;
  for(int i=a;i<=c;i++){
    for(int j=b;j<=d;j++){
      if(i==a&&j==b){
        dp[i][j] = 1;
      }else{
        ll add = dp[i-1][j]*j + dp[i][j-1]*i;
        ll sub = dp[i-1][j-1] * ((i-1)*(j-1))%MOD;
        add %= MOD;
        sub %= MOD;
        dp[i][j] = (add-sub+MOD)%MOD;
      }
    }
  }
  cout << dp[c][d]<<endl;
}


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

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

int X,Y,Z,K;
vector<ll> A,B,C;
ll cand[1010101];
int id[1010101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>Y>>Z>>K;
	A.resize(X);
	B.resize(Y);
	C.resize(Z);
	FOR(i,X) cin>>A[i];
	FOR(i,Y) cin>>B[i];
	FOR(i,Z) cin>>C[i];
	sort(ALL(C));
	reverse(ALL(C));
	
	priority_queue<pair<ll,int>> PQ;
	
	FOR(x,X) FOR(y,Y) {
		cand[x*Y+y]=A[x]+B[y];
		PQ.push({cand[x*Y+y]+C[0],x*Y+y});
	}
	
	while(K--) {
		ll sc=PQ.top().first;
		int cur=PQ.top().second;
		PQ.pop();
		
		cout<<sc<<endl;
		
		id[cur]++;
		if(id[cur]<Z) {
			PQ.push({cand[cur]+C[id[cur]],cur});
		}
		
	}
	
}


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


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

using namespace std;

#define int long long

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

typedef pair<int, int> PII;

//--------

vector<int> hashi[300000];
int before[300000];

// morau dp
int dp[300000];

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

    REP(i, 300000){
        before[i] = -1;
    }

    REP(i, N) {
        int a;
        cin >> a;
        if(before[a] != -1){
            // hasameruka
            if(i - before[a] != 1){
                hashi[i].push_back(before[a]);
                // cout << i << " " << before[a] << endl;
            }
        }
        before[a] = i;
    }

    dp[0] = 1;

    REP(i, N + 1) {
        if(i == 0) continue;

        dp[i] = dp[i - 1];
        for(auto a : hashi[i]){
            dp[i] += dp[a];
        }
        dp[i] %= 1000000007;
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 17664
import java.util.Scanner;

public class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    String S = sc.next();

    char[] l = new char[S.length()];
    l = S.toCharArray();

    l[K-1] = Character.toLowerCase(l[K-1]);

    String str = String.valueOf(l);

    System.out.println(str);

  }

}

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


int main(){
    ll N ,K ,Q;
    cin >> N >> K >> Q;
    vector<ll> pnt(N,K - Q);
    for(int i = 0; i < Q; i++){
        ll tmp;
        cin >> tmp;
        tmp--;
        pnt[tmp]++;
    }

    for(int i = 0; i < N; i++){
        if(pnt[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int x;
    cin>>x;
    if(x >= 30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3644
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    A, B, C, K = int(s[0]), int(s[1]), int(s[2]), int(s[3])
    score = 0
    if K <= A:
        score = K
    elif K <= A+B:
        score = A
    elif K <= A+B+C:
        score = A - (K-A-B)

    print(score)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define maxn 110
using namespace std;
int a[3][maxn], dp[3][maxn];
typedef long long LL;
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 2; ++i) {
        for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
    }
    for (int i = 1; i <= n; ++i) dp[1][i] = dp[1][i-1] + a[1][i];
    for (int i = 1; i <= 2; ++i) dp[i][1] = dp[i-1][1] + a[i][1];
    for (int j = 2; j <= n; ++j) {
        dp[2][j] = max(dp[1][j], dp[2][j-1]) + a[2][j];
    }
    printf("%d\n", dp[2][n]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
typedef long long int ll;
int main() {
	ll h, w, dis[10][10], a, ans = 0;
	cin >> h >> w;
	for (int i = 0; i < 10; i++)for (int j = 0; j < 10; j++)cin >> dis[i][j];
	for (int k = 0; k < 10; k++)for (int i = 0; i < 10; i++)for (int j = 0; j < 10; j++)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) {
		cin >> a;
		if (a != -1)ans += dis[a][1];
	}
	cout << ans << 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 num = (n/2)+(n%2);
        double par = num/(double)n;
		// 出力
		System.out.println((double)par);
	}
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    if (s.substr(i, n - i) == t.substr(0, n - i)) {
      cout << n + i << '\n';
      return 0;
    }
  }
  cout << n * 2 << '\n';
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CP
//
//  Created by Shiv Pavan Raj on 22/02/20.
//  Copyright © 2020 Shiv Pavan Raj. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)(x).size())
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define M 1000000007
#define MM 998244353
#define SZ(a) int((a).size())
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define mod 998244353
//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

using ll = long long;
using VI = vector<int>;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using VLL = vector<ll>;
using ld = long double;

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

const int MX = 5e6+10;
const int MX2 = 1e6+5;

ll INF= 4 * (ll)1e18;


int main(int argc, const char * argv[]) {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); // insert code here...
    int N,S;
    cin >> N >> S;
    int A[N+10];
    FOR(i,1,N) cin >> A[i];
    int ans =0;
    vector<vector<int> > dp(N+4,vector<int>(S+4,0));
    
    FOR(i,1,N) {
        FOR(j,1,S) {
            if (j == A[i]) dp[i][A[i]] = add(i,dp[i - 1][A[i]],mod);
            else if (A[i] < j) {
                dp[i][j] = add(dp[i][j],dp[i - 1][j - A[i]],mod);
                dp[i][j] = add(dp[i][j],dp[i - 1][j],mod);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    FOR(i,1,N) {
        ans = add(ans,mul(dp[i][S],1,mod),mod);
    }
    cout << ans << endl;
    return 0;
    
}







Measured memory_bytes: 35712
use proconio::input;
use std::collections::HashSet;
fn main() {
    input! {
        n: usize,
        m: usize
    };
    let bound = (m as f64).sqrt().floor() as usize;
    let mut divs = HashSet::new();
    for i in 1..bound+1 {
        if m % i == 0 {
            divs.insert(i);
            divs.insert(m/i);
        } else {}
    }
    let ans = divs.iter().map(|x| *x).filter(|x| m/x >= n).max().unwrap();
    println!("{}", ans);
}

Measured memory_bytes: 2652
// Problem : C - Tax Increase
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int a,b;
    cin>>a>>b;
    int cur = 1;
    while(true){
        db x = cur*0.08;
        db y = cur*0.1;
        int w = (int)x;
        int z = (int)y;
        if(w == a && z == b){
            cout<<cur<<endl;
            return;
        }
        if(w > a){
            cout<<-1<<endl;
            return;
        }
        cur++;
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    double r;
    cin >> r;

    double area, circumference;

    area = M_PI * r * r;
    circumference = M_PI * 2 * r;

    printf("%f %f", area, circumference);

    return 0;
}


Measured memory_bytes: 3196
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
km=[list(map(int, input().split())) for _ in range(m)]
p=list(map(int, input().split()))
e=0
for i in range(2 ** n):
    b=0
    d=0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            b+= 10**j # フラグが立っていたら bag に果物を詰める
    if 1==1:
        b="0"*(n-len(str(b)))+str(b)
    for j in range(m):
        c=0
        for k in range(1,km[j][0]+1):
            b=str(b)


            f=int(b[(km[j][k]-1)])

            c+=f
        if c%2!=p[j]:
            break
        else:
            d+=1
    if d==m:
        e+=1
print(e)


Measured memory_bytes: 42992
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=105;
const int maxk=1e5+5;

int n,k;
int a[maxn];
bool dp[maxk];

int main(){
	scanf("%d%d",&n,&k);
	FOR(i,0,n) scanf("%d",a+i);
	REP(i,1,k){
		FOR(j,0,n){
			if(a[j]<=i){
//				printf("%d %d\n",i,i-a[j]);
				dp[i]|=(!dp[i-a[j]]);
			}
		}
	}
//	REP(i,0,k) printf("%d ",dp[i]);
	if(dp[k]) puts("First");
	else puts("Second");
	return 0;
}


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

int main(void){
    
   int N,M,A,B;
   cin >> N >> M;
   int city[N];
   for(int i=0;i<N;i++) city[i] = 0;
   
   for(int i=0;i<M;i++){
       cin >> A >> B;
       city[A-1]++;
       city[B-1]++;
   }
   
   for(int i=0;i<N;i++) cout << city[i] << endl;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

template<class V> class SegTree0 {
  private:
    static int p2(int n, int m=1) { return m >= n ? m : p2(n, m * 2); }
    V comp(const V& l, const V& r) { return min(l, r);};
    const V def = std::numeric_limits<V>::max();
  public:
    const int n;
    vector<V> val;

    SegTree0(int _n): n(p2(_n)), val(n * 2, def) {}
    void reinit() {
      val.fill(def);
    }
    V getval(int a, int b, int k, int l, int r) {
      if (r <= a || b <= l) return def;
      if (a <= l && r <= b) return val[k];
      return comp(getval(a, b, k * 2 + 1, l, (l + r) / 2), getval(a, b, k * 2 + 2, (l + r) / 2, r));
    }
    V getval(int a, int b) {
      return getval(a, b, 0, 0, n);
    }
    void update(int i, V v) {
      i += n - 1;
      val[i] = v;
      while (i > 0) {
        i = (i - 1) / 2;
        val[i] = comp(val[i * 2 + 1], val[i * 2 + 2]);
      }
    }
};

void Main() {
  int N;
  ll x;
  scanf("%d%lld", &N, &x);
  vi A(N);
  rep(i, N) scanf("%d", &A[i]);

  SegTree0<int> seg(N);
  rep(i, N) {
    seg.update(i, A[i]);
  }

  ll ans = 1e18;
  rep(m, N) {
    ll cand = 0;
    rep(i, N) {
      if (i >= m) {
        cand += seg.getval(i-m, i+1);
      }
      else {
        cand += min(seg.getval(0, i+1), seg.getval(N-m+i, N));
      }
    }
    ans = min(ans, cand + x * m);
  }
  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


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

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

using namespace std;

struct HeavyLight {
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;
  vector<vector<int> > tree;

  HeavyLight(vector<vector<int> > t)
    :pathCount(0),n(t.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n),tree(t){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 24696
M = {}

q = int(input())


for _ in range(q):
    
    command, *list_num = input().split()

    if   command == "0":
        # insert(key, x)
        key = list_num[0]
        x = int(list_num[1])
        M[key] = x            
    elif command == "1":
        # get(key)
        key = list_num[0]
        if key in M:
            print(M[key])
        else:
            print(0)
    elif command == "2":
        # delete(key)
        key = list_num[0]
        if key in M:
            del M[key]
    else:
        raise



Measured memory_bytes: 37516
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let nextPermutation (arr: 'a array) =
    let swap i j =
        let tmp = arr.[i]
        arr.[i] <- arr.[j]
        arr.[j] <- tmp

    let mutable r = Array.length arr - 1
    while r > 0 && arr.[r - 1] >= arr.[r] do
        r <- r - 1
    if r <= 0 then
        false
    else
        let mutable l = Array.length arr - 1
        while (arr.[l] <= arr.[r - 1]) do
            l <- l - 1
        if l < r then failwith "hoge"
        swap l (r - 1)
        let mutable l = Array.length arr - 1
        while r < l do
            swap r l
            r <- r + 1
            l <- l - 1
        true

let rec permutations (arr: 'a array): seq<'a array> =
    seq {
        yield arr
        let mutable arr = arr |> Array.copy
        while nextPermutation arr do
            yield arr
            arr <- arr |> Array.copy
    }

let main() =
    let n = read int
    let P = reada int
    let Q = reada int

    let head =
        [| for i in 1 .. n -> i |]

    let perms = permutations head
    let lim = Seq.length perms
    // for pe in perms do
    //     sprintf "pe: %A" pe |> puts
    let mutable (p, q) = (0, 0)
    perms
    |> Seq.iteri (fun i pe ->
        if pe = P then p <- i + 1
        if pe = Q then q <- i + 1)

    p - q
    |> abs
    |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 24744
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	string s,shape[7];
	string tmp;
	shape[0]="1100000011";
	shape[1]="1000000010000000100000001";
	shape[2]="1111";
	shape[3]="1000000110000001";
	shape[4]="11000000011";
	shape[5]="100000001100000001";
	shape[6]="110000011";
	while(cin>>s)
	{
		for(int i=0;i<7;i++)
		{
			cin>>tmp;
			s+=tmp;
		}
		for(int i=0;i<7;i++)
		{
			if(s.find(shape[i])!=string::npos)
			{
				cout<<(char)('A'+i)<<endl;
			}
		}
	}
}

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

class Main{
  static final int INF = 2147483647;
   public static void main(String args[]){
     int[][] adj;
     int i,j,k=0,n,num,ans,e,v;
     int s=0;
     int[] g;
     Scanner scan = new Scanner(System.in);
     n = scan.nextInt();
     adj = new int[n*n][3];
     @SuppressWarnings("unchecked")
     List<Edge>[] edges = new List[n*n];
     g = new int[n];

       for(i=0;i<n;i++){
         g[i] = scan.nextInt();
         e = scan.nextInt();
         for(j=0;j<e;j++){
           v = scan.nextInt();
           num = scan.nextInt();
             adj[k][0] = i;
             adj[k][1] = v;
             adj[k][2] = num;
             k++;
         }
       }
        for(i=0;i<k;i++) {
            edges[i] = new ArrayList<Edge>();
        }

        for(i=0;i<k;i++) {
            edges[adj[i][0]].add(new Edge(adj[i][0], adj[i][1], adj[i][2]));
          //  edges[adj[i][1]].add(new Edge(adj[i][1], adj[i][0], adj[i][2]));
        }
        for(i=0;i<n;i++){
        ans = dij(n, edges,s,g[i]);
        System.out.println(g[i]+" "+ans);
      }
  }

    static int dij(int n, List<Edge>[] edges, int s, int g) {

      int[] distance = new int[n];
        Arrays.fill(distance, INF);
        distance[s] = 0;

        Queue<Edge> q = new PriorityQueue<Edge>();
        q.add(new Edge(s, s, 0));

        while (!q.isEmpty()) {
            Edge e = q.poll();
            if (distance[e.target] < e.cost) {
                continue;
            }
            for (Edge v : edges[e.target]) {
                if (distance[v.target] > distance[e.target] + v.cost) {
                    distance[v.target] = distance[e.target] + v.cost;
                    q.add(new Edge(e.target, v.target, distance[v.target]));
                }
            }
        }
        return distance[g];
    }

  static class Edge implements Comparable<Edge> {
          public int source = 0;
          public int target = 0;
          public int cost = 0;

          public Edge(int source, int target, int cost) {
              this.source = source;
              this.target = target;
              this.cost = cost;
          }

        public int compareTo(Edge o) {
              return this.cost - o.cost;
          }
      }
}



Measured memory_bytes: 42960
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int factorial(int n){
  int res=1;
  while(n>1){
    res*=n;
    n--;
  }
  return res;
}

int main(){
  int n, a=1, b=1, ansa, ansb;
  cin >> n;
  vector<int> arr(n), p(n), q(n);
  rep(i, n){
    cin >> p[i];
    arr[i]=i+1;
  }
  rep(i, n){
    cin >> q[i];
  }
  bool flag=false;
  do{
    rep(i, n){
      if(p[i]==arr[i]){
        continue;
      } else if(p[i]>arr[i]){
        a++;
        break;
      } else{
        flag=true;
        break;
      }
    }
    if(flag)break;
  } while(next_permutation(arr.begin(), arr.end()));
  flag=false;
  rep(i, n){
    arr[i]=i+1;
  }
  do{
    rep(i, n){
      if(q[i]==arr[i]){
        continue;
      } else if(q[i]>arr[i]){
        b++;
        break;
      } else{
        flag=true;
        break;
      }
    }
    if(flag)break;
  } while(next_permutation(arr.begin(), arr.end()));
  cout << abs(a-b) << endl;
  /*
  vector<bool> c(n);
  rep(i, n){
    cin >> p;
    p--;
    if(n-1==i)continue;
    int pj=0;
    rep(j, p){
      if(!c[p]){
        pj++;
      }
    }
    a+=pj*factorial(n-1-i)
  }
  rep(i, n){
    cin >> q;
  }
  */

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  long N; cin >> N;
  vector<int> V;
  int k=0; long p=1;
  
  if(N==0){cout << 0;}
  else{
    while(N!=0){
      if(N%p==0 && N%(2*p)!=0){
        V.push_back(1);
      	N = N - (int)pow(-1,k%2)*p;
      }
      else{V.push_back(0);}
      k++; p=p*2;
  	}
  }
  
  for(int i=V.size()-1; i>=0; i--){cout << V[i];}

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	
	//C


	//B
	long long int X;
	cin >> X;
	long long int a = 100;
	int counter = 0;
	while (a < X) {
		a = a + a / 100;
		counter++;
	}
	cout << counter << endl;
	return 0;	
	

	//A
	/*int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	int i;
	for (i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK\n";
			return 0;
		}
	}
	cout << "NG\n";
	return 0;*/
}

Measured memory_bytes: 3640
def c_one_quadrillion_and_one_dalmatians():
    N = int(input())

    ans = []
    current_val = N
    while current_val != 0:
        q, r = divmod(current_val, 26)
        if r == 0:
            r = 26
            q -= 1
        ans.append(r)
        current_val = q
    return ''.join(reversed([chr(ord('a') + a - 1) for a in ans]))

print(c_one_quadrillion_and_one_dalmatians())

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
void func(int n);
int flg[10] = {0};
long long sum;
string s;
int main(void){
	cin >> s;
	sum = 0;
	flg[s.size()-1] = 1;
	func(0);
	cout << sum << endl;
	return 0;
}

void func(int n){
	long long x,y,z;
	int cnt,k;
//	printf("n = %d\n",n);
	if(n == s.size() - 1){
		/*cout << "flg[i]: ";
		for(int i = 0; i < n; i++){
			if(i)	cout << " ";
			cout << flg[i];
		}
		cout << endl;*/
		x = 0;
		cnt = 1;
		k = s.size() - 1;
		for(int i = 0; i <= n; i++){
		//	printf(" i = %d flg[i] = %d\n",i,flg[i]);
			if(flg[i] == 0)	cnt++;
			else{
				y = 0;
				z = 1;
				for(int j = cnt - 1; j >= 0; j--){
					//printf(" k = %d s[k] = %c\n",k,s[k]);
					//printf(" z = %d",z);
					y += (s[k] - '0') * z;
					//printf("y = %d\n",y);
					z *= 10;
					k--;
				}
				x += y;
				//printf("cnt = %d x = %d y = %d z = %d\n",cnt,x,y,z);
				cnt = 1;
			}
		}
		sum += x;
	}
	else{
		func(n + 1);
		flg[n] = 1;
		func(n + 1);
		flg[n] = 0;
	}
}
		

Measured memory_bytes: 3616
import java.util.*;

public class Main {


    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int w[] = new int[n];

        int sums[] = new int[n-1];

        for (int i=0; i<n; i++){
            w[i] = sc.nextInt();
        }


        for (int t=0; t<n-1; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int x = 0; x < t + 1; x++) {
                s1 += w[x];
            }
            for (int y=t+1; y<n; y++) {
                s2 += w[y];
            }

            int ans = Math.abs(s1-s2);
            sums[t] = ans;

        }

        int max = sums[0];
        int min = sums[1];
        for (int z=1; z<sums.length; z++){
            int v = sums[z];
            if (v > max) max=v;
            if (v < min) min=v;
        }

        System.out.println(min);


        }

    }





Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<ll,ll>> vii;
typedef vector<vii> vvii;
typedef pair<ll,ll> ii;
 
#define pb push_back
#define mp make_pair
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define iter(i,c) for (auto i:c)
#define ss second
#define ff first
#define D(x) cout << '>' << #x << ':' << x << endl;
#define D2(x,a) cout << '>' << #x << ':' << x << " >" << #a << ':' << a <<  endl;
#define D3(x,a,b) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << endl;
#define D4(x,a,b,c) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << " >" << #c << ':' << c << endl;
#define PS(a,st,e) if (1) {if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<""<<a[noname];}cout<<"\n";}
#define PA1(a,st,e) if (1) {if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<" "<<a[noname];}cout<<'\n';}
#define PA(a,st,e) if (1) {cout<<#a<<": [";if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<", "<<a[noname];}cout<<"]\n";}
#define PSET(c) if (1) {cout<<#c<<": {";for (auto noname:c) cout<<noname<<",";cout<<"}\n";}
#define PM(c) if (1) {cout<<#c<<": {";for (auto noname:c) cout<<noname.first<<":"<<noname.second<<", ";cout<<"}\n";}


#define MAXN 100005
#define mod 1000000007

ll n, x, a[MAXN];
string s;
char c;

void solve() {
	cin>>n;
	if (n%1000==0) cout<<0<<endl;
	else cout<<(1000-n%1000)<<endl;
}
 
void aux() {
}
 
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
	}
	mountain := arr[0]
	count := 0
	for i := 0; i < n; i++ {
		if mountain <= arr[i] {
			count++
			mountain = arr[i]
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
 /////////////////////////////////////////////////////
int main(){
	int dx[8] = {0,1,1,1,0,-1,-1,-1};
	int dy[8] = {-1,-1,0,1,1,1,0,-1};
	
	int H,W;
	SCD(H);
	SCD(W);
	
	char S[54][54];
	char a[54][54];
	
	REP(i,54) { 
		REP(j,54){
			S[i][j] = '.';
		}
	}
	(void)getchar();
	FORq(i,1,H){
		FORq(j,1,W){
			scanf("%c",&S[i][j]);
		}
		(void)getchar();
	}
	
	FORq(i,1,H){
		FORq(j,1,W){
			int count = 0;
			
			REP(k,8){
				int nx = i + dx[k];
				int ny = j + dy[k];
				
				if (S[nx][ny] == '#'){
					count++;
				}
					
			}
			
			if (S[i][j] == '#'){
				a[i][j] = '#';
			}else{
				char c = '0' + count;
				a[i][j] = c;
			}
			
		}
	}
	
	FORq(i,1,H){
		FORq(j,1,W){
			printf("%c",a[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> e(n);
    vector<vector<ll> > g(n,vector<ll>(0));
    vector<ll> color(n,-1);
    color[0] = -2;
    rep0(i, n - 1){
        ll a,b;
        cin >> a >> b;
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
        e[i].first = a;
        e[i].second = b;
    }
    ll k = 0;
    rep0(i, n)chmax(k, ll(g[i].size()));
    
    queue<ll> to,from,erase;
    to.push(0);
    map<pair<ll, ll>,ll> m;
    while (!to.empty()) {
        from = to;
        to = erase;
        while (!from.empty()) {
            ll f = from.front(),c = 0;
            rep0(i, g[f].size()){
                if(color[g[f][i]] != -1)continue;
                if(color[f] == c)++c;
                color[g[f][i]] = c;
                m[make_pair(f, g[f][i])] = c;
                ++c;
                to.push(g[f][i]);
            }
            from.pop();
        }
    }
    pf(k);
    rep0(i, n - 1)pf(m[e[i]] + 1);
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll x = 0;
    for(int i=0;i<n;++i) {
        cin >> a[i];
        x ^= a[i];
    }

    for(int i=0;i<n;++i) {
        if(i) cout << " ";
        cout << (x^a[i]);
    }
}


Measured memory_bytes: 4760
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

const MOD = 10^^9 + 7;

long calc(string s) {

    long ans = 0;
    int one = 0; // 1 の個数
    for (int i = 0; i < s.length; i++) {
        if (s[i] == '1') {
            // s[i] = 0 とする
            // 範囲 [0, i) の各桁の組み合わせは (0, 1), (1, 0) の 2 通り
            // 範囲 [i + 1, $) の各桁の組み合わせは (0, 0), (0, 1), (1, 0) の 3 通り
            long a = modPow(2, one, MOD);
            long b = modPow(3, cast(int)s.length - i - 1, MOD);
            ans = (ans + (a * b)) % MOD;
            one++;
        }
    }

    // 上の for ループで i 番目を 0 にしたが、どの桁の 1 も 0 にしない場合
    ans = (ans + modPow(2, one, MOD)) % MOD;
    return ans;
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


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

typedef long long int lld;
int V = 100000;
lld MAX = numeric_limits<lld>::max();

/*
g++ -std=c++11 e-knapsack.cpp -o k
*/
int main() {
    int N, W;
    cin >> N >> W;
    int w[N+1];
    int v[N+1];

    vector<vector<lld>> m; // items to choose from ; values
    m.push_back(vector<lld>());
    for(int i = 1; i < N+1; i++) {
        cin >> w[i] >> v[i];
        m.push_back(vector<lld>(V+1));
    }

    for(int j = 0; j < V+1; j++) {
        if(j == v[1])
            m[1][j] = w[1];
        else
            m[1][j] = MAX;
    }

    for(int i = 2; i < N+1; i++) {
        for(int j = 0; j < V+1; j++) {
            if(v[i] == j) {
                if(j - v[i] > -1 && m[i-1][j-v[i]] < MAX) {
                    m[i][j] = min((lld) w[i], min(m[i-1][j], m[i-1][j-v[i]] + (lld) w[i]));
                } else {
                    m[i][j] = min((lld) w[i], m[i-1][j]);
                }
            } else {
                if(j - v[i] > -1 && m[i-1][j-v[i]] < MAX) {
                    m[i][j]  = min(m[i-1][j], m[i-1][j-v[i]] + (lld) w[i]);
                } else {
                    m[i][j] = m[i-1][j];
                }
            }
        }
    }
    
    int o;
    for(int j = 1; j < V+1; j++) {
        if(m[N][j] <= W) {
            o = j;
        }
    }
    cout << o << endl;

    return 0;
}


Measured memory_bytes: 78592