akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[3];
signed main(){
  rep(i,3)scanf("%lld", &a[i]);
  sort(a, a+3, greater<int>());
  printf("%lld\n", a[0]*10+a[1]+a[2]);
	return 0;
}








Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans = "No";
		int c=0;
		int d = 0;

		while(4*c+7*d<=n) {
			while(4*c+7*d<=n) {
				if(4*c+7*d==n) {
					ans = "Yes";
					break;
				}else d++;
			}
			c++;
			d=0;
		}
		System.out.println(ans);
	}


}

Measured memory_bytes: 21844
#include<stdio.h>

int main()
{
    int N, M, C,i,j,k,sum=0, count=0;
    scanf("%d %d %d", &N, &M, &C);
    int B[M], A[M];

    for(i=0; i<M; i++)
        scanf("%d", &B[i]);

    for(j=0; j<N; j++)
    {
         sum = 0;
         for(k=0;k<M; k++)
            {
                scanf("%d", &A[k]);

                sum += A[k]*B[k];


            }
            if(sum+C > 0)
                count++;
    }


    printf("%d\n", count);

    return 0;
}


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

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

  vector<int> a(N); 
  rep(i, 0, N) cin >> a.at(i);

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

  int Ans = 0;
  rep(i, 0, N) {
    if ((i+1)%2) Ans += a.at(i);
    else Ans -= a.at(i);
  }

  cout << Ans << endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
#define mid ((l + r) >> 1)
#define lson (x << 1)
#define rson ((x << 1) | 1)
using namespace std;
typedef long long LL;
const LL N = 998244353;

LL val[800005];

void pushup(LL x){
	val[x] = max(val[lson],val[rson]);
}

void modify(LL x,LL l,LL r,LL L,LL R,LL v){
	if(L > R) return;
	if(L <= l && r <= R){
		val[x] = v;
		return;
	}
	if(L <= mid) modify(lson,l,mid,L,R,v);
	if(R > mid) modify(rson,mid + 1,r,L,R,v);
	pushup(x);
}

LL query(LL x,LL l,LL r,LL L,LL R){
	if(L > R) return -1;
	if(L <= l && r <= R) return val[x];
	LL ret = 0;
	if(L <= mid) ret = max(ret,query(lson,l,mid,L,R));
	if(R > mid) ret = max(ret,query(rson,mid + 1,r,L,R));
	pushup(x); return ret;
}

struct node{
	LL x,d;
}s[400005];
bool cmp(node x,node y){
	return x.x < y.x;
}

LL n,ans = 0;
LL mr[400005],suf[400005] = {0},dp[400005] = {0};

LL kpw(LL x,LL y){
	LL ans = 1,tmp = x % N;
	while(y){
		if(y & 1) ans = (ans * tmp) % N;
		tmp = (tmp * tmp) % N;
		y >>= 1;
	}
	return ans;
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> s[i].x >> s[i].d;
	sort(s + 1,s + 1 + n,cmp);
	
	suf[n + 1] = 0;
	for(LL i = n;i >= 1;i --){
		mr[i] = i;
		LL L = i,R = n,MID,tmp = i;
		while(L <= R){
			MID = (L + R) >> 1;
			if(s[i].x + s[i].d > s[MID].x){
				tmp = MID;
				L = MID + 1;
			}
			else R = MID - 1;
		}
		mr[i] = max(i,query(1,1,n,i + 1,tmp)); modify(1,1,n,i,i,mr[i]);
		if(mr[i] == n) dp[i] = 1;
		else dp[i] = (suf[mr[i] + 1] + 1) % N;
		suf[i] = (suf[i + 1] + dp[i]) % N;
		ans = (ans + dp[i]) % N;
	}
	ans = (ans + 1LL) % N;
//	for(LL i = 1;i <= n;i ++) cout << dp[i] << (i == n ? '\n' : ' ');
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n+2,0);
    for(int i=1;i<=n;i++){
        cin >> A[i];
    }
    vector<int> D(n+1,0);
    int sum = 0;
    for(int i=0;i<n+1;i++){
        D[i] = abs(A[i+1] - A[i]);
        sum += D[i];
    }
    /*
    for(auto x:D){
        cout << x << " ";
    }
    
    cout << endl;
    */
    //cout << sum << endl;
    for(int i=1;i<=n;i++){
        int ans = sum;
        //cout << "消された" << D[i-1] + D[i] << endl;
        ans -= (D[i-1] + D[i]);
        ans += abs(A[i+1]-A[i-1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n,m,d;

int main(void)
{
    cin >> n >> m >> d;
    
    lin r = 
        ((n - 2 * d) > 0 && d != 0) ? 
        (d + d + (n - 2 * d) * 2) :
        n;

    long double result = (long double)(r * (m - 1)) / (long double)(n * n);

    cout << setprecision(10) << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> al = new ArrayList<String>();

		int cnt = Integer.parseInt(br.readLine());
		int j = 0;
		while (j < cnt) {
			al.add(br.readLine());
			j++;
		}

		for (int i = 0; i < al.size(); i++) {
			double px;
			double py;
			double r;
			String[] buf = al.get(i).split(" ");

			double x1 = Double.parseDouble(buf[0]);
			double y1 = Double.parseDouble(buf[1]);
			double x2 = Double.parseDouble(buf[2]);
			double y2 = Double.parseDouble(buf[3]);
			double x3 = Double.parseDouble(buf[4]);
			double y3 = Double.parseDouble(buf[5]);

			double a = 2 * (x2 - x1);
			double b = 2 * (y2 - y1);
			double c = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
			double d = 2 * (x3 - x1);
			double e = 2 * (y3 - y1);
			double f = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

			BigDecimal bdpx = new BigDecimal(px = (b * f - e * c)
					/ (a * e - d * b));
			BigDecimal bdpy = new BigDecimal(py = (c * d - f * a)
					/ (a * e - d * b));
			BigDecimal bdr = new BigDecimal(Math.sqrt((x1 - px) * (x1 - px)
					+ (y1 - py) * (y1 - py)));

			// px = (b * f - e * c) / (a * e - d * b);
			// py = (c * d - f * a) / (a * e - d * b);
			// r = Math.sqrt((x1 - px) * (x1 - px) + (y1 - py) * (y1 - py));

			px = bdpx.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
			py = bdpy.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
			r = bdr.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
			System.out.printf("%4.3f %4.3f %4.3f\n", px, py, r);
		}
	}
}

Measured memory_bytes: 25016
#include <stdio.h>
#define M 50
int X[M];long long Z[M+1][M*M+1];
int main(){
	int N,A,S=0,i,j,k;
	long long R=0;
	scanf("%d%d",&N,&A);
	for(i=0;i<N;i++)scanf("%d",X+i);
	Z[0][0]=1;
	for(i=0;i<N;i++){
		S+=X[i];
		for(k=i;k>=0;k--)for(j=S;j>=X[i];j--)Z[k+1][j]+=Z[k][j-X[i]];
	}
	for(i=1;i<=N;i++)R+=Z[i][i*A];
	printf("%lld\n",R);
	return 0;
}

Measured memory_bytes: 1152
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;


void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> v(n);
  rep(i,n) cin>>v[i];
  rep(i,n-1) cout<<v[i]<<" ";
  cout<<v[n-1]<<endl;
  repl(i,1,n){
    ll tmp = v[i];
    ll j = i-1;
    while( j >= 0 && v[j] > tmp){
      v[j+1] = v[j];
      j--;
    }
    v[j+1] = tmp;
    rep(i,n-1) cout<<v[i]<<" ";
    cout<<v[n-1]<<endl;
  }

}

int main(){
  solve();
  return 0;
}

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

int main() {
  int N=0, A=0, B=0, C=0;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> A;
    if(A%2==0){
      B = 0;
      while(A%2 == 0){
        A = A/2;
        B++;
      }
    }
    if(i==0){
      C = B;
    }
    else if(C > B){
    C = B;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int h, w, m;

void solve() {
	
	cin >> h >> w >> m;
	
	map<int, int> row, col;
	map<int, map<int,int> > vis;
	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		row[x]++;
		col[y]++;
		vis[x][y] = 1;
	}
	int x = 0, y = 0;
	for (auto r : row)x = max(x, r.second);
	for (auto c : col)y = max(y, c.second);
	VI a, b;
	for (auto r : row) {
		if (r.second == x) {
			a.push_back(r.first);
		}
	}
	for (auto c : col) {
		if (c.second == y) {
			b.push_back(c.first);
		}
	}
	rep(i, 0, sz(a)) {
		rep(j, 0, sz(b)) {
			if (!vis[a[i]].count(b[j])) {
				cout << x + y << endl;
				return;
			}
		}
	}
	cout << x + y - 1 << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 77748
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
int a[300000];

class UnionFind {
public:
	vector<int>par, sz;
public:
	UnionFind() {}
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		par[x]=y;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};
bool C(int t){
	unordered_map<int,int>mp,id,id_rev;
	set<int>se;
	UnionFind uf(n*3);
	int cnt=0;
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1])continue;
		if(!id.count(a[i])){
			id[a[i]]=cnt++;
			id_rev[id[a[i]]]=a[i];
		}
		int d=id_rev[uf.find(id[a[i]])];
		if(d==0||++mp[d]>t)return false;
		if(mp[d]==t){
			if(!id.count(d)){
				id[d]=cnt++;
				id_rev[id[d]]=d;
			}
			if(!id.count(d-1)){
				id[d-1]=cnt++;
				id_rev[id[d-1]]=d-1;
			}
			uf.unite(id[d],id[d-1]);
		}
		se.insert(d);
		auto it=se.lower_bound(d+1);
		while(it!=se.end()){
			mp[*it]=0;
			uf.par[id[*it]]=id[*it];
			it=se.erase(it);
		}
	}
	return true;
}
int main(){
	scanf("%d",&n);
	bool flag=false;
	rep(i,n){
		scanf("%d",&a[i]);
		if(i&&a[i-1]>=a[i])flag=true;
	}
	if(!flag){
		puts("1");return 0;
	}
	int ok=n*2,ng=0;
	while(ok-ng>1){
		int t=(ok+ng)/2;
		if(C(t))ok=t;
		else ng=t;
	}
	cout<<ok+1<<endl;
}

/*
7
1000000000 1000000000 1000000000 1000000000 1000000000 999999999 888888888
*/

Measured memory_bytes: 29376
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		double n,m,d;
		cin >> n >> m >> d;
		double ans;
		if  (d==0) ans = (m-1)/n;
		else ans =(m-1)*(2*(n-d))/(n*n);
		printf("%.12lf",ans);
		return 0;  
}  

/*
               
 

*/


Measured memory_bytes: 3776
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	xSlice := make([]int, m)
	for i := range xSlice {
		fmt.Scan(&xSlice[i])
	}
	sort.Ints(xSlice)

	diffSlice := make([]int, m-1)
	for i := 0; i < len(diffSlice); i++ {
		diffSlice[i] = abs(xSlice[i+1] - xSlice[i])
	}
	sort.Ints(diffSlice)

	ans := 0
	for i := 0; i < len(diffSlice)-n+1; i++ {
		ans += diffSlice[i]
	}
	fmt.Println(ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float fl;
typedef short int si;
using namespace std;
void solve()
{   si a; string b;
    cin >> a >> b;
    if(b.length()<=a) cout << b;
    else cout << b.substr(0,a)<<"...";
}

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


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

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

  int d = 1000;
  for (int i = 0; i <= s.size() - 3; i++) {
    const int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
    d = min(d, abs(753 - x));
  }
  cout << d << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

int H, A[2000000];

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void maxHeapify(int i) {
	int l = left(i);
	int r = right(i);
	int largest = i;
	if (l <= H && A[l] > A[i]) {
		largest = l;
	}
	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {
		int temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(largest);
	}
}

void insert(int key) {
	int i = ++H;
	A[i] = key;
	int p = parent(i);
	while (i > 1 && A[p] < A[i]) {
		int temp = A[p];
		A[p] = A[i];
		A[i] = temp;
		i = p;
		p = parent(i);
	}
}

int heapExtractMax() {
	int max = A[1];
	A[1] = A[H];
	H--;
	maxHeapify(1);

	return max;
}

int main() {
	H = 0;
	string com;
	int k;
	cin >> com;
	while (com != "end") {
		if (com == "insert") {
			cin >> k;
			insert(k);
		}
		if (com == "extract") {
			cout << heapExtractMax() << endl;
		}
		cin >> com;
	}
	return 0;
}

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

using namespace std;

int main(void)
{
    int K;
    string S;

    cin >> K >> S;

    if(S.length() <= K){
        cout << S << endl;
        return 0;
    }

    cout << S.substr(0, K) + "..." << endl;
    return 0;
}

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

const int INF = 1001001001;

int main(){
	int N, mincount = 0, input;
	ll ans = 0, fmin = INF;
	cin >> N;
	vector<int> A(N);
	rep(i, N){
		cin >> input;
		A.at(i) = input;
		if(input < 0){
			mincount++;
		}
		ll in_f = fabs(input);
		fmin = min(fmin, in_f);
		ans += in_f;
	}
	if(mincount % 2 == 1) ans += (-2) * fmin;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main()
{
    string s;
    cin >> s;
    int size=s.size();
    REP(i,(size-1)/2){
        if(s[i]!=s[size-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    REP(i, ((size - 1) / 2)/2){
        if (s[i] != s[(size - 1) / 2-i-1]){
            cout << "No" << endl;
            return 0;
        }
        if (s[size-i-1] != s[size-((size - 1) / 2 - i - 1)-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
    int N = 4;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    sort(A.begin(), A.end());
    cout << abs(A[0] + A[3] - A[1] - A[2]) << '\n';
    return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

vector<vector<int>> edge;
vector<vector<int>> tecomp;
vector<set<int>> nedge;
vector<int> uid, uuid;
vector<int> nw;



void visit(int v, int u,
        stack<int>& roots, stack<int>& S, vector<bool>& inS,
        vector<int>& num, int& tm) {
    num[v] = ++tm;
    S.push(v); inS[v] = true;
    roots.push(v);
    for (int w : edge[v]) {
        if (num[w] == 0)
            visit(w, v, roots, S, inS, num, tm);
        else if (u != w && inS[w])
            while (num[roots.top()] > num[w]) roots.pop();
    }
    if (v == roots.top()) {
        tecomp.push_back(vector<int>());
        while (1) {
            int w = S.top(); S.pop(); inS[w] = false;
            tecomp.back().push_back(w);
            if (v == w) break;
        }
        roots.pop();
    }
}


bool dfs(int now, int par, int zero) {
    bool ret = tecomp[now].size() > 1;
    for (int i : nedge[now]) {
        if (i == par) continue;
        ret |= dfs(i, now, zero);
    }
    if (ret) {
        uuid[now] = zero;
    }
    return ret;
}
int dfs(int now, int par) {
    int ret = 0;
    for (int i : nedge[now]) {
        if (i == par) continue;
        ret = max(ret, dfs(i, now));
    }
    return ret + nw[now];
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    edge.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> num(n, 0);
    vector<bool> inS(n);
    stack<int> roots, S;
    int tm = 0;
    for (int u = 0; u < n; ++u)
        if (num[u] == 0)
            visit(u, n, roots, S, inS, num, tm);

    int nn = tecomp.size();
    uid.resize(n);
    for (int i = 0; i < nn; ++i) {
        for (int j : tecomp[i])
            uid[j] = i;
    }
    int zero = uid[0];
    nedge.resize(nn);
    for (int i = 0; i < n; ++i) {
        for (int j : edge[i]) {
            if (uid[i] != uid[j])
                nedge[uid[i]].insert(uid[j]);
        }
    }
    uuid.resize(n);
    for (int i = 0; i < n; ++i) {
        uuid[i] = i;
    }
    dfs(zero, -1, zero);
    nw.resize(nn, 0);
    for (int i = 0; i < n; ++i) {
        nw[uuid[uid[i]]] += w[i];
    }
    vector<int> useduid(nn, 0);
    vector<int> used(nn, 0);
    int ma = 0;
    for (int i = 0; i < n; ++i) {
        if (!useduid[uid[i]] && uuid[uid[i]] == zero) {
            useduid[uid[i]] = 1;
            for (int j : nedge[uid[i]]) {
                if (uuid[j] != zero && !used[j]) {
                    used[j] = 1;
                    ma = max(ma, dfs(j, uid[i]));
                }
            }
        }
    }
    cout << (nw[zero] + ma) << "\n";
    return 0;
}

Measured memory_bytes: 42948
import java.util.*; 
import java.io.*;

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int arr[] = new int[100003];  
	    for(int i =0;i<n; i++) {
	    	int x = in.readInt(); 
	    	if(x != 0) {
	    		arr[x-1]++; 
	    	}
	    		arr[x]++; 
	    		arr[x+1]++; 
	    }
	    int min = 0; 
	    for(int i : arr) {
	    	min = Math.max(i, min); 
	    }
	    System.out.println(min); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21716
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll a,b;
    cin>>a>>b;
    ll aa,bb;
    for(ll i=0;i<10000;i++){
        aa=(i*8)/100;
        bb=(i*10)/100;
        if(aa==a && bb==b){
            cout<<i<<"\n";
            return;
        }
    }
    cout<<"-1\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    a--, b--;
    int g[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};

    if(g[a] == g[b]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
%:pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

const int N = 111;

#define int long long

char s[N];

int n;

map <pair <vector <int>, vector <int> > , int> Map[2];

main(void) {
	cin >> n;
	scanf("%s", s);
	n = strlen(s);
	n /= 2;
	int ans = 0;
	vector <int> A, B, C, D;
	int tot = 0;
	for(int i = 0; i < (1 << n); ++ i) {
		A.clear(); B.clear(); C.clear(); D.clear();
		for(register char j = 0; j < n; ++ j) {
			++ tot;
			if((i >> j) & 1) {
				A.push_back(s[j]);
				C.push_back(s[j + n]);
			}
			else {
				B.push_back(s[j]);
				D.push_back(s[j + n]);
			}
		}
		reverse(C.begin(), C.end());
		reverse(D.begin(), D.end());
		++ Map[0][make_pair(A, B)];
		ans += Map[1][make_pair(A, B)];
		++ Map[1][make_pair(C, D)];
		ans += Map[0][make_pair(C, D)];
	}
	cout << ans << endl;
}

Measured memory_bytes: 270592
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int x,y; cin>>x>>y;
  int cnt = 0;
  // int a=abs(x), b=abs(y);
  // if(x==0&&y<0) return cout<<abs(y)+1<<endl,0;
  // if(x*y>=0){
  //   if(a-b>=0^(x>=0&&y>=0)) cnt=abs(a-b);
  //   else cnt=abs(a-b)+2;
  // }else{
  //   cnt = abs(a-b)+1;
  // }
  int cnt0=INF,cnt1=INF,cnt2=INF,cnt3=INF;
  if(x<=y) cnt0 = y-x;
  if(-x<=y) cnt1 = y+x+1;
  if(x<=-y) cnt2 = -y-x+1;
  if(-x<=-y) cnt3 = -y+x+2;
  cnt = min(cnt0,min(cnt1,min(cnt2,cnt3)));
  cout << cnt << endl;

  return 0;
}


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

int main() {
	long long a, b, c, d, n, x, m;
	cin >> n;
	if(n > 999){
		cout << "ABD"<< endl;
	}else{
		cout << "ABC" <<endl;
	}
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
void solve() {
    string s;
    cin>>s;
    int n;
    cin>>n;
    bool isReversed = false;
    while(n--) {
        int x;
        cin>>x;
        if(x==1) isReversed ? isReversed = false : isReversed = true;
        else {
            int f;
            string c;
            cin>>f>>c;
            if(f==1) isReversed ? s+=c : s.insert(0, c);
            else isReversed ? s.insert(0, c) : s+=c;
        }
    }
    if(isReversed) {
        for(int i=s.size()-1; i>=0; --i) cout<<s[i];
        cout<<"\n";
    } else cout<<s<<"\n";
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

Measured memory_bytes: 912
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
int main()
{
	string a, b, c;

	cin >> a >> b >> c;

	if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
use std::io;

/// 線形探索による調査
fn search_same(target: &Vec<u64>, src: &Vec<u64>) -> u32 {
    let mut cnt = 0;
    for v in src {
        for t in target {
            if v == t {
                cnt += 1;
                break;   // 同じsrcに対して複数カウントはしない
            }
        }
    }
    cnt
}

fn main() {
    let sin = io::stdin();
    
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let _n: usize = buf.trim().parse().unwrap();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let s = buf.split_whitespace()
        .map(|v| v.parse::<u64>().unwrap())
        .collect::<Vec<u64>>();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let _q: usize = buf.trim().parse().unwrap();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let t = buf.split_whitespace()
        .map(|v| v.parse::<u64>().unwrap())
        .collect::<Vec<u64>>();

    println!("{}", search_same(&s, &t));
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){

    double x;cin>>x;
    double ans= (x/3)*(x/3)*(x/3);
    printf("%0.10lf",ans);
 
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[--x]++;
  }
  sort(a.begin(), a.end());
  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  for (int k = 1; k <= n; k++) {
    int lo = 0, hi = n + 1;
    while (hi - lo > 1) {
      int mid = (lo + hi) >> 1;
      int ltm = upper_bound(a.begin(), a.end(), mid) - a.begin();
      long long tot = sum[ltm] + 1LL * (n - ltm) * mid;
      if (tot >= 1LL * mid * k) lo = mid;
      else hi = mid;
    }
    cout << lo << '\n';
  }
  return 0;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int n,m;cin>>n>>m;
	cout<<n*m<<endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 2017

int n, Z, W, i, j;
int a[maxN];
int dp[maxN][2];

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n >> Z >> W;
    a[0] = W;
    for (i = 1; i <= n; i++) cin >> a[i];

    for (i = n - 1; i >= 0; i--) {
        //! compute for 0
        dp[i][0] = abs(a[i] - a[n]);
        for (j = i + 1; j < n; j++)
            dp[i][0] = min(dp[i][0], dp[j][1]);

        //! compute for 1
        dp[i][1] = abs(a[i] - a[n]);
        for (j = i + 1; j < n; j++)
            dp[i][1] = max(dp[i][1], dp[j][0]);
    }

    cout << dp[0][1];

    return 0;
}


Measured memory_bytes: 256
import glob
import os
import numpy as np

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:
    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index - 1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        H, W, M = map(int, self.input_data().split())
        B = [None for i in range(M)]

        ver_num =[0 for i in range(W+1)] # 列ごとの合計(行分ある)
        hol_num = [0 for i in range(H+1)] # 行ごとの合計(列分ある)

        for i in range(M):
            B[i] = list(map(int, self.input_data().split()))
            ver_num[B[i][1]] +=1
            hol_num[B[i][0]] +=1

        ver_max = np.max(np.array(ver_num))
        hol_max = np.max(np.array(hol_num))

        max_columns = []
        max_rows = []

        for i in range(1,W+1):
            if ver_max == ver_num[i]:
                max_columns.append(i)
        for i in range(1,H+1):
            if hol_max == hol_num[i]:
                max_rows.append(i)

        b_cross = 0
        for b in B:
            if ver_num[b[1]] == ver_max and hol_num[b[0]] == hol_max:
                b_cross += 1
        if b_cross == len(max_columns) * len(max_rows):
            result = ver_max + hol_max - 1
        else:
            result = ver_max + hol_max
        print(str(result))

solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 111340
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,x,t;
    cin >> n >> x >> t;

    cout << (n+x-1)/x * t << endl;
}

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

int main(){
    int n, a, b;
    ll k, cnt = 0;
    cin >> n >> k;
    map<int, ll> mp;
    rep(i, n){
        cin >> a >> b;
        mp[a] += b;
    }
    for(auto x : mp){
        cnt += x.second;
        if(k <= cnt){
            cout << x.first << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
int main()
{
  int W,H,n,i,count=0,gyougae=0;
  while(1)
  {
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    for(i=1;i<=H;i++)
    {
      gyougae++;
      if(gyougae%2!=0)
      {
        for(n=1;n<=W;n++)
        {
          count++;
          if(count%2!=0)printf("#");
          else printf(".");
        }
        count=0;
      }

      else
      {
        for(n=1;n<=W;n++)
        {
          count++;
          if(count%2!=0)printf(".");
          else printf("#");
        }
        count=0;
      }
      printf("\n");
    }
    gyougae=0;
    printf("\n");
  }
  return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N; cin >> N;
    ll H[100001];
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    ll cnt = 0;
    for (int i = 0; i < N-1; i++) {
        if(H[i] > H[i+1]){
            cnt++;
            if(abs(H[i]-H[i+1]) > 1){
                cout << "No" << endl;
                exit(0);
            }
            if(cnt > 1){
                cout << "No" << endl;
                exit(0);
            }
        } else if(H[i] < H[i+1]) {
            cnt = 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 4308
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB = sorted(AB, key=lambda x: x[0])

    for i in range(n):
        a, b = AB[i]
        if b < k:
            k -= b
        else:
            print(a)
            break


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29912
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;
#define EPS 1e-10

struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x=_x; y=_y;
    }
    Point operator +(const Point p)const{
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point p)const{
        return Point(x-p.x,y-p.y);
    }
	Point operator *(const double d)const{
		return Point(x*d,y*d);
	}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point _a,Point _b){
        a=_a; b=_b;
    }
};

double dot(Point p,Point q){
    return p.x*q.x+p.y*q.y;
}

double cross(Point p,Point q){
    return p.x*q.y-q.x*p.y;
}

int ccw(Point a,Point b,Point c){
    if(cross(b-a,c-b)>0) return +1;
    if(cross(b-a,c-b)<0) return -1;
    return 0;
}

bool intersection(Line l,Line m,Point &p){
	Point a1,a2,b1,b2;
	a1 = l.b-l.a; a2 = m.b-m.a;
	b1 = m.a-l.a; b2 = m.b-l.a;
	double s1,s2;
	s1 = abs(cross(a1,b1)); s2 = abs(cross(a1,b2));
	if(s1<EPS && s2<EPS) return false;
	if(s1<EPS) swap(s1,s2);
	p = Point(m.a.x+a2.x*s1/(s1+s2),m.a.y+a2.y*s1/(s1+s2));
}

int main(){
	Point p[4];
	while(true){
		for(int i=0;i<4;i++){
			if(scanf("%lf,%lf,",&p[i].x,&p[i].y)==EOF) return 0;
		}
		int w=0;
		bool ans=true;
		for(int i=0;i<4;i++){
			int w_ = ccw(p[i],p[(i+1)%4],p[(i+2)%4]);
			if(w*w_<0) ans = false;
			w = w_;
		}
		if(ans==true) puts("YES");
		else puts("NO");
	}
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n,m,x,ch[13][13],co[13];
bool bu[13];ll ans=INF;
void cal(){
	ll sum[13]={};
	ll sum1=0;
	for(ll i=0;i<n;i++){
		if(bu[i]==true){
			sum1+=co[i];
			for(ll j=0;j<m;j++){
				sum[j]+=ch[i][j];
			}
		}
	}
	for(ll i=0;i<m;i++){
		if(sum[i]<x){
			return ;
		}
	}
	ans=min(ans,sum1);
}
void dep(ll now){
	if(now==n){
		cal();
		return ;
	}
	bu[now]=0;dep(now+1);
	bu[now]=1;dep(now+1);
}
int main() {
	cin>>n>>m>>x;
	for(ll i=0;i<n;i++){
		cin>>co[i];
		for(ll j=0;j<m;j++){
			cin>>ch[i][j];
		}
	}
	dep(0);
	if(ans==INF){
		cout << -1;
	}
	else{
	cout <<ans;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#define SIZ 1400
int m[SIZ+1][SIZ];
long long st[SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,ptr,h;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	for(r=i=0;i<x;i++)for(ptr=j=0;j<=y;j++){
		int left=j;
		for(;ptr && (h=st[ptr-1]>>32)>m[j][i];){
			int l=st[--ptr]&0xffffffff,hh=h;
			if(hh>j-l)hh=j-l;
			if(r<hh*hh)r=hh*hh;
			left=l;
		}
		st[ptr++]=((long long)m[j][i]<<32)|left;
	}

	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 13836
S = input()
SL = [x for x in S]

ok = S[0] == "A"
SL[0] = "a"

ok = ok and (S[2:-1].count("C") == 1)
cpos = S[2:-1].find("C")

if cpos != -1:
    SL[2+cpos] = "c"

for c in SL:
    ok = ok and not c.isupper()

if ok:
    print("AC")
else:
    print("WA")


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

#define fs first
#define sc second

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; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

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


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    int ans = (b-1) / (a-1) + ((b-1) % (a-1) != 0);

    cout << ans << endl;

    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (((a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) ||
            (a == 5 && b == 5 && c == 7))
               ? "YES"
               : "NO")
       << endl;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
from itertools import combinations_with_replacement
l = [i for i in range(1, M+1)]
lis = list(combinations_with_replacement(l, N))

for l in lis:
    tmp = 0
    for j in range(Q):
        a, b, c, d = abcd[j]
        if l[b-1]-l[a-1]==c:
            tmp+=d
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 84776
#include <stdio.h>
#include <math.h>

int main(){
    int A[100][100];
    int b[100];
    int c[100];

    int m, n;
    scanf("%d %d", &m, &n);

    int tmp;
    for(int i=0;i<m;i++){
        c[i] = 0;
        for(int j=0;j<n;j++){
            scanf("%d", &tmp);
            A[i][j] = tmp;
        }
    }

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

    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            c[i] = c[i] + A[i][j] * b[j];
        }
    }

    for(int i=0;i<m;i++){
        printf("%d\n", c[i]);
    }

    return 0;
}


Measured memory_bytes: 2044
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

n,m = MI()
x,y = LI(),LI()
mod = 10**9+7

n,m = n-1,m-1
dx = [x[i+1]-x[i] for i in range(n)]
dy = [y[i+1]-y[i] for i in range(m)]

if n % 2 == 0:
    rx = [i*(n+1-i) for i in range(1,n//2+1)] + [i*(n+1-i) for i in range(n//2,0,-1)]
else:
    rx = [i*(n+1-i) for i in range(1,n//2+2)] + [i*(n+1-i) for i in range(n//2,0,-1)]
if m % 2 == 0:
    ry = [i*(m+1-i) for i in range(1,m//2+1)] + [i*(m+1-i) for i in range(m//2,0,-1)]
else:
    ry = [i*(m+1-i) for i in range(1,m//2+2)] + [i*(m+1-i) for i in range(m//2,0,-1)]

a = 0
for i,j in zip(dx,rx):
    a += i*j
    a %= mod
b = 0
for i,j in zip(dy,ry):
    b += i*j
    b %= mod

print((a*b) % mod)


Measured memory_bytes: 113628
#include <stdio.h>

int main() {
	int width = 0, height = 0;
	int x = 0, y = 0, r = 0;
	
	scanf("%d %d %d %d %d", &width, &height, &x, &y, &r);
	
	if (x + r <= width) {
		if (x - r >=0) {
			if (y + r <= height) {
				if (y - r >= 0) {
					printf("Yes\n");
					
					return 0;
				}
			}
		}
	}
	
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 584