akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ankit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                min = Math.min(min, x);
                max = Math.max(max, x);
            }
            out.println(max - min);
        }

    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i=a; i<(b); i++)

int  n;

void solve(){

}


int main(){
   	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
    if (n >= 30) cout << "Yes";
    else cout << "No";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>

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

    std::string S;
    std::cin >> S;

    std::vector<int> ints(4);
    for (int i = 0; i < 4; ++i) {
        ints[i] = S[i] - '0';
    }

    std::vector<int> sign(4, 1);
    bool found = false;
    int i = 0;
    for (i = 0; i < 8; ++i) {
        // get power
        for (int j = 0; j < 3; ++j) {
            sign[3-j] = ((i >> j) % 2) ? 1 : -1;
        }

        // inner product
        int sum = ints[0];
        for (int k = 1; k < 4; ++k) {
            sum += sign[k] * ints[k];
        }

        if (sum == 7) {
            found = true;
            break;
        }
    }

    std::string ans = "0+0+0+0=7";
    if (found) {
        for (int i = 0; i < 4; ++i) {
            ans[i*2] = S[i];
        }
        for (int i = 0; i < 3; ++i) {
            if (sign[i+1] == -1) ans[i*2 +1] = '-';
        }
    }
    else
    {
        ans = "not found";
    }

    std::cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
/*#pragma GCC target("avx,avx2,fma")
#pragma GCC target ("sse4")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
bool isPowerOfTwo (int x) {  return x && (!(x&(x-1)));  }
ll Modular_Exponentiation(ll x, ll n, ll M)
{
    if(n==0) return 1;
    if(n%2) return (x*Modular_Exponentiation((x*x)%M,n/2,M))%M;
    else return (Modular_Exponentiation((x*x)%M,n/2,M))%M;
}
void solve()
{
    ll S;  cin>>S;
    vector<ll> dp(S+1);
    dp[0]=1;
    rep(i,3,S+1)
    {
        for(ll j=i-3; j>=0; --j) 
        {
            dp[i]+=dp[j];
            dp[i]%=mod;
        }
    }
    cout<<dp[S]%mod;    
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<fixed<<setprecision(5)<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}

Measured memory_bytes: 3812
import itertools
import numpy as np

H, W, K = map(int, input().split())

temp = []
for _ in range(H):
    C = list(input())
    A = [c.replace('.', '0') for c in C]
    A = [a.replace('#', '1') for a in A]
    A = list(map(lambda x: int(x), A))
    temp.append(A)

C = np.array(temp)

count = 0
l = [0, 1]
wide = itertools.product(l, repeat=W)
for w in wide:
    hight = itertools.product(l, repeat=H)
    for h in hight:
        copy_C = C.copy()
        # print('w: ', w)
        # print('h: ', h)
        for num, i in enumerate(w):
            if i == 1:
                copy_C[:, num-1] = 0
            for num2, j in enumerate(h):
                if j == 1:
                    copy_C[num2-1, :] = 0
        if copy_C.sum() == K:
            count += 1

print(count)

Measured memory_bytes: 27244
parseInt(x) = parse(Int, x)

function main()
	x = map(parseInt, split(readline()))
	x = sort(x)
	if x[1]%2 == x[2]%2 == x[3]%3
		print(div(x[3]-x[2]+x[3]-x[1],2))
	elseif x[1]%2==x[2]%2
		x[1] += 1
		x[2] += 1
		print(1+div(x[3]-x[2]+x[3]-x[1],2))
	elseif x[1]%2 == x[3]%2
		x[1] += 1
		x[3] += 1
		print(1+div(x[3]-x[2]+x[3]-x[1],2))
	else
		x[2] += 1
		x[3] += 1
		print(1+div(x[3]-x[2]+x[3]-x[1],2))
	end
end

main()

Measured memory_bytes: 171076
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
  int n;

  cin >> n;

  int fail_num = 0;
  int o = 1;
  int a;

  for (int i = 0; i < n; i++) {
    cin >> a;
    // cout << a << endl;
    if (o != a) {
      fail_num++;
    } else {
      o++;
    }
  }

  if (fail_num == n) {
    cout << -1;
  } else {
    cout << fail_num;
  }
  cout << endl;

  return 0;
}


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

long long n;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto &p : a) cin >> p;
  sort(a.begin(), a.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  vector<int> cnt(1000001, 0);
  for (int i = 0; i < n; ++i) ++cnt[a[i]];
  for (int i = 0; i < n; ++i) {
    long long x = a[i];
    bool ch = 1;
    for (long long j = 1; j * j <= x; ++j)
      if (x % j == 0) {
        if (cnt[j] && (j * j) != x) ch = 0;
        if (cnt[x / j] > 1 || (j != 1 && cnt[x / j] > 0)) ch = 0;
      }
    res += ch;
  }
  return res;
}

Measured memory_bytes: 8776
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n, q;
  cin >> n >> q;
  vector<stack<int>> s(n);
  while (q--) {
    int c = in();
    if (c == 0) {
      int t, x;
      cin >> t >> x;
      s[t].emplace(x);
    }
    if (c == 1) {
      int t = in();
      if (s[t].empty()) continue;
      cout << s[t].top() << endl;
    }
    if (c == 2) {
      int t = in();
      if (s[t].empty()) continue;
      s[t].pop();
    }
  }
}



Measured memory_bytes: 5076
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream> 
    #include <cstdlib>
using namespace std;
const int MAXN=1e5+10;
const int INF=1e9+7;
int N,T;
int A[MAXN],dif[MAXN];
int main()
{
	int mn=INF,mx=-INF,cnt_mx=0,cnt_mn=0;
	scanf("%d%d",&N,&T);
	for(int i=0;i<N;i++)
	{
		scanf("%d",A+i);
		if(A[i]<mn)
		{
			mn=A[i];
			cnt_mn=1;
		}
		dif[i]=A[i]-mn;
		if(dif[i]>mx)
		{
			mx=dif[i];
			cnt_mx=1;
		}
		else if(dif[i]==mx)
			cnt_mx+=cnt_mn;
	}
	cout<<cnt_mx<<endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
from collections import deque

input = sys.stdin.readline


def bfs(H, W, A, dist):
    queue = deque([])
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                dist[h][w] = 0
                queue.append((h, w))
    while queue:
        h, w = queue.popleft()
        for y, x in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            next_h, next_w = h + y, w + x
            if dist[next_h][next_w] == -1:
                dist[next_h][next_w] = dist[h][w] + 1
                queue.append((next_h, next_w))


def main():
    H, W = map(int, input().split())
    A = [None] * (H + 2)
    A[0] = A[-1] = "." * (W + 2)
    for i in range(1, H + 1):
        A[i] = "".join([".", input().rstrip(), "."])

    dist = [[0] + [-1] * W + [0] for _ in range(H + 2)]
    dist[0] = dist[-1] = [0] * (W + 2)
    bfs(H + 2, W + 2, A, dist)

    ans = max(map(max, dist))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 113264
// https://atcoder.jp/contests/abc142/tasks/abc142_e

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 
#define pii pair<int, int>
#define fi first
#define se second

const int maxm = 1500;

int N, M;
vector<int> c[maxm];
int a[maxm];

int dp[5000];

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

    cin >> N >> M;

    for(int i = 1; i <= M; i++) {
        int b;
        cin >> a[i] >> b;

        for(int j = 1; j <= b; j++) {
            int x;
            cin >> x;

            c[i].emplace_back(x);
        }
    }

    for(int i = 1; i < 5000; i++) {
        dp[i] = INT_MAX;
    }
    dp[0] = 0;

    for(int i = 0; i <= (1<<N)-1; i++) {
        for(int j = 1; j <= M; j++) {
            int state = i;
            for(int x: c[j]) {
                state |= (1<<(x-1));
            }            

            dp[state] = min(dp[state], dp[i] + a[j]);
        }
    }

    if(dp[(1<<N)-1] == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << dp[(1<<N)-1] << endl;
    }
}


Measured memory_bytes: 3808
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt64

func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	A := nextInts(N)
	s := make([]int, N)
	s[N-1] = A[N-1]
	for i := N - 2; i >= 0; i-- {
		s[i] = (s[i+1] + A[i]) % 1000000007
	}
	ans := 0
	for i := 0; i < N-1; i++ {
		ans += A[i] * s[i+1] % 1000000007
	}
	fmt.Println(ans % 1000000007)
}


Measured memory_bytes: 7464
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int x,cnt=0,ans=0,jj=0;
    cin>>x;
    jj=x/100;
    cnt=x%100;
    if(jj*5>=cnt)
    {
        cout<<1<<NL;
    }
    else
    {
        cout<<"0"<<NL;
    }

    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <iomanip>
using namespace std;

int main(int argc, char const *argv[]) {
  int n,m;cin>>n>>m;
  vector<vector<long long>> d = vector<vector<long long>>(n,vector<long long>(n)), dd=vector<vector<long long>>(n,vector<long long>(n));
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      d[i][j]=1ll<<60;
      dd[i][j]=1ll<<60;
    }
  }
  for(int i=0;i<m;++i){
    int s,t,w;cin>>s>>t>>w;
    s--;t--;
    d[s][t]=w;
    d[t][s]=w;
    dd[s][t]=w;
    dd[t][s]=w;
  }
  for(int k=0;k<n;++k){
    for(int i=0;i<n;++i){
      for(int j=0;j<n;++j){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  int res=0;
  for(int i=0;i<n;++i)for(int j=i+1;j<n;++j)if(dd[i][j]<1ll<<60&&dd[i][j]>d[i][j])res++;
  cout<<res<<endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
    char a, b;
    cin >> a >> b;
    if(a > b) cout << ">" << endl;
    else if(a < b) cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>
#include <cmath>
#include <deque>
#include <numeric>
#include <cassert>
using namespace std;

int grid[500][500];
int move_y1[250000];
int move_x1[250000];
int move_y2[250000];
int move_x2[250000];

void set_move_same_row(int past_w, int cur_w, int h, int &N){
  if(past_w == cur_w){
    return;
  }

  if(h % 2 == 0){
    for(int i = past_w + 1; i <= cur_w; i++){
      move_y1[N] = h;
      move_x1[N] = i - 1;
      move_y2[N] = h;
      move_x2[N] = i;
      N++;
    }
  } else {
    for(int i = past_w - 1; i >= cur_w; i--){
      move_y1[N] = h;
      move_x1[N] = i + 1;
      move_y2[N] = h;
      move_x2[N] = i;
      N++;
    }
  }
}

void set_move_up(int h, int w, int &N){
  move_y1[N] = h;
  move_x1[N] = w;
  move_y2[N] = h + 1;
  move_x2[N] = w;
  N++;
}

void set_move(int past_h, int past_w, int cur_h, int cur_w, int H, int W, int & N){
  //cout << "set_move: " << past_h << " " << past_w << " " << cur_h << " " << cur_w << endl;
  if(past_h == cur_h){
    set_move_same_row(past_w, cur_w, past_h, N);
    return;
  } else {
    if(past_h % 2 == 0){
      set_move_same_row(past_w, W - 1, past_h, N);
      set_move_up(past_h, W - 1, N);
    } else {
      set_move_same_row(past_w, 0, past_h, N);
      set_move_up(past_h, 0, N);
    }

    for(int i = past_h + 1; i < cur_h; i++){
      if(i % 2 == 0){
        set_move_same_row(0, W - 1, i, N);
        set_move_up(i, W - 1, N);
      } else {
        set_move_same_row(W - 1, 0, i, N);
        set_move_up(i, 0, N);
      }
    }

    if(cur_h % 2 == 0){
      set_move_same_row(0, cur_w, cur_h, N);
    } else {
      set_move_same_row(W - 1, cur_w, cur_h, N);
    }
  }
}

int main(){
  int H;
  int W;
  cin >> H >> W;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> grid[i][j];
    }
  }

  int past_odd_h = -1;
  int past_odd_w = -1;
  int N = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(i % 2 == 0){
        //cout << i << j << endl;
        if(grid[i][j] % 2 == 1){
          if(past_odd_h < 0){
            past_odd_h = i;
            past_odd_w = j;
          } else {
            set_move(past_odd_h, past_odd_w, i, j, H, W, N);
            past_odd_h = -1;
            past_odd_w = -1;
          }
        }
      } else {
        //cout << i << W - 1 - j << endl;
        if(grid[i][W -  1 - j] % 2 == 1){
          if(past_odd_h < 0){
            past_odd_h = i;
            past_odd_w = W -  1 - j;
          } else {
            set_move(past_odd_h, past_odd_w, i, W - 1 - j, H, W, N);
            past_odd_h = -1;
            past_odd_w = -1;
          }
        }
      }
    }
  }

  cout << N << endl;
  for(int i = 0; i < N; i++){
    cout << move_y1[i] + 1 << " " << move_x1[i] + 1 << " " << move_y2[i] + 1 << " " << move_x2[i] + 1 << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli x,y;

int main(){
  cin >> x >> y;
  cout << x+y/2 << endl;
}


Measured memory_bytes: 768
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)    cin>>arr[i];
    int c=0;
    for(int i=0;i<n;i+=2)
    {
        if(arr[i]%2!=0)
            c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#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 all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}


void solve() {
	int n;ll k; cin >> n >> k;
	vector<P> v(n);
	rep(i, n)cin >> v[i].first >> v[i].second;
	sort(all(v));
	ll rest = k;
	rep(i, n) {
		if (rest <= v[i].second) {
			cout << v[i].first << "\n";
			return;
		}
		rest -= v[i].second;
	}
}





signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 20332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  cout << s[0];
  cout << s.size() - 2;
  cout << s[s.size()-1];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
int r, c, n;

bool hashi(int y, int x){
    return (y == 0 || y == c || x == 0 || x == r);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> n;
    vector<P> lt, rt, up, dn; 
    rep(i, 0, n){
        int x, y, x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(!(hashi(y1, x1) && hashi(y2, x2))) continue;
        x = x1; y = y1;
        if(x == 0){
            lt.push_back(P(y, i));
        }else if(y == c){
            dn.push_back(P(x, i));
        }else if(x == r){
            rt.push_back(P(y, i));
        }else if(y == 0){
            up.push_back(P(x, i));
        }
        // d.push_back(pair<P, int>(P(x, y), i));
        x = x2; y = y2;
        if(x == 0){
            lt.push_back(P(y, i));
        }else if(y == c){
            dn.push_back(P(x, i));
        }else if(x == r){
            rt.push_back(P(y, i));
        }else if(y == 0){
            up.push_back(P(x, i));
        }
        // d.push_back(pair<P, int>(P(x, y), i));        
    }
    sort(all(lt));
    sort(all(dn));
    sort(all(rt));
    reverse(all(rt));
    sort(all(up));
    reverse(all(up));
    stack<int> st;
    set<int> s;
    bool f = true;
    rep(i, 0, lt.size()){
        int next = lt[i].second;
        if(!s.count(next)){
            st.push(next);
            s.insert(next);
        }else{
            int p = st.top(); st.pop();
            if(p != next) f = false;
        }
    }
    rep(i, 0, dn.size()){
        int next = dn[i].second;
        if(!s.count(next)){
            st.push(next);
            s.insert(next);
        }else{
            int p = st.top(); st.pop();
            if(p != next) f = false;
        }
    }
    rep(i, 0, rt.size()){
        int next = rt[i].second;
        if(!s.count(next)){
            st.push(next);
            s.insert(next);
        }else{
            int p = st.top(); st.pop();
            if(p != next) f = false;
        }
    }
    rep(i, 0, up.size()){
        int next = up[i].second;
        if(!s.count(next)){
            st.push(next);
            s.insert(next);
        }else{
            int p = st.top(); st.pop();
            if(p != next) f = false;
        }
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 8368
#include<bits/stdc++.h>
using namespace std;
int main (){
string s ,t;
cin >>s >>t;
int x = stoi (s+ t );
for ( int i =1; i <=1000; i ++){
if ( i*i == x ){
puts (" Yes ");
return 0;
}
}
puts (" No ");
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
SS = [list(input()) for _ in range(h)]
num = 1
ans = [[0] * w for _ in range(h)]

for i in range(h):
    S = SS[i]

    if S != ['.'] * w:
        for j in range(w):
            s = S[j]
            if s == '#':
                ans[i][j] = num
                if j != w - 1:
                    if '#' in S[j + 1:]:
                        num += 1
            else:
                ans[i][j] = num
        num += 1

cnt = 1

for num, a in enumerate(ans):
    if a == [0] * w:
        cnt += 1
        continue
    else:
        for i in range(cnt):
            a = list(map(str, a))
            print(' '.join(a))
        cnt = 1

cnt1 = 0
if cnt != 1:
    p = []
    ans = ans[::-1]
    for i in range(h):
        b = ans[i]
        if b == [0] * w:
            cnt1 += 1
        else:
            for j in range(cnt1):
                b = list(map(str, b))
                print(' '.join(b))
            exit()




Measured memory_bytes: 51824
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
long long r[4007], g[4007], b[4007];
map<char,int> map_;
char func(char a, char b){
	bool check[3];
	clr(check,false);
	check[map_[a]] = true;
	check[map_[b]] = true;
	for(int i = 0; i < 3; i++){
		if(check[i] == false){
			if(i == 0)
				return 'R';
			if(i == 1)
				return 'G';
			if(i == 2)
				return 'B';
		}
	}
	return '#';
}
int main() 
{ 
	map_['R'] = 0; map_['G'] = 1; map_['B'] = 2;
	long long sum  = 0;
	clr(r,0); clr(g,0); clr(b,0);
	int n; cin>> n;
	string s; cin>> s;
	for(int i = 0; i < n; i++){
		if(r - 1 >= 0){
			r[i] = r[i-1];
			g[i] = g[i-1];
			b[i] = b[i-1];
		}
		if(s[i] == 'R')
			r[i]++;
		if(s[i] == 'G')
			g[i]++;
		if(s[i] == 'B')
			b[i]++;
	}
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(s[i] != s[j]){
				char c = func(s[i],s[j]);
				
				long long cnt = 0;
				int d = j - i;
				if(c == 'R'){
					cnt = r[n-1] - r[j];
					if(s[j + d] == c)
						cnt--;
				}
				if(c == 'G'){
					cnt = g[n-1] - g[j];
					if(s[j + d] == c)
						cnt--;
				}
				if(c == 'B'){
					cnt = b[n-1] - b[j];
					if(s[j + d] == c)
						cnt--;
				}
				//~ cout<< i <<" "<<j << " "<<c<<" "<<cnt<<endl;
				sum += cnt;
			}
		}
	}
	cout<<sum;
	return 0;
} 




Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <string>
using namespace std;

#define sz 105

int ara[sz] = {0};

int main(){

    int a, b, c;

    scanf("%d%d%d", &a, &b, &c);

    if(a != b && b != c && c != a) puts("3");
    else if((a == b && b != c) || (a == c && a != b) || (b == c && c != a)) puts("2");
    else puts("1");

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

from heapq import heappush, heappop
class PriorityQueue:

    def __init__(self):
        self.contaier = []

    def push(self, priority): # smaller is first
        heappush(self.contaier, (-1 * priority, priority))

    def pop(self):
        return heappop(self.contaier)[1]

    def is_empty(self):
        return len(self.contaier) == 0

def solve(data):
    confortable = 0
    chairs = PriorityQueue()
    chairs.push(data[0])
    for d in data[1:]:
        c = chairs.pop()
        confortable += c
        chairs.push(d)
        chairs.push(d)
    return confortable


if __name__ == '__main__':
    n = int(input())
    data = list(map(int, input().split()))
    data.sort()
    data.reverse()
    #print('data') # debug
    #print(data) # debug
    ans = solve(data)
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


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

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

    int ans = 0;
    if (a >= 13)
    {
        ans = b;
    }
    else if (a >= 6)
    {
        ans = b / 2;
    }
    else
    {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
li=[]
for i in range(n):
    a, b=map(int,input().split())
    li.append([a,b])
li=sorted(li, key=lambda x: x[0])
li=sorted(li, key=lambda x: x[1])
cnt=0
for i in range(n):
    cnt+=li[i][0]
    if cnt>li[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 39632
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ll dp[MAX][2],done[MAX][2];
vl g[MAX];
ll dfs(ll u,ll p,ll c){
  if(done[u][c])return dp[u][c];
  ll ans = 1;
  for(auto v:g[u]){
    if(v!=p){
      if(c == 1){
        ans*=dfs(v,u,0);
        ans%=MOD;
      }
      else{
        ans*=(dfs(v,u,1)+dfs(v,u,0))%MOD;
        ans%=MOD;
      }
    }
  }
  done[u][c] = 1;
  return dp[u][c] = ans;
}
int main(){FAST;
cin>>n;
if(n == 1){
  cout<<2;
  return 0;
}
for(ll i=1;i<=n-1;++i){
  ll u,v;cin>>u>>v;
  g[u].pb(v);
  g[v].pb(u);
}
cout<<(dfs(1,0,0)+dfs(1,0,1))%MOD;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */

Measured memory_bytes: 20376
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    int N, K;
    cin >> N >> K;
    deque<pll> dt(N);
    for (int i = 0; i < N; ++i) {
        ll t, d;
        cin >> t >> d;
        dt.emplace_back(d, t);
    }
    sort(dt.begin(), dt.end(), greater<pll>());
    map<ll, int> ts;
    ll base = 0;
    priority_queue<pll, vector<pll>, greater<pll>> pq1;
    priority_queue<pll, vector<pll>, less<pll>> pq2;
    for (int i = 0; i < K; ++i) {
        base += dt[i].first;
        if (ts[dt[i].second] >= 1) {
            pq1.push(dt[i]);
        }
        ts[dt[i].second]++;
    }
    ll kinds = ts.size();
    ll ret = base + kinds * kinds;
    for (int i = K; i < N; ++i) {
        if (ts[dt[i].second] == 0)
            pq2.push(dt[i]);
        ts[dt[i].second]++;
    }
    while (!pq2.empty() && !pq1.empty()) {
        auto s = pq2.top();
        pq2.pop();
        auto t = pq1.top();
        pq1.pop();
        base += s.first - t.first;
        kinds++;
        ret = max(ret, base + kinds * kinds);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 10612
import collections
import math
import numpy as np

# = input()
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
#
is_true = True
field = []
for i in range(3):
  field.append(list(map(int, input().split())))

field = np.array(field)
for i in range(3):
  field[i] -= min(field[i])

is_true = np.where(field==field[0], True, False).all()

field = np.array(field).T
for i in range(3):
  field[i] -= min(field[i])

is_true2 = np.where(field==field[0], True, False).all()

print('Yes' if is_true * is_true2 else 'No')

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    ll ans = 0;
    FOR(A, 1, N + 1) {
        ll max_B = (N - EPS) / A;
        ans += max_B;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
n = int(input())
lishop = [list(map(int,input().split())) for i in range(n)]
liben = [list(map(int,input().split())) for i in range(n)]

ans = 10**9
ans *= -1
for i in range(1,1024):
  tmp = format(i,'b').zfill(10)
  litmp = [0]*n
  for j in range(10):
    if tmp[j] == "1":
      for k in range(n):
        litmp[k] += lishop[k][j]
#  print(litmp)
  tmp2 = 0
  for j in range(n):
    tmp2 += liben[j][litmp[j]]
  ans = max(tmp2,ans)
print(ans)

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

int main() {
    int i, N, X, T;

    cin >> N;
    cin >> X;
    cin >> T;

    if (N%X == 0) {
        i = N*T/X;
    } else {
        i = (N/X + 1)*T;
    }

    cout << i << endl;

}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	//変数宣言
	int height[10],	//高さの配列
		pos,		//最大値消去用
		max[3];		//最大値格納
	//入力
	for(int i=0;i<10;i++)
		cin >> height[i];

	//最大値を出す
	for(int i=0;i<3;i++){
		int tmp = 0;
		//最大値を出す & posに場所記録
		for(int n=0;n<10;n++){
			if(tmp<height[n]){
				tmp = height[n];
				pos = n;
			}
		}
			//最大値を記録
			max[i] = tmp;
			//最大値を消す
			height[pos] = 0;
	}

	//表示
	for(int i=0;i<3;i++)
		cout << max[i] << "\n";
	return 0;
}

Measured memory_bytes: 1160
from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
ma = max(a)
mb = [i for i in b if i > ma]
mb.sort(reverse=True)
if sum(mb) >= h:
    i = 0
    while h > 0:
        h -= mb[i]
        i += 1
    print(i)
else:
    cnt = len(mb)
    h -= sum(mb)
    print(cnt + ceil(h/ma))

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int H, W; cin >> H >> W;
    vector<string> s(H);
    for(int i = 0; i < H; i++){
        cin >> s[i];
    }
    int dx[] = {1, 0, -1, 0, -1, 1, -1, 1};
    int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if(s[h][w] != '#'){
                int cnt = 0;
                for(int i = 0; i < 8; i++){
                    int nx = w + dx[i];
                    int ny = h + dy[i];
                    if(nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
                    if(s[ny][nx] == '#') cnt++;
                }
                s[h][w] = char(cnt + '0');
            }
        }
    }
    for(int i = 0; i < H; i++){
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()

s = s.replace("BC", "*")

point = 0
charge = 0
for i in range(len(s) - 1, -1, -1):
    if s[i] == "*":
        charge += 1
    elif s[i] == "A":
        point += charge
    else:
        charge = 0

print(point)


Measured memory_bytes: 3500
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
int main(){
    long double L;
    cin >> L;
    cout << fixed << setprecision(15) << L * L * L / 27 << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
using namespace std;

int n, a, b;
char S[110000];

int main() {
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", S);
	int l = strlen(S);
	for (int i = 0; i < l; i++)
		if (S[i] == 'a' && a + b > 0) {
			printf("Yes\n");
			a -= 1;
		}else if (S[i] == 'b' && b > 0 && a + b > 0) {
			printf("Yes\n");
			b -= 1;
		}else printf("No\n");
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <math.h>
#define PI 3.14159265359
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {

	// 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	int N, M;
	long long A = 0;

	cin >> N >> M;

	int tmp;
	for (int i = 0; i < M; i++)
	{
		cin >> tmp;
		A += tmp;
	}

	int res;

	if (N >= A) {
		res = N - A;
	}
	else {
		res = -1;
	}

	cout << res << endl;

	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll a, b;
    cin >> a >> b;

    if(a > 0){
        cout << "Positive" << endl;
        return 0;
    }
    if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
        return 0;
    }
    if(b<0){
        if((b-a+1)%2 == 0){
            cout << "Positive" << endl;
            return 0;
        }
        else{
            cout << "Negative" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define  all(v)     (v).begin(),(v).end()
#define  rall(v)    (v).rbegin(),(v).rend()
#define  pb         push_back
#define  eb         emplace_back
#define  mp         make_pair
#define  ff         first
#define  ss         second
#define  pf         push_front
#define  bs         binary_search
#define  lb         lower_bound
#define  ub         upper_bound
#define  dec(x)   fixed<<setprecision(x)
#define  lcm(a,b)   (a*b/__gcd(a,b))
const ll inf=LLONG_MAX;
const ll mod=1e9+7;
const ld pi=acos(-1);
                    
void solution(){
    ll x;
    cin>>x;
    if(x==0){cout<<1;}
    else cout<<0;
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solution();
        cout<<"\n";
    }
    return 0;
}


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

int main(){
  int N, K, n = 1;
  
  cin >> N >> K;
  
  while(N > 0){
    if(n*2 < n+K){
      n *= 2;
    }
    else{
      n += K;
    }
    N--;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
// Jai Sai Ram
//Always help me!
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2001][2001];
ll P=1e9+7;
void solve()
{
    ll i,j,k,l,m,n,o,p,q,r,t,a,b,c,d;
    cin>>n;
    for(i=0;i<=n;i++)
    {
         for(j=0;j<=n;j++)
         {
             dp[i][j]=0;
         }
    }
    dp[0][0]=1;
    for(i=3;i<=n;i++)
    {
       
        for(j=3;j<=n;j++)
        {
             dp[i][j]+=dp[i][j-1];
                dp[i][j]%=P;
            if(j>i)
            {
                
            }
            else 
            {
                dp[i][j]+=dp[i-j][i-j];
                dp[i][j]%=P;
            }
        }

    }
   
    cout<<dp[n][n]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(0);
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 34764
#include <stdio.h>

int a[105];

int main(){
    int N;
    scanf("%d", &N);
    for(int i=0; i<N; i++) scanf("%d", &a[i]);
    int res = 1000000000;
    for(int i=-100; i<=100; i++){
        int need=0;
        for(int j=0; j<N; j++) need += (a[j]-i)*(a[j]-i);
        if(need < res) res = need;
    }
    printf("%d", res);
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b, c = MAP()

if c-a-b >= 0 and 4*a*b < pow(c-a-b, 2):
    Yes()
else:
    No()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n;
int par[100001];
bool vis[100001];
int s[100001];
vector<int>v[100001];
void dfs(int x,int p)
{
	vis[x]=true;
	par[x]=p;
	for(int i=0;i<v[x].size();i++)
	{
		if(!vis[v[x][i]])dfs(v[x][i],x),s[x]+=s[v[x][i]];
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)s[i]=1;
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,0);
	int s1,s2;
	int k=n;
	int ss=0;
	while(par[k]!=1)
	{
		k=par[k];
		ss++;
	}
	int x=ss/2;
	k=n;
	for(int i=1;i<=x;i++)
	{
		k=par[k];
	}
	s2=s[k];
	s1=n-s2;
	if(s1>s2)printf("Fennec");else printf("Snuke");
	return 0;
}

Measured memory_bytes: 11264
#!/usr/bin/env python3

# 幸福度が増すパターン
# L:R--R:L  L:L---L:L +2
# R:L--L:R  R:R---R:R +2

# :R---R:L  :L---L:L  +1
# :R---R:R
# :R---R:L  :L---L:L  +1
# L:R---R

# :L---L:R

# L:R を 1
# R:L を 2
#
# 1-2 2-1


def solve(N, K, S):
    ans = 0
    last = S[0]
    lr = 0
    rl = 0
    for s in S[1:]:
        if last != s:
            if last == 'L':
                lr += 1
            else:
                rl += 1
        else:
            ans += 1
        last = s

    n = min(lr, rl)
    if n >= K:
        ans += K*2
    else:
        ans += n*2
        if lr != rl:
            ans += 1

    return ans


if __name__ == '__main__':
    N, K = map(int, input().split())
    S = input()

    ans = solve(N, K, S)

    print(ans)


Measured memory_bytes: 3316
s = gets.chomp.split(" ")
$n = s[0].to_i
$m = s[1].to_i
$list = Array.new($n).map{Array.new($n,false)}
$visited = Array.new($n,false)

for i in 0..$m-1 do
    s = gets.chomp.split(" ")
    a = s[0].to_i-1 
    b = s[1].to_i-1
    $list[a][b] = $list[b][a] = true
end

def check( i=0 )
    $visited[i] = true
    for j in 0..$n-1 do
        check(j) if $list[i][j] and $visited[j] == false
    end

    if $visited.count {|num| num == false } >= 1 then return false
    else return true end
end

count = 0
for i in 0..$n-1 do
    for j in 0..i do
        if $list[i][j] then
            $list[i][j] = $list[j][i] = false
            $visited.map!{false}
            count += 1 if check() == false
            $list[i][j] = $list[j][i] = true
        end
    end
end

puts count

Measured memory_bytes: 1916