akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 1000000;

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

typedef long long ll;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/



int main()
{
	double xA, yA, xB, yB, xC, yC, xD, yD;
	
	while (~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
        &xA,&yA,&xB,&yB,&xC,&yC,&xD,&yD))
	{
		if(fabs((xB-xA)*(xD-xC)+(yB-yA)*(yD-yC)) < 1e-10)
		{
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

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

using namespace std;

inline int f(int a, int b) {
	int r = 0;
	for (; a; a /= b)
		r += a % b;
	return r;
}
int main()
{
	int n, m = 1e9;
	cin >> n;
	for (int i = 0; i <= n; i++)
		m = min(m, f(i, 6) + f(n - i, 9));
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    int n;
    E[] g;
    int[] c;
    boolean[] visited;
    int[] ans;

    void run() {

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        g = new E[n];
        for (int i = 0; i < n; i++) g[i] = new E();

        for (int i = 1; i < n; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
            g[a].add(b);
            g[b].add(a);
        }
        c = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }

        Arrays.sort(c);
        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += c[i];
        }

        visited = new boolean[n];
        ans = new int[n];
        dfs(0);

        PrintWriter out = new PrintWriter(System.out);
        out.println(sum);
        out.print(ans[0]);
        for (int i = 1; i < n; i++) {
            out.print(" " + ans[i]);
        }
        out.println();
        out.flush();
    }

    int cnt = 0;
    void dfs(int p) {
        visited[p] = true;
        ans[p] = c[n - cnt - 1];
        cnt++;
        for (int next: g[p]) if (!visited[next]) {
            dfs(next);
        }
    }

    class E extends ArrayList<Integer> {
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 45956
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;


class P
{
    static void Main()
    {
        Console.WriteLine(DateTime.Parse(Console.ReadLine()) <= new DateTime(2019, 4, 30) ? "Heisei" : "TBD");
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int sosuu[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    vector<int> bun(100, 0);
    for (int i = 0; i < 25; ++i) {
        int tmp = 1;
        while(1){
            int d = pow(sosuu[i],tmp);
            if(N / d == 0){
                break;
            }
            bun[sosuu[i]] += N / d;
            tmp++;
        }
    }
    for (int i = 0; i < 100; ++i) {
    }
    vector<int> m(80, 0);
    for (int i = 0; i < 100; ++i) {
        if(bun[i] >= 2){
            m[2]++;
        }
        if(bun[i] >= 4){
            m[4]++;
        }
        if(bun[i] >= 14){
            m[14]++;
        }
        if(bun[i] >= 24){
            m[24]++;
        }
        if(bun[i] >= 74){
            m[74]++;
        }
    }
    int ans = 0;
    ans += m[4] * (m[4] - 1) / 2 * (m[2] - 2);
    ans += m[24] * (m[2] - 1);
    ans += m[14] * (m[4] - 1);
    ans += m[74];
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


int main(){
    CIN(N,k);
    int h;
    int ans=0;
    rep(i,N){
        cin>>h;
        if(h>=k)ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

$visited = Array.new(n+1,false)
$visited[0] = $visited[1] = true
$graph = Array.new(n+1){Array.new(n+1, false)}


edge = []

0.upto(m-1) do |i|
  edge[i] = gets.split.map(&:to_i)
end

#隣接行列
0.upto(m-1) do |i|
  $graph[edge[i][0]][edge[i][1]] = $graph[edge[i][1]][edge[i][0]] = true
end


$ans = 0
#深さ優先探索
def dfs(v)
  if !$visited.include?(false)
    $ans += 1
  else
    $graph[v].each_with_index do |b, i|
      if !$visited[i] & b && i!= 0
        $visited[i] = true
        dfs(i)
        $visited[i] = false
      end
    end
  end
  return
end

dfs(1)
puts $ans


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

const int Maxn = 505;

int n, m;
char B[Maxn][Maxn];
char res1[Maxn][Maxn], res2[Maxn][Maxn];

int main()
{
    scanf("%d %d", &n, &m);
    fill((char*)res1, (char*)res1 + Maxn * Maxn, '.');
    fill((char*)res2, (char*)res2 + Maxn * Maxn, '.');
    for (int i = 0; i < n; i++) {
        scanf("%s", B[i]);
        for (int j = 0; j < m; j++)
            if (B[i][j] == '#')
                res1[i][j] = res2[i][j] = '#';
            else if (i % 2 == 0)
                if (j == 0) res1[i][j] = '#';
                else res2[i][j] = '#';
            else if (j == m - 1) res2[i][j] = '#';
                 else res1[i][j] = '#';
        res1[i][m] = res2[i][m] = '\0';
    }
    for (int i = 0; i < n; i++)
        printf("%s\n", res1[i]);
    printf("\n");
    for (int i = 0; i < n; i++)
        printf("%s\n", res2[i]);
    return 0;
}


Measured memory_bytes: 1536
'use strict'

const translate = (num) => {
  if (num == 1) return num = 14;
  else return num - 0;
}

function main(arg) {
  arg = arg.split(' ');
  const a = translate(arg[0]);
  const b = translate(arg[1]);
  if (a == b) return console.log('Draw');
  if (a > b) {
    console.log('Alice');
  } else {
    console.log('Bob');
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn=3e5+5,maxm=1e5+5;
int m,n;
struct Pair{
    int l,r;
}p[maxn];
bool Cmp(Pair a,Pair b){return a.r-a.l<b.r-b.l;}
class segTree{
    int a[maxn],s[maxn*4],tag[maxn*4];
public:
    segTree(){memset(a,0,sizeof(a));}
    void build(int node,int begin,int end){
        tag[node]=0;
        if(begin==end){
            s[node]=a[begin];
        }else{
            build(2*node,begin,(begin+end)/2);
            build(2*node+1,(begin+end)/2+1,end);
            s[node]=s[2*node]+s[2*node+1];
        }
    }
//    void Updata(int node,int begin,int end,int idx,int add){
//        s[node]+=add;
//        if(begin==end){
//            a[begin]+=add;
//        }else{
//            int m=(begin+end)/2;
//            if(idx<=m){
//                Updata(2*node,begin,m,idx,add);
//            }else{
//                Updata(2*node+1,m+1,end,idx,add);
//            }
//        }
//    }
    void pushdown(int node,int begin,int end){
        if(begin==end){
            s[node]+=tag[node];
            a[begin]=s[node];
        }else{
            tag[2*node]+=tag[node];
            tag[2*node+1]+=tag[node];
            s[node]+=tag[node]*(end-begin+1);
        }
        tag[node]=0;
    }
    void Change(int node,int begin,int end,int left,int right,int add){
        if(begin>=left&&end<=right){
            tag[node]+=add;
        }else{
            pushdown(node,begin,end);
            int m=(begin+end)/2;
            if(!(right<begin||left>m)){
                Change(2*node,begin,m,left,right,add);
            }
            if(!(right<m+1||left>end)){
                Change(2*node+1,m+1,end,left,right,add);
            }
        }
    }
    int query(int node,int begin,int end,int idx){
        pushdown(node,begin,end);
        if(begin==end)return a[begin];
        int m=(begin+end)/2;
        if(idx<=m)return query(2*node,begin,m,idx);
        return query(2*node+1,m+1,end,idx);
    }
}st;
int main(){
    scanf("%d%d",&n,&m);
    st.build(1,1,m);
    for(int i=0;i<n;i++)
        scanf("%d%d",&p[i].l,&p[i].r);
    sort(p,p+n,Cmp);
    int i=0;
    for(int d=1;d<=m;d++){
        while(i<n&&p[i].r-p[i].l<d){
            st.Change(1,1,m,p[i].l,p[i].r,1);
            i++;
        }
        int ans=n-i;
        for(int k=d;k<=m;k+=d){
            ans+=st.query(1,1,m,k);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 11776
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    edge = []
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
        edge.append((a, b))

    que = queue.Queue()
    used = [0 for _ in range(N)]
    parent = [0 for _ in range(N)]
    max_color = 0
    edge_num = {}
    que.put(0)
    used[0] = 1
    while not que.empty():
        cn = que.get()
        color_num = 0
        for nn in G[cn]:
            if used[nn] != 1:
                color_num += 1
                used[nn] = 1
                if (color_num == parent[cn]):
                    color_num += 1
                edge_num[(cn, nn)] = color_num
                parent[nn] = color_num
                que.put(nn)
        max_color = max(max_color, color_num)

    print(max_color)
    for a, b in edge:
        print(edge_num[(a, b)])


if __name__ == '__main__':
    main()


Measured memory_bytes: 93596
N = int(input())
S = [0] * 4
for i in range(N):
    s = input()
    if s == 'AC':
        S[0] += 1
    elif s == 'WA':
        S[1] += 1
    elif s == 'TLE':
        S[2] += 1
    elif s == 'RE':
        S[3] += 1

print('AC', 'x', S[0])
print('WA', 'x', S[1])
print('TLE', 'x', S[2])
print('RE', 'x', S[3])


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

int gcd(int a, int b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main(){
    int K;
    cin >> K;
    int ans = 0;
    for (int a=1; a<=K; a++) {
        for (int b=1; b<=K; b++) {
            for (int c=1; c<=K; c++) {
                ans += gcd(a, gcd(b,c));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	int number1,number2;
	number1 = a * b;
	number2 = c * d;
	if(number1 == number2)
	{
		printf("%d",number1);
	}
	else if(number1 > number2)
	{
		printf("%d",number1);
	}
	else if(number1 < number2)
	{
		printf("%d",number2);
	} 
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<long long> t(n,0);
	for(int i=0;i<n;i++)
	{
		cin >> t.at(i);
	}
	long long k=1;
	for(int i=0;i<n;i++)
	{
		long long mx = max(k,t.at(i)),
		          mn = min(k,t.at(i)),
		          dx = mx,dn = mn;
		while(dn > 0)
		{
			long long dm;
			dm = dx % dn;
			dx = dn;
			dn = dm;
		}
		long long s1 = mx / dx;
		k = s1 * mn;
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a=0, b=0, S=0, L=0;
	
	scanf("%d %d",&a ,&b);
	
	S = a * b;
	L = 2 * (a + b);
	
	printf("%d %d\n",S ,L);
	
	return 0;
}

Measured memory_bytes: 596
n,h = map(int,input().split())
s1 = []
s2 = []
for _ in range(n):
  a, b = map(int,input().split())
  s1.append(a)
  s2.append(b)
maxa = max(s1)
s2.sort(key=lambda x:-x)
ans = 0
for s2i in s2:
  if s2i > maxa:
    ans += 1
    h -= s2i
  if h <= 0:
    break
if h > 0:
  if h % maxa == 0:
    ans += h // maxa
  else:
    ans += h // maxa + 1
  print(ans)
else:
  print(ans)





Measured memory_bytes: 93892
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
	int n;
	int tm;
	int c[105];
	int t[105];
	int min=10000;
	cin >> n;
	cin >> tm;
	for (int i = 1; i < n + 1; i++) {
		cin >> c[i];
		cin >> t[i];
		if (t[i] <=tm && min>c[i]) {
			min = c[i];
		}
	}
	if (min == 10000)cout << "TLE";
	else cout << min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll d= 1000000000;
int main() {
ll S;
cin >> S;
ll x1 = 0;
ll y1 = 0;
ll x2 = d;
ll y2 = 1;
ll y3 = S/d +1;
ll x3 = d - S%d;
if(S == d*d) {
    x3 = 0;
    y3 = d;
    cout << x1 << " "<<y1<<" "<<x2 <<" "<<y2 << " "<<x3 << " "<<y3 <<endl;
}

else{
    cout << x1 << " "<<y1<<" "<<x2 <<" "<<y2 << " "<<x3 << " "<<y3 <<endl;
}
}




Measured memory_bytes: 256
//Author: Suifeng0214
#include <bits/stdc++.h>
#define int long long
using namespace std;
map <char ,int> mp;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++){
		int tmp = i, nums=0;
		while(tmp>0){
			nums += tmp %10;
			tmp /= 10;
		}
		if (a <= nums && nums <= b){
			ans += i;
		}
		
	} 
	cout << ans << "\n";
} 

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

#define rep(i, j, k) for(int i = (int) j; i < (int) k; ++i)
#define sz(x) ((int) (x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int >
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof (x))
#define zerox(x, y) memset((x), (y), sizeof (x))
#define db double

using namespace std;
const db pi = acos(-1.0);
const int N = 200017;

pii u, v;
pii p[N];
int n;

int main()
{
#ifdef PIT
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif //PIT

	//ios_base::sync_with_stdio(false); cin.tie(0);
	scanf("%d %d %d %d", &u.fi, &u.se, &v.fi, &v.se);
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d %d", &p[i].fi, &p[i].se);
	sort(p, p+n);
	if(u.fi > v.fi) swap(u, v);
	if(u.se > v.se) reverse(p, p+n);
	vector<int > vp; vp.clear();
	
	int mi = min(u.se, v.se), mx = max(u.se, v.se);
//printf("st:%d  ed:%d  mi:%d  mx:%d\n", st, ed, mi, mx);
	for(int i = 0; i < n; ++i) {
		if(p[i].se > mx || p[i].se < mi) continue;
		if(p[i].fi > v.fi || p[i].fi < u.fi) continue;
		// printf("i == %d\n", i);
		if(vp.empty() || p[i].se > vp.back()) vp.pb(p[i].se);
		else {
			int d = upper_bound(vp.begin(), vp.end(), p[i].se) - vp.begin();
			vp[d] = p[i].se;
		}
	}
	db ans = 100.0*(v.fi-u.fi + mx-mi);
	int m = sz(vp);
	ans -= 20.0*m;
	ans += pi*5*m;
	if(m == min(mx-mi+1, v.fi-u.fi+1)) ans += pi*5;
	printf("%.15f\n", ans);
	
#ifdef PIT
flush(cout);
cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif //PIT
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  int i,n=s.size();
  long long ans=0;
  
  for(int bit=0;bit<(1<<(n-1));bit++){
    string t;
    for(i=0;i<n;i++){
      t+=s[i];
      if(bit&(1<<i)){
        t+='+';
      }
    }
    long long tmp=0;
    long long sum=0;
    for(i=0;i<t.size();i++){
      if(t[i]=='+'){
        sum+=tmp;
        tmp=0;
      }else{
        tmp=tmp*10+(t[i]-'0');
      }
    }
    sum+=tmp;
    ans+=sum;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

ll b[200010];
int main(){
  int N;
  cin >> N;
  ll a;
  rep(i,N){
    cin >> a;
    b[i] = a-i-1;
  }
  sort(b,b+N);
  ll md = b[N/2];
  ll ans = 0;
  rep(i,N) ans += abs(b[i]-md);
  cout << ans << endl;
}
  





Measured memory_bytes: 1792
//https://atcoder.jp/contests/abc174/tasks/abc174_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin>>x;
	if(x>=30)
	{
		cout<<"Yes"<<"\n";
	}
	else
	{
		cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;

class Combination {
    public:
        ll N;
        ll MOD;
        ll *fact;

        /*
         * MOD must be a prime number.
         */
        Combination(ll N, ll MOD){
            this->N = N;
            this->MOD = MOD;
            fact = new ll[N + 1];
            fact[0] = 1;
            for(ll i = 1; i <= N; i++){
                fact[i] = fact[i - 1] * i % MOD;
            }
        }

        ll pow(ll a, ll b){
            return b ? (b & 1 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1;
        }

        ll comb(ll n, ll k){
            return fact[n] * pow(fact[n - k] * fact[k] % MOD, MOD - 2) % MOD;
        }
};

int main(){
    Combination C(1e5 + 10, MOD);
    ll N;
    cin >> N;
    vector<ll> W(N);
    for(ll &w : W) cin >> w;
    ll ans = 0;
    vector<ll> cnt(N + 1);
    for(ll i = 2; i <= N; i++) cnt[i] = C.fact[i - 1] * C.fact[N - i] % MOD * C.comb(N, i) % MOD;
    vector<ll> sum(N + 1);
    for(ll i = 2; i <= N; i++) (sum[i] += sum[i - 1] + cnt[i]) %= MOD;
    for(ll i = 0; i < N; i++){
        (ans += W[i] * C.fact[N] % MOD) %= MOD;
        (ans += sum[i + 1] * W[i] % MOD) %= MOD;
        (ans += sum[N - i] * W[i] % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int telep[200005][70];
int main(){
  int n;
  long long k;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>telep[i][0];
  }
  
  long long cnt=1;
  while(((long long)1<<cnt)<=k){
    for(int i=1;i<=n;i++){
      telep[i][cnt]=telep[telep[i][cnt-1]][cnt-1];
    }
    cnt++;
  }
  
  cnt=0;
  int pos=1;
  while(((long long)1<<cnt)<=k){
    if((k&((long long)1<<cnt))!=0){
      pos=telep[pos][cnt];
    }
    cnt++;
  }
  cout<<pos<<endl;
  return(0);
}

Measured memory_bytes: 58324
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	instr s;
	inll k;

	ll pos = 0;

	REP (i, k)
	{
		if (s[i] != '1') return OUT(s[i]);
	}
	return OUT(1);
}


Measured memory_bytes: 256
from itertools import product


def solve(string):
    d = len(string)
    if d == 1:
        return string
    s0, ss, sn = int(string[0]), int(string[1:-1] or 0), int(string[-1])
    t = [[0] * 10] + [[int("1" * (d - 2) or 0)] * 10 for _ in range(9)]
    for i in range(1, 10):
        t[i][i] += 1
    for i, j in product(range(1, s0), range(10)):
        t[i][j] += 10**(d - 2)
    for j in range(sn + 1):
        t[s0][j] += ss + 1
    for j in range(sn + 1, 10):
        t[s0][j] += ss
    return str(sum(t[i][j] * t[j][i] for i, j in product(range(1, 10), repeat=2)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define int long long int

int n, k, r, s, p, ans = 0;
string t;

int lesser(char a, char b)
{
    if (a == 'r' && b == 's') return r;
    if (a == 's' && b == 'p') return s;
    if (a == 'p' && b == 'r') return p;
    return 0;
}

int calc(string str, int h)
{
    vector<int> r1(str.length());
    vector<int> s1(str.length());
    vector<int> p1(str.length());

    r1[0] = lesser('r', t[h]);
    s1[0] = lesser('s', t[h]);
    p1[0] = lesser('p', t[h]);

    for (int i = 1; i < str.length(); i++)
    {
        r1[i] = max(s1[i - 1], p1[i - 1]) + lesser('r', t[h + i * k]);
        s1[i] = max(r1[i - 1], p1[i - 1]) + lesser('s', t[h + i * k]);
        p1[i] = max(s1[i - 1], r1[i - 1]) + lesser('p', t[h + i * k]);
    }

    return max(r1[str.length() - 1], max(s1[str.length() - 1], p1[str.length() - 1]));
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k >> r >> s >> p;
    cin >> t;

    for (int i = 0; i < k; i++)
    {
        string cur = "";
        for (int j = i; j < n; j += k)
            cur += t[j];
        ans += calc(cur, i);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
    private long fac[];
    private long finv[];
    private long inv[];
    private static int MAX_LEN = 510000;
    private static int MOD = 1000000007;
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        COMinit();
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        HashMap<Integer, List<Integer>> map = new HashMap<>();
        int n = scan.nextInt();
        int[] a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = scan.nextInt();
            if (!map.containsKey(a[i])) {
                map.put(a[i], new ArrayList<>());
            }
            map.get(a[i]).add(i);
        }
        int left = 0;
        int right = 0;
        for (int x : map.keySet()) {
            List<Integer> list = map.get(x);
            if (list.size() == 2) {
                left = list.get(0) - 1;
                right = n + 1 - list.get(1);
            }
        }
        for (int i = 1; i <= n + 1; i++) {
            System.out.println((COM(n + 1, i) - COM(left + right, i - 1) + MOD) % MOD);
        }
    }
    void COMinit() {
        this.fac = new long[MAX_LEN];
        this.finv = new long[MAX_LEN];
        this.inv = new long[MAX_LEN];
        this.fac[0] = this.fac[1] = 1;
        this.finv[0] = this.finv[1] = 1;
        this.inv[1] = 1;
        for (int i = 2; i < MAX_LEN; i++) {
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }
    long COM(int n, int k) {
        if (n < k) {
            return 0;
        };
        if (n <0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k]%MOD)%MOD;
    }
}


Measured memory_bytes: 89088
#include <iostream>
#include <vector> 
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define int long long

signed main() {
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's') {
        cout << s + "es" << endl;
        return 0;
    }

    cout << s + "s" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

#define INF 1e17

long long cost[301][301],Q,memo[302][301][301];
long long i,j,k,s,a,b,N,L,M;


long long dp(long long n,long long m,long long u)
{
  if(memo[n][m][u]!=-1)
  {
    return memo[n][m][u];
  }
  
  long long t,v,w;
  
  t=dp(n-1,m,u);
  v=dp(n-1,m,n-1)+dp(n-1,u,n-1);
  w=min(t,v);
  
  memo[n][m][u]=w;
  memo[n][u][m]=w;
  
  return w;
  
}

int main()
{
  
  cin >>N>>M>>L;
  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
        cost[i][j]=INF;
        cost[j][i]=INF;  
    }
  }
    for(i=0;i<N+1;i++)
  {
    for(j=0;j<N;j++)
    {
      for(k=0;k<N;k++)
      {
        memo[i][j][k]=-1;
        memo[i][k][j]=-1;
      }
    }
  }
  
  for(i=0;i<M;i++)
  {
    cin>>j>>k;
    
    cin>>s;
    j--;
    k--;
    cost[j][k]=s;
    cost[k][j]=s;    
  }
  for(i=0;i<N;i++)
  {
    cost[i][i]=0;
  }
  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      memo[0][i][j]=cost[i][j];
      memo[0][j][i]=cost[i][j];
    }
  }
  
  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      dp(N,i,j);
      
    }
  }
  
  ////ここまで各頂点の最短距離．以下燃料計算．

    for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
        cost[i][j]=INF;
        cost[j][i]=INF;  
    }
  }
 
  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      if(memo[N][i][j]<=L)
      {
        cost[i][j]=1;
        cost[j][i]=1;
      }

    }
  }
    for(i=0;i<N+1;i++)
  {
    for(j=0;j<N;j++)
    {
      for(k=0;k<N;k++)
      {
        memo[i][j][k]=-1;
        memo[i][k][j]=-1;
      }
    }
  }
  
  for(i=0;i<N;i++)
  {
    cost[i][i]=0;
  }
  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      memo[0][i][j]=cost[i][j];
      memo[0][j][i]=cost[i][j];
    }
  }
  

  
  cin >>Q;
  for(i=0;i<Q;i++)
  {
    cin>>a>>b;
    a--;
    b--;
    j=dp(N,a,b);
    if(j<INF)
    {
      j--;
      cout << j<<endl;
    }
    else
    {
      cout <<-1 <<endl;
    }
  }
  
}



Measured memory_bytes: 214272
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

vector<int> day;
int flag[24] = {};
int D[13] = {};

int solve(int i) {

	if (i == day.size()) {

		int result = 50;

		for (int j = 0; j < 24; j++) {
			if (flag[j] >= 2) {
				result = 0;
				break;
			}

			if (flag[j] == 1) {
				int s = 1;
				while (flag[(j + s) % 24] == 0)s++;
				CHMIN(result, s);
				s = 1;
				while (flag[(j - s + 24) % 24] == 0)s++;
				CHMIN(result, s);
				//cerr << j << " " << result << endl;
			}
		}
/*
		for (int j = 0; j < 24; j++)
			cout << flag[j] << " ";
		cout << endl;

		cerr << result << endl;
*/
		return result;

	}

	int result = 0;

	if (D[day[i]] == 2) {
		flag[(12 + day[i]) % 24]++;
		flag[(12 - day[i]) % 24]++;
		result = solve(i + 1);
		flag[(12 + day[i]) % 24]--;
		flag[(12 - day[i]) % 24]--;
	}
	else {
		flag[(12 + day[i]) % 24]++;
		CHMAX(result, solve(i + 1));
		flag[(12 + day[i]) % 24]--;

		flag[(12 - day[i]) % 24]++;
		CHMAX(result, solve(i + 1));
		flag[(12 - day[i]) % 24]--;
	}

	return result;

}

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

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

	for (int i = 0; i < 13; i++) {
		if (D[i] >= 3) {
			cout << 0 << endl;
			return 0;
		}
		else {
			if (D[i] > 0)
				day.push_back(i);
		}
	}

	flag[12] = 1;
	cout << solve(0) << endl;

	return 0;
}


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

int main()
{
	string X;
	cin >> X;
	int ans =754;//ansに大きな数を入れる//

	for (int i = 0; i <= X.size()-3; i++) {//Xの長さよりも３回少なくループする。iは０から始まり１ずつふえる//

		int MIN = min(ans, abs(753 - stoi(X.substr(i, 3))));
		//ansとXから抜き出したiから三番目までの数を比べ、小さいほうをint MINに代入する。//
		//初回は大きな数と比べるため必ず抜き出した数がint MINに代入される//
		ans = abs(MIN);
		//int MINを絶対値にしてansに代入し、ループする//
	}
	//上のfor文で最も小さいansを出力する//
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;
    int d;
    vector<int> ds;
    for (int i = 0; i < N; ++i) {
        cin >> d;
        ds.push_back(d);
    }

    vector<int> ms;
    ms.push_back(ds[0]);
    for (int i = 1; i < N; ++i) {
        ms.push_back(ds[i] + ms[i - 1]);
    }

    int sum = 0;
    for (int i = 1; i < N; ++i) {
        sum += (ds[i] * ms[i - 1]);
    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: isize,
    };

    let ans = match n % 10 {
        2 => "hon",
        4 => "hon",
        5 => "hon",
        7 => "hon",
        9 => "hon",
        0 => "pon",
        1 => "pon",
        6 => "pon",
        8 => "pon",
        3 => "bon",
        _ => "",
    };

    println!("{}", ans);
}


Measured memory_bytes: 2116
from collections import defaultdict

def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A:
        d[a] += 1

    total = 0
    for i, j in d.items():
        total += (j * (j - 1)) // 2

    for a in A:
        print(total - (d[a] - 1))



if __name__ == "__main__":
    main()

Measured memory_bytes: 87884
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   int n;
   cin >> n;
   bool f = false;
   for(int x = 0; x <= n/4; ++x){
       if((n-4*x)%7==0) f = true;
   }
   if(f) cout << "Yes" << endl;
   else cout << "No" << endl;
}


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

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

for i in range(1,N):
    A[i]=A[i]+A[i-1]

for j in reversed(range(N-1)):
    B[j]=B[j]+B[j+1]


S=[0]*N
for i in range(N):
    S[i]=A[i]+B[i]


print(max(S))


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long X;
	cin >> X;

	long long year = 0;
	long long start = 100;
	while (start < X)
	{
		long long interest = start * 0.01;
		start += interest;
		year++;
	}

	cout << year;

	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define vp vector<pair <$$,$$> >
#define vctr vector<$$>
#define in(a) scanf("%lld",&a)
#define out(a) printf("%lld ",a)
#define loop(i,m,p) for ($$ i = m; i < p; i++)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;


int main()
{
	$$ a,b;
	cin>>a>>b;
	if ((a<=8)&&(b<=8))
	{
		/* code */cout<<"Yay!\n";
	}
	else
		cout<<":(\n";

 




return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int xx[105];
int main()
{
    int n,v,c=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>v;
        xx[v]++;
    }
    for(int i=1;i<=100;i++)
        if(xx[i]!=0)c++;

       cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
ans = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    S = input()
    for j, s in enumerate(S):
        if s == "#":
            ans[i][j] = "#"
            if i != 0:
                if ans[i - 1][j] != "#":
                    ans[i - 1][j] += 1
            if j != 0:
                if ans[i][j - 1] != "#":
                    ans[i][j - 1] += 1
            if i != 0 and j != 0:
                if ans[i - 1][j - 1] != "#":
                    ans[i - 1][j - 1] += 1
            if j != w - 1:
                if ans[i][j + 1] != "#":
                    ans[i][j + 1] += 1
            if j != w - 1 and i != 0:
                if ans[i - 1][j + 1] != "#":
                    ans[i - 1][j + 1] += 1
            if i != h - 1:
                if ans[i + 1][j] != "#":
                    ans[i + 1][j] += 1
            if i != h - 1 and j != w - 1:
                if ans[i + 1][j + 1] != "#":
                    ans[i + 1][j + 1] += 1
            if i != h - 1 and j != 0:
                if ans[i + 1][j - 1] != "#":
                    ans[i + 1][j - 1] += 1

for a in ans:
    print("".join(map(str, a)))


Measured memory_bytes: 74048
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{ 

  int N,K;
  cin>>N>>K;
  vector<pair<int,int> > vp(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vp[i].first>>vp[i].second;
  }
  sort(ALL(vp));
  int SUM = 0;
  int nSUM = 0;
  for (int i = 0; i < N; i++)
  {
    nSUM += vp[i].second;
    if(SUM<K && nSUM >= K)
    {
      cout<<vp[i].first;
      return;
    }
  }
  
  

  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>=s; i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)

#define int long long

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

int fac[MAXN],inv[MAXN];

int qpow(int a,int b) {
	int ans=1;
	while(b) {
		if(b&1) ans=(ans*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return ans;
}

int c(int m,int n) {
	if(n==m||!m||!n) return 1;
	return ((fac[m]*inv[n]%MOD)*inv[m-n])%MOD;
}

int calc(int x_1,int y_1,int x_2,int y_2) {
	return c(abs(x_2-x_1)+abs(y_2-y_1),abs(x_2-x_1));
}

signed main() {
	int h=read(),w=read(),a=read(),b=read();
	fac[0]=1;
	REP(i,1,h+w) fac[i]=(fac[i-1]*i)%MOD;
	
	REP(i,1,h+w) inv[i]=qpow(fac[i],MOD-2);
	int ans=0;	
	REP(i,1,h-a) {
		ans=(ans+calc(1,1,b,i)*(calc(b+1,i,w,h)))%MOD;
	}
	
	printf("%lld\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll int,ll int>
#define PI 2*acos(0)
//#define mx 1000000
#define INF LONG_LONG_MAX
using namespace std;
const ll int p=998244353;
//vector<ll > prime;
//bool mark[mx];
ll int mod(ll int a,ll int b)
{
    ll int m=a%b;
    if(m<0) m=(b<0)?(m-b):(m+b);
    return m;
}
ll maxpow(ll n)
{
    return (n & (~(n-1)));
}
bool isPrime(ll n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
/*void init()
{
    mark[1]=1;
    int i,j,limit=sqrt(mx*1.0)+2;
    prime.push_back(2);
    for(i=4;i<mx;i+=2) mark[i]=1;
    mark[2]=0;
    for(i=3;i<mx;i+=2){
        if(!mark[i]){
            prime.push_back(i);
            if(i<=limit){
                for(j=i*i;j<mx;j+=2*i){
                    mark[j]=1;
                }
            }
        }
    }
}*/
/*
ll maxdiv(ll n)
{
    ll i,ans=1;
    for(i=0;i<prime.size();i++){
        if(n%prime[i]==0){
            ans=n/prime[i];break;
            //return ans;
        }
    }
    return ans;
}*/
ll lcm(ll a,ll b)
{
    ll ans=a*b;
    return (ans/__gcd(a,b));
}
// ax+by and a>b
ll gcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll d=gcd(b,mod(a,b),x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
ll abso(ll a)
{
    if(a>=0) return a;
    return -a;
}
ll div_count(ll n)
{
    bool flag[n+1];
    memset(flag,1,sizeof(flag));
    for(int p=2;p*p<n;p++){
        if(flag[p]){
            for(int i=p*2;i<n;i+=p) flag[i]=false;
        }
    }
    ll total=1;
    for(int p=2;p<=n;p++){
        if(flag[p]){
            int cnt=0;
            while(n%p==0){
                n/=p;
                cnt++;
            }
            total*=(cnt+1);
        }
    }
    return total;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll dp[n+1],l[k+1],r[k+1],pref[n+1];
    memset(dp,0,sizeof(dp));
    memset(pref,0,sizeof(pref));
    for(int i=1;i<=k;i++) cin>>l[i]>>r[i];
    dp[1]=1;dp[0]=0;pref[1]=1;pref[0]=0;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i>=l[j]) dp[i]+=mod(pref[i-l[j]],p);
            if(i>r[j]) dp[i]-=mod(pref[i-r[j]-1],p);
            dp[i]=mod(dp[i],p);
        }
        pref[i]=mod(pref[i-1]+dp[i],p);
    }
    cout<<dp[n];
    return 0;
}
//1028C


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

using namespace std;

/*

    bottom up

*/

const int N = 1e5 + 5;
const int INF = 2e9;

int n , k;
int h[N];
int dp[N];

main(){

    scanf("%d %d" , &n , &k);

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &h[i]);
    }

    // initialize dp table
    for(int i = 0 ; i < n ; i ++){
            dp[i] = INF;
    }
    dp[0] = 0;

    for(int i = 0 ; i < n ; i ++){
            for(int j = 1 ; j <= k ; j ++){
                    dp[i + j] = min(dp[i + j] , abs(h[i] - h[i + j]) + dp[i]);
            }
    }

    printf("%d\n" , dp[n-1]);

    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict
import sys
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())
a = list(map(int, input().split()))
dd = defaultdict(int)

for i in a:
    dd[i] += 1

if len(dd) <= k:
    print(0)
else:
    dd = sorted(dd.items(), key=lambda x: x[1])
    ans = 0
    for i in range(len(dd) - k):
        ans += dd[i][1]
    print(ans)


Measured memory_bytes: 44168
#include <iostream>
#include <vector>

using namespace std;

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v,int N,bool visited[nmax]){
  bool all_visited=true;
  for(int i=0;i<N;i++){
    if(visited[i]==false) all_visited=false;
  }
  if(all_visited) return 1;

  int ret=0;

  for(int i=0;i<N;i++){
    if(graph[v][i]==false) continue;
    if(visited[i]) continue;

    visited[i]=true;
    ret+=dfs(i,N,visited);
    visited[i]=false;
  }

  return ret;
}

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

  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    graph[A-1][B-1]=graph[B-1][A-1]=true;
  }

  bool visited[nmax];
  for(int i=0;i<N;i++){
    visited[i]=false;
  }
  visited[0]=true;
  cout<<dfs(0,N,visited)<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        Point[] points = new Point[n];
        for (int i = 0; i < n; i++) {
            points[i] = new Point(i);
        }
        
        while (m-- > 0) {
            int parent = sc.nextInt() - 1;
            int child = sc.nextInt() - 1;
            points[parent].addChild(points[child]);
        }
        
        int max = 0;
        for (int i = 0; i < n; i++) {
            int length = getLength(0, points[i]);
            max = Math.max(max, length);
        }
        
        System.out.println(max);
    }
    
    public static class Point {
        int name;
        List<Point> children;
        int generationLength = -1;
        
        Point(int name) {
            this.name = name;
            this.children = new ArrayList<Point>();
        }
        
        void addChild(Point p) {
            this.children.add(p);
        }
    }
    
    public static int getLength(int depth, Point p) {
        int length = 0;
        
        boolean alreadyKnown = p.generationLength != -1;
        if (alreadyKnown) {
            return depth + p.generationLength;
        }
        
        if (p.children.isEmpty()) {
            length = depth;
        } else {
            for (Point child : p.children) {
                int l = getLength(depth + 1, child);
                length = Math.max(length, l);
            }
        }
        
        p.generationLength = length - depth;
        
        return length;
    }
}

Measured memory_bytes: 102980
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int X, A;
    scanf("%d %d", &X, &A);
    if(0<=X && X<=9 && 0<=A && A<=9 && X<A)
      {
        printf("0\n");
      }
    else if(X>=0 && X<=9 && 0<=A && A<=9 && X>A || X==A)
    {
    printf("10\n");
    }
    else
{

}
    return 0;
}


Measured memory_bytes: 128