akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ull MOD = 998244353;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int x, y; cin >> x >> y;
  REP(i, x+1){
    if(2*i+4*(x-i) == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

#define N 100005

typedef struct {
	int parent;
	int appear;
	int member;
	int root;
}node_t;

node_t node[N] = { 0 };

int input();
	void joint(int ja, int jb);
		int root(int ra);
void output(int n);

int main(void) {
	int n = input();
	
	output(n);

	return 0;
}

int input() {
	int n, m, k, a, b, c, d;
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; i++)
		node[i].member = 1;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a, &b);
		node[a].appear++;
		node[b].appear++;
		joint(a, b);
	}
	for (int i = 1; i <= n; i++)
		node[i].root = root(i);
	for (int i = 0; i < k; i++) {
		scanf("%d %d", &c, &d);
		if (node[c].root == node[d].root) {
			node[c].appear++;
			node[d].appear++;
		}
	}
	return n;
}

void output(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (node[node[i].root].member > 1) {
			ans = node[node[i].root].member - node[i].appear - 1; 
			printf("%d", ans);
		}
		else
			printf("0");
		if (i != n)
			printf(" ");
		else
			printf("\n");
	}
	return;
}

void joint(int a, int b) {
	int ra = root(a), rb = root(b);

	if (ra != rb) {
		if (node[ra].member >= node[rb].member) {
			node[rb].parent = ra;
			node[ra].member += node[rb].member;
			node[rb].member = 0;
		}
		else {
			node[ra].parent = rb;
			node[rb].member += node[ra].member;
			node[ra].member = 0;
		}
	}
	return;
}

int root(int node_no) {
	if (node[node_no].parent == 0)
		return node_no;
	else
		return root(node[node_no].parent);
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

char dp[1000010];

int main(){
	int n,a,b;
	while(scanf("%d%d%d",&n,&a,&b),n|a|b){
		memset(dp,0,sizeof(dp));
		dp[0] = 1;
		int ret = n;
		for(int i=0; i<n; i++)if( dp[i] ){
			if( i+a<=n ){
				if( !dp[i+a] ){ ret--; dp[i+a]=1; }
			}
			if( i+b<=n ){
				if( !dp[i+b] ){ ret--; dp[i+b]=1; }
			}
		}
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 0
// https://atcoder.jp/contests/abc170/tasks/abc170_c

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int X_MAX = 100;
const int N_MAX = 100;
const int P_I_MAX = 100;

int X, N;
vector<int> p;

vector<bool> f;

int main() {
  cin >> X >> N;
  p = vector<int>(N);
  REP(i, N) cin >> p[i];

  f = vector<bool>(102, false);
  REP(i, N) f[p[i]] = true;
  int ans = 1e6;
  FOR(i, 0, 101) {
    if (!f[i] && abs(i - X) < abs(ans - X)) ans = i;
  }

  cout << ans << endl;
}


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

using namespace std;

int main(void) {
    int k, a, b;
    cin >> k >> a >> b;
    if(((b / k) * k) >= a){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
from collections import defaultdict

d = defaultdict(int)
def f():
  global d
  for x in range(1, 10**2+1):
    x2 = x**2
    if x2 >= 10**4:
      break
    for y in range(x, 10**2+1):
      y2 = y**2
      if x2 + y2 >= 10**4:
        break
      for z in range(y, 10**2+1):
        z2 = z**2
        num = x2 + y2 + z2 + x*y + y*z + z*x
        if num > 10**4:
          break
        l = len(set([x, y, z]))
        if l == 1:
            d[num] += 1
        elif l == 2:
            d[num] += 3
        else:
            d[num] += 6
  return True

_ = f()
N = int(input())
ans = []
for i in range(1, N+1):
  ans.append(d[i])

print(*ans, sep='\n')

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i] && b[i] == c[i]) continue;
    else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ans++;
    else ans += 2;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
kouho = []
ans = 0

AB = sorted(AB)

# 後ろから見て優先度付きキューで取り出す
n = 0
heapq.heapify(kouho)
for i in range(1, M+1):
    if n < N:
        while AB[n][0] <= i:
            heapq.heappush(kouho, AB[n][1] * (-1))
            n += 1
            if n >= N:
                break
    
    if kouho:
        b = heapq.heappop(kouho)
        ans += b*(-1)
    
print(ans)

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

void test_data(int N, vector<double>v){
    N = 2;
    v = {3, 4};
    cout << v[0] << endl;
}

int input_data(int N, vector<double> v){
    cin >> N;

	for(int i=0; i<N; i++) {
		int x;
		cin >> x;
        v.push_back(x);
	};
}

double nabe(double x, double y){
    double ans = (x + y) / 2;
    return ans;
}

int main(){
    // int N = 3;
    // vector<double> v = {3, 4, 5};


    int N;
    vector<double> v;
    
    cin >> N;

	for(int i=0; i<N; i++) {
		int x;
		cin >> x;   
        v.push_back(x);
	};

    for(int i=0; i<v.size(); i++){
        // cout << v.at(i) << endl;
    }

    // vector<double> v_s;
    sort(v.begin(), v.end());

    for(int i=0; i<v.size(); i++){
        // cout << v.at(i) << endl;
    }

    // double test_ans = nabe(x, y);
    double x = nabe(v.at(0), v.at(1));

    if(N>=3){
        for(int i=2; i<v.size(); i++){
        // cout << x << "+" << v.at(i) << endl;
        x = nabe(v.at(i), x);
        // cout << i << endl;
         }
        
        cout << x << endl;
        return 0;
    }
    else if(N<=2){
        cout << x << endl;
        return 0;
    }

    
   
    // ans.push_back(nabe(v.at(0), v.at(1)));
    // cout << "ans" << endl;
    // cout << x << endl;
    // ans.push_back( nabe(v.at(1), v.at(2)));

    // cout << test_ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void){
  int L;
  cin >> L;
  double e = ((double)L)/3.0;
  std::cout << std::fixed;
  cout << std::setprecision(10) << e*e*e << endl;
  return 0;
}


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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b);
    return 0;
}


Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int R = in.nextInt();
        if(N >= 10){
            println(R);
        }
        else{
            println(R + 100 * (10 - N));
        }  
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22484
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int N, b[101], ans[101];
	int i,j;
	scanf("%d", &N);
	int N_copy = N;
	for (i = 1;i <=N;i++)
	{
		scanf("%d", &b[i]);
		if (b[i] > i)
		{
			printf("-1\n");
			return 0;
		}
	}
	for ( i=N;N>0;i--)
	{
		if (b[i] == i)
		{
			ans[N] = b[i];
			for (j=i;j<N;j++)
			{
				b[j] = b[j+1];
			}
			N--;
			i = N+1;
		}
	}

	for (i=1;i<=N_copy;i++)
	{
		printf("%d\n", ans[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,t,u;
  int a, b;
  cin >> s;
  //cin >> a >> b;
  //cin >> s >> t >> u;
  
  if(s=="ABC") cout <<  "ARC" << endl; 
  else cout << "ABC" << endl; 
  
}

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

int main(){ 
    int n;
    int a=0;
    int b=0;
    int c=10000000;
    cin >>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    for(int i=0;i<n;i++){
a +=vec.at(i);
    }
    for(int i=0;i<n;i++){
a=a-vec.at(i)-vec.at(i);if(a<0){
    a*=-1;
    break;
}
c=min(a,c);
    }
    if(a>=c){
        cout<<c<<endl;
    }else{
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
target = ans - 1
sum = 0
for aa in a:
    sum += target%aa
print(sum)

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
int l, r, d, ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> l >> r >> d;
for (int i=l; i<=r; i++){
	if (i%d==0) ans++;
} cout << ans;
return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  bool cond1 = (S[0] == S[1]) && (S[2] == S[3]) && (S[0] != S[2]);
  bool cond2 = (S[0] == S[2]) && (S[1] == S[3]) && (S[0] != S[1]);
  bool cond3 = (S[0] == S[3]) && (S[1] == S[2]) && (S[0] != S[1]);
  if (cond1 || cond2 || cond3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
def countingSort(A, B, k, n):
	C = [0] * (k + 1)

	# C[i]にiの出現数を記録する
	for j in range(n):
		C[A[j]] += 1
	
	# C[i]にi以下の数の出現数を記録する
	for i in range(1, k + 1):
		C[i] = C[i] + C[i - 1]

	for j in range(n - 1, -1, -1):
		B[C[A[j]] - 1] = A[j]
		C[A[j]] -= 1


if __name__ == "__main__":
	n = int(input())
	A = list(map(int, input().split()))
	k = max(A)
	B = [0] * n
	countingSort(A, B, k, n)
	print(' '.join(map(str, B)))



Measured memory_bytes: 240320
import sys, os


if 'local' in os.environ :
    sys.stdin = open("./input.txt", "r")

a,b,c,d,e,k = int(input()),int(input()),int(input()),int(input()),int(input()), int(input())

if e-a>k:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<set>
using namespace std;
const int N=100005;

int n,p[N];

int fa[N];
int find(int u) {return u==fa[u] ? u : fa[u]=find(fa[u]);}
int m;
set<int> s[N];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&p[i]),fa[i]=i;
	for (int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		fa[find(u)]=find(v);
	}
	for (int i=1;i<=n;i++) s[find(i)].insert(p[i]);
	int ans=0;
	for (int i=1;i<=n;i++) if (s[fa[i]].find(i)!=s[fa[i]].end()) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10368
import itertools

n = int(input())
H = list(map(int, input().split()))

count = 0
h_max = max(H)
for i in range(1, h_max + 1):
    watering = [(1 if h >= i else 0) for h in H]

    itrs = itertools.groupby(watering)
    watering_group = [k for k, v in itrs if sum(list(v)) > 0]
    count += sum(watering_group)

print(count)

Measured memory_bytes: 3064
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d: String = " ") = str().split(d)
fun <T> list(d: String = " ", f: String.() -> T) = read(d).map { f(it) }
fun list() = list { toInt() }

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
    abc000X()
}

fun abc000X() {
    val n = int()
    val a = BooleanArray(n) {
        val (p, q) = list()
        p == q
    }

    (0..n - 3).any { a[it] && a[it + 1] && a[it + 2] }
            .let { println(if (it) "Yes" else "No") }
}


Measured memory_bytes: 37972
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let a:i32 = match buf.trim().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	
	if a < 3200 {
		println!("red");
	}else{
		println!("{}", s);
	}
}

Measured memory_bytes: 4352
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N, _ := io.nextInt()
	var a [5]int
	var b [5]int
	for i := 0; i < 5; i++ {
		a[i], _ = io.nextInt()
		b[i] = N / a[i]
		if N%a[i] != 0 {
			b[i]++
		}
	}

	max := b[0]
	for i := 1; i < 5; i++ {
		if b[i] > max {
			max = b[i]
		}
	}

	io.PutInt(max + 4)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //?§???????????????¢??????????????????
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int n;

    while (cin >> n, n){
        int m[11][11], x[11] = {0}, y[11] = {0}, sum = 0;
        REP(i, n){
            REP(j, n){
                cin >> m[i][j];
                x[i] += m[i][j];
                y[j] += m[i][j];
                sum += m[i][j];
            }
        }

        REP(i, n){
            REP(j, n){
                printf("%5d", m[i][j]);
            }
            printf("%5d", x[i]);
            cout << "\n";
        } 

        REP(i, n){
            printf("%5d", y[i]);
        }

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

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

int main() {
int X, N;cin >> X >> N;
vector<int> V(N);

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

if(N == 0)cout << X;

else{

for(int i = 0; i < 10000;i++){
bool C = 1, D = 1;
    for(int j = 0; j < N;j++){

    if(V[j] == X - i)C =0;
    if(V[j] == X + i)D = 0;

    }

if( (C && !D) || (C && D) ){cout << X - i;break;}

if(!C && D){cout << X + i;break;}

}

}

}

Measured memory_bytes: 3628
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    X = I()
    print((X // 500) * 1000 + ((X % 500) // 5) * 5)

if __name__ == '__main__':
    main()

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

using namespace std;

const int MOD=1e9+7;
//const int MOD=998244353;

const double PI=3.14159265359;

vector<int> getPrimes(int stop){
    int sieveStop=ceil(sqrt(stop));
    vector<int> psj;
    for(int i=2; i<=sieveStop; i++){
        bool isP=true;
        for(int j=2; j<i && isP; j++){
            isP=i%j;
        }
        if(isP) psj.push_back(i);
    }
    
    vector<bool> primesb(stop+1,true);
    for(int j:psj){
        for(int i=2; i*j<=stop; i++){
            primesb[i*j]=false;
        }
    }
    vector<int> ans;
    for(int i=2; i<=stop; i++){
        if(primesb[i]) ans.push_back(i);
    }
    return ans;
}


int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long n,p;
    cin>>n>>p;
    
    if(n==1){
        cout<<p;
        return 0;
    }
    
    auto pl=getPrimes(1000000);
    
    //cout<<pl.size();
    
    long long ans=1;
    for(int i:pl){
        int ct=0;
        while(!(p%i)){
            p/=i;
            ct++;
        }
        ct/=n;
        for(int j=0; j<ct; j++){
            ans*=i;
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N, M;
vector<int> pa[100001];
list<int> ch[100001];
int tps[100001], res[100001];
bool used[100001];
stack<int> st;

void topo_sort() {
	int root;
	for (int i = 1;i <= N;i++) {
		if (pa[i].empty()) {
			root = i;
			break;
		}
	}
	st.push(root);
	used[root] = true;
	int num = N;
	while (!st.empty()) {
		int r = st.top();
		while (!ch[r].empty() && used[*ch[r].begin()]) {
			ch[r].pop_front();
		}
		if (ch[r].empty()) {
			tps[r] = num--;
			st.pop();
		}
		else {
			st.push(*ch[r].begin());
			used[*ch[r].begin()] = true;
			ch[r].pop_front();
		}
	}
}

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

	cin >> N >> M;
	REP(i, N - 1 + M) {
		int A, B;
		cin >> A >> B;
		ch[A].push_back(B);
		pa[B].push_back(A);
	}
	topo_sort();
	for (int i = 1;i <= N;i++) {
		int n = pa[i].size();
		int tmp = 0;
		for (int j = 0;j < n;j++) {
			if (tmp < tps[pa[i][j]]) {
				tmp = tps[pa[i][j]];
				res[i] = pa[i][j];
			}
		}
	}
	for (int i = 1;i <= N;i++) cout << res[i] << "\n";
	
	return 0;
}

Measured memory_bytes: 12240
N = int(input())
A, B = [],[]
for _ in range(N):
	ta,tb = map(int, input().split())
	A.append(ta)
	B.append(tb)

A = A[::-1]
B = B[::-1]

ans = 0
for i in range(N):
	A[i] += ans
	ans += -A[i] % B[i]

print(ans)

Measured memory_bytes: 14900
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

bool compare_by_b(pair<int,string> a, pair<int,string> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second < b.second;
	}
}

int main()
{
	ll N,ANS=0;
	cin >> N;
	fore(i,1,N+1){
		if(i%3==0||i%5==0){
			continue;
		}
		else{
			ANS=ANS+i;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 3196
import java.util.*;
import java.io.*;

public class Main{

  public static long query(long[] h, long A, long B, long T){
    long need = 0;
    for(int i=0;i<h.length;i++){
      if(h[i]-B*T>0){
        need += (long)Math.ceil((double)(h[i]-B*T)/(double)(A-B));
      }
    }
    return need;
  }

  public static void main(String[] args) {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
      String[] sArr = in.readLine().split(" ");
      int N = Integer.parseInt(sArr[0]);
      long A = Long.parseLong(sArr[1]);
      long B = Long.parseLong(sArr[2]);
      long[] h = new long[N];

      for(int i=0;i<N;i++){
        h[i] = Long.parseLong(in.readLine());
      }

      long t = (long)Math.pow(10, 9);
      long min=0;
      long max=(long)Math.pow(10, 9);
      long need;
      while(max-min>1){
        t=min+(max-min)/2;
        need = query(h, A, B, t);
        if(need>t){
          min=t;
        }else if(need<=t){
          max=t;
        }
      }

      System.out.println(max);

    }catch(IOException e){
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 30892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  for(int i=1;i<=9;++i) {
    if(n % i == 0) {
      if(1 <= n / i && n / i <= 9) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
from functools import reduce


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7


def cmb(N, A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    # pow(den,MOD-2,MOD)はdenの逆元
    return num * pow(den, MOD - 2, MOD) % MOD


def main():
    N, K = map(int, input().split())
    R = N - K
    if R >= K - 1:
        for i in range(K):
            A = cmb(R + 1, i + 1)
            if i >= 1:
                B = cmb(K - 1, i)
            else:
                B = 1
            print(A * B % MOD)
    else:
        for i in range(R + 1):
            A = cmb(R + 1, i + 1)
            if i >= 1:
                B = cmb(K - 1, i)
            else:
                B = 1
            print(A * B % MOD)
        for i in range(K - R - 1):
            print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3940
import Data.IORef
import Control.Monad

main :: IO()
main = do
        n <- readLn
        x <- readLn
        y <- readLn
        print =<< solve (y - x) (min x y) n

solve :: Int -> Int -> Int -> IO Int
solve a b n = do
                a' <- newIORef a
                b' <- newIORef b
                n' <- newIORef (n - 2)
                solve' a' b' n'
    where solve' x' y' n' = do
                             n <- readIORef n'
                             if n == 0 then readIORef x'
                             else do
                              modifyIORef n' (subtract 1)
                              z <- readLn
                              x <- readIORef x'
                              y <- readIORef y'
                              when (z - y > x) $ writeIORef x' (z - y)
                              when (z < y) $ writeIORef y' z
                              solve' x' y' n'

Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int dfs(int node, vector<vector<int>>& edge, vector<int>& dst, vector<bool>& used){
    if(used[node]) return -1;
    used[node] = true;
    int ret = dst[node];
    for(auto e:edge[node]){
        if(e == node) continue;
        ret = max(ret, dfs(e, edge, dst, used));
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    char c;
    vector<vector<int>> edge(n, vector<int>());
    for(int x = 0; x < n; x++){
        for(int y = 0; y < n; y++){
            cin >> c;
            if(c == '1'){
                edge[x].push_back(y);
                edge[y].push_back(x);
            }
        }
    }

    int ans = 0;

    for(int i=0;i<n;i++){
        vector<int> dst(n, -1);
        queue<P> q;
        q.push(make_pair(i,0));
        int tar, depth;
        while(!q.empty()){
            tie(tar, depth) = q.front();q.pop();
            // cout << i << ": " << tar << ". " << depth << endl;  
            if(dst[tar] == -1 ){
                dst[tar] = depth;
                for(auto e: edge[tar]){
                    if(dst[e] != -1 && dst[e] == depth - 1) continue;
                    q.push(make_pair(e, depth+1));
                }
            }else if(dst[tar] != depth){
                cout << -1 << endl;
                return 0;
            } // dst same -> nothing to do
        }

        int first = 0, second = 0;
        vector<bool> used(n, false);
        used[i] = true;
        for(auto e: edge[i]){
            int val = dfs(e, edge, dst, used);
            if(val >=first){
                second = first;
                first = val;
            }else if(val > second){
                second = val;
            }
        }
        ans = max(ans, first+second+1);
    }
    cout << ans << endl;

}

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

typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

struct LIST_node{
	LIST_node *pre;
	LIST_node *nex;
	int id;
	void add_pre(int id_ = 0){
		pre->nex = new LIST_node;
		pre->nex->pre = pre;
		pre->nex->nex = this;
		pre->nex->id = id_;
		pre = pre->nex;
	}
	void add_nex(int id_ = 0){
		nex->pre = new LIST_node;
		nex->pre->pre = this;
		nex->pre->nex = nex;
		nex->pre->id = id_;
		nex = nex->pre;
	}
	LIST_node* erase(){
		pre->nex = nex;
		nex->pre = pre;
		return nex;
	}
};

struct enkan_LIST{
	LIST_node *root;
	LIST_node *pos;
	void init(int id_ = 0){
		root = new LIST_node;
		root->pre = root;
		root->nex = root;
		root->id = id_;
		pos = root;
	}
};

int main(){
	static int R,C,N;
	static int x[100010][2],y[100010][2];
	scanf("%d%d%d",&R,&C,&N);
	for(int i = 1 ; i <= N ; i ++){
		for(int j = 0 ; j < 2 ; j ++){
			scanf("%d%d",&x[i][j],&y[i][j]);
		}
	}
	
	vector<P> points;
	for(int i = 1 ; i <= N ; i ++){
		if(0 < x[i][0] && x[i][0] < R && 0 < y[i][0] && y[i][0] < C)continue;
		if(0 < x[i][1] && x[i][1] < R && 0 < y[i][1] && y[i][1] < C)continue;
		for(int j = 0 ; j < 2 ; j ++){
			if(y[i][j] == 0){
				points.pb(P(x[i][j],i));
			}
			else if(y[i][j] == C){
				points.pb(P(2*R+C-x[i][j],i));
			}
			else if(x[i][j] == R){
				points.pb(P(R+y[i][j],i));
			}
			else {
				points.pb(P(2*C+2*R-y[i][j],i));
			}
		}
	}
	sort(points.begin(),points.end());
	
	if(points.size() == 0){
		puts("YES");
		return 0;
	}
	
	int siz = points.size();
	enkan_LIST lis;
	lis.init(points[0].sc);
	for(int i = 1 ; i < points.size() ; i ++){
		lis.pos->add_nex(points[i].sc);
		lis.pos = lis.pos->nex;
	}
	
	LIST_node* check_begin = lis.pos;
	while(1){
		while(lis.pos->pre->id == lis.pos->id){
			lis.pos->pre->erase();
			lis.pos = lis.pos->erase();
			siz -= 2;
			if(siz == 0)break;
			check_begin = lis.pos;
		}
		if(siz == 0)break;
		lis.pos = lis.pos->nex;
		if(lis.pos == check_begin)break;
	}
	
	if(siz == 0){
		puts("YES");
	}
	else puts("NO");
}



Measured memory_bytes: 9584
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        x: [(String, String); n],
    }

    let mut jpy: i32 = 0;
    let mut btc: f64 = 0.0;

    for (value, unit) in x {
        if unit == "JPY" {
            jpy += value.parse::<i32>().unwrap();
        } else {
            btc += value.parse::<f64>().unwrap();
        }
    }

    println!("{}", jpy as f64 + btc * 380000.0);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    ll K, A, B;
    cin >> K >> A >> B;

    auto solve = [&]() {
        if (A < B) {
            ll t = K - A + 1;
            if (t < 0) return K + 1;
            ll n = A;
            n += (B - A) * (t / 2);
            if (t % 2 == 1) n++;
            return max(n, K + 1);
        } else {
            return K + 1;
        }
    };
    cout << solve() << endl;
    return 0;
}

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = INF;
	int tmp;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	int ch[n+1] = {};
	REP1(i,n) ch[a[i-1]] = ch[a[i-1]-1] + 1;
	REP1(i,n) ans = min(ans, n - ch[i]);
	cout << ans << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

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

int main(){
  ios; cfs(15);
  int n;
  scan(n);
  vi a(n);
  rep(i, n) {
    int x;
    cin >> x;
    a[i] = x;
  }

  unsigned long long s=0;
  rep2(i, 1, n) {
    if(a[i-1] > a[i]) {
      int temp = (a[i-1] - a[i]);
      s += temp;
      a[i] += temp;
    }
  }
  cout<<s<<endl;
  ret;
}


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

using namespace std;

typedef long long ll;

int main(){
    int N;
    int input;
    cin >> N;
    
    vector<int> a;
    for (int i = 0; i<N; i++){
        cin >> input;
        a.push_back(input);
    }
    
    vector<ll> acum(N+1,0);
    for(int i = 0; i<a.size(); i++){
        acum[i+1] = acum[i] + a[i];
    }

    ll ans = 1e18;
    for(int i=1; i< N; i++){
        ll x = acum[i];
        ll y = acum[N]-acum[i];
        ans = min(ans, abs(x-y));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2676
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
      puts("a > b");
}
    if(a < b){
      puts("a < b");
}
    if(a == b){
      puts("a == b");
}
    return 0;
}

Measured memory_bytes: 580
import sys

N=int(input())

lst=[]
for i in range(N):
    lst.append(input())


#重複判定
if len(lst) != len(set(lst)):
    print("No")
    exit()


#しりとり判定
nbr=0
flag=0
before_word=""
now_word=""

for i in lst:
    
    if (before_word != ""):
        #前のワードと比較
        #一致しなかったらsys.exit
        if(before_word[-1] != i[0]):
            print("No")
            sys.exit()

    #before_wordを書き換え
    before_word = i

print("Yes")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n,k,q = map(int,input().split()) 
a=[]
for i in range(q):
    a.append(int(input()))

count = [k - q] * n #みんなからｑポイント引いとく
for i in range(q):
    count[a[i] - 1] += 1 #正解者に１ポイント足す
#print(count)
for i in range(n):
    if count[i] <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 10472
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
int main() {
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll>> V(n);
    for(ll i=0;i<n;i++){
        cin >> V[i].first;
        cin >> V[i].second;
    }
    sort(V.begin(),V.end());
    ll represent=0;
    ll count=0;
    for(ll i=0;i<n;i++){
        if(count<k){
            represent=V[i].first;
            count+=V[i].second;
        } else break;
    }
    cout<<represent<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  cin >> s;
  int a[s.size()];
  int c=0;
  rep(i,0,s.size()){
    if(s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
      c++;
      a[i]=c;
    }
    else{
      c=0;
      a[i]=c;
    }
  }
  sort(a, a+s.size()); reverse(a, a+s.size());
  co(a[0]);
  
  return 0;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) int __VA_ARGS__; in(__VA_ARGS__)
//オーバーフロー対策
#define INL(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#pragma endregion RegionDefs

void solve()
{
    double a, b, x; cin >> a >> b >> x;
    if (a * a * b == x)
    {
        cout << 0 << endl;
    }
    else if (a * a * b / 2 < x)
    {
        cout << 90 - atan(a*a*a/2/(a*a*b-x)) * 360 / 2 / M_PI << endl;
    }
    else
    {
        cout << atan(a*b*b/2/x) * 360 / 2 / M_PI << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

#define ll long long int

using namespace std;

bool dfs(vector<vector<ll>> & G, ll n, ll v, vector<ll> & color, ll c) {
    color[v] = c;
    for (ll i = 0; i < G[v].size(); ++i) {
        if (color[G[v][i]] == c) return false;
        if (color[G[v][i]] == 0) {
            if (!dfs(G, n, G[v][i], color, -c)) return false;
        }
    }
    return true;
}

bool isBipartite(vector<vector<ll>> & G, ll n) {
    vector<ll> color(n, 0); // 0 -> is not colored, 1,-1 is red,green
    for (ll i = 0; i < n; ++i) {
        if (color[i] == 0) {
            if (!dfs(G, n, i, color, 1LL)) {
                return false;
            }
        }
    }
    return true;
}

void warshall_floyd(vector<vector<ll>> &d, ll n) {
    for (ll k = 0; k < n; ++k) {
        for (ll i = 0; i < n; ++i) {
            for (ll j = 0; j < n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> G(n, vector<ll>());
    vector<vector<ll>> d(n, vector<ll>(n, 1e9));

    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < n; ++j) {
            char c;
            cin >> c;
            if (c == '1') {
                G[i].push_back(j);
                G[j].push_back(i);
                d[i][j] = 1;
                d[j][i] = 1;
            }
        }
    }

    // check bipartite
    if (!isBipartite(G, n)) {
        cout << -1 << endl;
        return 0;
    }

    warshall_floyd(d, n);

    ll res = 0;
    for (ll i = 0; i < n; ++i) {
        for (ll j = i+1; j < n; ++j) {
            if (d[i][j] != 1e9) {
                res = max(res, d[i][j]);
            }

        }
    }
    cout << res + 1<< endl;
}


Measured memory_bytes: 4572
#include<iostream>
auto main ( ) -> int
{
    for ( int i = 1 ; ; ++ i )
    {
        int a ;
        int b ;
        std::cin >> a >> b ;
        if ( ! ( a || b ) )
        {
            break ;
        }
        std::cout << std::min ( a , b ) << ' ' << std::max ( a , b ) << std::endl ;
    }
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[[] for i in range(N+1)]

for i in range(M):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[-1]*(N+1)
USE[0]=0
USE[1]=0

from collections import deque
Q=deque()
Q.append(1)
while Q:
    x=Q.pop()
    for to in E[x]:
        if USE[to]==-1:
            USE[to]=x
            Q.appendleft(to)

if -1 in USE:
    print("No")
else:
    print("Yes")
    print(*USE[2:])


Measured memory_bytes: 35052
N = gets.chomp.to_i
ans = []
if N % 2 == 0
  ans = [N, N, N/2]
  puts ans.join(' ')
else
  (1..3500).each do |h|
    (1..3500).each do |w|
      x = N * h * w
      y = 4 * h * w - N * h - w * N
      if y > 0 && x % y == 0
        ans = [h, w, x / y]
        puts ans.join(' ')
        exit
      end
    end
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <limits.h>
#include <functional>
using namespace std;
int n,k;
int p[200001];
double ex[200001];
double tmp=0.0;
double ans=0.0;
int main(){
	cin >> n >> k;
	for(int i=0;i<n;i++)cin >> p[i];
	for(int i=0;i<n;i++){
		ex[i] = ((double)p[i]+1.0)/2.0;
	}
	for(int i=0;i<k;i++)tmp+=ex[i];
	ans=max(ans,tmp);
	for(int i=k;i<n;i++){
		tmp-=ex[i-k];
		tmp+=ex[i];
		ans = max(ans,tmp);
	}
	printf("%f\n",ans);
	return 0;
}


Measured memory_bytes: 5972
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
vector<ll> divisor(ll n){
	vector<ll> ret;
	for(int i=1;i<=(int)sqrt(n);i++){
		if(n%i==0){
			ret.push_back(i);
            if(i*i!=n)ret.push_back(n/i);
		}
	}
	sort(ret.begin(),ret.end());
	return(ret);
}
int main(){
    ll a,b;
    cin>>a>>b;
   ll n=gcd(a,b);
   vector<ll> d=divisor(n);
   int t=d.size();
   vector<bool> ch(t,true);
   int cnt=1;
   for(int i=1;i<t;i++){
       if(ch[i])cnt++;
       for(int j=1;j<t;j++){
           if(d[j]%d[i]==0)ch[j]=false;
       }
   }
   cout<<cnt<<endl;
}



Measured memory_bytes: 384