akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

const int mod = 1e9 + 7;

#define pow abcdef_pow
int pow(int a, int b) {
  if (b == 0) return 1;
  int t = pow(a, b / 2);
  t = (t * t) % mod;
  if (b % 2) return (t * a) % mod;
  return t;
}

int invc(vector<int> &a) {
  int ret = 0, n = a.size();
  for (int i = 0; i < n - 1; i++)
  for (int j = i + 1; j < n; j++) {
    if (a[i] > a[j]) {
      ret++;
      if (ret > mod) ret -= mod;
    }
  }
  return ret;
}

int rmod(int x) {
  return x % mod;
}

void Main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  vector<int> b(all(a));
  b.insert(b.end(), all(a));
  int t1 = invc(a), t2 = invc(b) - t1 * 2;
  t1 = rmod(t1 * k);
  t2 = rmod(rmod(t2 * k) * rmod((k - 1) * pow(2, mod - 2)));
  cout << rmod(t1 + t2) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- -- ----- <3\n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 3708
x,y = map(int, input().split())

ans = 0
if x == y:
    ans = 0
elif abs(x) == abs(y):
    ans = 1
elif x > 0 and y > 0:
    if x < y:
        ans = y - x
    else:
        ans = 2 + (x - y)
elif x < 0 and y < 0:
    if abs(x) < abs(y):
        ans = 2 + abs(abs(x) - abs(y))
    else:
        ans = abs(abs(x) - abs(y))
elif x*y < 0:
    ans = 1 + abs(abs(y) - abs(x))
elif x*y == 0:
    if x == 0:
        if y > 0:
            ans = y
        else:
            ans = abs(y) + 1
    else:
        if x > 0:
            ans = 1 + x
        else:
            ans = abs(x)

print(ans)


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

int main(void){
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 1270; ++i) {
        const int xa = static_cast<double>(i) * 0.08;
        const int xb = static_cast<double>(i) * 0.1;
        if (xa == a && xb == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
    long N,A,B,C,D,E;
    long T[5];
    scanf("%ld%ld%ld%ld%ld%ld",&N,&T[0],&T[1],&T[2],&T[3],&T[4]);

    //TminにT[5]の中の最小値を格納
    long Tmin=T[0];
    //minindexに最小値のインデックスを格納
    int minindex=0;
    for(int i=0;i<5;i++){
        if(Tmin>T[i]){
            Tmin=T[i];
            minindex=i;
        }
    }

    //時間
    long t=N/Tmin+MIN(N%Tmin,1)+4;
    printf("%ld\n",t);

    return 0;
}

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

int main(){
  int N,size,count_p=0,count_n=0;
  cin >> N;
  size = N-1;
  vector<int> A(N);
  vector<int> choice1, choice2;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i]<0){
      count_n ++;
    }else{
      count_p ++;
    }
  }
  sort(A.begin(),A.end());

  //cout << "cp " << count_p << "cn " << count_n << endl;

  while(A.size()>2){
    if(count_n > count_p){
      choice1.push_back(A[N-1]);
      choice2.push_back(A[0]);
      //cout << A[N-1] << " " << A[0] << endl;
      A[N-1] = A[N-1] - A[0];
      count_n -= 1;
      A.erase(A.begin());
      N -= 1;

    }else{
      choice1.push_back(A[0]);
      choice2.push_back(A[N-1]);
      //cout << A[0] << " " << A[N-1] << endl;
      A[0] = A[0] - A[N-1];
      count_p -= 1;
      A.pop_back();
      N -= 1;
    }
    //cout << "cp " << count_p << "cn " << count_n << endl;
    //cout << "as " << A.size() << endl;
  }

  if(A[0]<=0){
    choice1.push_back(A[N-1]);
    choice2.push_back(A[0]);
    //cout << A[N-1] << " " << A[0] << endl;
    A[0] = A[N-1] - A[0];
    //count_n -= 1;
    A.pop_back();
    //N -= 1;
  }else{
    choice1.push_back(A[0]);
    choice2.push_back(A[N-1]);
    //cout << A[0] << " " << A[N-1] << endl;
    A[0] = A[0] - A[N-1];
    //count_p -= 1;
    A.pop_back();
    //N -= 1;
  }


  cout << A[0] << endl;
  for(int i=0;i<size;i++){
    cout << choice1[i] << " " << choice2[i] << endl;
  }

}


Measured memory_bytes: 3316
grid_num,color_num = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(color_num)]
c = [list(map(int,input().split())) for _ in range(grid_num)]

memo0 = {}
memo1 = {}
memo2 = {}

for i in range(grid_num):
  for j in range(grid_num):
    if (i+j)%3 ==0:
      if c[i][j] not in memo0:
        memo0[c[i][j]] = 1
      else:
        memo0[c[i][j]] += 1
    if (i+j)%3 ==1:
      if c[i][j] not in memo1:
        memo1[c[i][j]] = 1
      else:
        memo1[c[i][j]] += 1
    if (i+j)%3 ==2:
      if c[i][j] not in memo2:
        memo2[c[i][j]] = 1
      else:
        memo2[c[i][j]] += 1

#print(memo0)
#print(memo1)
#print(memo2)
        
cost0=[0]*color_num
cost1=[0]*color_num
cost2=[0]*color_num

for i in range(color_num):

  for j in memo0:
    cost0[i] += memo0[j]*(d[j-1][i])
    
  for j in memo1:
    cost1[i] += memo1[j]*(d[j-1][i]) 
    
  for j in memo2:
    cost2[i] += memo2[j]*(d[j-1][i])

    
#print(cost0)
#print(cost1)
#print(cost2)
ans = 1000000000000000
for i in range(color_num):
  for j in range(color_num):
    for k in range(color_num):
      if i != j and j != k and k != i:
        ans = min(ans,cost0[i]+cost1[j]+cost2[k])
    
print(ans)
  

Measured memory_bytes: 5620
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int d=sc.nextInt();
        
        if(d==25){
            System.out.println("Christmas");
        }
        if(d==24){
            System.out.println("Christmas Eve");
        }
        if(d==23){
            System.out.println("Christmas Eve Eve");
        }
        if(d==22){
            System.out.println("Christmas Eve Eve Eve");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m,ans=0;
	cin>>n>>m;
	char a[51][51];
	int b[51][51];
	memset(a,'.',sizeof(a));
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++) cin>>a[i][j];
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++) {
			if(a[i][j]=='.') {
				if(a[i][j+1]=='#') ans++;
				if(a[i][j-1]=='#') ans++;
				if(a[i-1][j]=='#') ans++;
				if(a[i+1][j]=='#') ans++;
				if(a[i-1][j-1]=='#') ans++;
				if(a[i-1][j+1]=='#') ans++;
				if(a[i+1][j-1]=='#') ans++;
				if(a[i+1][j+1]=='#') ans++;
				b[i][j]=ans;
				ans=0;
			} else b[i][j]=-1;
		}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			if(b[i][j]==-1) cout<<"#";
			else cout<<b[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;


int main() {
  int N; cin >> N;
  int C[505],S[505],F[505];
  int t[505];
  for ( int i = 1; i < N; i++ ) cin >> C[i] >> S[i] >> F[i];

  for ( int i = 1; i < N; i++ ) {
    int t = S[i]+C[i];
    
    for( int j = i+1; j < N; j++ ) {
      if ( t < S[j] ) {
	t = S[j];
      } else if ( t > S[j] ) {

	if ( t % F[j] != 0 ) {
	  //int tmp = t - S[j];
	  //	  int k = (tmp-1)/F[j] + 1;
	  // cout << "tmp " << tmp << " " << "k " << " " << k  << endl;
	  //	  t = S[j] + F[j] * 1;
	  t = t+F[j] - t % F[j];
	}

      }
      t += C[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,M;cin>>N>>M;
  vector<vector<long>>A(N*3);
  for(int i=0;i<M;i++){
    long u,v;cin>>u>>v;
    A[u-1].push_back(v-1+N);
    //A[v-1].push_back(u-1+N);
    A[u-1+N].push_back(v-1+2*N);
    //A[v-1+N].push_back(u-1+2*N);
    A[u-1+2*N].push_back(v-1);
    //A[v-1+2*N].push_back(u-1);
  }
  long S,T;cin>>S>>T;
  vector<long>D(3*N,-3);
  queue<long>q;q.push(S-1);D[S-1]=0;
  while(q.size()){
    long f=q.front();q.pop();
    for(long n:A[f]){
      if(D[n]==-3){D[n]=D[f]+1;q.push(n);}
      else D[n]=min(D[n],D[f]+1);
    }
  }
  //for(int i=0;i<3;i++){for(int j=0;j<N;j++)cout<<D[j+i*N]<<" ";cout<<endl;}
  //cout<<D[T-1]<<endl;
  cout<<(D[T-1]%3==0?D[T-1]/3:-1);
  
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll x,y,z; cin>>x>>y>>z;
	cout<<z<<' '<<x<<' '<<y<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "OK" << endl ; else cout << "NG" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll m = 100 ;
	ll ans = 0 ;
	while(m<n){
		ans++ ;
		m += m/100 ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

struct Event{
    int x, s, t;
};

bool compare(const Event& lhs, const Event& rhs){
    if(lhs.s == rhs.s){
        if(lhs.x < rhs.x){
            return true;
        }
        else{
            return false;
        }
    }
    else{
        if(lhs.s < rhs.s){
            return true;
        }
        else{
            return false;
        }
    }

    return false;
}

bool operator<(const Event& lhs, const Event& rhs){
    if(lhs.x == rhs.x){
        return lhs.s < rhs.s;
    }
    return lhs.x < rhs.x;
}

bool operator>(const Event& lhs, const Event& rhs){
    return !(lhs < rhs);
}

int main(){

    int N, Q;
    cin >> N >> Q;

    vector<Event> v(N);
    vector<int> D(Q);
    vector<int> ans(Q);

    int s, t, x;
    for(int i = 0; i < N; i++){
        cin >> s >> t >> x;
        Event temp;
        temp.x = x;
        temp.s = s - x;
        temp.t = t - x - 1;
        v[i] = temp;
    }

    for(int i = 0; i < Q; i++){
        cin >> D[i];
        ans[i] = -1;
    }

    sort(v.begin(), v.end(), compare);

    int index = 0;
    priority_queue<Event, vector<Event>, greater<Event>> q;
    for(int i = 0; i < Q; i++){
        int d = D[i];

        while(index < N){
            Event temp = v[index];
            if(temp.s <= d){
                q.push(temp);
                index++;
            }
            else{
                break;
            }
        }

        while(!q.empty()){
            Event temp = q.top();
            if(temp.t < d){
                q.pop();
            }
            else{
                break;
            }
        }

        if(!q.empty()){
            ans[i] = q.top().x;
        }
    }

    for(int i = 0; i < Q; i++){
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 8180
func main() {
    let A = ["dream", "dreamer", "erase", "eraser"]
    var S = readLine()!
    
    while let a = A.first(where: { S.hasSuffix($0) }) {
        S.removeLast(a.count)
    }
    
    if S.count == 0 {
        print("YES")
    } else {
        print("NO")
    }
}

main()


Measured memory_bytes: 7680
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

ll LCM(ll x , ll y){
	return (x*y) / __gcd(x,y) ;
}

ll NumOfDiv(ll a , ll b , ll k){
	return b/k - a/k + (a%k == 0) ;
}
void start(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int res(int a , int b , int c){
	int x[3] = {a,b,c} ;
	sort(x,x+3);
	return x[1] ;
}

int main()
{
	start();
	int x , y ; 
    cin >> x >> y ; 
    cout << ((x<10 and y < 10) ? x*y : -1) << endl ;
	return 0 ;
}


Measured memory_bytes: 256
import numpy as np

N=int(input())
num_list=[]
while True:
    try:
        num_list.append(list(map(int,input().split())))

    except:
        break;

sum_list=[]
for k in range(N):
  sum_list.append(sum(num_list[0][0:k+1])+sum(num_list[1][k:N+1]))
          
print(max(sum_list))

Measured memory_bytes: 12428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string S;
  string head, tail;
  int Q;
  cin >> S >> Q;
  bool is_reversed = false;
  rep(i, Q)
  {
    int T;
    cin >> T;
    if (T == 1)
    {
      is_reversed = !is_reversed;
    }
    else
    {
      int F;
      string C;
      cin >> F >> C;
      if (F == 1)
      {
        if (is_reversed)
          tail += C;
        else
          head += C;
      }
      else
      {
        if (!is_reversed)
          tail += C;
        else
          head += C;
      }
    }
  }

  if (is_reversed)
  {
    reverse(tail.begin(), tail.end());
    reverse(S.begin(), S.end());

    cout << tail << S << head << endl;
  }
  else
  {
    reverse(head.begin(), head.end());
    cout << head << S << tail << endl;
  }
  return 0;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
  fast;
  ll n;
  cin>>n;
  string s;
  cin>>s;


  ll l[n+5]={0};
  ll r[n+5]={0};
  l[0]=0;
  r[n-1]=0;
  for(ll i=1;i<=n;i++)
  {
    l[i]=l[i-1];
      if(s[i-1]=='W')
        l[i]++;
  }
  for(ll i=n-2;i>=0;i--)
  {
    r[i]=r[i+1];
    if(s[i+1]=='R')
      r[i]++;
  }

  ll ans=n-1;
  fr(i,0,n+1)
  {
    ans=min(ans,max(l[i],r[i]));
  }

  cout<<ans<<endl;
  
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 6884
s = input()
cnt = 0

l = list(s)
a = l.count('0')
b = l.count('1')

# print(a)
# print(b)

print(min(a,b) * 2)
exit()
while '10' in s:
    ind = s.find('10')
    temp = []
    temp.append(str(s[0:ind]))
    temp.append(str(s[ind + 2:len(s)]))
    #print(s)
    s = "".join(temp)
    cnt = cnt + 2

while '01' in s:
    ind = s.find('01')
    # print(ind)
    temp = []
    temp.append(str(s[0:ind]))
    temp.append(str(s[ind + 2:len(s)]))
    s = "".join(temp)
    #print(s)
    cnt = cnt + 2

print(cnt)

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

int main(){
std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        const int N=1e5+3;
        int arr[N]={0};
        long long i,a,j,n,q,e=0,b,t,o=0,c=0,temp,k,maxpeak=0,peak,d;
        string s;
        cin>>a>>b>>c>>d;
        cout<<max(a*b,c*d);
        
        
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy\n";
    else if (s == "Cloudy") cout << "Rainy\n";
    else if (s == "Rainy") cout << "Sunny\n";
    return 0;
}

Measured memory_bytes: 256
import math

n,d=map(int,input().split())
ans=[]
cnt=0
for _ in range(n):
    ans.append(list(map(int,input().rstrip().split())))
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        else:
            result = math.sqrt(sum(abs(ans[i][k]-ans[j][k])**2 for k in range(d)))
            if result.is_integer():
                cnt += 1
            else:
                continue
print(cnt)

Measured memory_bytes: 3064
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int n = N;
		int sum = 0;
		while(n > 0){
			sum += n%10;
			n /= 10;
		}

		if(N%sum == 0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}




Measured memory_bytes: 20560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int a,b,n;cin>>a>>b>>n;
    if(n<b)
    {
        int ans=(a*n)/b-a*(n/b);
        cout<<ans;
        return 0;
    }

    int one_val=a;
    int cur=a/b+bool(a%b);
    one_val-=cur;

    int two_val=(a*n)/b-a*(n/b);

    cout<<max(one_val,two_val);

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 1;
    bool zero = false;
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i] == 0){
            zero = true;
        }
    }
    if(zero){
        cout << 0 << endl;
    }
    else{
        for (ll i = 0; i < N; i++)
        {
            ans *= A[i];
            if(ans > 1000000000000000000 || ans < 1){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4000
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		int n;
		cin>>n;
		if(n==0) break;
		vector<ll> p(26, 0);
		ll fp = 0, sp = 0;
		ll det = false;
		char f = 'A', s = 'B';
		REP(i, n) {
			char c;
			cin>>c;
			++p[c - 'A'];
			if(f == c) {
				++fp;
			} else if(s == c) {
				if(p[c - 'A'] > fp) {
				swap(f, s);
				sp = fp;
				fp = p[c - 'A'];
				} else {
					++sp;
				}
			} else if(p[c - 'A'] > fp) {
				sp = fp;
				fp = p[c - 'A'];
				s = f;
				f = c;
			} else if(p[c - 'A'] > sp) {
				sp = p[c - 'A'];
				s = c;
			}
			if(fp - sp > n - (i + 1)) {
				if(!det) {
				cout<<f<<" "<<i + 1<<endl;
				det = true;
				}
			}
		}
		if(!det) {
			cout<<"TIE"<<endl;
		}
	}
}

Measured memory_bytes: 3092
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto M = 2 * N - 1;
    auto A = readln.split.map!(to!int).array;

    int hi = M + 1;
    int lo = 0;
    while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        auto B = A.map!(a => a >= mid).array;
        int a = B[N-2], b = B[N-1], c = B[N];
        if ((a & b) || (b & c)) {
            lo = mid;
        } else if ((!a & !b) || (!b & !c)) {
            hi = mid;
        } else {
            bool ok = false;
            for (int l = N - 3, r = N + 1; l >= 0; l--, r++) {
                if (B[l] == B[l+1]) {
                    if (B[l]) lo = mid;
                    else hi = mid;
                    ok = true;
                    break;
                } else if (B[r] == B[r-1]) {
                    if (B[r]) lo = mid;
                    else hi = mid;
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                bool hoge = B[N-1];
                if (M / 2 % 2) hoge ^= 1;
                if (hoge) lo = mid;
                else hi = mid;
            }
        }
    }

    lo.writeln;
}


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

int main(){
  string s;
  cin >> s;
  
  int len;
  rep2(i,1,s.length()){
    string t = s.substr(0,s.length()-i);
    len = t.length();
    
    if(len%2 == 1) continue;
    if(t.substr(0,len/2) == t.substr(len/2, len/2)) break;
  }
  
  cout << len << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,a;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a%2==0 && a%3!=0 && a%5!=0){
            puts("DENIED");
            return 0;
        }
    }
    puts("APPROVED");
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let r = parse_line!(u32);
    let ans = 3 * r * r;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll a,b,q,x;
  cin>>a>>b>>q;
  vector<ll> s(a),t(b);
  for(int i=0;i<a;i++) cin>>s[i];
  for(int i=0;i<b;i++) cin>>t[i];
  for(int i=0;i<q;i++){
    cin>>x;
    ll m=1000000000000000;
    ll ls=(ll)(lower_bound(s.begin(),s.end(),x)-s.begin());
    if(ls!=0){
      ll lt=(ll)(lower_bound(t.begin(),t.end(),s[ls-1])-t.begin());
      if(lt!=0){
        m=min(m,x-t[lt-1]);
      }
      if(lt!=b){
        if(x>t[lt]) m=min(m,x-s[ls-1]);
        else m=min(m,min(x-s[ls-1]+t[lt]-s[ls-1],t[lt]-x+t[lt]-s[ls-1]));
      }
    }
    if(ls!=a){
      ll lt=(ll)(lower_bound(t.begin(),t.end(),s[ls])-t.begin());
      if(lt!=0){
        if(x<t[lt-1]) m=min(m,s[ls]-x);
        else m=min(m,min(x-t[lt-1]+s[ls]-t[lt-1],s[ls]-x+s[ls]-t[lt-1]));;
      }
      if(lt!=b){
        m=min(m,t[lt]-x);
      }
    }
    cout<<m<<endl;
  }
}

Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

template<class T> inline T cabs(const T &x) { return x > 0 ? x : (-x); }
template<class T> inline T gcd(const T &x, const T &y) { return (y == 0) ? x : gcd(y, x % y); }
template<class T> inline T sgn(const T &x) { return (x > 0) - (x < 0); }

#define dbg(x) cout << #x << " = " << (x) << endl
#define dbg2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define dbg3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
#define dbg4(x,y,z,w) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #w << " = " << w << endl

#define out(x) cout << (x) << endl
#define out2(x,y) cout << (x) << " " << (y) << endl
#define out3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define out4(x,y,z,w) cout << (x) << " " << (y) << " " << (z) << " " << (w) << endl


int main()
{
    //freopen("data.in", "r", stdin);
    int h, w;
    cin >> h >> w;
    string str;
    for(int i = 0; i < h; i ++) {
        for(int j = 0; j < w; j ++) {
            cin >> str;
            if( str == "snuke" ) {
                char ch = j + 'A';
                int d = i + 1;
                printf("%c%d\n", ch, d);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main() {
	int n;cin >> n;
    LV a(n);REP(i,n)cin >> a[i];
    double s=0;
    REP(i,n){
        s+=1.0/a[i];
    }
    cout << 1/s << endl;
    return 0;


}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int A,B,C,X,Y;
  scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
  int sum=0;
  if(A+B>2*C){
  	if(X>Y){
  		sum=2*C*Y;
  		if(A>2*C){
  			sum+=(X-Y)*2*C;
  		}else{
  			sum+=(X-Y)*A;
  		}
  	}else{
  		sum=2*C*X;
  		if(B>2*C){
  			sum+=(Y-X)*2*C;
  		}else{
  			sum+=(Y-X)*B;
  		}
  	}
  }else{
  	sum=A*X+B*Y;
  }
  printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>


int main() {
	int N, candy = 0, maxCandy = 0;
	std::cin >> N;

	std::vector<std::vector<int>> A( 2, std::vector<int>(N) );

	for(int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			std::cin >> A[i][j];
		}
	}

	for (int k = 1; k < N + 1; k++) {
		for (int i = 0; i < k; i++) {
			candy += A[0][i];
		}
		for (int i = k - 1; i < N; i++) {
			candy += A[1][i];
		}

		if (candy > maxCandy) {
			maxCandy = candy;
		}
		candy = 0;
	}

	std::cout << maxCandy << std::endl;

	return 0;
}


Measured memory_bytes: 256
from math import gcd
import functools

K = int(input())
ans = 0
for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            i = (a, b, c)
            length = len(set(i))
            if length == 1:
                ans = ans + a
            elif length == 2:
                ans = ans + 3 * (functools.reduce(gcd, [a, b, c]))
            elif length == 3:
                ans = ans + 6 * (functools.reduce(gcd, [a, b, c]))
                         
print(ans)

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

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

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

int main() {
  string S;
  cin >> S;
  
  int m = 0,b = 0;
  
  for(int i = 0; i < S.size();i++) {
  	if(S.at(i) == 'o') m++;
  }
  
  int rest = 15 - S.size();
  if(m + rest >= 8) {
  cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int comp(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int comp_inv(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}

int main() {
	int n, m, x[100000], i, d[100000], cnt;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) scanf("%d", &x[i]);
	qsort(x, m, sizeof(int), comp);
	d[0] = 0;
	for (i = 1; i < m; i++) d[i] = x[i] - x[i - 1];
	qsort(d, m, sizeof(int), comp_inv);
	cnt = 0;
	for (i = n - 1; i < m; i++) cnt += d[i];
	printf("%d", cnt);
	return 0;
}

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

using namespace std;

long long comb(int a, int b) {
    long long c = a;

    for (int i = 1; i < b; ++i) {
        c *= a - i;
    }

    return c;
}

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    int R = 0;
    int G = 0;
    int B = 0;

    long long count = 0;

    for (const char c : S) {
        switch (c) {
        case 'R':
            R++;
            break;
        case 'G':
            G++;
            break;
        case 'B':
            B++;
            break;
        }
    }

    for (int i = 0; i < N - 2; ++i) {
        switch (S.at(i)) {
        case 'R':
            R--;
            count += G * B;
            break;
        case 'G':
            G--;
            count += B * R;
            break;
        case 'B':
            B--;
            count += R * G;
            break;
        }

        for (int j = 1; i + 1 + 2 * j <= N; ++j) {
            if (S.at(i) != S.at(i + j) && S.at(i + j) != S.at(i + 2 * j) && S.at(i + 2 * j) != S.at(i)) {
                count--;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    ll sum = 0;
    int pre = 0;
    for(int i = 0; i < n; i++) {
        if (a[i] == 0) {
            pre = 0;
            continue;
        }
        sum += (a[i] + pre) / 2;
        if ((a[i]+pre) % 2 == 0) pre = 0;
        else pre = 1;

        cerr << i << " " << sum << " " << pre << endl;
        
    }

    cout << sum << endl;
    
    return 0;
}

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

int n, k;
int w[100100];

bool calc(int m){
	int cnt = 1, now = 0;
	for(int i = 0; i < n; i++){
		if(now + w[i] <= m){
			now += w[i];
		}else if(w[i] <= m){
			now = w[i];
			cnt++;
		}else{
			return false;
		}
	}
	return cnt <= k;
}

int main(){
    cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> w[i];
	}
	int l = 0, r = 1e9 + 1, m;
	while(r - l >= 1){
		m = (l + r) / 2;
		if(calc(m)) r = m;
		else l = m + 1;
	}
	cout << r << endl;
}

Measured memory_bytes: 3472
#include <stdio.h>

#define N 100

int main(){

  int A[100];
  int i,j,flag=1,a,swap,n,count=0;

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

    for(j=n-1; j>=1; j--){
      
      if (A[j] < A[j-1]){
	swap=A[j];
	A[j] = A[j-1];
	A[j-1] = swap;
	count++;
	flag=1;
      } 
    }
}

  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i!=n-1)
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>
#include <bits/stdc++.h>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    IO;
    int n ;
    cin>>n ;
    int arr[n+2];
    for(int i =0 ;i < n ; i++)cin>>arr[i];
    int best_in_last= abs(arr[1]-arr[0]);
    int best_in_last_last=0;
    for(int i = 2 ;i < n ; i++){
        int best_in_last_temp=best_in_last;
        best_in_last=min(best_in_last+(abs(arr[i]-arr[i-1])),best_in_last_last+abs(arr[i]-arr[i-2]));
        best_in_last_last=best_in_last_temp;
    }
    cout<<best_in_last<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
	return 0;
}


Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int N; cin>>N;
   if(N%1000==0) cout << 0 << endl;
   else cout << 1000-N%1000 << endl;


   return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;


ll pow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    for(int i=0; i<5; i++){
        cin >> a;
        if(a==0)
            b=i+1;
    }
    cout << b << el;
    return 0;
}
    


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int n = 100;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int m[n][n];
    int n, u, k, v;
    cin >> n;
    rep(i, n) {
        rep(j, n) { m[i][j] = 0; }
    }

    rep(i, n) {
        cin >> u >> k;
        u--;  // 0-indexに変換
        rep(j, k) {
            cin >> v;
            v--;          // 0-indexに変換
            m[u][v] = 1;  // uとvの間に辺を張る。
        }
    }
    rep(i, n) {
        rep(j, n) {
            if (j) cout << " ";
            cout << m[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits.h>
int main()
{
	int n,l;
	std::vector<int> a;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		std::cin >> l;
		a.push_back(l);
	}
	std::sort(a.begin(), a.end());
	int min = a[0];
	int max = a[a.size() - 1];
	long buf, min_record;
	long min_value = LONG_MAX;
	for (int i = min; i <= max; i++)
	{
		for (unsigned int j = 0; j < a.size(); j++)
		{
			buf += std::pow((a[j] - i), 2.0);
		}
		if (min_value > buf)
		{
			min_value = buf;
			min_record = i;
			buf = 0;
		}
	}
	int result;
	for (unsigned int i = 0; i < a.size(); i++)
	{
		result += std::pow(a[i] - min_record, 2.0);
	}
	std::cout << result << "\n";
    return 0;
}



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

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i <= n; i++){
        bool ok = true;
        for(int j = 0; j < n - i; j++){
            if(s[i + j] != t[j]) ok = false;
        }
        if(ok){
            cout << n + i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
    if(y==NIL){
      root=z;
    }
    else if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }


void inorder(Node u){
  if (u->left != NIL){
    inorder(u->left);
  }
  printf(" %d", u->key);
  if (u->right != NIL){
    inorder(u->right);
  }
}
void preorder(Node u){
  printf(" %d",u->key);
  if (u->left != NIL){
    preorder(u->left);
  }
  if (u->right != NIL){
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, input().split())
    cake = [list(map(int, input().split())) for _ in range(N)]
    C = [[] for _ in range(8)]
    for i in range(2 ** 3):
        for c in range(N):
            m = 0
            for j in range(3):
                if (i >> j) & 1:
                    m += cake[c][j]
                else:
                    m -= cake[c][j]
            C[i].append(m)
    answer = 0
    for i in range(8):
        C[i].sort(reverse=True)
        ans = sum(C[i][:M])
        if ans > answer:
            answer = ans
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
import java.util.*;

import java.io.*;
 
public class Main{

    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        int A = s.nextInt();
        int B = s.nextInt();
        String U = s.next();
        
        if(U.equals(S)){
            A--;
        }else{
            B--;
        }
        
        
        System.out.println(A + " " + B);
        
        
	}
} 

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

int main(){
  int N;
  cin >> N;
  const int64_t mod=1e9+7;
  vector<int> v(N,0);
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    if(N%2==0){
      if(A%2==0){
        cout << 0 << endl;
        return 0;
      }
    }else{
      if(A%2!=0){
        cout << 0 << endl;
        return 0;
      }
    }
    v.at(A)++;
    if(A==0){
      if(v.at(A)>1){
        cout << 0 << endl;
        return 0;
      }
    }else{
      if(v.at(A)>2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  int64_t ans=1;
  int n=N/2;
  int64_t a=2;
  while(n>0){
    if(n&1){
      ans*=a;
      ans%=mod;
    }
    a*=a;
    a%=mod;
    n>>=1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String str = sc.nextLine();
			for(int i = 0;i<str.length();i++) {
				char ch = str.charAt(i);
				if(64<ch&&ch<91) {
					System.out.print((char)(ch+32));
				}
				else if(96<ch&&ch<123) {
					System.out.print((char)(ch-32));
				}
				else {
					System.out.print(ch);
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 26956