akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e3+17;
int mp[MAXN*2][MAXN*2];
int cnt[MAXN*2][MAXN*2];
inline int dap(int rx,int ry,int lx,int ly){return cnt[rx][ry]-cnt[rx][ly-1]-cnt[lx-1][ry]+cnt[lx-1][ly-1];}
int main(int argc ,char const *argv[])
{
   	 #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n,k;
    cin>>n>>k;
    for (int i = 0; i < n; ++i)
    {
    	int x,y;
    	string cl;
    	cin>>x>>y>>cl;
    	x++,y++;
    	if(cl=="B")	x+=k;
    	int a = x%(2*k)==0?(2*k):x%(2*k);
    	int b = y%(2*k)==0?(2*k):y%(2*k);
    	mp[a][b]++;
    }
    for (int i = 1; i <= 2*k; ++i)
    	for (int j = 1; j <= 2*k; ++j)
    		cnt[i][j] = mp[i][j]+cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1];
    int ans = 0;
    for (int i = 1; i <= k; ++i)
    	for (int j = 1; j <= k; ++j)
    	{
    		int mid =  dap(2*k+1-i,2*k+1-j,k+2-i,k+2-j);
    		int zx = dap(k+1-i,k+1-j,1,1);
    		int zs = dap(k+1-i,2*k,1,2*k+2-j);
    		int ys = dap(2*k,2*k,2*k+2-i,2*k+2-j);
    		int yx = dap(2*k,k+1-j,2*k+2-i,1);
    		int sum = mid+zx;
    		if(j!=1) sum += zs;
    		if(i!=1) sum += yx;
    		if((j!=1)&&(i!=1)) sum+=ys;
    		int fan = dap(2*k,2*k,1,1)-sum;
    		ans = max(ans,max(fan,sum));
    	}
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD= 1000000007;
signed main() {
int n;
cin>>n;
int x[n];
for(int i=0;i<n;i++)cin>>x[i];
int t=0,ans=1;
for(int i=0;i<n;i++){
  t++;
  while(x[i]<t*2-1){
    ans=(ans*t)%MOD;
    t--;
  }
}
while(t){
  ans=(ans*t)%MOD;
  t--;
}
cout<<ans;
return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  int p0 = 0, p1 = 0, p2 = 0;
  rep(i, n){
    int p;
    cin >> p;

    if(p <= a) p0++;
    if(a < p and p <= b) p1++;
    if(b < p) p2++;
  }

  cout << min(p0, min(p1, p2)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int n;
int a;

int main() {

    std::cin>>n;

    int res=1,res1=1;

    for(int i=0;i<n;++i){
        std::cin>>a;
        res*=3;
        if(a%2==0)
            res1*=2;
    }

    std::cout<<res-res1<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(void)
{
    ll N;
		cin >> N;
    vector<ll> h(N);
    vector<ll> dp(N);
		rep(i, N) cin >> h.at(i);
		rep(i, N) dp.at(i) = INF;
		dp.at(0) = 0;

		repd(i, 1, N)
		{
			chmin(dp.at(i), dp.at(i-1) + abs(h.at(i) - h.at(i-1)));
			if(i>1) chmin(dp.at(i), dp.at(i-2) + abs(h.at(i) - h[i-2]));
		}
		cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  ll int a = 100, b, c = 0;
  cin >> b;
  while(a < b){
    a += a / 100;
    c++;
  }
  cout << c << "\n";
  return 0;
}

Measured memory_bytes: 3608
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64, int64[:], int64[:], ), cache=True)
def pre_calc(n, pos, coef):
    ret = np.empty((1 << n, n), np.int64)
    ret[0] = np.abs(pos) * coef

    for i in range(n):
        bt = 1 << i
        ret[bt:2 * bt] = np.minimum(ret[:bt], np.abs(pos - pos[i]) * coef)

    return ret


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = pre_calc(n, x, p)
    hor = pre_calc(n, y, p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")


Measured memory_bytes: 117856
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

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

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, t;
	cin >> a >> b >> t;

	cout << (t / a)*b << endl;

	return 0;
}

Measured memory_bytes: 256
n=(int)(input())
a=list(map(int, input().split(" ")))
for i in range(len(a) - 1, 0, -1):
  if a[i] < a[i - 1]:
    a[i - 1] -= 1
  if a[i] < a[i - 1]:
    print("No")
    break
else:
  print("Yes")

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

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

int main() {
    int S; cin >> S;
    vector<int> v(10000000);
    v[0] = S;
    rep(i,10000000){
        if(v[i] % 2 == 0){
            v[i + 1] = v[i] / 2;
            for(int j = i - 1; j >= 0; j--){
                if(v[i] == v[j]){
                    cout << i + 1 << endl;
                    return 0;
                }
            }
        }else{
            v[i + 1] = 3*v[i] + 1;
            for(int j = i - 1; j >= 0; j--){
                if(v[i] == v[j]){
                    cout << i + 1 << endl;
                    return 0;
                }
            }
        }
    }
}

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

int main(){
  string str;
  cin>>str;
  if((int)str.size()>=4 && str[0]=='Y' && str[1]=='A' && str[2]=='K' && str[3]=='I'){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
# include <string>
# include <cstdio>

using namespace std;
int main(void) {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
 
  int x_diff = tx- sx;
  int y_diff = ty - sy; 

  	cout << string(y_diff, 'U') << string(x_diff+1, 'R');
    cout << string(y_diff+1, 'D')<< string(x_diff+1, 'L') << string(1, 'U');
    
  	cout << string(x_diff, 'R') << string(y_diff+1, 'U');
  	cout << string(x_diff+1, 'L') << string(y_diff+1, 'D');
    cout << string(1, 'R') << endl;
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve(int n,int m){
    int c[m];
    for(int i=0;i<m;i++)scanf("%d",&c[i]);
    vector<long long> dp(256,1e18);
    dp[128]=0;
    for(int i=0;i<n;i++){
        int x;scanf("%d",&x);
        vector<long long> ndp(256,1e18);
        for(int j=0;j<256;j++){
            if(dp[j]==1e18)continue;
            for(int k=0;k<m;k++){
                int p=min(255,max(0,j+c[k]));
                ndp[p]=min(ndp[p],dp[j]+(x-p)*(x-p));
            }
        }
        dp=ndp;
    }
    long long ans=1e18;
    for(int i=0;i<256;i++){
        ans=min(ans,dp[i]);
    }
    printf("%lld\n",ans);
}
int main(){
    while(true){
        int n,m;scanf("%d%d",&n,&m);
        if(n==0 and m==0)break;
        solve(n,m);
    }
    return 0;
}


Measured memory_bytes: 3232
public class Main {
  private static void solve() {
    char c = ns()[0];
    System.out.println((char) (c + 1));

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    string S;
    cin >> S;
    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    int C_count = 0;
    for(int i = 2; i <= S.size() - 2; i++){
        C_count += (S[i] == 'C');
    }
    if(C_count != 1){
        cout << "WA" << endl;
        return 0;
    }
    int big_character_count = 0;
    for(int i = 0; i < S.size(); i++){
        big_character_count += ('A' <= S[i] && S[i] <= 'Z');
    }
    if(big_character_count == 2){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
import sys;
import math;
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(float, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()

n = int(input());
arr = get_array();
dp = [[0 for i in range(n+1)] for i in range(n+1)];
dp[0][0]=1;
for i in range(1,n+1):
    dp[i][0]=dp[i-1][0]*(1-arr[i-1])
for i in range(1,n+1):
    for j in range(1,n+1):
        if(i==j):
            dp[i][j]=dp[i-1][j-1]*arr[i-1];
            continue
        if(j>i):
            continue;
        dp[i][j] = dp[i-1][j-1]*arr[i-1]+dp[i-1][j]*(1-arr[i-1]);
#print(dp);
ans = 0;
for i in range(n+1):
    if(i>=n//2 + 1):
        ans += dp[n][i];
print(ans);


Measured memory_bytes: 224376
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[sc.nextInt() - 1] = i + 1;
		}

		StringBuilder sb = new StringBuilder();
		Arrays.stream(a).forEach(i ->  {
			sb.append(" ");
			sb.append(i);
		});
		sb.deleteCharAt(0);
		System.out.println(sb.toString());

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 33216
#include<stdio.h>
int main(){
	int a, b, c, d, p;
	int x, y, m;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &p);
	x = a*p;
	if (p>c) y = b + ((p - c)*d);
	else y = b;
	if (x>y)printf("%d\n", y);
	else printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 2736
main = 
  let 
    func = do
      line <- getLine
      let 
        [h,w] = map read $ words line :: [Int]
        drawLine w = 
          if w > 0
            then do 
              putStr "#"
              drawLine (w-1)
            else do
              putStrLn ""
        drawRect h w =
          if h > 0
            then do
              drawLine w
              drawRect (h-1) w
            else do
              putStrLn ""
        in 
          if h == 0 && w == 0
            then putStr ""
            else do
              drawRect h w
              func
    in func



Measured memory_bytes: 4100
import math
a,b,x=map(int,input().split())
y=0
if x==a**2*b:
    print(0)
    exit()
elif x<=a**2*b*0.5:
    y+=2*x/(a*b**2)
   
else:
    y+=a**3/(2*b*a**2-2*x)
   
theta=math.degrees(math.atan(y))   
print(90 - theta)    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    VEC(int,b,n);
    std::vector<int> d(n);
    rep(i,n){
        d[i]=i+1;
    }
    int aa,bb;
    int c=0;
    do{
        bool aaa=1,bbb=1;
        rep(i,n){
            if(a[i]!=d[i])aaa=0;
            if(b[i]!=d[i])bbb=0;
        }
        c++;
        if(aaa)aa=c;
        if(bbb)bb=c;
    }while(next_permutation(all(d)));
    std::cout << abs(aa-bb) << std::endl;
}

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

typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int mx=-105;
    int sum=0;
    while(n--)
    {
        int a;
        cin>>a;
        mx=max(mx,a);
        sum+=a;
    }
    sum-=mx;
    cout<<(mx<sum ? "Yes" : "No")<<endl;
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

s = gets.chomp.split('')
n = s.size
a = []
check = 0

(n/2).times do |i|
  check += 1 if s[i] == s[-(i+1)]
end
if check != (n / 2)
  puts :No
  exit
end
(0...(n-1)/2).each do |i|
  a << s[i]
end
check = 0
(a.size / 2).times do |i|
  check += 1 if a[i] == a[a.size - 1 - i]
end
if check != a.size / 2
  puts :No
  exit
end

b = []
(((n + 3) / 2 - 1)...n).each do |i|
  b << s[i]
end
check = 0
(b.size / 2).times do |i|
  check += 1 if b[i] == b[b.size - 1 - i]
end
if check != b.size / 2
  puts :No
  exit
end
puts :Yes


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin>>A>>B;
  if(A%3==0) cout<<"P";
  else if(B%3==0)cout<<"P";
  else if((A+B)%3==0)cout<<"P";
  else cout<<"Imp";
  cout<<"ossible";
  return 0;
 
}


Measured memory_bytes: 256
n,m=map(int,input().split())
graph=[[] for i in range(n)]
for i in range(m):
    u,v=map(int,input().split())
    graph[u-1].append(v-1)
s,t=map(int,input().split())
s=s-1
t=t-1
from collections import deque
que=deque([])
que.append(s)
check0=[-1]*n
check1=[-1]*n
check2=[-1]*n
check0[s]=0
while len(que)>0:
    now=que.popleft()
    for i in graph[now]:
        if check1[i]==-1:
            if check0[now]!=-1:
                check1[i]=check0[now]+1
                que.append(i)
        if check2[i]==-1:
            if check1[now]!=-1:
                check2[i]=check1[now]+1
                que.append(i)
        if check0[i]==-1:
            if check2[now]!=-1:
                check0[i]=check2[now]+1
                que.append(i)
if check0[t]==-1:
    print(-1)
else:
    print(check0[t]//3)


Measured memory_bytes: 74400
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	counter := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					counter += 1
				}
			}
		}
	}
	fmt.Println(counter)
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF_L = 1e17+7;
const long long INF_I = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;

int main(){	
	
	long long n,m,d;
	cin >> n >> m >> d;
	long double ans;
	
	if(d>0){
		ans=(double)(m-1)*(2*(double)(n-d)/(double)(pow(n,2)));
	}else if(d==0){
		ans=(double)(m-1)*((double)1/(double)(pow(n,1)));
	}
	
	cout << fixed << setprecision(10) << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3720
import Data.List

-- 二分探索をするやつ。単調な条件関数 f と、f ok を満たす ok、f ng を満たさない ng を与えると、f x をギリギリ満たすような x を返す
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))

-- 悲しさ値の計算関数
f a b = sum $ map abs $ zipWith (-) a [b+1..]

-- b と b+1 の悲しさ値の差分。これは単調。
diff a b = f a (b+1) - f a b

-- 悲しさ値の差分が非負になるような値を求め、その値における悲しさ値を返す。これは悲しさ値の最小値となる。
calc a = let b = ibsearch ((>=0) . diff a) (maximum a, minimum a - length a - 1) in f a b

main = getLine >> getLine >>= print . calc . map read . words


Measured memory_bytes: 70012
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> M(N);
    ll sum = 0;
    rep(i, N)
    {
        cin >> A[i];
        sum += A[i];
    }
    M[0] = sum;
    for (int i = 1; i < N; i+= 2) {
        M[0] -= 2 * A[i];
    }
    for (int i = 1; i < N; i++) {
        M[i] = 2 * A[i - 1] - M[i - 1];
        }
    rep(i, N)
    {
        cout << (i == 0 ? "" : " ") << M[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        sa: String,
        sb: String,
        sc: String,
    }

    let va: Vec<char> = sa.chars().collect();
    let vb: Vec<char> = sb.chars().collect();
    let vc: Vec<char> = sc.chars().collect();
    let v: Vec<Vec<char>> = vec!(va, vb, vc);
    let mut turn = 0;
    let mut card_idx = vec!(0, 0, 0);
    loop {
        if card_idx[turn] == v[turn].len() {
            match turn {
                0 => println!("A"),
                1 => println!("B"),
                2 => println!("C"),
                _ => unreachable!(),
            }
            return;
        }

        card_idx[turn] += 1;
        turn = match v[turn][card_idx[turn] - 1] {
            'a' => 0,
            'b' => 1,
            'c' => 2,
            _ => unreachable!(),
        };
    }
}


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

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

  if (a+b > c+d){
    cout << "Left" << endl;
  } else if (a+b == c+d){
    cout << "Balanced" << endl;
  } else if (a+b < c+d){
    cout << "Right" << endl;
  }
}

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

int main(){
    int N, X; cin >> N >> X;
    int L[110];
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    int ans=1;
    int now=0;
    for(int i=0; i<N; i++){
        now += L[i];
        if(now<=X) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,m,b[N],num[N],ans;ll a[N];
struct edge{
	int a,b,val;
	bool operator <(const edge&e){return val<e.val;}
}ed[N];
inline int f(int x){if(b[x]!=x)return b[x]=f(b[x]);return x;}
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(register int i=1;i<=m;i++)scanf("%d%d%d",&ed[i].a,&ed[i].b,&ed[i].val);
	sort(ed+1,ed+m+1);
	for(register int i=1;i<=n;i++)b[i]=i;
	for(register int i=1;i<=m;i++){
		int x=ed[i].a,y=ed[i].b,z=ed[i].val;
		int f1=f(x),f2=f(y);
		if(f1!=f2)a[f1]+=a[f2],num[f1]+=num[f2];
		num[f1]++;b[f2]=f1;
		if(z<=a[f1])ans+=num[f1],num[f1]=0;
	}
	printf("%d\n",m-ans);
	return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    char c;
    cin >> c;
    cout << (char)(c+1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"YES"<<endl;
}

void no(){
    cout<<"NO"<<endl;
}

void solve(){
    string a;
    cin>>a;
    int ca=0;
    int cb=0;
    for(int i=0;i<3;i++){
        if(a[i]=='A'){
            ca++;
        }else{
            cb++;
        }
    }
    if(ca==0 || cb==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
using namespace std;

typedef long long ll;

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

string s, t;
int n;

void solve(){
}

int main(){
  while(cin >> s){
    cin >> n;
    int res = 0;
    rep(i,n){
      cin >> t;
      t = t + t;
      if(t.find(s) != -1) res++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main()
{
	int n, b =0, c = 0,d = 0,e = 0;
	string a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a[0] == 'A')
			b++;
		else if (a[0] == 'T' )
			c++;
		else if (a[0] == 'W')
			d++;
		else {
			e++;
		}
	}cout << "AC x "<< b << endl;
	cout << "WA x " << d << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x "<< e << endl;
	
	return 0;
}

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

int i,j,k;
int d,n,m,a[100005],b[10005],x,ans=0;
int p,q,r;
int comp(const void *p,const void *q){
	return *(int *)p-*(int *)q;
}

int main(){
	scanf("%d",&d);
	while(d!=0){
		scanf("%d",&n);
		scanf("%d",&m);
		for(i=1;i<=n-1;i++)scanf("%d",&a[i]);
		a[0]=0,a[n]=d;
		//for(i=0;i<m;i++)scanf("%d",&b[i]);
		qsort(a,n+1,sizeof(int),comp);
		//for(i=0;i<=n;i++)printf("%d ",a[i]);
		ans=0;
		for(i=0;i<m;i++){
			scanf("%d",&x);
			p=0;q=n;
			while(q-p>1){
				r=(p+q)/2;
				//if(a[r]==b[i])break;
				/*else*/ if(a[r]>x)q=r;
				else p=r;
			}
			//if(b[i]-a[r]>a[r+1]-b[i])ans+=a[r+1]-b[i];
			//else ans+=b[i]-a[r];
			if(x-a[p]>a[q]-x)ans+=a[q]-x;
			else ans+=x-a[p];
			//printf("%d ",ans);
		}
		printf("%d\n",ans);
		scanf("%d",&d);
	}
	return 0;
}

Measured memory_bytes: 1120
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

a = int(input())

print(a + a ** 2 + a ** 3)

Measured memory_bytes: 9180
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] cnt = new int[n + 1];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			cnt[a]++;
		}
		sc.close();

		Arrays.parallelSort(cnt);
		int ans = 0;
		for (int i = 0; i < cnt.length - k; i++) {
			ans += cnt[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 86628
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N = get_input(int)
    A = get_inputs(int)

    counter = Counter(A)

    sigma = 0
    for n in counter.values():
        sigma += n * (n-1) // 2

    for a in A:
        print(sigma - (counter[a] - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 34176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// dp[a][b]:a©çb,n-bÉªf·éÌÉKvÈÅ¬b
//int dp[10001][5001];
int dp[2][5010][2];
int times[10001];
int n;
const int INF=1000000000;


//    for(int i = idx; i < n-1; i++){
//        int len1=i-idx+1;
//        int len2=n-len1;
//        if(len1==length||len2==length)
//            minTime=min(minTime,times[i]);
//        else{
//            int al=n-idx;
//            int minl=length;
//            int maxl=al-length;
//
//            if(minl-len1>0)
//                minTime=min(minTime,dfs(i,min(minl-len1,len2))+times[i]);
//            if(maxl-len1>0)
//                minTime=min(minTime,dfs(i,min(maxl-len1,len2))+times[i]);
//            if(minl-len2>0)
//                minTime=min(minTime,dfs(i,min(minl-len2,len1))+times[i]);
//            if(maxl-len2>0)
//                minTime=min(minTime,dfs(i,min(maxl-len2,len1))+times[i]);
//        }
//    }
//    return dp[idx][length]=minTime;
//}

int main(){

    cin>>n;
    for(int i = 0; i < n; i++)cin>>times[i];
    for(int i = 0; i < 2; i++)
        for(int j = 0; j < 5010; j++)
            for(int k = 0; k < 2; k++)
                dp[i][j][k]=INF;
    dp[0][1][0]=0;
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j <= 5000; j++){
            if(i==n-1){
                cout<<endl;
            }
            dp[(i+1)&1][j+1][0]=min(dp[i&1][j][0],dp[i&1][j][1]+times[i]);
            dp[(i+1)&1][j][1]=min(dp[i&1][j][0]+times[i],dp[i&1][j][1]);
        }
        dp[i&1][0][0]=INF;
    }
    int res;
    dp[(n-1)%2][n/2][1];
    cout<<min(dp[(n-1)%2][n/2][0],dp[(n-1)%2][n/2][1])<<endl;

    return 0;
}

Measured memory_bytes: 944
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val m = mutableMapOf<Int, Int>()
	val n = scn.nextInt()
	repeat(n){
		val a = scn.nextInt()
		m[a] = m.getOrElse(a){0} + 1
	}
	var s = m.entries.sumByDouble { it.key*it.value.toDouble() }.toLong()
	val q = scn.nextInt()
	repeat(q){
		val b = scn.nextInt()
		val c = scn.nextInt()
		val mb = m.remove(b)
		if (mb!=null){
			m[c] = m.getOrElse(c){0} + mb
			s += mb.toLong() * (c-b)
		}
		println(s)
	}
}


Measured memory_bytes: 65592
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test  ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main(){
    io ; 
   
   int a,b ; cin>>a>>b ; 
   //a is the num of animals and b are the legs . 
   if(a>b){
       cout<<"No" ; return 0 ; 
   }
   if(a==1 and b==2){
       cout<<"Yes\n" ; return 0 ; 
   }
   if(a==1 and b==4){
       cout<<"Yes\n" ; return 0 ; 
   }
   //base cases done . 
   for(int i=1 ; i<=a ; i++){
       if( 2*i + 4*(a-i)==b){
           cout<<"Yes\n" ; return 0 ; 
       }
   }
  
    if(2*a==b or 4*a==b){
     cout<<"Yes\n" ;  return 0 ; 
    }
  
  cout<<"No\n" ; 
  
 }

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    if(a==b+c||b==a+c||c==a+b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

vector<ll> G[212345];

int main() {
  ll N, Q;
  cin >> N >> Q;

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> S(N + 5, 0);
  vector<int> visited(N + 5, 0);

  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    S[p] += x;
  }

  queue<int> q;
  q.push(1);
  while(!q.empty()) {
    int temp = q.front();
    q.pop();
    visited[temp] = 1;
    for (int i = 0; i < G[temp].size(); i++) {
      int index = G[temp][i];
      if (visited[index] == 0) {
        S[index] += S[temp];
        q.push(index);
      }
    }
  }

  cout << S[1];
  for (int i = 2; i <= N; i++) {
    cout << SP << S[i];
  }
  cout << BR;

  return 0;
}

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

int main()
{  
  while(true){
    int n;
    cin >> n;
    if(n==0) break;
    int asum=0,bsum=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      if(a>b) asum=asum+a+b;
      else if(a<b) bsum=bsum+a+b;
      else if(a==b){
	asum +=a;
	bsum +=b;
      }
    }
    cout << asum << " " <<  bsum << endl;
  }
  
  return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s[12];
int dy[] = {-1, 0, 0, 1};
int dx[] = {0, -1, 1, 0};

void dfs(int y, int x) {
  s[y][x] = '0';
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i], nx = x + dx[i];
    if (ny >= 0 && ny < 12 && nx >= 0 && nx < 12 && s[ny][nx] == '1') {
      dfs(ny, nx);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> s[0]) {
    for (int i = 1; i < 12; i++) {
      cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < 12; i++) {
      for (int j = 0; j < 12; j++) {
        if (s[i][j] == '0') continue;
        dfs(i, j);
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3252
#include<stdio.h>
#include<math.h>
int n,m,x,a;
int r=0;
int l=0;
int main(){
scanf("%d",&n);
scanf("%d",&m);
scanf("%d",&x);
for(int i=0;i<m;i++){
scanf("%d",&a);
if(a<x)l++;
if(a>x)r++;
}
if(l>r)l=r;
printf("%d",l);
}

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

int	main(){

	while(true){
	
	int A,B,C,D,E,F,G,H,I,J,answer;
		
	cin >> A;
	if(A == 0) return 0;
	cin >> B >> C >> D >> E >> F >> G >> H >> I >> J;
	answer = A - B - C - D-E-F-G-H-I-J;
	cout << answer << endl;

	}
	return 0;
}


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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) a.size()

const int N = 2000100;
const int MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

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


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,k;
struct q
{
	int num,tot;
};
q qs[100001];
bool cmp(q a,q b)
{
	return a.num<b.num;
};
signed main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>qs[i].num>>qs[i].tot;
	}
	sort(qs,qs+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(k>qs[i].tot)
		{
			k-=qs[i].tot;
		}
		else
		{
			cout<<qs[i].num;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n,k;
	cin>>n>>k;
	int a[n+1],dp[k+1];
	loop(i,1,n+1) cin>>a[i];
	init(dp,0);
	loop(i,0,k+1) if(i<=a[1]) dp[i] = 1;
	loop(i,2,n+1)
	{
		loop(j,1,k+1) dp[j] = (dp[j] + dp[j-1])%mod;
		for(int j=k;j>0;j--)
			if(j>a[i]) 
				dp[j] = (dp[j] - dp[j-a[i]-1] + mod)%mod;
	}
	cout<<dp[k]<<endl;
	return 0;		
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
//BFSキタコレ
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> G[100000];
    vector<bool> visited(n,false);
    vector<int> sign(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue <int> q;
    q.push(0);
    while(!q.empty()){
        int p = q.front();
        visited[p]=true;
        q.pop();
        rep(i,G[p].size()){
            int next = G[p][i];
            if(!visited[next]){
                visited[next]=true;
                q.push(next);
                sign[next] = p;
                //cout<<"sign["<<next+1<<"]="<<p+1<<endl;
            }
        }
    }
    bool ans=true;
    rep(i,n){
        if(!visited[i]){
            ans=false;
        }
    }
    //if(!ans){
    //    cout<<"No"<<endl;
    //    return 0;
    //}
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<sign[i]+1<<endl;
    }
}

Measured memory_bytes: 10120
use std::io;

fn main() {
    let mut input = String::new();
    if let Ok(_) = io::stdin().read_line(&mut input) {
        if let Ok(x) = input.trim_end().parse::<i32>() {
            println!("{}", if x >= 30 { "Yes" } else { "No" });
        }
    }
}


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

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

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

    int ans = 1001;

    for(int i = 0; i < N; i++) {
        if(a[i][1] <= T && a[i][0] < ans) {
            ans = a[i][0];
        }
    }

    if(ans == 1001) {
        cout << "TLE";
    }
    else {
        cout << ans;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc075-C
#[fastout]
fn main() {
    input![n: usize, m: usize, edge: [(usize, usize); m]];

    // println!("n={}, m={} edges:{:?}", n, m, edge);

    let mut ad_mat = vec![vec![false; n as usize]; n as usize];

    for (from, to) in edge.iter() {
        ad_mat[from - 1][to - 1] = true;
        ad_mat[to - 1][from - 1] = true;
    }

    // println!("{:?}", ad_mat);

    let dfs = |non_use_edge: (usize, usize)| {
        let (non_from, non_to) = non_use_edge;
        let (non_from, non_to) = (non_from - 1, non_to - 1);

        eprintln!("non_use_edge: {}, {}", non_from, non_to);
        for from_node_idx in 0..n {
            eprintln!("from_node_idx: {:?}", from_node_idx);
            let mut s = Vec::new();
            let mut is_visits = vec![false; n];
            s.push(from_node_idx);

            let is_all_visits = |is_visits: &Vec<bool>| {
                for is_visit in is_visits.iter() {
                    // eprintln!("is_visit: {}", *is_visit);

                    if *is_visit {
                    } else {
                        return false;
                    }
                }

                return true;
            };

            while !(s.is_empty() || is_all_visits(&is_visits)) {
                let n = s.pop().unwrap();

                if is_visits[n] {
                    continue;
                }

                is_visits[n] = true;
                for (idx, to) in ad_mat[n].iter().enumerate() {
                    if (non_from == n && non_to == idx) || (non_from == idx && non_to == n) {
                        eprintln!("non_from: {}, non_to == {}", non_from, non_to);

                        continue;
                    }

                    if *to {
                        if !is_visits[idx] {
                            s.push(idx);
                        }
                    }
                }
            }

            eprintln!(
                "is_all_visits: {}, is_visits: {:?}, ",
                is_all_visits(&is_visits),
                is_visits
            );

            if !is_all_visits(&is_visits) {
                return false;
            }
        }

        return true;
    };

    let mut ans = 0;
    for non_use_edge in edge.iter() {
        if !dfs(*non_use_edge) {
            ans += 1;
        }
    }

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


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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    N, A, B, C, D = map(int, input().split())
    log(N, A, B, C, D)
    S = input()
    if "##" in S[A-1:max(D, C)]:
        print("No")
        return
    if C < D:
        print("Yes")
        return
    log(S[B-2:D+1])
    if "..." in S[B-2:D+1]:
        print("Yes")
        return
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572