akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 
 
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
ordered_set<ll> ors;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ld PI=3.14159265359;
 
ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}
 
ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}
 
ll lp[100001];
vector<ll> pr;
 
void prime()
{
    repf(i,1,100001) lp[i]=i;
    repf(i,2,100001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<100001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
    repf(i,2,100001) if(lp[i]==i) pr.pb(i);
}

const ll MX=200001;

vector<ll> v[MX];
ll depth[MX];
ll D[MX][22];
 
void dfs(ll x, ll p, ll h=0) {
    D[x][0]=p;
    depth[x]=h;
    repf(i,1,22)
    {
        if(D[x][i-1]!=-1 && D[D[x][i-1]][i-1]!=-1)
        {
            D[x][i]=D[D[x][i-1]][i-1];
        }
    }
    for(auto i:v[x]) {
        if(i==p) continue;
        dfs(i,x,h+1);
    }
}

ll walk(ll x, ll k)
{
    repf(i,0,22)
    {
        if((1<<i)&k)
        {
            x=D[x][i];
        }
    }
    return x;
}

ll lca(ll x, ll y)
{
    if(depth[x]>depth[y]) x=walk(x,depth[x]-depth[y]);
    if(depth[y]>depth[x]) y=walk(y,depth[y]-depth[x]);
    if(x==y) return x;
    repb(i,21,0)
    {
        if(D[x][i]!=D[y][i])
        {
            x=D[x][i];
            y=D[y][i];   
        }
    }
    return D[x][0];
}

void init() {

}

void solve(ll tt) {
    ll n;
    cin>>n;
    ll d[n][2];
    repf(i,0,n) cin>>d[i][0]>>d[i][1];
    repf(i,0,n) {
        if(i+3>n) break;
        bool ok=true;
        repf(j,i,i+3) if(d[j][0]!=d[j][1]) {
            ok=false;
            break;
        }
        if(ok) {
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
} 
 
 
int main()
{
    // IOS;
    // init();
    ll t=1;
    // cin>>t;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 8328
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    while(a){
        a/=b;
        ans++;
    }
    cout<<ans;
}

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

int main(){
    ll N, Y;
    cin >> N >> Y;
    rep(x, 0, N+1){
        rep(y, 0, N-x+1){
            ll z = N - x - y;
            if(10000*x + 5000*y + 1000*z == Y){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

lstL = list()
lstR = list()

for i in range(0, M):
    L, R = map(int, input().split())
    lstL.append(L)
    lstR.append(R)

minVal = max(lstL)
maxVal = min(lstR)

res = (maxVal - minVal + 1) if minVal <= maxVal else 0

print(res)

Measured memory_bytes: 11028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

   
   int a,b;
   cn a>>b;

   string aa(b,'0'+a),bb(a,'0'+b);
   ct min(aa,bb);nl;







    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;
const ll INF = 1e12;

int main() {
    int N, W;
    cin >> N >> W;
    ll w[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    ll dp[N + 1][100010];
    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < 100010; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 100010; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j - v[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 100010; i++) {
        if (dp[N][i] <= W)
            ans = i;
    }
    OUT(ans);
}

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

using namespace std;

const int MAX_N = 100, INDEX = 1;

int n, a[MAX_N + INDEX], cnt[9];
int ansMin = 0, ansMax = 0;

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i <= 8; i++) {
        cnt[i] = 0;
    }

    for (int i = 1; i <= n; i++) {
        cnt[min(8, a[i] / 400)]++;
    }

    for (int i = 0; i < 8; i++) {
        if (cnt[i] > 0) {
            ansMin++;
        }
    }

    ansMax = ansMin + cnt[8];

    ansMin = max(1, ansMin);

    cout << ansMin << ' ' << ansMax << endl;

    return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  
  bool judge=true;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=T.at(i)) {
      judge=false;
    }
  }
  
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


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


namespace ABC162
{
    class B
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            long sum = 0;
            for (int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int k = 1; k <= K; k++)
                    {
                        sum += CalcGCD(CalcGCD(i, j), k);
                    }
                }
            }
            Console.WriteLine(sum);
        }
        public static long CalcGCD(long a, long b)
        {
            if (b == 0) { return a; }
            return CalcGCD(b, a % b);
        }

        public static long CalcLCM(long a, long b)
        {
            return a * b / CalcGCD(a, b);
        }
    }

}



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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String s = sc.next();

        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                count++;
            }
        }
        out.printf("%d\n", count);
        out.flush();
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
 
void DICE(char x, int *dice1, int *dice2, int *dice3, int *dice4, int *dice5, int *dice6){
    int tmp1, tmp2, tmp3, tmp4;
    if(x=='S'){
        tmp1=*dice1;
        tmp2=*dice2;
        tmp3=*dice5;
        tmp4=*dice6;
        *dice1=tmp3;
        *dice2=tmp1;
        *dice5=tmp4;
        *dice6=tmp2;
    }
        else if(x=='W'){
        tmp1=*dice1;
        tmp2=*dice3;
        tmp3=*dice4;
        tmp4=*dice6;
        *dice1=tmp2;
        *dice3=tmp4;
        *dice4=tmp1;
        *dice6=tmp3;
    }
    else if(x=='N'){
        tmp1=*dice1;
        tmp2=*dice2;
        tmp3=*dice5;
        tmp4=*dice6;
        *dice1=tmp2;
        *dice2=tmp4;
        *dice5=tmp1;
        *dice6=tmp3;
    }
    else if(x=='E'){
        tmp1=*dice1;
        tmp2=*dice3;
        tmp3=*dice4;
        tmp4=*dice6;
        *dice1=tmp3;
        *dice3=tmp1;
        *dice4=tmp4;
        *dice6=tmp2;
    }
}
 
 
int main(void){
     
    int dice1, dice2, dice3, dice4, dice5, dice6, i;
    int d1, d2, d3, d4, d5, d6;
     
    scanf("%d %d %d %d %d %d\n%d %d %d %d %d %d", &dice1, &dice2, &dice3, &dice4, &dice5, &dice6, &d1, &d2, &d3, &d4, &d5, &d6);
     
    if(d2!=dice2){
        for(i=1; i<=6; i++){
                DICE('N', &dice1, &dice2, &dice3, &dice4, &dice5, &dice6);
                if(d2==dice2) break;
        }
        if(d2!=dice2){
            DICE('E', &dice1, &dice2, &dice3, &dice4, &dice5, &dice6);
            for(i=1; i<=6; i++){
                DICE('N', &dice1, &dice2, &dice3, &dice4, &dice5, &dice6);
                if(d2==dice2) break;
            }
        }
    }
         
    if(d1!=dice1){
        for(i=1; i<=6; i++){
            DICE('E', &dice1, &dice2, &dice3, &dice4, &dice5, &dice6);
            if(d1==dice1) break;
        }
    }
         
    if(d3==dice3 && d4==dice4 && d5==dice5 && d6==dice6) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9 + 7
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    string N;

    cin >> N;
    int cnt = 0;
    for (int i = 0; i < N.length(); i++)
    {
        string a = N.substr(i, 1);
        cnt += atoi(a.c_str());
    }
    if (cnt % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
// Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<Int> h(n), dp(100010, 1e9);
    for (Int i = 0; i < n; i++) cin >> h[i];
    dp[0] = 0;
    for (Int i = 0; i < n - 1; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        if (i < n - 2) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
        }
    }
    dump(dp[n - 1]);
    return 0;  
} 

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long a, b, c = 0;
    char ch;
    cin >> a >> b >> ch >> c;
    cout << a*(b*100+c)/100 << endl;
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

ll point(ll a){
  if(a == 1) return 300000;
  if(a == 2) return 200000;
  if(a == 3) return 100000;
  return 0;
}

int main(){
  ll x,y;
  cin >> x >> y;
  
  cout << point(x) + point(y) + (x*y==1?400000:0) << endl;
}
  
  

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0;i<(n);i++)

int cmpint(const void *a,const void *b){
  return *(int *)b-*(int *)a;
}
int main(){
  int n,k;
  int x[100];
  scanf("%d%d",&n,&k);
  rep(i,n){
    scanf("%d",&x[i]);
  }
  int cnt=0;
  rep(i,n){
    if((x[i])<=k-x[i]){
      cnt+=2*x[i];
    }else{
      cnt+=2*(k-x[i]);
    }
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
ll dp[110][100010];
 
int main() {

    ll n, w;
    cin >> n >> w;

    vector<ll> wm(n);
    vector<ll> vm(n);

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

    
    //ll dp[n][w];

    //AA(dp[n - 1][0]);

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            if (j - wm[i - 1] < 0) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wm[i - 1]] + vm[i - 1]);
                //cout << i << "  " << j << "  " << dp[i][j] << endl;
            }
        }
    }

    AA(dp[n][w]);
}

Measured memory_bytes: 79360
#include<cstdio>
#include<cstdlib>
#define min(a,b) (a<b?a:b)
const int clz=998244353;
#define mod clz
long long matm(long long val,long long k){
	long long ret=1;
	while(k){
		if(k&1) ret=ret*val%mod;
		k>>=1; val=val*val%mod;
	}
	return ret;
}
int n,k;
long long pw[100005],pu[100005],inv[100005];
inline long long C(int n,int m){if(m<0||m>n) return 0;return (pu[n]*inv[m]%mod)*inv[n-m]%mod;}
long long getans(int val){
	if(val&1){
		long long ans=0;
		int gro=min(k-val/2,val/2);
		int p=k-gro*2;
		//if(p==0) exit(0);
		for(int i=(p==0)?1:0;i<=gro;i++) {ans+=(C(n+p-1,i+p-1)*pw[i]%mod)*C(gro,i)%mod; ans%=mod;}
		return ans;
	}
	else{
		long long ans=0;
		int gro=min(k-val/2+1,val/2);
		int p=k-gro*2+1;
		//if(p==0) exit(0);
		for(int i=(p==0)?1:0;i<gro;i++) {ans+=(C(n+p-1,i+p-1)*pw[i]%mod)*C(gro-1,i)%mod; ans%=mod;}
		for(int i=(p==0)?1:0;i<gro;i++) {ans+=(C(n+p-2,i+p-1)*pw[i]%mod)*C(gro-1,i)%mod; ans%=mod;}
		return ans;
	}
}
int main(){
	pu[0]=pw[0]=1;
	for(int i=1;i<=100000;i++) pu[i]=pu[i-1]*i%mod;
	for(int i=1;i<=100000;i++) pw[i]=pw[i-1]*2%mod;
	inv[100000]=matm(pu[100000],mod-2);
	for(int i=99999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	scanf("%d%d",&k,&n);
	for(int i=2;i<=2*k;i++) printf("%lld\n",getans(i));
	return 0;
}

Measured memory_bytes: 2560
function Main(input) {
  input = input.trim();
  var N = input;

  var Ns = N.split("");

  var saigo = Ns[Ns.length - 1];
  if (saigo == "3") {
    console.log("bon");
    return;
  } else if (saigo == "0" || saigo == "1" || saigo == "6" || saigo == "8") {
    console.log("pon");
    return;
  } else {
    console.log("hon");
    return;
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29628
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  vec A(N); rep(i, N) cin >> A[i];

  rep(i, N) {
    if(A[i]%2 == 1) continue;
    if(A[i]%3!=0 && A[i]%5!=0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;

  return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split('');
        var counter=[0,0,0,0,0];
        for(var i=0;i<input.length;i++){
            for(var j=0;j<5;j++){
               if(input[i]===''+j)counter[j]++;
            }
        }
        for(var k=0;k<5;k++){
            if(counter[k]>2){
              console.log('NO');
              return 0;
            }
        }
        console.log('YES');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

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

  cout<<(s==t.substr(0,s.size())?"Yes":"No")<<newl;
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int N;
string S[20];
int W[20];int L[20];
bool F[20];
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)return 0;
		for(int i=0;i<N;i++)F[i]=true;
		for(int i=0;i<N;i++){
			W[i]=0;L[i]=0;
		}
		for(int i=0;i<N;i++){
			cin >> S[i];
			for(int j=0;j<N-1;j++){
				int n;
				scanf("%d",&n);
				if(n==0)W[i]++;
				else if(n==1)L[i]++;
			}
		}
		for(int i=0;i<N;i++){
			int maxw=-1;int maxwi;bool FF=true;
			for(int j=0;j<N;j++){
				if(!F[j])continue;
				if(maxw<W[j]){
					
					maxw=W[j];maxwi=j;FF=true;
				}
				else if(maxw==W[j]){
					FF=false;
				}
			}
			if(FF){
				cout << S[maxwi] << "\n";
				F[maxwi]=false;
			}
			else{
				int minl=20;int minli;
				for(int j=0;j<N;j++){
					if(!F[j])continue;
					if(maxw!=W[j])continue;
					if(minl>L[j]){
						minl=L[j];
						minli=j;
					}
				}
				cout << S[minli] << "\n";
				F[minli]=false;
			}
		}
		
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

bool check(int l1, int l2, int l3)
{
    if( l1 == l2 || l2 == l3 || l3 == l1 ) return false;
    return ( l1 < l2 + l3 && l2 < l3 + l1 && l3 < l1 + l2);
}

int main()
{
    int count = 0;
    int n; cin >> n;
    int *l = new int[n];
    rep(i, n) cin >> l[i];
    int ans = 0;

    for(int a = 0; a < n - 2; a++ )
        for(int b = a + 1; b < n - 1; b++)
            for(int c = b + 1; c < n; c++)
            {
                if( check(l[a], l[b], l[c]) ) ans++;
            }

    cout << ans;
    delete l;
    return 0;    
}

Measured memory_bytes: 3628
//written by newbiechd
#include <cstdio>
#include <cctype>
#include <algorithm>
#define R register
#define I inline
#define B 1000000
#define L long long
using namespace std;
const int N = 200003;
char buf[B], *p1, *p2;
I char gc() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, B, stdin), p1 == p2) ? EOF : *p1++; }
I int rd() {
    R int f = 0;
    R char c = gc();
    while (c < 48 || c > 57)
        c = gc();
    while (c > 47 && c < 58)
        f = f * 10 + (c ^ 48), c = gc();
    return f;
}
int h[N], w[N], siz[N], vis[N], f[N], n, E, T, all, tmp, rt, u;
L dis[N], clos;
struct edge {
    int s, g, w;
    edge() {}
    edge(int s, int g, int w) : s(s), g(g), w(w) {}
}e[N << 1];
struct tree {
    int x, y;
    L w;
    I int operator < (tree t) { return w < t.w; }
}t[N << 5];
I int max(int x, int y) { return x > y ? x : y; }
I void add(int x, int y, int z) { e[++E] = edge(h[x], y, z), h[x] = E; }
I int find(int x) {
    R int r = x, y;
    while (f[r] ^ r)
        r = f[r];
    while (x ^ r)
        y = f[x], f[x] = r, x = y;
    return r;
}
void getsize(int x, int f) {
    siz[x] = 1;
    for (R int i = h[x], y; i; i = e[i].s)
        if (!vis[y = e[i].g] && y ^ f)
            getsize(y, x), siz[x] += siz[y];
}
void getroot(int x, int f) {
    R int m = 0, i, y;
    for (i = h[x]; i; i = e[i].s)
        if (!vis[y = e[i].g] && y ^ f)
            getroot(y, x), m = max(m, siz[y]);
    m = max(m, all - siz[x]);
    if (m < tmp)
        tmp = m, rt = x;
}
void dfs1(int x, int f) {
    if (dis[x] + w[x] < clos)
        u = x, clos = dis[x] + w[x];
    for (R int i = h[x], y; i; i = e[i].s)
        if (!vis[y = e[i].g] && y ^ f)
            dis[y] = dis[x] + e[i].w, dfs1(y, x);
}
void dfs2(int x, int f) {
    t[++T] = (tree){x, u, clos + w[x] + dis[x]};
    for (R int i = h[x], y; i; i = e[i].s)
        if (!vis[y = e[i].g] && y ^ f)
            dfs2(y, x);
}
void dac(int x) {
    R int i, y;
    getsize(x, 0), tmp = n, all = siz[x], getroot(x, 0),
        vis[rt] = 1, u = rt, dis[rt] = 0, clos = w[rt];
    for (i = h[rt]; i; i = e[i].s)
        if (!vis[y = e[i].g])
            dis[y] = e[i].w, dfs1(y, rt);
    dfs2(rt, 0);
    for (i = h[rt]; i; i = e[i].s)
        if (!vis[e[i].g])
            dac(e[i].g);
}
int main() {
    R int i, x, y, z;
    L ans = 0;
    n = rd();
    for (i = 1; i <= n; ++i)
        w[i] = rd(), f[i] = i;
    for (i = 1; i < n; ++i)
        x = rd(), y = rd(), z = rd(), add(x, y, z), add(y, x, z);
    dac(1), sort(t + 1, t + T + 1);
    for (i = 1; i <= T; ++i) {
        x = find(t[i].x), y = find(t[i].y);
        if (x ^ y)
            f[x] = y, ans += t[i].w;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 78720
#include<iostream>
#include<cstdio>
#define eps 4000
using namespace std;
int H,W,h,w,map[505][505];
long long sum;
int main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
	for(int i=h;i<=H;i+=h)
		for(int j=w;j<=W;j+=w)
			map[i][j]=-eps*(h*w-1)-1,sum+=map[i][j];
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
		if(i%h||j%w)
		map[i][j]=eps,sum+=map[i][j];
	if(sum<=0)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		printf("%d ",map[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, C;
    long long K;
    cin >> A >> B >> C;
    cin >> K;
    int ans;
    if (K % 2 != 0)
    {
        ans = B - A;
    }else
    {
        ans = A - B;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> A(N + 1);
  for (auto&e : A) cin >> e;
  if (N == 0 && A[0] != 1) {
  		cout << -1 << endl;
  		return 0;
 	}
  vector<long long> csum(N + 1, 0);
  partial_sum(crbegin(A), crend(A), rbegin(csum));
  vector<long long> nodes(N + 1);
  nodes[0] = 1;
  for (int i = 0; i <= N; ++i) {
  	if (nodes[i] < A[i]) {
  		cout << -1 << endl;
  		return 0;
  	}
  	nodes[i] -= A[i];
  	if (i < N) nodes[i + 1] = min(nodes[i] * 2ll, csum[i + 1]);
  }
  long long ans = accumulate(cbegin(nodes), cend(nodes), 0ll) + csum[0];
  cout << ans << endl;
}


Measured memory_bytes: 5560
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {
	
	int n;
	cin >> n;
	if (n >= 65 && n <= 90) {
		cout << '1' << endl;
	}
	else if (n >= 97 && n <= 122) {
		cout << '2' << endl;
	}
	else { cout << '0' << endl; }



	return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
    int n;
    cin>>n;
    int mx=0;
    long long ans=0;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++) {
        if(a[i]<mx) {
            ans+=abs(a[i]-mx);
        } else {
            mx=max(mx,a[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4364
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long price = 90000000000;
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var b = inputLongArray[1];
            var c = inputLongArray[2];
            var x = inputLongArray[3];
            var y = inputLongArray[4];
            for (var i = 0; i <= (x >= y ? x : y); i++)
            {
                var priceAB = i * 2 * c;
                var priceA = i >= x ? 0 : (x - i) * a;
                var priceB= i >= y ? 0 : (y - i) * b;
                if (price > priceA + priceB + priceAB) price = priceA + priceB + priceAB;
            }
            Console.WriteLine(price);
        }
    }
}

Measured memory_bytes: 27904
import sys
from decimal import Decimal

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N1 = list(readline().split())
    N = int(N1[0]); M = Decimal(N1[1])
    ans = int(N*M)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10064
N,A,B = [int(i) for i in input().split()]
all_sum = 0
for i in range(1,N+1) :
    degit_sum = sum([int(i) for i in list(str(i))])
    if (A <= degit_sum and degit_sum <= B ) :
        all_sum += i

print(all_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

ll n;
ll mo(ll p){
    return (p+n)%n;
}

int main(){fastio
    cin>>n;
    ll a[n],b[n];
    rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1)cin>>b[i];
    ll ans=0;
    queue<ll>q;
    rep(i,0,n-1){
        if(b[mo(i-1)]+b[mo(i+1)]<=(b[mo(i)]-a[mo(i)])){
            q.push(i);
        }
    }
    while(!q.empty()){
        ll t=q.front();q.pop();
        ll ad=(b[mo(t)]-a[mo(t)])/(b[mo(t-1)]+b[mo(t+1)]);
        if(ad==0)continue;
        b[mo(t)]-=ad*(b[mo(t-1)]+b[mo(t+1)]);
        ans+=ad;
        for(ll i=t-1;i<=t+1;i+=2){
            if(b[mo(i-1)]+b[mo(i+1)]<=(b[mo(i)]-a[mo(i)])){
                q.push(mo(i));
            }
        }
    }
    rep(i,0,n-1){
        if(a[i]!=b[i]){
            cout<<-1<<endl;return 0;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 4224
def gcd(x,y):
    if x%y!=0:
        return gcd(y,x%y)
    else:
        return y
def GCD(x,y,z):
    return gcd(gcd(x,y),z)
ans=0
K=int(input())
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans+=GCD(a,b,c)
print(ans)


Measured memory_bytes: 81068
n, k = map(int, input().split())
r = [0 for _ in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        r[j-1] += 1
result = 0
for i in r:
    if i==0:
        result += 1
print(result)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL fac[55];
LL C[55][55];
int n;
void init()
{
    int i, j;
    C[0][0]=1;
    for(i=1; i<=n; i++)
    {
        C[i][0]=1;
        for(j=1; j<=i; j++)
        {
            C[i][j]=C[i-1][j-1]+C[i-1][j];
        }
    }
    return;
}

int main()
{
    int p;
    cin>>n>>p;
    init();
    int i;
    LL odd=0, even=0, x;
    for(i=0; i<n; i++)
    {
        scanf("%lld", &x);
        odd+=x&1;
        even+=(x%2==0);
    }
 //   cout<<odd<<" "<<even<<endl;
    LL ans=0;
    even=1LL<<(even);
    if(p==0)
    {
       ans+=even;
       for(i=2; i<=odd; i+=2)
       {
            ans+=even*C[odd][i];
   //         printf("%lld\n", C[odd][i]);
       } 
    }
    else 
    {
        for(i=1; i<=odd; i+=2)
        {
            ans+=even*C[odd][i];
        }
    }
    cout<<ans<<endl;
    
}


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

string a, b, c;

int main() {
    cin >> a >> b >> c;

    cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K; cin >> K;
    ll ans = K;
    string S = to_string(K);
    int n = S.length();
    rep(i, S.length()) {
        int times = 1;
        int cnt = 1;
        rep(j, n - 2) cnt *= 2;
        rep(j, S.length() - 1) {
            int num = S[i] - '0';
            ans += (ll)(num) * cnt * times;
            cnt /= 2;
            if(n - 2 - i >= j) times *= 10;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
 
#define MAX 31
 
int main(){
  int dp[MAX] = {1,1,2};
 
  for(int i = 3 ; i < MAX ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
 
  int n;
  while(scanf("%d" ,&n),n){
    printf("%d\n" ,dp[n]/3650+1);
  }
 
  return 0;
}

Measured memory_bytes: 2748
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n, l;
    while (cin >> n >> l, n || l)
    {
        vector<int> d(n);
        vector<vector<int>> pos(l + 10);
        for (int i = 0; i < n; i++)
        {
            string s;
            cin >> s;
            if (s == "L")
                d[i] = 0;
            else
                d[i] = 1;
            int p;
            cin >> p;
            pos[p].push_back(i);
        }
        bool update = true;
        int res = 0, last;
        while (true)
        {
            update = false;
            int left = 0, right = 0;
            vector<vector<int>> tmp = pos;
            for (int i = 1; i <= l - 1; i++)
            {
                pos[i].clear();
            }
            for (int i = 1; i <= l - 1; i++)
            {
                for (int j = 0; j < (int)tmp[i].size(); j++)
                {
                    update = true;
                    int idx = tmp[i][j];
                    if (d[idx])
                    {
                        // R
                        pos[i + 1].push_back(idx);
                        if (i + 1 == l)
                            right = idx + 1;
                    }
                    else
                    {
                        pos[i - 1].push_back(idx);
                        if (i - 1 == 0)
                            left = idx + 1;
                    }
                }
            }
            if(left){
                last = left;
            }
            else if(right){
                last = right;
            }
            for (int i = 1; i <= l - 1; i++)
            {
                if (pos[i].size() < 2)
                    continue;
                int st = pos[i][0], gt = pos[i][1];
                d[st] = 1 - d[st];
                d[gt] = 1 - d[gt];
            }
            if (!update)
                break;
            res++;
        }
        cout << res << " " << last << endl;
    }
}



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

using namespace std;

const int N = 10003;

int h, w, n, a[N], ans[103][103];

int main() {
  #ifdef GG
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
  #endif
  scanf("%d%d", &h, &w);
  scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int r = 1, c = 1;
  for (int i = 1; i <= n; ++i) {
    while (a[i]--) {
      ans[r][c] = i;
      if (r & 1) c++; else c--;
      if (c == w + 1 || c == 0) {
        if (c == w + 1) c = w; else c = 1;
        ++r;
      }
    }
  }
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) printf("%d ", ans[i][j]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=505;
char a[N][N];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n)forn(j,n)cin>>a[i][j];
    int ans=0;
    int ex=-1,any=0;
    forn(i,n){
        int ok=1;
        forn(j,n){
            ok&=a[i][j]=='#';
            any|=a[i][j]=='#';
        }
        if(ok)ex=i;
    }
    if(!any){
        cout<<"-1\n";
        return 0;
    }
    if(ex==-1){
        int mn=N;
        forn(f,n){
            int bad=0,ok=0;
            forn(j,n){
                if(a[f][j]=='.')bad++;
                if(a[j][f]=='#')ok=1;
            }
            if(ok&&bad<mn)mn=bad;
            if(!ok&&bad+1<mn)mn=bad+1;
        }
        ans+=mn;
    }
    int cnt=0;
    forn(j,n){
        int ok=1;
        forn(i,n)ok&=a[i][j]=='#';
        if(!ok)cnt++;
    }
    ans+=cnt;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3884
N = int(input())
strlist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


ans = [['a']]
for i in range(1, N):
  ans.append([])
  for s in ans[i-1]:
    n = len(set(s))
    for j in range(n+1):
      ans[i].append(s+strlist[j])

# ans.sort()
print(*ans[-1], sep='\n')

Measured memory_bytes: 16340
from collections import defaultdict

N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]

x=defaultdict(int)
for i in s:
  x[i]+=1
  
for i in t:
  x[i]-=1
  
ans=0
for y in x.keys():
  ans=max(ans, x[y])
  
print(ans)

Measured memory_bytes: 9460
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   int a,b,c;
   cin>>a>>b>>c;
   int cnt=0;
   for(int i=a;i<=b; ++i){
   	if(i%c == 0) cnt++;
   }
   cout<<cnt;
   


}

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



Measured memory_bytes: 3536
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	fmt.Println((n - 1) * (m - 1))
}


Measured memory_bytes: 1776
a,b,c = map(int,input().split())

if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    for i in range(1,10**5):
        a2 = (b+c)//2
        b2 = (a+c)//2
        c2 = (a+b)//2
        a = a2
        b = b2
        c = c2
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            res = 0
        else:
            res = i
            print(res)
            break
        if i == 10**5-1:
            print(-1)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LETSGO     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    int n;
    cin >> n;
    cout << (n%1000!=0)*1000 - n%1000 << "\n";
}





int main(){
    LETSGO
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
a,b,h,m = gets.split.map(&:to_i)
s_theta = (30*h+0.5*m)/180.0 * Math::PI
l_theta = 6*m / 180.0 * Math::PI
phi = (s_theta - l_theta).abs
ans = (a**2 + b**2 -2*a*b * Math::cos(phi))**(1/2.0)
printf("%.10f\n", ans)

Measured memory_bytes: 14800
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    char x = s[i];
    x = (((x - 'A') + n) % 26) + 'A';
    s[i] = x;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# 素因数分解
from collections import Counter
from itertools import product
def prime_factors(n):
  i = 2
  while i * i <= n:
    if n % i:
      i += 1
    else:
      n //= i
      yield i
  if n > 1:
    yield n

from functools import reduce
import operator
int_product = lambda it: reduce(operator.mul,it,1)


def divisors(n):
    factors = prime_factors(n)
    factors = Counter(factors)
    pows = tuple(factors.values())
    factors = tuple(factors.keys())
    for pp in product(*(range(p+1) for p in pows)):
        yield int_product(f**p for f,p in zip(factors,pp))


N,K = map(int,input().split())
A = list(map(int,input().split()))

def check(m):
    cost = 0
    S = sorted(a%m for a in A)
    total = sum(S)//m
    # print(m,S, total)
    return (sum(s for s in S[:N-total]) + sum(m-s for s in S[N-total:]))//2

for d in sorted(divisors(sum(A)), reverse=True):
    # print(d,check(d))
    if check(d) <= K:
        print(d)
        break


Measured memory_bytes: 3692
#include <cstdio>
#include <set>

using namespace std;

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

int N;
set<int> st;

void solve() {
  REP(i, N) {
    int A;
    scanf("%d", &A);
    if (st.count(A)) {
      st.erase(A);
    } else {
      st.insert(A);
    }
  }
  printf("%d\n", st.size());
}

void input() {
  scanf("%d", &N);
}

int main() {
  input();
  solve();
  return 0;
}


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

void solve()
{
	string s,t;
	cin >> s ;
	cin >> t;
	int l=s.size();
	int ln=t.size();
	int c=0,ans=10000000;
	for(int i=0;i<=l-ln;i++)
	{
		int p=i;
		c=0;
		for(int j=0;j<ln;j++)
		{
			if(t[j]!=s[p])
				c++;
			p++;
		}
		if(ans > c)
			ans=c;
	}
	cout << ans ;
}
int main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("ouput.txt","w",stdout);
	//#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

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

using namespace std;

#define ll long long

struct UnionFind{
    vector<int> data;
    /* constructor */
    UnionFind(int sz){ data.assign(sz,-1); }
    /* merge the set to which x belongs and the set to which y belongs */
    bool unite(int x,int y){
        x = find(x); y = find(y);
        if (x == y) // if x and y already belong to the same set,
            return false; // return false
        if (data[x] > data[y]){
            // swap x and y
            x = x ^ y;
            y = x ^ y;
            x = x ^ y;
        }
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    /* find the root of k */
    int find(int k){
        if (data[k] < 0) return k;
        return data[k] = find(data[k]);
    }
    /* calculate the size of the set to which k belongs */
    int size(int k){ return -data[find(k)]; }
};

signed main(){
    int n,q;
    cin >> n >> q;

    UnionFind uf(n);
    while (q--){
        int com,x,y;
        cin >> com >> x >> y;
        if (com){ // same
            cout << (uf.find(x) == uf.find(y) ? 1 : 0) << endl;
        }
        else { // unite
            uf.unite(x,y);
        }
    }

    return 0;
}


Measured memory_bytes: 3148
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int  a[26];
int main()
{
	string s;
	while(cin>>s)
    {
        memset(a,0,sizeof(a));
        for(int i=0;i<s.size();i++)
        {
            char t=s[i];
            a[t-'a']++;
        }
        int t=0,i;
        for( i=0;i<26;i++)
        {
            if(!a[i])
			break;
        }
        if(i==26)
            cout<<"None";
        else
            cout<<(char)(i+'a')<<endl;
    }

	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

string s,s2="CODEFESTIVAL2016";

int main()
{
	cin >>s;
	int ans=0;
	forn(i,s.size())
		if(s[i]!=s2[i])
			ans++;
	cout <<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
 

 class Main{
             
     static int[] ints=new int[10];
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;
             while((line=br.readLine())!= null){if(line.isEmpty())break;
             ints=new int[10];
                for(int i=0;i<10;i++)ints[i]=Integer.parseInt(line.charAt(i)+"");
                while(!func()){}
                 
                 
             }
             
         }catch(Exception e){}         
     }
     static boolean func(){
         //System.out.println(Arrays.toString(ints));
         int prevLen=ints.length;
         if(ints.length==1){System.out.println(ints[0]);return true;}
         int[] nex=new int[prevLen-1];
         for(int i=0;i<prevLen-1;i++){
             nex[i]=(ints[i]+ints[i+1])%10;
         }
         ints=nex;
         return false;
     }
    
 }

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        b.at(i)=a.at(i);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(b.at(i)!=a.at(n-1))cout<<a.at(n-1)<<endl;
        else cout<<a.at(n-2)<<endl;
    }

    

}

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

void solve() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        if (h >= k) ++ans;
    }
    cout << ans << endl;
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 3604