akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

    if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n)
{
    ll ans = 1 ;
    for(ll i = 1 ; i <= n ; ++i)
        ans *= i ;
    return ans ;
}
unsigned long long Factorial(int n)
{
    const unsigned int M = 1000000007;
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;

    return f;
}
int arr[ N ];
int main()
{
    FastInputOutput() ;
    int m ;
    cin >> m ;
    int x = 24 - m ;
    cout << 2 * x + m << endl ;


}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

void printv(vector<auto> const& s) {
  REP(i, s.size()) {
    cout << s[i] << endl;
  }
}

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

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

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }

  ll ans = 0;
  REP(i, n) {
    ans += a[i] - 1;
  }

  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 65636
#define MAXM 20
#define MOD 1000000007
using namespace std;
long long dp[2][MAXN],q[MAXN],p[MAXN];
int a[MAXM],n,m;
bool cmp(int x,int y){
	return x>y;
}
long long fsp(long long x,int y){
	long long res=1;
	while(y){
		if(y&1)
			res=(res*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return res;
}
long long C(int x,int y){
	if(x<y)
		return 0;
	return ((q[x]*p[y])%MOD*p[x-y])%MOD;
}
int count(int x){
	int res=0;
	while(x){
		if(x&1)
			res++;
		x>>=1;
	}
	return res%2;
}
int main(){
	SF("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		SF("%d",&a[i]);
	q[0]=1;
	for(int i=1;i<(1<<n);i++)
		q[i]=(1ll*q[i-1]*i)%MOD;
	p[(1<<n)-1]=fsp(q[(1<<n)-1],MOD-2);
	for(int i=(1<<n)-1;i>=1;i--)
		p[i-1]=(1ll*p[i]*i)%MOD;
	sort(a+1,a+1+m,cmp);
	int now=0;
	dp[now][0]=1;
	for(int i=1;i<=m;i++){
		now^=1;
		for(int j=0;j<(1<<n);j++){
			if(dp[now^1][j]==0)
				continue;
			dp[now][j]=(dp[now][j]+dp[now^1][j])%MOD;
			int les=(1<<n)-1-j;
			for(int k=0;k<n;k++)
				if((j&(1<<k))==0){
					dp[now][j|(1<<k)]+=((C(les-a[i]+1,(1<<k)-1)*dp[now^1][j])%MOD*q[1<<k])%MOD;
					dp[now][j|(1<<k)]%=MOD;
				}
		}
		memset(dp[now^1],0,sizeof dp[now^1]);
	}
	long long ans=0;
	for(int i=0;i<(1<<n);i++){
		if(dp[now][i]==0)
			continue;
		dp[now][i]=(dp[now][i]*q[(1<<n)-1-i])%MOD;
		if(count(i)==0)
			ans+=dp[now][i];
		else
			ans-=dp[now][i];
		ans%=MOD;
	}
	ans<<=n;
	ans%=MOD;
	PF("%lld",(ans+MOD)%MOD);
} 

Measured memory_bytes: 2304
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1144();
	}
	
	class AOJ1144{
		AOJ1144(){
			while(sc.hasNext()){
				w=sc.nextInt();
				h=sc.nextInt();
				if((w|h)==0)	break;
				solve(w,h);
			}
		}
		final int INF=Integer.MAX_VALUE/4;
		final int[] vx={0,1,0,-1},vy={-1,0,1,0};
		int w,h;
		int sx,sy,ex,ey;
		void solve(int w,int h){
			boolean[][] b=new boolean[w][h];
			sx=0;	sy=0;	ex=0;	ey=0;
			for(int y=0; y<h; ++y)for(int x=0; x<w; ++x){
				int tmp=sc.nextInt();
				b[x][y]=(tmp!=1);
				if(tmp==2){
					sx=x;	sy=y;
				}else if(tmp==3){
					ex=x;	ey=y;
				}
			}
			
			int ans=-1;
			for(int cnt=0; cnt<=10; ++cnt){
				boolean[][] bc=new boolean[w][h];
				for(int x=0; x<w; ++x)for(int y=0; y<h; ++y)	bc[x][y]=b[x][y];
				int ret=DFS(sx,sy,0,cnt,bc);
				if(ret<INF){
					ans=ret;
					break;
				}
			}
			System.out.println(ans);
		}
		int DFS(int x,int y,int depth,int limit,boolean[][] b){
//			System.out.println(x+" "+y+" "+depth+" "+limit);
			if(depth>=limit)	return INF;
			if(x==ex&&y==ey)	return depth;
			
			int ret=INF;
			for(int v=0; v<4; ++v){
				int xx=x+vx[v],yy=y+vy[v];
				if(!(0<=xx&&xx<w && 0<=yy&&yy<h))	continue;
				if(!b[xx][yy])	continue;
				if(xx==ex&&yy==ey){
					ret=min(ret,depth+1);
					continue;
				}
				while(true){
					xx+=vx[v];
					yy+=vy[v];
					if(!(0<=xx&&xx<w && 0<=yy&&yy<h))	break;
					if(xx==ex&&yy==ey){
						ret=min(ret,depth+1);
						break;
					}
					if(!b[xx][yy]){
						xx-=vx[v];
						yy-=vy[v];
						b[xx+vx[v]][yy+vy[v]]=true;
						ret=min(ret, DFS(xx,yy,depth+1,limit,b));
						b[xx+vx[v]][yy+vy[v]]=false;
						break;
					}
				}
			}
			return ret;
			
		}
	}

}

Measured memory_bytes: 36632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    string a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);

    cout << a << ' ' << b << ' ' << c << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

//　if文
// if (num == 0)
// {
//     cout << "0";
// }
// else if (num == 1)
// {
//     cout << "1"; // 1が表示される
// }
// else
// {
//     cout << "01以外";
// }

Measured memory_bytes: 256
# 8 Puzzle
import copy
[N, d] = [3, 0]
start = []
goal = [[i + j*N for i in range(1, N + 1)] for j in range(N)]
goal[2][2] = 0
for i in range(N):
    start.append(list(map(int, input().split())))


def manhattan(value, pairs):
    h = 0

    if value == 1:
        h = (pairs[0] + pairs[1])
    if value == 2:
        h = (pairs[0] + abs(pairs[1] - 1))
    if value == 3:
        h = (pairs[0] + abs(pairs[1] - 2))
    
    if value == 4:
        h = (abs(pairs[0] - 1) + pairs[1])
    if value == 5:
        h = (abs(pairs[0] - 1) + abs(pairs[1] - 1)) 
    if value == 6:
        h = (abs(pairs[0] - 1) + abs(pairs[1] - 2))
        
    if value == 7:
        h = (abs(pairs[0] - 2) + pairs[1])      
    if value == 8:
        h = (abs(pairs[0] - 2) + abs(pairs[1] - 1))
        
    return h

s_h = 0
for i in range(N):
    for j in range(N):
        s_h += manhattan(start[i][j], [i, j])

for i in range(N):
        check = start[i].count(0)
        if check != 0:
            [s_r, s_c] = [i, start[i].index(0)]
            break
        if i == 3:
            print("Error")

while True:
    d += 1
    flag = 0
    queue = [[s_h, start, 0, [s_r, s_c], flag]]
    
    while len(queue) != 0:
        short_n = queue.pop(0)
        h = short_n[0] - short_n[2]
        state = short_n[1]
        g = short_n[2]
        [r, c] = short_n[3]
        flag = short_n[4]
        
        if h == 0:
            print(short_n[2])
            break
       
        if r - 1 >= 0 and flag != 3:
            temp = copy.deepcopy(state)
            h = short_n[0] - short_n[2] - manhattan(temp[r - 1][c], [r - 1, c]) + manhattan(temp[r - 1][c], [r, c])
            [temp[r][c], temp[r - 1][c]] = [temp[r - 1][c], temp[r][c]]
            if g + 1 + h <= d:
                queue.append([h + g + 1, temp, g + 1, [r - 1, c], 1])
        
        if c + 1 < N and flag != 4:
            temp = copy.deepcopy(state)
            h = short_n[0] - short_n[2] - manhattan(temp[r][c + 1], [r, c + 1]) + manhattan(temp[r][c + 1], [r, c])
            [temp[r][c], temp[r][c + 1]] = [temp[r][c + 1], temp[r][c]]
            if g + 1 + h <= d:
                queue.append([h + g + 1, temp, g + 1, [r, c + 1], 2])

        if r + 1 < N and flag != 1:
            temp = copy.deepcopy(state)
            h = short_n[0] - short_n[2] - manhattan(temp[r + 1][c], [r + 1, c]) + manhattan(temp[r + 1][c], [r, c])
            [temp[r][c], temp[r + 1][c]] = [temp[r + 1][c], temp[r][c]]
            if g + 1 + h <= d:
                queue.append([h + g + 1, temp, g + 1, [r + 1, c], 3])
        
        if c - 1 >= 0 and flag != 2:
            temp = copy.deepcopy(state)
            h = short_n[0] - short_n[2] - manhattan(temp[r][c - 1], [r, c - 1]) + manhattan(temp[r][c - 1], [r, c])
            [temp[r][c], temp[r][c - 1]] = [temp[r][c - 1], temp[r][c]]
            if g + 1 + h <= d:
                queue.append([h + g + 1, temp, g + 1, [r, c - 1], 4])
                
        queue.sort(key = lambda data:data[0])
        queue.sort(key = lambda data:data[2], reverse = True)

        data = []
        g_data = []

    if state == goal:
        break


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

int x[3][500];
signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    rep(i, 1, 3)
    {
        rep(j, 1, n + 1)
        {
            int a;
            cin >> a;
            x[i][j] = a + max(x[i - 1][j], x[i][j - 1]);
        }
    }

    cout << x[2][n] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=2e5;
int n,m;
ll k,a[mxN+2]={0},b[mxN+2]={0};
int main()
{
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i+1];
        b[i+1]+=b[i];
    }
    int ans=0;
    for(int i=0,j=m;i<=n;i++)
    {
        if(a[i]>k)break;
        while(a[i]+b[j]>k)j--;
        ans=max(ans,i+j);
    }
    cout<<ans;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  for (int n = 0; n < 2000; n++) {
    int A = n*8/100;
    int B = n*10/100;
    if (a == A && b == B) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.text.ParseException;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	static int a;
	static int b;
	static int q;
	static long[] s;
	static long[] t;
	static long INF = (long) Math.pow(10, 18);

	public static void main(String[] args) throws ParseException {
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();
		q = sc.nextInt();
		s = new long[a + 2];
		t = new long[b + 2];

		s[0] = -INF;
		s[a + 1] = INF;
		t[0] = -INF;
		t[b + 1] = INF;


		for (int i = 1; i < a + 1; i++) {
			s[i] = sc.nextLong();
		}

		for (int i = 1; i < b + 1; i++) {
			t[i] = sc.nextLong();
		}


		for (int i = 0; i < q; i++) {
			long res = INF;
			long n = sc.nextLong();

			int b = Arrays.binarySearch(s, n);
			int d = Arrays.binarySearch(t, n);

			long[] sAry = { s[~b - 1], s[~b] };
			long[] tAry = { t[~d - 1], t[~d] };

			for (long S : sAry) {
				for (long T : tAry) {
					long d1 = Math.abs(S - n) + Math.abs(T - S);
					long d2 = Math.abs(S - T) + Math.abs(T - n);

					res = Math.min(res, Math.min(d1, d2));
				}
			}
			System.out.println(res);
		}

		sc.close();
	}

}


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

int main(){
  int X, A, B;
  cin >> X >> A >> B;

  int eat;
  eat = B - A;
  if(eat <= 0){
    cout << "delicious" << endl;
  } else if(eat <= X){
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}


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

using namespace std;


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

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

	int S = a[0];
	for (int i = 1; i < N; i++) {
		S = S ^ a[i];
	}
	for (int i = 0; i < N; i++) {
		cout << (S ^ a[i]) << " ";
	}
	cout << endl;
}


Measured memory_bytes: 4360
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    string s;
    cin >> s;
    s += "##";
    
    vector<int> memo(s.size() - 2, -1);
    ll ans = 0;
    per(i, s.size() - 2) {
        if (s[i] != 'A') continue;
        memo[i] = 0;
        int now = i + 1;
        while (true) {
            if (s[now] == 'A') {
                memo[i] += memo[now];
                break;
            }
            if (s[now] != 'B') break;
            ++now;
            if (s[now] != 'C') break;
            ++now;
            ++memo[i];
        }
        ans += memo[i];
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 4416
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

from heapq import *

def solve():
    dist = [inf] * n
    cnt = [0] * n
    hp = []
    heappush(hp, (0, s))
    dist[s] = 0
    cnt[s] = 1
    while hp:
        d, u = heappop(hp)
        if d > dist[t]: break
        if d > dist[u]: continue
        for v, c in to[u]:
            nd = d + c
            if nd == dist[v]: cnt[v] += cnt[u]
            elif nd < dist[v]:
                dist[v] = nd
                cnt[v] = cnt[u]
                heappush(hp, (nd, v))

    distr = [inf] * n
    cntr = [0] * n
    hp = []
    heappush(hp, (0, t))
    distr[t] = 0
    cntr[t] = 1
    while hp:
        d, u = heappop(hp)
        #print(d,u,hp,distr,cntr)
        if d * 2 > dist[t]: continue
        if d > distr[u]: continue
        for v, c in to[u]:
            nd = d + c
            if nd == distr[v]: cntr[v] += cntr[u]
            elif nd < distr[v]:
                distr[v] = nd
                cntr[v] = cntr[u]
                heappush(hp, (nd, v))

    ans = pow(cnt[t], 2, md)
    dt = dist[t]
    for u in range(n):
        if dist[u] * 2 == dt:
            ans -= (cnt[u] * cntr[u])**2
            ans %= md
    for u, v, c in uvd:
        for _ in range(2):
            if dist[u] + distr[v] + c == dt and dist[u] * 2 < dt and distr[v] * 2 < dt:
                ans -= (cnt[u] * cntr[v])**2
                ans %= md
            u, v = v, u
    print(ans)

md = 10 ** 9 + 7
inf = 10 ** 16
n, m = MI()
s, t = MI1()
to = [[] for _ in range(n)]
uvd = []
for _ in range(m):
    u, v, d = MI()
    to[u - 1].append((v - 1, d))
    to[v - 1].append((u - 1, d))
    uvd.append((u - 1, v - 1, d))

solve()


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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n,m,c;
  cin >>n>>m>>c;
  int b[m];
  int a[n][m];
  for(int i=0; i<m ; i++){
    cin >> b[i];
  }
  for(int i =0 ; i<n ; i++){
    for(int j =0; j<m; j++){
      cin>>a[i][j];
    }
  }
  
  int ans =0;
  int wa=c;
  for(int i =0 ; i<n ; i++){
    for(int j =0; j<m; j++){
      wa += a[i][j]*b[j];
      
    }
    if(wa >0){
      ans ++;
    }
    wa =c;
  }

  cout <<ans <<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 21000;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct TwoSat {
    int N;
    vector<vi> gr;
    vi values; // 0 = false, 1 = true
 
    TwoSat(int n = 0) : N(n), gr(2*n) {}
 
    int add_var() { // (optional)
        gr.emplace_back();
        gr.emplace_back();
        return N++;
    }
 
    void either(int f, int j) {
        f = max(2*f, -1-2*f);
        j = max(2*j, -1-2*j);
        gr[f^1].push_back(j);
        gr[j^1].push_back(f);
    }
    void set_value(int x) { either(x, x); }
 
    void at_most_one(const vi& li) { // (optional)
        if (sz(li) <= 1) return;
        int cur = ~li[0];
        rep(i,2,sz(li)) {
            int next = add_var();
            either(cur, ~li[i]);
            either(cur, next);
            either(~li[i], next);
            cur = ~next;
        }
        either(cur, ~li[1]);
    }
 
    vi val, comp, z; int time = 0;
    int dfs(int i) {
        int low = val[i] = ++time, x; z.push_back(i);
        trav(e, gr[i]) if (!comp[e])
            low = min(low, val[e] ?: dfs(e));
        ++time;
        if (low == val[i]) do {
            x = z.back(); z.pop_back();
            comp[x] = time;
            if (values[x>>1] == -1)
                values[x>>1] = !(x&1);
        } while (x != i);
        return val[i] = low;
    }
 
    bool solve() {
        values.assign(N, -1);
        val.assign(2*N, 0); comp = val;
        rep(i,0,2*N) if (!comp[i]) dfs(i);
        rep(i,0,N) if (comp[2*i] == comp[2*i+1]) return 0;
        return 1;
    }
};

int N;
pair <int, int> pp[MAXN];

bool works (int d)
{
    TwoSat sat(3*N);
    for (int i = 0; i < 2 * N; i++)
    {
        int cv = pp[i].second;
        sat.either(cv, ~(i+N));
        if (i > 0 && pp[i-1].first / d == pp[i].first / d)
        {
            sat.either(i-1+N, ~(i+N));
            sat.either(i-1+N, cv);
        }
    }

    int hi = 2 * N - 1;
    for (int i = 2 * N - 1; i >= 0; i--)
    {
        int cv = pp[i].second;
        while (hi > i && pp[hi].first >= pp[i].first + d)
            hi--;
        if (pp[hi].first / d > pp[i].first / d)
        {
            sat.either(hi+N, cv);
        }
    }
    return sat.solve();
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        pp[2*i] = make_pair (x, ~i);
        pp[2*i+1] = make_pair (y, i);
    }

    sort (pp, pp + 2 * N);
    int lo = 0, hi = 1e9;
    while (lo < hi)
    {
        int mid = (lo + hi + 1) / 2;
        if (works (mid))
            lo = mid;
        else
            hi = mid - 1;
    }
    cout << lo << "\n";
}

Measured memory_bytes: 6816
from collections import Counter
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()

N, Q = tuple(li())
S = ns()
ops = []
for i in range(Q):
    ops.append(tuple(ls()))

head, tail = 0, N-1
while(ops):
    cur = ops.pop()
    if cur[1] == 'L' and head <N:
        if S[head] == cur[0]:
            head += 1
        if tail <= N-2 and S[tail + 1] == cur[0]:
            tail = min(tail + 1, N-1)
    elif cur[1] == 'R' and tail >= 0:
        if S[tail] == cur[0]:
            tail -= 1
        if head >= 1 and S[head - 1] == cur[0]:
            head = max(0, head-1)
alive = tail - head + 1
# print("tail:{}, head:{}".format(tail, head))
print(max(alive, 0))


Measured memory_bytes: 18100
n = int(input())
a = list(map(int, input().split()))
d = {'gray': 0, 'green': 0, 'cyan': 0, 'red': 0, 'brown': 0, 'blue': 0, 'yellow': 0, 'orange': 0, 'above':0}
for i in a:
    if i <= 399:
        d['gray'] += 1
    elif i <=799:
        d['brown'] += 1
    elif i <= 1199:
        d['green'] += 1
    elif i <= 1599:
        d['cyan'] += 1
    elif i <= 1999:
        d['blue'] += 1
    elif i <= 2399:
        d['yellow'] += 1
    elif i <= 2799:
        d['orange'] += 1
    elif i <= 3199:
        d['red'] += 1
    else:
        d['above'] += 1
res1 = 0
res2 = 0
for i in d.items():
    if i[0] != 'above' and i[1] > 0:
        res1 += 1
        res2 += 1
print(max(1, res1), res2 + d['above'])

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

using namespace std;
const int maxn = 110;

int n, b[maxn];
vector<int> ans;

bool remove(int x) {
    if(b[x] == x) {
        ans.push_back(x);
        for (int i = x; i < n; ++i)
            b[i] = b[i+1];
        b[n] = 0;
        --n;
        return 1;
    }
    return 0;
}

int main() {
    int mx = -1;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", b + i);
        mx = max(mx, b[i]);
    }
    while(1) {
        bool fg = false;
        for (int i = mx; i >= 1; --i) {
            if(remove(i)) {
                fg = 1;
                break;
            }
        }
        if(n == 0) break;
        if(!fg) return puts("-1"), 0;
    }
    reverse(ans.begin(), ans.end());
    for (auto v: ans)
        printf("%d\n", v);
    return 0;
}


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

using namespace std;


int DoStuff(string a, string b) {
    int n = b.size();

    int ans = 1e9;
    for (int diff = 0; diff < n; ++diff) {
        vector<int> left(n, 0), right(n, 0);

        // Build left
        if (b[0] != '1') {
            left[0] = 1;
            int pos = n - 1;
            while (b[pos] != '1') {
                --pos;
                ++left[0];
            }
        }
        for (int i = 1; i < n; ++i) {
            if (b[i] == '1')
                left[i] = 0;
            else left[i] = 1 + left[i - 1];
        }

        // Build right
        if (b[n - 1] != '1') {
            right[n - 1] = 1;
            int pos = 0;
            while (b[pos] != '1') {
                ++pos;
                ++right[n - 1];
            }
        }
        for (int i = n - 2; i >= 0; --i) {
            if (b[i] == '1')
                right[i] = 0;
            else right[i] = 1 + right[i + 1];
        }
/*
        cerr << a << " " << b << endl;
        for (auto x : left) cerr << x << " "; cerr << endl;
        for (auto x : right) cerr << x << " "; cerr << endl;
*/
        int now = diff;
        vector<pair<int, int>> pairs;

        for (int i = 0; i < n; ++i) {
            now += a[i] != b[i];
            if (a[i] != b[i] && left[i] > diff) {
                pairs.emplace_back(left[i] - diff, right[i]);
            }
        }

        sort(pairs.rbegin(), pairs.rend());
        ans = min(ans, now + n);

        if (pairs.empty()) {
            ans = min(ans, now);
        } else {
            int need_right = 0;
            for (auto p : pairs) {
                ans = min(ans, now + 2 * (p.first + need_right));
                need_right = max(need_right, p.second);
            }
        }
        rotate(b.begin(), b.begin() + 1, b.end());
    }

    return ans;
}

int main() {

    string a, b;
    cin >> a >> b;

    if (a == b) {
        cout << 0 << endl;
        return 0;
    }
    if (*max_element(b.begin(), b.end()) == '0') {
        cout << -1 << endl;
        return 0;
    }

    int ans = 1e9;
    for (int it = 0; it < 2; ++it) {
        ans = min(ans, DoStuff(a, b));
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        string st;
        cin>>st;
        vector<char> ans(st.size());
        j=0;
        FOR(i,0,st.size())
        {
          if(st[i]=='B'){
            if(j>0)
              j--;
          }
          else
            ans[j++]=(char)st[i];
        }
        FOR(i,0,j)cout<<ans[i];
        cout<<endl;
    }
}

Measured memory_bytes: 3556
n = int(input())

reds = []
for _ in range(n):
    reds.append(list(map(int, input().split())))

blues = []
for _ in range(n):
    blues.append(list(map(int, input().split())))

blues = sorted(blues, key=lambda x: x[0])

count = 0
for blue in blues:
    lefts = sorted([red for red in reds if red[0] < blue[0]
                    and red[1] < blue[1]], key=lambda r: r[1])
    if len(lefts) == 0:
        continue

    reds.remove(lefts[-1])
    count += 1

print(count)

Measured memory_bytes: 3064
N=gets.to_i
A=gets.split.map(&:to_i)

puts A.join(" ")

def insertionSort(a, n)
  for i in 1..n-1 do
    v=a[i]
    j=i-1
    while j>=0&&a[j]>v do
      a[j+1]=a[j]
      j -= 1
    end
    a[j+1]=v
    puts a.join(" ")
  end
end
insertionSort(A, N)



Measured memory_bytes: 6896
import sys
import heapq
if sys.version[0] == '2':
    range, input = xrange, raw_input
MAX_SPEED = 30
dvs = (-1, 0, 1)
while True:
    N, M = map(int, input().split())
    if not (N | M):
        break
    S, G = map(lambda x: int(x) - 1, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        x, y, d, c = map(int, input().split())
        edge[x - 1].append((y - 1, d, c))
        edge[y - 1].append((x - 1, d, c))
    INF = 1e9
    dist = [[[INF for _ in range(N)] for _ in range(MAX_SPEED + 1)] for _ in range(N)]
    que = [(0.0, S, 0, S)]
    while que:
        cost, now, v, prev = heapq.heappop(que)
        if cost > dist[now][v][prev]:
            continue
        if now == G and v == 1:
            print("{:.20f}".format(cost))
            break
        dist[now][v][prev] = cost
        for x, d, c in edge[now]:
            if x == prev:
                continue
            for dv in dvs:
                nv = v + dv
                if 0 < nv <= c and dist[x][nv][now] > dist[now][v][prev] + d / nv:
                    dist[x][nv][now] = dist[now][v][prev] + d / nv
                    heapq.heappush(que, (dist[x][nv][now], x, nv, now))
    else:
        print("unreachable")

Measured memory_bytes: 9852
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
 
 
int main() {
    ll n;
    scanf("%lld",&n);
    int flag = 0;

    rep(i,n){
        ll aaa;
        scanf("%lld",&aaa);
        if(aaa % 2 == 1){
            flag = 1;
        }
    }
    if(flag == 1){
        puts("first"); return 0;
    }

    puts("second"); 
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

inline void show(int* a, int n){
    for(int i = 0; i < n - 1; i++) cout << a[i] << " ";
    cout << a[n - 1] << endl;
}

void InsertionSort(int* a, int n){

    int i, j, v;

    for(i = 1; i < n; i++){
        v = a[i];
        j = i - 1;
        while((j >= 0) && (a[j] > v)){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        show(a, n);
    }
}

int main(){

    int N, A[100];

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    show(A, N);
    InsertionSort(A, N);

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int n;
int a[100000+5];
int c[100000+5];
int tree[3*100000+5];

int lowbit(int x){
	return x&-x;
}

void update(int x){
	while(x<=200010){
		tree[x]++;
		x+=lowbit(x);
	}
}

ll query(int x){
	ll res=0;
	while(x>0){
		res+=tree[x];
		x-=lowbit(x);
	}
	return res;
}

bool check(int x){
	c[0]=0;
	for(int i=1;i<=n;i++) c[i]=c[i-1]+(a[i-1]>=x ? 1:-1);
	memset(tree,0,sizeof(tree));
	ll sum=0;
	for(int i=0;i<=n;i++){
		sum+=query(c[i]+100005);
		update(c[i]+100005);
	}
	return sum >= 1ll*n*(n+1)/4;
}

int main(){
	cin >> n;
	int l=0,r=-1e9;
	for(int i=0;i<n;i++){
		cin >> a[i];
		r=max(a[i],r);
	}
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int x;
  cin >> x;
  if (x >= 30) COUT("Yes");
  else COUT("No");

  return 0;
}


Measured memory_bytes: 3564
n,q = map(int,input().split())
queue = []
for i in range(n):
    p,t = map(str,(input().split()))
    t = int(t)
    queue.append([p,t])

total_time = 0
while len(queue)  > 0:
    x = queue.pop(0)
    if x[1] > q :
        total_time += q
        x[1] -= q
        queue.append(x)
    else:
        total_time += x[1]
        print(x[0],total_time)

Measured memory_bytes: 15888
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1e9 + 7;
ll dp[5010][5010];

int main() {
    int n;
    string s;
    cin >> n >> s;
    int m = s.length();

    dp[0][0] = 1;
    REP(i,n) REP(j,n){
        dp[i+1][j+1] = (dp[i+1][j+1] + 2 * dp[i][j]) % mod;
        dp[i+1][max(0,j-1)] = (dp[i+1][max(0,j-1)] + dp[i][j]) % mod;
    }

    // REP(i,n+1){
    //     REP(j,n+1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    ll ans = dp[n][m];
    // cout << ans << endl;
    REP(_,m){
        ans = (ans * 500000004) % mod;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    //
    long long x, k, d;

    cin >> x >> k >> d;
    x = abs(x);
    long long tmp;

    if (x /d > k) {
        cout << x - (k * d);
    } else {
        tmp = (x / d);
        k -= tmp;
        x -= tmp * d;
        if (k % 2 == 0)
            cout << abs(x);
        else cout << abs(x - d);
    }
}


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

int main()
{
  int A,B,C,K,N,count=0;
  string s,t;
  cin>>A>>B>>C>>K;
  int ans=0;
  if(K-A<0){
    cout<<K;
  }else if(K-A-B<0){
    cout<<A;
  }else {
    cout<<A-(K-A-B);
  }
  return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int arr[55];
long long ans;
int main(){
    scanf("%d",&n);
    for (int x=0;x<n;x++) scanf("%d",&arr[x]);
    for (int x=0;x<n;x++){
        for (int y=x+1;y<n;y++){
            ans+=arr[x]*arr[y];
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<vector<int>> c(M, vector<int>(0));

    // cout << -1 << endl;
    // return 0;

    set<int> can_be_opened;
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        for(int j=0; j<b[i]; j++) {
            int tmp;
            cin >> tmp;
            tmp--;
            c[i].push_back(tmp);
            can_be_opened.insert(tmp);
        }
    }

    if(can_be_opened.size() < N) {
        cout << -1 << endl;
        return 0;
    }

    vector<int> dp((1<<N), 2e9);
    for(int i=0; i<M; i++) {
        int flag = 0;
        for(int j=0; j<b[i]; j++)
            flag |= (1<<c[i][j]);
        // dp[flag] = a[i];
        for (int y = 0; ; y = (y - flag) & flag) {
            dp[y] = min(a[i], dp[y]);
            if (y==flag) break;
        }
    }
    
    for(int i=0; i<(1<<N); i++) {
        for (int y = 0; ; y = (y - i) & i) {
            for(int z = 0; ; z = (z-i) & i ) {
                if(y!=z && (y|z)==i)
                    dp[i] = min(dp[i], dp[y] + dp[z]);
                if(z==i) break;
            }
            if (y==i) break;
        }
    }
    cerr << "debug result" << endl;
    for(auto x: dp) cerr << x <<" "; cerr << endl;
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include <vector>
#include <algorithm> 
#include <list>
 
using namespace std;
 
int main(){
   long a,b,n;
   cin >> a>>b>>n;
   if(b>n){
     long k =a*n/b;
     cout<<k;
   }
   else{
     long k =a*(b-1)/b;
     cout<<k;
   }
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    for(ll i = 0; i < x; i++) {
        cin >> a[i];
    }
    for(ll i = 0; i < y; i++) {
        cin >> b[i];
    }
    for(ll i = 0; i < z; i++) {
        cin >> c[i];
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());

    vector<bool> seen(x*y*z,false);
    seen[0]=true;

    priority_queue<pair<ll,ll>> pq;
    pq.emplace(make_pair(a[0]+b[0]+c[0],0));
    ll cnt=0;
    while(!pq.empty()) {
        pair<ll,ll> tmp=pq.top();
        ll v=tmp.second;
        ll vz=v/(x*y);
        ll vy=(v-x*y*vz)/x;
        ll vx=v-x*y*vz-x*vy;
//        cout << tmp.first << " " << vx << " " << vy << " " << vz << "\n";
        cout << tmp.first << "\n";
        pq.pop();

        if(!seen[v+1] && vx!=x-1){
            ll pt=a[vx+1]+b[vy]+c[vz];
            pq.emplace(make_pair(pt,v+1));
            seen[v+1]=true;
        }
        if(!seen[v+x] && vy!=y-1){
            ll pt=a[vx]+b[vy+1]+c[vz];
            pq.emplace(make_pair(pt,v+x));
            seen[v+x]=true;
        }
        if(!seen[v+x*y] && vz!=z-1){
            ll pt=a[vx]+b[vy]+c[vz+1];
            pq.emplace(make_pair(pt,v+x*y));
            seen[v+x*y]=true;
        }

        cnt++;
        if(cnt==k) return 0;
    }
    return 0;
}



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

int main(void){
  int N;
  cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  map<string,int> dict;
  for(int i=0;i<N;i++){
    dict[S[i]]++;
  }
  int maxi=-1;
  for(auto x:dict){
    maxi=max(maxi,x.second);
  }
  for(auto x:dict){
    if(x.second==maxi){
      cout<<x.first<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
vector<int>G[maxn];
int n,m;
int deg[maxn],vis[maxn];
vector<int>path;
bool dfs(int u){
	vis[u]=1;
	path.push_back(u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(!vis[v]){
		
			dfs(v);
			return true;
		}
	}
	return false;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
		deg[u]++;deg[v]++;
	}

	vector<int>p1,p2;
	int cnt=0;
	for(int i=0;i<G[1].size();i++){
		int v=G[1][i];
		vis[1]=1;
		if(!vis[v]){
			++cnt;
			path.clear();
			dfs(v);
			if(cnt==1)
				p1=path;
			else p2=path;
			if(cnt==2)break;
		}
	}


/*	cerr<<"p1"<<endl;
	for(auto x:p1)
		cerr<<x<<" ";
	cerr<<endl;

	cerr<<"p2"<<endl;
	for(auto x:p2)
		cerr<<x<<" ";
	cerr<<endl;
*/
	if(cnt==1){
		p1.insert(p1.begin(),1);
		printf("%d\n",(int)p1.size());
		for(int i=0;i<p1.size();i++)
			printf("%d%c",p1[i]," \n"[i+1==p1.size()]);
	}else{
		vector<int>p;
		for(int i=(int)p2.size()-1;i>=0;i--)
			p.push_back(p2[i]);
		p.push_back(1);
		for(int i=0;i<p1.size();i++)
			p.push_back(p1[i]);
		printf("%d\n",(int)p.size());
		for(int i=0;i<p.size();i++)
			printf("%d%c",p[i]," \n"[i+1==p.size()]);
	}

	return 0;
}

Measured memory_bytes: 11128
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main(void){
    int n,k,hmn,hmx,ans = INT_MAX;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    for(int i = 0;i < n-k+1;i++){
        hmn = h[i];
        hmx = h[i+k-1];
        ans = min(ans,(hmx-hmn));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())

E = [[] for i in range(N)]

ab = []
for i in range(M):
    a, b = map(int, input().split())
    ab.append([a-1, b-1])

visited = []


def search(pos):
    for n_pos in E[pos]:
        if n_pos not in visited:
            visited.append(n_pos)
            search(n_pos)

count = 0
for i in range(M):
    visited = []
    E = [[] for i in range(N)]
    for j in range(M):
        if j == i:
            continue
        E[ab[j][0]].append(ab[j][1])
        E[ab[j][1]].append(ab[j][0])
    search(0)
    if len(visited) < N:
        count += 1

print(count)


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int K = nextInt();

		int[] h =nextInts();
		int ans = 0;
		for(int x:h){
			if(x>=K){
				ans++;
			}
		}
		pw.println(ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 34616
N = int(input())
H = [int(i) for i in input().split()]

ans = "Yes"

for i in range(N):
  if i == 0:
    H[0] -= 1
  else:
    if H[i-1] ==  H[i]:
      H[i-1] = H[i]
    elif H[i-1] > H[i]-1:
      ans = "No"
      break
    else:
      H[i] -= 1

print(ans)


Measured memory_bytes: 14396
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;

int main() {
    LL X, Y;
    cin >> X >> Y;
    int ans = 1;
    while (1) {
          LL tmp = Y / X;
          if (tmp < 2) break;
          X *= 2;
          ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, t;
	cin >> n >> t;
	int min = INT_MAX, max = INT_MIN, ans = 0;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(a < min) min = a;
		if(max == a - min) {
			ans++;
		} else if(max < a - min) {
			ans = 1;
			max = a - min;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>

using namespace std;
const static int N = 5;
const static int BOTTOM = 40;

int main() {
  int sum = 0;
  for( int i = 0; i < N; i++ ) {
    int score;
    cin >> score;
    sum += max( BOTTOM, score );
  }
  cout << sum / N << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    rep(i,n){
        for(int j=i+1; j<n; j++){
            int mx = l[i]+l[j];
            int idx = lower_bound(l.begin(), l.end(), mx) - l.begin() - 1;
            ans += max(0, idx-j);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a < 10 && b < 10){
		cout<<a * b<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define rep(i,N) for(lint i=0; i<N; i++)
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

vector<lint> depth(lint N,lint root,vector<lint> l1,vector<lint> l2) {
  vector<lint> res(N,-1);
  res[root] = 0;
  vector<queue<lint>> can(N);
  rep(i,N-1) {
    can[l1[i]].push(l2[i]);
    can[l2[i]].push(l1[i]);
  }
  
  queue<lint> que;
  que.push(root);
  lint pla;
  
  while (!que.empty()) {
    pla = que.front();
    while (!can[pla].empty()) {
      if (res[can[pla].front()] == -1) {
        res[can[pla].front()] = res[pla] + 1;
        que.push(can[pla].front());
      }
      can[pla].pop();
    }
    que.pop();
  }
  
  return res;
}

int main() {
  lint N,u,v;
  cin >> N >> u >> v;
  u--;
  v--;
  
  vector<lint> A(N-1),B(N-1);
  rep(i,N-1) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  
  vector<lint> u_depth = depth(N,u,A,B);
  vector<lint> v_depth = depth(N,v,A,B);
  
  lint ans = 0;
  
  rep (i,N) {
    if (u_depth[i] < v_depth[i]) {
      ans = max(ans,(v_depth[i] - 1));
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 72264