akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = max(min(b,d)-max(a,c), 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    P = list(map(int, input().split()))
    ans = 0
    for i in range(1, N-1):
        if P[i-1] < P[i] < P[i+1] or P[i-1] > P[i] > P[i+1]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38584
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	long n;
	readf("%s", n);

	long r;

	foreach (i;1..n) {
		r += (n - 1) / i;
	}

	writeln(r);
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
 
const ll inf = 0x3f3f3f3f;
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}
 
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	ll a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	vector<pair<ll, ll>> buy(n);
	vector<ll> sell(n, 0);
	buy[0] = make_pair(1000/a[0], 1000%a[0]);
	sell[0] = 1000;
	for (int i = 1; i<n; i++) {
		for (int j = 0; j<i; j++) sell[i] = max(sell[i], buy[j].first * a[i] + buy[j].second);
		buy[i] = make_pair(1000/a[i], 1000%a[i]);
		for (int j = 0; j<=i; j++) {
			if (sell[j] / a[i] > buy[i].first) buy[i] = make_pair(sell[j] / a[i], sell[j] % a[i]);
			else if (sell[j] / a[i] == buy[i].first) buy[i].second = max(buy[i].second, sell[j]%a[i]);
		}
		
	}
	ll ret = 1000;
	for (int i = 0; i <n; i++) ret = max(ret, sell[i]); 
	cout << ret << '\n';
}


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

int main()
{
    int X;
    cin >> X;
    int N = 120;
    int ans = 0;

    for (int i = -119; i < N; i++)
    {
        if (ans == 1)
            break;
        for (int j = -119; j < N; j++)
        {
            if (pow(i, 5) - pow(j, 5) == X)
            {
                cout << i << " " << j << endl;
                ans = 1;
                break;
            }
        }
    }
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0);

  multiset<int> P;
  int N;
  scanf("%d", &N);
  REP(i,N) {
    int a;
    scanf("%d", &a);
    P.insert(a);
  }
  int M;
  scanf("%d", &M);
  REP(i,M) {
    int b;
    scanf("%d", &b);
    if (P.find(b) == P.end()) {
      printf("NO\n");
      return 0;
    }
    P.erase(P.find(b));
  }
  printf("YES\n");
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

int gcd(int x, int y) {
    return y ? gcd(y, x % y) : x;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3112
inputs = input().split()
N = int(inputs[0])
M = int(inputs[1])

grid_list = [[] for x in range(N)]
input_edge = []

diff = 0
for i in range(N):
    diff += i

for M in range(M):
    inputs = input().split()
    a = int(inputs[0])
    b = int(inputs[1])
    input_edge.append([a-1, b-1])
    grid_list[a - 1].append(b-1)
    grid_list[b-1].append(a-1)



ans = 0
for inp in input_edge:
    grid_list[inp[0]].remove(inp[1])
    grid_list[inp[1]].remove(inp[0])
    able_list = []
    sum = 0
    search_list = []
    for g in grid_list[0]:
        search_list.append(g)
    for g in search_list:
        able_list.append(g)
        for h in grid_list[g]:
            if h not in search_list:
                search_list.append(h)
    able_list = list(set(able_list))
    for i in able_list:
        sum += i
    if diff > sum:
        ans += 1
    grid_list[inp[0]].append(inp[1])
    grid_list[inp[1]].append(inp[0])

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define loop(n) for (int i = 0; i < n; i++)
#define double long double
#define mod 998244353
#define pi 3.1415926535897
#define F first
#define S second
#define pb push_back

using namespace std;

vector<int> primeFactors(int n)
{
    // Print the number of 2s that divide n

    vector<int> primes;
    while (n % 2 == 0)
    {
        primes.push_back(2);
        ;
        n = n / 2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            primes.push_back(i);
            n = n / i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        primes.push_back(n);

    return primes;
}

signed main()
{
    fast;
    int test = 1;
    // cin >> test;
    for (int index = 0; index < test; index++)
    {
        int n;
        cin >> n;

        vector<int> pp = primeFactors(n);
        map<int, int> mp;
        for (int i = 0; i < pp.size(); i++)
        {
            if (mp.find(pp[i]) != mp.end())
            {
                mp[pp[i]]++;
            }
            else
            {
                mp.insert({pp[i], 1});
            }
        }
        int count = 0;
        for (auto itr = mp.begin(); itr != mp.end(); itr++)
        {
            int temp = itr->first;
            int val = itr->second;
            int t = 1;
            while (val > 0)
            {
                val -= t;
                t++;
                if (val >= 0)
                    count++;
            }
        }
        cout << count << endl;
    }
}


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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if(x >= r && y >= r && (w - x) >= r && (h - y) >= r) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
	int n,g=0;
	cin >> n;
	while(n--)
	{
		if(g) cout << endl; g=1;

		int f[9][9],k[9][9]={0};

		for(int i=0; i<81; i++)
			cin >> f[i/9][i%9];

		for(int y=0; y<9; y++)
		{
			int c[10]={0};
			for(int x=0; x<9; x++) c[f[y][x]]++;
			for(int x=0; x<9; x++) if(c[f[y][x]]!=1) k[y][x]=1;
		}
		for(int x=0; x<9; x++)
		{
			int c[10]={0};
			for(int y=0; y<9; y++) c[f[y][x]]++;
			for(int y=0; y<9; y++) if(c[f[y][x]]!=1) k[y][x]=1;
		}

		for(int y1=0; y1<3; y1++)
		for(int x1=0; x1<3; x1++)
		{
			int c[10]={0};
			for(int y2=0; y2<3; y2++)
			for(int x2=0; x2<3; x2++)
			{
				int x=x1*3+x2;
				int y=y1*3+y2;
				c[f[y][x]]++;
			}

			for(int y2=0; y2<3; y2++)
			for(int x2=0; x2<3; x2++)
			{
				int x=x1*3+x2;
				int y=y1*3+y2;
				if(c[f[y][x]]!=1) k[y][x]=1;
			}
		}

		for(int y=0; y<9; y++)
		{
			for(int x=0; x<9; x++)
			{
				cout << (k[y][x]?'*':' ') << f[y][x];
			}
			cout << endl;
		}
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll a, b;
	cin >>n >>a >>b;
	VI x(n);
	rep(i, n) cin >>x[i];
	
	ll ans = 0;
	rep2(i,1,n){
		ans += min(a*(x[i] - x[i-1]), b);
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  int n, x;
  while (true) {
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = j + 1; k <= n; ++k) {
          if (i + j + k == x) ++ans;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<cstdint>
#include<chrono>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

using namespace std;


class segtree_min_pointupdate {
private:
	typedef int T;
public:
	segtree_min_pointupdate(const int N) {
		SIZE = roundup_pow2(N);
		v.clear();
		v.resize(SIZE * 2, numeric_limits<T>::max());
	}

	//v[index]=numberとする。
	void update(const int index, const T number) {
		v[index + SIZE] = number;
		for (int i = (index + SIZE) / 2; i; i = i / 2)v[i] = min(v[i * 2], v[i * 2 + 1]);
	}

	//[index]の値を返す。
	T getnum(const int index) {
		return v[index + SIZE];
	}

	//[L,R)の最小値を返す。
	T getmin(const int L, const int R) {
		return getmin_inner(L, R, 1, 0, SIZE);
	}
private:
	T getmin_inner(const int queryL, const int queryR, const int index, const int segL, const int segR) {
		if (queryR <= segL || segR <= queryL)return numeric_limits<T>::max();
		if (queryL <= segL && segR <= queryR)return v[index];
		return min(getmin_inner(queryL, queryR, index * 2, segL, (segL + segR) / 2),
			getmin_inner(queryL, queryR, index * 2 + 1, (segL + segR) / 2, segR));
	}

	//x以上であるような2のべき乗数のうち最小のものを返す。
	int roundup_pow2(int x) {
		x--;
		rep(i, 6)x |= x >> (1LL << i);
		return x + 1;
	}

	int SIZE;
	vector<T>v;
};


signed main() {

	int N, M;
	cin >> N >> M;
	string S;
	cin >> S;

	//seg[i]:=(マスiからゴールまでの最短手数)*(N+1)+i
	segtree_min_pointupdate seg(N + M + 1);

	//dp[i]:=マスiからゴールまでの最短手数と、そのために次に踏むべき最も小さいマス
	vector<pair<int,int>>dp(N + 1, make_pair(0,0));

	seg.update(N, N);

	for (int i = N - 1; i >= 0; --i) {
		if (S[i] == '1') {
			dp[i] = make_pair(-1, -1);
			continue;
		}

		int res = seg.getmin(i + 1, i + M + 1);


		int tekazu = (res / (N + 1)) + 1;
		int next = res % (N + 1);

		if (tekazu > N) {
			dp[i] = make_pair(-1, -1);
			continue;
		}


		dp[i] = make_pair(tekazu, next);
		seg.update(i, tekazu * (N + 1) + i);
	}

	if (dp[0].first == -1) {
		cout << -1 << endl;
		return 0;
	}

	for (int ans = 0; ans < N;) {
		if (ans)cout << " ";
		cout << dp[ans].second - ans;
		ans = dp[ans].second;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t,x;
    cin >> t >> x;
    double ans = (double)t/x;
    cout << ans;

    return 0;
}

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

void dfs(vector<vector<int>> &v, int from, bool visit[], int x, int y){
    visit[from] = true;
    if(v[from].size() != 0){
        for(int i=0; i<v[from].size(); i++){
            int to = v[from][i];
            if(visit[to] == false && (from != x || to != y) && (from != y || to != x)) dfs(v, to, visit, x, y);
        }
    }
    return;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> E(n);
    vector<pair<int, int>> edges;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
        edges.push_back(make_pair(a, b));
    }

    int cnt = 0;
    for(int i=0; i<edges.size(); i++){
        bool visit[51];
        for(int j=0; j<n; j++) visit[j] = false;
        int x = edges[i].first, y = edges[i].second;
        dfs(E, 0, visit, x, y);
        bool flag = true;
        for(int j=0; j<n; j++) if(visit[j] == false) flag = false;
        if(flag == false) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!{
        a:u32,
    }
    println!("{}",a + a.pow(2)+ a.pow(3));
    

}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
int main(){
char a,b;
  cin>>a>>b;
  int sum=0;
  if(a=='D')
    sum++;
  if(b=='D')
    sum++;
  if(sum==1)
    cout<<'D'<<endl;
  else
    cout<<'H'<<endl;
  
  
   return 0;
}

Measured memory_bytes: 256
AC = 0
WA = 0
TLE = 0
RE = 0

N = int(input())
for i in range(N):
  a = input()
  if(a == 'AC'):
    AC+=1
  elif(a == 'WA'):
    WA+=1
  elif(a == 'TLE'):
    TLE+=1
  else:
    RE+=1

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))








Measured memory_bytes: 74824
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {

  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long int x = -1;
  long long int y = -1;
  for(int i=n-1; i>=1; i--){
    if( a[i] == a[i-1] ){
      if( x != -1 ){
        y = a[i];
        cout << x * y << endl;
        return 0;
      }else{
        x = a[i];
        a[i] = -1;
        a[i-1] = -1;
      }
    }
  }
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
    int N, T;
    int c, t;
    int route = 0;

    scanf("%d %d", &N, &T);
    
    for (int i = 1; i<= N; i++){
        scanf("%d %d", &c, &t);
        if(route == 0){
            if (t <= T){
                route = c;
            }
        } else if (c < route && t <= T) {
            route = c;
        }
    }

    if(route == 0){
        printf("TLE\n");
    } else {
        printf("%d\n", route);
    }

    return 0;
}

Measured memory_bytes: 1716
#include <cstdio>
int main(){
  int N,p,g,a[9]={};
  int i,o;
  char v,prev;
  scanf("%d",&N);
  for(i=1;i<=N+1;i++){
    p=0;
    while(1){
      p++;
      scanf("%c",&v);
      if(v=='\n') break;
      if(v=='1') a[0]++;
      if(v=='2') a[1]++;
      if(v=='3') a[2]++;
      if(v=='4') a[3]++;
      if(v=='5') a[4]++;
      if(v=='6') a[5]++;
      if(v=='7') a[6]++;
      if(v=='8') a[7]++;
      if(v=='9') a[8]++;
      if(v=='0') {
	if(prev=='1') {
	  if(a[0]%5==4) printf("?");
	  if(a[0]%5==1) printf(".");
	  if(a[0]%5==2) printf(",");
	  if(a[0]%5==3) printf("!");
	  if(a[0]%5==0) printf(" ");
	}
	if(prev=='2'){
	  g=a[1]%3;
	  if(g==0) g=3;
	  printf("%c",96+g);
	}
	if(prev=='3'){
	  g=a[2]%3;
	  if(g==0) g=3;
	  printf("%c",99+g);
	}
	if(prev=='4'){
	  g=a[3]%3;
	  if(g==0) g=3;
	  printf("%c",102+g);
	}
	if(prev=='5'){
	  g=a[4]%3;
	  if(g==0) g=3;
	  printf("%c",105+g);
	}
	if(prev=='6'){
	  g=a[5]%3;
	  if(g==0) g=3;
	  printf("%c",108+g);
	}
	if(prev=='7'){
	  g=a[6]%4;
	  if(g==0) g=4;
	  printf("%c",111+g);
	}
	if(prev=='8'){
	  g=a[7]%3;
	  if(g==0) g=3;
	  printf("%c",115+g);
	}
	if(prev=='9'){
	  g=a[8]%4;
	  if(g==0) g=4;
	  printf("%c",118+g);
	}
	for(o=0;o<=8;o++){
	  a[o]=0;
	}
      } 
      prev=v;
    }
    if(i>=2)   printf("\n");
  }
  return 0;
}

Measured memory_bytes: 996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
int n;
 
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
  	cin>>n;
  	if(n%1000!=0){
  		cout<<(n/1000+1)*1000-n;
  	}
  	else{
  		cout<<0;
  	}



    return 0;
}

Measured memory_bytes: 3636
from collections import *
from itertools import *
h, w = map(int, input().split())
maze = [input() for _ in range(h)]
dest = [(1, 0), (-1, 0), (0, 1), (0, -1)]
score = 0

for sx, sy in product(range(w), range(h)):
  if maze[sy][sx] == '#':
    continue
  r = [[-1] * w for _ in range(h)]
  r[sy][sx] = 0
  queue = deque([(sx, sy)])
  while queue:
    x, y = queue.popleft()
    for dx, dy in dest:
      nx, ny = x + dx, y + dy
      if not (0 <= nx < w and 0 <= ny < h):
        continue
      if maze[ny][nx] == '#' or r[ny][nx] != -1:
        continue
      r[ny][nx] = r[y][x] + 1
      queue.append((nx, ny))
      score = max(score, r[ny][nx])
print(score)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==a){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5] ) cout << "Yes" << endl;
    else cout << "No" << endl;
    

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll

string next(string a)
{
    bool allnine=true;
    for(ll i=0;i<sz(a);i++)
    {
        if(a[i]!='9')
            allnine=false;
    }
    if(allnine)
    {
        string ans(sz(a)+1,'0');
        ans[0]='1';
        return ans;
    }
    ll index=0;
    for(ll i=sz(a)-1;i>=1;i--)
    {
        if(a[i]!='9' && abs(a[i]+1-a[i-1])<=1)
        {
            index=i;
            break;
        }
    }
  //  if(a=="12")
 //       tr1(index);
    a[index]++;
    for(ll i=index+1;i<sz(a);i++)
    {
        a[i]=max((ll)a[i-1]-1,(ll)'0');
    }
    return a;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    string curr="1";
    for(ll i=0;i<k-1;i++)
    {
        curr=next(curr);
//        tr1(curr);
    }
    cout<<curr<<nl;
}


Measured memory_bytes: 256
n,m,x=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(n)]
payment=1e10
flag=True
for i in range(2**n):
    total=0
    skil=[0]*m
    for j in range(n):
        if ((i >> j) & 1):
            total+=lis[j][0]
            for h in range(1,m+1):
                skil[h-1]+=lis[j][h]
    for k in skil:
        if k>=x:
            pass
        else:
            break
    else:
        if payment>total:
            payment=total
if payment==1e10:
    print(-1)
else:
    print(payment)

Measured memory_bytes: 9228
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	vector<int> dp_a(n + 1, -MOD), dp_b(n + 1, -MOD), dp_c(n + 1, -MOD);
	cin >> dp_a[0] >> dp_b[0] >> dp_c[0];
	rep2(i, 1, n) {
		int a, b, c;
		cin >> a >> b >> c;
		dp_a[i] = max(dp_b[i-1], dp_c[i-1]) + a;
		dp_b[i] = max(dp_a[i-1], dp_c[i-1]) + b;
		dp_c[i] = max(dp_a[i - 1], dp_b[i - 1]) + c;
	}
	cout << max(max(dp_a[n - 1], dp_b[n - 1]), dp_c[n - 1]);
}



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

int main(){
  int A[3];cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  int ans=0;
  ans += (A[2]-A[0])/2 + (A[2]-A[1])/2;
  A[0] += ((A[2]-A[0])/2)*2;
  A[1] += ((A[2]-A[1])/2)*2;
  if(A[0]<A[2]&&A[1]<A[2]) ans++;
  else if(A[0]==A[2]&&A[1]==A[2]);
  else ans+=2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  class Card(val input: String, val inputOrder: Int) {
    val mark = input.split(" ")(0)
    val rank = input.split(" ")(1).toInt
  }

  val n = readInt
  val arr = Array.fill[Card](n)(null)
  for (i <- 0 until n) {
    arr(i) = new Card(readLine, i)
  }
  quickSort(arr)
  if (isStable(arr)) {
    println("Stable")
  } else {
    println("Not stable")
  }
  println(arr.map(e => s"${e.mark} ${e.rank}").mkString("\n"))

  def isStable(sortedArr: Array[Card]): Boolean = {
    sortedArr.zipWithIndex.foreach { case(e, i) => {
      if (i < sortedArr.length - 1) {
        val next = sortedArr(i + 1)
        if (e.rank == next.rank && e.inputOrder > next.inputOrder) {
          return false
        }
      }
    }}
    true
  }

  def quickSort(arr: Array[Card]): Unit = {
    quickSort(arr, 0, arr.length - 1)
  }

  def quickSort(arr: Array[Card], p: Int, r: Int): Unit = {
    if (p < r) {
      val q = partition(arr, p, r)
      quickSort(arr, p, q - 1)
      quickSort(arr, q + 1, r)
    }
  }

  def partition(arr: Array[Card], p: Int, r: Int): Int = {
    var i = p - 1
    for (j <- p to r - 1) {
      if (arr(j).rank <= arr(r).rank) {
        i = i + 1
        exchange(arr, i, j)
      }
    }
    exchange(arr, i + 1, r)
    i + 1
  }

  def exchange(arr: Array[Card], i: Int, j: Int): Unit = {
    if (i != j) {
      val tmp = arr(i)
      arr(i) = arr(j)
      arr(j) = tmp
    }
  }
 
}



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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt A; string B; cin >> A >> B;
	lnt b = (B[0]-'0')*100 + (B[2]-'0')*10 + (B[3]-'0');
	cout << A*b / 100 << ln;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <atcoder/scc>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}
lli m = 1e9 + 7;
int main(void)
{
    int N;
    cin >> N;
    int a, b;
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        if (a == b)
        {
            cnt++;
        }
        else
        {
            cnt = 0;
        }
        if (cnt == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

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

	int N=in();
	REP(n,N){
		vector<vector<int>> M(8,vector<int>(8,0));
		REP(i,8){
			string S=in<string>();
			REP(j,8){
				M[i][j] = S[j]-'0';
			}
		}
		int X=in()-1,Y=in()-1;
		queue<pair<int,int>> Q;
		Q.emplace(X,Y);
		while(!Q.empty()){
			auto P=Q.front();
			Q.pop();
			M[P.second][P.first] = 0;
			REP(i,3){
				if(P.first-i-1>=0 && M[P.second][P.first-i-1]) Q.emplace(P.first-i-1,P.second);
				if(P.first+i+1<8 && M[P.second][P.first+i+1]) Q.emplace(P.first+i+1,P.second);
				if(P.second-i-1>=0 && M[P.second-i-1][P.first]) Q.emplace(P.first,P.second-i-1);
				if(P.second+i+1<8 && M[P.second+i+1][P.first]) Q.emplace(P.first,P.second+i+1);
			}
		}
		cout << "Data " << n+1 << ":" << endl;
		REP(i,8){
			REP(j,8){
				cout<<M[i][j];
			}
			out();
		}
	}

	return 0;
}


Measured memory_bytes: 3240
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
 
        StringBuilder sb = new StringBuilder();
        sb.append(s1.charAt(0));
        sb.append(s2.charAt(0));
        sb.append(s3.charAt(0));
        _out.println(sb.toString().toUpperCase());
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

typedef long long ll;

int main() {
    map<string,int> m;
    int q; cin >> q;
    for(int i=0; i<q; i++){
        int query;
        cin >> query;
        if(query==0){
            string key; int x;
            cin >> key >> x;
            m[key] = x;
        }
        else if(query==1){
            string key;
            cin >> key;
            cout << m[key] << endl;
        }
        else if(query==2){
            string key;
            cin >> key;
            m.erase(key);
        }
        else if(query==3){
            string L,R;
            cin >> L >> R;
            auto l = m.lower_bound(L);
            auto r = m.upper_bound(R);
            for(auto itr=l; itr!=r; itr++){
                if(itr->second!=0) cout << itr->first <<" "<< itr->second << endl;
            }
        }
    }
}



Measured memory_bytes: 27676
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

int a[200001],b[200001];

int32_t main()
{
    FIO
    int n,m; cin>>n>>m;
    int p=n%m;
    p=min(p,m-p);
    cout<<p<<"\n";
    return 0;
}

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

struct Point {
  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); }
};
typedef Point Vector;
double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }

Point p[4];

bool solve() {
  double c0 = cross(p[1] - p[0], p[2] - p[0]);
  for(int i = 1; i < 4; i++) {
    if(c0 * cross(p[(i+1)%4] - p[i], p[(i+2)%4] - p[i]) < 0.0) return false;
  }
  return true;
}

main() {
  while( scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
	       &p[0].x, &p[0].y, &p[1].x, &p[1].y,
	       &p[2].x, &p[2].y, &p[3].x, &p[3].y) != EOF )
    { cout << (solve() ? "YES" : "NO") << endl; }
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int vis[100];
int a[100];
bool check(int x)
{
    while(x)
    {
        if(vis[x%10] == 1)
            return false;
        x /= 10;
    }
    return true;
}
int main()
{
   int m,n,x;
   while(~scanf("%d %d",&m,&n))
   {
       memset(vis,0,sizeof(vis));
       for(int i = 0;i<n;i++)
       {
           scanf("%d",&x);
           vis[x] = 1;
       }
      for(int i = m;;i++)
       {
           if(check(i))
           {
               printf("%d\n",i);
               break;
           }
       }
   }
}




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

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;


void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }else{
            x=x->right;
    }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

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


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
         
            insert(x);
        } else if ( com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        }
    
    
    return 0;
}



Measured memory_bytes: 25152
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;

int main(){
	cin >> N;

	int k = 1;
	ll d = 1;
	ll ans = 0;
	while(N>=d){
		if(k%2==1){
			ans += min(N-d+1, 9*d);
		}
		d *= 10;
		k++;
	}

	cout << ans << endl;


	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    map<string,int>m;
    for(int i=0;i<n;i++){
        cin>>s;
        m[s]++;

    }
    vector<pair<int,string>>v;
    for(auto c:m){
        v.push_back(make_pair(c.second,c.first));

    }

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

    int index =v.size()-1;
   int k =index;
   vector<string>ans;
    while(v[index].first == v[k].first){
        ans.push_back(v[index].second);
        index--;
    }
    sort(ans.begin(),ans.end());
    for(auto l:ans){
        cout<<l<<endl;
    }
    return 0;
}


Measured memory_bytes: 33388
s = list(input())
we = [0,0]
ns = [0,0]

for i in range(len(s)):
    if s[i] == ('N'):
        ns[0] = 1
    elif s[i] == ('W'):
        we[0] = 1
    elif s[i] == ('S'):
        ns[1] = 1
    else:
        we[1] = 1

if sum(we) % 2 == 0 and sum(ns) % 2 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,K;
map<ll,ll> cnt;
void input(){
    fast_io();
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll a,b; cin >> a >> b;
        cnt[a] += b;
    }
    
}

int solve(){
    ll sum = 0;
    ll ans = 0;
    for(auto &p:cnt){
        sum += p.second;
        if(sum>=K) {
            ans = p.first;
            break;
        }
        // p.second = sum;
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4224
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define show(x) cout<<#x<<" = "<<(x)<<" "
#define ENA cout<<endl;
#define ENAA cout<<endl<<endl;

int MAX = 1e+6+5;
int BIG = 1e+9;
int MOD = 1e+9+7;

signed main()
{
    IOS;
    int n,m;
    cin>>n>>m;

    map<int,int>ac,wa;
    int acCount(0);
    int waCount(0);
    repa(i,1,m)
    {
        int nn; cin>>nn;
        string s; cin>>s;
        if (s[0]=='A')
            ac[nn]=1;
        else
        {
            if (ac[nn])
                continue;
            else 
                wa[nn]++;
        }
    }

    for (auto it: ac)
        acCount+=it.ss;

    for (auto it:wa)
        if (ac[(it.ff)])
            waCount+=it.ss;


    cout<<acCount<<" "<<waCount<<endl;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    int n,k,q;
    cin>>n>>k>>q;
    ll a[n];
    pair<ll,ll> p[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        p[i] = make_pair(a[i],i);
    }
    sort(p,p+n);
    map<ll,ll> mp;
    mp[n] = 1;
    ll ans = 1e18;
    for(int mini=0;mini<=n;mini++){
        if(mini) mp[p[mini-1].second]++;
        int cnt=0;
        priority_queue<int,vector<int>,greater<int>> que;
        for(int i=0;i<n;i++){
            if(mp[i]==0){
                cnt++;
            }
            if(mp[i+1]){
                if(cnt>=k){
                    priority_queue<int,vector<int>,greater<int>> que2;
                    for(int j=i-cnt+1;j<=i;j++){
                        que2.push(a[j]);
                    }
                    while(que2.size()>=k){
                        que.push(que2.top());
                        que2.pop();
                    }
                }
                cnt = 0;
            }
        }
        if(que.size()<q) break;
        ll ret = -que.top();
        for(int i=1;i<q;i++){
            que.pop();
        }
        ret += que.top();
        ans = min(ans,ret);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef pair<int,int> P;

int N, M;

int main() {
  while (scanf("%d%d", &N, &M), N) {
    priority_queue<P> q;
    int d, p;
    rep(i,N) {
      scanf("%d%d", &d, &p);
      q.push(P(p, d));
    }
    
    while (!q.empty() && M > 0) {
      P p = q.top(); q.pop();
      if (M >= p.second) {
        M -= p.second;
        continue;
      }
      q.push(P(p.first, p.second - M));
      M = 0;
    }

    int ans = 0;
    while (!q.empty()) {
      P p = q.top(); q.pop();
      ans += p.first * p.second;
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1048
#include<iostream>
using namespace std;
 
#define MAX 200000
#define SENTINEL 1200000000
 
typedef long long hyper;
hyper cnt = 0;
 
void Merge(int* A, int left, int mid, int right)
{
    int R[MAX], L[MAX];
    int i, j, k, n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    for(i = 0; i < n1; i++) L[i] = A[i + left];
    for(j = 0; j < n2; j++) R[j] = A[j + mid];
 
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    i = j = 0;
 
    // sorting.
    for(k = left; k < right; k++){
 
        if(L[i] <= R[j]){ A[k] = L[i]; i++; }
 
        else{ A[k] = R[j]; j++; cnt = cnt + n1 - i; } // add n1 - i.
    }
}
 
void MergeSort(int* A, int left, int right)
{
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}
 
int main()
{
    int i, n, A[MAX];
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];

    MergeSort(A, 0, n);
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 2728
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static long mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			ulong[] vs = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
			ulong a = vs[0];
			ulong b = vs[1];
			ulong ans = XOR(a - 1) ^ XOR(b);
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

		static ulong XOR(ulong x)
		{
			ulong c = (x + 1) / 2;
			ulong d = (x + 1) % 2;
			ulong result = (c % 2) ^ (d == 1 ? x : 0);
			//System.Diagnostics.Debug.WriteLine($"{x}:{Convert.ToString((long)x, 2).PadLeft(4, '0')} {c} {d} {result}:{Convert.ToString((long)result, 2).PadLeft(4, '0')}");
			return result;
		}

	}
}


Measured memory_bytes: 13396
import sys
input = sys.stdin.readline
from collections import deque
def main():
    L, R = map(int, input().split())
    ans = 2019
    if R - L >= 2019:
        for i in range(L,L+2019):
            for j in range(L+1,L+2020):
                mod = i*j%2019
                ans = min(ans, mod)
    else:
        for i in range(L,R):
            for j in range(L+1,R+1):
                mod = i*j%2019
                ans = min(ans, mod)
    print(ans) 

if __name__ == '__main__':
    main()

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

int main() {
    int m, n; cin >> m >> n;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            string s; cin >> s;
            if (s == "snuke") cout << (char) ('A' + j) << i + 1 << endl;
        }
    }
    cout << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#define T 1001
#define M 1000000007
#define E e[x][i]
#define S e[x].size()
using namespace std;
typedef long long ll;
ll func(int);
int N,s,t,j;
string n[T];
vector<int> e[T];
 
main(){
  cin>>N;
  for(j=0;j<N;j++) cin>>n[j];
  N--;
  while(N--) cin>>s>>t,e[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
}

ll func(int x){
  ll res=0,i;
  if(!S){
    if(n[x]=="E") return 1;
    return 2;
  }
  if(n[x][0]=='E'){
    res++;
    for(i=0;i<S;i++) res*=func(E);
    if(n[x]=="E?") res++;
  }
  else if(n[x][0]=='A'){
    for(i=0;i<S;i++) res+=func(E);
    if(n[x]=="A?") res++;
  }else{
    res++;
    for(i=0;i<S;i++) res*=(1+func(E));
    if(n[x]=="R") res--;
  }
  return res%M;
}

Measured memory_bytes: 1360