akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  //ll ans;
  string S, T;
  cin >> A >> B >> C;
  cout << min(B/A, C) << endl;

  
  //cout << ans << endl;
  

}


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

int main() {
    string S;
    cin >> S;
    bool answer = true;
    for(int i=0;i<S.length()-1;i++){
        if(S[i] == S[i+1]){
            answer = false;
        }
    }
    if(answer){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    k, n = map(int, args[0].split())
    A = list(map(int, args[1].split()))

    D = [k-A[-1]+A[0]] + [A[i+1]-A[i] for i in range(n-1)]

    return str(k-max(D))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int N;
int a;

int main(){
	cin >> N;
	map<int,int> m;
	for(int i=0;i<N;i++){
		cin >> a;
		m[a]++;
	}
	int p = 0;
	for(auto i=m.begin();i!=m.end();i++){
		int u = i -> second;
		if(u%2==0) p++;
	}
	if(p%2==0) cout << m.size() << endl;
	else cout << m.size()-1 << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    int i,n;
    cin>>n;
    int x[n],y[n];
    for(i=0;i<n;i++)cin>>x[i]; 
    for(i=0;i<n;i++)cin>>y[i];
    double manhattan=0,euclidean2=0,euclidean3=0,chebyshev=0;
    for(i=0;i<n;i++){
        manhattan+=abs(x[i]-y[i]);
        if(chebyshev<abs(x[i]-y[i]))chebyshev=abs(x[i]-y[i]);
    }
    for(i=0;i<n;i++)euclidean2+=pow(abs(x[i]-y[i]),2);
    for(i=0;i<n;i++)euclidean3+=pow(abs(x[i]-y[i]),3);
    printf("%.5f\n%.5f\n%.5f\n%.5f\n",manhattan,sqrt(euclidean2),cbrt(euclidean3),chebyshev);
    return 0;
}



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

using namespace std;

int main() {
    int W, H, N;
    int x[100], y[100], a[100];
    int x_max_a1;
    int x_min_a2;
    int y_max_a3;
    int y_min_a4;
    int area;

    cin >> W >> H >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> a[i];
    }
    x_max_a1 = 0;
    x_min_a2 = W;
    y_max_a3 = 0;
    y_min_a4 = H;

    for (int i = 0; i < N; i++) {
        switch (a[i]) {
        case 1:
            if (x_max_a1 < x[i]) {
                x_max_a1 = x[i];
            }
            break;
        case 2:
            if (x_min_a2 > x[i]) {
                x_min_a2 = x[i];
            }
            break;
        case 3:
            if (y_max_a3 < y[i]) {
                y_max_a3 = y[i];
            }
            break;
        case 4:
            if (y_min_a4 > y[i]) {
                y_min_a4 = y[i];
            }
            break;
        }
    }

    if ( (x_min_a2 < x_max_a1) || (y_min_a4 < y_max_a3) ) {
        area = 0;
    } else {
        area = (x_min_a2 - x_max_a1) * (y_min_a4 - y_max_a3);
    }
    cout << area << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
int main() {
    int n; cin >> n;
    int dp[n + 1];
    //選択肢はある金額に1円たすか6^k円たすか、9^k円たすかしかない
    rep(i, n + 1) dp[i] = i;
    rep(i, n + 1) {
        int j = 6;
        while (i - j >= 0) {
            dp[i] = dp[i - j] + 1;
            j *= 6;
        }
        j = 9;
        while (i - j >= 0) {
            dp[i] = min(dp[i], dp[i - j] + 1);
            j *= 9;
        }
    }
    cout << dp[n] << endl;
    
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

int n, k;
vector<int> a;

bool works(int x){
    int left = k;
    for(int i = 0; i < n; ++i){
        int lo = 1;
        int hi = 1e9+5;
        int ans = -1;
        while(lo <= hi){
            int mid = (lo+hi)/2;
            if(a[i] <= (ll)mid*x){
                ans = mid;
                hi = mid-1;
            }
            else lo = mid+1;
        }
        left -= ans-1;
        if(left < 0) return false;
    }
    return true;
}

void solve(){
    cin >> n >> k;
    a = vector<int>(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    int lo = 1;
    int hi = 1e9+5;
    int ans = -1;
    while(lo <= hi){
        int mid = (lo+hi)/2;
        if(works(mid)){
            ans = mid;
            hi = mid-1;
        }
        else lo = mid+1;
    }
    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

void solve(long long N, long long X, long long M) {
    ll ans = 0;
    unordered_map<int, int> mp;
    ll num = X;
    int i = 0;
    while (i < N) {
        // cerr << "num=" << num << endl;
        if (mp.find(num) != mp.end()) {
            ll loupLen = i - mp[num];
            ll remain = N - i;
            ll loupVal = 0;
            ll tempVal = num;
            rep(i, loupLen) {
                loupVal += tempVal;
                tempVal *= tempVal;
                tempVal %= M;
            }
            ll nextLoup = remain / loupLen;
            ans += loupVal * nextLoup;
            remain %= loupLen;
            tempVal = num;
            rep(i, remain) {
                ans += tempVal;
                tempVal *= tempVal;
                tempVal %= M;
            }
            break;
        } else {
            mp[num] = i;
            ans += num;
            num *= num;
            num %= M;
            i++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    long long M;
    scanf("%lld", &M);
    solve(N, X, M);
    return 0;
}


Measured memory_bytes: 5344
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18



int main(){
    int P,Q,R; cin >> P >> Q >> R;
    int ans = min(P+Q,min(Q+R,R+P));
    cout << ans << endl;
}
  


  


Measured memory_bytes: 256
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();

    let s = get().as_bytes();
    let t = get().as_bytes();
    for i in 0..s.len() {
    	let mut f = true;
    	for j in 0..t.len() {
        	let i = (i + j) % s.len();
            if s[i] != t[j] {
            	f = false;
            }
        }
        if f {
        	println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int w,h;
int ls[55][55];
int alr[55][55];

void dfs(int a,int b){
	alr[a][b]=1;
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(i!=0||j!=0){
				if(a+i>=0&&a+i<h&&b+j>=0&&b+j<w){
					if(alr[a+i][b+j]==0&&ls[a+i][b+j]==1){
						dfs(a+i,b+j);
					}
				}
			}
		}
	}
	return;
}

int main(){
	while(1){
		cin>>w>>h;
		if(w==0&&h==0)break;
		for(int i=0;i<55;i++){
			for(int j=0;j<55;j++){
				alr[i][j]=0;
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>ls[i][j];
			}
		}
		int ans=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(alr[i][j]==0&&ls[i][j]==1){
					ans++;
					dfs(i,j);
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3252
N,K=map(int,input().split())
A=list(map(int,input().split()))
def warp(x,k):
    a=x
    for i in range(k):
        a=A[a-1]
    return a
count=[-1 for i in range(N)]
x=1
count[0]=0
time=0
if N>=K:
    print(warp(1,K))
else:
    for i in range(1,N+1):
        x=warp(x,1)
        if count[x-1]==-1:
            count[x-1]=i
        else:
            time=i-count[x-1]
            break;
    print(warp(1,count[x-1]+(K-count[x-1])%time))

Measured memory_bytes: 32268
<?php

$abk = explode(' ', trim(fgets(STDIN)));

$ab = [];
if ($abk[1]-$abk[0]+1 <= $abk[2]){
  for($i=0; $i<$abk[1]-$abk[0]+1; $i++){
    array_push($ab, $abk[0]+$i);
  }
} else {
  $a = $b = [];
  for($i=0; $i<$abk[2]; $i++){
    array_push($a, $abk[0]+$i);
    array_push($b, $abk[1]-$i);  
  }
  sort($b);
  $ab = array_values(array_unique(array_merge($a,$b)));
}
for($i=0; $i<count($ab); $i++){
  if ($i !== 0){
    echo "\n";
  }
  echo $ab[$i];
}

?>

Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int, int> P;
map<P, long long> m;
vector<P> place;
int D;
long long INF = 1e18;
int main(){
    int H, W;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int> (W));
    vector<P> place(H * W);
    for(int i= 0; i < H; i++){
        for(int j = 0; j < W; j++) {
            cin >> A[i][j];
            place[A[i][j] - 1] = P(i, j);
        }
    }
    vector<long long> vec[D];
    for(int i = 0; i < D; i++){
        long long t = i;
        long long res = 0;
        while(t + D <= H * W){
            vec[i].push_back(res);
            P v = place[t], u = place[t + D];
            t += D;
            res += abs(v.first - u.first) + abs(v.second - u.second);
        }
        vec[i].push_back(res);
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int L, R;
        cin >> L >> R;
        int s = R % D;
        long long ans;
        if(s != 0) ans = vec[s - 1][(R - s) / D] - vec[s - 1][(L - s) / D];
        else ans = vec[D - 1][(R - s) / D - 1] - vec[D - 1][(L - s) / D - 1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
    int n,k,ls;
    int sc=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>ls;
        if(ls>=k)
            sc++;
    }
    cout<<sc<<endl;



    return 0;
}


Measured memory_bytes: 256
s,n;main(i,j){
  for(;i=s=scanf("%d",&n)*n;printf("%d\n",s))
    for(;++i<=n*2;){
      //for(j=2;j*j<=i&&!(!(i%j++)&&s--););
      for(j=2;j*j<=i&&(i%j++?:!--s););
    }
}

Measured memory_bytes: 408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

typedef long long ll;

int main() {
  int a,b,c; cin >> a >> b >> c;
  if ( a+b == c || b+c == a || c+a == b ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#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
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  vector<int> a(5);
  rep(i,5){
    a.at(i)=i+1;
  }
  rep(i,5){
    int b;
    cin>>b;
    if(b!=a.at(i)){
      cout<<i+1<<endl;
      return 0;
    }
  }
}

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

using namespace std;
#define int long long
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define all(o) o.begin(), o.end()
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
inline int ad(int x,int y){
	x += y;
	if(x < mod) return x;
	return x - mod;
}
inline int mu(int x,int y){return 1LL * x * y % mod;}

int dp[2][maxn], ps[2][maxn];
void st(int idx,int i,int x){
	dp[idx][i] = x;
	ps[idx][i + 1] = ad(ps[idx][i], x);
}
int x[maxn];
int y[maxn];
main(){
	IOS;
	st(0, 0, 1);
	st(1, 0, 1);
	int n, A, B;
	cin >> n >> A >> B;
	if(A > B) swap(A, B);
	for(int i=0; i<n; i++)
		cin >> x[i];
	for(int i=0; i+2<n; i++){
		if(x[i + 2] - x[i] < A){
			cout << "0" << endl;
			return 0;
		}
	}
	for(int i=1; i<n; i++)
		y[i] = y[i - 1] + (x[i] - x[i - 1] < A);
	for(int i=1; i<n; i++){
		int pos = upper_bound(x, x + n, x[i] - B) - x;
		//cout << pos << " " << "POS" << endl;
		if(y[i - 1] - y[pos] > 0)
			st(1, i, 0);
		else{
			if(pos == 0) st(1, i, 1);
			if(pos != i) st(1, i, dp[0][pos]);
			else st(1, i, ad(dp[0][i - 1], dp[1][i - 1]));
		}
		if(x[i] - x[i - 1] >= A)
			st(0, i, ad(dp[0][i - 1], dp[1][i - 1]) );
		else
			st(0, i, dp[1][i - 1]);
		//cout << dp[0][i] << " ** " << dp[1][i] << endl;
	}
	cout << ad(dp[0][n - 1], dp[1][n - 1]) << endl;
}

Measured memory_bytes: 5120
# -*- using:utf-8 -*-

if __name__ == "__main__":
  s = list(input())
  sum = 0
  for i in range(3):
    if s[i] == 'R':
      sum = 1
  if s[0] == 'R' and s[1] =='R':
    sum += 1
  if s[1] == 'R' and s[2] == 'R':
    sum += 1
  print(sum)

Measured memory_bytes: 61652
<?php
  $HW = explode(" ",trim(fgets(STDIN)));
  $hw = explode(" ",trim(fgets(STDIN)));
  
  $H = $HW[0];
  $W = $HW[1];
  $h = $hw[0];
  $w = $hw[1];
  
  $ans = ($H - $h) * ($W - $w);
  echo $ans;

?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

//DP解法
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,X,Y;cin>>n>>X>>Y;
    vector<ll> a(n+1);
    rep(i,n) cin>>a[i+1];
    //dp[i][先手後手]=山札からi枚とったときの一番いい値
    //0を先手1を後手にする
    //0->最大値を更新，1->最小値を更新
    vector<vector<ll>> dp(n+1,vector<ll>(2));

    for(int i=n-1;i>=0;i--){
        ll y=(i==0?Y:a[i]);
        //yをi番目のカードにして残り全部とってゲームを終える
        dp[i][0]=abs(y-a[n]);
        //後手の未来のあらゆる最適から一番デカイのを選ぶ．
        for(int j=i+1;j<n;j++) chmax(dp[i][0],dp[j][1]);


        ll x=(i==0?X:a[i]);
        dp[i][1]=abs(x-a[n]);
        for(int j=i+1;j<n;j++) chmin(dp[i][1],dp[j][0]);
    }
    

    //dp[0][0]がゲーム開始時から未来を見たときの一番イイ値
    cout<<dp[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 1000001

int Partition(int, int );
int A[N];

int main(void){
int i,n,y;
 
 scanf("%d",&n);

 for(i=1;i<=n;i++){
   scanf("%d",&A[i]);

 }
 
 y=Partition(1,(n));
 
 for(i=1;i<n;i++){

   if (i==y){
     printf("[%d] ",A[i]);

   }

   else printf("%d ",A[i]);

 }
 
 printf("%d\n",A[n]);
 
 return 0;
 
}

int Partition(int p, int r){
  int i, j, x, k;
  
  x=A[r];
  i=p-1;

  for(j=p;j<=r-1;j++){

    if(A[j]<=x){

      i++;      
      k=A[i];
      A[i]=A[j];
      A[j]=k; 

    }

  }

  k=A[i+1];
  A[i + 1] = A[r];
  A[r]=k;

  return i+1;
  
}

Measured memory_bytes: 984
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1e9 + 7

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i%5 != 0 && i % 3 != 0) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 1e9+7;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e5;

 

 
int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	int n;
	cin>>n;
	int a[n+1];
	for(int i = 1; i<=n ; i++)
		cin>>a[i];
	int cur = 1;
	for(int i = 1; i<=n ; i++)
	{
		if(a[i] == cur)
			cur++;
	}
	cur = cur - 1;
	if(cur == 0)
		cout<<-1<<endl;
	else
	cout<< n - cur <<endl;
	return 0;
	
}

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

int main() {
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s == t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3576
import scala.collection.mutable

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()
    val G = Array.fill(N+1)(List[Int]())
    (0 until M) foreach { _ =>
      val u, v = sc.nextInt()
      G(u) ::= v
      G(v) ::= u
    }
    // 1からスタートして, dfsする
    // 今通過している頂点情報を持っておく,
    // 頂点数がNになった場合にはカウントを増やす
    // 頂点を複数回訪れることはOK
    // しかし, 辺は複数回訪れてはいけない
    // 辺を訪れたかどうかの情報を保持しておく

    def solve(N: Int, M: Int, G: Array[List[Int]]): Int = {
      val visiting = mutable.Set[Int]()
      @scala.annotation.tailrec
      def dfs(stack: List[(Int, Int)], count: Int): Int =
        if (stack.nonEmpty) {
          val (t, u) = stack.head
          if (u < 0) {
            visiting -= -u
            dfs(stack.tail, count)
          } else {
            visiting += u
            if (visiting.size >= N) {
              visiting -= u
              dfs(stack.tail, count + 1)
            } else {
              dfs(G(u).foldLeft((t, -u) :: stack.tail)(
                (b, v) => if (!visiting.contains(v)) (u, v) :: b else b), count)
            }
          }
        } else count

      dfs((1, 1) :: Nil, 0)
    }

    println(solve(N, M, G))
  }

}


Measured memory_bytes: 30144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	bool yes = false;
	if (N[0] == N[1]) {
		yes = true;
	}
	if (N[1] == N[2]) {
		yes = true;
	}
	if (N[2] == N[3]) {
		yes = true;
	}

	if (yes == true) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long a,b;
	char p;
	cin >> a >> p >> b;
	if(p == '+')
	    {
	    	cout << a + b << endl;
		}
		else
		    {
		    	cout << a - b << endl;
			}
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector <PII> num;
    rep(i,n){
      int x;
      cin >> x;
      num.push_back(make_pair( x , i ));
    }
    sort(all(num));
    // rep(i,n){
    //   cout << num[i].first << ":" << num[i].second << endl;
    // }
    int cnt = 1;
    int maxCnt = 1;
    rep(i,n-1){
      if(num[i].second < num[i+1].second){
        cnt++;
      }else{
        maxCnt = max(maxCnt,cnt);
        cnt = 1;
      }
    }
    maxCnt = max(maxCnt,cnt);
    cout << n - maxCnt  << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
// Example program
#include<iostream>
using namespace std;
 
int main (){
  int  a;
  int  b;
  
  cin >> a >> b;
  
  cout << a/b << " "  << a%b ;
  printf(" %.5f\n", 1.0*a/b ); 
}


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

int main() { 
    int N, M;
    cin >> N >> M;
    vector<bool> issafe;
    issafe.assign(N+1, true);
    for (int i=1; i<M+1; i++) {
        int a;
        cin >> a;
        issafe[a] = false;
    }

    vector<int> dp;
    dp.assign(N+1, 0);

    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;


    for (int i=2; i<=N; i++) {
        if (issafe[i-1]) dp[i] += dp[i-1];
        if (issafe[i-2]) dp[i] += dp[i-2];
        dp[i] %= 1000000007;
    }

    cout << dp[N] << endl;
    
    return 0;
}

Measured memory_bytes: 640
A, B = map(int, input().split())

if A > 1 and B > 1:
  if A < B:
    print("Bob")
  elif A > B:
    print("Alice")
  elif A == B:
    print("Draw")
elif A == 1 and B != 1:
  print("Alice")
elif B == 1 and A != 1:
  print("Bob")
elif A == B:
  print("Draw")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int n;    
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    
    if (d[n/2-1] == d[n/2]) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    int tmp = d[n/2];
    while (tmp != d[n/2-1]) {
        ans++;
        tmp--;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  ll n, m;
  cin >> n >> m;

  ll bi, ci;
  vector<ll> a(m);
  vector<ll> c(m, 0);

  for (ll i = 0; i < m; i++) {
    cin >> a[i] >> bi;
    for (ll j = 0; j < bi; j++) {
      cin >> ci;
      c[i] += 1 << (ci - 1);
    }
  }
  
  ll jmax = 1;
  for (ll i = 0; i < n; i++) {
    jmax *= 2;
  }

  // cout << jmax << endl;

  // for (ll i = 0; i < m; i++) {
  //   cout << c[i] << endl;
  // }

  vector<vector<ll>> dp(m + 1, vector<ll>(jmax, -1));

  for (ll i = 0; i <= m; i++) {
    dp[i][0] = 0;
  }

  for (ll i = 1; i <= m; i++) {
    for (ll j = 0; j < jmax; j++) {
      dp[i][j] = dp[i - 1][j];
    }
    for (ll j = 0; j < jmax; j++) {
      if (dp[i - 1][j | c[i - 1]] != -1 && dp[i - 1][j] == -1) {
        if (dp[i][j | c[i - 1]] != -1) {
          dp[i][j | c[i - 1]] = min(dp[i][j | c[i - 1]], dp[i - 1][j | c[i - 1]]);
        } else {
          dp[i][j | c[i - 1]] = dp[i - 1][j | c[i - 1]];
        }

      } else if (dp[i - 1][j | c[i - 1]] == -1 && dp[i - 1][j] != -1) {
        if (dp[i][j | c[i - 1]] != -1) {
          dp[i][j | c[i - 1]] = min(dp[i][j | c[i - 1]], dp[i - 1][j] + a[i - 1]);
        } else {
          dp[i][j | c[i - 1]] = dp[i - 1][j] + a[i - 1];
        }

      } else if (dp[i - 1][j | c[i - 1]] != -1 && dp[i - 1][j] != -1) {
        if (dp[i][j | c[i - 1]] != -1) {
          dp[i][j | c[i - 1]] = min(dp[i][j | c[i - 1]], min(dp[i - 1][j | c[i - 1]], dp[i - 1][j] + a[i - 1]));
        } else {
          dp[i][j | c[i - 1]] = min(dp[i - 1][j | c[i - 1]], dp[i - 1][j] + a[i - 1]);
        }
      }
    }
  }

  // for (ll i = 0; i <= m; i++) {
  //   for (ll j = 0; j < jmax; j++) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  cout << dp[m][jmax - 1] << endl;
}


Measured memory_bytes: 32384
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
using namespace std;
 
int main(){
  int A, B, C;
  cin >> A >> B >> C;

  int _max = max(max(A, B), C);
  if(_max == A){
    cout << _max * 10 + B + C << endl;
  }else if(_max == B){
    cout << _max * 10 + A + C << endl;
  }else{
    cout << _max * 10 + A + B << endl;
  }

  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut pv = vec![0i32; n];
    for i in 0..n - 1 {
        pv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    pv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut qv = pv.clone();
    qv.sort();
    let mut count = 0;
    for i in 0..n {
        if pv[i] != qv[i] {
            count += 1;
        }
    }
    let ans = if count == 0 || count == 2 {
        "YES"
    } else {
        "NO"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
def solve():
    N, M = map(int, input().split())
    contains_redball = [False] * N
    contains_redball[0] = True
    balls_cnt = [1] * N
    for _ in range(M):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        balls_cnt[x] -= 1
        balls_cnt[y] += 1
        if contains_redball[x]:
            contains_redball[y] = True
        if balls_cnt[x] == 0:
            contains_redball[x] = False
    print(sum(contains_redball))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 10396
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
A = [lr() for _ in range(H)]
answer = []
for i in range(H):
    for j in range(W-1):
        if A[i][j]&1:
            answer.append((i+1, j+1, i+1, j+2))
            A[i][j+1] += 1

for i in range(H-1):
    if A[i][-1]&1:
        answer.append((i+1, W, i+2, W))
        A[i+1][-1] += 1

print(len(answer))
for a in answer:
    print(*a)


Measured memory_bytes: 26724
#include <stdio.h>

int main()
{
    char s[4];
    int i;
    scanf("%s", s);

    for(i=0; i<3; i++)
    {
        if(s[i] == '7') break;
    }
    if(i < 3) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    vector<ll> vec(n);
    rep(i,n) cin>>vec[i];
    sort(all(vec));
    ll ans = 0;
    rep(i,n) repl(j,i+1,n){
        auto it = upper_bound(vec.begin(),vec.end(),vec[i]+vec[j]-1);
        // cout<<it - vec.begin()<<" "<<vec[i]<<" "<<vec[j]<<endl;
        ans += (it - vec.begin()) - j - 1;
        // cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9 + 7;

long long n, a, b, sum, mn = inf;

main()
{
    cin >> n;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a >> b;
        sum += a;
        if( a > b )
            mn = min( mn, b );
    }
    if( mn == inf )
        sum = inf;
    cout << sum - mn;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  bool f = false;
  int k, a, b;
  cin >> k >> a >> b;
  REP(i, 1000000) {
    if (a <= i * k && i * k <= b) f = true;
  }
  if (f)
    cout << "OK"
         << "\n";
  else
    cout << "NG"
         << "\n";
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<ll>(a, b)(g1);}

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);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

//ll fmul(ll a, ll b, ll mod){ll res=0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
//ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
//inline bool rabbin_miller(ll x){if(x%2==0) return false;for(int i=0;i<5;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

ll A,B,res=1;

ll fmul(ll a, ll b, ll mod){ll res = 0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
bool prim(ll x){if(x==2||x==3)return true;if(x%2==0)return false;for(int i=0;i<30;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

int main(){
	scanf("%lld %lld",&A,&B);
	ll gg = __gcd(A,B);
	for(ll i=2; i<=sqrt(gg); i++){
		if(gg%i == 0){
			if(prim(i))
				res++;
			if(i*i != gg && prim(gg/i))
				res++;
		}
	}
	if(prim(gg) && gg != 1) res++;
	printf("%lld\n",res);
}

Measured memory_bytes: 256
// AOJ ALDS1_6_B Partition
// 2018.5.1 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int partition(int *a, int lo, int hi)
{
	int i, j, x, t;

	x = a[hi], i = lo-1;
	for (j = lo; j < hi; j++) {
		if (a[j] <= x) i++, t = a[i], a[i] = a[j], a[j] = t;
	}
	t = a[++i], a[i] = a[hi], a[hi] = t;
	return i;
}

int a[100002];

int main()
{
	int n, i, k;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();
	k = partition(a, 0, n-1);
	printf((!k? "[%d]": "%d"), a[0]);
	for (i = 1; i < n; i++) {
		putchar(' ');
		printf((k==i? "[%d]": "%d"), a[i]);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

int main() {
  int m, n1, n2;
  while(cin >> m >> n1 >> n2){
    if(m==0) return 0;
    vector<int> v(m);
    rep(i, m) cin >> v[i];
    sort(v.begin(), v.end(), greater<int>());
    int gap=0, ans;
    REP(i, n1-1, n2){
      int t = v[i]-v[i+1];
      if(gap<=t){
        gap = t;
        ans = i+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int a[100010];

int main() {
    int n;
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
    }
    map<int, int>cnt;

    int res=1;
    for (int i = 0; i < n; i++) {
        cnt[a[i]]++;
        if(cnt[a[i]]>=3||(n%2&&cnt[0]>=2)){
            cout<<0<<endl;
            return 0;
        }
    }
    for (int i = 0; i < n/2; i++) {
        (res*=2)%=MOD;
    }

    cout<<res<<endl;

    return 0;
}

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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

	int n;
	cin >> n;
	int ans = 1000;
	for(int i=1;i<=100;i++)
	{
		if(ans*i>=n)
		{
			cout << ans*i -  n;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 5480
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};



long long modpow(long long a, long long n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}

mint comb(int n,int k){
    if(n-k<k) k=n-k;
    mint res1=1,res2=1;
    rep(i,k){
        res1*=(n-i);
        res2*=(i+1);
    }
    return res1/res2;
}
int main() {
    int n,a,b;cin>>n>>a>>b;
    mint res=-1;
    res+=modpow(2,n);
    res-=comb(n,a)+comb(n,b);
    cout<<res.x<<endl;
}

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

int main() {
  int N;
  int64_t sum = 0;
  int max = -1000000;
  int min =  1000000;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (max < x) max = x;
    if (min > x) min = x;
    sum += x;
  }

  cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3116
#include<iostream>
using namespace std;
typedef long long int ll;
static const ll MOD = 1000000007;

ll mod_pow(ll n, ll x){
	if(n == 0) return 1;
	ll ret = mod_pow(n / 2, x) * mod_pow(n / 2, x) % MOD;
	if(n % 2) return ret * x % MOD;
	return ret;
}

int main(){
	int n, k;
	cin >> n >> k;
	cout << mod_pow((ll)n, (ll)k) << endl;
	return 0;
}



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

int main(){
    int a,b,c;
    string o;

    for (;;){
        cin >> a >> b >> c;
        if (a==-1 && b==-1 && c==-1)break;
        if (a==-1 || b==-1){
            o="F";
        }else if((a+b)>=80){
            o="A";
        }else if((a+b)>=65 && (a+b) < 80){
            o="B";
        }else if((a+b)>=50 && (a+b) < 65){
            o="C";
        }else if((a+b)>=30 && (a+b) < 50){
            o="D";
            if (c>=50)o="C";
        }else if((a+b)<30 ){
            o="F";
        }
        cout << o << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3160
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

cnt = 0

for i in range(n):
    res = c
    for j in range(m):
        res += a[i][j]*b[j]
    if res > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String str = stdR.readLine();
        int R = 0;
        int B = 0;
        for(int i = 0 ; i < str.length(); i++) {
            if(str.charAt(i) == 'R') {
                R++;
            }else {
                B++;
            }
        }
        if(R > B) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24532
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string A, B;
  cin >> A >> B;
  if(A.size() > B.size()){
    cout << "GREATER" << endl;
    return 0;
  }
  if(A.size() < B.size()){
    cout << "LESS" << endl;
    return 0;
  }
  if(A == B){
    cout << "EQUAL" << endl;
    return 0;
  }
  for(int i = 0; i < A.size(); i++){
    if(A[i] > B[i]){
      cout << "GREATER" << endl;
      return 0;
    }
    if(A[i] < B[i]){
      cout << "LESS" << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    static void divmod (int[] vi, int a, int b) {
        int q;
        int r;
        if (b < 0) {
            b = -b;
            a = -a;
        }
        q = 0;
        r = a;
        if (r > 0) {
            while (r - b >= 0) {
                q += 1;
                r -= b;
            }
        } else if (r < 0) {
            do {
                q -= 1;
                r += b;
            } while (r < 0);
        }
        vi[0] = q;
        vi[1] = r;
    }
    public static void main (String[] args) throws IOException {
        final String s;
        try (BufferedReader reader =
                 new BufferedReader (new InputStreamReader (System.in))) {
            s = reader.readLine();
        }
        int[] vi           = new int[2];
        int           N    = Integer.parseInt (s);
        StringBuilder sb   = new StringBuilder();
        int           base = 2;
        while (0 != N) {
            // base = 3 でうまくいかない
            // 例えば 7
            // base = 2 は OK
            // sb.insert (0, String.valueOf (Math.abs (N % base)));
            // N -= Math.abs (N % base);
            // N /= -base;

            // base = 3 でもうまくいく
            divmod (vi, N, base);
            sb.insert (0, String.valueOf (vi[1]));
            N -= vi[1];
            divmod (vi, N, -base);
            N = vi[0];
        }
        if (sb.length() == 0) sb.append ("0");
        System.out.println (sb);
    }
}


Measured memory_bytes: 23252