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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()
#define pb(a) push_back(a)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;
constexpr int MAX = 200020;

void solve()
{
    int n;
    in(n);
    vl a(n), b(n), c(n);
    rep(i, n)
    {
        in(a[i]);
    }
    sort(all(a));
    rep(i, n)
    {
        in(b[i]);
    }
    rep(i, n)
    {
        in(c[i]);
    }
    sort(all(c));
    ll ans = 0;
    rep(i, n)
    {
        ll low = lower_bound(all(a), b[i]) - a.begin();
        ll up = c.end() - upper_bound(all(c), b[i]);
        ans += low * up;
    }
    out(ans);
}

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

Measured memory_bytes: 2560
def main():
    N, Y = map(int, input().split())
    YY = Y - N * 1000
    for x in range(0, int(YY/9000)+1):
        y = int((YY - x * 9000) / 4000)
        if (YY - x * 9000) % 4000 == 0 and x + y <= N:
            print(x, y, N - x - y)
            return
    print(-1, -1, -1)


if __name__ == '__main__':
    main()


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


int main(){
    long long n,m,k;
    cin>>n>>m>>k;
    vector<long long> a(n+1),b(m+1);
    for(int i=0;i<n;++i) cin>>a[i+1];
    for(int i=0;i<m;++i) cin>>b[i+1];
    
    for(int i=0;i<n;++i) a[i+1]+=a[i];
    for(int i=0;i<m;++i) b[i+1]+=b[i];

    long long ans=0;
    long long J=m;
    for(int i=0;i<=n;++i){
        long long rest=k-a[i];
        if(rest<0) break;
        for(int j=J;j>=0;--j){
            if(b[j]<=rest){
                ans=ans<i+j?i+j:ans;
                J=j;
                break;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6404
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] counter = new int[26];
        for(int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            counter[c - 'A']++;
        }
        int count = 0;
        for(int i = 0; i < 26; i++) {
            if(counter[i] == 2) count++;
        }
        if(count == 2) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

const ll MOD = 1e9+7;

int N;
vector<int> adj[100001];

// first : white, second : black
pll dfs(int p, int c) {
    pll res = {1, 1};
    repi(i, adj[c]) if (i != p) {
        pll r = dfs(c, i);
        res.fi = (res.fi*(r.fi+r.se))%MOD;
        res.se = (res.se*r.fi)%MOD;
    }
    return res;
}

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

    cin >> N;
    rep(i, N-1) {
        int a, b; cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    pll o = dfs(0, 1);
    cout << (o.fi+o.se)%MOD << endl;
}

Measured memory_bytes: 12672
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
for i in range(n):
    if a[i] < b[i]:
        x += (b[i] - a[i])//2
    else:
        x -= (a[i] - b[i])
if x < 0:
    print("No")
else:
    print("Yes")


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

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<int>> recording(c, vector<int>(100010, 0));
    rep(i, n) {
        int s, t, c;
        cin >> s >> t >> c;
        recording[c - 1][s]++;
        recording[c - 1][t + 1]--;
    }
    rep(i, c) {
        rep(j, 100009) {
            recording[i][j + 1] += recording[i][j];
        }
    }
    int ans = 0;
    rep(j, 100010) {
        int running = 0;
        rep(i, c) {
            if(recording[i][j]) running++;
        }
        ans = max(ans, running);
    }
    cout << ans << endl;
}


Measured memory_bytes: 12416
function Main(input){
	var inputs = input.split(' ');
  var N = Number(inputs[0]);
  var Y = Number(inputs[1]);
  var K = [];
  loop: for(var i=0;i<=N;i++){
    for(var j=0;j<=N-i;j++){
      var k=N-i-j;
      if((10000*i+5000*j+1000*k)==Y){
        K=i+' '+j+' '+k;
        break loop;
      }
    }
  }
  if(K==''){
    K='-1 -1 -1';
  }
  console.log(K);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    long A[N];
    for(int i=0; i<N; i++) cin >> A[i];
    long p[N], n[N];
    for(int i=0; i<N; i++){
        p[i] = i + A[i];
        n[i] = i - A[i];
    }
    long ans = 0;
    map<long, int> m;
    for(int i=0; i<N; i++){
        if(m.count(n[i]) != 0){
            ans += m.at(n[i]);
        }
        if(m.count(p[i]) == 0) m.insert({p[i], 1});
        else m.at(p[i])++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

int main(){
  int n=in(),k=in();
  vector<int> h(n);
    
  rep(i,n){
    cin>>h[i];
  }

  sort(all(h));
  int ans=INF;
  rep(i,n-k+1){
    ans=min(ans,h[i+k-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}

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

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

    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    if (N == 1)
    {
        cout << h[0] << endl;
        return 0;
    }

    // 先頭の0を削除
    int index = 0;
    for (int i = 0; i < h.size(); i++)
    {
        if (h[i] <= 0)
        {
            index++;
        }
        else
        {
            break;
        }
    }
    if (index > 0)
    {
        h.erase(h.begin(), h.begin() + index);
    }

    // 末尾の0を削除
    reverse(h.begin(), h.end());
    index = 0;
    for (int i = 0; i < h.size(); i++)
    {
        if (h[i] <= 0)
        {
            index++;
        }
        else
        {
            break;
        }
    }
    if (index > 0)
    {
        h.erase(h.begin(), h.begin() + index);
    }
    reverse(h.begin(), h.end());

    // for (int i = 0; i < h.size(); i++)
    // {
    //     cout << h[i] << ", ";
    // }
    // cout << endl;

    int ans = 0;
    while (h.size() > 0)
    {
        int block = 0;
        bool zero = false;
        for (int i = 0; i < h.size(); i++)
        {
            if (h[i] <= 0 && zero == false)
            {
                block++;
                zero = true;
            }
            else if (h[i] > 0)
            {
                h[i]--;
                zero = false;
            }
        }
        ans += block + 1;

        // 先頭の0を削除
        index = 0;
        for (int i = 0; i < h.size(); i++)
        {
            if (h[i] <= 0)
            {
                index++;
            }
            else
            {
                break;
            }
        }
        if (index > 0)
        {
            h.erase(h.begin(), h.begin() + index);
        }

        // 末尾の0を削除
        reverse(h.begin(), h.end());
        index = 0;
        for (int i = 0; i < h.size(); i++)
        {
            if (h[i] <= 0)
            {
                index++;
            }
            else
            {
                break;
            }
        }
        if (index > 0)
        {
            h.erase(h.begin(), h.begin() + index);
        }
        reverse(h.begin(), h.end());

        if (h.size() == 1)
        {
            ans += h[0];
            break;
        }

        // for (int i = 0; i < h.size(); i++)
        // {
        //     cout << h[i] << ", ";
        // }
        // cout << endl;
        // cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    k: usize,
    aa: [usize; n]
  }
  let mut win = vec![false; k+1];
  for i in 1 .. k + 1 {
    for &a in aa.iter() {
      if let Some(j) = i.checked_sub(a) {
        if ! win[j] {
          win[i] = true;
          break;
        }
      }
    }
  }
  println!("{}", if win[k] { "First" } else { "Second" });
}


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

int a[100], b[100], c[100], d[100];

int main(){
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < n; i++) {
    int mi = -1;
    int dm = 1e9;
    for (int j = 0; j < m; j++) {
      int dd = max(a[i] - c[j], c[j] - a[i]) + max(b[i] - d[j], d[j] - b[i]);
      if (dd < dm) {
        dm = dd;
        mi = j;
      }
    }
    cout << mi+1 << endl;
  }
  return 0;
}

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

int main() {
  string s = "";
  
  // ここにプログラムを追記
  for(int i = 0; i < 3; i++){
    string t;
    cin >> t;
    s += t.at(0);
}
  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char const *argv[]) {
  int n,m,t,i,j;

  scanf("%d %d", &n, &m);
  int a[100][100],b[100],ans[100];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  for (i = 0; i < n; i++) {
    t=0;
    for (j = 0; j < m; j++) {
      t=t+(a[i][j]*b[j]);
    }
    ans[i]=t;
  }
  for (i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

int main() {
    int a_h,a_a, b_h, b_a;

    cin >> a_h >> a_a >> b_h >> b_a;

    while( a_h > 0 || b_h > 0) {
        b_h -= a_a;
        if (b_h < 1) break;
        a_h -= b_a;
    }

    if (a_h > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<cctype>
#include<math.h>

using namespace std;

bool former_is_bigger(string a, string b){
    if(a.size() > b.size() || (a.size() == b.size() && a.compare(b) >= 1)){
        return true;
    } else {
        return false;
    }
}

int main(){
    while(1){
        int w, h;
        string dp[71][71];
        string map[71][71];
        
        cin >> w >> h;

        if(w==0) break;
        
        for(int i=0; i<h; ++i){
            string line;
            cin >> line;
            for(int j=0; j<w; ++j){
                map[i][j] = line.substr(j, 1);
            }
        }

        for(int i=0; i<71; ++i){
            for(int j=0; j<71; ++j){
                dp[i][j] = "";
            }
        }

        for(int i=h-1; i>=0; --i){
            for(int j=w-1; j>=0; --j){
                int copy_i;
                int copy_j;
                if(isdigit(map[i][j][0])){
                    if(former_is_bigger(dp[i+1][j],  dp[i][j+1])){
                        copy_i = i+1;
                        copy_j = j;
                    } else if(former_is_bigger(dp[i][j+1], dp[i+1][j])){
                        copy_i = i;
                        copy_j = j+1;
                    } else {
                        copy_i = i+1;
                        copy_j = j;
                    }
                    dp[i][j] = map[i][j] + dp[copy_i][copy_j];
                }
            }
        }
        /*
        for(int i=0; i<=h; i++){
            for(int j=0; j<=w; j++){
                cout << dp[i][j] << "   ";
            }
            cout << endl;
        }
        */

        string output = "";
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if(dp[i][j][0] != '0'){
                    if(former_is_bigger(dp[i][j], output)){
                        output = dp[i][j];
                    }
                }
            }
        }
        cout << output << endl;
    }
}

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

int main()
{
    set<int> S;
    int query;
    scanf("%d", &query);

    int comment, num;
    set<int>::iterator itr;
    for (int loop = 0; loop < query; loop++)
    {
        scanf("%d", &comment);
        switch (comment) {
        case 0:
            scanf("%d", &num);
            S.insert(num);
            printf("%d\n", S.size());
            break;
        case 1:
            scanf("%d", &num);
            itr = S.find(num);
            if (itr == S.end())
            {
                printf("%d\n", 0);
            }
            else
            {
                printf("%d\n", 1);
            }
            break;
        case 2:
            scanf("%d", &num);
            //itr = S.find(num);
            S.erase(num);
            break;
        default:
            break;
        }

    }
    return 0;
}



Measured memory_bytes: 12572
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	cin >> A >> B >> C >> D >> E;
	if(D > E){
		cout << min(A*D+B*E, min(2*C*E+A*(D-E), 2*C*max(D, E)));
	}else{
		cout << min(A*D+B*E, min(2*C*D+B*(E-D), 2*C*max(D, E)));
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int k,x;
  cin>>k>>x;
  int l,r;
  l = max(x-k+1,-1000000);
  r = min(x+k-1,1000000);
  for(int i=l;i<=r;i++){
    cout<<i<<' ';
  }
  cout<<endl;
  return 0;
}


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


int main(void) {
  int X;
  int max = 1;
  scanf("%d", &X);
  for (int i = 1; i < 32; i++) {
    for (int j = 2; j < 10; j++) {
      if (max <= pow(i, j) && pow(i, j) <= X) max = pow(i, j);
    }
  }
  printf("%d", max);
  return 0;
}


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

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

return 0;
}

Measured memory_bytes: 3592
using System;

public class Program
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var K = int.Parse(input[1]);
        var Q = int.Parse(input[2]);

        var seikai = new int[Q];
        var sankasha = new int[N];

        for (int i = 0; i < Q; i++)
        {
            seikai[i] = int.Parse(Console.ReadLine());
            sankasha[seikai[i] - 1]++;
        }

        for (int i = 0; i < sankasha.Length; i++)
        {
            sankasha[i] += (K - Q);
        }

        for (int i = 0; i < sankasha.Length; i++)
        {
            if (sankasha[i] > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

    }
}

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


int main()
{
    long long  h;
    cin >>h;
    long long ans=0;
    long long i=1;
    while(i <=h){
        
        ans*=2;
        ans++;
        i*=2;
    }

    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, m, c, pa[N];

int uni(int p) {
	if (pa[p] == p) return p;
	return pa[p] = uni(pa[p]);
}

int main()
{
	int i, t1, t2, x, y, z;
	cin >> n >> m;
	for (i = 1; i <= n; i++) pa[i] = i;
	c = n;
	while (m--) {
		scanf("%d %d %d", &x, &y, &z);
		t1 = uni(x); t2 = uni(y);
		if (t1 == t2) continue;
		pa[t1] = t2;
		c--;
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
K,N = map(int, input().split())
houses = list(map(int, input().split()))

distance = [houses[i+1] - houses[i] 
            if i != N-1 else abs(houses[0] - (houses[N-1] - K))
            for i in range(N)]

print(K-max(distance))

Measured memory_bytes: 26444
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] list = br.readLine().split(" ");
		int a = Integer.parseInt(list[0]);
		int b = Integer.parseInt(list[1]);
		if((a * b) % 2 == 0){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}
	}
}

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

typedef long long int ll;

void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
#define fioe() fileioe()
#else
#define fioe() 1
#endif

int main()
{
	GO
	//fioe();
	string s;
	cin>>s;
	bool A=0,B=0;
	for(ll i=0;i<3;i++){
		if(s[i]=='A')A=true;
		else B=true;
	}
	if(A&&B){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		var x int = i
		if x % 3 == 0 {
			fmt.Printf(" %d", i)
		} else {
			for ; x != 0; {
				if x % 10 == 3 {
					fmt.Printf(" %d", i)
					break
				}
				x /= 10
			}
		}
	}
	fmt.Println("")
}



Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
#define EPS (1e-8)
#define INF (1e8)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )

class Point{
public:
  double x, y;  
  Point (double x = 0, double y = 0): x(x), y(y){}
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
};
double norm(Point a){ return a.x*a.x + a.y*a.y; }
double abs(Point a){ return sqrt(norm(a)); }
double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }
double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double getDistanceLP(Point s1,Point s2,Point p){
  return abs(cross(s2-s1,p-s1)/abs(s2-s1));
}
double getDistanceSP(Point s1,Point s2,Point p){
  if(dot(s2-s1,p-s1)<0.0)return abs(p-s1);
  if(dot(s1-s2,p-s2)<0.0)return abs(p-s2);
  return getDistanceLP(s1,s2,p);
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw( Point p0, Point p1, Point p2 ){
  Point a = p1 - p0;
  Point b = p2 - p0;
  if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
  if ( cross(a, b) < -EPS ) return CLOCKWISE;
  if ( dot(a, b) < -EPS ) return ONLINE_BACK;
  if ( norm(a) < norm(b) ) return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool isIntersectSS(Point p1, Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <=0 &&
	  ccw(p3,p4,p1) * ccw(p3,p4,p2) <=0);
}

double getDistanceSS(Point s1,Point s2,Point t1,Point t2){
  if(isIntersectSS(s1,s2,t1,t2))return 0.0;
  return min(min(getDistanceSP(s1,s2,t1),getDistanceSP(s1,s2,t2)),
	     min(getDistanceSP(t1,t2,s1),getDistanceSP(t1,t2,s2)));
}

bool isOn(Point p,vector<Point> t){
  int size=t.size();
  for(int i=0;i<(int)t.size();i++)
    if(ccw(t[i],t[(i+1)%size],p)==COUNTER_CLOCKWISE)
      return false;
  return true;
}

double getD(Point s1,Point s2,vector<Point> t){
  if(isOn(s1,t)||isOn(s2,t))return 0;
  double res=INF;
  int size=t.size();
  for(int i=0;i<size;i++)
    res=min(res,getDistanceSS(s1,s2,t[i],t[(i+1)%size]));
  return res;
}

double calc(double dist,double h){
  if(dist<h)return dist;
  else return(dist*dist+h*h)/2.0/h;
}

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    Point si,ti;
    double ans=INF;
    cin>>si.x>>si.y>>ti.x>>ti.y;
    for(int i=0;i<n;i++){
      vector<Point> t(4);
      double h,dist,a,b,c,d;
      cin>>a>>b>>c>>d>>h;
      t[0]=Point(a,b);
      t[1]=Point(a,d);
      t[2]=Point(c,d);
      t[3]=Point(c,b);
      for(int j=0;j<4;j++){
	dist=getD(si,ti,t);
	//printf("%.8f %.8f %.8f\n",dist,h,calc(dist,h));
	ans=min(ans,calc(dist,h));
      }
    }
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1248
n,m = gets.split.map(&:to_i)
l,r= m.times.map{gets.split.map(&:to_i)}.transpose
if l.max>r.min
  puts 0
elsif n>r.min
  puts r.min-l.max+1
elsif n<l.max
  puts 0
else
  puts n-l.max+1
end

Measured memory_bytes: 11132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		
		int ans = 1;
		for(int i = 0;i < N;++i) {
			if(ans > K)
				ans += K;
			else
				ans *= 2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
    using namespace std;
    const int maxn = 1000 + 10;
     
    int n;
    int a[maxn];
    bool vis[maxn];
    queue<int> q[maxn];

    set<int> s;
    set<int>::iterator it;
     
    int tt = 0;

    int main()
    {

        ios::sync_with_stdio(false); cin.tie(false); cout.tie(false);
        cin>>n;

        for(int i=1;i<=n;i++){
            for(int j=1,x;j<n;j++){
                cin>>x;
                q[i].push(x);
            }
            s.insert(i);
        }
        int res = 0;
        while(s.size()){
            memset(vis,0,sizeof vis);
            bool f = false;
            int tot = 0;
            for(it=s.begin();it!=s.end();it++){
                tt++;
                if(vis[*it]) continue;
                if(q[*it].size()==0) continue;
                int to = q[*it].front();
                if(vis[to]) continue;
                if(q[to].front()==*it){
                    f = true;
                    q[*it].pop();
                    if(q[*it].size()==0) a[tot++] = *it;
                    vis[*it] = true;
                    q[to].pop();
                    if(q[to].size()==0) a[tot++] = to;
                    vis[to] = true;
                }
            }
            if(f==false){
                cout<<"-1"<<endl;
                return 0;
            }else{
                if(tt>=1e8) {
                    cout<<n*(n-1)/2<<endl;
                    return 0;
                }
                res += 1;
                if(tot>0){
                    for(int i=0;i<tot;i++){
                        s.erase(a[i]);
                    }
                }
            }
        }
        cout<<res<<endl;
        return 0;
    }

Measured memory_bytes: 4736
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}



int32_t SALI()
{
    int n,W; cin >> n >> W;
    int w[n];
    int v[n];
    int dp[W+1] = {0};
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
    for(int i = 0; i < n; i++){
        for(int j = W; j >= w[i]; j--){
            dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
        }
    }
    cout << dp[W] << endl;
}


/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 4360
import math
Time=[int(input()) for _ in range(5)]
amari=[math.ceil(Time[i]/10)*10 for i in range(5)]

last=min((Time[i]-1)%10 for i in range(5))
last+=1

print(amari[0]+amari[1]+amari[2]+amari[3]+amari[4]+last-10)

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

int judge(int x) {
  if (x <= 7) {
    if (x == 2) {
      x = 3;
    } else if (x % 2 == 0) {
      x = 2;
    } else {
      x = 1;
    }
  } else {
    if (x % 2 == 0) {
      x = 1;
    } else {
      x = 2;
    }
  }
  return x;
}
      
int main() {
  int x, y;
  cin >> x >> y;
  if (judge(x) == judge(y)) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  
  
      

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

map<string,int> dic;

void make_dic(){
  string buf;
  while(cin>>buf,buf!="END_OF_FIRST_PART"){
    int weight;
    cin>>weight;
    dic[buf]=weight;
  }
  return;
}

int get_num(int& p,string &s){
  int res=0;
  while(isdigit(s[p])){
    res*=10;
    res+=(s[p]-'0');
    p++;
  }
  return res;
}

int atom(int& p,string& s){
  string name="";
  name+=s[p];
  p++;
  while(p<s.size() && islower(s[p])){
    name+=s[p];
    p++;
  }
  if(!dic.count(name)) throw "UNKNOWN";
  return dic[name];
}

int weight(int& p,string& s){
  int res=0;
  while(p<s.size() && s[p]!=')'){
    if(s[p]=='('){
      assert(s[p]=='(');
      p++;
      int w=weight(p,s);
      assert(s[p]==')');
      p++;
      int rep=get_num(p,s);
      res+=(rep*w);
    }
    else{
      int w=atom(p,s);
      if(p<s.size() && isdigit(s[p])){
	int rep=get_num(p,s);
	res+=(rep*w);
      }
      else{
	res+=w;
      }
    }
  }
  return res;
}

int main(){
  make_dic();

  string buf;
  while(cin>>buf,buf!="0"){
    int p=0;
    int res;
    try{
      res=weight(p,buf);
    }catch(const char* ex){
      res=-1;
    }
    if(res==-1) cout<<"UNKNOWN"<<endl;
    else cout<<res<<endl;
  }
  
}

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

int W, H;
int Buildings[102][102] = {};
bool visible[102][102] = { false };

void visibilityDiffusion(int w, int h){
	if (w == 0 || h == 0 || w == W + 1 || h == H + 1) return;
	if (visible[w][h]) return;

	visible[w][h] = true;
	if (Buildings[w-1][h] == 0) visibilityDiffusion(w-1, h);
	if (Buildings[w+1][h] == 0) visibilityDiffusion(w+1, h);
	if (h % 2 == 1){
		// odd
		if (Buildings[w][h-1] == 0) visibilityDiffusion(w, h-1);
		if (Buildings[w][h+1] == 0) visibilityDiffusion(w, h+1);
		if (Buildings[w+1][h-1] == 0) visibilityDiffusion(w+1, h-1);
		if (Buildings[w+1][h+1] == 0) visibilityDiffusion(w+1, h+1);
	}
	else{
		// even
		if (Buildings[w-1][h-1] == 0) visibilityDiffusion(w-1, h-1);
		if (Buildings[w-1][h+1] == 0) visibilityDiffusion(w-1, h+1);
		if (Buildings[w][h-1] == 0) visibilityDiffusion(w, h-1);
		if (Buildings[w][h+1] == 0) visibilityDiffusion(w, h+1);
	}
}

int main(){
	cin >> W >> H;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			cin >> Buildings[j][i];
		}
	}

	// 建物がない場所のうち、外から見える部分を探索する
	for (int i = 1; i <= W; i++){
		if (Buildings[i][1] == 0) visibilityDiffusion(i, 1);
		if (Buildings[i][H] == 0) visibilityDiffusion(i, H);
	}
	for (int i = 1; i <= H; i++){
		if (Buildings[1][i] == 0) visibilityDiffusion(1, i);
		if (Buildings[W][i] == 0) visibilityDiffusion(W, i);
	}

	int ans = 0;
	int hole = 0;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			if (Buildings[j][i] == 1){
				ans += 6;
				if (Buildings[j + 1][i] == 1) ans -= 2;
				if (i % 2 == 1){
					// odd
					if (Buildings[j][i + 1] == 1) ans -= 2;
					if (Buildings[j + 1][i + 1] == 1) ans -= 2;
				}
				else{
					// even
					if (Buildings[j][i + 1] == 1) ans -= 2;
					if (Buildings[j - 1][i + 1] == 1) ans -= 2;
				}
			}
			else if (!visible[j][i]){
				hole += 6;
				if (Buildings[j + 1][i] == 0) hole -= 2;
				if (i % 2 == 1){
					// odd
					if (Buildings[j][i + 1] == 0) hole -= 2;
					if (Buildings[j + 1][i + 1] == 0) hole -= 2;
				}
				else{
					// even
					if (Buildings[j][i + 1] == 0) hole -= 2;
					if (Buildings[j - 1][i + 1] == 0) hole -= 2;
				}
			}
		}
	}

	cout << ans-hole << endl;
	return 0;
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,b,sum=0;
  long long ans1=0;
  cin>>n;
  int a[n];
  for (i = 0; i < n; i++) {
    cin>>a[i];
    a[i]-=i;
    sum+=a[i];
  }
  sort(a,a+n);
  /*if(n%2==0)b=(a[n/2]+a[(n/2)-1])/2;
  else */b=a[(n-1)/2];
  for (i = 0; i < n; i++) {
    ans1+=abs(a[i]-b);
  }
  cout<<ans1<<endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
s_list = []
t_list = []

for i in range(N):
  s, t = input().split()
  s_list.append(s)
  t_list.append(int(t))

x = input()

result = 0
for i in range(N):
  if s_list[i] == x:
    result = i

print(sum(t_list[result + 1::]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;cin>>N;
    int X;cin>>X;
    int count=0;
    vector<int> m(N);
    for(int i=0;i<N;i++){
        cin>>m[i];
        X=X-m[i];
        count++;
    }
    sort(m.begin(),m.end());
    while(X>=m[0]){
        X=X-m[0];
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto a = readln.chomp.map!(c => cast(int)(c-'0')).array;
  foreach (i; 0..1<<3) {
    auto r = a[0];
    foreach (j; 0..3)
      r += a[j+1] * (i.bitTest(j) ? 1 : -1);

    if (r == 7) {
      write(a[0]);
      foreach (j; 0..3)
        write(i.bitTest(j) ? "+" : "-", a[j+1]);
      writeln("=7");
      return;
    }
  }
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
    int w, a, b;
    scanf("%d %d %d", &w, &a, &b);
    if(a+w < b)
        printf("%d", b - a - w);
    else if(b >= a && b <= a + w)
        printf("0\n");
    else if(b <= a && a <= b + w)
        printf("0\n");
    else if(b + w < a)
        printf("%d\n", a - b - w);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int a,b;
	cin >> a >> b;
	if(b%a == 0) cout << a+b << endl;
	else cout << b-a << endl;
}

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

string str1,str2,str3;
int main(){
  int i=0,x;
  while(1)
  {
    cin>>str1;
    if(str1=="-") break;
    cin>>i;
    for(int i2=0;i2<i;i2++)
	{
        cin>>x;
	str2=str1.substr(0,x);
	str3=str1.substr(x,str1.size());
	str1=str3+str2;
	//str1.erase( str.begin() , str.begin()+x );
	}
    cout<<str1<<endl;
}
return 0;
}


Measured memory_bytes: 3208
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

C = ["s", "r", "p"]
Win = {"s": "r", "r": "p", "p": "s"}
Point = {"r": R, "p": P, "s": S}

Group = [[] for _ in range(K)]
for i in range(len(T)):
    Group[i % K].append(T[i])

res = 0
for g in Group:
    n = len(g)
    DP = [[0 for _ in range(3)] for _ in range(n + 1)]
    for index, tmp in enumerate(C):
        if Win[g[0]] == tmp:
            DP[0][index] += Point[tmp]
    for i in range(n - 1):
        for j, c in enumerate(C):
            p = 0
            if c == Win[g[i + 1]]:
                p = Point[c]
            if j == 0:
                DP[i + 1][j] = max(DP[i][1], DP[i][2]) + p
            elif j == 1:
                DP[i + 1][j] = max(DP[i][0], DP[i][2]) + p
            else:
                DP[i + 1][j] = max(DP[i][0], DP[i][1]) + p
    res += max(DP[n - 1][0], DP[n - 1][1], DP[n - 1][2])
    # for i in range(n):
    #     print(DP[i])
    # print("------------")

print(res)


Measured memory_bytes: 25604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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(){
    int N;
    cin>>N;
    while(N>0){
        N -= 1000;
    }
    cout << -N << endl;

    return 0;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N; cin >> N;
    string S; cin >> S;
    
    vector<ll> w(N, 0);
    {
        ll c = 0;
        REP(i, N) {
            w[i] = c;
            if (S[i] == 'W') c++;
        }
    }
    
    vector<ll> e(N, 0);
    {
        ll c = 0;
        RREP(i, N-1) {
            e[i] = c;
            if (S[i] == 'E') c++;
        }
    }
    
    ll ans = INF;
    REP(i, N) ans = min(ans, w[i] + e[i]);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5380
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int h, w;
vector<vector<int>> perm;

void dfs(vector<int> dat, int sz){
  if(sz==(h+1)/2) {
    perm.push_back(dat);
    return;
  }
  if(sz==0&&h%2==1){
    for(int i=0;i<h;i++){
      vector<int> tmp = dat;
      tmp[i] = h/2;
      dfs(tmp, sz+1);
    }
  }else{
    int f = -1;
    for(int i=0;i<h;i++){
      if(dat[i]==-1){
        f = i;
        break;
      }
    }
    for(int i=f+1;i<h;i++){
      if(dat[i]!=-1) continue;
      vector<int> tmp = dat;
      tmp[f] = tmp[i] = (sz - h%2);
      dfs(tmp, sz+1);
    }
  }
}
int main(int argc, char const *argv[]){
  scanf("%d %d", &h, &w);
  vector<string> s(h);
  for(int i=0;i<h;i++) std::cin >> s[i];
  dfs(vector<int>(h, -1), 0);

  for(int x=0;x<perm.size();x++){
    vector<int> v = perm[x];
    bool wo = (w%2==1);
    vector<string> row(w, string(h, '.'));
    for(int i=0;i<h;i++){
      if(row[0][v[i]]=='.'){
        for(int j=0;j<w;j++) row[j][v[i]] = s[i][j];
      }else{
        for(int j=0;j<w;j++) row[j][h-1-v[i]] = s[i][j];
      }
    }

    bool flag = true;
    vector<bool> use(w, false);
    for(int i=0;i<w;i++){
      int f = -1;
      for(int j=0;j<w;j++){
        if(!use[j]){
          f = j;
          break;
        }
      }
      if(f==-1) break;
      int p = -1;
      for(int j=f+1;j<w;j++){
        if(use[j]) continue;
        string t = row[j];
        reverse(all(t));
        if(t==row[f]){
          p = j;
          break;
        }
      }

      if(p==-1){
        string t = row[f];
        reverse(all(t));
        if(wo&&t==row[f]) {
          wo = false;
          use[f] = true;
        }else {
          flag = false;
        }
      }else{
        use[f] = use[p] = true;
      }
    }

    if(flag){
      std::cout << "YES" << '\n';
      exit(0);
    }
  }
  std::cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << x << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
    string rt[k+1];
    FORE(i,1,k){
        rt[i] = string(k+2,'z');
    }
    for(int i = 0; i < n;++i){
        string ss;
        for(int x = i; x < min(n, i+k+2); ++x){
            ss += s[x];
            FORE(i,1,k){
                if(ss == rt[i]) break;
                if(ss < rt[i]){
                    for(int j = k-1; j >= i;--j){
                        rt[j+1] = rt[j];
                    }
                    rt[i] = ss;
                    break;
                }
            }
        }
    }
    cout << rt[k] << '\n';
}



Measured memory_bytes: 384