akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

constexpr int mod = 1000000007;
class mint {
public:
    long long x;
    constexpr mint(long long x=0) : x((x%mod+mod)%mod) {}
    constexpr mint operator-() const { 
      return mint(-x);
    }
    constexpr mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    constexpr mint inv() const {
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
};
ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
}

mint COM(ll n,ll a){
 	mint x=1, y=1; 
  	rep(i,a){
     	x*=n-i;
      	y*=i+1;
    }
  	return x/y;
}

int main() {
	ll n,a,b;
  	cin>>n>>a>>b;
  	mint ans(2);
  	ans=ans.pow(n);
	
  	ans-=COM(n,a);
  	ans-=COM(n,b);
  	ans-=1;
  
  	cout<<ans<<endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*
n,m,x = map(int, raw_input().split())
list =[]
list = map(int, raw_input().split())
r_sum = 0
h_sum =0
for i in range(m):
 if list[i] < x:
  r_sum += 1
 if list[i] > x:
  h_sum += 1

if h_sum > r_sum:
 print(r_sum)
else:
 print(h_sum)

Measured memory_bytes: 2568
main = do
  [x,y] <- map read . words <$> getLine
  let g = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
  let gx = map (or . map (==x)) g
  let gy = map (or . map (==y)) g
  putStrLn $ if gx==gy then "Yes" else "No"

Measured memory_bytes: 3656
n,W=map(int,input().split())
wv=[[int(i) for i in input().split()]for _ in range(n)]
dp=[W+1]*(10**5+1)
dp[0]=0
for i in range(0,n):
    w,v = wv[i]
    for j in range(10**5,v-1,-1):
        dp[j]=min(dp[j],dp[j-v]+w)
for i in range(10**5,-1,-1):
    if dp[i]<=W:
        print(i)
        break

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

int main(){
    string s,q,w,e,r,t,y,u;
    cin>>s;
    q="MON";
    w="TUE";
    e="WED";
    r="THU";
    t="FRI";
    y="SAT";
    u="SUN";
    if(s==q){
        cout<<6<<endl;
    }
    else if(s==w){
        cout<<5<<endl;
    }
    else if(s==e){
        cout<<4<<endl;
    }
    else if(s==r){
        cout<<3<<endl;
    }
    else if(s==t){
        cout<<2<<endl;
    }
    else if(s==y){
        cout<<1<<endl;
    }
    else if(s==u){
        cout<<7<<endl;
    }
   return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.TreeSet;
 
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	}
}

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

namespace ConsoleApp15
{
    class Class35
    {
        static void Main()
        {
            var ST = Console.ReadLine().Split();
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var U = Console.ReadLine();
            if (U == ST[0])
            {
                AB[0]--;
            }
            else
            {
                AB[1]--;
            }
            Console.WriteLine(string.Join(" ", AB));
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
int main(){
  ios::sync_with_stdio(0);  cin.tie(0); cout<<setprecision(3); cout<<fixed;
  #ifdef DEBUG
  //freopen("ip.txt","r",stdin);
  clock_t tStart = clock();
  #endif


  char a,b; cin>>a>>b;
  if(a>b) cout<<'>'; else if(a<b) cout<<'<'; else cout<<'=';


  #ifdef DEBUG
	cout<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)<<"s.\n";
	#endif
  return 0;
}


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

int main(){
  
string S;
  cin >> S;
int cnt = 0;
  for(int i = 0;i < 3;i++){
  if(S.at(i) == 'o') cnt++;  
  }
  
  cout << 700 + cnt * 100 << endl;
  return 0;
  
}

Measured memory_bytes: 256
function main(lines) {
  const [N, K] = splitN(lines[0]);
  const ps = splitN(lines[1]).sort((a, b) => a-b);

  let res = 0;
  for (let i = 0; i < K; i++) {
    res += ps[i];
  }
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 29736
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
mn = BIG
for i in range(0,n+1,9):
    j = n-i
    sm = 0
    k = i
    while k>0:
        sm += k%9
        k //= 9
    k = j
    while k>0:
        sm += k%6
        k //= 6
    mn = min(mn,sm)
print(mn)


Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,c,d=0;
  cin>>a;
  vector<int> b(9,0);
  fo(i,a){
    cin>>c;
    b.at(min<int>(8,c/400))++;
  }
  fo(i,8){
    if(b.at(i)>0)
      d++;
  }
  if(d>0)
  cout<<d<<endl<<d+b.at(8)<<endl;
  else
    cout<<1<<endl<<b.at(8)<<endl;
}


Measured memory_bytes: 256
import operator

N, T = [int(i) for i in input().split()]
ct_list = [ [int(i) for i in input().split()] for j in range(N)]

tmp = list(filter(lambda x: operator.ge(T,x[1]), ct_list))

ans = min(tmp, key=lambda x: x[0])[0] if len(tmp) != 0 else "TLE"
print(ans)


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

int main() {
    int a,b,t,x;
    cin >> a >> b >> t;

    for (int i=1; i<t+0.5; i++){
        if (i%a==0) {
            x += b;
        }
    }

    cout << x;
    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 = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int a[1 << 18];
int dp[1 << 18][2][2];
int n;

void dfs(int x){
    dp[x][0][0] = a[x];
    dp[x][0][1] = x;
    dp[x][1][0] = a[0];
    dp[x][1][1] = 0;
    if(dp[x][0][0] < dp[x][1][0]){
        swap(dp[x][0][0], dp[x][1][0]);
        swap(dp[x][0][1], dp[x][1][1]);
    }
    vector<int> v;
    int x_ = x;
    rep(i,n){
        if(x_ % 2 == 1){
            v.push_back(pow(2,i));
        }
        x_ /= 2;
    }
    if(v.size() != 1){
        rep(i,v.size()){
            int y = x ^ v[i];
            if(dp[y][0][0] == -1){
                dfs(y);
            }
            vector<P> p;
            p.push_back(P(dp[x][0][0], dp[x][0][1]));
            p.push_back(P(dp[x][1][0], dp[x][1][1]));
            if(dp[y][0][1]!=dp[x][0][1] && dp[y][0][1]!=dp[x][1][1]){
                p.push_back(P(dp[y][0][0], dp[y][0][1]));
            }
            if(dp[y][1][1]!=dp[x][0][1] && dp[y][1][1]!=dp[x][1][1]){
                p.push_back(P(dp[y][1][0], dp[y][1][1]));
            }
            sort(p.begin(), p.end(), greater<P>());
            dp[x][0][0] = p[0].first;
            dp[x][0][1] = p[0].second;
            dp[x][1][0] = p[1].first;
            dp[x][1][1] = p[1].second;
        }   
    }
}

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

    rep(i,(1<<n)){
        dp[i][0][0] = -1;
    }

    dfs((1<<n) - 1);
    int ans[1<<n] = {};
    srep(i,1,(1<<n)){
        ans[i] = max(ans[i-1], dp[i][0][0] + dp[i][1][0]);
        cout << ans[i] << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 9216
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let s = input!(String);
    let t = input!(String);

    let s = s.chars().collect::<Vec<char>>();
    let t = t.chars().collect::<Vec<char>>();

    if s.len() < t.len() {
        println!("UNRESTORABLE");
        return;
    }

    for i in (0..(s.len() - t.len() + 1)).rev() {
        for j in (0..t.len()).rev() {
            if s[i+j] == t[j] || s[i+j] == '?' {
                if j == 0 {
                    for k in 0..s.len() {
                        if k < i || i + t.len() <= k {
                            if s[k] == '?' {
                                print!("a");
                            } else {
                                print!("{}", s[k]);
                            }
                        } else {
                            print!("{}", t[k-i]);
                        }
                    }
                    return;
                }
            } else {
                break;
            }
        }
    }
    println!("UNRESTORABLE");
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    double a,b,c,n;
    scanf("%lf",&n);
    for(a=1;a<=3500;a++)
    for(b=1;b<=3500;b++)
    {
        c=n*a*b/(4*a*b-n*a-n*b);
        if(c==(int)c&&c>0)
        {
            printf("%.0lf %.0lf %.0lf\n",a,b,c);
            return 0;
        }
    }
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String x;
		Scanner scan = new Scanner(System.in);
		while(true){
			x=scan.next();
			if(x.equals("0")){
				scan.close();
				break;
			}
			char[] c = x.toCharArray();
			int sum=0;
			for(int i=0;i<c.length;i++){
				sum+=(c[i]-48);
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 26360
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = int(readline())
    vs = sorted(list(map(int, readline().split())), reverse=True)
    vs[-1] *= 2

    ans = 0
    r = 2
    for v in vs:
        ans += v / r
        r *= 2
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
    int K,A,B;
    cin>>K>>A>>B;
    int maxi = min(B,A+K-1);
    for(int i = A;i <= maxi;i ++)
    {
        if(i % K ==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3628
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}
template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }
template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}
template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> void update_min(T &a, const T &b) { a = min(a, b); }
vector<pair<char, Int>> merge_cont_char(const string &s) {
  vector<pair<char, Int>> ret;
  if (s.empty())
    return ret;
  ret.push_back(make_pair(s[0], 0));
  FOR(c, s) {
    if (ret.back().first == c)
      ret.back().second++;
    else
      ret.push_back(make_pair(c, 1));
  }
  return ret;
}

class Shakutori {
public:
  // 全体の範囲
  // [0, end)
  // 注目している範囲
  // [tail, head)
  Int head, tail, end = 0;
  bool moveHead() {
    if (head == end) {
      return false;
    }
    head++;
    return true;
  }
  void moveTail() { tail++; }
  bool valid() {
    if (head == tail)
      return true;
    // [tail, head)
    // が解として適当か検証する
    return true;
  }
  void solve() {
    head = tail = 0;
    Int ans = 0;
    while (moveHead()) {
      while (!valid()) {
        moveTail();
      }
      // ここで解を更新する
    }
  }
};

class Solver {
public:
    int A, B, T, t;
  Solver() {}
  void input() {
      cin >> A >> B >> T;
  }
  void solve() {
       t = T/A;
  }
  void output() {
      cout << B * t <<endl;
  }
};

void initilization() {
  struct BoolName : numpunct<char> {
    string t, f;
    BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
    string do_truename() const { return t; }
    string do_falsename() const { return f; }
  };
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
}

int main() {
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}


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

int main()
{   
    int N, Q; string S;
    cin >> N >> S >> Q;
    
    vector<set<int>> vsi(26);
    for (int i = 0; i < S.size(); ++i) {
        vsi[S[i] - 'a'].insert(i);
    }
    for (int i = 0; i < Q; ++i) {
        int t; 
        cin >> t;
        if (t == 1) {
            int p; char c;
            cin >> p >> c; p--;
            char sc = S[p];
            vsi[sc - 'a'].erase(p);
            S[p] = c;
            vsi[c - 'a'].insert(p);
        } else {
            int l, r;
            cin >> l >> r; l--; r--;
            int ans = 0;
            for (char c = 0; c < 26; ++c) {
                auto it = vsi[c].lower_bound(l);
                if (it != vsi[c].end() && *it <= r) ans++;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 24196
using System;

public class Program
{
	public static void Main(string[] args)
	{
		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????
		int[] intArray = new int[26];

		string abc = "abcdefghijklmnopqrstuvwxyz";
		char[] abcArray = abc.ToCharArray();


		while(true)
		{
			string sentence = Console.ReadLine();
			if (sentence == null)
			{
				break;
			}
			string s = sentence.ToLower();


			char[] charArray = new char[s.Length];
			charArray = s.ToCharArray();
			for (int i = 0; i < s.Length; i++)
			{
				for (int j = 0; j < abcArray.Length; j++)
				{
					if (charArray[i] == abcArray[j])
					{
						intArray[j] += 1;
						break;
					}
				}
			}

		}

		for (int i = 0; i < abcArray.Length; i++)
		{
			Console.WriteLine(abcArray[i] + " : " + intArray[i]);
		}

		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

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

int main(){
	int n;
	string s;
	int max_x, min_x;
	cin >> n;

	rep(i, n){
		cin >> s;
		sort(s.begin(), s.end());
		min_x = stoi(s);
		sort(s.begin(), s.end(), greater<char>());
		max_x = stoi(s);

		cout << max_x - min_x << endl;
	}
}

Measured memory_bytes: 1228
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String s1 = sc.next();
   String s2 = sc.next();

   if(s1.charAt(0)==s2.charAt(2)&&s1.charAt(1)==s2.charAt(1)&&s1.charAt(2)==s2.charAt(0))System.out.println("YES");
   else System.out.println("NO");
 }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;

    while (1) {
        scanf("%d %c %d", &a, &op, &b);

        switch (op) {
            case '+':
                printf("%d\n", a + b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '/':
                printf("%d\n", a / b);
                break;
            case '?':
                return 0;
        }
    }
}



Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  int tmp = N, dig = 0;
  while(tmp){
    dig += tmp % 10;
    tmp /= 10;
  }
  cout << (N % dig == 0 ? "Yes" : "No") << endl;
}


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

const int maxn=1e5+5;
int a[maxn],vis[maxn];

int main()
{
    int n,c,k;
    scanf("%d%d%d",&n,&c,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int num=0,cnt=0,flag=0,minn=a[0];
    for(int i=0;i<n;i++)
    {
        if(a[i]-minn>k)
        {
            cnt++;
            num=1;
            minn=a[i];
        }
        else
        {
            num++;
        }
        if(num==c)
        {
            num=0;cnt++;
            minn=a[i+1];
        }
    }
    if(num)
        cnt++;
    printf("%d\n",cnt);
}


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

int main() {
  int n;
  cin >> n;
  map<char, int> cnt;
  rep (i, 3) cin >> cnt['A' + i];
  vector<string> s(n + 1);
  rep (i, n) cin >> s[i];
  string ans;
  rep (i, n) {
    char t1 = s[i][0];
    char t2 = s[i][1];
    if (cnt[t1] == 0 && cnt[t2] == 0) {
      cout << "No" << endl;
      return 0;
    }
    if (cnt[t1] > cnt[t2]) {
      swap(t1, t2);
    }
    if (cnt[t1] == 1 && cnt[t2] == 1) {
      if (t2 == s[i + 1][0] || t2 == s[i + 1][1]) {
        swap(t1, t2);
      }
    }
    ans += t1;
    cnt[t1]++;
    cnt[t2]--;
  }
  cout << "Yes" << endl;
  for (char i : ans) cout << i << endl;
  return 0;
}

Measured memory_bytes: 6696
# int(input()) # 入力が1つ
from collections import defaultdict
n, k = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
mod = 10 ** 9 + 7
cum = [0] + [i for i in range(n + 1)]
for i in range(n + 1):
    cum[i + 1] += cum[i]

ans = 0
for i in range(k, n + 2):
    MIN = cum[i]
    MAX = cum[n + 1] - cum[n + 1 - i]
    ans += (MAX - MIN + 1) % mod
print(ans % mod)

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

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

    map<char, long long> mp;
    for (int i = 0; i < N; ++i) ++mp[S[i]];
    long long ans = mp['R'] * mp['G'] * mp['B'];

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (2*j-i >= 0 && 2*j-i < N && S[i] != S[j] && S[j] != S[2*j-i] && S[2*j-i] != S[i]) --ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using graph=vector<vector<int>>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);

    ll key=x/d;

    ll ans=0;

    if(k>key){
        if(key%2==k%2) ans=x%d;
        else ans=abs(d-x%d);
    }
    else if(k==key) ans=x%d;
    else ans=x-k*d;

    cout<<ans<<endl;
}

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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {
	string A,B,C;
	while (cin >> A) {

		if (A == "-")break;
		else {
			cin>>B>>C;
		}
		vector<string>sts{ A,B };
		vector<int>places(2);
		int center=1;
		string answer;
		if (C[0] == A[0]) {
			places[0]=1;
			places[1]=0;
			center=0;
		}
		else {
			places[0]=0;
			places[1]=1;
			center=1;
		}
		for (int i = 0; i < C.size(); ++i) {
			if (C[i] == sts[center][places[center] - 1]) {
				places[0]++;
				center=0;
			}
			else {
				answer.push_back(sts[center][places[center]-1]);
				places[1]++;
				center=1;
				i--;
			}
		}
		while (answer.size() < B.size()) {
			answer.push_back(sts[center][places[center]-1]);
			places[1]++;
			center=1;
		}
		cout<<answer<<endl;
	}
	return 0;
}




Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int N;
vector<int> A;
vector<vector<int>> G;
vector<int> ans;
vector<int> L;
int length = 1;


void dfs(int v,int p){
    for(int nv: G[v]){
        if(nv == p) continue;
        if(L[length-1] < A[nv]){
            L[length] = A[nv];
            length++;
            ans[nv] = length;
            dfs(nv,v);
            length--;
            L[length] = 0;
        }else{
            int temp = *lower_bound(L.begin(),L.begin()+length,A[nv]);
            *lower_bound(L.begin(),L.begin()+length,A[nv]) = A[nv];
            ans[nv] = length;
            dfs(nv,v);
            int itr = lower_bound(L.begin(),L.begin()+length,A[nv]) - L.begin();
            L[itr] = temp;
        }         
    }
}

int main(){
    cin >> N;
    A.resize(N);
    for(int i=0; i<N; i++) cin >> A[i];
    G.resize(N);
    for(int i=0; i<N-1; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    L = vector<int>(N+1,0);
    ans.resize(N);
    ans[0] = 1;
    L[0] = A[0];
    for(int nv: G[0]){
        if(L[length-1] < A[nv]){
            L[length] = A[nv];
            length++;
            ans[nv] = length;
            dfs(nv,0);
            length--;
            L[length] = 0;
        }else{
            int temp = *lower_bound(L.begin(),L.begin()+length,A[nv]);
            *lower_bound(L.begin(),L.begin()+length,A[nv]) = A[nv];
            ans[nv] = length;
            dfs(nv,0);
            int itr = lower_bound(L.begin(),L.begin()+length,A[nv]) - L.begin();
            L[itr] = temp;
        }
    }
    for(int i=0; i<N; i++){
        cout << ans[i] << enld;
    }
    return 0;
}

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

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

  int z =0;
  for(int i = 0; i<n-1 ; i ++){
      int y = a[i+1]-a[i];
      z = max(z,y);
  }
  z=max(z,k-a[n-1]+a[0]);
  cout <<k-z<< endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

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

  int N = S.size();
  vector<vector<long long>> dp(100100, vector<long long>(13, 0));
  dp[0][0] = 1;

  for(int i = 1; i <= N; i++){
    if(S[i-1] == '?'){
      for(int a = 0; a < 10; a++){
        for(int j = 0; j < 13; j++){
          dp[i][(j * 10 + a) % 13] += dp[i-1][j];
        }
      }
    }else{
      int a = S[i-1] - '0';
      for(int j = 0; j < 13; j++){
        dp[i][(j * 10 + a) % 13] += dp[i-1][j];
      }
    }
    for(int j = 0; j < 13; j++) dp[i][j] %= 1000000007;
  }
  cout << dp[N][5] << endl;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    //vector<map<int,int>> dp(n+1);

    map<int,int> dp1;
    //map<int,int> dp2;
    dp1[0]=3;
    //dp[0][0]=3;
    ll ans = 1;
    for(int i=1; i<=n; i++){
        //ans *= dp[i-1][a[i-1]];
        ans*=dp1[a[i-1]];
        ans = ans%MOD;
        dp1[a[i-1]+1]++;
        dp1[a[i-1]]--;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;
vector<int> gr[101];

void solve()
{
    cin>>n>>k; 
    int x,y;

    for(int i=0;i<k;i++){
        cin>>x;
        for(int j=0;j<x;j++){
            cin>>y;
            gr[y].pb(x);
        }
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(gr[i].size() == 0){
            cnt++;
        }
    }
    cout<<cnt;
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, d; cin >> n >> d;
    d = d * 2 + 1;
    cout << n / d + (n % d > 0) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}
ll cnt[1000001];
int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 1, y = INF, ans = 0, k;
        cin >> n;
        ll a[n];
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            cnt[a[i]]++;
        }
        for(int i = 0; i < n; i++)
        {
            x = a[i];
            y = 0;
            for(ll j = 1; j * j <= x; j++)
            {
                if(x % j == 0)
                {
                    y += cnt[x / j];
                    if(x / j != j)
                        y += cnt[j];
                }
            }
            if(y == 1)
                ans++;
        }
        cout << ans << "\n";
     }
     return 0;
}


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

int distance(int i, int j, int X, int Y)
{
	int result;
	result = min(abs(i - j), abs(X - i) + 1 + abs(Y - j));
	result = min(result, abs(Y - i) + 1 + abs(X - j));
	return result;
}
int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N, X, Y;
	scanf("%d %d %d", &N, &X, &Y);

	vector<long long> count(N, 0);
	// cout << "k=" << k << "\n";
	for (int i = 1; i < N; i++)
	{
		for (int j = i + 1; j <= N; j++)
		{
			// cout << i << " " << j << " " << distance(i, j, X, Y) << "\n";
			count[distance(i, j, X, Y)]++;
		}
	}
	for (int k = 1; k <= N - 1; k++)
	{

		cout << count[k] << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define gcd __gcd
using namespace std;

signed main() {
  int n;
  cin>>n;
  vector<int>vec(n);
  mii mp;
  int cnt=0;
  rep(i,n) {
    cin>>vec.at(i);
    mp[vec.at(i)]++;
  }
  sort(vec);
  if(n==1) {
    if(vec.at(0)==1) {
      cout<<"0"<<endl;
    }
    else {
      cout<<"1"<<endl;
    }
  }
  else {
    rep(i,n) {
      if(mp[vec.at(i)]>vec.at(i)) {
        cnt+=mp[vec.at(i)]-vec.at(i);
      }
      else if(mp[vec.at(i)]<vec.at(i)) {
        cnt+=mp[vec.at(i)];
      }
      mp[vec.at(i)]=0;
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 7040
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve;
}
 
void solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	writeln( 0 );
	stdout.flush();
	input.popFront;
	auto s = input.front;
	if( s == "Vacant" ) return;
	
	auto queue = heapify!( ( a, b ) => b[ 0 ] < a[ 0 ] || ( b[ 0 ] == a[ 0 ] && b[ 1 ] < a[ 1 ] ) )( new Tuple!( bool, long, long, string, long, string )[ 20 ], 0 );
	queue.insert( tuple( true, n - 1, 0L, s, n, s ) );
	while( !queue.empty )
	{
		auto li = queue.front[ 2 ];
		auto ls = queue.front[ 3 ];
		auto ri = queue.front[ 4 ];
		auto rs = queue.front[ 5 ];
		queue.popFront;
		
		auto ci = ( ri + li ) / 2;
		writeln( ci );
		stdout.flush();
		input.popFront;
		auto cs = input.front;
		if( cs == "Vacant" ) return;
		
		auto lcd = ci - li - 1;
		auto rcd = ri - ci - 1;
		if( 0 < lcd ) queue.insert( tuple( ( lcd % 2 ) ? ls == cs : ls != cs, lcd, li, ls, ci, cs ) );
		if( 0 < rcd ) queue.insert( tuple( ( rcd % 2 ) ? rs == cs : rs != cs, rcd, ci, cs, ri, rs ) );
	}
	
	assert( false );
}


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

#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) {}
#define eprintf(...) do {} while(0)
#endif

template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename T>
ostream& operator << (ostream& out, const vector<T> &v) {
	int n = v.size();
	out << "{";
	for(int i = 0; i < n; ++i) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "}";
}
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &v) {
	return out << "(" << v.first << ", " << v.second << ")";
}

typedef long long LL;

const int maxN = (1 << 18) + 5;
const LL P = 1000000007;
int n, h, p[maxN];

LL val[maxN];

LL prod = 1, sum = 0;
void mark(int u, LL coef) {
	coef = coef * u % P;
	if(u < n / 2) {
		mark(u * 2, coef);
		mark(u * 2 + 1, coef);
	} else {
		int x = p[u];
		while(x) {
			val[x] = (val[x] + coef) % P;
			coef = coef * x % P;
			x /= 2;
		}
	}
}
LL count(int u, LL coef) {
	coef = coef * u % P;
	if(u < n / 2) {
		return (count(u * 2, coef) + count(u * 2 + 1, coef)) % P;
	} else {
		int x = p[u];
		LL sum = 0, ref = 0;
		while(x) {
			// ref = ref * x % P;
			coef = coef * x % P;
			(sum += val[x] * coef - val[x] * coef % P * x % P * (x / 2)) %= P;
			// (ref += (val[x] * coef - ref) % P * x) %= P;
			x /= 2;
		}
		return (sum + P) % P;
	}
}
void unmark(int u) {
	if(u < n / 2) {
		unmark(u * 2);
		unmark(u * 2 + 1);
	} else {
		int x = p[u];
		while(x) {
			val[x] = 0;
			x /= 2;
		}
	}
}
LL ans = 0;
void dfs(int u) {
	if(u < n / 2) {
		mark(u * 2, u);
		(ans += count(u * 2 + 1, 1)) %= P;
		unmark(u * 2);
		dfs(u * 2);
		dfs(u * 2 + 1);
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> h;
	n = (1 << h);
	for(int i = n / 2; i < n; ++i) cin >> p[i], p[i] += n / 2 - 1;
	memset(val, 0, sizeof(val));
	dfs(1);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6168
#include<stdio.h>

void swap(int *x,int *y){
	int z;
	z = *x;
	*x = *y;
	*y =z;
}

void bubbleSort(int A[], int N){
	int flag=1;
	int count=0;
	int j;
	while(flag==1){
		flag=0;
		for (j=N-1; j>0; j--){
			if(A[j] < A[j-1]){
				swap(&A[j], &A[j-1]);
				count++;
				flag = 1;
			}
		}
	}
	for(j=0; j<N-1; j++){
		printf("%d ",A[j]);
	}
	printf("%d\n",A[j]);
	printf("%d\n",count);
}

int main(void)
{
	int N;
	scanf("%d",&N);
	int Num[N];
	int i;
	for(i=0;i<N;i++) scanf("%d",&Num[i]);
	bubbleSort(Num,N);
	return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() != b.size()) {
        cout << (a.size() > b.size() ? "GREATER" : "LESS") << endl;
    } else if (a != b) {
        cout << (a > b ? "GREATER" : "LESS") << endl;
    } else {
        cout << "EQUAL" << endl;
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N;
  cin>>N;
  int H[N];
  rep(i,N)
    cin>>H[i];
  int count=0;
  for(int i=N-1;i>=0;i--){
    bool flag=true;
    for(int j=i-1;j>=0;j--){
      if(H[i]<H[j])
	flag=false;
    }
    if(flag)
      count++;
  }
  cout<<count<<endl;
  return 0;
}
  


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

n, m = map(int, input().split())

inf = float('inf')
p = 2**n
dp = [inf]*p
dp[0] = 0

for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(i-1) for i in map(int, input().split())])
    for i in range(p):
        if dp[i|c] > dp[i] + a: 
            dp[i|c] = dp[i] + a
    
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

    

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

/* define class and method names */
#define TCC ParenthesisRemoval
#define TCM countWays


using namespace std;


typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;




/* testing process */
int main(){
	LL N,K;
	map<LL,LL> cnt;
	cin>>N>>K;
	for(LL i=0;i<N;++i){
		LL a,b;
		cin>>a>>b;
		cnt[a] += b;
	}
	auto it = cnt.begin();
	for(;it!=cnt.end() &&K>it->second ;++it){
		K-=it->second;
	}
	cout<<it->first;
	return 0;
}

Measured memory_bytes: 4224
n=gets.to_i
r = []
for i in 0...n do
    s,p=gets.split
    p=p.to_i
    r[i] = [i+1,s,p]
end

r.sort! {|a,b| ((a[1] <=> b[1]) == 0)? -(a[2] <=> b[2]) : a[1] <=>b[1]}

r.each do |r1|
    p r1[0]
end


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

using namespace std;

const int MOD=1e9+7;
vector<tuple<int,int,int>> E;
int color[1000];
map<long long,int> cnt;

long long fast_pow(long long a, long long b)
{
	long long ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=(ret*a)%MOD;
		a=(a*a)%MOD;
	}
	return ret;
}

int find_(int a)
{
	return color[a]=color[a]==a ? a:find_(color[a]);
}

void union_(int a, int b)
{
	a=find_(a); b=find_(b);
	color[a]=color[b]=min(a,b);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL);
	int N, M, s=0, e=0, m=0;
	long long X;
	cin>>N>>M>>X;
	E.resize(M);
	for(int i=0;i<M;i++) {
		int u, v, w;
		cin>>u>>v>>w;
		E[i]=make_tuple(w,--u,--v);
	}
	sort(E.begin(),E.end());
	for(int j=0;j<M;j++) {
		int u, v, w;
		long long sum;
		for(int i=0;i<N;i++) color[i]=i;
		tie(w,u,v)=E[j];
		sum=w;
		union_(u,v);
		for(int i=0;i<M;i++) {
			tie(w,u,v)=E[i];
			if(find_(u)!=find_(v)) {
				union_(u,v);
				sum+=w;
			}
		}
		cnt[sum]++;
	}
	for(auto t: cnt) {
		if(t.first<X) s+=t.second;
		else if(t.first>X) e+=t.second;
		else m+=t.second;
	}
	if(m==0) cout<<"0\n";
	else {
		long long ans;
		if(s) ans=(2LL*((fast_pow(2,m)+MOD-1)*fast_pow(2,e))%MOD)%MOD;
		else ans=((fast_pow(2,m)+MOD-2)*fast_pow(2,e))%MOD;
		cout<<ans%MOD<<'\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

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

  vector<double> v(n);
  rep(i, n) cin >> v[i];

  
  sort(v.begin(), v.end());
  double ans = v[0];
  for(int i = 1; i < n; ++i){
    ans = (ans + v[i]) / 2;
  }

  cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	ll k,n,i;
	cin>>k>>n;
	ll a[n];
	rep(i,n)
		cin>>a[i];
	sort(a,a+n);
	/*
	ll temp=0,ans=0;
	temp=a[n-1]-a[0];
	ll t=k-a[n-1]+a[n-2];
	cout<<min(temp,t);
	*/
	ll ans=INF64;
	ll temp=a[n-1]-a[0];
	ans=min(ans,temp);
	for(i=1;i<n;i++)
	{
		temp=k-a[i]+a[i-1];
		ans=min(ans,temp);
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int main(){
	string t,p;
	cin>>t>>p;
	
	stack<char> st;
	vector<int> b;
	vector<int> f;
	
	for(int i=0;i<p.size();i++)st.push(p[i]);
	
	for(int i=t.size()-1;i>=0;i--){
		if(st.size()&&t[i]==st.top()){
			f.push_back(i);
			st.pop();
		}
	}
	
	if(st.size()){
		cout<<"no"<<endl;
		return 0;
	}
	
	while(st.size())st.pop();
	
	for(int i=p.size()-1;i>=0;i--)st.push(p[i]);
	
	for(int i=0;i<t.size();i++){
		if(st.size()&&t[i]==st.top()){
			b.push_back(i);
			st.pop();
		}
	}
	
	reverse(b.begin(),b.end());
	
	if(b==f&&b.size()==p.size()){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}
	
	return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll ans = 0, a = 100;
  while (a < x) {
    a += a/100;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
a=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y=gets.split.map(&:to_i)
ans = false
3.times do |i|
    if a[i].include?(x) && a[i].include?(y)
        ans = true
    end
end
puts ans ? "Yes" : "No"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int
#define pb push_back
#define endl "\n"
#define ull unsigned long long int

int main()
{
   ll n;
   double count=0.0;
   unsigned long long sum=1;
   cin>>n;
   ll ar[n];
   for(ll i=0;i<n;i++)
   {
       cin>>ar[i];
      count+=log10(ar[i]);
   }
   string s;
  if((int)count==18)
  {
      for(ll i=0;i<n;i++)
   {
       sum=sum*ar[i];
   }
   s=to_string(sum);
   if(s[s.size()-1]=='0' && sum< 10000000000000000000 )
   {
       cout<<s<<endl;
   }
   else cout<<-1<<endl;
  }
  else if((int)count<18)
  {
         for(ll i=0;i<n;i++)
   {
       sum=sum*ar[i];
   }
   s=to_string(sum);
   cout<<s<<endl;
  }
  else cout<<-1<<endl;
}


Measured memory_bytes: 4672
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    double a;
    cin>>a;
    cout<<int((a/2+0.9))/a<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k,ans=0;
    cin >> n >>k;
    ans = floor(n/k)*floor(n/k)*floor(n/k);
    if(k%2==0){
        long long hoge=floor(n/k);
        if(n%k>=k/2){
            hoge ++;
        }
        ans += hoge*hoge*hoge;
    }


    cout << ans<<endl;
}

Measured memory_bytes: 256