akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

// chmax, chmin
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;
}

void solve(long long N, std::vector<long long> u, std::vector<long long> v) {

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += 1ll * (i + 1) * (N - i);
    }
    for (int i = 0; i < N - 1; i++) {
        ans -= 1ll * min(u[i], v[i]) * (N - max(u[i], v[i]) + 1);
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> u(N - 1);
    std::vector<long long> v(N - 1);
    for (int i = 0; i < N - 1; i++) {
        scanf("%lld", &u[i]);
        scanf("%lld", &v[i]);
    }
    solve(N, std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 6432
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
const unsigned long long MOD = 100000000000000000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF -1//INT_MAX/3
#define MAX_N 100000

void solve(){
  int ans=0,n;
  int a[MAX_N+1];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> v;
  for(int i=0;i<n;i+=2){
    v.push_back(a[i]);
  }
  sort(a,a+n);
  multiset<int>s;
  for(int i=0;i<n;i+=2){
    s.insert(a[i]);
  }
  for(int i=0;i<v.size();i++){
    if(s.count(v[i])){
      s.erase(s.find(v[i]));
    } else {
      ans++;
    }
  }
  cout<<ans<<endl;
  return ;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 3196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForce
{



    class CF
    {

        static void Main(string[] args)
        {
            var numbers = new List<long>(Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x)));
            numbers[0] %= numbers[1];
            Console.WriteLine(Math.Min(numbers[0], numbers[1] - numbers[0]));
        }
    }
}


Measured memory_bytes: 13268
x, y, z = gets.chomp.split(" ").map(&:to_i)
# haba = 0
# count = 0
# while true
#     haba += z
# 	if haba > x
#       break
#     end
# 	haba += y
# 	if haba > x
#       break
#     end
#   	count += 1
	
# end
haba = x - z
ans = haba / (y + z)
puts ans


Measured memory_bytes: 14308
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AA = []
for i in range(N):
    if i == 0:
        AA.append(A[i])
    else:
        AA.append(A[i])
        AA.append(A[i])
AA.sort(reverse=True)
ans = 0
for i in range(N-1):
    ans += AA[i]
print(ans)


Measured memory_bytes: 31620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 131072
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 2147483647;
//__gcd(a,b), __builtin_popcount(a);

int n;
ll dat[MAX*2], add[MAX*2];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
	for(int i = 0;i < 2*n;i++)dat[i] = INF;
	for(int i = 0;i < 2*n;i++)add[i] = -1;
}

void lazy_update(int k){
	if(add[k] == -1)return;
	if(k < n-1){
		add[k*2+1] = add[k];
		add[k*2+2] = add[k];
	}
	add[k] = -1;
}

void update(int a, int b, int x, int k, int l, int r){
	if(r <= a || b <= l)return;
	if(a <= l && r <= b){
		add[k] = dat[k] = x;
		lazy_update(k);
		return;
	}
	if(add[k] != -1)dat[k] = add[k];
	lazy_update(k);
	update(a, b, x, k*2+1, l, (l+r)/2);
	update(a, b, x, k*2+2, (l+r)/2, r);
	ll t1 = dat[k*2+1], t2 = dat[k*2+2];
	if(add[k*2+1] != -1)t1 = add[k*2+1];
	if(add[k*2+2] != -1)t2 = add[k*2+2];
	dat[k] = min(t1, t2);
	return;
}

ll find(int a, int b, int k, int l, int r){
	if(r <= a || b <= l)return INF;
	if(a <= l && r <= b){
		if(add[k] != -1){
			dat[k] = add[k];
		}
		lazy_update(k);
		return dat[k];
	}
	if(add[k] != -1)dat[k] = add[k];
	lazy_update(k);
	ll vl = find(a, b, k*2+1, l, (l+r)/2);
	ll vr = find(a, b, k*2+2, (l+r)/2, r);
	ll t1 = dat[k*2+1], t2 = dat[k*2+2];
	if(add[k*2+1] != -1)t1 = add[k*2+1];
	if(add[k*2+2] != -1)t2 = add[k*2+2];
	return min(vr, vl);
}

int main(){
	int m, q, c, s, t, x;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d", &c);
		if(c == 0){
			scanf("%d%d%d", &s, &t, &x);
			update(s, t+1, x, 0, 0, n);
		}else{
			scanf("%d%d", &s, &t);
			ll ans = find(s, t+1, 0, 0, n);
			printf("%lld\n", ans);
		}
	}
	/*rep(i,2*n-1)printf("%d ", dat[i]);
	printf("\n");
	rep(i,2*n-1)printf("%d ", add[i]);*/
	return 0;
}



Measured memory_bytes: 7264
#include<bits/stdc++.h>
using namespace std;
int n;
string str;
string res;
map<char,char> o;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n;
    cin>>str;
    res="";
    for(int i=0;i<n;i++)
        res+="?";
    o['S']='W';
    o['W']='S';
    res[0]='S';
    res[n-1]='S';
    while(1){
        bool flg=true;
        for(int i=0;i<n;i++){
            if(res[i]=='S'&&str[i]=='o'||res[i]=='W'&&str[i]=='x'){
                if(res[(i-1+n)%n]!=res[(i+1)%n]&&res[(i+1)%n]!='?')
                {	
                    flg=false;
                    break; 
                }
                res[(i+1)%n]=res[(i-1+n)%n];
            }
            else{
                if(res[(i-1+n)%n]==res[(i+1)%n]&&res[(i+1)%n]!='?')
                {
                    flg=false;
                    break; 
                }
                res[(i+1)%n]=o[res[(i-1+n)%n]];
            }
        }
        if(flg==true){
            cout<<res<<endl;
            return 0;
        }
        for(int i=1;i<n-1;i++)
            res[i]='?';
        if(res[0]=='S'&&res[n-1]=='S')
            res[n-1]='W';
        else if(res[0]=='S'&&res[n-1]=='W')
            res[n-1]='S',res[0]='W';
        else if(res[0]=='W'&&res[n-1]=='S')
            res[n-1]='W';
        else
            break;
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		scan.close();
		
		String out = null;
		if (str.length() == 2) {
			out = str;
		} else if(str.length() == 3) {
			out = String.valueOf(str.charAt(2))
					+ String.valueOf(str.charAt(1))
					+ String.valueOf(str.charAt(0));
		} else {
			out = "文字列は2文字または3文字で入力してください";
		}
		
		System.out.println(out);
	}

}


Measured memory_bytes: 23252
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    ll k=pow(3,N);
    vl x(N),y(N),p(N);
    ll memo_tate[N][(int)pow(2,N)],memo_yoko[N][(int)pow(2,N)];//bitが1の時あるとする
    rep(i,N){
        cin >> x[i] >> y[i] >> p[i];
    }
  	rep(i,N){
      	rep(j,1<<N){
          	memo_tate[i][j]=memo_yoko[i][j]=INF;
        }
    }
    rep(i,1<<N){
        rep(j,N){
            rep(k,N){
                if((i>>k)%2==1){
                    memo_tate[j][i]=min(memo_tate[j][i],abs(x[k]-x[j])*p[j]);
                }
                memo_tate[j][i]=min(memo_tate[j][i],abs(x[j])*p[j]);
            }
        }
    }
    rep(i,1<<N){
        rep(j,N){
            rep(k,N){
                if((i>>k)%2==1){
                    memo_yoko[j][i]=min(memo_yoko[j][i],abs(y[k]-y[j])*p[j]);
                }
                memo_yoko[j][i]=min(memo_yoko[j][i],abs(y[j])*p[j]);
            }
        }
    }
    rep(i,N){
      	rep(j,1<<N){
          	//cout << memo_tate[i][j] << endl;
        }
    }
    vl ans(N+1,INF);
    rep(trit,k){
        int x=trit;//今見てるtritが0ならなし、1なら横のみ、2なら縦のみに通っていると考える
        int now_bit=1;
        ll tate=0,yoko=0;
        ll res=0,now=0;
        while(x){
            int b=x%3;
            if(b==1){
                yoko+=now_bit;
                res++;
            }
            if(b==2){
                tate+=now_bit;
              	res++;
            }
            now_bit*=2;
            x-=b;
            x/=3;
        }
        //cout << tate << " " << yoko << endl;
        rep(i,N){
            now+=min(memo_tate[i][tate],memo_yoko[i][yoko]);
        }
        ans[res]=min(ans[res],now);
    }
    rep(i,N+1){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 11768
N, Q = map(int,input().split())
nord = [set() for i in range(N)]

for i in range(N-1):
    a, b = map(int,input().split())
    nord[b-1].add(a-1)
    
nord_num = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int,input().split())
    nord_num[p-1] = nord_num[p-1] + x
    
for i in range(N):
    for j in nord[i]:
        nord_num[i] = nord_num[j] + nord_num[i]
        
count = 1
for i in nord_num:
    if count == N:
        print(i)
    else:
        print(i, end=" ")
        count += 1

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

using namespace std;

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

    int n=str.length();

    if(str[n-1]=='s'){
        str=str+"es";
    }
    else{
        str=str+"s";
    }

    cout<<str<<'\n';

    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> X(N);
    REP(i, N) cin >> X[i];

    vector<int> B = X;
    SORT(B);
    int l = B[N / 2 - 1];
    int r = B[N / 2];

    REP(i, N) {
        if (X[i] <= l) {
            cout << r << '\n';
        } else {
            cout << l << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 3840
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
 
N = int(input())
A = list(map(int, input().split()))

L = [0, 0]
for ai in A:
    L.append(gcd(L[-1], ai))

R = [0, 0]
for ai in A[::-1]:
    R.append(gcd(R[-1], ai))
 
print(max(gcd(l, r) for l, r in zip(L, reversed(R))))

Measured memory_bytes: 14076
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        String S = reader.next();
        String T = reader.next();
        for (int i=0; i<N; i++) {
            System.out.print(S.charAt(i));
            System.out.print(T.charAt(i));
        }
        System.out.println();
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int 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 int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 2e18+5;
 
void solve()
  {
     int n;
     int x = 0;
     cin>>n;
     vector<int> v(n);
     loop(i,0,n){
      cin>>v[i];
      x ^= v[i];
     } 
     loop(i,0,n){
      cout<<(x^v[i])<<" ";
     }
  }
signed main()
 {
   
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

       solve();    
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define pi acos(-1)
#define el << endl
#define yes cout << "YES" <<  endl
#define no cout << "NO" << endl
#define show(x) cout << x << endl
#define impossible cout<< "impossible" << endl
#define tc int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const ll maxn = 2e5+10;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	ll n;
	cin>>n;
	cout << n+n*n+n*n*n << endl;



	return 0;
}
///Alhamdulillah
///Full: me




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

using namespace std;

typedef long long ll;

const int maxn = 800 + 50;
const int mod = 1e9 + 7;

int adjx[] = {0, 1, 0, -1};
int adjy[] = {1, 0, -1, 0};

string s[maxn];
int h[maxn][maxn];
int k;

bool inrange(int l, int m, int r){
	return l <= m and m < r;
}

int dis(int a, int b){
	return (abs(a - b) + k - 1) / k;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	
	memset(h, -1, sizeof h);
	queue<pair<int, int> > q;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (s[i][j] == 'S')
				q.push({i, j}), h[i][j] = 0;
	while (!q.empty()){
		int x = q.front().first, y = q.front().second;
		q.pop();
		for (int z = 0; z < 4; z++){
			int nx = x + adjx[z], ny = y + adjy[z];
			if (!inrange(0, nx, n) or !inrange(0, ny, m) or h[nx][ny] != -1 or s[nx][ny] == '#')
				continue;
			h[nx][ny] = h[x][y] + 1;
			q.push({nx, ny});
		}
	}
	int answer = n + m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (h[i][j] == -1 or h[i][j] > k)
				continue;
			if (i == 0 or j == 0 or i == n - 1 or j == m - 1)
				return cout << 1 << endl, 0;
			int mx = min(dis(0, i), dis(i, n - 1));
			int my = min(dis(0, j), dis(j, m - 1));
			
			answer = min(answer, min(mx, my) + 1);
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    double r;

    cin >> r;

    printf("%.10f\n", r * 2 * M_PI);
}


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


int main(){
    int c[3][3];
    rep(i,3)rep(j,3) cin >> c[i][j];
    if(c[1][0]-c[0][0]==c[1][1]-c[0][1] && c[1][1]-c[0][1]==c[1][2]-c[0][2]){
        if(c[2][0]-c[0][0]==c[2][1]-c[0][1] && c[2][1]-c[0][1]==c[2][2]-c[0][2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; ;)
		{
			int n = scanner.nextInt();
			if(n == 0)
			{
				break;
			}
			
			int count = 0;
			int[] s = new int[n];
			int[] c = new int[n];
			int[] p = new int[n];
			boolean is_input = true;
			for(; ;)
			{
				int[] num_cnt = new int[100];
				for(int i=0; i<n; i++)
				{
					if(is_input)
					{
						s[i] = scanner.nextInt();
					}
					else
					{
						s[i] = c[i];
					}
					
					num_cnt[s[i]-1] ++;
				}
				
				
				for(int i=0; i<n; i++)
				{
					c[i] = num_cnt[s[i]-1];
				}
				
				boolean is_loopend = true;
				for(int i=0; i<n; i++)
				{
					if(is_input)
					{
						if(n == s[0])
						{
							if(s[0] != s[i])
							{
								is_loopend = false;
							}
						}
						else
						{
							is_loopend = false;
						}
					}
					else
					{
						if(p[i] != c[i])
						{
							is_loopend = false;
						}
					}
				}
				
				if(is_loopend)
				{
					System.out.println(count);
					for(int i=0; i<n; i++)
					{
						System.out.print((i>0?" ":"") + c[i]);
					}
					System.out.println("");
					break;
				}
				
				count ++;
				is_input = false;
				for(int i=0; i<n; i++)
				{
					p[i] = c[i];
				}
			}
		}
	}
}

Measured memory_bytes: 31464
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n;
  cin >> n;
  i64 x = n % 1000, y = n / 10;
  if (x % 111 == 0 || y % 111 == 0) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N);
  long long k=0;
  for (int i=0; i<N; i++){
    cin >> A[i];
    k+=A[i];
  }
  if (k%(N*(N+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }
  k/=N*(N+1)/2;
  vector<long long> B(N);
  for (int i=0; i<N; i++){
    B[i] = A[(i+1)%N] - A[i];
    B[i] -= k;
  }
  for (int i=0; i<N; i++){
    if (B[i] > 0){
      cout << "NO" << endl;
      return 0;
    }
    if ((-B[i])%N != 0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1792
$n = gets.chomp.to_i
$a = []
$a[0] = gets.chomp.split(" ").map(&:to_i)
$a[1] = gets.chomp.split(" ").map(&:to_i)
$max = 0
def dfs(x,y,count)
    if y == 1 and x == $n-1
        $max = [count + $a[y][x], $max].max
    else
        if y >= 1
            dfs(x+1,y,count + $a[y][x])
        elsif x >= ($n - 1)
          dfs(x, y+1,count + $a[y][x])
        else
            dfs(x+1,y,count + $a[y][x])
            dfs(x,y+1,count + $a[y][x])
        end
    end
end
dfs(0,0,0)
print($max)

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    string s;
    cin >> s;

    char prev = 'Z';
    vector<char> arr;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            arr.push_back(s[i]);
            prev = s[i];
            continue;
        }
        if (prev == s[i]) {
        } else {
            arr.push_back(s[i]);
        }
        prev = s[i];
    }
    cout << arr.size() << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int a,b;
        scanf("%i",&a);
        scanf("%i",&b);
        int c=a*b;
        int d=(a*2)+(b*2);
        printf("%i %i\n",c,d);
        return 0;
    }


Measured memory_bytes: 2028
import sys
import collections
import bisect as bs
input=sys.stdin.readline
n,m=map(int,input().split())
d=collections.defaultdict(list)
L=[]
for i in range(m):
    a,b=map(int,input().split())
    L.append((a,b))
for x,y in sorted(L):
    d[x].append(y)
for x,y in L:
    z=bs.bisect(d[x],y)
    print("%06d%06d"%(x,z))

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

int main() {
  string S,T;
  cin>>S>>T;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      cout<<"No"<< endl;
      return 0;
    }
  }
  cout<<"Yes"<< endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, int> pli;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

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

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

int main()
{
  long long N,M;
  cin>>N>>M;
  multiset<pair<long long,long long>> vec;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    vec.insert(make_pair(a,-b));
  }
  
  long long sum=0;
  auto itr = vec.begin();
  while(M!=0){    
    if(M>=(-1*(*itr).second)){
      sum+=(*itr).first*(-1*(*itr).second);
      M-=(-1)*(*itr).second;
      itr++;
    }
    else{
      sum+=(*itr).first*M;
      M=0;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int main()
{
	LL a,b,c,d;
	LL ans=0;
	scan(a,b),scan(c,d);
	b=min(b,2*a);
	c=min(c,2*b);
	d=min(d,2*c);
	LL wkwk;
	scan(wkwk);
	ans=(wkwk/2)*d+(wkwk%2)*c;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
a = list(map(int, input().split()))

cs = list(itertools.accumulate(a)) + [0]

def score(l, r):
    return cs[r] - cs[l - 1]

dp = [[None] * (n + 1) for _ in range(n + 1)]
def dfs(l=0, r=n):
    if dp[l][r] is not None:
        return dp[l][r]

    if r - l == 2:
        # print(l, r, "end", a[l] + a[r - 1])
        value = a[l] + a[r - 1]
        dp[l][r] = value
        return value
    if r - l == 1:
        dp[l][r] = 0
        return 0

    scores = [dfs(l, c) + score(l, c - 1) + dfs(c, r) + score(c, r - 1) for c in range(l + 1, r)]
    value = min(scores)
    dp[l][r] = value
    return value

# print(dfs())
for l in reversed(range(n + 1)):
    for r in range(l + 1, n + 1):
        if r - l == 2:
            value = a[l] + a[r - 1]
            dp[l][r] = value
            continue
        if r - l == 1:
            dp[l][r] = 0
            continue

        scores = [dp[l][c] + score(l, c - 1) + dp[c][r] + score(c, r - 1) for c in range(l + 1, r)]
        value = min(scores)
        dp[l][r] = value
print(dp[0][n])


Measured memory_bytes: 45660
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int Maxn = 200010;

int a[Maxn], b[Maxn];

int n;

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

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    vector<int> ans;
    for (int i = n; i >= 1; --i) {
        int sum = 0;
        for (int j = 2; i * j <= n; ++j) {
            sum += b[i * j];
        }
        if (sum % 2 != a[i]) {
            ans.emplace_back(i);
            b[i] = 1;
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for (int i = 0; i < (int) ans.size(); ++i) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(int argc, const char * argv[]) {
    
   
    
    int N; cin >> N;
    int happiness[N][3];
    int  dp[100010][3];
    for (int i = 0; i < N; i++) {
        cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
    }
    //first day
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    
    for (int i = 1; i <= N; i++) {
        dp[i][0] = max(dp[i-1][1] + happiness[i-1][1], dp[i-1][2] + happiness[i-1][2]);
        dp[i][1] = max(dp[i-1][2] + happiness[i-1][2], dp[i-1][0] + happiness[i-1][0]);
        dp[i][2] = max(dp[i-1][0] + happiness[i-1][0], dp[i-1][1] + happiness[i-1][1]);
    }
    
    cout << max( { dp[N][0], dp[N][1], dp[N][2] }) << endl;
    
    
    
    
    
    
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	bool flag = false;
	if (a <= 0 && b >= 0) flag = true;
	if (c <= 0 && d >= 0) flag = true;
	long long add;
	if (flag) add = 0;
	else add = b * d;
	cout << max({a * c, a * d, b * c, b * d, add}) << endl;
	return (0);
}


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

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

int main(void){
  int a, b;
  cin >> a >> b;
  if(a - 2 * b >= 0) cout << a-2*b << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	h, w = LI()
	original = GRIDfromString(h, w)
	modified = np.full((2*h,w), b'')
	for i in range(2*h):
		modified[i] = original[i//2]
	for modified_line in modified:
		for modified_point in modified_line:
			print(modified_point.decode(),end='')
		print('\r')

if __name__ == '__main__':
    main()

Measured memory_bytes: 27280
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize,
    }
    let ans_a = if a >= k { a - k } else { 0 };
    let ans_b = if a >= k {
        b
    } else if a + b >= k {
        a + b - k
    } else {
        0
    };
    println!("{} {}", ans_a, ans_b);
}


Measured memory_bytes: 4352
#include <stdio.h>
int MAX=0;
int main ()
{
	int n, an=1, t;
	scanf("%d", &n);
	for (int i=1; i<=n;i++)
	{
		t=i;
		int m=0;
		while(t)
		{
		
			if (t%2!=0) 
				break;
			if (t%2==0)
			{
				t= t/2;
				m++;
				continue;
			}
				
		}
		if (m>MAX) 
		{
			MAX=m;
			an=i;
		}

	
	}
	printf("%d\n",an);
}

Measured memory_bytes: 256
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<pl, ll>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll  i, j,n, a[mx];
	cin>>n;
	string s, t;
    cin>>s>>t;

    rep(i, 0, n)
    cout<<s[i]<<t[i];
	
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x)  push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  ll  long long
#define  maxm(a,b,c)  max(a,max(b,c))
int mod = 1e9+7;
ll dp[110][100010];
int main(){
	 int n,k;
	 cin>>n>>k;
	 int a[n+1];
	 for(int i = 1;i<=n;++i){
	 	  cin>>a[i];
	 }
	 for(int j = 0;j<=k;++j){
	 	  dp[1][j] = (j>a[1]) ? 0 : 1;
	 }
	 for(int i = 2;i<=n;++i){
	 	 for(int j = 0;j<=k;++j){
	 	 	  if(j == 0)dp[i][j]  = dp[i-1][j];
	 	 	  else dp[i][j] = (mod+dp[i][j-1]+dp[i-1][j] - ((j-a[i]-1 >= 0) ? dp[i-1][j-a[i]-1] : 0))%mod;
		  }
	 }
	 cout<<dp[n][k];
}

Measured memory_bytes: 79360
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char s[10];
	cin>>s;
	if(s[3]==s[2]&&s[4]==s[5])cout<<"Yes"<<endl;
	  else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import deque
import heapq


def solve(N, M, A, B):
    ans = 0
    # 日付順にソートする
    all_works = deque(sorted(zip(A, B), key=lambda x: x[0]))
    pq = []

    for d in range(1, M+1):
        # print('d=', d)
        # 今日が期限の仕事があれば追加
        while all_works and all_works[0][0] == d:
            work = all_works.popleft()
            # 最小値優先なのでマイナスをつける
            heapq.heappush(pq, -work[1])
        if pq:
            work = heapq.heappop(pq)
            ans -= work

    return ans


if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for idx in range(N):
        A[idx], B[idx] = map(int, input().split())

    ans = solve(N, M, A, B)

    print(ans)


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

int main(){
    int n,tmp;
    cin >> n;
    tmp = n;

    int a[4];
    int i=0;
    while(tmp){
        a[i] = tmp%10;
        tmp /= 10;
        i++;
    }

    if ((a[0]==a[1] && a[1]==a[2]) || (a[1]==a[2] && a[2]==a[3]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is, 1<<h) rep(js, 1<<w) {
    int cnt = 0;
    rep(i,h) rep(j,w) {
      if(is>>i & 1) continue;
      if(js>>j & 1) continue;
      if(s[i][j] == '#') cnt++;
    }
    if(cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;



int main() {
    ll K,T;
    cin >> K >> T;

    vl a(T);
    for(int i=0; i<T; i++)
	cin >> a[i];

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll sum=0;
    for(int i=1; i<T; i++) sum += a[i];

    ll ans = 0;
    if( a[0] > sum )
	ans = a[0] - sum - 1;
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int INF = (1 << 21);

int a(int x){
    return x * x * x;
}

int b(int x){
    return (x * (x - 1) * (x - 2)) / 6;
}

int c(int n, int x){
    return n - x;
}

int main(){
    int n;
    while(cin >>n){
        if(n == 0) break;
        int ans = INF, tmp;
        for(int i = 1; i < 100; i++){
            tmp = c(n, a(i));
            if(tmp < 0) break;
            else ans = min(ans, tmp);
            for(int j = 1; j < 100; j++){
                tmp = c(n, a(i) + b(j));
                if(tmp < 0) break;
                else ans = min(ans, tmp);
            }

        }
        for(int i = 1; i < 100; i++){
            tmp = c(n, b(i));
            if(tmp < 0) break;
            else ans = min(ans, tmp);
        }
        cout <<n - ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 200005;

int A[N];

vector<pii > v; // this is compressed form of string
int n;

bool check(int allowed) {
  v.clear();
  int p;
  rep(i,0,n) {
    // if(i) {
    //   rep(j,0,v.size()) {
    //     printf("%d %d ->",v[j].FF, v[j].SS);
    //   }
    //   printf("\n");
    // }
    int x = A[i];
    if(i == 0) {
      p = x;
      v.pb(mp(0, 0));
      continue;
    }

    if(x > p) {
      if(v.back().FF != 0) {
        v.pb(mp(0, p));
      }
      p = x;
      continue;
    }
    while(v.back().SS >= x) {
      v.pop_back();
    }


    // normalize
    if(v.back().SS == x - 1) {
      if(v.size() == 1 && v.back().FF == allowed - 1) {
        if(x == 1) v.clear();
        v.pb(mp(allowed, x - 1));
        return false;
      } else {
        v.back().FF++;
        while(v.size() > 1) {
          int sz = v.size();
          if(v[sz - 1].FF == v[sz - 2].FF) {
            v.pop_back();
          } else {
            break;
          }
        }
      }
    } else {
      if(v.size() == 1 && v.back().FF == allowed - 1) {
        if(x == 1) v.clear();
        v.pb(mp(allowed, x - 1));
        return false;
      } else {
        v.pb(mp(v.back().FF + 1, x - 1));
      }
    }
    if(v.back().FF == allowed) {
      while(v.back().FF == allowed) {
        int cur = v.back().SS;
        v.pop_back();
        if(!v.size()) break;
        if(v.back().SS == cur - 1) {
          v.back().FF++;
        } else {
          v.pb(mp(v.back().FF + 1, cur - 1));
        }
      }

      int last = v.back().SS;
      while(v.size() > 1) {
        int sz = v.size();
        if(v[sz - 1].FF == v[sz - 2].FF) {
          v.pop_back();
        } else {
          break;
        }
      }

      if(!v.size()) {
        assert(0);
      }
      // add all a's in the end
      if(last < x - 1) {
        v.pb(mp(0, last + 1));
      }
    }
    p = x;
  }
  return true;
}

int main() {
  S(n);
  int p;
  rep(i,0,n) {
    S(A[i]);
  }
  int lo = 1, hi = n;
  int ans = 1;
  while(lo <= hi) {
    int mi = (lo + hi) >> 1;
    if(check(mi)) {
      ans = mi;
      hi = mi - 1;
    } else {
      lo = mi + 1;
    }
  }
  P(ans);
  return 0;
}


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

int gcd(int x, int y){
	if(y == 0) return x;
	else return gcd(y, x%y);
}

int main(void){
	int n;
	bool ispc = true, issc = true;
	cin >> n;
	vector<int> a(n+1), b(1000001, 0);
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i : a) b[i]++;

	// pairwise coprime
	for(int i = 2; i <= 1000000; i++){
		int temp = 0;
		for(int j = i; j <= 1000000; j+=i){
			temp += b[j];
		}
		ispc = ispc and (temp <= 1);
	}

	// setwise coprime
	int temp2 = a[1];
	for(int i = 2; i <= n; i++){
		temp2 = gcd(temp2, a[i]);
	}
	issc = (temp2 == 1);

	if(ispc) cout << "pairwise coprime" << endl;
	else if(issc) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;
	return 0;
}


Measured memory_bytes: 11108
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	map<int,int> v;
	
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		v[tmp]++;
	}
	priority_queue<int, vector<int>, greater<>> q;
	for (auto i : v) {
		q.push(i.second);
	}
	int H = q.size();
	int ans = 0;
	for (int i = 0; i < H - K; i++) {
		ans += q.top(); q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1000001
typedef long long ll;
 
int main()
{
    ll N, M, a;
    vector<ll> d(MAX, 0), e(MAX+1, 0);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        d[a]++;
    }
    for (int i = 0; i < MAX; i++) {
        d[i] *= (ll)i;
    }
    for (int i = 0; i < MAX; i++) {
        e[i+1] = e[i] + d[i+1];
    }
    cin >> M;
    vector<ll> b(M);
    for (int i = 0; i < M; i++) {
        cin >> a;
        b[i] = e[a];
    }
    for (int i = 0; i < M; i++) {
        cin >> a;
        cout << (b[i] >= a ? "Yes" : "No") << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  vi cnt;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    cnt.push_back(it->second);
  }
  sort(all(cnt));
  int ans = 0;
  rep(i, sz(cnt)-k) {
    ans += cnt[i];
  }
  cout << ans << endl;
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(a+b,min(a+c,b+c)) << endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,i,j,k,count=0;
cin >>N;
int a[N],b[N];
for(i=0;i<N;i++){cin >> a[i];}
if(N==2){if(a[0]==1) cout<<1;
else cout<<0;}
else{
//if (a[0]==1){count++;k=a[0];a[0]=a[1];a[1]=k;}
//if(a[N-1]==N){count++;k=a[N-2];a[N-2]=a[N-1];a[N-1]=k;}
for(i=0;i<N;){
if (a[i]==i+1){count++;i=i+2;}
else i++;}
cout<<count;}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;

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

	int n,d,c=0;
	cin>>n>>d;
	vector<int> points[12];
	for(int i=0;i<n;i++) {
		points[i] = vector<int>(12);
		for(int j=0;j<d;j++)
			cin>>points[i][j];
	}

	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++) {
			int dis = 0;
			for(int k=0;k<d;k++)
				dis += (points[i][k]-points[j][k])*(points[i][k]-points[j][k]);
			
			int lo =0, hi = 200;
			while(lo<hi) {
				int mid = (lo+hi)/2;
				if(mid*mid>=dis)
					hi = mid;
				else
					lo = mid+1;
			}
			if(lo*lo==dis)
				c++;
		}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A,B;
  int X=0;
  
  scanf("%d%d",&A,&B);
  if(A>B && A-B>=2)
    X=2*A-1;
  else if(B>A && B-A>=2)
    X=2*B-1;
  else
    X=A+B;
  
  printf("%d",X);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define endl '\n'
const ld PI=3.14159265358979;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

ll dp[100105];
bool cmp(pair<ppl,ll> &a,pair<ppl,ll> &b)
{
    return (a.F.F+a.F.S)<(b.F.F+b.F.S);
}
int main()
{
    IOS
    ll n;
    cin>>n;
    vector<pair<ppl,ll>> v(n+1);

    for(int i=1;i<=n;i++)
        cin>>v[i].F.F>>v[i].F.S>>v[i].S;
    sort(all(v),cmp);
    
    //dp[i]=max score for weight i 
    ll maxS=100100;
    for(int i=1;i<=n;i++)
    {   
        for(int w=min(v[i].F.S,maxS-v[i].F.F);w>=0;w--)
        {
            dp[w+v[i].F.F]=max(dp[w+v[i].F.F],dp[w]+v[i].S);
        }
    }
    ll ans=0;
    for(int i=0;i<=maxS;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;  
}

Measured memory_bytes: 384
from itertools import accumulate
from bisect import bisect_left

N,M,K=list(map(int,input().split()))

A=list(map(int,input().split()))
B=list(map(int,input().split()))

Ac=[0]+list(accumulate(A))
Bc=[0]+list(accumulate(B))
ans=0
for i,ac in enumerate(Ac):
    j=bisect_left(Bc,K-ac)

    for k in range(j-1,min(j+2,M+1)):
        if ac+Bc[k]<=K:
            ans=max(ans,i+k)

print(ans)

Measured memory_bytes: 130088
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,d,e;
int main()
{
	//freopen("input.txt","r",stdin);
	cin>>a>>b>>c;
	d=4*a*b;
	e=c-a-b;
	e=e*e;
	if(d<e and c-a-b>0) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256