akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//abc127
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m; cin>>n>>m;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));

    vector<P> cb(m);
    rep(i,m)cin>>cb.at(i).S>>cb.at(i).F;
    sort(all(cb),greater<P>());

    int pl=0;
    rep(i,m){
        int b=cb.at(i).S,c=cb.at(i).F;
        if(pl==n)break;
        if(a.at(pl)>c)break;
        for(int j=0; j<b; j++){
            if(pl==n)break;
            if(a.at(pl)>c)break;
            a.at(pl)=c;
            pl++;
        }
    }

    int ans=0;
    rep(i,n)ans+=a.at(i);
    cout<<ans<<endl;

}

Measured memory_bytes: 2560
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%k
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)

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

int main() {
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
  
    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            Alice += a[i];
        }else{
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
  
    return 0;
}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

#define        MX        3005
string str1, str2;

int ara[MX][MX];

string LCS()
{
    int n1 = str1.size(), n2 = str2.size();

    for(int i = 1; i < n1; i++){
        for(int j = 1; j < n2; j++){
            if(str1[i] == str2[j]){
                ara[i][j] = (ara[i-1][j-1]+1);
            }
            else{
                ara[i][j] = max(ara[i-1][j], ara[i][j-1]);
            }
        }
    }

    int i = n1-1, j = n2-1;
    string ans;
    while(ara[i][j]){
        if(ara[i][j] == ara[i-1][j]) i--;
        else if(ara[i][j] == ara[i][j-1]) j--;
        else{
            ans += str1[i];
            i--, j--;
        }
    }
    reverse(ans.begin(), ans.end());
    return ans;
}
int main()
{
    str1 += '?';
    str2 += '#';
    string temp;
    cin>>temp;
    str1 += temp;
    cin>>temp;
    str2 += temp;
    cout<<LCS()<<endl;
}


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

using ll = long long;

int const nmax = 100000;
std::vector<int> g[1 + nmax];
int v[1 + nmax];

int dfs(int node, int &result, int k) {
  int acc = 0;
  for(int h = 0; h < g[node].size(); h++) {
    int to = g[node][h];
    int acc2 = dfs(to, result, k);
    if(acc2 == k) {
      if(node != 1) {
        result++;
        acc2 = 0;
      }
    } else
      acc = std::max(acc, acc2);
  }
  return acc + 1;
}

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

  int n, k;
  std::cin >> n >> k;
  int far;
  std::cin >> far;
  int result = 0;
  if(far != 1)
    result++;
  for(int i = 2; i <= n; i++) {
    std::cin >> far;
    g[far].push_back(i);
  }
  dfs(1, result, k);
  std::cout << result;
}


Measured memory_bytes: 13568
import java.util.*;
public class Main{
 	public static void main(String[] args) {
 	    
		Scanner sc = new Scanner(System.in);
      	
      	int[] n = new int[4];
      	int a=0;
        
        
        for(int i=0; i<6; i++){
            a = sc.nextInt();
            n[a-1]++;
            
        }
        
        for(int i=0; i<4; i++){
            
            if(!(n[i]<3)){
            System.out.println("NO");
            return;
                
            }
            
        }
        
        System.out.println("YES");
 	}
}


Measured memory_bytes: 35748
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
using namespace std;

int main() {
    int x, y, z;
    scan3Int(x, y, z);
    printf("%d %d %d\n", z, x, y);
    return 0;
}


Measured memory_bytes: 3744
from functools import reduce


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


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
T = []

for _ in range(n):
    T.append(int(input()))

print(lcm(*T))


Measured memory_bytes: 3572
# A - Frog 1
N = int(input())
h = list(map(int, input().split()))
DP = []

for i in range(N):
    if i == 0:
        DP.append(0)
    elif i == 1:
        DP.append(abs(h[1]-h[0]))
    else:
        # 1個進む
        A = DP[i-1] + abs(h[i] - h[i-1])

        # 2個進む
        B = DP[i-2] + abs(h[i] - h[i-2])
        if A < B:
            DP.append(A)

        else:
            DP.append(B)

ans = DP[N-1]
print(ans)

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


int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if ((s[i] + n) > 90) {
            int m  = n - 26;
            s[i] = s[i] + m;
        } else {
            s[i] = s[i] + n;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		String output = "";
		int N = nextInt();
		while(N != 0){
			if(N % 2 == 1 || N % 2 == -1){
				if(output.length() % 2 == 1){
					N++;
				}else{
					N--;
				}
				output = "1" + output;
			}else{
				output = "0" + output;
			}
			N /= 2;
		}
		if(output.equals("")){
			output = "0";
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 36536
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    ll x,y,check=0;
    cin >> x >> y;
    ll i=1;
    while(i<=x){
        if(((i*2+(x-i)*4)==y)||(i*4+(x-i)*2)==y){
            check=1;
            break;
        }
        else i++;
    }
    if(check==1)cout << "Yes\n";
    else cout << "No\n";

    return 0;
}



Measured memory_bytes: 3648
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int checkpoint(int x1,int x2,  int y1, int y2) {
	int ans = abs(x1 - x2) + abs(y1 - y2);
	return ans;
}

ll a[100], b[100], c[100], d[100];

int main()
{
	int N, M; cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < N; i++) {
		ll ans = 10000000000000000;
		ll num = 0;
		for (int j = 0; j < M; j++) {
			int mi = checkpoint(a[i], c[j], b[i], d[j]);
			if (ans > mi) {
				ans = mi;
				num = j;
			}
		}
		cout << num + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, ans=1;
  string S;
  cin >> N >> S;
  if (N>1) {
    rep(i,0,N-1) {
      if (S[i]!=S[i+1]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3740
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
#define Y1 b1[0]-'a'
#define X1 b1[2]-'1'
#define Y2 b2[0]-'a'
#define X2 b2[2]-'1'
using namespace std;
int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
int m,n,ds,ns,nc,nj,sy,sx,gy,gx,t,
S[20][20],D[20][20][20][20]; bool V[20][20][101][4]; char ch,tmp;
void dfs(int y,int x,int t,int d){
	V[y][x][t][d]=1;
	int ny,nx,c,nt,nd;
	rep(i,4){
		nd=d+i&3,ny=y+dy[nd],nx=x+dx[nd];
		if(ck(ny,m)&&ck(nx,n)&&i!=2){
			c=D[y][x][ny][nx],nt=t+c;
			if((!S[ny][nx]||nd%2==nt/S[ny][nx]%2)&&c
			&&nt<101&&!V[ny][nx][nt][nd])dfs(ny,nx,nt,nd);
		}
	}
}
int main(){
	while(cin>>m>>n,m){
		cin>>ds; rep(y,m)rep(x,n){
			S[y][x]=0; rep(d,4){
				int ny=y+dy[d],nx=x+dx[d];
				if(ck(ny,m)&&ck(nx,n))D[y][x][ny][nx]=D[ny][nx][y][x]=ds;
			}
		}
		int x1,x2,y1,y2,k;
		cin>>ns; rep(i,ns){
			cin>>ch>>tmp>>x1>>k; x1--;
			S[ch-'a'][x1]=k;
		}
		cin>>nc; rep(i,nc){
			cin>>ch>>tmp>>x1; y1=ch-'a'; x1--;
			cin>>ch>>tmp>>x2; y2=ch-'a'; x2--;
			D[y1][x1][y2][x2]=D[y2][x2][y1][x1]=0;
		}
		cin>>nj; rep(i,nj){
			cin>>ch>>tmp>>x1; y1=ch-'a'; x1--;
			cin>>ch>>tmp>>x2>>k; y2=ch-'a'; x2--;
			D[y1][x1][y2][x2]+=k,D[y2][x2][y1][x1]+=k;
		}
		cin>>ch>>tmp>>sx; sy=ch-'a'; sx--;
		cin>>ch>>tmp>>gx; gy=ch-'a'; gx--;
		
		rep(i,m)rep(j,n)rep(t,101)rep(d,4)V[i][j][t][d]=0;
		rep(d,4)dfs(sy,sx,0,d);
		rep(t,101)rep(d,4)if(V[gy][gx][t][d]){
			cout<<t<<endl; goto END;
		}
		END:;
	}
	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    edpd()
}

data class Item(val weight: Int, val price: Int)

fun edpd() {
    val (n, w) = readLine()!!.split(" ").map { it.toInt() }
    val items = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Item(it[0], it[1]) }

    val dp = Array(n) { LongArray(w + 1) { -1L } }

    val answer = dp(0, w, n, items, dp)

    println(answer)
}

fun dp(itemIndex: Int, remainWeight: Int, n: Int, items: List<Item>, dp: Array<LongArray>): Long {
    if (itemIndex == n) return 0

    if (dp[itemIndex][remainWeight] != -1L) {
        return dp[itemIndex][remainWeight]
    }

    val currentItem = items[itemIndex]

    val result = if (currentItem.weight > remainWeight) {
        dp(itemIndex + 1, remainWeight, n, items, dp)
    } else {
        Math.max(
            dp(itemIndex + 1, remainWeight, n, items, dp),
            currentItem.price
                    + dp(itemIndex + 1, remainWeight - currentItem.weight, n, items, dp)
        )
    }

    dp[itemIndex][remainWeight] = result

    return result
}


Measured memory_bytes: 123124
#include <iostream>
#include <string>
 
int main() {
  std::string s;
  std::getline(std::cin, s);
  int len = s.size();
  int64_t sum = 0;
  int i = 0, t = 0, b0 = 0, b1 = 0;
  do {
    while (s[i] == '<' && i < len) i++;
    t = i;
    while (s[i] == '>' && i < len) i++;
    b1 = i;
    for (int j = b0; j < t; j++) {
      sum += j - b0;
    }
    sum += std::max(t - b0, b1 - t);
    for (int j = t + 1; j <= b1; j++) {
      sum += b1 - j;
    }
    b0 = b1;
  } while (i < len);
  
  std::cout << sum << std::endl;
}



Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

#define N 10000000

int prime[N];

void eratosthenes(){
  rep(i,N) prime[i]=1;
  prime[0]=prime[1]=0;
  rep(i,N){
    if(prime[i]){
      for(int j=i+i;j<N;j+=i) prime[j]=0;
    }
  }
}

bool primeNumber(int n){
  if(n < 2) return false;
  else{
    for(int i = 2; i * i <= n; i++){
      if(n % i == 0) return false;
    }
    return true;
  }
}


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  int n;
  cin>>n;
  eratosthenes();
  int ans=0;
  vector<int> nn;
  rep(i,N){
    if(prime[i]==1){
      int num=i;
      while(n%num==0){
	n/=num;
	num*=i;
	ans++;
      }
    }
  }
 
  
 
    if(n>=N) ans++;
  
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 81756
#include <iostream>
//#include <memory.h>
//#include <limits.h>
//#include <math.h>
//#include <stdio.h>
//#include <stdlib.h>
//#include <algorithm>
using namespace std;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    for(int i=1;i<=100001;i++)
    {
        if((a * i) % b == c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split());k=10**9+7
c=(1<<n)%k-1
X=Y=1
for i in range(b):
	X=X*(n-i)%k;Y=Y*(i+1)%k
	if i+1 in(a,b):c-=X*pow(Y,k-2,k)
print(c%k)

Measured memory_bytes: 263412
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    ll ans = 0;
    exrep(d, 1, n) {
        ans += d * (n/d) * (n/d + 1) / 2;
    }

    out(ans);
    re0;
}

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

vector<int> rolledDice(char, vector<int>);

/* 0: t, 1: s, 2: e, 3: w, 4: n, 5: b */
int main()
{
    vector<int> dice;
    for (int i = 0; i < 6; i++)
    {
        int label;
        cin >> label;
        dice.push_back(label);
    }

    // map<int, int> invdice;
    // for (int i = 0; i < 6; i++)
    // {
    //     invdice[dice[i]] = i; // 逆関数（※ i≠j ≠> dice[i]≠dice[j]のときundefined）
    // }

    int nQuery;
    cin >> nQuery;

    int lTop, lFront;
    for (int i = 0; i < nQuery; i++)
    {
        cin >> lTop >> lFront;
        if (dice[2] == lFront)
        {
            dice = rolledDice('W', dice);
            dice = rolledDice('S', dice);
        }
        else if (dice[3] == lFront)
        {
            dice = rolledDice('E', dice);
            dice = rolledDice('S', dice);
        }
        else
        {
            while (dice[1] != lFront)
            {
                dice = rolledDice('N', dice);
            }
        }

        while (dice[0] != lTop)
        {
            dice = rolledDice('E', dice);
        }

        cout << dice[2] << endl;
    }

    // for (int i = 0; i < 6; i++)
    // {
    //     cout << dice[i] << " ";
    // }
    // cout << endl;

    // string str;
    // cin >> str;
    // for (int i = 0; i < (int)str.length(); i++)
    // {
    //     dice = rolledDice(str[i], dice);
    // }

    // cout << dice[0] << endl;

    return 0;
}

vector<int> rolledDice(char direction, vector<int> olddice)
{
    vector<int> newdice = olddice;
    if (direction == 'N')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[1];
        newdice[1] = olddice[5];
        newdice[5] = olddice[4];
        newdice[4] = olddice[0];
    }
    else if (direction == 'S')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[4];
        newdice[4] = olddice[5];
        newdice[5] = olddice[1];
        newdice[1] = olddice[0];
    }
    else if (direction == 'E')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[3];
        newdice[3] = olddice[5];
        newdice[5] = olddice[2];
        newdice[2] = olddice[0];
    }
    else if (direction == 'W')
    {
        // cout << "rolling to " << direction << endl;
        newdice[0] = olddice[2];
        newdice[2] = olddice[5];
        newdice[5] = olddice[3];
        newdice[3] = olddice[0];
    }
    return newdice;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b,c,k;
  	cin >> a >> b >> c >> k;
  	for(int i=0;i<k;i++){
    	if(a>=c) c*=2;
      	else if(a>=b) b *= 2;
      	else if(b>=c) c*= 2;
      	else if(a<b && b<c) break;
    }
  	if(a<b && b<c) cout<<"Yes"<<endl;
  	else cout << "No" <<endl;
}

Measured memory_bytes: 3584
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int h,w,n,ans[10];
vector<pair<int,int>> points,black;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> h >> w >> n;
  for(int i=1;i<=n;i++){
    int x,y;
    cin >> x >> y;
    black.pb({x,y});
    for(int dx=-2;dx<=0;dx++){
      for(int dy=-2;dy<=0;dy++){
        if( x+dx>=1 && x+dx+2<=h && y+dy>=1 && y+dy+2<=w   )
        points.pb({ x+dx, y+dy });
      }
    }
  }
  sort(all(points));
  sort(all(black));
  points.erase(unique(all(points)), points.end());

  for(auto t:points){
    int x = t.fs;
    int y = t.sc;
    int cnt = 0;
    for(int dx=0;dx<=2;dx++){
      for(int dy=0;dy<=2;dy++){
        if(binary_search( all(black) , make_pair( x+dx, y+dy ) ))cnt++;
      }
    }
    ans[cnt]++;
  }

  ans[0] = (h-2)*(w-2) - points.size();

  for(int i=0;i<=9;i++){
    cout << ans[i] << endl;
  }


return 0;
}
///....


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

ll re(int lv, ll x) {
  if (x <= 0) return 0;
  if (lv <= 0) return 1;
  ll height = pow(2ll, lv + 2) - 3;
  if (x >= height - 1) return pow(2ll, lv + 1) - 1;
  if (x <= height / 2) return re(lv - 1, x - 1);
  if (x == height / 2 + 1) return pow(2ll, lv);
  return pow(2ll, lv) + re(lv - 1, x - (height / 2 + 1));
}
int main() {
  int n;
  ll x;
  cin >> n >> x;
  cout << re(n, x) << endl;
}


Measured memory_bytes: 256
import math
def isprime(n):
    if n==1:return(False)
    if n==2:return(True)
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return(False)
    return(True)
s=set([i for i in range(1,10**5,4) if isprime(i) and isprime((i+1)//2)])
s.add(3)
l=[i in s for i in range(10**5)]
ls=[]
tmp=0
for i in l:
    tmp+=i
    ls.append(tmp)
n=int(input())
for i in range(n):
    l,r=map(int,input().split())
    print(ls[r]-ls[l-1])

Measured memory_bytes: 7004
#include <stdio.h>
#include <string.h>
#define min(x, y) ((x<y) ? (x) : (y))

int main(){
    int N, i, j, ans = 0;
    scanf("%d", &N);

    int SN[N];
    char S[N][10];
    for (i=0; i<N; i++){
        scanf("%s", &S[i]);
        SN[i] = strlen(S[i]);
    }

    int A=0, B=0, AB=0;
    for (i=0; i<N; i++){
        if (S[i][0] == 'B' && S[i][SN[i]-1] == 'A'){
            AB++;
            continue;
        }
        if (S[i][0] == 'B'){
            B++;
            continue;
        }
        if (S[i][SN[i]-1] == 'A'){
            A++;
            continue;
        }
    }

    for (i=0; i<N; i++){
        for (j=0; j<SN[i]-1; j++){
            if (S[i][j] == 'A' && S[i][j+1] == 'B'){
                ans++;
            }
        }
    }

    if (AB>0) ans += AB-1;
    if (AB>0 && A>0){
        A--;
        ans++;
    }
    if (AB>0 && B>0){
        B--;
        ans++;
    }
    ans += min(A, B);
 
    printf("%d", ans);
    return 0;
}


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

using namespace std;

using ll = long long;

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

    ll N, X;
    cin >> N >> X;
    vector<ll> x(N), s(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    sort(x.rbegin(), x.rend());
    for (int i = 0; i < N; i++)
    {
        s[i] = (i == 0 ? x[i] : s[i - 1] + x[i]);
    }
    ll ret = 1e18;
    for (ll i = 1; i <= N; i++)
    {
        bool ovf = false;
        ll sum = N * X + i * X;
        for (int index = 1; index <= (N - 1) / i + 1; index++)
        {
            int st = (index - 1) * i, gt = min(N - 1, index * i - 1);
            if (index == 1)
            {
                sum += 5 * s[gt];
            }
            else
            {
                sum += (2 * index + 1) * (s[gt] - s[st - 1]);
            }
            if (sum > 1e18)
            {
                ovf = true;
                break;
            }
        }
        if (ovf)
            continue;
        ret = min(ret, sum);
    }
    cout << ret << endl;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
using namespace std;
using namespace tr1;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

int main(){
    ios_base:: sync_with_stdio(false); 
    cin.tie(0);

        int n,  cnt = 0;
        cin >> n;
        FORD(i,9,1){
            if(n % i == 0 && n/i <= 9){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No";
        return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
char str[MAXN];
int dp[MAXN];

int main() {
	scanf("%s", str);
	int n = strlen(str);
	dp[0] = 1;
	if (n > 1) {
		if (str[0] == str[1])
			dp[1] = 1;
		else
			dp[1] = 2;
	}
	for (int i = 2; i < n; i++) {
		if (str[i-1] == str[i])
			dp[i] = max(dp[i-2] + 1, dp[i-3] + 2);
		else
			dp[i] = dp[i-1] + 1;
	}
	pri(dp[n-1]);
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
typedef long long ll;
using namespace std;
 
int main(){
  double t,x;
  cin >> t >> x;
  
  double ans = t/x;
  
  printf("%.10lf",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin>>h>>w;
    string s[100];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int d[30];
    for(int i=0;i<30;i++)d[i]=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[s[i][j]-'a']++;
        }
    }
    if(h%2==1&&w%2==1){
        //真ん中１っこ
        //ついになるのがh/2+w/2こ
        //4つ組がh/2*w/2こ
        int two=(h/2)+(w/2);
        for(int i=0;i<26;i++){
            if(d[i]%4==1||d[i]%4==3){
                d[i]-=1;
                break;
            }
        }
        for(int i=0;i<26;i++){
            if(d[i]%4==2&&two){
                d[i]-=2;
                two--;
            }
        }
        for(int i=0;i<26;i++){
            if(d[i]%4==0){
                d[i]=0;
            }
        }
    }
    else if(h%2==1){
        //ついになるのがw/2こ
        //４つくみがh/2*w/2こ
        int two=w/2;
        for(int i=0;i<26;i++){
            if(d[i]%4==2&&two){
                d[i]-=2;
                two--;
            }
        }
        for(int i=0;i<26;i++){
            if(d[i]%4==0){
                d[i]=0;
            }
        }
    }
    else if(w%2==1){
        //ついになるのがh/2こ
        //４つくみがh/2*w/2こ
        int two=h/2;
        for(int i=0;i<26;i++){
            if(d[i]%4==2&&two){
                d[i]-=2;
                two--;
            }
        }
        for(int i=0;i<26;i++){
            if(d[i]%4==0){
                d[i]=0;
            }
        }
    }
    else{
        for(int i=0;i<26;i++){
            if(d[i]%4==0){
                d[i]=0;
            }
        }
    }
    bool can=true;
    for(int i=0;i<26;i++){
        if(d[i]!=0)can=false;
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, K;
    cin >> N >> K;
    if((N-1)*(N-2)/2 < K){
        cout<<"-1"<<endl;
        return 0;
    }
    ll M = N-1 + ((N-1)*(N-2)/2 - K);
    cout<<M<<endl;
    for(int i=2;i<=N;i++){
        cout<<1<<" "<<i<<endl;
    }
    ll count = (N-1)*(N-2)/2 - K;
    for(int i=2;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(count==0) return 0;
            cout<<i<<" "<<j<<endl;
            count--;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

template< typename flow_t >
struct Dinic {
	const flow_t INF;

	struct edge {
		int to;
		flow_t cap;
		int rev;
		bool isrev;
		int idx;
	};

	vector< vector< edge > > graph;
	vector< int > min_cost, iter;

	Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

	void add_edge(int from, int to, flow_t cap, int idx = -1) {
		edge a = { to, cap, (int)graph[to].size(), false, idx };
		graph[from].emplace_back(a);
		a = { from, 0, (int)graph[from].size() - 1, true, idx };
		graph[to].emplace_back(a);
	}

	bool bfs(int s, int t) {
		min_cost.assign(graph.size(), -1);
		queue< int > que;
		min_cost[s] = 0;
		que.push(s);
		while (!que.empty() && min_cost[t] == -1) {
			int p = que.front();
			que.pop();
			for (auto& e : graph[p]) {
				if (e.cap > 0 && min_cost[e.to] == -1) {
					min_cost[e.to] = min_cost[p] + 1;
					que.push(e.to);
				}
			}
		}
		return min_cost[t] != -1;
	}

	flow_t dfs(int idx, const int t, flow_t flow) {
		if (idx == t) return flow;
		for (int& i = iter[idx]; i < graph[idx].size(); i++) {
			edge& e = graph[idx][i];
			if (e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
				flow_t d = dfs(e.to, t, min(flow, e.cap));
				if (d > 0) {
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	flow_t max_flow(int s, int t) {
		flow_t flow = 0;
		while (bfs(s, t)) {
			iter.assign(graph.size(), 0);
			flow_t f = 0;
			while ((f = dfs(s, t, INF)) > 0) flow += f;
		}
		return flow;
	}

	void output() {
		for (int i = 0; i < graph.size(); i++) {
			for (auto& e : graph[i]) {
				if (e.isrev) continue;
				auto& rev_e = graph[e.to][e.rev];
				cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
			}
		}
	}
};

int N;
struct point {
	int x, y;
};
vector<point> B, R;

int main() {
	cin >> N;
	Dinic<int> D(2 * N + 2);
	B.resize(N);
	R.resize(N);
	for (int n = 0; n < N; n++)cin >> R[n].x >> R[n].y;
	for (int n = 0; n < N; n++)cin >> B[n].x >> B[n].y;
	for (int r = 0; r < N; r++) {
		for (int b = 0; b < N; b++) {
			if (R[r].x < B[b].x && R[r].y < B[b].y) {
				D.add_edge(r + 1, N + b + 1,1);
			}
		}
		D.add_edge(0, r + 1,1);
		D.add_edge(N + r + 1, 2 * N + 1,1);
	}
	cout << D.max_flow(0, 2 * N + 1) << endl;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        Integer n = sc.nextInt();

        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        int ans = 0;

        for (int i = 0; i < n; i++) {

            if (array[i] <= min) {
                ans++;
                min = array[i];
            }
        }

        System.out.println(ans);

    }

}

Measured memory_bytes: 66864
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int N;
vector<LL> line;

bool check(int x){
	LL sum = line[x];
	REP(i, N){
		if(x==i)continue;
		if(sum*2 < line[i])return false;
		sum += line[i];
	}
	return true;
}

int main(){
	int N;
	cin >> N;
	LL A, B, C, D;
	cin >> A >> B >> C >> D;
	--N;
	LL dis = abs(B - A);
	LL lo = 0;
	LL ho = 0;
	LL d = dis / D;
	dis -= d * D;
	N -= d;
	if(N<0){
		cout << "NO" << endl;
		return 0;
	}
	lo = (C-D) * d;
	ho += N / 2 * (D-C);
	lo -= N / 2 * (D-C);
	N %= 2;
	if(N){
		if((lo + C <= dis && dis <= ho + D) || (lo - D <= dis && dis <= ho - C)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	else{
		if(lo <= dis && dis <= ho){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  vl cum(n + 1);
  rep(i, n) cum[i + 1] = cum[i] + a[i];
  dump(cum);
  map<ll, ll> mp;
  rep(i, n + 1) mp[cum[i]]++;
  dump(mp);
  ll ans = 0;
  for (auto m : mp) {
    if (m.second >= 2) ans += (ll)m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 8;
int n;
VI g[N];
int mt[N];
char u[N];

bool kuhn(int v)
{
	if (u[v]) return 0;
	u[v] = 1;
	
	for(auto i: g[v]) if (mt[i] == -1)
	{
		mt[i] = v;
		return 1;
	}
	
	for(auto i: g[v]) if (kuhn(mt[i]))
	{
		mt[i] = v;
		return 1;
	}
	
	return 0;
}

PII A[N];
PII B[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	FOR(i, 0, n) cin >> A[i].X >> A[i].Y;
	FOR(i, 0, n) cin >> B[i].X >> B[i].Y;
	
	FILL(mt, -1);
	
	FOR(i, 0, n) FOR(j, 0, n) if (A[i].X < B[j].X && A[i].Y < B[j].Y)
		g[i].PB(j);
	
	int ans = 0;
	FOR(i, 0, n)
	{
		FILL(u, 0);
		ans += kuhn(i);
	}
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX_PRIME = 2000000;
vector<int> primes;
vector<bool> is_prime;
void init_primes() {
  is_prime = vector<bool>(MAX_PRIME + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= MAX_PRIME; i++) {
    if (is_prime[i]) {
      primes.push_back(i);
      for (int j = i*2; j <= MAX_PRIME; j+=i) {
        is_prime[j] = false;
      }
    }
  }
}
int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  init_primes();
  int x;cin>>x;
  for(auto v : primes){
    if(v>=x){
      cout<<v<<endl;
      return 0;
    }
  }


  
  return 0;
}


Measured memory_bytes: 4456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=200000 +10, M=(ll)1e9+1 ;
const int mod =998244353 ,sz=5 ;
vl g[N];
vl vis(N,0),ans(N,0),a(N,0);
ll sum=0;
void dfs(ll u,ll sum){
  vis[u]=1;
  sum+=a[u];
  ans[u]=sum;
  for(auto &it:g[u]){
    if(!vis[it]){
      dfs(it,sum);
    }
  }
}
void work(){
  ll n,q;
  cin >> n >> q;
  for(ll i=0;i<n-1;i++){
    ll u,v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  for(ll i=0;i<q;i++){
    ll v,c;
    cin >> v >> c;
    a[v]+=c;
  }
  dfs(1,0);
  for(ll i=1;i<=n;i++)
    cout << ans[i] << " ";
  
}
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int K;
  cin >> K;
  int a = K / 2;
  int b = a + K % 2;
  cout << a * b << endl;
}


Measured memory_bytes: 3592
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0].split(" ").map(n => Number(n));
    const x = input[0];
    const a = input[1];
    const b = input[2];
    if (Math.abs(x - a) < Math.abs(x - b)) {
        console.log("A");
    } else {
        console.log("B");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i;
    char s[101],t[101];
    scanf("%d",&n);getchar();
    scanf("%s %s",s,t);getchar();
    for(i=0;i<n;i++)
        printf("%c%c",s[i],t[i]);
    return 0;
}


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

pair<string,string> split(string s, int i){
	string s1, s2;
	
	for(int j=0 ; j < s.size() ; j++ ){
		if( j <= i ){
			s1.push_back( s[j] );
		}else{
			s2.push_back( s[j] );
		}
	}
	return pair<string,string> (s1,s2);
}

int main(){
	int m;
	cin >> m;
	for(int i=0 ; i < m ; i++ ){
		string s;
		cin >> s;
		
		set<string> vs;
		for(int i=0 ; i < s.size()-1 ; i++ ){
			pair<string,string> p = split( s , i );
			string s1 = p.first;
			string s2 = p.second;
			vs.insert( s1 + s2 );
			vs.insert( s2 + s1 );
			reverse( s1.begin() , s1.end() );
			vs.insert( s1 + s2 );
			vs.insert( s2 + s1 );
			reverse( s2.begin() , s2.end() );
			vs.insert( s1 + s2 );
			vs.insert( s2 + s1 );
			reverse( s1.begin() , s1.end() );
			vs.insert( s1 + s2 );
			vs.insert( s2 + s1 );
		}
		cout << vs.size() << endl;
	}
}

Measured memory_bytes: 1000
function main(input) {
  const [w, a, b] = input.trim().split(" ").map(n => Number(n));
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  const result = min + w < max ? max - min - w : 0;
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
w = input()
d = dict()
for i in range(len(w)):
    c = w[i]
    count = d.get(c, 0)
    d[c] = count + 1
f = True
for k in d:
    if d[k] % 2 != 0:
        f = False
print("Yes" if f else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> w(n, 0);
    for (int i = 2;; i += 2)
    {
        if (i == n)
            break;
        i %= n;
        int x = i - 1, y = i - 2;
        if (x < 0)
            x += n;
        if (y < 0)
            y += n;
        int z = a[x] - a[y];
        int p = i - 2;
        if (p < 0)
            p += n;
        w[i] = w[p] + 2 * z;
    }
    int sum = 0;
    rep(i, n) sum += w[i];
    int summ = 0;
    rep(i, n) summ += a[i];
    summ -= sum;
    summ /= n;
    rep(i, n) cout << w[i] + summ << " ";
    cout << endl;
}

Measured memory_bytes: 2944
MOD = 10**9 + 7
S = input()
N = len(S)
target = 'ABC'
n = len(target)
cur = [0]*(n+1)
cur[0] = 1
for s in S:
    for w in range(n):
        if s == target[w]:
            cur[w+1] += cur[w]
            cur[w+1] %= MOD
            break
    else: # case of '?'
        for w in range(n-1,-1,-1):
            cur[w+1] = (cur[w+1]*3 + cur[w]) % MOD
        cur[0] *= 3
        cur[0] %= MOD
print(cur[-1])

Measured memory_bytes: 42476