akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};
    
int g[5100][5];

signed main(){
    
    while(1){
    memset(g, 0, sizeof(g));
    int n; cin >> n;
    if(!n) break;
    int sum = 0;
    for(int j = 0; j < 5; j++){
        g[0][j] = 1;
    }


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

        int a, p, q; cin >> a >> p >> q;
        swap(p, q);
        p--;
        sum += q;
        if(a == 1){


            // 落とす
            int y;
            for(int i = 5000; i >= 1; i--){
                bool flag = false;
                for(int j = p; j < p + q; j++){
                    if(g[i - 1][j] == 1){
                        flag = true;
                        y = i;        
                        break;
                    }
                }
                if(flag) break;
            }

            for(int j = p; j < p + q; j++){
                g[y][j] = 1;
            }

            // 消えるかどうか
            bool erase = true;
            for(int j = 0; j < 5; j++){
                if(!g[y][j]) erase = false;
            }

            if(erase){
                sum -= 5;
                for(int i = y + 1; i <= 5000; i++){
                    for(int j = 0; j < 5; j++){
                        g[i - 1][j] = g[i][j];
                        g[i][j] = 0;
                    }
                }
            }

        }else{
            

            // 落とす
            int y = 0;
            for(int i = 5000; i >= 0; i--){
                if(g[i - q][p]){
                    y = i;
                    break;
                }
            }

            for(int i = y - q + 1; i <= y; i++) g[i][p] = 1;

            // 消えるかどうか
            y = y - q + 1;
            for(int itr = 0; itr < 5; itr++){
                bool erase = true;
                for(int j = 0; j < 5; j++){
                    if(!g[y][j]) erase = false;
                }

                if(erase){
                    sum -= 5;
                    for(int i = y + 1; i <= 5000; i++){
                        for(int j = 0; j < 5; j++){
                            g[i - 1][j] = g[i][j];
                            g[i][j] = 0;
                        }
                    }
                }else{
                    y++;
                }
            }
        }

        /*
        // デバック
        for(int i = 10; i >= 0; i--){
            for(int j = 0; j < 5; j++){
                cout << g[i][j] << " ";
            }
            cout << endl;
        }
        */
    }


    cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3232
#include<cstdio>

#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
Node T[MAX];

int n;

void preParse(int u){
	if(u==NIL)return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u==NIL)return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

void postParse(int u){
	if(u==NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main(){
	int v,l,r,root;
	
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		T[i].p=NIL;
	}
	
	for(int i=0;i<n;++i){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l!=NIL)T[l].p=v;
		if(r!=NIL)T[r].p=v;
	}
	
	for(int i=0;i<n;++i){
		if(T[i].p==NIL) root=i;
	}
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2736
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

ll fac[1000001];

void pre(){
    fac[0]=fac[1]=1;
    for(int i=2;i<=1000001;i++)
{

    fac[i]=(fac[i-1]*1LL*i)%mod;
}
}

ll binpower(ll a,ll n){
    ll res=1;
    while(n){

    if(n%2)
        res = (res*1LL*a)%mod;

        n/=2;
        a=(a*1LL*a)%mod;

    }
    return res;

}

ll nCrmod(ll n,ll r){


ll res= fac[n];
res = (res*1LL*binpower(fac[r],mod-2))%mod;
res= (res*1LL*binpower(fac[n-r],mod-2))%mod;
return res;

}

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll modexp(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  modexp(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*modexp(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return modexp(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}

void SieveOfEratosthenes(ll n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (ll p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

vector<int> Centroid(vector<int>g[],int n) {

        vector<int> centroid;
        vector<int> sz(n+1);
        function<void (int, int)> dfs = [&](int u, int prev) {
                sz[u] = 1;
                bool is_centroid = true;
                for (auto v : g[u]) if (v != prev) {
                        dfs(v, u);
                        sz[u] += sz[v];
                        if (sz[v] > n / 2) is_centroid = false;
                }
                if (n - sz[u] > n / 2) is_centroid = false;
                if (is_centroid) centroid.push_back(u);
        };
        dfs(1, 0);
        return centroid;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0;
    for(int a=1;a<n;a++){
       int b= n/a;
       ans+=b;
       if(a*b==n)ans--;

    }
    cout<<ans;



    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>

int main(){
	char cards[400];
	int c, s, i;
	char t;

	while(true){
		i = 0;
		scanf("%c", &t);
		if(t == '-'){
			return 0;
		}
		while(t - 10){
			cards[i] = t;
			i++;
			scanf("%c", &t);
		}

		for (int j = 0; j < i; j++)
		{
			cards[j + i] = cards[j];
		}

		scanf("%d", &c);
		int sum = 0;
		for(int j = 0; j < c ; j++){
			scanf("%d", &s);
			sum += s;
		}
		sum %= i;
		scanf("%c", &t);
		for(int j = 0; j < i ; j++){
			printf("%c", cards[j + sum]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 992
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(
            think([1, 1, 2, 1, 2]),
            [2, 2, 3, 2, 3]
        )

    def test_2(self):
        self.assertEqual(
            think([1, 2, 3, 4]),
            [0, 0, 0, 0]
        )

    def test_3(self):
        self.assertEqual(
            think([3, 3, 3, 3, 3]),
            [6, 6, 6, 6, 6]
        )

    def test_4(self):
        self.assertEqual(
            think([1, 2, 1, 4, 2, 1, 4, 1]),
            [5, 7, 5, 7, 7, 5, 7, 5]
        )


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    hist = make_hist(a)
    num_of_pair = calc_num_of_pair(hist)
    sum_of_num_of_pair = 0

    result = [0] * len(a)

    for k, v in num_of_pair.items():
        sum_of_num_of_pair += v

    for i, e in enumerate(a):
        if hist[e] <= 1:
            result[i] = sum_of_num_of_pair
        else:
            n = hist[e]
            result[i] = sum_of_num_of_pair - num_of_pair[e]
            result[i] += ((n - 1) * (n - 2)) // 2
    return result


def make_hist(a):
    hist = {}
    for e in a:
        hist[e] = hist.get(e, 0) + 1
    return hist


def calc_num_of_pair(hist):
    num_of_pair = {}
    for k, v in hist.items():
        if v <= 1:
            num_of_pair[k] = 0
        else:
            num_of_pair[k] = (v * (v - 1)) // 2
    return num_of_pair


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 111572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class AWeLoveGolf {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();

            for (int i = a; i <= b; i++) {
                if (i % k == 0) {
                    out.println("OK");
                    return;
                }
            }
            out.println("NG");
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

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

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

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

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

    }
}



Measured memory_bytes: 25520
import math
 
X=int(input())
def ans165(X:int):
    cash=100#当初の預金額
    count=0
    while True:
        # cash=int(cash*1.01) #元本に１パーセントの利子をつけ小数点以下切り捨て # WA
        # cash = cash * 1.01 * 100 // 100 # 1%の利子をつけて100倍した後に100で割って整数部のみ取り出す # WA
        # cash += cash * 0.01 * 100 // 100 # 1%の利子を計算して100倍した後に100で割って整数部のみ取り出す # WA
        # cash += cash // 100 # 元本に100で割った整数部を足す # AC
        # cash += math.floor(cash * 0.01) # WA
        # cash += math.floor(cash / 100) # WA
        cash += math.floor(cash // 100) # WA
        count += 1#利子をつける回数だけcountを増やす
        if cash>=X:#cashがXの値以上になったらループ終了
            break
    return count
print(ans165(X))

Measured memory_bytes: 9060
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template
ans = 10**18
N,A,B,C = inputlist()
l = [0]*N
for i in range(N):
    l[i] = int(input())

n = 4**N

def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co

for i in range(n+1):
    k = base10to(i,4)
    if len(k) < N:
        d = N-len(k)
        for j in range(d):
            k = '0'+k
    c = Counter(list(k))
    if c['1'] < 1 or c['2'] < 1 or c['3'] < 1:
        continue
    ans_k = 0
    la = []
    lb = []
    lc = []
    for j in range(N):
        if k[j] == '1':
            la.append(l[j])
        if k[j] == '2':
            lb.append(l[j])
        if k[j] == '3':
            lc.append(l[j])
    ans_k += count(la,A) + count(lb,B) + count(lc,C)
    ans = min(ans,ans_k)
print(ans)

Measured memory_bytes: 113880
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();;

    let mut ans = 0_f32;
    for _ in 0..n {
        let x: f32 = iter.next().unwrap().parse().unwrap();
        let u = iter.next().unwrap();
        let rate: f32 = if u == "JPY" { 1f32 } else { 380000f32 };
        ans += x * rate;
    }

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


Measured memory_bytes: 4352
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s[] = sc.next().split("");
    if (s[0].equals("9") || s[1].equals("9")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35504
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  vi A(5);
  int k; 
  rep(i,5)cin>>A[i];
  cin >> k ;
  string ans = "Yay!";
  rep(i,5) rep(j,5) {
    if (i >= j) continue;
    if (A[j] - A[i] > k) ans = ":(";
  }
  cout << ans << endl;
  return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
     int a,b;
     cin>>a>>b;
     cout<<a*b<<endl;
    return 0;
}

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

int main(void){
    long h, w;
    cin >> h >> w;
    if(h==1||w==1){
        cout << 1 << endl;
        return 0;
    }
    if(h%2==0 && w%2==0){
        cout << (h/2)*(w/2)+(h/2)*(w/2) << endl;
    }else if(h%2==0 && w%2==1){
        cout << (h/2)*((w+1)/2)+(h/2)*((w+1)/2-1) << endl;
    }else if(h%2==1 && w%2==0){
        cout << ((h+1)/2)*(w/2)+((h+1)/2-1)*(w/2) << endl;
    }else{
        cout << ((h+1)/2)*((w+1)/2)+((h+1)/2-1)*((w+1)/2-1) << endl;
    }

    return 0;
}

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

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

	int n; cin >> n;
	int even = 0, odd = 0;
	for(int i = 0; i < n; i++) {
		int a; cin >> a;
		if(a % 2 == 0) even++;
		else odd++;
	}
	if(odd % 2 != 0){
		cout << "NO" << endl;
		return 0;
	}
	else {
		cout << "YES" << endl;
		return 0;
	}
	return 0;	
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<bool>> C(3, vector<bool>(3));
  for(int i = 0; i < 9; i++) cin >> A.at(i / 3).at(i % 3);
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i = 0; i < N; i++) {
    cin >> b.at(i);
    for(int j = 0; j < 9; j++) {
      if(b.at(i) == A.at(j / 3).at(j % 3)) C.at(j / 3).at(j % 3) = 1;
    }
  }
  
  string judge = "No";
  
  if((C.at(0).at(0) == 1) && (C.at(0).at(1) == 1) && (C.at(0).at(2) == 1)) judge = "Yes";
  else if((C.at(1).at(0) == 1) && (C.at(1).at(1) == 1) && (C.at(1).at(2) == 1)) judge = "Yes";
  else if((C.at(2).at(0) == 1) && (C.at(2).at(1) == 1) && (C.at(2).at(2) == 1)) judge = "Yes";
  else if((C.at(0).at(0) == 1) && (C.at(1).at(0) == 1) && (C.at(2).at(0) == 1)) judge = "Yes";
  else if((C.at(0).at(1) == 1) && (C.at(1).at(1) == 1) && (C.at(2).at(1) == 1)) judge = "Yes";
  else if((C.at(0).at(2) == 1) && (C.at(1).at(2) == 1) && (C.at(2).at(2) == 1)) judge = "Yes";
  else if((C.at(0).at(0) == 1) && (C.at(1).at(1) == 1) && (C.at(2).at(2) == 1)) judge = "Yes";
  else if((C.at(2).at(0) == 1) && (C.at(1).at(1) == 1) && (C.at(0).at(2) == 1)) judge = "Yes";
  
  cout << judge << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    string S;
    int K;
    vector<vector<vector<int>>> dp;

    void input() {
        cin >> S >> K;
        dp.resize(S.size(), vector<vector<int>>(S.size(), vector<int>(K + 1, -1)));
    }

    int rec(int l, int r, int k) {
        if (dp[l][r][k] != -1) return dp[l][r][k];
        if (l == r) return 1;
        if (l + 1 == r) {
            if (k > 0 || S[l] == S[r]) {
                return 2;
            } else {
                return 1;
            }
        }

        int ret = 0;
        if (S[l] == S[r]) {
            chmax(ret, 2 + rec(l + 1, r - 1, k));
        } else {
            ll tmp;
            if (k > 0) {
                tmp = 2 + rec(l + 1, r - 1, k - 1);
                chmax(ret, tmp);
            }
            tmp = rec(l, r - 1, k);
            chmax(ret, tmp);
            tmp = rec(l + 1, r, k);
            chmax(ret, tmp);
        }
        return dp[l][r][k] = ret;
    }

    void solve() {
        input();
        int ans = rec(0, S.size() - 1, K);
        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 109568
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        300005
#define mod         998244353  
 
 
int main(){
    ios_base::sync_with_stdio(false);   
    cin.tie(NULL);
    // ll t;
    // cin>>t;
    // while(t--){
        ll n,k,i,x,y,len,p,pos;
        cin>>n>>k;
        ll a[n+1];
        for(i=1;i<=n;i++){
            cin>>a[i];
        }
        set<ll> st;
        vector<ll> vi;
        vi.pb(10000000000);
        x=a[1];
        vi.pb(1);
        st.insert(1);
        while(st.find(x)==st.end()){
            st.insert(x);
            vi.pb(x);
            x=a[x];
        }
        k++;
        vi.pb(x);
        // for(auto x:vi){
        //     cout<<x<<" ";
        // }
        p=x;
        for(i=1;i<vi.size();i++){
            if(vi[i]==p){
                pos=i;
                break;
            }
        }
        if(k<=pos){
            cout<<vi[k];
        }
        else{
            k=k-pos;
            len=vi.size()-1-pos;
            k=k%len;
            y=pos+k;
            cout<<vi[y];
        }
        cout<<endl;
    // }
}

Measured memory_bytes: 15364
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s; cin >> s;
	vi c(3);
	for(char i : s) c[i - 'a']++;
	
	cout << (*max_element(all(c)) - *min_element(all(c)) < 2 ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	ll k;
	cin>>k;
	ll arr[n];
	//ll akk[k];
	ll ktermsM=1;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		if(i<k){
			//akk[i]=arr[i];
			ktermsM=ktermsM*arr[i];

		}
	}
	//cout<<ktermsM<<endl;
	ll newKterms=1;
	ll j=0;
	//ll flag=0;
	for(ll i=k;i<n;i++){
		if(arr[i]>arr[j]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
		
		j++;

	}

	/*for(ll i=k;i<n;i++){
		newKterms=ktermsM/arr[j];
		newKterms=newKterms*arr[i];
		if(ktermsM>=newKterms){
			cout<<"No"<<endl;
			//flag=1;
			//break;
		}else{
			cout<<"Yes"<<endl;
		}

		ktermsM=newKterms;
		j++;

	}*/
  return 0;

}

Measured memory_bytes: 5104
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] line = br.readLine().split(" ");
        int x1 = Integer.parseInt(line[0]);
        int y1 = Integer.parseInt(line[1]);
        int x2 = Integer.parseInt(line[2]);
        int y2 = Integer.parseInt(line[3]);
        int[] vec1 = {x2 - x1, y2 - y1};
        int[] vec2 = {-1 * vec1[1], vec1[0]};
        out.println(new StringBuilder()
            .append(x2 + vec2[0])
            .append(" ")
            .append(y2 + vec2[1])
            .append(" ")
            .append(x1 + vec2[0])
            .append(" ")
            .append(y1 + vec2[1])
            .toString());
        out.close();
    }
}

Measured memory_bytes: 20820
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al=lin()
	vm=10**6+1
	rr = [0]*(vm)
	for v in al:
		rr[v]+=1
	ual=list(set(al))
	ual.sort()
	for v in ual:
		if rr[v]==0:
			continue
		for i in range(2*v, vm, v):
			rr[i]=0
	ret = rr.count(1)
	print(ret)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

int n, m;
int a[111111];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		a[u]++;
		a[v]++;
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] & 1)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

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

string s, ans;
vector<char> v;

int main() {
  ans = "yes";
  cin >> s;
  rep (i, s.size()) {
    if (find(v.begin(), v.end(), s.at(i)) == v.end()) {
      v.push_back(s.at(i));
    }else{
      ans = "no";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static String[][] s;


    private static boolean hasNeighbor(int h, int w) {
        return (h != 0 && "#".equals(s[h - 1][w]))
                || (h != s.length - 1 && "#".equals(s[h + 1][w]))
                || (w != 0 && "#".equals(s[h][w - 1]))
                || (w != s[h].length - 1 && "#".equals(s[h][w + 1]));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        s = new String[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next().split("");
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (".".equals(s[i][j])) {
                    continue;
                }
                if (!hasNeighbor(i, j)) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }

}


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

using namespace std;
using ll = long long;


int main(){
  int H, W;
  cin >> H >> W;
  
  int left[H][W], right[H][W], up[H][W], down[H][W];
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      left[i][j] = 0;
      right[i][j] = 0;
      up[i][j] = 0;
      down[i][j] = 0;
    }
  }
  
  vector<string> S(H);
  for (int i=0; i<H; i++) cin >> S[i];
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]=='.'){
      	if(j==0){
          left[i][j] = 1;
        }else{
          left[i][j] = left[i][j-1] + 1;
        }
      }
    }
  }
  
   for(int i=0; i<H; i++){
    for(int j=W-1; j>=0; j--){
      if(S[i][j]=='.'){
      	if(j==W-1){
          right[i][j] = 1;
        }else{
          right[i][j] = right[i][j+1] + 1;
        }
      }
   
    }
   }
  
  
   for(int i=0; i<W; i++){
    for(int j=H-1; j>=0; j--){
      if(S[j][i]=='.'){
        if(j==H-1){
          down[j][i] = 1;
        }else{
          down[j][i] = down[j+1][i] + 1;
        }
      }
      
    }
  }
  
  
  for(int i=0; i<W; i++){
    for(int j=0; j<H; j++){
      if(S[j][i]=='.'){
        if(j==0){
          up[j][i] = 1;
        }else{
          up[j][i] = up[j-1][i] + 1;
        }
      }
      
    }
  }
  
  
  
  int res = 0;
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]=='#') continue;
      res = max(res, left[i][j]+right[i][j]+up[i][j]+down[i][j]-3);
    }
  }
  
  cout << res << endl;
 
  return 0;
}

Measured memory_bytes: 73732
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

int main() {
  std::string L;
  std::cin >> L;
  L.reserve();
  std::vector<long long> dp1(L.size(), 0), dp2(L.size(), 0);
  dp1[0] = 2;
  dp2[0] = 1;
  for (int i = 1; i < L.size(); ++i)
  {
    if (L[i] == '0')
    {
      dp1[i] = dp1[i - 1];
      dp2[i] = (dp2[i - 1] * 3) % MOD;
    }
    else
    {
      dp1[i] = (dp1[i - 1] * 2) % MOD;
      dp2[i] = (dp1[i - 1] + dp2[i - 1] * 3) % MOD;
    }
  }
  std::cout << (dp1.back() + dp2.back()) % MOD << std::endl;
  return 0;
}



Measured memory_bytes: 2044
c = [list(map(int,input().split())) for _ in range(3)]

def check(c):
  for a1 in range(c[0][0]):
    b = [c[0][i] - a1 for i in range(3)]
    a = [a1] + [c[i][0] - b[0] for i in range(1,3)]

    for ai in range(len(a)):
      for bi in range(len(b)):  
        if c[ai][bi] != a[ai]+b[bi]:
          print('No')
          return
  print('Yes')

check(c)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,ans=0,nowx,nowy,temp;

int main(){
    cin>>N;
    int A[N][2];
    rep(i,2){
        rep(j,N){
            cin>>A[j][i];
        }
    }
    rep(i,N){
        nowx=0;
        nowy=0;
        temp=A[0][0];
        rep(j,N){
            if(i==j)nowy++;
            else nowx++;
            temp+=A[nowx][nowy];
            // printf("x:%d y:%d temp:%d A[x][y]:%d\n",nowx,nowy,temp,A[nowx][nowy]);
        }
        // printf("x:%d y:%d\n",nowx,nowy);
        // out(temp);
        ans=max(ans,temp);
    }
    out(ans);
    // out(A[0][0]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=1e5+5;
int mul(int a,int b){return (long long)a*b;}
typedef long long ll;
int n,x[N],y[N],d[N];
const double inf=1e20;
double getans(double mid)
{
    double mnx=inf,mxx=-inf,mny=inf,mxy=-inf;
    for(int i=1;i<=n;i++)
    {
        double xx=x[i],yy=y[i];
        if(d[i]==1) xx-=mid;
        if(d[i]==2) xx+=mid;
        if(d[i]==3) yy+=mid;
        if(d[i]==4) yy-=mid;
        mnx=min(mnx,xx);
        mxx=max(mxx,xx);
        mny=min(mny,yy);
        mxy=max(mxy,yy);
    }
    return (mxx-mnx)*(mxy-mny);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char s[5];
        scanf("%d%d%s",&x[i],&y[i],s);
        if(s[0]=='L') d[i]=1;
        else if(s[0]=='R') d[i]=2;
        else if(s[0]=='U') d[i]=3;
        else d[i]=4;
    }
    double l=0,r=1e8;
    for(int i=1;i<=1000;i++)
    {
        double len=(r-l)/3,mid=l+len,midmid=l+2*len;
        if(getans(midmid)>=getans(mid)) r=midmid;
        else l=mid;
    }
    printf("%f\n",getans((r+l)/2));
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=155;
int n,K,P;
namespace sub1{
	int f[N][N];
	void sol(){
		f[0][0]=1;
		K/=2;
		rep(i,1,(n+1)/2){
			rep(j,0,K)(f[i][0]+=f[i-1][j])%=P;
			rep(j,1,K)(f[i][j]+=f[i-1][j-1])%=P;
		}
		int ans1=0,ans2=0;
		rep(i,0,K)(ans1+=f[n/2][i])%=P,(ans2+=f[(n+1)/2][i])%=P;
		printf("%lld\n",1LL*ans1*ans2%P);
	}
}
namespace sub2{
	int f[N][N][N];
	void sol(){
		f[0][0][0]=1;
		int T=(n+(++K))/2;
		rep(i,1,T)rep(j,0,K)rep(k,0,i){
			int w=f[i-1][j][k],x=2*i-1;
			(f[i][0][0]+=w)%=P;
			if(x>=K){
				(f[i][j?j+1:0][0]+=w)%=P;
			}
			if(x<=n){
				(f[i][0][k+1]+=w)%=P;
			}
			if(K<=x&&x<=n){
				(f[i][max(j+1,k+2)][k+1]+=w)%=P;
			}
		}
		int ans=0;
		rep(j,0,K)rep(k,0,n)(ans+=f[T][j][k])%=P;
		printf("%d\n",ans);
	}
}
int main(){
	scanf("%d%d%d",&n,&K,&P);
	if(K%2==0){
		sub1::sol();
	}else{
		sub2::sol();
	}
	return 0;
}

Measured memory_bytes: 11068
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

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

    sort(A.begin(), A.end());

    vector<long long> cumsum(N+1);
    for (int i = 0; i < N; i++) {
        cumsum[i+1] += cumsum[i] + A[i];
    }

    long long ans = 1LL<<60;
    for (int i = 0; i <= N; i++) {
        long long tmp = -cumsum[i] + cumsum[N] - cumsum[i];

        long long add = 1LL<<60;
        if (i > 0) add = A[i-1] * (i - (N-i));
        if (i < N) add = min(add, A[i] * (i - (N-i)));
        tmp += add;

        ans = min(ans, tmp);
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 6304
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=m/n;i>=1;i--)
	{
		if(m%i==0)
		{
			int t=m/i;
			if(t>=n)
			{
				cout<<i<<endl;
				break;
			}
		}
	}
}

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

using namespace std;

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

    int ans = 0;
    for(int i=0; i<S.length()/2; ++i){
        if(S[i] != S[S.length()-1-i]){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
struct unionfind{
    vector<int> rank,parent,size;
    int independent_tree;
    int N;
    
    unionfind(int n){
        N=n;
        for(int i=0;i<n;i++){
            rank.push_back(1);
            parent.push_back(i);
            size.push_back(1);
            independent_tree=N;
        }
    }
    int getroot(int x){
        if(parent[x]==x)
            return x;
        return parent[x]=getroot(parent[x]);
    }
    bool issame(int a,int b){
        return getroot(a)==getroot(b);
    }
    void unite(int a,int b){
        a=getroot(a);
        b=getroot(b);
        if(a==b)
            return;
        else if(rank[a]>rank[b]){
            parent[b]=a;
            size[a]+=size[b];
        }
        else if(rank[a]==rank[b]){
            parent[b]=a;
            rank[a]++;
            size[a]+=size[b];
        }
        else{
            parent[a]=b;
            size[b]+=size[a];
        }
    }
};
//---------------------------------------------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;
    cin>>n;
    ll ans=0;
    ll now;
    for(ll i=1;i<=n;i++)
    {
        ans+=i;
        if(ans+i+1>n)
        {
            now=i+1;
            break;}
        else if(ans+i+1==n)
        {
            for(int j=1;j<=i+1;j++)
                cout<<j<<endl;
            return 0;
        }
    }
    ll c=n-ans;
    ll d=ans+now-n;
    for(int j=1;j<=now;j++)
    {
        if(j!=d)
            cout<<j<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

int d, g;
vector<int> p(10), c(10);

int dfs(int ct, int score, vector<int> f)
{
    if (ct == d + 1)
    {
        int q = 0;
        for (int i = d - 1; i >= 0; i--)
        {
            if (!f.at(i))
            {
                while (score + q * (i + 1) * 100 < g && q < p.at(i))
                    q++;
                if (q == p.at(i))
                    return INT_MAX;
                break;
            }
        }
        for (int i = 0; i < d; i++)
            if (f.at(i))
                q += p.at(i);
        return q;
    }
    f.push_back(1);
    int a = dfs(ct + 1, score + p.at(ct - 1) * ct * 100 + c.at(ct - 1), f);
    f.back() = 0;
    int b = dfs(ct + 1, score, f);
    return min(a, b);
}

int main()
{
    cin >> d >> g;
    for (int i = 0; i < d; i++)
        cin >> p.at(i) >> c.at(i);
    vector<int> v(0);
    cout << dfs(1, 0, v) << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
i = 0
while(i <= N - M):
    x = A[i].find(B[0])
    while(N - M >= x and x >= 0):
        for j in range(1,M):
            if A[i+j][x:x+M] != B[j]:
                x = A[i].find(B[0], x+1)
                break
        else:
            print("Yes")
            exit()
    i += 1
print("No")


Measured memory_bytes: 3064
import java.util.*;


public class Main {

    private static final int INF = 1000000007;
    private static final int INF1 = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(n*3*n);
    }
}


Measured memory_bytes: 21844
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: String -> Int
calc [] = 0
calc ss = k + calc ss4
  where
    len_ss = length ss
    (ss1, ss2) = span (== '<') ss
    (ss3, ss4) = span (== '>') ss2
    len_ss1 = length ss1
    len_ss3 = length ss3
    k = sigma len_ss1 + sigma len_ss3 - minimum [len_ss1, len_ss3]

sigma :: Int -> Int
sigma n = (n * (n + 1)) `div` 2

main = do
  [s] <- getString
  print $ calc s


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll r, g, b, n;
  cin >> r >> g >> b >> n;


  vector<ll> dp(n+5, 0);
  dp[0]++;

  rep(x, n+5){
    if(0 <= x-r) dp[x] += dp[x-r];
  }

  rep(x, n+5){
    if(0 <= x-g) dp[x] += dp[x-g];
  }

  rep(x, n+5){
    if(0 <= x-b) dp[x] += dp[x-b];
  }

  cout << dp[n] << endl;


  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N, Q;

vector<ll> waru(ll x) {
  vector<ll> ans;
  ans.push_back(x);
  while (x > 0) {
    x = (x-1)/N;
    ans.push_back(x);
  }
  reverse(ans.begin(), ans.end());
  return ans;
}

ll solve(ll x, ll y) {
  if (N == 1) {
    return min(x, y);
  }
  vector<ll> V = waru(x);
  vector<ll> W = waru(y);
  int ind = 0;
  ll ans = 0;
  while (ind < (int)V.size() && ind < (int)W.size()) {
    if (V[ind] == W[ind]) {
      ans = V[ind];
      ind++;
    } else {
      break;
    }
  }
  return ans;
}

int main () {
  cin >> N >> Q;
  for (auto i = 0; i < Q; ++i) {
    ll v, w;
    cin >> v >> w;
    v--;
    w--;
    cout << solve(v, w) + 1 << endl;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
     
    using namespace std;
     
    int a[5];
     
    int main()
    {
    	cin >> a[0] >> a[1] >> a[2];
      	cout << min(a[0] + a[1], min(a[1] + a[2], a[2] + a[0]));
      	return 0;
    }

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

using namespace std;

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

    string s = "MARCH";
    int c[5] = {};
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        for (int j = 0; j < 5; j++) if (t[0] == s[j]) c[j]++;
    }

    long long ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += 1LL * c[i] * c[j] * c[k];
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

signed main(){
	ll n;
	cin>>n;
	ll ans=0;
	vector<ll>a(n+1),b(n);
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n){
		ll left=min(a[i],b[i]);
		a[i]-=left;
		b[i]-=left;
		ans+=left;
		ll right=min(a[i+1],b[i]);
		a[i+1]-=right;
		ans+=right;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    string alice = "Alice", brown = "Brown";
    long long x, y;
    cin >> x >> y;

    if (x < y)
        swap(x, y);

    bool res = x - y >= 2;
    cout << (res ? alice : brown) << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
tasks = []
for _ in range(n):
    a,b = map(int, input().split())
    tasks.append([a,b])

tasks.sort()
tasks = sorted( tasks, key = lambda a: a[1] )

time = 0
flg = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        flg = 1
print( 'No' if flg else 'Yes' )

Measured memory_bytes: 89304
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long a, b, c, s, i, j, k, aa, bb, cc, n, ans, x;

	cin >> n >> x;
	vector<long long> v(n);
	for (i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	ans = 0;
	for (auto p : v) {
		if (x >= p) {
			x -= p; 
			ans++;
		}
	}
	if ((ans == n) && (x > 0)) ans--;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256