akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;




int main() {

    
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}



Measured memory_bytes: 3632
import numpy as np
H, W, N, *A = map(int, open(0).read().split())
ls = []
for i in range(N):
  ls += [i+1]*A[i]
ls = np.array(ls)
ls = ls.reshape((H,W))
ls[1::2] = ls[1::2,::-1]
for a in ls:
  print(*a)


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

int main()
{
    int n, m, d;

    cin >> n >> m >> d;

    char area[n][m];
    for( int i = 0; i < n; i++ )
        for( int j = 0; j < m; j++ )
            cin >> area[i][j];
    
    int cnt = 0;
    for( int i = 0; i < n; i++ )
        for( int j = 0; j < m; j++ )
        {
            if( i + d <= n )
            {
                bool judge = true;
                for( int k = 0; k < d; k++ )
                    if( area[i+k][j] != '.' )
                    {
                        judge = false;
                        break;
                    }
                if( judge == true )
                    cnt++;
            }
            if( j + d <= m )
            {
                bool judge = true;
                for( int k = 0; k < d; k++ )
                    if( area[i][j+k] != '.' )
                    {
                        judge = false;
                        break;
                    }
                if( judge == true )
                    cnt++;
            }
        }
    
    cout << cnt << endl;

    return 0;
}


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

using ll = long long;
double f(ll a){
	ll s = 0;
	for(ll t = a; t; t /= 10) s += t % 10;
	return a * 1.0 / s;
}

int main(){
	int k; cin >> k;
	ll LIM = 3e16;
	vector<ll> v, ans;
	for(int i = 1; i <= 9999; i++) for(ll j = i; j < LIM; j = j * 10 + 9) v.push_back(j);
	sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
	double mn = 1e18;
	for(int i = v.size() - 1; i >= 0; i--){
		double s = f(v[i]);
		if(mn + 1e-9 > s){
			mn = s;
			ans.push_back(v[i]);
		}
	}
	reverse(ans.begin(), ans.end());
	for(int i = 0; i < k; i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001], fixstr[1001];
	int i;
	int len;
	
	scanf("%s", str);
	
	len = strlen(str);
	
	for (i = 0; i < len; i++){
		if (str[i] >= 'A' && str[i] <= 'C'){
			fixstr[i] = str[i] + 23;
		}
		else if (str[i] >= 'D' && str[i] <= 'Z'){
			fixstr[i] = str[i] - 3;
		}
	}
	
	fixstr[i] = '\0';
		
	printf("%s\n", fixstr);
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++){
        cout << x * r - d << endl;
        x = x * r - d;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int a[MAXN],N,cnt[MAXN];
bool vis[MAXN];
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    for(int i = 1 ; i <= N ; ++i) {
        int cnt = 0;
        for(int j = 1 ; j < i ; ++j) {
            if(a[j] <= a[i]) ++cnt;
        }
        if(cnt + 1 < a[i]) {puts("-1");return;}
    }
    for(int i = 1 ; i <= N ; ++i) {
        cnt[0] = 0;
        for(int j = 1 ; j <= N ; ++j) cnt[j] = cnt[j - 1] + vis[j];
        for(int j = N ; j >= 1 ; --j) {
            if(!vis[j] && cnt[j - 1] + 1 == a[j]) {
                vis[j] = 1;
                out(a[j]);enter;
                break;
            }
        }
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,t,m,a[200000],n=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  t=a[1]-a[0];
  m=a[0];
for(i=0;i<n;i++){
if(m>a[i]){m=a[i];}
if(t<a[i+1]-m && n> i+1){t=a[i+1]-m;}
}

  printf("%d\n",t);
return 0;
}

Measured memory_bytes: 1376
class Dice
    @numbers = []

    def initialize numbers
        @numbers = numbers
    end

    def roll direction
        old = @numbers.dup
        case direction
        when "N"
            @numbers[0] = old[1]
            @numbers[1] = old[5] 
            @numbers[5] = old[4]
            @numbers[4] = old[0]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "E"
            @numbers[3] = old[5]
            @numbers[0] = old[3] 
            @numbers[2] = old[0]
            @numbers[5] = old[2]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        when "S"
            @numbers[0] = old[4]
            @numbers[1] = old[0] 
            @numbers[5] = old[1]
            @numbers[4] = old[5]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "W"
            @numbers[3] = old[0]
            @numbers[0] = old[2] 
            @numbers[2] = old[5]
            @numbers[5] = old[3]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        end
    end

    def top
        @numbers[0]
    end
end

numbers = gets.chomp.split.map(&:to_i)
dice = Dice.new(numbers)
directions = gets.chomp.split("")
directions.each{|direction| dice.roll direction}
puts dice.top

Measured memory_bytes: 8668
#include<stdio.h>
#include<string.h>

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

int main(){

  char t[200001];
  scanf("%s",t);
  int len =strlen(t);

  for(int i = 0; i < len ; ++i){
    if(t[i] == '?'){
      if(t[i-1] == 'P'){
        t[i] = 'D';
      }else if(t[i+1] == 'D'){
        t[i] = 'P';
      }else if(t[i+1] == 'P'){
        t[i] = 'D';
      }else if(t[i+1] == '?'){
        t[i] = 'P';
      }else{
        t[i] = 'D';
      }
    }
  }

  printf("%s",t);

  return 0;
}


Measured memory_bytes: 1924
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define P pair<int,int>
#define x first
#define y second
#define pb push_back
#define abs(x)(x>0?x:-(x))
using namespace std;
const int N=5005;
int n,ans;
vector<P>S,T;
char s[N],t[N];
void work(vector<P>&a,vector<P>&b){
	int pre=0,s;
	fo(i,0,a.size()-1){
		if(a[i].y==b[0].y){
			s=pre;
			int j=i,k=0;
			for(;j<a.size()&&k<b.size();++j,++k)
				s+=abs(a[j].x-b[k].x);
			for(;j<a.size();++j)s+=n-a[j].x;
			for(;k<b.size();++k)s+=n-b[k].x;
			ans=min(ans,s);
		}
		pre+=a[i].x;
	}
	for(P i:b)pre+=n-i.x;
	ans=min(ans,pre);
}
int main(){
	scanf("%d\n%s\n%s",&n,s+1,t+1);
	if(n<=2){
		fo(i,1,n)if(s[i]!=t[i])++ans;
		cout<<ans;
		return 0;
	}
	fo(i,1,n-1){
		if(s[i]!=s[i+1])S.pb(P(i,s[i]-'0'));
		if(t[i]!=t[i+1])T.pb(P(i,t[i]-'0'));
	}
	ans=1e9;
	work(S,T);
	work(T,S);
	cout<<ans;
}

Measured memory_bytes: 384
<?php

[$N] = fscanf(STDIN, "%d");

[$zero] = fscanf(STDIN, "%d");
if($zero !== 0){
    echo -1;
    exit;
}
$last = 0;
$ans = 0;
for($i=1;$i<$N;$i++){
    [$value] = fscanf(STDIN, "%d");
    if($last + 1 === $value){
        $ans += 1;
    }elseif($last >= $value){
        $ans += $value;
    }else{
        echo -1;
        exit;
    }
    $last = $value;
}
echo $ans;

Measured memory_bytes: 16196
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
g = []
for i in range(n):
    g.append([])
for i in range(m):
    s, t = na()
    g[s-1].append(t-1)

es = [0] * n
for i in range(n-2,-1,-1):
    s = 0
    for e in g[i]:
        s += es[e]
    s = s / len(g[i]) + 1
    es[i] = s

# print(es)

cont = [0] * n
for i in range(n):
    ees = [0] * (i+1)
    ees[-1] = 1.0
    for j in range(i-1,-1,-1):
        t = 0
        for e in g[j]:
            if e <= i:
                t += ees[e]
        ees[j] = t / len(g[j])
    cont[i] = ees[0]
# print(cont)

ans = es[0]
for i in range(n):
    if len(g[i]) == 1:
        continue
    s = 0
    for e in g[i]:
        s += es[e]
    minto = es[i]
    for e in g[i]:
        to = (s - es[e])/(len(g[i])-1) + 1
        minto = min(minto, to)
    ans = min(ans, es[0] - (es[i]-minto)*cont[i])
print("{:.14f}\n".format(ans))


Measured memory_bytes: 57692
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, K;

int main(){
	cin >> N >> K;
	vector<long long>A(N);
	vector<long long>F(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> F[i];


	sort(A.begin(), A.end());
	sort(F.begin(), F.end(), greater<long long>());

	long long start = -1;
	long long end = 1e12 + 1;

	while(start + 1 < end) {
		long long mid = (start + end)/2;

		long long cost = 0;
		rep(i, N) {
			long long minia;
				minia = mid/F[i];
			//if(mid%F[i] == 0) {
			//	minia = mid/F[i];
			//} else {
			//	minia = mid/F[i] + 1;
			//}
			cost += max(A[i] - minia, 0LL);
		}
		
		if(cost > K) {
			start = mid;
		} else {
			end = mid;
		}
	}


	cout << end << endl;
}

Measured memory_bytes: 6352
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (d, n) = listOfInt()
    val base = Math.pow(100.0, d.toDouble()).toInt()

    var cnt = 0
    var num = 0
    while (cnt < n) {
        num++
        if (num % base == 0 && num % (base * 100) != 0) cnt++
    }

    println(num)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37924
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}
 
int main(){
    ll N,M,T=0;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<ll> V;
    rRep(i,N,0){
        if(i==0){
            break;
        }
        ll K=0;
        rRep(j,M,T){
            if(j==T){
                cout << -1 << endl;
                return 0;
            }
            if(i-j>=0){
                if(S[i-j]=='0'){
                    V.pb(j);
                    i=i-j+1;
                    break;
                }
            }
            else{
                K++;
            }
        }
        T=K;
    }
    rep(i,V.size()){

        cout  << V[V.size()-1-i];
        if(i!=V.size()-1){
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1528
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        long mod = 1000000007;
        int[] counts = new int[26];

        for (int i = 0; i < n; ++i) {
            int current = s.charAt(i) - 'a';
            counts[current]++;
        }
        long result = 1;
        for (int i = 0; i < 26; ++i) {
            if (counts[i] == 1) {
                result *= 2;
                result %= mod;

            } else if (counts[i] > 1) {
                result *= (counts[i] + 1);
                result %= mod;
            }
        }
        result--;
        System.out.println(result);

    }
}


Measured memory_bytes: 26196
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int sod(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    int n;
    cin>>n;
    if(n%sod(n)==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int a,b; cin >> a >> b;
	cout << 6-a-b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N+1);
  REP(i, N)
  cin >> A.at(i+1);
  vector<int> DP(N+1);
  DP.at(0) = 0;
  DP.at(1) = 0;
  DP.at(2) = abs(A.at(1)-A.at(2));
  for (int i = 3; i <= N; i++){
    DP.at(i) = min(DP.at(i - 2) + abs(A.at(i - 2)-A.at(i)), DP.at(i - 1) + abs(A.at(i - 1)-A.at(i)));
  }
  cout << DP.at(N) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

map<P, ll> m;
ll mod = 1e9+7;

ll f(ll S, ll X){
  if(S == 1){
    return 2;
  }
  else if(S == 0){
    return 1;
  }
  else if(m.find(P(S, X)) == m.end()){
    ll res = (f(S/2, X/2) + f((S-1)/2, (X-1)/2) + f((S-2)/2, X/2)) % mod;
    m[P(S, X)] = res;
    return res;
  }
  else{
    ll res = m[P(S, X)];
    return res;
  }
}

int main(){
  ll N;   cin >> N;
  cout << f(N, N) << endl;

  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int r,g,b,k;
    cin>>r>>g>>b>>k;
    rep(i,k){
        if(g<=r){
            g *=2;
            continue;
        }
        if(b<=g){
            b *=2;
            continue;
        }
    }
    if(b>g && g>r) Yes;
    else No;
}/*
./problem.exe
*/

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  int num = 0;
  for(int i=0; i<2; i++) {
    if(A > B) {
      num += A;
      A--;
    } else {
      num += B;
      B--;
    }
  }
  
  cout << num << endl;
  
  return 0;
}

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

#define i64 long long int
#define ran 66

int n;
int cnt0[ran], cnt1[ran];

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		i64 x;
		scanf("%lld", &x);
		for(int j=0;j<60;j++)
			if(x & (1LL<<j)) cnt1[j]++;
			else cnt0[j]++;
	}
	
	int ans = 0;
	for(int i=0;i<60;i++) {
		i64 base = 1LL<<i;
		base %= ma.mod;
		
		ans = ma.add(ans, ma.mul(base, ma.mul(cnt0[i], cnt1[i])));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;

#define endl '\n'

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int a,b,sum,maxn;
	cin>>a>>b;
	sum=0;
	maxn=1;
	while(maxn<b){
		maxn--;
		maxn+=a;
		sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

map<char, char>mp;
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	mp['A'] = 'T';
	mp['T'] = 'A';
	mp['G'] = 'C';
	mp['C'] = 'G';
	char b; cin >> b;
	print(mp[b]);
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
s = sum(w)
ans = []
for i in range(n):
  s1 = 0
  for j in range(n):
    if j <= i:
      s1 += w[j]
  s2 = s - s1
  ans.append(abs(s1-s2))
print(min(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
int a,b,c,root;
scanf("%d%d",&a,&b);
c=b;
while(c!=0)
{
a*=10;
c/=10;

}
a=a+b;
root = sqrt(a);
if((root*root)==a)
printf("Yes");
else
printf("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <utility>

using namespace std;

#define pb push_back
#define ft first
#define sd second
#define mpr make_pair
#define all(x) begin((x)), end((x))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define max3(a, b, c) max((a), max((b), (c)))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define min3(a, b, c) min((a), min((b), (c)))
#define min4(a, b, c, d) min(min((a), (b)), min((c), (d)))
#define isz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef vector<int> vi;

/* <------------------------------------------------------------------------------------> */

int a[57], n, p;
ll d[107][2];

void solve()
{
    scanf("%d%d", &n, &p);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", a + i);
        a[i] &= 1;
    }
    d[0][0] = 1;
    for (int i = 1; i <= n; ++i) forn (j, 2)
        d[i][j] = d[i - 1][j] + d[i - 1][j ^ a[i]];
    printf("%lld\n", d[n][p]);
}

/* <------------------------------------------------------------------------------------> */

// #define LOCAL
// #define FILE_NAME

int main()
{
    #if defined LOCAL
        freopen("input.txt", "r", stdin);
    #elif defined FILE_NAME
        freopen(FILE_NAME".in", "r", stdin);
        freopen(FILE_NAME".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 256
#最大公約数
def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  c = a % b
  return gcd(b, c)

#最小公倍数
def lcm(a, b):
  return int(a * b / gcd(a, b))

def calc(a, c, d):
  g = lcm(c, d)
  return a - (a // c) - (a // d) + (a // g)
  
A, B, C, D = map(int, input().split())

print(calc(B, C, D) - calc(A-1, C, D))


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

int primes[]={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};
int main(){
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cout<<primes[i]<<" ";
    }
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N, D;
	cin >> N >> D;
	if (N%(2*D+1)==0) {
		ce(N/ (2 * D + 1))
	}
	else {
		ce(N / (2 * D + 1)+1)
	}
    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k & 1) {
		cout << b - a << endl;
	} else {
		cout << a - b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int A = Integer.parseInt(arr[0]);
        int B = Integer.parseInt(arr[1]);
        int C = Integer.parseInt(arr[2]);
        out.println((A < C && B > C) || (A > C && B < C) ? "Yes" : "No");
        out.close();
    }
}


Measured memory_bytes: 21716
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N, K; std::cin >> N >> K;
  int count = 0;
  for (int n = 0; n < N; ++n) {
    int h; std::cin >> h;
    if (h >= K) ++count;
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
package main


import (
  "fmt"
  // "strings"
  // "strconv"
)


func main () {
  var k, x float64
  fmt.Scanf("%f %f", &k, &x)
  lower := x - k + 1
  upper := x + k - 1

  for i := lower; i<=upper; i++ {
    fmt.Println(i)
  }
}




Measured memory_bytes: 512
N,M = map(int,input().split())
d = set()
m = 1
while m*m <= M:
    if M%m==0:
        d.add(m)
        d.add(M//m)
    m += 1

ans = 1
for n in d:
    m = M//n
    if m >= N:
        ans = max(ans,n)
print(ans)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) (c).begin(),(c).end()

using namespace std;

int a[100001], ans[5];

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> a[i];
  int b = -1;
  bool end = false;
  int i = 0;
  while(a[i] == a[i + 1] && i < N)
    i++;
  for(i++; i < N - 1; i++)
  {
    b = a[i - 1];
    int now = a[i], c = a[i] /* ????????? */;
    bool f = false; // ?????£??????????????°??????(??????or?????°or?±±???)
    // ?????°??????
    while(now == a[i + 1])
    {
      now = a[++i];
      f = true;
      if(i == N - 1)
      {
        end = true;
        break;
      }
    }
    if(end)
      break;
    int next = a[i + 1];
    if(!f && b < c && c < next)
      continue;
    if(f) // ?????°??????
    {
      if(b < c && c > next) // ??????
        ans[0]++;
      else if(b > c && c < next) // ?????°
        ans[1]++;
      else if(b < c && c < next) // ?±±???1
        ans[2]++;
      else if(b > c && c > next) // ?±±???2
        ans[2]++;
    }
    else // ?????°??????
    {
      if(b < c && c > next) // ??°
        ans[3]++;
      else if(b > c && c < next) // ?????°
        ans[4]++;
    }
  }
  for(int i = 0; i < 4; i++)
    cout << ans[i] << " ";
  cout << ans[4] << endl;
}


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

using namespace std;

int W, H, N, x, y, t;

int main() {

	cin >> W >> H >> N;
	int lx = 0, rx = W, ly = 0, ry = H;

	for(int i = 0; i < N; i++) {
		cin >> x >> y >> t;
		if(t == 2){
            rx = min(rx, x);
        }else if(t == 1){
            lx = max(lx, x);
        }else if(t == 4){
            ry = min(ry, y);
        }else if(t == 3){
        ly = max(ly, y);
        }
	}
    
	cout << max(rx - lx, 0) * max(ry - ly, 0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
void err() {
	puts("No");
	exit(0);
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int N;
	cin >> N;
	vector<pair<int, int>>v1, v2;
	int h = 0;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		int sum = 0;
		int mi = 0;
		for (int j = 0; j < s.size(); j++) {
			sum += (s[j] == '(')?1:-1;
			mi = min(sum,mi);
		}
		h += sum;
		if (sum >= 0) { v1.pb({mi,sum}); continue; }
 
		sum = 0, mi = 0;
		reverse(all(s));
		for (int j = 0; j < s.size(); j++) {
			sum += (s[j] == ')') ? 1 : -1;
			mi = min(sum, mi);
		}
		v2.pb({mi,sum});
	}
 
	if (h != 0)err();
 
	sort(all(v1));
	reverse(all(v1));
	sort(all(v2));
	reverse(all(v2));
 
	int z = 0;
	for (int i = 0; i < v1.size(); i++) {
		if (v1[i].first + z < 0)err();
		z += v1[i].second;
	}
 
	z = 0;
	for (int i = 0; i < v2.size(); i++) {
		if (v2[i].first + z < 0)err();
		z += v2[i].second;
	}
	puts("Yes");
	
	return 0;
}

Measured memory_bytes: 11480
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int counter = 0;

    for (int i = a; i <= b; i++) {
      if (c % i == 0) {
        counter++;
      }
    }
    System.out.println(counter);
  }
}


Measured memory_bytes: 26216
K, X = map(int, input().split())

ans = [X]; tmp1 = X; tmp2 = X
for i in range(K-1):
    ans.append(tmp1+1)
    tmp1 += 1
    ans.append(tmp2-1)
    tmp2 -= 1
    
print(' '.join([str(num) for num in sorted(ans)]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  string s,t;
  cin >> s >>t;
  int c=0;
  rep(i,s.size()){
    if(s.at(i)!=t.at(i)){
      c++;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 3916
open System

let rec isSubList xs ys =
    match xs, ys with
    | [], _ -> true
    | _, [] -> false
    | x::xs, y::ys when x = y -> isSubList xs ys
    | xs, y::ys -> isSubList xs ys

let n = stdin.ReadLine() |> int
let s = stdin.ReadLine().ToCharArray() |> List.ofArray

let a = List.length [
    for i in ['0'..'9'] do
    for j in ['0'..'9'] do
    for k in ['0'..'9'] do
    if isSubList [i; j; k] s then yield () ]
 
printfn "%d" a

Measured memory_bytes: 22332
#include <unistd.h>
#define IN_MAX 65536
#define OUT_MAX 65536
#define D_MAX 10
#define N_MAX 500000
#define Q_MAX 500000
char in_buf[IN_MAX];
char *in_ptr = in_buf, *in_end = in_buf + IN_MAX;
void read_stdin(void) {
	int k = read(0, (void *)in_buf, (size_t)IN_MAX);
	if(k < IN_MAX) {
		in_buf[k] = '\x00';
	}
	in_ptr = in_buf;
	return;
}
int read_int_plus(void) {
	int n = 0;
	while(*in_ptr >= '0' && *in_ptr <= '9') {
		n = n * 10 + (int)(*in_ptr++ - '0');
		if(in_ptr == in_end) {
			read_stdin();
		}
	}
	if(*in_ptr == '\n' || *in_ptr == ' ') {
		++in_ptr;
		if(in_ptr == in_end) {
			read_stdin();
		}
	}
	return n;
}
char out_buf[OUT_MAX];
char *out_ptr = out_buf, *out_end = out_buf + OUT_MAX;
void write_stdout(void) {
	write(1, (void *)out_buf, (size_t)(out_ptr - out_buf));
	out_ptr = out_buf;
	return;
}
void write_int_plus(int n) {
	int a[D_MAX + 1];
	int k = 0;
	while(n) {
		a[++k] = (char)(n % 10) + '0';
		n /= 10;
	}
	while(k) {
		*out_ptr++ = a[k--];
		if(out_ptr == out_end) {
			write_stdout();
		}
	}
	*out_ptr++ = '\n';
	if(out_ptr == out_end) {
		write_stdout();
	}
	return;
}
void add(int *a, int p, int x) {
	while(p <= *a) {
		a[p] += x;
		p += p & -p;
	}
	return;
}
int get(int *a, int p) {
	int s = 0;
	while(p) {
		s += a[p];
		p -= p & -p;
	}
	return s;
}
int main(int argc, char **argv) {
	read_stdin();
	int n, q;
	n = read_int_plus();
	q = read_int_plus();
	int c[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		c[i] = read_int_plus();
	}
	int first[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		first[i] = 0;
	}
	int next[Q_MAX + 1];
	int l[Q_MAX + 1];
	for(int i = 1; i <= q; ++i) {
		l[i] = read_int_plus();
		int r = read_int_plus();
		next[i] = first[r];
		first[r] = i;
	}
	int t[N_MAX + 1];
	t[0] = n;
	for(int i = 1; i <= n; ++i) {
		t[i] = 0;
	}
	int a[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		a[i] = 0;
	}
	int ans[Q_MAX + 1];
	for(int r = 1; r <= n; ++r) {
		if(a[c[r]]) {
			add(t, a[c[r]], -1);
		}
		add(t, r, 1);
		for(int i = first[r]; i; i = next[i]) {
			ans[i] = get(t, r) - get(t, l[i] - 1);
		}
		a[c[r]] = r;
	}
	for(int i = 1; i <= q; ++i) {
		write_int_plus(ans[i]);
	}
	write_stdout();
	return 0;
}

Measured memory_bytes: 17388
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(Scanner())
	w, _ := strconv.Atoi(Scanner())
	d, _ := strconv.Atoi(Scanner())
	n := h * w
	as := make([][]int, n)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			x, _ := strconv.Atoi(Scanner())
			as[x-1] = []int{i, j}
		}
	}
	list := make([][]int, d)
	for i := 0; i < d; i++ {
		x := make([]int, 1)
		for j := i; j < n-d; j += d {
			x = append(x, dist(as[j], as[j+d]))
		}
		for j := 1; j < len(x); j++ {
			x[j] = x[j-1] + x[j]
		}
		list[i] = x
	}
	q, _ := strconv.Atoi(Scanner())
	for i := 0; i < q; i++ {
		l, _ := strconv.Atoi(Scanner())
		r, _ := strconv.Atoi(Scanner())
		l--
		r--
		fmt.Println(list[r%d][r/d] - list[l%d][l/d])
	}
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func dist(x, y []int) int {
	return abs(x[0]-y[0]) + abs(x[1]-y[1])
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  string a; cin >> a;
  bool ans = false;
  if(a[0] == a[1] && a[1] == a[2] ) ans = true;
  if(a[1] == a[2] && a[2] == a[3] ) ans = true;
  
  cout << (ans ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 3624
h,w=map(int,input().split())
norow=set()
nocolumn=set()
s=[]
for i in range(h):
  a=input()
  s.append(a)
for i in range(h):
  flag=0
  for j in range(w):
    if s[i][j]=='#':
      flag=1
  if flag==0:
    norow.add(i)
for j in range(w):
  flag=0
  for i in range(h):
    if s[i][j]=='#':
      flag=1
  if flag==0:
    nocolumn.add(j)
for i in range(h):
  if i in norow:
    continue
  ans=[]
  for j in range(w):
    if j in nocolumn:
      continue
    ans.append(s[i][j])
  print(''.join(ans))

Measured memory_bytes: 67224
import java.util.Scanner;

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

        if (word.equals("A")) {
            System.out.print("T");
        } else if (word.equals("T")) {
            System.out.print("A");
        } else if (word.equals("C")) {
            System.out.print("G");
        } else if (word.equals("G")) {
            System.out.print("C");
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define TC int tt; cin >> tt; for(int t=0; t<tt; t++)
#define ll long long
#define pb push_back
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve()
{
    int a,k,i,j,n,sum=0,mx=0,ind,ct=1;
    cin >> n;
    if(n%1000) cout <<1000-n%1000<<endl;
    else cout <<0<<endl;
}
int  main()
{
//    Fast
//    Freed
//    Fout
 //   TC
        solve();
  return 0;
}


Measured memory_bytes: 3528
#include <stdio.h>
int main(void){
    int n,m,x,i,broken[100010]={0},dp[100010]={0};
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&x);
        broken[x]=1;
    }
    dp[n]=1;
    for(i=n-1;i>=0;i--){
        if(broken[i]==1) continue;
        dp[i] = (dp[i+1]+dp[i+2])%1000000007;
    }
    printf("%d",dp[0]);
}

Measured memory_bytes: 2516
dog, monkey = gets.chomp.split(" ").map(&:to_i)
sa = (dog - monkey).abs
a = 10 **9 + 7
dogs = (1..dog).inject{ |s,i| s * i % a}
monkeys  = (1..monkey).inject{ |s,i| s * i % a}

if  sa >= 2
	puts 0
elsif sa == 1
	puts dogs * monkeys % a
else
	puts (dogs * monkeys) * 2 % a
end

Measured memory_bytes: 1788
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	int sum = 0;
	for (int i = 5; i; i--)
		sum += max(40, in());
	out(sum / 5, '\n');
}


Measured memory_bytes: 2504
def kth_common_divisor(a, b, k):
    min_ = min(a, b)
    divisors = []

    for i in range(1, min_+1):
        if a % i == 0 and b % i == 0:
            divisors.append(i)

    return divisors[-k]


if __name__ == "__main__":
    a, b, k = map(int, input().split())
    print(kth_common_divisor(a, b, k))

Measured memory_bytes: 38256
#include <stdio.h>

int main()
{
    int i;
    int n, m;
    int count = 0, sum = 0;
    float popular;
    int a[1000];

    scanf("%d%d", &n, &m);

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

    popular = (float)sum / 4 / m;

    for (i = 0; i < n; i++) {
        if (a[i] >= popular) {
            count++;
        }
    }

    if (count >= m)
        printf("Yes\n");
    else 
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 1664
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#define waru 1000000000+7

using namespace std;

int main(){
    int k, x;
    cin >> k >> x;
    int hasi = x - (k-1);
    for(int i = 0; i < 2*k-1; i++){
        cout << hasi + i << " ";
    }

}

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    a[i]=0;
  }
  for(int i=0;i<n-1;i++){
    int m;
    cin>>m;
    a[m-1]++;
  }
  for(int i=0;i<n;i++){
    cout<<a[i]<<endl;
  }
}


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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;

int main()  {
    fast;
    int n;  cin>>n;
    int h[n],ans[n];
    fl(i,0,n)   cin>>h[i];
    ans[0]=0;   ans[1]=abs(h[1]-h[0]);
    fl(i,2,n)   ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
    cout<<ans[n-1];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

bool tile[20][20];
bool visited[20][20];

void visit(int x, int y) {
  visited[y][x] = true;
  if (x > 0 && tile[y][x-1] && !visited[y][x-1]) visit(x-1, y);
  if (x < 19 && tile[y][x+1] && !visited[y][x+1]) visit(x+1, y);
  if (y > 0 && tile[y-1][x] && !visited[y-1][x]) visit(x, y-1);
  if (y < 19 && tile[y+1][x] && !visited[y+1][x]) visit(x, y+1);
}

int main() {
  int w, h, x, y, count;
  string tmp;
  while (cin >> w >> h, w | h) {
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        visited[i][j] = false;
        tile[i][j] = false;
      }
    }
    for (int i = 0; i < h; i++) {
      cin >> tmp;
      for (int j = 0; j < w; j++) {
        if (tmp[j] == '.') {
          tile[i][j] = true;
        } else if (tmp[j] == '@') {
          x = j;
          y = i;
          tile[i][j] = true;
        }
      }
    }
    visit(x, y);
    count = 0;
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        if (visited[i][j]) count++;
      }
    }
    cout << count << el;
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

string r = "yuiophjklnm";

bool f(char a, char b)
{
	bool flga = 0, flgb = 0;
	REP(i, r.size())
	{
		if (a == r[i]) {
			flga = 1;
			break;
		}
	}
	REP(i, r.size())
	{
		if (b == r[i]) {
			flgb = 1;
			break;
		}
	}
	if (flga == flgb) {
		return 0;
	} else {
		return 1;
	}
}

int main()
{
	while (1) {
		cin >> s;
		if (s[0] == '#') {
			return 0;
		} else {
			cnt = 0;
			REP(i, s.size() - 1)
			{
				if (f(s[i], s[i + 1])) {
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3164
#include <cstdint>
#include <cstdio>
#include <algorithm>

const int N = 1e5 + 10;
int n, a[N];
int64_t ans = 1;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    a[n] = a[n + 1] = a[n + 2] = a[n + 3] = 0;
    std::sort(a, a + n + 4, [](const int &a, const int &b) {
        return a > b;
    });
    static int i = 0;
    while (true) {
        if (a[i] == a[i + 1])
            break;
        i++;
    }
    ans *= a[i];
    i += 2;
    while (true) {
        if (a[i] == a[i + 1])
            break;
        i++;
    }
    ans *= a[i];
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 512
#!/usr/bin/env python3
def main():
    N, Ma, Mb = map(int, input().split())
    a = [None] * N
    b = [None] * N
    c = [None] * N
    for i in range(N):
        a[i], b[i], c[i] = map(int, input().split())

    INF = 10**12
    dp = [[INF] * 401 for _ in range(401)]
    dp[0][0] = 0

    for i in range(N):
        for j in range(400,-1,-1):# 後ろから更新すること
            for k in range(400,-1,-1):
                if j - a[i] >= 0 and k - b[i] >= 0:
                    dp[j][k] = min(dp[j][k], dp[j-a[i]][k-b[i]]+c[i])
    
    ans = INF
    for j in range(400):
        for k in range(400):
            if j*Mb == k*Ma != 0:
                ans = min(ans,dp[j][k])
    print(ans) if ans < INF else print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 75300