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

int main() {
  string s;
  int ans = 7;
  cin >> s;
  if (s == "SAT") {
    ans = 1;
  }else if (s == "FRI") {
    ans = 2;
  }else if (s == "THU") {
    ans = 3;
  }else if (s == "WED") {
    ans = 4;
  }else if (s == "TUE") {
    ans = 5;
  }else if (s == "MON") {
    ans = 6;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX_V 100010

using namespace std;
struct edge{int to,cost; };
vector<edge> G[MAX_V];

bool used[MAX_V];
int d[MAX_V],f[MAX_V];
int V,E;

void dfs(int s){
	used[s] = true;
	int i = 0;
	while(true){
		edge e = G[s][i];
		if(e.to==-1){
			break;
		}
		i++;
		if(!used[e.to]){
			d[e.to] = d[s]+e.cost;
			dfs(e.to);
		}
	}
}

int main(){
	int i,c=0;
	cin >> V;
	E = V-1;
	for(i=0;i<E;i++){
		int s,t;
		cin >> s >> t;
		s--; t--;
		edge e;
		e.to = t;
		e.cost = 1;
		G[s].push_back(e);
		e.to = s;
		e.cost = 1;
		G[t].push_back(e);
	}
	for(i=0;i<V;i++){
		edge e;
		e.to = -1; e.cost = 0;
		G[i].push_back(e);
		used[i] = false;
	}
	
	d[0] = 0;
	dfs(0);
	for(i=0;i<V;i++){
		f[i] = d[i];
		used[i] = false;
	}
	d[V-1] = 0;
	dfs(V-1);
	for(i=0;i<V;i++){
		if(f[i]<=d[i]){
			c++;
		}
	}
	if(c>V/2){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}
}
	




Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<int> a(n);
        rep(i,n) cin >>a[i];

        int ans = 19191919;
        rep(i,n)rep(j,i) ans = min(ans,abs(a[i]-a[j]));
        cout << ans << endl;
    }
    return 0;
}

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

int saidaikoyakusu(int a,int b){
  int saidai = 0;
  if(b == 0){
    saidai = a;
    return saidai;
  }

  int amari;
  if(a >= b){
    amari = a % b;
    saidai += saidaikoyakusu(b,amari);
  }
  else{
    amari = b % a;
    saidai += saidaikoyakusu(a,amari);
  }
  return saidai;
}



int gcd(int a,int b,int c){
  //ベースケース
  int koyaku;
  int maxkoyaku = 1;
  koyaku = saidaikoyakusu(a,b);
  maxkoyaku = saidaikoyakusu(koyaku,c);
  return maxkoyaku;
}



int main()
{
  int k;
  cin >> k;
  int sum = 0;
  for(int i = 1;i <= k;i++){
    for(int j = 1;j <= k;j++){
      for(int l = 1;l <= k;l++){
        sum += gcd(i,j,l);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

typedef int64_t s64;

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int dp[2][101][256];
int main() {
	int n = ri();
	int k = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	dp[0][0][0] = 1;
	dp[0][1][a[0]] = 1;
	for (int i = 0; i < n - 1; i++) {
		memset(dp[(i+1)%2], 0x00, sizeof(int) * 101 * 256);
		int x = a[i+1];
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k < 256; k++) {
				dp[i&1^1][j][k] += dp[i&1][j][k];
				if (dp[i&1^1][j][k] >= 1000000007)
					dp[i&1^1][j][k] -= 1000000007;
				dp[i&1^1][j+1][k^x] += dp[i&1][j][k];
				if (dp[i&1^1][j+1][k^x] >= 1000000007)
					dp[i&1^1][j+1][k^x] -= 1000000007;
			}
		}
	}
	int fact[101];
	fact[1] = 1;
	for (int i = 2; i <= 100; i++) fact[i] = fact[i-1] * ((s64)i) % 1000000007;
	int res = 0;
	for (int i = 1; i <= 100; i++) {
		res = (res + ((s64)dp[n&1^1][i][k]) * fact[i]) % 1000000007;
	}
	std::cout << res << std::endl;
		
	return 0;
}


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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

ll n;
string s;
// *********************************************************
int main(){

    cin >>  s ;

    int ans=0;
    ll sz = s.size();
    for(ll i=0; i<s.size(); ++i){
        int num = s[i]-'0';
        ans += num;
        ans %= 9;
    }
    


/*
    if(n==0){
        cout <<"Yes"<<endl;
        return 0;
    }

    int ans=0;
    for(;n>0;){
        ans += n%10;
        ans = ans%9;
        n=n/10;
    }
*/
    if(ans==0){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 3720
using System;

class Node{
  public int key;
  public int parent;
  public int left;
  public int right;
}

class A9{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    Node[] node = new Node[n + 1];
    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    for(int i = 1;i <= n;i++){
      node[i] = new Node();
    }
    for(int i = 0;i < n;i++){
      node[i + 1].key = input[i];
    }

    for(int i = 1;i <= n;i++){
      Console.Write("node " + i + ": key = " + node[i].key + ", ");
      if(i / 2 > 0){
        node[i].parent = node[i / 2].key;
        Console.Write("parent key = " + node[i].parent + ", ");
      }
      if(2 * i <= n){
        node[i].left = node[i * 2].key;
        Console.Write("left key = " + node[i].left + ", ");
      }
      if(2 * i + 1 <= n){
        node[i].right = node[2 * i + 1].key;
        Console.Write("right key = " + node[i].right + ", ");
      }
      Console.WriteLine();
    }
  }
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, N; cin >> H >> N;
    int atk = 0;
    rep(i, N){
        int a; cin >> a;
        atk += a;
    }
    if(atk >= H) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace kyoupuro1
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var ps = GetPNLs(N);
            var sisuu = new int[ps.Count()];

            for (int m = 1; m <= N; m++)
            {
                for (int i = 0; i < ps.Count; i++)
                {
                    sisuu[i] += E(ps[i], m);
                }
            }
            int dob = sisuu.Count(x => x >= 2);
            int f = sisuu.Count(x => x >= 4);
            int ft = sisuu.Count(x => x >= 14);
            int tf = sisuu.Count(x => x >= 24);
            int sf = sisuu.Count(x => x >= 74);

            int res =
                C(f, 2) * A(dob - 2)
                + tf * A(dob - 1)
                + sf
                + ft * A(f - 1);
            Console.WriteLine(res);
        }

        static int A(int x)
        {
            if (x < 0) return 0;
            else return x;
        }

        static List<int> GetPNLs(int max)
        {
            List<int> prime = new List<int>();
            if (max <= 1) return new List<int> {2};
            for (int i = 2; i <= max; i++)
            {
                bool isPrime = true;
                foreach (var p in prime)
                {
                    if (i % p == 0 && i != p)
                    {
                        isPrime = false;
                        break;
                    }
                }
                if (isPrime) prime.Add(i);
            }
            return prime;
        }

        static int E(int prime, int n)
        {
            int k = n;
            int c = 0;
            while (k % prime == 0)
            {
                k = k / prime;
                c++;
            }
            return c;
        }

        static int C(int a, int b)
        {
            if (a < b) return 0;
            return F(a) / (F(b) * F(a - b));
        }

        static int F(int n)
        {
            if (n > 1)
                return F(n - 1) * n;
            else
                return 1;
        }
    }
}


Measured memory_bytes: 13268
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  st s = tos(N);
  int a = 0, c = 0;
  rep(i, sz(s)){
    c += s.at(i) - 48;
  }
  if(N % c == 0){
    co("Yes");
  }
  else{
    co("No");
  }
}


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

using namespace std;

const int N = 1e6 + 5;

int main() {
	string a[3];
	int pos[3] = {0};
	cin >> a[0] >> a[1] >> a[2];
	int ind = 0;
	while (pos[ind] != a[ind].size()) {
		char c = a[ind][ pos[ind] ];
		pos[ind] ++;
		ind = c - 'a';
	}
	char ans = ind + 'a';
	ans = toupper(ans);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;
    n--;
    
    int c[n], s[n], f[n];
    for (int i = 0; i < n; i++)
        cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n; i++) {
        int cur = 0;

        for (int j = i; j < n; j++) {
            if (cur < s[j])
                cur = s[j];
            else
                cur = (cur+f[j]-1)/f[j] * f[j];
            cur += c[j];
        }

        cout << cur << endl;
    }
    
    cout << "0" << endl;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    string s; cin >> s;
    string t; cin >> t;
    ll n; cin >> n;
    ll m; cin >> m;
    string u; cin >> u;

    if(u == s) cout << n-1 << " " << m;
    else cout << n << " " << m-1;
}

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

using namespace std;

typedef long long ll;



int main(){

    int n,m;

    cin >> n >> m;



    vector<vector<int>> s(m);



    for(int i = 0; i < m; i++){

        int k;

        cin >> k;

        for(int j = 0; j < k; j++){

            int sw;

            cin >> sw;

            sw--;

            s[i].push_back(sw);

        }

    }



    vector<int> p(m);

    for(int i = 0; i < m; i++)

        cin >> p[i];

    

    ll ans = 0;

    for(int bit = 0; bit < (1 << n); bit++){

        bool flag = true;

        for(int i = 0; i < m; i++){

            int cnt = 0;

            for(auto v : s[i]){

                if(bit & (1 << v))

                    cnt++;

            } 

            if(cnt % 2 != p[i])

                flag = false;

        }

        if(flag)

            ans++;

    }



    cout << ans << endl;



    return 0;

}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int n,m,x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> v(n,vector<int>(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> v[i][j];
  }
  
  int ans = -1;
  rep(bit,1<<n){
    vector<int>a(m); int ci = 0;
    rep(i,n) if((bit>>i)&1) {
      rep(j,m) a[j] += v[i][j];
      ci += c[i];
    }
    bool ok = true;
    rep(i,m) if(a[i]<x){
      ok = false;
      break;
    }
    if(ok){
      if(ans == -1) ans = ci;
      else ans = min(ans,ci);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c0=0,c1=0;
  vector<int> a;
  cin>>n;
  for(int i=0,b;i<n;i++){
    cin>>b;
    if(b==0)c0++;
    else if(b==1)c1++;
    else a.push_back(b);
  }
  sort(a.begin(),a.end());
  int f=0;
  if(c0%2==1&&c1==0&&a.size()){
    a.push_back(a[0]);
    a.erase(a.begin());
    f=1;
    c0--;
  }
  if(a.size()-f>=2&&a[a.size()-f-1]==3&&a[a.size()-f-2]==2)swap(a[a.size()-f-1],a[a.size()-f-2]);
  for(int i=0;i<(int)a.size()-f;i++){
    cout<<a[i]<<endl;
  }
  if(c0%2==1&&c1){
    f=2;
    c0--,c1--;
  } 
  for(int i=0;i<c0;i++)cout<<0<<endl;
  if(f==1)cout<<a[a.size()-1]<<endl<<0<<endl;
  if(f==2)cout<<1<<endl<<0<<endl;
  for(int i=0;i<c1;i++)cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int A, B, C, K;

int main(void) {

	cin >> A >> B >> C >> K;

	long long int ans = 0;
	long long int num = 0;

	if (K <= A) { ans = K; }
	else if (K <= A + B) { ans = A; }
	else { ans = A - (K - (A+B)); }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3588
package main

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

func main() {
	sc := NewScanner()
	S := sc.Next()

	if S[2] == S[3] && S[4] == S[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

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

    int N;
    cin >> N;

    vector<pair<int, int> > R(N);
    vector<pair<int, int> > B(N);

    vector<bool> C(N);

    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        R[i] = make_pair(b, a);
    }

    for(int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        B[i] = make_pair(c, d);
    }

    sort(R.begin(), R.end(), greater<pair<int, int> >());
    sort(B.begin(), B.end());

    int ans = 0;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(C[j]) continue;
            if(R[j].second < B[i].first && R[j].first < B[i].second) {
                C[j] = true;
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#[macro_use]extern crate text_io;
use proconio::input;

fn dfs<F>(v:&mut Vec::<i32>,n:i32,m:i32,dep:i32,max:&mut i32,checker:&F)
where F:Fn(&Vec::<i32>) -> i32
{
    if dep == n {
        *max = std::cmp::max(*max,checker(v));
        return;
    }
    for i in if dep == 0 {1}else{v[(dep-1) as usize]}..=m {
        v[dep as usize] = i;
        dfs(v,n,m,dep+1,max,checker);
    }
}

fn main() {
    input!(n:i32,m:i32,q:i32);
    let mut st = Vec::new();
    for _ in 0..q {
        input!(a:i32,b:i32,c:i32,d:i32);
        st.push((a,b,c,d));
    }
    let mut ar = Vec::new();
    for _ in 0..n {
        ar.push(1);
    }
    let check = |ag:&Vec<i32>|{
        let mut pt = 0;
        for (a,b,c,d) in st.iter() {
            if ag[(*b-1) as usize] - ag[(*a-1) as usize] == *c {pt += *d}
        }
        pt
    };
    let mut cnt = 0;
    dfs(&mut ar,n,m,0,&mut cnt,&check);
    println!("{}",cnt);
}

Measured memory_bytes: 2200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) cin >> d[i];

    sort(d.begin(), d.end());

    cout << (d[n/2] - d[n/2 - 1]) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,M,K;
  cin>>N>>M>>K;
  vector<ll> A(N+1);
  vector<ll> B(M+1);
  A.at(0)=0;
  B.at(0)=0;
  for(ll i=1;i<=N;i++){
    ll a;
    cin>>a;
    A.at(i)=a+A.at(i-1);
  }
  for(ll i=1;i<=M;i++){
    ll a;
    cin>>a;
    B.at(i)=a+B.at(i-1);
  }
  ll answer=0;
  for(ll i=0;i<=N;i++){
    if(A.at(i)>K){continue;}
    ll ans=0;
    ll left=0,right=M;
    while(left<=right){
      ll mid=left+(right-left)/2;
      if(B.at(mid)<=K-A.at(i)){left=mid+1;ans=max(ans,mid);}
      else{right=mid-1;}
    }
    answer=max(answer,ans+i);
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 6408
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var r = Enumerable.Range(1, int.Parse(Console.ReadLine())).ToArray();
		Array.Sort(r.Select(_ => Console.ReadLine().Split()).Select(x => $"{x[0]} {999 - int.Parse(x[1]):D3}").ToArray(), r);
		Console.WriteLine(string.Join("\n", r));
	}
}


Measured memory_bytes: 11744
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << 0;
    }
    else{
        cout << 10;
    }
    cout << endl;
}


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

counter = 1
possible_remainders = []


while counter >= 0:
  remainder = (A*counter)%B
  if remainder in possible_remainders:
    break
  else:
    possible_remainders.append(remainder)
    counter += 1

if C in possible_remainders:
  print("YES")
else:
  print("NO")

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int t[n];
    for(int i=0; i<n; i++)
    {
        cin >> t[i];
    }
    int m;
    cin >> m;
    int p[m],x[m];
    for (int i=0; i<m; i++)
    {
        cin >> p[i];
        cin >> x[i];
    }
    for (int k=0; k<m; k++)
    {
        int sum= 0;
        for (int j=0; j<n; j++)
        {
            if (p[k]-1==j)
                sum += x[k];
            else
                sum += t[j];
        }
        cout << sum << endl;
    }

}


Measured memory_bytes: 256
#参考: https://betrue12.hateblo.jp/entry/2018/08/05/230358
D,G=map(int,input().split())
p,c=[],[]

for i in range(D):
    inp=input().split()
    p.append(int(inp[0]))
    c.append(int(inp[1]))

ans=1000000000
for i in range(2**D):
    num,sum=0,0
    index=[]
    for j in range(D):
        if (i>>j)&1:
            sum+=100*(j+1)*p[j]+c[j]
            num+=p[j]
            index.append(j)
            #print(i,j+1)
    if sum >= G:
        #print(num)
        ans=min(num,ans)
    else:
        for ii in reversed(range(0,D)):
            if not ii in index:
                for jj in range(p[ii]):
                    sum+=100*(ii+1)
                    num+=1
                    if sum >= G:
                        #print(num)
                        #debug(index)
                        ans=min(num,ans)
                        break

print(ans)


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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n][m];

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

    int b[m][1];

    for (int i = 0; i < m; i++) {
        cin >> b[i][1];
    }

    for (int i = 0; i < n; i++) {
        int num = 0;
        for (int j = 0; j < m; j++) {
            num += a[i][j] * b[j][1];
        }
        cout << num << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ans(INF);
	int sum(0), l(0);
	int N, S; cin >> N >> S;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	int r(0);
	while (r < N) {
		while (r < N&&sum < S)sum += a[r++];
		if (sum >= S)chmin(ans, r - l);
		while (sum >= S) {
			chmin(ans, r - l);
			sum -= a[l++];
		}
	}
	cout << (ans == INF ? 0 : ans) << endl;
	return 0;
}

Measured memory_bytes: 3348
import java.util.Scanner;

public class Main {

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

        String S = sc.next();
        long K = sc.nextLong();

        System.out.println(solve(S, K));
    }

    public static int solve(String S, long K){
        long next = 5_000_000_000_000_000L;

        long count = 0;
        for (int i=0; i<S.length(); i++) {
            int t = S.charAt(i) - '0';

            count += Math.pow(t, next);

            if (K <= count) return t;
        }

        return -1;
    }
}

Measured memory_bytes: 23380
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string S;

int main(){
    cin>>S;
    rep(i,3){
        if(S[i]=='1'){
            S[i]='9';
        }
        else{
            S[i]='1';
        }
    }
    out(S);
}


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

int main() {
  int H,W;
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0)
      break;
    for(int i=1; i<=H; i++){
      for(int j = 1; j <= W; j++){
        if(i%2 == j%2){
          cout << "#";
        }
        else{
          cout << ".";
        }
      }
    cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3076
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--n >= 0){
        vector<vector<int> > p(5, vector<int>(5));
        for(int i=0; i<5; ++i){
            for(int j=0; j<5; ++j){
                cin >> p[i][j];
            }
        }

        vector<int> height(5+1, 0);
        int ret = 0;
        for(int i=0; i<5; ++i){
            for(int j=0; j<5; ++j){
                if(p[i][j] == 1)
                    ++ height[j];
                else
                    height[j] = 0;
            }
            stack<pair<int, int> > stk;
            stk.push(make_pair(0, 5));
            for(int j=0; j<5+1; ++j){
                int k = j;
                while(height[j] < stk.top().first){
                    k = stk.top().second;
                    ret = max(ret, stk.top().first * (j-k));
                    stk.pop();
                }
                if(height[j] > stk.top().first)
                    stk.push(make_pair(height[j], k));
            }
        }
        cout << ret << endl;
    }

    return 0;
}

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

int main()
{
    int n;
    int res[4001];

    while( cin >> n )
    {
        int cnt = 0;
        for( int i = 0; i <= 4000; i++ )
            res[i] = 0;

        //4つの組み合わせを2つに分けて考える。
        for( int i = 0; i <= 1000; i++ )
            for( int j = 0; j <= 1000; j++ )
            {
                if( i + j <= n )
                    res[i+j]++;
            }
        //○○が0、○○が2の場合と、○○が2、○○が0の場合は違うので、両方数える。
        for( int i = 0; i <= 2000; i++ )
            cnt += res[i] * res[n-i];
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
mod=1000000007
h,w=map(int,input().split())
p=[]
ans=[[0]*w for i in range(h)]
for i in range(h):
    p.append(input())
ans[0][0]=1
for i in range(h):
    for j in range(w):
        if p[i][j]=="#":
            ans[i][j]=0
        elif i==0 and j!=0:
            ans[0][j]=ans[0][j-1]
        elif i!=0 and j==0:
            ans[i][0]=ans[i-1][0]
        elif i!=0 and j!=0:
            ans[i][j]=(ans[i-1][j]+ans[i][j-1])%mod
print(ans[h-1][w-1])


Measured memory_bytes: 51952
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include<utility>

#include <functional>

#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

int main(){
    ll N,a;
    cin >> N;
    vector< pair<int,int> > V;
    for(int i=1; i <= N; i++){
        cin >> a;
        V.push_back(make_pair(a,i));
    }
    sort(V.begin(), V.end());
    cout << V[0].second;
    for(int i=1; i < N; i++){
        cout << " " << V[i].second;
    }
    cout << endl;
}

Measured memory_bytes: 1780
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

bool solve(vector<string>ini_field,int gx,int gy) {
	set<vector<string>>memo;
	memo.emplace(ini_field);
	queue<vector<string>>que;
	que.push(ini_field);
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,1,0,-1 };
	while (!que.empty()) {
		auto field(que.front());
		que.pop();
		for (int y = 0; y < field.size(); ++y) {
			for (int x = 0; x < field[0].size(); ++x) {
				if (field[y][x] == 'o') {
					if(y==gy&&x==gx)return true;
					for (int way = 0; way < 4; ++way) {
						auto nextfield(field);
						int nx(x);
						int ny(y);
						while (true) {
							const int next_x=nx+dx[way];
							const int next_y=ny+dy[way];
							if (next_x >= 0 && next_x < field[0].size() &&
								next_y >= 0 && next_y < field.size()) {
								swap(nextfield[ny][nx],nextfield[next_y][next_x]);
							}
							else {
								break;
							}
							nx=next_x;
							ny=next_y;
						}
						if (memo.find(nextfield) == memo.end()) {
							memo.emplace(nextfield);
							que.push(nextfield);
						}
					}
				}
			}
		}
	}
	return false;
}

int main() {
	int H,W;cin>>H>>W;
	vector<string>field;
	vector<pair<int,int>>curs;
	int gx,gy;
	for (int i = 0; i < H; ++i) {
		string st;cin>>st;
		field.push_back(st);
		for (int j = 0; j < W; ++j) {
			auto ch(st[j]);
			{
				if (ch == 'o') {
					curs.push_back(make_pair(i,j));
				}
				else if (ch == '@') {
					gx=j;
					gy=i;
					field[i][j]='.';
				}
			}
		}
	}
	bool ok=false;
	 if (curs.size() >= 3&&H>1&&W>1) {
		ok=true;
	 }
	 else {
		 ok=solve(field,gx,gy);
	 }
	if(ok)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

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

int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		if(a%3==0||b%3==0||(a+b)%3==0)
		cout<<"Possible"<<endl;
		else
		cout<<"Impossible"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
bool vis[110];
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int siz;
		cin >>siz;
		for (int j=0;j<siz;j++)
		{
			int x;
			cin >>x;
			vis[x-1]=1;
		}
	}
	cout <<count(vis,vis+n,0);
	return 0;
}

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

int construct[17][17], dp[17][17], W, H, N;
int main()
{
loop:
  memset(construct, 0, sizeof construct);
  memset(dp, 0, sizeof dp);
  cin >> W >> H;
  if(!W && !H)
    return 0;

  cin >> N;
  for(int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    construct[a][b] = 1;
  }

  dp[0][1] = 1;
  for(int x = 1; x <= W; x++)
  {
    for(int y = 1; y <= H; y++)
    {
      if(construct[x][y])
        continue;
      dp[x][y] = dp[x - 1][y] + dp[x][y - 1];      
    }
  }
  cout << dp[W][H] << endl;
  goto loop;
}

Measured memory_bytes: 1160
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    if a == b:
        print(2*a)
    else:
        print(2*max(a,b)-1)
    return

#B
def B():
    n = I()
    h = LI()
    m = h[0]
    ans = 1
    for i in range(1,n):
        if m <= h[i]:
            ans += 1
            m = h[i]
    print(ans)
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39152
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[100][100];
		int[] b = new int[100];
		int c;
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[i][j] = sc.nextInt();
			}
		}
		
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++){
			c = 0;
			
			for(int j = 0; j < m; j++){
				c += a[i][j] * b[j];
			}
			
			System.out.println(c);
		}
	}
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }

    sort(a.begin(), a.end());

    int ansn = a.at(n-1), ansr = a.at(0);
    for(int in=0;in<n;in++) {
        if(ansn%2==0) {
            if(a.at(in)<=ansn/2&&ansr<a.at(in)||a.at(in)>=ansn/2&&ansr<(ansn-a.at(in))) { 
                ansr = a.at(in);
            }
        }
        else {
            if(a.at(in)<=(ansn+1)/2&&ansr<a.at(in)||a.at(in)>=(ansn+1)/2&&ansr<(ansn+1-a.at(in))) { 
                ansr = a.at(in);
            }
        }
        
    }

    cout << ansn << " " << ansr << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    
    cin >> a>>b;
    
    if(a!=1 && b!=1)
    {
        if(a>b)
        cout<<"Alice";
        else if(a<b)
        cout<<"Bob";
        else
        cout <<"Draw";
    }
    else if(a==b && a!=1)
    cout <<"Draw";
    else
    {
        if(a>b)
        cout<<"Bob";
        else if(a<b)
        cout<<"Alice";
        else
        cout<<"Draw";
    }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> A(H+2,vector<char>(W+2,'.'));
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>A.at(i).at(j);
    }
  }
  vector<vector<int>> dist(H+2,vector<int>(W+2,0));
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  queue<pair<int,int>> q;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(A.at(i).at(j)=='#'){
        dist.at(i).at(j)=0;
        q.push(make_pair(i,j));
      }else{
        dist.at(i).at(j)=-1;
      }
    }
  }
  while(!q.empty()){
    int x=q.front().first;
    int y=q.front().second;
    for(int i=0;i<4;i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(dist.at(nx).at(ny)!=-1){
        continue;
      }
      dist.at(nx).at(ny)=dist.at(x).at(y)+1;
      q.push(make_pair(nx,ny));
    }
    q.pop();
  }
  int ans=0;
  for(int i=1;i<=H;i++){
    for(int j=0;j<=W;j++){
      ans=max(ans,dist.at(i).at(j));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 13456
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
 
    sort(h,h+N);
    long long ans=100000000000000,sa;
    for(int i=0;i<N-K+1;i++){
        sa = h[i+K-1]-h[i];
        ans = min(ans,sa);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
m=([0]*14).map{[0]*14}
while gets
x,y,t=$_.split(?,).map{|i|i.to_i+2}
m[x][y]+=1
m[x-1][y]+=1
m[x+1][y]+=1
m[x][y-1]+=1
m[x][y+1]+=1
[m[x-1][y-1]+=1,m[x-1][y+1]+=1,m[x+1][y-1]+=1,m[x+1][y+1]+=1]if t>3
[m[x-2][y]+=1,m[x+2][y]+=1,m[x][y-2]+=1,m[x][y+2]+=1]if t>4
end
n=m[2..11].flat_map{|i|i[2..11]}
p n.count(0),n.max

Measured memory_bytes: 6132
import java.util.Scanner;

public class Main {

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

		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();

			if (H == 0 && W == 0) {
				break;
			}

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if(i % 2 == 0) {

					if (j % 2 == 0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					} else {

						if (j % 2 == 0) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.println();
			}
			System.out.println();

		}

	}

}



Measured memory_bytes: 36744
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 100;
int arr[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	int tot = 0;
	for(int i = 0;i < n;i++) {
		cin>>arr[i];
		tot += arr[i];
	}
	int avg = tot / n;
	int mini = 1e9;
	for(int i = -1;i <= 1;i++) {
		int chg = 0;
		int navg = i + avg;
		for(int j = 0;j < n;j++) {
			int x = arr[j] - navg;
			chg += x * x;
		}
		mini = min(mini, chg);
	}
	cout<<mini<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




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

void print(int count,char di){
    for(int i=0;i<count;i++){
        cout<<di<<flush;
    }
}

int main(){
    int sx,sy;
    int tx,ty;
    cin>>sx>>sy>>tx>>ty;
    print(ty-sy,'U');
    print(tx-sx,'R');    
    print(ty-sy,'D');
    print(tx-sx,'L');
    print(1,'L');
    print(ty-sy+1,'U');
    print(tx-sx+1,'R');    
    print(1,'D');
    print(1,'R');
    print(ty-sy+1,'D');
    print(tx-sx+1,'L');
    print(1,'U');
    cout<<endl;        
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r,q;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  int an=n%1000;
  if(an==0) an=1000;
  cout  <<1000-an<<'\n';
  return (0);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector <long long> a(n);
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        long long div = 0;
        while(a[i]%2==0){
            a[i]/=2;
            div++;
        }
        a[i] = div;
    }
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;


int main() {
  int x;cin>>x;
  if(x >= 30) print("Yes");
  else print("No");
  return 0;
}

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

int main() {
  int A,B;
  cin >>A >>B ;
  
  if(A>B){
    cout <<(A+A-1) <<endl;
  }
  else if(B>A){
    cout <<(B+B-1) <<endl;
  }
  else{
    cout <<2*A <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = ReadInt();
            int[] h = ReadInts();
            long[] cost = new long[N];
            cost[1] = Abs(h[0] - h[1]);
            for(int i = 2; i < N; i++)
            {
                cost[i] = Min(cost[i - 1] + Abs(h[i - 1] - h[i]),cost[i-2]+Abs(h[i]-h[i-2]));
            }
            Write(cost[N-1]);




        }

        
        private static void Write<T>(IEnumerable<T> target,string sep=" ") { Console.WriteLine(string.Join(sep,target)); }
        private static void Write<T>(T str) { Console.WriteLine(str); }
        private static string[] ReadStrings() { return Console.ReadLine().Split(' '); }
        private static int ReadInt() { return int.Parse(Console.ReadLine()); }
        private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        private  static int[] ReadInts() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        private static double[] ReadDoubles() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        
    }

}

Measured memory_bytes: 20192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

using P = pair<int,int>;
int N;
VV<P> G;
V<int> col;

void dfs(int v,int p,ll d){
	col[v] = d%2;
	for(auto e: G[v]){
		int u = e.fs;
		int c = e.sc;
		if(u == p) continue;
		dfs(u,v,d+c);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	cin >> N;
	G.resize(N);
	col.resize(N);
	rep(i,N-1){
		int a,b,c;
		cin >> a >> b >> c;
		a--,b--;
		G[a].emplace_back(b,c);
		G[b].emplace_back(a,c);
	}
	dfs(0,-1,0);
	rep(i,N) cout << col[i] << endl;
}


Measured memory_bytes: 8192
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
long n, k, ans;
int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    cin >> n >> k;
    //nをkで割った場合に余りが0となる数の個数を求める
    ans += pow(n / k, 3);
    //nをkで割った場合に余りがk/2となる数の個数を求める
    //nにk/2を足し、kで割ることで余りがk/2となる数の個数を求めることができる
    if (k % 2 == 0) {
        ans += pow((n + k / 2) / k, 3);
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int MOD = 1e9+7;

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

	vec_i v(n);
	vec_i visited(n, 0);
	rep(i, n){
		cin >> v[i];
		v[i]--;
	}

	int s = 0;
	rep(i, n){
		visited[s] = 1;
		if(s == 1){
			cout << i << endl;
			return 0;
		}
		if(visited[v[s]] == 1){
			break;
		}
		s = v[s];
	}
	cout << -1 << endl;
}

Measured memory_bytes: 1152