akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m-1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main(){
	int n, m;
	int ans = 0;
	cin >> n >> m;
	hei(int)x(m),y(m-1);
	rep(i, 0, m) {
		cin >> x[i];
	}
	if (n < m) {
		sort(x);
		ans = x[m - 1] - x[0];
		rep(i, 0, m - 1) {
			y[i] = x[i + 1] - x[i];
		}
		sort(y);
		reverse(y);
		rep(i, 0, n - 1) {
			ans -= y[i];
		}
	}
	cout << ans << endl;
	
	return 0;
}




  


Measured memory_bytes: 1024
while True:
    s = input()
    if s == "0 0":
        break
    n, x = [int(w) for w in s.split()]
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    ans += 1
    print(ans)



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

static const int MAX = 2000000;

int left(int i){ return (i+1)*2 -1; }
int right(int i){ return (i+1)*2+1 -1; }
int parent(int i){ return (i+1)/2 -1; }

int n;

void maxHeapify(int *a, int i){
        int l = left(i);
        int r = right(i);
        int largest;
        if(l<n && a[l]>a[i]) largest = l;
        else largest = i;
        if(r<n && a[r]>a[largest]) largest = r;

        if(largest!=i){
                swap(a[i],a[largest]);
                maxHeapify(a,largest);
        }
}

void heapIncreaseKey(int *a, int i){
        if(i==0) return;
        int j = i;
        while(a[j]>a[parent(j)]){
                swap(a[j], a[parent(j)]);
                j = parent(j);
                if(j<=0) break;
        }
}

void insert(int *a, int v){
        a[n] = v;
        heapIncreaseKey(a, n);
        n++;
}

int extract(int *a){
        int r = a[0];
        a[0] = a[n-1];
        n--;
        maxHeapify(a,0);
        return r;
}

int main(){
        int a[MAX];
        string s;
        int v;
        n=0;
        while(1){
                cin>>s;
                if(s=="end") break;
                else if(s=="insert"){
                        cin>>v;
                        insert(a,v);
                }else if(s=="extract"){
                        v = extract(a);
                        cout<<v<<endl;
                }
        }
        return 0;
}



Measured memory_bytes: 7108
import java.util.Scanner;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c;
        if (b < 10) {
            c = a*10+b;
        } else if (b < 100) {
            c = a*100+b;
        } else {
            c = a*1000+b;
        }
        double d = Math.sqrt(c);
        if (Math.floor(d) < d) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 22484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int main(){
	string s;
	cin>> s;
	int ans=0;
	rep(i,s.size()){
		if(s[i]=='+')ans++;
		else ans--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var N = nm[0];
			var M = nm[1];
			var skm = ReadLines(M)
					.Select(x => x.Split(' ').Skip(1).Select(int.Parse).Select(i => i - 1))
					.Select((x, i) => new { k = i, s = x })
					.SelectMany(x => x.s.Select(s => new { s, k = x.k }))
					.ToList();
			var pm = Console.ReadLine().Replace(" ", "");

			var ans = 0;
			foreach (var i in Enumerable.Range(0, (int)Math.Pow(2, N)))
			{
				var sw = Convert.ToString(i, 2).Reverse();
				var rp = new int[M];

				foreach (var cs in sw.Select((c, s) => new { c, s }).Where(x => x.c == '1'))
				{
					foreach (var sk in skm.Where(x => x.s == cs.s))
					{
						rp[sk.k]++;
					}
				}

				var rpi = string.Join("", rp.Select(x => x % 2));
				if (rpi == pm) ans++;
			}
			Console.WriteLine(ans);
		}

		static IEnumerable<string> ReadLines(int n)
		{
			foreach (var _ in Enumerable.Range(0, n)) yield return Console.ReadLine();
		}
	}
}


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

int main(){
  int one=0;
  string S;
  cin >> S;
  
  for(int i=0; i<S.length(); i++){
    if(i%2 == 0 && S[i] == '1') one++;
    if(i%2 == 1 && S[i] == '0') one++;
  }
  
  int another = S.length() - one;
  cout << min(one, another) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    string S;
    cin >> S;
    if(S[3-1]==S[4-1]&&S[5-1]==S[6-1]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<lint> a(n);
    lint b = 0;
    lint sum = 0;
    REP(i,n) cin >> a[i];
    FOR(i, 1, n){
         b = (b + a[i]) % MOD;
    }
    REP(i,n - 1){
        sum = (sum + ((b * a[i]) % MOD)) % MOD;
        b = (b - a[i + 1]) % MOD;
        if(b < 0) b += MOD;
    }
    println(sum);
    return 0;
}

Measured memory_bytes: 4840
//
// Created by myabu on 2020/01/31.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    string S;
    cin>>S;
    
    int ans = 700;

    for (int i = 0; i < S.length(); ++i) {
        if(S[i] == 'o'){
            ans += 100;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	var d = input[0][0];
	var cs = input[1][0];
	var ss = input.slice(1);
	
	var ans = '';
	for(let i = 0; i < 365; i++){
		ans += (i%26)+1+'\n';
	}

	console.log(ans);
}

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

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	int ans = 0, cnt = 0;
	for(int i = 2; i< 1000010; i++){
		cnt = 0;
		while(n % i == 0){
			n /= i;
			cnt++;
		}
		for(int j = 1; j<10000; j++){
			if(cnt-j >= 0){
				cnt -= j;
				ans++;
			}
			else{
				break;
			}
		}
	}
	if(n > 1){
		ans ++;
	}
	cout << ans;
	return 0;
}

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

int main() {
    int H, N;
    int A[100001];
    int damage = 0;
    cin >> H >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        damage += A[i];
    }

    if(H <= damage) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, x, y;
    ll k, a[100005] = {};
    cin >> n >> k;
    while (n--) cin >> x >> y, a[x] += y;
    for (int i = 1; i <= 100000; i++) a[i] += a[i - 1];
    a[100001] = 328ll * mod;
    for (int i = 1; i <= 100001; i++) if (a[i] >= k) {
        cout << i;
        return 0;
    }
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    c=a+b;
    if(c%3==0)
        printf("Possible\n");
    else if (a%3==0)
    {
        printf("Possible\n");
    }
    else if (b%3==0)
    {
        printf("Possible\n");
    }
    else
        {printf("Impossible\n");}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str1, str2;
	int i, n;
	int tarou = 0, hanako = 0;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> str1 >> str2;
		if (str1 > str2) tarou += 3;
		else if (str1 < str2) hanako += 3;
		else {
			tarou++;
			hanako++;
		}
	}
	
	cout << tarou << " " << hanako << endl;

	return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;

void solve()
{

  string s;
    cin>>s;
    int c=0;
    int ans=0;
    fr(i,s.length())
    {
        if(s[i]=='R')
        c++;
        else
        {ans=max(ans,c);
        c=0;
        }
    }
    ans=max(ans,c);
    cout<<ans;
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;


void SelectionSort(vector<string> Array, int N)
{
  	bool isStable=true;
  	for(int i = 0; i< N;i++)
    {
      int min_idx = i;
      bool isSame = false;
      int same_idx;
      for(int j=i+1;j<N;j++)
      {
        if(Array[j][1] - '0' == Array[min_idx][1] - '0') 
        {
          isSame=true;
          same_idx = j;
        }
        if(Array[j][1] - '0' < Array[min_idx][1] - '0')
        {
          min_idx = j;
        }
      }
      if(isSame && same_idx < min_idx) isStable = false;
      string tmp = Array[i];
      Array[i] = Array[min_idx];
      Array[min_idx] = tmp;
    }
	for(int i=0;i<N;i++)
    {
      cout << Array[i] << endl;
    }
  	cout << Array[N-1] << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long N, K;
	cin >> N >> K;
  	string S;
  	cin >> S;	
  	/*vector<string> Array(N);
  	int idx = 0;
  	while(cin >> Array[idx]) idx++;
    */
  	for(int i=0;i<N;i++)
    {
      if(i+1 == K)
      {
        if(S[i] == 'A')
        {
          cout << "a";
        }
        else if(S[i] == 'B')
        {
          cout << "b";
        }else
        {
          cout << "c";
        }
      }
      else
      {
        cout << S[i];
      }
    }
  	cout << endl;
  	return 0;
}


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

const int N = 1e5 + 7;
#define mid ((s + e) / 2)
#define int long long

int n, ed, tad;
int x[N];
int dp[N];
int seg[N * 4];
int laz[N * 4];
int get(int l, int r, int v = 1, int s = 0, int e = N) {
	if (r <= s || e <= l)
		return 2e18;
	if (l <= s && e <= r)
		return seg[v];
	seg[v * 2] += laz[v];
	seg[v * 2 + 1] += laz[v];
	laz[v] = 0;
	return min(get(l, r, v * 2, s, mid), get(l, r, v * 2 + 1, mid, e));
}
void add(int l, int r, int val, int v = 1, int s = 0, int e = N) {
	if (r <= s || e <= l)
		return;
	if (l <= s && e <= r) {
		seg[v] += val;
		laz[v] += val;
		return;
	}
	seg[v * 2] += laz[v];
	seg[v * 2 + 1] += laz[v];
	laz[v * 2] += laz[v];
	laz[v * 2 + 1] += laz[v];
	laz[v] = 0;
	add(l, r, val, v * 2, s, mid);
	add(l, r, val, v * 2 + 1, mid, e);
	seg[v] = min(seg[v * 2], seg[v * 2 + 1]);
}
int tmp[N];
int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> ed >> tad;
	int pnt = -1;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	for (int i = 1; i <= n; i++) {
		if (i == 1) {
			add(0, 1, 0 + x[1] - 0 + tad);
		}
		add(0, pnt, (x[i] - x[i - 1]) * 2);
		while ((x[i] - x[pnt + 1]) * 2 >= tad) {
			add(pnt, pnt + 1, (x[i] - x[pnt + 1]) * 2 - tad);
//			cout << "pnt << " << pnt << endl;
			pnt++;
		}
		add(0, i - 1, x[i] - x[i - 1]);
/*		cout << "all done : " << endl;
		for (int j = 0; j < i; j++)
			cout << j << " > " << get(j, j + 1) << "    "; 
		cout << endl;*/
		dp[i] = get(0, i);
//		cout << "dp[i] : " << i << " " << dp[i] << " " << tmp[i] << endl << endl << endl;
		add(i, i + 1, dp[i] + x[i + 1] - x[i] + tad);
	}
	cout << ed - x[n] + dp[n];

	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

string tolowers(string s)
{
  for (int i=0; i<s.size(); i++) s[i] = tolower(s[i]);
  return s;
}

int main()
{
  string w;
  cin >> w;
  w = tolowers(w);
  int count = 0;
  while (1) {
    string t;
    cin >> t;
    if (t == "END_OF_TEXT") break;
    t = tolowers(t);
    if (t == w) count++;
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	

	rep(i, N) {
		cin >> A.at(i);
	}

	rep(i, N-K) {
		if(A.at(i)<A.at(i+K)){
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

}


Measured memory_bytes: 4772
import random

def is_prime(q, k=50):
    """ ??????????????????????´???°?????????????????¨??????????????????????????°????´???°???????????????????????????
    http://d.hatena.ne.jp/pashango_p/20090704/1246692091
    """
    q = abs(q)
    # ?¨???????????????§?????????????????§????????????????????????
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*d??¨????????????a?????´??°???d????\???°)???d????±???????
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # ?????????k?????°?????????
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]??????????????????????????§??????
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


Primes = []
def find_nth_prime(n):
    """ n??????????´???°????±??????? """
    count = len(Primes)
    if count >= n:
        return
    if count > 0:
        num = Primes[-1] + 1
    else:
        num = 2
    while True:
        if is_prime(num):
            count += 1
            Primes.append(num)
        if count >= n:
            break
        num += 1


if __name__ == '__main__':
    # ??????????????\???
    while True:
        data = int(input())
        if data == 0:
            break

        # ????????¨???????????¨???
        find_nth_prime(data)
        # print(Primes)
        print(sum(Primes[:data]))

Measured memory_bytes: 11760
import sys
input = sys.stdin.readline

n = int(input())
S = tuple(map(int, input().split()))
ans = 0
for c in range(1, n-1):
  temp = 0
  T = set()
  for k in range(n):
    d = c*k
    if d+c >= n:
      break
    if d == n-1-d or d in T or n-1-d in T:
      break
    T.add(d)
    T.add(n-1-d)
    temp += S[d]+S[n-1-d]
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 134180
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  string s; cin >> s;
  rep(i,sz(s)) s[i] = 'x';
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 77;
const int MAXLOG = 61;

int a[MAXN], n;
int lst[MAXN], R[MAXN], fst[MAXN];
ll k;

ll add[MAXLOG][MAXN];
ll go[MAXLOG][MAXN];

void solve() {
	cin >> n >> k;

	for(int i = 0; i < MAXN; ++i) {
		lst[i] = NIL;
		fst[i] = NIL;
	}

	for(int i = 0; i < n; ++i) {
		cin >> a[i];

		if(fst[a[i]] == NIL) {
			fst[a[i]] = i;
		}
	}

	for(int i = n - 1; i >= 0; --i) {
		R[i] = lst[a[i]];
		lst[a[i]] = i;
	}

	for(int i = 0; i < n; ++i) {
		int j = (R[i] == NIL ? fst[a[i]] + n : R[i]);

		go[0][i] = (j + 1) % n;
		add[0][i] = j - i + 1;
	}

	for(int log = 1; log < MAXLOG; ++log) {
		for(int i = 0; i < n; ++i) {
			int i2 = go[log - 1][i];
			go[log][i] = go[log - 1][i2];
			add[log][i] = add[log - 1][i] + add[log - 1][i2];

			if(add[log][i] > LL_INF) {
				add[log][i] = LL_INF;
			}
		}
	}

	ll cur = 0, pref = 0;

	for(int log = MAXLOG - 1; log >= 0; --log) {
		if(cur + add[log][pref] <= n * k) {
			cur += add[log][pref];
			pref = go[log][pref];
		}
	}

	/*while(cur + add[0][pref] <= n * k) {
		cur += add[0][pref];
		pref = go[0][pref];
	}*/

	DBG(cur); DBG(pref);
	vector<int> answ;
	set<int> setik;

	for(; cur < n * k; pref = (pref + 1) % n, ++cur) {
		if(setik.count(a[pref])) {
			while(answ.back() != a[pref]) {
				setik.erase(answ.back());
				answ.pop_back();
			}

			setik.erase(answ.back());
			answ.pop_back();
		} else {
			setik.insert(a[pref]);
			answ.push_back(a[pref]);
		}
	}

	cout << answ << '\n';
}	

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 205556
# C - *3 or /2
import sys 
import math
#def input(): return sys.stdin.readline().rstrip()
def exp_bin(n):
    e = 0
    while(n%2==0):
        e += 1
        n = int(n/2)
    return e

N = int(input())
A = map(int, input().split())
ans = 0
for a in A:
    ans += exp_bin(a)
print(ans)

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

int main() {
  int n;
  while(cin >> n && n) {
    int two, five, tmp;
    tmp = n; two = 0;
    while(tmp >= 2) {
      two += tmp / 2;
      tmp /= 2;
    }
    tmp = n; five = 0;
    while(tmp >= 5) {
      five += tmp / 5;
      tmp /= 5;
    }
    cout << min(two, five) << endl;
  }
  return 0;
}

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

using namespace std;

bool can(int N, const string &S, int A, int C)
{
	for (int i = A; i < C; ++i) {
		if (S[i] == '#' && S[i + 1] == '#') {
			return false;
		}
	}
	return true;
}

bool test(int N, const string &S, int B, int D)
{
	for (int i = B; i <= D; ++i) {
		if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
			return true;
		}
	}
	return false;
}

int main()
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	--A;
	--B;
	--C;
	--D;
	string S;
	cin >> S;

	if (C < D) {
		if (can(N, S, A, C) && can(N, S, B, D)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (test(N, S, B, D) && can(N, S, A, C) && can(N, S, B, D)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int i, cnt;

  cnt = 1;
  while(true){
    cin >> i;
    if(i == 0) break;
    cout << "Case " << cnt << ": " << i << endl;
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 1160
// Papers, Please

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

bool isDivideBy3or5(int n) {
    return (n % 3 == 0) || (n % 5 == 0);
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    // int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        int num = A[i];
        if (num % 2 == 1) {
            continue;
        }
        if (!isDivideBy3or5(num)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict

sys.setrecursionlimit(10**7)
N = int(input())
S, T = input().split()

l = ''
for i in range(N):
    l += S[i]
    l += T[i]

print(l)


Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define mod 1000000007
#define lint long long
#define N 100
using namespace std;
char s1[N],s2[N];
int main()
{
	int n;scanf("%d",&n);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	int x=0,ans=1;
	for(int i=1;i<=n;i+=x)
		if(s1[i]==s2[i])
		{
			if(!x) ans=(lint)ans*3%mod;
			else if(x==1) ans=(lint)ans*2%mod;
			x=1;
		}
		else{
			if(!x) ans=(lint)ans*6%mod;
			else if(x==1) ans=(lint)ans*2%mod;
			else ans=(lint)ans*3%mod;
			x=2;
		}
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, k, a, b;
vector<int> vec[100010];
int cnt[100010];
int ans;

void dfs(int x, int y) {
	if (!y) {
		ans = k;
		cnt[x] = 1;
	}
	else {
		ans *= max((int)0, k - cnt[y]);
		ans %= mod;
		cnt[x] = 2;
	}
	for (int i = 0; i < (int)vec[x].size(); i++) {
		if (y != vec[x][i]) {
			dfs(vec[x][i], x);
			cnt[x]++;
		}
	}
}

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	dfs(1, 0);
	cout << ans << endl;
}

Measured memory_bytes: 9984
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef long long ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	int x[8], y[8];
	REP(i, N) cin >> x[i] >> y[i];

	// idx
	vector<int> idx(N);
	REP(i, N) idx[i] = i;

	// 順列
	double ans = 0;
	do {
		for (int i = 0; i < N - 1; i++) {
			double diffx = x[idx[i]] - x[idx[i + 1]];
			double diffy = y[idx[i]] - y[idx[i + 1]];
			ans += sqrt((pow(diffx, 2) + pow(diffy, 2)));
		}
	} while (next_permutation(idx.begin(), idx.end()));

	// 個数
	double div = 1;
	for (int i = 1; i <= N; i++) {
		div *= i;
	}
	ans = ans / div;
	printf("%lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int biggerNum = 0;
    int smallerNum = 0;

    if( a > b ){
      biggerNum = a;
      smallerNum = b;
    }else{
      smallerNum = a;
      biggerNum = b;
    }

    for(int i = 0; i < biggerNum; i++){
      System.out.print(smallerNum);
    }
  }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 50;
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    ll ans = 0;
    for(int i = 1;i < n;i++){
        if(a[i] < a[i - 1]){
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>

using namespace std;

void failure () {
  cout << "NO" << endl;
  exit(0);
}

typedef long long ll;

const int MAX_N = 1e5 + 5;

ll arr [MAX_N];
ll diff [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  ll mn = 1e9 + 5;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mn = min(mn, arr[i]);
    sum += arr[i];
  }

  ll per_op = 0;
  for (int i = 1; i <= n; i++) {
    per_op += i;
  }

  if (sum % per_op != 0) {
    failure();
  }

  ll n_op = sum / per_op;
  
  for (int i = 0; i < n; i++) {
    diff[i] = arr[(i + 1) % n] - arr[i];
    diff[i] -= n_op;
    if (diff[i] % n != 0) {
      failure();
    }
    if (diff[i] > 0) {
      failure();
    }
  }

  cout << "YES" << endl;
}


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

bool f(int x) {
  int k = 0;
  while(x) {
    k++;
    x = x / 10;
  }
  return k % 2 == 1;
}
int main() {

  int n;
  cin >> n;
  
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(f(i)) ans++;
  }
  cout << ans << 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;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  if (s == "ARC")
    cout << "ABC";
  else
    cout << "ARC";
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
inline void Add(int &x,int y)
{
	x+=y; if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
inline int qpow(int bas,int pw)
{
	int ans=1;
	for(;pw;pw>>=1,bas=1ll*bas*bas%mod)
		if(pw&1) ans=1ll*ans*bas%mod;
	return ans;
}
int n,k,F[200][4010];
int main()
{
	n=read(); k=read();
	F[n+1][0]=1;
	for(int i=n;i>0;i--)
		for(int j=0;j<=k;j++)
			for(int d=0;d<=4000;d++) if(F[i+1][d])
			{
				if(j>i) Add(F[i][d],F[i+1][d]);
				else Add(F[i][d+(j+d)/i],F[i+1][d]);
			}
	int ans=1ll*n*(k+1)*k/2%mod*qpow(k+1,n-1)%mod;
	for(int i=0;i<=4000;i++)
		Add(ans,-1ll*i*F[1][i]%mod);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

L, R, d = MI()
ans = 0

for i in range(L, R + 1):
    if i % d == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 61920
/* ALDS1_6_C: QuickSort */
/* 20181121 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#define N 100000

typedef struct {
	int order;
	char suit;
	int value;
} Card;

int partition(Card* A, int p, int r);
void quickSort(Card* A, int p, int r);
void swap(Card* x, Card* y);
int stableJudge(Card* A, int n);

int main(void) {
	Card* A = (Card *)malloc(sizeof(Card) * N);
	int n;
	int i = 0;
	//char S[2];

	scanf("%d", &n);
	getchar();
	while(i < n) {
		//scanf("%s %d", S, &A[i].value);
		//A[i].suit = S[0];
		scanf("%c %d", &A[i].suit, &A[i].value);
		getchar();
		A[i].order = i + 1;
		i++;
	}

	quickSort(A, 0, n - 1);

	if(stableJudge(A, n)) {
		puts("Stable");
	} else {
		puts("Not stable");
	}
	
	for(i = 0; i < n; i++) {
		//printf("%2d %c %d\n", A[i].order, A[i].suit, A[i].value);
		printf("%c %d\n", A[i].suit, A[i].value);
	}

	return 0;
}

void quickSort(Card *A, int p, int r) {
	int q;

	if(p < r) {
		q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

int partition(Card *A, int p, int r){
	int i, j;

	i = p - 1;
	for(j = p; j < r; j++) {
		if(A[j].value <= A[r].value) {
			i++;
			swap(&A[i], &A[j]);
		}
	}
	swap(&A[++i], &A[r]);

	return i;
}

void swap(Card* x, Card* y) {
	Card temp = *x;
	*x = *y;
	*y = temp;
}

int stableJudge(Card* A, int n) {
	int i, j;
	
	for(i = 0; i < n - 1; i++) {
		for(j = i + 1; j < n; j++) {
			if(A[i].value == A[j].value && A[i].order > A[j].order) {
				return 0;
			}
		}
	}

	return 1;
}


Measured memory_bytes: 2960
//abc132_a.cpp
//Sat Jun 29 20:41:35 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	char x[4];
	for (int i=0;i<4;i++){
		x[i] = s[i];
	}
	sort (x,x+4);

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

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 + 7;
int M;
inline int add(int x, int y) {int res = x + y; if (res >= M) res -= M; return res;}
inline int mul(int x, int y) {ll res = (ll)x * y; res -= res / M * M; return res;}

vector<int>G[MAXN];
int f[MAXN], fs[MAXN], fp[MAXN], g[MAXN];
void dfs1(int u, int fa)
{
    int p = 1;
    for(int v : G[u]) if(v != fa) 
    {
        dfs1(v, u);
        fp[v] = p;
        p = mul(p, f[v] + 1);
    }
    f[u] = p;
    p = 1;
    for (auto it = G[u].rbegin(); it != G[u].rend(); it++) if (*it != fa)
        fs[*it] = p, p = mul(p, f[*it] + 1);
}
void dfs2(int u, int fa)
{
    for (int v : G[u]) if (v != fa)
    {
        g[v] = mul(g[u] + 1, mul(fs[v], fp[v]));
        dfs2(v, u);
    }
}
int main()
{
    int n; scanf("%d%d", &n, &M);
    for (int i = 1, x, y; i < n; i++) 
    {
        scanf("%d%d", &x, &y);
        G[x].push_back(y); G[y].push_back(x);
    }
    dfs1(1, 0); dfs2(1, 0);
    for (int i = 1; i <= n; i++) printf("%d\n", mul(f[i], g[i] + 1));
    return 0;
}

Measured memory_bytes: 14976
#include<iostream>
using namespace std;
const int maxn=2e5+10;
int a[maxn],n,k;
bool judge(int x){
    int cnt=0;
    for(int i=0; i<n; i++)
       cnt+=(a[i]-1)/x;
    return cnt<=k;
}
int main()
{
    int l=1,r=0;
    cin>>n>>k;
    for(int i=0;i<n;i++) 
      cin>>a[i],r=max(r,a[i]);
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(judge(mid))
           r=mid-1;
        else l=mid+1;
    }
    cout<<l;
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll dp[M][5],ar[M],i,n,br[M],cr[M];

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

	cin >> n;
	cin >> dp[1][1] >> dp[1][2] >> dp[1][3];

	for(i=2;i<=n;++i)
	{
		cin >> ar[i] >> br[i] >> cr[i];
		dp[i][1] = ar[i]+max(dp[i-1][2],dp[i-1][3]);
		dp[i][2] = br[i]+max(dp[i-1][1],dp[i-1][3]);
		dp[i][3] = cr[i]+max(dp[i-1][1],dp[i-1][2]);
	}

	cout << max(max(dp[n][1],dp[n][2]),dp[n][3]) << endl;
	return 0;
}

	


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int n,m;
  cin >> n >> m;
  vint A(n);
  rep(i,0,n){
    cin >> A[i];
  }
  vint sum(n+1);
  rep(i,0,n){
    sum[i+1] = (sum[i] + A[i])%m;
  }
  map<int,int> map;
  int ans = 0;
  rep(i,0,n+1){
    ans += map[sum[i]];
    map[sum[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N; cin >> N;
    vector<ll> P(N), Q(N), V(N); 
    for(int i = 0; i < N; i++) cin >> P[i];
    for(int i = 0; i < N; i++) cin >> Q[i];
    for(int i = 0; i < N; i++) V[i] = i+1;

    ll cnt = 0, cnt1, cnt2;
    do{
        bool f1 = true, f2 = true;
        for(int i = 0; i < N; i++) if(V[i] != P[i]) f1=false;
        for(int i = 0; i < N; i++) if(V[i] != Q[i]) f2=false;
        if(f1) cnt1 = cnt;
        if(f2) cnt2 = cnt;
        cnt++;

    }while(next_permutation(V.begin(), V.end()));
    cout << abs(cnt2-cnt1) << endl;

} 


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

int main() {
	int X, N;
	cin >> X >> N;
	set<int> p;
	for (int i = 0; i < N; ++i) {
		int n;
		cin >> n;
		p.insert(n);
	}
	for (int d = 0; d <= 105; ++d) {
		if (!p.count(X-d)) {
			cout << X-d << endl;
			return 0;
		}
		if (!p.count(X+d)) {
			cout << X+d << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
ll mod = 1000000007;
ll INF = 1000000099;

signed main(){
    ll n,K,ans=0,x=0;
    cin >>n>>K;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++)
    {
        cin>>v.at(i);
    }
    
//bitcount,存在する桁としない桁があるので、bit数が違うことに注意

    for (ll i = 60; -1<=i ; i--)//iより上の桁はＫと一致
    {
        ll x=0;
        if( i!=-1 && !(K & (1ll<<i)) ){
            continue;
        }
            for (ll j = 60; 0<=j ; j--)
            {
                ll mask = 1ll<<j,cnt=0;
                for (ll i = 0; i < n; i++) 
                    if(mask&v.at(i)) cnt++;
                
                
                if(j>i){
                    if(K & mask){//kのそのビットが1
                        x+=mask*(n-cnt);
                    }else{
                        x+=mask*cnt;
                    }
                }else if(j==i){
                    x+=mask*cnt;
                }else{
                    x+=mask*max(cnt,n-cnt);
                }
            }
            ans=max(ans,x);
       
    }
    cout<<ans<<endl;
}
/*
制約がない場合のxを出しておいて、何桁目までkと一致させるか考えていく
+=する時、初期化してるか確認

bitで表したときのある桁を、直接確認する時&が使える*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mod 1000000007LL;
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;

void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}


int32_t main(){
/////////////////////////////////////////////////////////////////////
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(10);
	int n,k;
	cin>>n>>k;
	vii arr(n);
	rep(i,0,n) cin>>arr[i];
	vii dp(n+1,0);
	dp[0]=dp[1]=0;
	dp[2]=abs(arr[1]-arr[0]);
	rep(i,3,n+1){
		int minm=INT_MAX;
		rep(ii, 1, k+1)
		{	if(i-ii-1>=0)
			minm=min(dp[i-ii]+abs(arr[i-1]-arr[i-ii-1]), minm);
		}
		dp[i]=minm;
	}
	cout<<dp[n]<<endl;
	return 0;
	}
	


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

const int sz = 1e6+1;
bool notPrime[sz];


void sieve(){
  notPrime[0] = notPrime[1] = true;
  for(int i=2;i*i<sz;i++) for(int j=i*i;j<sz;j+=i) notPrime[j] = true;
}


int main(){

  int x; cin >> x;
  sieve();
  while(notPrime[x]==true) x++;
  cout << x;
  
  return 0;
}

Measured memory_bytes: 1280
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

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

  int ans=0;
  rep(i,3){
    if(S[i]==T[i]){
      ans++;
    }
  }

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


Measured memory_bytes: 256