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

typedef long long ll;
const ll mod=1e9+7;
const ll N=5e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> a(n),b(m);
	for(ll &i:a) cin>>i;
	for(ll &i:b) cin>>i;
	int ans=0,aptr=0,bptr=0;
	ll sum=0;
	while(aptr<n and sum+a[aptr]<=k) sum+=a[aptr++];
	ans=aptr;
	while(aptr){
		while(bptr<m and sum+b[bptr]<=k) sum+=b[bptr++];
		ans=max(ans,aptr+bptr);
		sum-=a[--aptr];
	}
	bptr=0,sum=0;
	while(bptr<m and sum+b[bptr]<=k) sum+=b[bptr++];
	ans=max(ans,bptr);
	cout<<ans;
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 N, X, T;
    cin >> N >> X >> T;
    u64 coe = ceil((double)N / X);
    cout << coe * T << endl;
    
    return 0;
    
}


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

long long digit(long long x) {
    int cnt = 0;
    while (x > 0) {
        cnt++;
        x /= 10;
    }
    return cnt;
}

int main(void){
    long long n, a, b;
    cin >> n;
    
    long long ans = 100000000000;
    for(long long  i = 1; i*i <= n; i++){
        if(n%i == 0) {
            a = i; b = n/i;
            ans = min(ans, max(digit(a), digit(b)));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)
int main(){
  ios::sync_with_stdio(false);
  //std::cout<<std::fixed<<std::setprecision(10);
  cin.tie(nullptr);
  ll a,b;
  cin>>a>>b;
  ll ans = 0;
  ll x= a*b/2;
  ans+=x;
  if(a%2==1&&b%2==1)ans+=1;
  if(a==1||b==1)ans=1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define       pb(a)             push_back((a))
#define       mp(a,b)           make_pair((a),(b))
#define       REP(a,b)          for(ll i=(a);i<(b);i++)
#define       REP2(a,b)         for(ll j=(a);j<(b);j++)
#define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
#define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
#define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
#define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
#define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
#define       all(v)            (v).begin(),(v).end()
#define       Trvs(c)           for (auto it = (c).begin(); it != (c).end(); it++)
#define       INF               INT_MAX
#define       sz(x)             x.size()
#define       flash             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define       F                 first
#define       S                 second
#define       MOD               1000000007
 
using         ll     = long long;
using         vi     = vector<int>;
using         vvi    = vector<vi>;
using         vll    = vector<ll>;
using         vvll   = vector<vll>;
using         vb     = vector<bool>;
using         vd     = vector<double>;
using         vs     = vector<string>;
using         pii    = pair<int, int>;
using         pll    = pair<ll, ll>;
using         pdd    = pair<double, double>;
using         vpii   = vector<pii>;
using         vvpii  = vector<vpii>;
using         vpll   = vector<pll>;
using         vvpll  = vector<vpll>;
using         vpdd   = vector<pdd>;
using         vvpdd  = vector<vpdd>;
 
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

void solve(){
    ll n;
    cin>>n;
    string s1,s2; cin>>s1>>s2;
    REP(0,n)cout<<s1[i]<<s2[i];
}
 
 
int main(){
 
	flash
	/*
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("output.txt","w",stderr);
	#endif
 	*/
   
	//ll t;cin>>t;while(t--)
	solve();
 
 
	return 0;
}

Measured memory_bytes: 256
_N = gets.to_i
as = gets.split.map(&:to_i)
def func(array, count)
  flag = true
  array.each do |num|
    flag = false if num.odd?
  end
  if flag
    func(array.map { |x| x / 2 }, count + 1)
  else
    puts count
  end
end
func(as, 0)


Measured memory_bytes: 1788
N = int(input())

dic = {}
B = []

for i in range(N):
    a, b = map(int,input().split())
    B.append(b)
    if '{}'.format(b) in dic:
        dic['{}'.format(b)] += a
    else:
        dic['{}'.format(b)] = a

Bs = sorted(list(set(B)))

time = 0

for i, num in enumerate(Bs):
    time += dic['{}'.format(num)]
    if num < time:
        print('No')
        break

    if i == len(Bs)-1:
        print('Yes')


Measured memory_bytes: 55744
#include<stdio.h>
int main()
{
    int num,i,j=1,k,big=-1,avg,max,total=0,count[50];
    scanf("%d",&max);
    for(i=0; i<max; i++)
    {
        scanf("%d",&count[i]);
        if(count[i]!=j)
        {
            total++;
        }
        j++;

    }
    if(total>2)
    {
        printf("NO");
    }
    else
    {
        printf("YES");
    }
    //printf("%d",total);
    return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	map<string, int> M;
	rep(i, n){
		string s; cin >> s;
		M[s]++;
	}
	int max = 0;
	for(auto x: M){
		int v = x.second;
		if(v > max) max = v;
	}
	for(auto x: M){
		int v = x.second;
		if(v == max) cout << x.first << endl;
	}
} 

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);
typedef pair<int, int> pii;

const int maxn = 100100;
int cnt[maxn];
vector<pii> g[maxn];
int n;
ll res;
bool sos = false;

void dfs(int u, int prev = -1) {
    cnt[u] = 1;
    bool vsos = true;
    for (auto p: g[u]) {
        int v = p.first;
        int w = p.second;
        if (v == prev)
            continue;
        dfs(v, u);
        cnt[u] += cnt[v];
        if (cnt[v] * 2 >= n)
            vsos = false;

        ll x = min(cnt[v], n - cnt[v]) * 2;
        res += x * w;
        if (cnt[v] * 2 == n) {
            assert(!sos);
            sos = true;
            res -= w;
        }
    }
    if ((n - cnt[u]) * 2 >= n)
        vsos = false;
    if (vsos) {
        assert(!sos);
        sos = true;
        ll minw = inf;
        for (auto p: g[u]) {
            minw = min<ll>(minw, p.second);
        }
        cerr << "vsos " << minw << '\n';
        res -= minw;
    }
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    cin >> n;
    forn (i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }
    dfs(0);
    assert(sos);
    cout << res << '\n';
}


Measured memory_bytes: 15488
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	priority_queue<int>PQ;
	for (int i = 0; i < N; i++) {
		cin >> K;
		PQ.push(K);
	}
	for (int i = 0; i < M; i++) {
		int cn = PQ.top();
		PQ.pop();
		cn >>= 1;
		PQ.push(cn);
	}
	long long int ans = 0;
	while (!PQ.empty()) {
		ans += PQ.top();
		PQ.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

int main() {
    ll N, T;
    cin >> N >> T;
    ll a[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    sort(a, a + N);
    ll ans = 1;
    REP(i, 0, N) {
        ll id = upper_bound(a, a + N, a[i] + T) - a;
        ll num = id - i;
        ans = multiply(ans, num);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3916
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
# define maxh 2000
# define maxn 100000
// # define mod 1e9+7

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ll N,X,x[maxn];
  cin>>N>>X;
  for (int i(0);i<N;i++){
    cin>>x[i];
    x[i]=abs(x[i]-X);
  }
  ll a = x[0];
  for (int i(1);i<N;i++){
    a = gcd(a,x[i]);
  }
  cout << a<<endl;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    final int m = scanner.nextInt();
    
    if(n == m) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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


long double nthRoot(ll A, ll N) 
{ 
    // llially guessing a random number between 
    // 0 and 9 
    long double xPre = rand() % 10; 
  
    //  smaller eps, denotes more accuracy 
    long double eps = 1e-3; 
  
    // initializing difference between two 
    // roots by INT_MAX 
    long double delX = INT_MAX; 
  
    //  xK denotes current value of x 
    long double xK; 
  
    //  loop untill we reach desired accuracy 
    while (delX > eps) 
    { 
        //  calculating current value from previous 
        // value by newton's method 
        xK = ((N - 1.0) * xPre + 
              (long double)A/pow(xPre, N-1)) / (long double)N; 
        delX = abs(xK - xPre); 
        xPre = xK; 
    } 
  
    return xK; 
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin>>x;
    ll a=-1,b=-1;
    //cout<<nthRoot(-32,5)<<"\n";
    for(ll i=-200;i<=200;++i)
    {
        ll temp=x+pow(i,5);
        long double temp1=nthRoot(temp,5);
        ll lo=temp1;
        ll hi=temp1+1;
        ll mid=temp1-1;
        if(pow(lo,5)==temp)
        {
            b=i;
            a=lo;
            break;
        }
        
        if(pow(hi,5)==temp)
        {
            b=i;
            a=lo;
            break;
        }
        
        if(pow(mid,5)==temp)
        {
            b=i;
            a=mid;
            break;
        }
        
    }
    
   
    cout<<a<<" "<<b<<"\n";

}


Measured memory_bytes: 4060
N = int(raw_input())
U = [raw_input() for _ in range(N)]  # user id

M = int(raw_input())
T = [raw_input() for _ in range(M)]

lock = True

for i in T:
    if i in U:
        print ("Opened" if lock else "Closed") + " by " + i
        lock = not lock
    else:
        print "Unknown", i


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

int main(void) {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s<t) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	char o[10000];
	int a[10000],b[10000],i[10000],z,x,n;
	z=0;
	x=0;
	while(1){
		scanf("%d ",&a[z]);
		scanf("%c ",&o[z]);
		scanf("%d",&b[z]);
		if(o[z] == '?'){break;}
		if(o[x] == '+'){
			i[x]=a[x]+b[x];
		}else if(o[x] == '-'){
			i[x]=a[x]-b[x];
		}else if(o[x] == '*'){
			i[x]=a[x]*b[x];
		}else if(o[x] == '/'){
			i[x]=a[x]/b[x];
		}else{
			break;
		}
		z++;
		x++;
	}
	for(n=0;n<x;n++){
		printf("%d\n",i[n]);
	}
	return 0;
}


Measured memory_bytes: 2052
#include<cstdio>
#include<algorithm>
int n,dp[3010][3010],c[6020];
int a[3010],b[3010],cnta,cntb;
char S[6010],S1[6010],S2[6010];
bool check(int x){
	int len1=0,len2=0;
	for(int i=1;i<=2*n;i++){
		if(dp[x][c[i]])S1[++len1]=S[i];
		if(dp[x+1][c[i]])S2[++len2]=S[i];
	}
	S1[++len1]=' ';
	S2[++len2]=' ';
	for(int i=1;i<=std::max(len1,len2);i++){
		if(S1[i]>S2[i])return false;
		if(S1[i]<S2[i])return true;
	}
		
}
int main(){
	scanf("%d",&n);
	scanf("%s",S+1);
	for(int i=1;i<=2*n;i++)
		if(S[i]=='a'){
			a[++cnta]=i;
			c[i]=cnta;
		}
		else{
			b[++cntb]=i;
			c[i]=cntb;
		}
	dp[n][n]=1;
	for(int i=n-1;i>=1;i--){
		dp[i][i]=1;
		if(a[i]<b[i]){
			int maxn=0;
			for(int j=a[i];j<=b[i];j++)
				if(c[j]>=i)maxn=std::max(maxn,c[j]);
			for(int j=b[i]+1;j<=2*n;j++)
				if(c[j]>maxn)
					dp[i][c[j]]=dp[maxn+1][c[j]];				
		}
		else{
			int tot=0,maxn=0;
			for(int j=b[i];j<=a[i];j++) {
				if(c[j]<i)continue;
				if(c[j]!=i)tot++;
				maxn=std::max(maxn,c[j]);
				dp[i][c[j]]=1;
            }
            for(int j=a[i]+1;j<=2*n;j++){
            	if(S[j]=='b'){
					if(tot==0)dp[i][c[j]]=dp[maxn+1][c[j]];
					else{
						dp[i][c[j]]=1;
						tot++;
					}
				}
            	else{
					if(tot==0)dp[i][c[j]]=dp[maxn+1][c[j]];
                    else{
                        dp[i][c[j]] = 1;
                        maxn=std::max(maxn,c[j]);
                        tot--;
                    }
            	}
            }
		}
		if(check(i))
			for(int j=1;j<=n;j++)
				dp[i][j]=dp[i+1][j];
	}
	for(int i=1;i<=2*n;i++)
		if(dp[1][c[i]])putchar(S[i]);
}

Measured memory_bytes: 35328
fun main(args: Array<String>) {
    val N = Integer.parseInt(readLine())
    val a = (readLine()!!.split(" ")).map { Integer.parseInt(it)}

    val sorted = a.sorted().reversed()

    var alice = 0
    var bob = 0
    for (i in 0..N-1) {
        if (i % 2 == 0) {
            alice += sorted[i]
        } else {
            bob += sorted[i]
        }
    }

    println(alice - bob)
}

Measured memory_bytes: 37904
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int y, m, d;
    char ca, cb;
    cin >> y >> ca >> m >> cb >> d;
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
INF=10**10

def main():
    
    str=input()
    n=len(str)
    if n==2:
        if str[0]==str[1]:
            print("1 2")
            return 0
        else:
            print("-1 -1")
            return 0
        
    
    for i in range(n-2):
        temp=str[i:i+3]
        for j in range(2):
            for k in range(j+1,3): #(0,1),(0,2),(1,2)
                if temp[j]==temp[k]:
                    print("{0} {1}".format(i+1,i+3))
                    return 0
    print("-1 -1")
    
if __name__=="__main__":
    main()
    

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;
            int[] a = new int[2], b = new int[2], c = new int[2], d = new int[2];

            while ((line = Console.ReadLine())!=null) {
                double[] cites  = line.Split(' ').Select(double.Parse).ToArray();
                for (int i = 0; i < 2; i++) {
                    double cite = cites[i];
                    if (cite >= 1.1) { a[i]++; }
                    else if (cite >= 0.6) { b[i]++; }
                    else if (cite >= 0.2) { c[i]++; }
                    else { d[i]++; }
                
                }


            }
            Console.WriteLine(a[0] + " " + a[1]);
            Console.WriteLine(b[0] + " " + b[1]);
            Console.WriteLine(c[0] + " " + c[1]);
            Console.WriteLine(d[0] + " " + d[1]);
        }
        
    }
}

Measured memory_bytes: 6124
#include <stdio.h>

int main(void){
  int N,bal;
  scanf("%d",&N);
  N %= 1000;
  
  if(N!=0){
    bal = 1000-N;
  }else{
    bal = 0;
  }
  
  printf("%d",bal);  
  
  return 0;
}

Measured memory_bytes: 1732
#include <cstdlib>
#include <climits>
#include <iostream>
#include <sstream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> a;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        a.push_back(t);
    }

    std::stringstream ss;
    if (N % 2 == 0) {
        // 偶数
        for (int64_t i = N - 1; i > 0; i -= 2) {
            ss << a[i] << " ";
        }
        for (int64_t i = 0; i < N; i += 2) {
            ss << a[i] << " ";
        }
    }
    else {
        // 奇数
        for (int64_t i = N - 1; i >= 0; i -= 2) {
            ss << a[i] << " ";
        }
        for (int64_t i =1; i < N; i += 2) {
            ss << a[i] << " ";
        }
    }

    std::string s = ss.str();
    boost::algorithm::trim(s);
    std::cout << s << std::endl;

    return 0;
}


Measured memory_bytes: 7668
lst = []
while True:
    a = list(map(int, input().split()))
    if a[0] == a[1] == 0:
        break
    else:
        lst.append(a)
for i in range(len(lst)):
    for y in range(lst[i][0]):
        for x in range(lst[i][1]):
            if (y == 0 or x == 0 
                    or y == lst[i][0] - 1 or x == lst[i][1] - 1):
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int cnt[26] = {0};
    for (int i = 0; i <= S.size() - 1; i++)
    {
        if (cnt[(int)S[i] - 97] == 1)
        {
            cout << "no" << endl;
            return 0;
        }
        cnt[(int)S[i] - 97] += 1;
    }

    cout << "yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()
left = []
right = []
i, j = 0, N-1
while len(left) <= K-1:
    if S[i] == "o":
        left.append(i)
        i += C+1
    else:
        i += 1
while len(right) <= K-1:
    if S[j] == "o":
        right.append(j)
        j -= C+1
    else:
        j -= 1
right.sort()
for n in range(K):
    if left[n] == right[n]:
        print(left[n] + 1)

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

int main() {
  string s;
  cin >> s;
  string ans = "AC";
  if ( s[0] != 'A' ) { ans = "WA"; }
  int C = -1;
  for ( int i = 2; i <= s.size()-2; i++ ) {
    if ( s[i] == 'C' ) {
      if ( C != -1 ) { C = -1; break; }
      C = i;
    }
  }
  if ( C == -1 ) { ans = "WA"; }

  for ( int i = 1; i < s.size(); i++ ) {
    if ( i == C ) { continue; }
    if ( isupper(s[i]) ) { ans = "WA"; break; }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++){
		if((a*i)%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <list>
#include <cmath>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <functional>
#include <cassert>
using namespace std;

#define tmax(a, b) if (b > a) a = b
#define tmin(a, b) if (b < a) a = b
char inc() { char _[10]; scanf("%s", _); return _[0]; }
int ini() { int _; scanf("%d", &_); return _; }
long long inll() { long long _; scanf("%I64d", &_); return _; }
double ind() { double _; scanf("%lf", &_); return _; }
string ins() { string _; cin >> _; return _; }
int inl(char _[]) { if (!fgets(_, (int)1e8, stdin)) return -1; int i = strlen(_); if (_[i - 1] == '\n') _[--i] = 0; return i; }

typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef long long LL;
const int inf = 0x3f3f3f3f;
const LL lnf = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-8;
const int mod = 100007;
const int maxn = 200+ 10;

int n;
deque<int> q;

int main() {
    int CAS = 0;
    //std::ios::sync_with_stdio(0);
    //std::cin.tie(0);
#ifdef NIGHT_13
    freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
    int time_night_13 = clock();
#endif // NIGHT_13

	while (scanf("%d", &n) != EOF) {
		q.clear();
		bool hl = true;
		while (n--) {
			int a = ini();
			!hl ? q.push_front(a) : q.push_back(a);
			hl = !hl;
		}
		if (hl) {
			while (!q.empty()) {
				printf("%d ", q.front());
				q.pop_front();
			}
		} else {
			while (!q.empty()) {
				printf("%d ", q.back());
				q.pop_back();
			}
		}
		puts("");
	}

#ifdef NIGHT_13
    fprintf(stderr, "\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
    fprintf(stderr, "\t   Time: %d ms", (int)clock() - time_night_13);
    fprintf(stderr, "\n...........................................\n\n");
#endif // NIGHT_13
    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
int main()
{

    int n;
    char s[51];
    scanf("%d %s",&n,s);

    int len = strlen(s),i,count = 0;
    for (i = 2; i < n; i++)
    {
        if(s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C')
        {
            count ++;
        }
    }
    printf("%d",count);
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			int n = sc.nextInt();
			List<Integer> an = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				an.add(sc.nextInt());
			}

			int[] resultList = new int[an.size()];
			for (int i = 1; i <= an.size(); i++) {
				int cand = an.get(i - 1);
				resultList[cand - 1] = i;
			}

			StringBuilder sb = new StringBuilder();
			for (int result : resultList) {
				sb.append(result);
				sb.append(" ");
			}
			sb.setLength(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 59356
// Weighted Union Find Trees

#include <iostream>

using namespace std;

int n, q;

int fat[100000];
int dis[100000];

int find(int u) {
	if (fat[u] == u)
		return u;
	int g = find(fat[u]);
	dis[u] += dis[fat[u]];
	fat[u] = g;
	return g;
}

void relate(int x, int y, int z) {
	int u = find(x);
	int v = find(y);
	fat[u] = v;
	dis[u] = z - dis[x] + dis[y];
}

bool check(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

int diff(int x, int y) {
	find(x);
	find(y);
	return dis[x] - dis[y];
}

int main() {
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
		fat[i] = i, dis[i] = 0;
	for (int i = 0; i < q; ++i) {
		int k, x, y, z;
		cin >> k >> x >> y;
		if (k == 0)
			cin >> z, relate(x, y, z);
		else {
			if (check(x, y))
				cout << diff(x, y) << endl;
			else
				cout << "?" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4492
N=int(input())

List=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(List[N-1])

Measured memory_bytes: 3060
using System;
 using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
     int[] input=new int[N];
      int ans=0;
      int ex=0;
      for(int i=0;i<N;i++){
        input[i]=int.Parse(Console.ReadLine());
        if(input[i]==input.Max()){
          ex=input[i];
        }
      
        ans+=input[i];
      }
      ans-=(ex/2);
      Console.WriteLine(ans);
    
    }
    
  }

}

Measured memory_bytes: 13268
N = int(input())

num = [1,10,100,1000,10000, 100000]
num2 = {1:9, 100:900, 10000:90000}
num3 = {1:1,2:10,3:100,4:1000,5:10000, 6:100000}
count = 0

for n in num:
    if len(str(n)) % 2 == 0: continue
    if len(str(N)) > len(str(n)):
#        print('unk')
#        print(N,n, num2[n])
        count += num2[n]
#print(count)
if len(str(N)) % 2 != 0:
#    count += num3[len(str(N))]*10-N
    count += N-num3[len(str(N))]+1

print(count)


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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;
const int mod = 1e9 + 7;

string S;
int dp[2001][2001];
int nearL[26][2001];
int nearR[26][2001];


int dfs(int l, int r) {
  if(~dp[l][r]) return dp[l][r];
  int64 ret = 0;
  for(int i = 0; i < 26; i++) {
    if(nearL[i][l] <= nearR[i][r]) ++ret;
    if(nearL[i][l] < nearR[i][r]) ret += dfs(nearL[i][l] + 1, nearR[i][r] - 1) + 1;
  }
  return dp[l][r] = ret % mod;
}

int main() {
  cin >> S;
  fill_n(*nearL, 26 * 2001, INF);
  memset(nearR, -1, sizeof(nearR));
  for(int i = 0; i < S.size(); i++) {
    nearL[S[i] - 'a'][i] = i;
    nearR[S[i] - 'a'][i] = i;
  }
  for(int i = 0; i < 26; i++) {
    for(int j = S.size() - 1; j >= 0; j--) {
      nearL[i][j] = min(nearL[i][j], nearL[i][j + 1]);
    }
    for(int j = 1; j < S.size(); j++) {
      nearR[i][j] = max(nearR[i][j], nearR[i][j - 1]);
    }
  }

  memset(dp, -1, sizeof(dp));
  cout << dfs(0, S.size() - 1) << endl;
}


Measured memory_bytes: 19292
import math

A, B, H, M = map(int, input().split())

h = 360 / (12 * 60)
m = 360 / 60

deg = abs(360 - abs(h * (H * 60 + M) - m * M))

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(deg))))


Measured memory_bytes: 9484
#include <iostream>
using namespace std;
int main(void){
  int H,W,N;
  cin >> H >> W >> N;
  
  int d = 0;
  if(H > W) d = H;
  else d = W;
  
  cout << (N + d - 1) / d << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
long long MAX(long long a,long long b){
    return a>b?a:b;
}
long long MIN(long long a,long long b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long*)b)return 1;
    return -1;
}
int main()
{   int a,b,n,k,m,x,y,i,t;
    scanf("%d",&n);
    int v[n];
    for(i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    int c[n];
    for(i=0;i<n;i++)scanf("%d",&c[i]);
    long long ans=0;
    for(i=0;i<n;i++){
        if(v[i]>=c[i]){
            ans+=v[i]-c[i];
        }
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 128
using System;

namespace AtCoder0205
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            int total = 0;
            int max = 0;
            int x = 0;

            for (int i = 0; i < N; i++)
            {
                x = int.Parse(s[i]);
                total += x;
                if (max < x)
                    max = x;
            }

            if (total > max * 2)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }


    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 

int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  int A, B, C, D;
  //int ans=1;
  char comp[6]={};
//  int sosu[20000]={};
  char s[5001]={};
  int len;
  int ans[2]={};
  int i,j,k;
  int flag=0;  
//    int k=0;

  
  scanf("%d %d", &A, &B);
  ans[0]=A+B;
  ans[1]=A-B;
  ans[2]=A*B;

  if(ans[0]<ans[1]) ans[0]=ans[1];
  if(ans[0]<ans[2]) ans[0]=ans[2];
  
  
  printf("%d\n", ans[0]);
  
return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
public class Program {
    static void Main (string[] args) {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split();
        var l = new List<int>();
        var t = new List<int>();
        foreach (var i in s) { l.Add(int.Parse(i)); }
        foreach (var i in l) { t.Add(i); }
        t.Sort();
        var x = (int)((n+1) / 2) - 1;
        for (int i = 0; i < n; ++i) {
            if (l[i] <= t[x]) {
                Console.WriteLine(t[x+1]);
            } else {
                Console.WriteLine(t[x]);
            }
        }
    }
}

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

using namespace std;

int main() {
  int N, Q;
  long long int K;
  cin >> N >> K >> Q;
  int ary[N];
  for (int i = 0; i < N; i++) {
    ary[i] = K - Q;
  }
  for (int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    ary[a - 1]++;
  }
  for (int i = 0; i < N; i++) {
    if (ary[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VI a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  VI ord(n);
  iota(all(ord), 0);
  sort(all(ord), [&](int x, int y) {return a[x] < a[y];});
  int ans = 0;
  int count = 0;
  priority_queue<int> q;
  rep(i , m) {
    while(count < n && a[ord[count]] <= i + 1) {
      q.push(b[ord[count]]);
      count++;
    }
    if(!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void setIO(string name) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}


int main() {
   fast(); 
   long long x,y;
   cin>>x>>y;
   if(x*y<0){
    cout<<abs(abs(x)-abs(y))+1<<endl;
     return 0;
   }else{
     if(y==0){
        if(x>0){
          cout<<x+1<<"\n";
          return 0;
        }else{
          cout<<abs(x)<<"\n";
          return 0;
        }
     }
     if(x==0){
        if(y>0){
           cout<<y-x<<"\n";
          return 0;
        }else{
           cout<<abs(y)+1<<"\n";
          return 0;
        }
     }
     if(x<=y){
       
       cout<<y-x<<"\n";
       return 0;
     }else{
        cout<<-y+x+2<<"\n";
       return 0;
     }
   }
   

} 

Measured memory_bytes: 3636
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int T[10000005];
int32_t main()
{
    speed
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=i; j<=n; j+=i)
            T[j]++;
    }
    ll wynik=0;
    for(int i=1; i<=n; i++)
        wynik+=(ll)i*T[i];
    cout<<wynik;
    return 0;
}


Measured memory_bytes: 42640
def main():
    s = input()
    k = int(input())
    print(solve(s, k))

def solve(s, k):
    n = 0
    for c in s:
        if c != '1':
            break
        n += 1

    if k <= n:
        return '1'
    else:
        return s[n]

main()


Measured memory_bytes: 2940
// ABC162 A

#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    cin >> str;
    for(int i =0; i<3; i++){
        if(str.at(i) == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int i,j,a[20],n,b,c,l;
int main()
{
  for(cin>>n>>l;i<n;i++)c+=l+i;
  cout<<(l<0?(l+i>=1?c:c-(l+i-1)):c-l);
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())
A = LI()

mountains = [-1 for i in range(N)]
last = sum(A)//2
for i in range(0,N-1,2):
    last -= A[i]

mountains[-1] = last

for i in reversed(range(N-1)):
    mountains[i] = A[i] - mountains[i+1]

for i in range(N):
    print(mountains[i]*2,end=" ")
print("")


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

/*
dp[i][k][h] := i列処理して、k回変更可能で、最後の高さが h の時の最小スコア
dp[i+1][k][h[i]] <- dp[i][k][h] + max(0, h[i]-h)
dp[i+1][k-1][h'] <- dp[i][k][h] + max(0, h'-h)

b := sorted(h)
c := inv(b)

1. dp[i+1][k][c[i]] <- dp[i][k][j] + max(0, b[c[i]] - b[j])
2. dp[i+1][k-1][j'] <- dp[i][k][j] + max(0, b[j'] - b[j])

1. はまぁあとからやればよくて、 2. の計算量削減が本質
dp[i][k][j] = min_{j'} dp[i-1][k+1][j'] + max(0, b[j] - b[j'])

maxが邪魔なので外す
dp[i][k][j] = min(
				min_{j' >= j} dp[i-1][k+1][j'],
				min_{j' <  j} dp[i-1][k+1][j']-b[j'] + b[j])

セグ木を2本はやしたくなるが log は重い
よく考えるとこれは順番にやれば良い
*/

int n,k;
ll h[325];
ll b[325];
int c[325];

ll dp[2][325][325];

ll seg[325];

int main(){
	scanf("%d%d",&n,&k);
	REP(i,n)scanf("%lld",h+i);
	REP(i,n)b[i] = h[i];
	b[n] = 0;
	sort(b,b+n+1);
	REP(i,n)c[i] = lower_bound(b,b+n+1,h[i]) - b;
	int cur = 0;
	REP(kk,k+1)REP(jj,n+1)dp[cur][kk][jj] = 1ll<<60;
	dp[cur][k][0] = 0;
	REP(i,n){
		int nxt = cur ^ 1;
		REP(kk,k+1)REP(jj,n+1)dp[nxt][kk][jj] = 1ll<<60;
		// 1.
		REP(kk,k+1)REP(jj,n+1){
			CHMIN(dp[nxt][kk][c[i]], dp[cur][kk][jj] + max(0ll, h[i] - b[jj]));
			// CHMIN(dp[nxt][kk][c[i]], dp[cur][kk][jj] + max(0ll, b[jj] - h[i]));
		}
		// 2.
		// dp[i+1][k-1][j'] <- dp[i][k][j] + max(0, b[j'] - b[j])
		// dp[i][k][j] = min(
		// 		min_{j' >= j} dp[i-1][k+1][j'],
		// 		min_{j' <  j} dp[i-1][k+1][j']-b[j'] + b[j])

		REP(kk,k){
			// REP(jj,n+1){
			// 	REP(j2,n+1){
			// 		CHMIN(dp[nxt][kk][jj], dp[cur][kk+1][j2] + max(0ll, b[jj] - b[j2]));
			// 	}
			// }
			// jj > j2 -> dp[j2]-b[j2] + b[jj]
			fill(seg, seg+n+1, 1ll<<60);
			REP(jj,n+1){
				seg[jj] = dp[cur][kk+1][jj] - b[jj];
				CHMIN(seg[jj+1], seg[jj]);
			}
			REP(jj,n+1){
				CHMIN(dp[nxt][kk][jj], seg[jj] + b[jj]);
			}
			fill(seg, seg+n+2, 1ll<<60);
			FORR(jj,0,n+1){
				seg[jj] = dp[cur][kk+1][jj];
				CHMIN(seg[jj], seg[jj+1]);
			}
			REP(jj,n+1){
				CHMIN(dp[nxt][kk][jj], seg[jj]);
			}
		}
		cur = nxt;
		// printf("i=%d\n",i);
		// REP(kk,k+1){
		// 	REP(jj,n+1)printf("%lld ",dp[cur][kk][jj]);puts("");
		// }
		// puts("");
	}
	ll ans = 1ll<<60;
	REP(kk,k+1)REP(jj,n+1)CHMIN(ans, dp[cur][kk][jj]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [0] + list(map(int , input().split())) + [0]
#print(a)
d = 0
for i in range(len(a)):
    d += abs(a[i] - a[i-1])
#print(d)

for i in range(1, len(a)-1):
    x = d - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])
    print(x)




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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
vi a;
int n;
lli f(lli x) {
  rep(i,0,n) {
    x = x - (x % a[i]);
  }
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int k; cin>>k;
  n = k;
  a.resize(n);
  rep(i,0,k) cin>>a[i];
  lli l = 0, r = (long long int)1e18;
  while((r-l)>1) {
    lli mid = (l + r)/2;
    if(f(mid)>=2) {
      r = mid;
    }
    else l = mid;
  }
  if(f(r) != 2) {
    cout<<-1<<endl;
    return 0;
  }
  cout<<r<<" ";
  l = 0; r = (long long int)1e18;
  while((r-l)>1) {
    lli mid = (l + r) / 2;
    if(f(mid) > 2) {
      r = mid;
    }
    else l = mid;
  }
  cout<<l<<endl;
}



Measured memory_bytes: 640
import itertools
import sys
a,b=map(int,input().split())

# 最大公約数（ユークリッドの互除法）
def gcd(A,B):
    while B!=0:
        A,B=B,A%B
    return A

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

print(len(factorization(gcd(a,b)))+1 if a!=1 and b!=1 else 1)
# print(gcd(a,b))
# print(factorization(gcd(a,b)))

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 a, b, c, k;
  cin >> a >> b >> c >> k;
  if (abs(a - b) > 1e18) cout << "Unfair" << endl;
  else {
    if (k % 2 == 0) cout << a - b << endl;
    else cout << b - a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n,m=map(int, input().split())
        l=[list(map(int,input().split())) for i in range(m)]
        for i in range(10**n):
            flag=True
            s=str(i)
            if len(s)!=n:
                continue
            for x,y in l:
                if int(s[x-1])!=y:
                    flag=False
                    break
            if flag:
                return i
        return -1
    print(main())
resolve()

Measured memory_bytes: 38256
N,K=map(int,input().split())
snukes=list()
for i in range(K):
    d=input()
    snukes.append(list(map(int,input().split())))


gotsnacks=[]

for i in snukes:
    for j in i:
        if j not in gotsnacks:
            gotsnacks.append(j)

print(N-len(gotsnacks))

    


Measured memory_bytes: 9132
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    if(a.equals("H")){
      if(b.equals("H")){
        System.out.println("H");
      }else{
        System.out.println("D");
      }
    }else{
      if(b.equals("H")){
        System.out.println("D");
      }else{
        System.out.println("H");
      }
    }
  }
}


Measured memory_bytes: 21844
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int chain = 0,ans = 0;
    bool flag;
    string S,A = "ACGT";
    cin >> S;

    rep(i, S.size()){
        flag = false;
        rep(j, 4){
            if(S.at(i) == A.at(j)){
                flag = true;
            }
        }

        if(!flag){
            ans = max(ans,chain);
            chain = 0;
        }else{
            chain++;
        }
    }

    ans = max(ans,chain);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

void f(const int &k, const int &l, const int &r) {
    if(l == r) {
        cout << l << " ";
        return;
    }
    int a = (l ^ r) & -(l ^ r), kk = k ^ a, b = kk & -kk;
    f(kk, l, l ^ b);
    f(kk, l ^ b ^ a, r);
}

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

    int n, a, b;
    cin >> n >> a >> b;
    if(__builtin_popcount(a ^ b) & 1) {
        cout << "YES" << endl;
        f((1 << n) - 1, a, b);
    } else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }
    else{ 
      char a=s[0];
      string b=s.substr(1);
      s= b+a;
    }
  }
  cout <<"No"<< endl;
}
        
      

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

const int N=1e5+10;

struct Edge{ int to,next; };

Edge way[N<<1];
int n,tot,num[N],l[N],r[N],col[N],k;

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init()
{
	scanf("%d",&n);
	int a,b;
	for (int i=2;i<=n;++i)
	{
		scanf("%d%d",&a,&b);
		Build(a,b);
		Build(b,a);
	}
	for (int i=1;i<=n;++i) l[i]=-1e6,r[i]=1e6;
	scanf("%d",&k);
	for (int i=1;i<=k;++i)
	{
		scanf("%d%d",&a,&b);
		l[a]=r[a]=b;col[a]=b;
	}
}

void Dfs(int x,int fa)
{
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		if (v==fa) continue;
		l[v]=max(l[x]-1,l[v]);
		r[v]=min(r[x]+1,r[v]);
		Dfs(v,x);
	}
	if (fa)
	{
		l[fa]=max(l[x]-1,l[fa]);
		r[fa]=min(r[x]+1,r[fa]);
	}
}

bool use[2000010];
bool FindAns(int x,int fa)
{
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		if (l[v]==r[v]) use[l[v]+1000000]=1;
	}
	col[x]=l[x];
	while (use[col[x]+1000000] && col[x]<=r[x]) col[x]++;
	if (col[x]>r[x]) { col[x]=-1e7; return 0; }
	
	l[x]=r[x]=col[x];
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		if (l[v]==r[v]) use[l[v]+1000000]=0;
	}
	
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		if (v==fa) continue;
		l[v]=max(l[x]-1,l[v]);
		r[v]=min(r[x]+1,r[v]);
		if (!FindAns(v,x)) return 0;
	}
	return 1;
	
}

void Solve()
{
	Dfs(1,0);
	
	bool fl=1;
	for (int i=1;i<=n;++i) if (l[i]>r[i]) fl=0;
	
	if (!fl) printf("No\n");
	else 
	{
		fl=FindAns(1,0);
		if (!fl) { printf("No\n"); return ; }
		printf("Yes\n");
		for (int i=1;i<=n;++i) printf("%d\n",col[i]);
	}
	
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 8704
n=int(raw_input())
a=map(int,raw_input().split())
q=int(raw_input())
m=map(int,raw_input().split())
ans=set()
p=(1<<n)-1
while p:
    w=str(bin(p))[2:]
    bits='0'*(n-len(w))+w
    p-=1
    k=0
    for i,j in enumerate(bits):
        if j=='1':
            k+=a[i]
    ans.add(k)
for i in m:
    print 'yes' if i in ans else 'no'

Measured memory_bytes: 4268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

}



Measured memory_bytes: 26296
#include <stdio.h>
int ruizyou(int x,int n){
	int i,sum=1;
	for(i=1;i<=n;i++){
		sum*=x;}
		return sum;}
int main(void)
{int i,h,a,b,c,k,l,m,N,K,j,v,g,flag,sum;
scanf("%d%d",&N,&K);
printf("%d",K*ruizyou(K-1,N-1));

	return 0;
}


Measured memory_bytes: 128