akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
//#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define printP(x) "(" << (x).first << ", " << (x).second << ")"
#define mod 1000000007
using namespace std;
typedef pair<int, int> P;

llint n;
vector<llint> G[200005];

llint dtmp[200005];
llint distdfs(vector<llint> G[], int v, int p, llint d)
{
	dtmp[v] = d;
	for(int i = 0; i < G[v].size(); i++){
		llint u = G[v][i], c = 1; //
		if(u == p) continue;
		distdfs(G, u, v, d+c);
	}
}

llint getDiameter(vector<llint> G[], llint n, llint &u, llint &v)
{
	distdfs(G, 1, -1, 0);
	llint max_val = -1, max_v;
	for(int i = 1; i <= n; i++){
		if(max_val < dtmp[i]){
			max_val = dtmp[i];
			max_v = i;
		}
	}
	u = max_v;
	
	distdfs(G, u, -1, 0);
	max_val = -1;
	for(int i = 1; i <= n; i++){
		if(max_val < dtmp[i]){
			max_val = dtmp[i];
			max_v = i;
		}
	}
	v = max_v;
	
	return max_val;
}

int main(void)
{
	cin >> n;
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	llint d = getDiameter(G, n, u, v);
	
	if(d % 3 == 1) cout << "Second" << endl;
	else cout << "First" << endl;
	
	return 0;
}


Measured memory_bytes: 25216
#解説見た 要復習
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-1, -1, -1):
    for j in range(i-1, -1, -1):
        ans += (n-1-i) - (n - bisect.bisect_left(l,l[i]+l[j]))

print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=1000000007,N=100000;
const double pi=acos(-1.0);
typedef long long ll;
int cnt[5];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	int i;
	for (i=1;i<=3;i++)
	{
		int x=read(),y=read();
		cnt[x]++;cnt[y]++;
	}
	int a=0,b=0;
	for (i=1;i<=4;i++)
	{
		if (cnt[i]==1) a++;
		else if (cnt[i]==2) b++;
	}
	if ((a==2) && (b==2)) cout <<"YES";else cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];
int p[100001]={};
int main() {
	int n,k,q;
	cin>>n>>k>>q;
	rep(i,q){
		int a;
		cin>>a;
		p[a]++;
	}
	rep(i,n){
		if(k-(q-p[i+1])>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#define REP(i,m,n) for(int i = (int)(m) ; i < (int) (n);i++)
#define rep(i,n) REP(i , 0 ,n)
using namespace std;

int n, d[110], c;

int main() {
	cin >> n;
	rep(i, n) cin >> d[i];

	rep(i, n){
		rep(j, n) {
			if (i != j){
				c += d[i] * d[j];
			}
		}
	}
	cout << c / 2 << endl;




	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int co2=0,co5=0;
    loop(i,1,n+1){
      int tmp=i;
      while(tmp%5==0){
	co5++;
	tmp/=5;
      }
      while(tmp%2==0){
	co2++;
	tmp/=2;
      }
    }
    cout<<min(co2,co5)<<endl;
  }
}

Measured memory_bytes: 1160
def isprime(n):
  judge = n
  for i in range(2,int(judge**0.5)+1):
    if judge%i == 0:
      return False
  return True

def solve():
  x = int(input())
  for i in range(x,10**6+15):
    if isprime(i):
      print(i)
      exit()
      
solve()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

    bool issame(int x,int y){
        return root(x)==root(y);
    }

    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    int p[n];
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }

    UnionFind uf(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        uf.merge(x,y);
    }

    int ans=0;
    rep(i,n){
        if(uf.issame(p[i],i)) ans++;
    }

    cout<<ans<<endl;
}


 

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
  int N,M;
  cin>>N>>M;
  int ans = 1;
  rep(i,N){
    ans = min(ans * 2,ans + M);
  }
  print(ans)
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <memory.h>
#include <functional>

using namespace std;

#define REP(i,x) for(int i = 0; i <(int)(x);i++)

typedef int Weight;

struct Edge{
	int src, dst;
	Weight weight;
	Edge(int f, int t, Weight c):src(f),dst(t),weight(c){}
};

struct Node:public vector<Edge>{};
bool operator<(const Edge &a, const Edge &b){
	return a.weight<b.weight;
}
bool operator>(const Edge &a, const Edge &b){
	return b<a;
}

typedef vector<Node>Graph;

//FILE * in = freopen("E", "r", stdin);

int n, m;
int data1[1000];
int data2[1000];

Graph data;

int gcd(int a, int b){
	return b>0?gcd(b,a%b):a;
}

void input(){
	data.clear();
	data.push_back(Node());
	for(int i = 1; i <= n; i++){
		scanf("%d", &data1[i]);
		data.push_back(Node());
		//data[0].push_back(Edge(0,i,1));
		//data[i].push_back(Edge(i,0,1));
	}
	for(int j = 1; j <= m; j++) {
		scanf("%d", &data2[j]);
		data.push_back(Node());
		for(int i = 1; i <= n; i++) {
			if(gcd(data1[i], data2[j])>1){
				data[i].push_back(Edge(i,n+j,1));
			}
		}
		//data[n+j].push_back(Edge(n+j,n+m+1,1));
	}
	data.push_back(Node());
	for(int j = 1; j <= m;j++){
		//data[n+m+1].push_back(Edge(n+m+1,n+j,1));
	}
}

bool dfs(const Graph &G, int v, vector<int> &match, vector<bool>&visit){
	visit[v] = true;
	REP(i,G[v].size()){
		int dst=G[v][i].dst;
		int w = match[dst];
		if(w == -1 || (!visit[w] && dfs(G,w,match,visit))) {
			match[v] = dst;
			match[dst] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(const Graph &G){
	int res = 0;
	vector<int> match(G.size(),-1);
	REP(v,G.size())if(match[v] == -1){
		vector<bool>visit(G.size());
		if(dfs(G,v,match,visit))res++;
	}
	printf("%d\n",res);
	return res;
}

int main() {
	while(true){
		scanf("%d%d", &n, &m);
		if(n == 0) break;
		input();
		bipartite_matching(data);
	}
	return 0;
}

Measured memory_bytes: 3388
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        while((C > 0) && (A > 0)){
            C -= B;
            if (C > 0){
            A -= D;
            }
        }

        if (A > 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35928
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> c(n), v(n), s(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        s[i] = v[i] - c[i];
        if (s[i] > 0) {
            ans += s[i];
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int n, q;

string ret[2] = { "broccoli","cauliflower" };
typedef vector<int> V;
typedef vector<V> VV;
typedef pair<int, int> P;
void euler_tour(int v, VV &g, vector<P> &seg, int& cnt) {
	int l = cnt++;
	for (auto &u : g[v])
		euler_tour(u, g, seg, cnt);
	int r = cnt;
	seg[v] = { l,r };
}
constexpr int b = 300;

int latte[112345];
namespace ike {
	int flag[1000];
	int num[1000][2];
	void init() {
		for (int i : range(1000)) {
			flag[i] = 0;
			num[i][0] = num[i][1] = 0;
		}
	}
	void update(int l, int r) {
		while (l < r) {
			if (l%b == 0 && l + b <= r) {
				flag[l / b] = 1 - flag[l / b];
				l += b;
			}
			else {
				num[l / b][latte[l]]--;
				latte[l] = 1 - latte[l];
				num[l / b][latte[l]]++;
				l++;
			}
		}
	}
	int get() {
		int i = 0;
		int ret = 0;
		while (i < n) {
			int id = i / b;
			ret += num[id][flag[id]];
			i += b;
		}
		return ret;
	}
}

int main() {
	while (cin >> n >> q) {
		VV g(n);
		V l(n);
		for (int i : range(n - 1)) {
			int par; cin >> par;
			g[par - 1].push_back(i + 1);
		}
		for (int i : range(n)) {
			char x; cin >> x;
			l[i] = (x == 'G');
		}
		vector<P> seg(n);
		{
			int id = 0;
			euler_tour(0, g, seg, id);
		}
		ike::init();
		for (int i : range(n)) {
			int pos = seg[i].first;
			latte[pos] = l[i];
			ike::num[pos / b][l[i]]++;
		}
		for (int _ : range(q)) {
			int v;
			cin >> v;
			v--;
			ike::update(seg[v].first, seg[v].second);
			int malta = ike::get();
			cout << ret[malta > n - malta] << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 17584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

list<int> Prime(int num) {
	list<int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

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

	list<int>P = Prime(123456 * 2);
	cin >> N;
	while (N) {
		M = 0;
		for (auto i : P) {
			if (i > N&&i <= N * 2) {
				M++;
			}
			if (i > N * 2) {
				break;
			}
		}
		cout << M << endl;
		cin >> N;
	}
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


map<PII, int> m;
int main() {
	vector<pair<PII, int> > team;
	int t, r, p;
	while ( ~scanf( "%d %d %d", &t, &p, &r ) && t && p && r ) {
		team.resize( t );
		for ( int i = 0; i < t; i++ ) {
			team[ i ] = pair<PII, int>( PII( 0, 0 ), -i - 1 );
		}
		for ( int i = 0; i < r; i++ ) {
			int tid, pid, time;
			string str;
			cin >> tid >> pid >> time >> str;
			if ( str == "WRONG" ) {
				m[ make_pair( tid, pid ) ]++;
			}
			else {
				team[ tid - 1 ].first.first++;
				team[ tid - 1 ].first.second -= ( m[ make_pair( tid, pid ) ] * 1200 ) + time;
			}
		}
		sort( team.rbegin(), team.rend() );
		for ( int i = 0; i < team.size(); i++ ) {
			printf( "%d %d %d\n", -team[ i ].second, team[ i ].first.first, -team[ i ].first.second );
		}

		m.clear();
	}
	return 0;
}

Measured memory_bytes: 1312
N = int(input())

A = list(map(int, input().split()))



A.sort()

res = A[-1]

if N == 2:
    print(res)
    exit()


for i in range(1,N):
    res += 2*A[-1-i]
    if 1 + 2*i == N-1:
        break
    if 1 + 2*i == N:
        res -= A[-1-i]
        break


print(res)





Measured memory_bytes: 94144
import java.util.*;
import java.util.ArrayList;

public class Main{
	public static void main(String args[]){

		//　定数
		// 入力値取得
		int num = 0;
		Scanner sc = new Scanner(System.in);
		String exp  = sc.next();
		String res  = sc.next();
		ArrayList<String> expects = new ArrayList<>();
		ArrayList<String> results = new ArrayList<>();

		// リストに格納
		for(int i=0;i<3;i++ ){
			expects.add(exp.substring(i,i+1));
			results.add(res.substring(i,i+1));

		}

		// 判定
		for(int j = 0;j<expects.size();j++){

			if(expects.get(j).equals(results.get(j))){
				num = num + 1;
			}
		}

		System.out.println(num);
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void)
{
int N, K, i;
char S[10];

scanf("%d", &N);
scanf("%s", S);
scanf("%d", &K);

for(i=0; i<N; i++){
 if(S[i] != S[K-1])
  S[i] = '*';
}

printf("%s \n", S);

return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>  
using namespace std; 
int a[100+1][100+1],dp[100+1][100+1];
int main(){
    int n;
    long long f[100];
    f[0]=2;
    cin>>n;
    for(int i=1;i<=n;i++){
        f[i]=f[i-1]*2+2;
    }
    cout<<f[n]<<endl;
    return 0;
}

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

const int N=100010;
int a[N],n,cnt[2];

bool gao()
{
    for(int i=1;i<=n;i++)
        if(a[i]&1) a[i]--;
    cnt[0]=cnt[1]=0;
    int gcd=a[1];
    for(int i=2;i<=n;i++)
        gcd=__gcd(a[i],gcd);
    for(int i=1;i<=n;i++)
        cnt[(a[i]/=gcd)&1]++;
    if(cnt[0]&1) return 1;
    else if(cnt[1]>1) return 0;
    else
    {
        for(int i=1;i<=n;i++)
            if(a[i]==1) return cnt[0]&1?1:0;
        return gao()^1;
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",a+i);
        cnt[a[i]&1]++;
    }
    if(cnt[0]&1) puts("First");
    else if(cnt[1]>1) puts("Second");
    else
    {
        for(int i=1;i<=n;i++)
            if(a[i]==1){puts(cnt[0]&1?"First":"Second");return 0;}
        puts(gao()^1?"First":"Second");
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n;
pair<int,int> a[200005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i].second>>a[i].first;
	sort(a,a+n);
	int t=0;
	for(int i=0;i<n;i++)
	{
		t+=a[i].second;
		if(t>a[i].first)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!

n = input()

# print(n)

# print(n[0])
# print(n[1])
# print(n[2])

def convert(char):
    if char == '1':
        return '9'
    else:
        return '1'    

a = []
for c in n:
    # print(c)
    a.append(convert(c))

# a = ['0', '0', '0']

# if n[0] == '1':
#     a[0] = '9'
# else:
#     a[0] = '1'
    
# if n[1] == '1':
#     a[1] = '9'
# else:
#     a[1] = '1'
    
# if n[2] == '1':
#     a[2] = '9'
# else:
#     a[2] = '1'

# print(a[0])
# print(a[1])
# print(a[2])

print("".join(a))

Measured memory_bytes: 2940
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	char c;
	scanf("%c", &c);
	printf("%c\n", c < 'a' ? 'A' : 'a');

	Please AC;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, a, b;
	cin >> n >> a >> b;
	vll x(n);
	for (ll i = 0; i < n; i++) cin >> x[i];

	ll ans = 0;
	for (ll i = 0; i < n - 1; i++) ans += min(a * (x[i + 1] - x[i]), b);
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
int n,a;

cin >> n >> a;

while(1){
  n -= 500;
  if(n < 0){
    break;
  }
}

n += 500;

if(n <= a){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector> 
#include <algorithm>
#include<iomanip>
#include<math.h>
#include<string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main() {
    int N;
    cin >> N;
    N %= 10;
    if (N==2||N == 4 || N == 5 || N == 7 || N == 9)cout << "hon" << endl;
    if (N == 0 || N == 1 || N == 6 || N == 8)cout << "pon" << endl;
    if (N == 3)cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0,h,w;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >>x>>y>>z;
  x-=z;
while(x >= y+z){
   c++;
   x-=(y+z);
}
cout << c <<endl;
return 0;
}


Measured memory_bytes: 3624
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<long> h(N);
    for (int i = 0; i < N; ++i){
        cin >> h[i];
    } 
    sort(h.begin(), h.end());
    long MIN = 1000000001;
    K--;
    for(int i = 0; i < (N - K); ++i){
        MIN = min(h[i+K] - h[i], MIN);
    }
    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		int cnt[n+1];
		memset(cnt,0,sizeof(cnt));
		for(int i=0;i<n-1;i++){
			int x;
			cin>>x;
			cnt[x]++;
		}
		for(int i=1;i<=n;i++)
		cout<<cnt[i]<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 4428
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, dist[55]; string x, y, s[55]; vector<int> g[55];
bool isvalid(string t, bool yoko) {
	if (t.size() <= 4) return false;
	if (t[1] != 'o') return false;
	if (t[t.size() - 2] != 'o') return false;
	for (int i = 2; i <= t.size() - 3; i++) {
		if (!((yoko && t[i] == '-') || (!yoko && t[i] == '|'))) return false;
	}
	return true;
}
int main() {
	cin >> H >> W >> x >> y;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = j + 1; k <= W; k++) {
				if (isupper(s[i][j]) && isupper(s[i][k - 1]) && isvalid(s[i].substr(j, k - j), true)) {
					g[s[i][j] - 65].push_back(s[i][k - 1] - 65);
					g[s[i][k - 1] - 65].push_back(s[i][j] - 65);
				}
			}
		}
	}
	for (int i = 0; i < W; i++) {
		string t;
		for (int j = 0; j < H; j++) {
			t += s[j][i];
		}
		for (int j = 0; j < H; j++) {
			for (int k = j + 1; k <= H; k++) {
				if (isupper(t[j]) && isupper(t[k - 1]) && isvalid(t.substr(j, k - j), false)) {
					g[t[j] - 65].push_back(t[k - 1] - 65);
					g[t[k - 1] - 65].push_back(t[j] - 65);
				}
			}
		}
	}
	for (int i = 0; i < 26; i++) dist[i] = -1;
	queue<int> que; que.push(x[0] - 65); dist[x[0] - 65] = 0;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i : g[u]) {
			if (dist[i] == -1) {
				dist[i] = dist[u] + 1;
				que.push(i);
			}
		}
	}
	cout << dist[y[0] - 65] << endl;
	return 0;
}


Measured memory_bytes: 3212
a,b,c = gets.chomp.split(" ").map(&:to_i)
k = gets.to_i
d = []
d << a
d << b
d << c
d.sort!{|a,b|b <=> a}
k.times do |i|
  d[0] = d[0] * 2
end
print("#{d[0]+d[1]+d[2]}\n")

Measured memory_bytes: 1788
#include <stdio.h>

int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    int mx = a < b ? a : b;
    int mn = a + b <= n ? 0 : a + b - n;
    printf("%d %d\n", mx, mn);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 5e5 + 5;
vector<int> seg[4*N];
vector<int> vec;
void init(int cur, int l, int r){
	seg[cur].clear();
	for(int i = l; i <= r; i++){
		seg[cur].pb(vec[i]);
	}
	//cout<<l<<" "<<r<<" "<<seg[cur].size()<<"\n";
	//for(auto x: seg[cur]) cout<<x<<" ";
	//cout<<"\n";
	SORT(seg[cur]);
	if(l == r) return;
	init(2*cur, l, (l+r)/2);
	init(2*cur+1, (l+r)/2 + 1, r);
}
int get(int cur, int l, int r, int tl, int tr){
	if(l > tr || r < tl) return 0;
	if(tl <= l && r <= tr){
		int left = 0, right = r - l;
		//cout<<l<<" "<<r<<" "<<seg[cur].size()<<endl;
		//for(auto x: seg[cur]) cout<<x<<" ";
		//cout<<"\n";
		while(left < right){
			int mid = (left + right) / 2;
			if(seg[cur][mid] <= tr) left = mid+1;
			else right = mid;
		}
		if(seg[cur][left] > tr) return r-l - left + 1;
		else return 0;
	}
	int ans = 0;
	ans += get(2*cur, l, (l+r)/2, tl, tr);
	ans += get(2*cur+1, (l+r)/2 + 1, r, tl, tr);
	return ans;
}
int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n, q; cin>>n>>q;
	vec.resize(n);
	for(auto &x: vec) cin>>x;
	vector<int> idx(N, 1e9);
	for(int i = n-1; i >= 0; i--){
		int tmp = vec[i];
		vec[i] = idx[tmp];
		idx[tmp] = i;
	}
	//for(auto x: vec) cout<<x<<" ";
	//cout<<"\n";
	init(1, 0, n-1);
	while(q--){
		int l, r; cin>>l>>r;
		l--, r--;
		cout<<get(1, 0, n-1, l, r)<<"\n";
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int amari = (a*b) % 2;
  
  //cout << amari <<endl;
  if(amari == 0)
    cout << "Even";
  else
    cout << "Odd";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x[] = new int[3];
		int max = 0;
		for (int i = 0; i < 3; ++i) {
			x[i] = sc.nextInt();
			max = Math.max(max, x[i]);
		}
		int k = sc.nextInt();
		List<Long> a[] = new List[3];
		for (int i = 0; i < 3; ++i)
			a[i] = new ArrayList<Long>();
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < x[i]; ++j)
				a[i].add(sc.nextLong());
			Collections.sort(a[i]);
		}
		sc.close();
		List<Long> ans = new ArrayList<Long>();
		for (int i = 0; i < x[0]; ++i) {
			for (int j = 0; j < x[1]; ++j) {
				for (int m = 0; m < x[2]; ++m) {
					if((i + 1) * (j + 1) * (m + 1) <= k) {
						long tmp = a[0].get(x[0] - i - 1) + a[1].get(x[1] - j - 1) + a[2].get(x[2] - m - 1);
						ans.add(tmp);
					}
				}
			}
		}
		Collections.sort(ans);
		int n = ans.size();
		for (int i = 0; i < k; ++i)
			System.out.println(ans.get(n - i - 1));
	}

}


Measured memory_bytes: 35356
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <tuple>
#include <vector>

template <class... Ts> using tuple_t = std::tuple<Ts...>;
template <class T, class U> using map_t = std::map<T, U>;
template <class T, class U> using pair_t = std::pair<T, U>;
template <class T> using vector_t = std::vector<T>;
template <class T> using set_t = std::set<T>;

int min(const vector_t<int> &nums) {
  int min_ = std::numeric_limits<int>::max();
  for (auto &i : nums)
    if (min_ > i)
      min_ = i;
  return min_;
}

int max(const vector_t<int> &nums) {
  int max_ = std::numeric_limits<int>::min();
  for (auto &i : nums)
    if (max_ < i)
      max_ = i;
  return max_;
}

int main() {
  int N;
  std::cin >> N;
  if (N < 1200)
    std::cout << "ABC" << std::endl;
  else if (N < 2800)
    std::cout << "ARC" << std::endl;
  else
    std::cout << "AGC" << std::endl;
  return 0;
}


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

typedef long long ll;

const int Maxn = 200005;

int n, k;
int a[Maxn];
map <int, int> M;
ll res;

int main()
{
    scanf("%d %d", &n, &k);
    if (k == 1) { printf("0\n"); return 0; }
    M[0]++;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        a[i] = (a[i] + a[i - 1]) % k;
        res += M[a[i] - i] + M[a[i] - i + k];
        if (i >= k - 1) {
            int ind = i - (k - 1);
            M[a[ind] - ind]--;
        }
        M[a[i] - i]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}
 
void solve(){
	ll a, b, c;
	cin >> a >> b >> c;
	if (a >= c) {
		cout << a - c << ' ' << b;
	}
	else {
		cout << 0 << ' ' << max(0ll, b + a - c);
	}
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int ans = 0, flower = 0;
    VI h(n); VIin(h);
    rep(i,n){
        if(flower < h[i]){
            ans += h[i] - flower;
            flower = h[i];
        }else flower = h[i];
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
n,k=NM()
hi=10**9
lo=1
l=L()
def f(mi):
    x=0
    for i in l:
        if i<=mi:
            continue
        x+=(i+mi-1)//mi-1
    if x<=k:
        return True
    return False
while hi>=lo:
    mi=(hi+lo)//2
    if f(mi):
        hi=mi-1
    else:
        lo=mi+1
print(lo)

Measured memory_bytes: 93876
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

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

    vector<int> data(N);
    vector<int> data2(N);

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

    sort(data2.begin(), data2.end(), greater<int>());

    for (int i = 0; i < N; i++) {
        if (data[i] == data2[0]) {
            cout << data2[1] << endl; 
        } else {
            cout << data2[0] << endl;
        }
    }

}



Measured memory_bytes: 3200
#include<stdio.h>
#include<math.h>
int main(void){
	
	double answer,px,py,p2x,p2y,tate,yoko;
	scanf("%lf %lf %lf %lf",&px,&py,&p2x,&p2y);
	if(py<p2y){
		tate=p2y-py;
	}else if(p2y<py){
		tate=py-p2y;
	}else{
		tate=0;
	}
		if(px<p2x){
	yoko=p2x-px;
		}else if(p2x<px){
	yoko=px-p2x;
		}else{
	yoko=0;
	}
	answer=pow(tate,2)+pow(yoko,2);
	printf("%f",sqrt(answer));
return 0;
}

Measured memory_bytes: 2712
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    int n;
    cin >> n;
    
    vector<string> str(2);

    cin >> str[0];
    cin >> str[1];

    bool frag = true;

    int i = 0;
    LL result;

    if(str[0][0] == str[1][0]){
        i++;
        result = 3;
    }else{
        i += 2;
        result = 6;
        frag = false;
    }

    while(i < n){
        if(frag){
            if(str[0][i] == str[1][i]){
                i++;
                result *= 2;
                result %= MOD;
                frag = true;
            }else{
                i += 2;
                result *= 2;
                result %= MOD;
                frag = false;
            }
        }else{
            if(str[0][i] == str[1][i]){
                i++;
                frag = true;
            }else{
                i += 2;
                result *= 3;
                result %= MOD;
                frag = false;
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
lst = list(map(int,input().split()))
cnt = 0
for i in range(N):
    for j in range(N-1, i, -1):
        if (lst[j] < lst[j-1]):
            lst[j],lst[j-1] = lst[j-1],lst[j]
            cnt += 1
print(" ".join(list(map(str, lst))))
print(cnt)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t N,K;
  cin>>N>>K;
  map<int,int64_t>k;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    k[a]+=b;
  }
  int64_t cnt=K;
  for(auto c:k){
    cnt-=c.second;
    if(cnt<=0){cout<<c.first<<endl;return 0;}
  }
  return 0;  
}

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

int selectionSort(int *A, int N){
    int minj, count=0;
    for(int i=0; i<N; i++){
        minj = i;
        for(int j=i; j<N; j++){
            if(A[j] < A[minj])
                minj = j;
        }
        if(A[i] != A[minj]){
            int temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
            count++;
        }
    }
    return count;
}

int main(){
    int N, count;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++) cin >> A[i];
    
    count = selectionSort(A, N);
    
    for(int i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;

#define fi first
#define se second
#define mp make_pair

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, k;
int dp[100007];
int A[110];

int f(int left){
     int&ans=dp[left];
     if(ans!=-1) return ans;
     ans=0;
     for(int i=0;i<n;i++){
          int temp=left-A[i];
          if(temp>=0) ans=ans||(!f(left-A[i]));
     }
     return ans;
}

int main(){
     memset(dp, -1, sizeof(dp));
     cin>>n>>k;
     for(int i=0;i<n;i++)cin>>A[i];
     sort(A, A+n);
     if(f(k)) cout<<"First"<<endl;
     else cout<<"Second";
}

Measured memory_bytes: 5376
import java.io.*;

public interface Main {
    public static void main(String[] args) throws IOException{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    String str=br.readLine();
    int  num=Integer.parseInt(str);
    
    int h=num/3600;           
    int m=(num%3600)/60;
    int s=(num%3600)%60;
    
    System.out.println(h+":"+m+":"+s);
    
    }
    
}

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

void fill(std::vector<std::deque<int>>& g, std::vector<std::vector<int>>& dp, int v, int d, int i) {
    if (d < 0) return;
    for (int j = 0; j <= d; j++) if (dp[v][j] < 0) dp[v][j] = i;
    if (!d) return;
    for (auto adj : g[v]) {
        if (dp[adj][d - 1] < 0) fill(g, dp, adj, d - 1, i);
    }
}

int main() {
    long long n, m, q;
    std::cin >> n >> m;
    std::vector<std::deque<int>> g(n);
    for (int i = 0; i < m; i++) {
        int p, q;
        std::cin >> p >> q;
        p--; q--;
        g[p].push_back(q);
        g[q].push_back(p);
    }

    std::cin >> q;
    std::vector<std::vector<int>> dp(n, std::vector<int>(11, -1));
    std::vector<int> v(q), d(q), c(q);
    for (int i = q - 1; i >= 0; i--) {
        std::cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    for (int i = 0; i < q; i++) fill(g, dp, v[i], d[i], i);
    for (int i = 0; i < n; i++) std::cout << (dp[i][0] < 0 ? 0 : c[dp[i][0]]) << std::endl;

    return 0;
}

Measured memory_bytes: 77952
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto &it:a) cin>>it;
    int idx = -1;
    int last_num = 0x3f3f3f3f;
    vector<int> anss;
    for (int i = 0; i < a.size(); i++) {
        if(last_num > a[i]){
            anss.push_back(i);
        }
        last_num = min(last_num, a[i]);
    }

    cout<<anss.size()<<endl;
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n,ans=INF*1000000;cin>>n;
    vector<ll> sum(n,0);
    cin>>sum[0];
    for(int i=1;i < n;i++)
    {
        ll a;cin>>a;
        sum[i]=a+sum[i-1];
    }

    rep(i,n-1){
        ans=min(ans,abs(2*sum[i]-sum[n-1]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int a,b;
    while (~scanf("%d %d", &a,&b)) {
        if (b%a==0) printf("%d\n", a+b);
        else printf("%d\n", b-a);
    }
    return 0;
}


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

//関数


//main関数
int main() {
    
    
    //入力
    long N,K;
    cin>>N>>K;
    vector<long> h(N);
    for(int i=0;i<N;i++){
        cin>>h.at(i);
    }
    
    //計算
    sort(h.begin(),h.end());
    long ans=INF;
    for(int i=0;i<=N-K;i++){
        ans=min(ans,h.at(i+K-1)-h.at(i));
    }
    
 
    //出力
    cout<<ans<<endl;
}


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

namespace _164_b
{
    internal class Battle
    {
        private static void Main(string[] args)
        {
            var abcd = Console.ReadLine()?.Split(' ').Select(int.Parse).ToArray();
            if (abcd == null) return;

            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];

            while (true)
            {
                c -= b;
                if (c <= 0)
                {
                    Console.WriteLine("Yes");
                    return;
                }

                a -= d;
                if (a <= 0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 28248
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): return print(arg)
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

S = S()
d = DD(int)
for s in S:
  d[s] += 1
for k in d:
  if d[k]%2:
    NE()
YE()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	sort(S.begin(), S.end());
	bool b = false;
	if ((S[0] == S[1]) && (S[2] == S[3])) {
		if (S[1] != S[2]) b = true;
	}

	cout << (b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620