akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N,K;
    long long at=0;
    long long soeji=0;

    cin >> N >> K;
    vector<pair<long long,long long>>P(N);

    rep(i,N){
        cin >> P[i].first >> P[i].second;
    }
    sort(P.begin(), P.end());
    for(int i=0; i<N; i++){
        at+=P[i].second;
        if(at>=K){
            soeji=i;
            break;
        }
    }

    cout << P[soeji].first << endl;
    return 0;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

string O, E;

int main() {
  cin >> O >> E;
  rep(i, 0, E.size()) { cout << O[i] << E[i]; }
  if (O.size() > E.size()) {
    cout << O.back();
  }
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

int main() {


	ll n, m;
	while (cin >> n >> m, n | m)
	{
	
		vector<ll> a(n + 1, 0);

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

		vector<ll> vec;

		for (int i = 0; i < a.size(); i++)
		{
			for (int j = 0; j < a.size(); j++)
			{
				if (a[i] + a[j] <= m)
				{
					vec.push_back(a[i] + a[j]);
				}

			}
		}

		sort(vec.begin(), vec.end());
		ll siz = vec.size();
		ll maxi = 0;
		for (ll i = 0; i < siz; i++)
		{
			auto itr = upper_bound(vec.begin(), vec.end(), m - vec[i]);

			if (itr == vec.begin())
			{
				if (vec[i] <= m)
				{
					maxi = max(maxi, vec[i]);
				}
			}
			else
			{
				itr--;
				if (vec[i] + *itr <= m)
				{
					maxi = max(maxi, vec[i] + *itr);
				}
			}
			
		}

		a.shrink_to_fit();
		vec.shrink_to_fit();
		cout << maxi << endl;
	}
	

	return 0;
}


Measured memory_bytes: 18904
import Control.Applicative
import Data.List
count :: Eq a => [a] -> a -> Int
count [] x = 0
count (a:as) x = if a == x then 1 + (count as x) else (count as x)



update :: [Int] -> [Int]
update xs = [count xs x |x <- xs]

solve :: [Int] -> ([Int],Int)
solve xs = let xs' = update xs in
           if xs == xs' then (xs,0) else fmap (+1) (solve xs')

     

main = do
  n <- readLn
  if n == 0 then return ()
  else do
    xs <- map read <$> words <$> getLine :: IO [Int]
    let (as,b) = solve xs
    print b
    putStrLn (intercalate " " (map show as))
    main

Measured memory_bytes: 4116
import bisect
N,M,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

ruiA=[0]*N
ruiA[0]=A[0]
for i in range(1,N):
    ruiA[i]=A[i]+ruiA[i-1]


ruiB=[0]*M
ruiB[0]=B[0]
for i in range(1,M):
    ruiB[i]=B[i]+ruiB[i-1]
ans=0
for i in range(N):
    totala=ruiA[i]
    if totala>K:
        break
    res=K-totala
    idx=bisect.bisect_right(ruiB, res)
    if idx==0:
        sub=i+1
    else:
        sub=i+1+idx
    ans=max(ans, sub)

corner=bisect.bisect_right(ruiB, K)
ans=max(ans, corner)
print(ans)
#print(ruiA, ruiB)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    return gcd(b, a % b);
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = 0;
    if (C == D)
    {
        ans += (B - B / C) - (A - 1 - (A - 1) / C);
    }
    else
    {
        ans += (B - B / C - B / D) - (A - 1 - (A - 1) / C - (A - 1) / D);
        ll p = C * D / gcd(C, D);
        ans += B / p - (A - 1) / p;
    }

    cout << ans << endl;
}


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

using std::cin;
using std::cout;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    std::vector<ll> num(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> num[i];
    }
    ll res = -1e18;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 2; j < 4; j++)
        {
            res = std::max(res, num[i] * num[j]);
        }
    }
    cout << res << std::endl;

    // write code above
    return 0;
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

# mod Kをうまく使ってaを全検索

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

num = [0] * K
# 元のNまでの数がmod Kの世界で何になるかを集計
for i in range(1,N+1):
    num[i%K] += 1

ans = 0
# a mod Kを決め打ちしてb mod Kとc mod Kを出す
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    # つじつまが合ってるか確認
    if (b + c) % K == 0:
        # 予め集計してあるmod Kでの数を合計させる
        ans += num[a] * num[b] * num[c]
print(ans)

Measured memory_bytes: 4596
a=[?0*6]
b=a.dup
5.times{|i|
  a<<?0+gets[0,4]+?0
  b<<(i<4?(?0+gets):?0*6)
}
c=[a,b]
x=2
y=d=1
print "R"
while x+y!=2
  case d
  when 1#R
  if c[1][y-1][x]==?1
    y-=1
    d=0
    print "U"
  elsif c[0][y][x]==?1
    x+=1
    d=1
    print "R"
  elsif c[1][y][x]==?1
    y+=1
    d=2
    print "D"
  elsif c[0][y][x-1]==?1
    x-=1
    d=3
    print "L"
  end
  when 2#D
  if c[0][y][x]==?1
    x+=1
    d=1
    print "R"
  elsif c[1][y][x]==?1
    y+=1
    d=2
    print "D"
  elsif c[0][y][x-1]==?1
    x-=1
    d=3
    print "L"
  elsif c[1][y-1][x]==?1
    y-=1
    d=0
    print "U"
  end
  when 3#L
  if c[1][y][x]==?1
    y+=1
    d=2
    print "D"
  elsif c[0][y][x-1]==?1
    x-=1
    d=3
    print "L"
  elsif c[1][y-1][x]==?1
    y-=1
    d=0
    print "U"
  elsif c[0][y][x]==?1
    x+=1
    d=1
    print "R"
  end
  when 0#U
  if c[0][y][x-1]==?1
    x-=1
    d=3
    print "L"
  elsif c[1][y-1][x]==?1
    y-=1
    d=0
    print "U"
  elsif c[0][y][x]==?1
    x+=1
    d=1
    print "R"
  elsif c[1][y][x]==?1
    y+=1
    d=2
    print "D"
  end
  end
end
puts""

Measured memory_bytes: 6092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){

int n,m;
cin>>n>>m;

map< int , char > mp ;
bool flag = 0 ;
array < int, 10 > arr;
for(int i =0 ; i < m;i++){
	
	int s,c;
	cin>>s>>c;
	s--;
	if( !mp.count(s))
	mp[s] = (char)c+48;
	else
	{
		if ((mp[s])!= (char)48+c) 
		flag  =1;
		
	}
	
	arr[s] = c;
	
	
}
ll ans =0 ; 


if(flag == 1)
{
	cout<<-1<<endl;
	return  0 ;
}


string ss = string( n , '*');
for(int i=0 ; i <n;i++){
	
	    if(mp.count( i ))
		ss[i] =  (char)(48+arr[i]);
	
}

if(ss.length() > 1){
	
	if(ss[0] == '0')
	{
		cout<<-1<<endl;
		return  0 ;
	}
	else if( ss[0]=='*')
	ss[0] = '1';
}

for(int i =0 ; i < n ;i++)
if(ss[i] == '*') ss[i] = '0';




//if(ss.length() > 1 && ss[0]=='0')
//{
	//cout<<-1<<endl;
	//return  0; 
//}

cout<<ss<<endl;



return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3648
a, b, k = map(int, input().split())
while True:
    if a % 2 == 1:
        a -= 1
    b += a // 2
    a //= 2
    k -= 1
    if not k:
        break
    if b % 2 == 1:
        b -= 1
    a += b // 2
    b //= 2
    k -= 1
    if not k:
        break
print(a, b)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> c(61,make_pair(0ll, 0ll));
    rep0(i, n){
        ll a;
        cin >> a;
        ll cnt = 0;
        rep0(j,61){
            if(a & 1ll)++c[cnt].first;
            else ++c[cnt].second;
            ++cnt;
            a >>= 1;
        }
    }
    ll t = 1,ans = 0;
    rep0(i, 61){
        ans += c[i].first * c[i].second % mod * t % mod;
        t *= 2;
        ans %= mod;
        t %= mod;
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;cin>>A>>B>>C>>X;
  int ans=0;
  for(int a=0; a<=A; a++){
    for(int b=0; b<=B; b++){
      for(int c=0; c<=C; c++){
        if(a*500+b*100+c*50==X)ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    double pi=3.1415926525897932384626;
    int n;
    cin>>n;
    n*=2;
    cout<<fixed<<setprecision(10);
    cout<<n*pi<<endl;
}

Measured memory_bytes: 3772
#include<stdio.h>
int main(){
  int TT,TA,AT,AA;
  scanf("%d%d%d%d",&TT,&TA,&AT,&AA);
  while (!(TT<=0||AT<=0)){
    AT-=TA;
    if(AT<=0){
      printf("Yes");
      break;
    }
    TT-=AA;
    if(TT<=0){
      printf("No");
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1732
N,X=map(int,input().split())
x=list(map(int,input().split()))
absx=[]
for i in range(len(x)):
    absx.append(abs(x[i]-X))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)
print(gcd_list(absx))

Measured memory_bytes: 14224
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int n;
void exec()
{
	cin >> n;
	if(n==0)exit(0);
	priority_queue<T, vector<T>, greater<T> > l0, l1;
	int m0=0;
	int m1=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		l0.push(T(a,a,b));
		m0=max(m0,a);
	}
	while(l0.size()||l1.size()){
		if(l1.size()==0||(l0.size()&&l0.top()<l1.top())){
			T t=l0.top();
			//cout << "0 " << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << endl;
			l0.pop();
			get<0>(t)=m1=max(m1,get<0>(t)+get<1>(t));
			l1.push(t);
		}
		else
		{
			T t=l1.top();
			//cout << "1 " << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << endl;
			l1.pop();
			get<2>(t)--;
			if(get<2>(t)<=0){
				continue;
			}
			get<0>(t)=m0=max(m0,get<0>(t)+get<1>(t));
			l0.push(t);
		}
	}
	cout << m1 << endl;
}
int main() {
	while(1)exec();
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int cal(int x) {
	return x * (x - 1) / 2;
}
int main() {
	int n, m;
	cin >> n >> m;
	cout << cal(n) + cal(m) << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, h, w) = readLine()!!.split(" ").map{it.toInt()}

    var cnt = 0
    repeat(n) {
        val (h2, w2) = readLine()!!.split(" ").map{it.toInt()}
        if (h2 >= h && w2 >= w) cnt++
    }

    println(cnt)
}

Measured memory_bytes: 36356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
bool flag[200010];
int b[200010];
int f[200010];
int tof[200020];
int tob[200020];
int res1[200010];
int res2[200010];
int N, K, C;
string S;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K >> C >> S;
    tof[0] = N;
    tob[N - 1] = N;
    if(C == 0){
        vector<int> vs;
        for(int i = 0; i < N; i++){
            if(S[i] == 'o') vs.push_back(i);
        }
        if(vs.size() == K){
            for(auto u : vs) cout << u + 1 << endl;
        }
        return 0;
    }
    for(int i = 0; i < N; i++){
        if(i != 0) tof[i] = tof[i - 1];
        if(S[i] == 'o') tof[i] = i;
    }
    for(int i = 0; i < N; i++){
        if(i != 0) f[i] = f[i - 1];
        if(S[i] == 'o'){
            if(i - C - 1 >= 0) chmax(f[i], f[tof[i - C - 1]] + 1);
            else chmax(f[i], 1);
        }
    }
    for(int i = N - 1; i > 0; i--){
        tob[i] = tob[i + 1];
        if(S[i] == 'o') tob[i] = i;
    }
    for(int i = N - 1; i >= 0; i--){
        b[i] = b[i + 1];
        if(S[i] == 'o'){
            if(i + C + 1 < N) chmax(b[i], b[tob[i + C + 1]] + 1);
            else chmax(b[i], 1);
        }
    }
    for(int i = 0; i < N; i++){
        res1[i] = f[i];
        if(i + C + 1 < N) res1[i] += b[i + C + 1];
    }
    for(int i = N - 1; i >= 0; i--){
        res2[i] = b[i];
        if(i  - C - 1 >= 0) res2[i] += f[i - C - 1];
    }

    int ov = 0;
    for(int i = 1; i <= C; i++){
        if(res2[i] >= K) ov++;
    }
    for(int i = 0; i < N; i++){
        if(S[i] == 'o'){
            if(ov == 0) cout << i + 1 << endl;
        }
        if(i - C + 1 >= 0){
            if(res1[i - C + 1] >= K) ov--;
        }
        if(i + C + 1 < N){
            if(res2[i + C + 1] >= K) ov++;
        }
        if(res2[i + 1] >= K) ov--;
        if(res1[i] >= K) ov++;
    }
    return 0;
}

Measured memory_bytes: 5396
// SeeAlso: 

#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 MAX 100000
#define NIL -1
#define MOD 1000000007

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int n;
    string S;
    char c[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
    cin >> n;
    cin >> S;
    for (auto it = S.begin(); it != S.end(); it++) {
        char value = *it;
        int ind;
        rep(i, 26) {
            if(c[i]==value) {
                ind = i;
            }
        }
        ind = (ind+n) % 26;
        cout << c[ind];
    }
    cout << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int M=100000007;

int h,w;
char B[10][11];

int encode(const vector<int> &S){
	int res=0;
	rep(i,w+1) res=res*3+S[i];
	return res;
}

int dp[10][10][177147];
int dfs(int i,int j,vector<int> S){
	if(i==h){
		bool ok=true;
		rep(k,w+1) if(S[k]>0) ok=false;
		return ok?1:0;
	}

	if(j==w){
		if(S[w]>0) return 0;
		else       return dfs(i+1,0,S);
	}

	int E=encode(S);
	if(dp[i][j][E]!=-1) return dp[i][j][E];

	int res=0;
	if(B[i][j]=='.'){
		if(S[w]==0){
			res+=dfs(i,j+1,S);
			res%=M;
		}
		else if(S[j]==0){
			res+=dfs(i,j+1,S);
			res%=M;
		}
	}
	else{
		int num=B[i][j]-'0';
		if(S[w]+S[j]<=num){
			num-=S[w]+S[j];
			if(num<=4){
				rep(k,num+1) if(k<=2 && num-k<=2) {
					S[j]=k;
					S[w]=num-k;
					res+=dfs(i,j+1,S);
					res%=M;
				}
			}
		}
	}

	return dp[i][j][E]=res;
}

int main(){
	scanf("%d%d",&h,&w);
	rep(i,h) scanf("%s",B[i]);

	memset(dp,-1,sizeof dp);
	printf("%d\n",dfs(0,0,vector<int>(w+1,0)));

	return 0;
}

Measured memory_bytes: 70276
#include "bits/stdc++.h"
using namespace std;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(abs(c-a)<=d)
  {
    cout<<"Yes"<<endl;
  }
else
{
  if(abs(b-a)<=d&&abs(c-b)<=d)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
     cout<<"No"<<endl;
  }
}
}
   
  
    


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func pow(args ...int) int {
  x, y := args[0], args[1]
  res := 1
  if len(args) == 3 {
    mod := args[2]
    for y != 0 {
      if y & 1 == 1 {res = res * x % mod}
      y >>= 1
      x = x * x % mod
    }
  }  else {
    for y != 0 {
      if y & 1 == 1 {res *= x}
      y >>= 1
      x *= x
    }
  }
  return res
}

func main() {
  var n int
  fmt.Scan(&n)
  fmt.Println(pow(n, 3))
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int t,n,m;
int arr[maxn];
int gcd(int a,int b)
{
    return b>0?gcd(b,a%b):a;
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	ll fin=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				int zz=gcd(i,j);
				int zzz=gcd(zz,k);
				fin+=zzz;
			}
		}
	}
	cout<<fin<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    cout << a[n-1]-a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
cnt = [0]*n
cnt_e = [0]*n
cnt_w = [0]*n
e = 0
w = 0
for i in range(n):
    if s[i] == "E":
        e += 1
    else :
        w += 1
    cnt_e[i] = e
    cnt_w[i] = w

cnt[0] =  e - cnt_e[0]
for i in range(1,n):
    cnt[i] = cnt_w[i-1] + e - cnt_e[i]

print(min(cnt))

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

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
elif N >= 1800 and N <= 1999:
    print(1)


Measured memory_bytes: 9180
n, m = map(int, input().split())
drink = [list(map(int, input().split())) for i in range(n)]
drink.sort()
ans = 0

for i, j in drink:
    if m != 0:
        if m >= j:
            ans += i * j
            m -= j
        else:
            ans += i * m
            break

print(ans)

Measured memory_bytes: 27476
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;

const int M=1e5+5;
int a[M];
int datagroup=0;

int main()
{
    int num;
    memset(a,0,sizeof(a));
    scanf("%d",&datagroup);
    for(int i=1;i<=datagroup;i++)
    {
        scanf("%d",&num);
        a[num]=i;
    }
    for(int i=1;i<=datagroup;i++)
    {
        printf("%d",a[i]);
        if(i!=datagroup)
        printf(" ");
    }
    return 0;
}


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

using namespace std;

int main() {
    //forItachi
    int n;
    vector<int> v1;
    vector<int> v2;
    int i;
    cin>>n;
    for(i=0;i<n;i++){
        int x;
        cin>>x;
        
        v1.push_back(x);
    }
    v2.push_back(0);
    v2.push_back(abs(v1[1]-v1[0]));
    for(i=2;i<n;i++){
        
        v2.push_back(std::min(abs(v1[i]-v1[i-1])+v2[i-1],abs(v1[i]-v1[i-2])+v2[i-2]));
    }
    
    cout<<v2[n-1]<<endl;
}
    
    
	
	        
	
	    
    


Measured memory_bytes: 1400
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  /*unusedはまだ生成してないスライム
    slimeは生成したスライム*/
  std::multiset<ll> unused,slime;
  rep(i,0,1<<n){
    ll s;
    std::cin>>s;
    unused.insert(s);
  }

  //unusedの最大値を最初のスライムにする
  slime.insert(*unused.rbegin());unused.erase(*unused.rbegin());

  //各秒を貪欲で考える
  rep(i,0,n){
    //この秒で生成するスライムを保管しておくtemp
    std::vector<ll> temp;

    //今いるスライム各々が生成できる最大のスライムを作る
    for(auto itr=slime.rbegin();itr!=slime.rend();itr++){
      auto itr2=unused.lower_bound(*itr);

      //自分より小さいスライムがいないならNo
      if(itr2==unused.begin()){
        std::cout<<"No";
        return 0;
      }
      itr2--;
      temp.push_back(*itr2);
      unused.erase(itr2);
    }

    rep(j,0,1<<i)slime.insert(temp[j]);
  }

  std::cout<<"Yes";

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,i,a,b;
    t = 1;
    while(t--) {
     a = b = 0;
	 cin >> n;
	 int arr[n],brr[n];
	 for(i = 0; i < n; i++) {
	  cin >> arr[i];
	  brr[i] = arr[i];
     }
     sort(brr, brr + n);
	 for(i = 0; i < n; i++) {
	  if(arr[i] != brr[i])
	   a++;
	 }
	 for(i = n - 1; i >= 0; i--) {
	  if(arr[i] != brr[i])
	   b++;
	 }
	 if(min(a, b) <= 2) 
	  cout << "YES" << endl;
	 else
	  cout << "NO" << endl;
    }
    return 0;
}


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

int main(){
  int a,b,c,cnt_tyou=0,cnt_hishi=0;
  while(scanf("%d,%d,%d",&a,&b,&c) != EOF){
    if(a==b) cnt_hishi++;
    if(a*a + b*b == c*c) cnt_tyou++;
  }
  cout<<cnt_tyou<<endl<<cnt_hishi<<endl;
  return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int ans = 0;
	if (N < 10){
		ans = N;
	} else if (N < 100) {
		ans = 9;
	} else if (N < 1000) {
		ans = 9;
		ans += N - 99;
	} else if (N < 10000) {
		ans = 9;
		ans += 900;
	} else if (N < 100000) {
		ans = 9;
		ans += 900;
		ans += N - 9999;
	} else {
		ans = 9;
		ans += 900;
		ans += 100000 - 1 - 9999;
	}

	cout << ans << "\n";


	return 0;
}


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

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

    ll n;
    cin >> n;

    ll res = 0;
    rep1(i, n+1){
        if(i%3==0 || i%5==0) continue;

        res += i;
    }

    cout << res << endl;

    return 0;
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    int N; long long X;
    cin >> N >> X;
    vector<long long> x(N);
    for (int i = 0; i < N; ++i) cin >> x[i], x[i] -= X;
    long long g = abs(x[0]);
    for (int i = 0; i < N; ++i) g = GCD(g, abs(x[i]));
    cout << g << endl;
}

Measured memory_bytes: 1024
import scala.collection.mutable.Stack
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val bst = new Bst()
  val n = readInt
  for (_ <- 0 until n) {
    val arr = readLine.split(" ")
      arr(0) match {
      case "insert" => bst.insert(arr(1).toInt)
      case "find" => if (bst.find(arr(1).toInt)) println("yes") else println("no")
      case "print" => bst.printTree()
    }
  }

  class Node(val value: Int) {
    var left: Node = null
    var right: Node = null
    var visited: Boolean = false
  }

  class Bst {

    var root: Node = null

    def insert(value: Int): Unit = {
      if (root == null) {
        root = new Node(value)
        return
      }
      var prev: Node = null
      var cur = root
      while (cur != null) {
        prev = cur
        if (cur.value > value) {
          cur = cur.left
          if (cur == null) prev.left = new Node(value)
        } else {
          cur = cur.right
          if (cur == null) prev.right = new Node(value)
        }
      }
    }

    def find(value: Int): Boolean = {
      var cur = root
      while (cur != null) {
        if (cur.value == value) {
          return true
        } else if (cur.value > value) {
          cur = cur.left
        } else {
          cur = cur.right
        }
      }
      false
    }

    def printTree(): Unit = {
      inOrder()
      preOrder()
    }

    def inOrder(): Unit = {
      val stack = new Stack[Node]
      stack.push(root)
      while (!stack.isEmpty) {
        var node = stack.top
        while (node.left != null && !node.left.visited) {
          stack.push(node.left)
          node = node.left
        }
        node = stack.pop
        if (!node.visited) {
          print(s" ${node.value}")
          node.visited =true
        }
        if (node.right != null && !node.right.visited) {
          stack.push(node.right)
        }
      }
      println()
    }

    def preOrder(): Unit = {
      val stack = new Stack[Node]
      stack.push(root)
      while (!stack.isEmpty) {
        val node = stack.pop
        if (node != null) {
          node.visited = false
          print(s" ${node.value}")
          stack.push(node.right)
          stack.push(node.left)
        }
      }
      println()
    }
  }
}



Measured memory_bytes: 458688
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	 int n,q,w,e,s;
	 scanf("%d",&n);
	 q=n/1000;
	 w=(n%1000)/100;
	 e=(n%100)/10;
	 s=n%10;
	 if(q==w&&w==e&&e==s)  printf("Yes");
	 else if(w==e && e==s) printf("Yes");
	// else if(q==e && e==s) printf("Yes");
	 else if(q==w && w==e) printf("Yes");
	 else printf("No");
	 return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    string S;
    cin >> S;
    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    auto ss = S.substr(2, S.length()-3);
    auto a = ss.find_first_of('C');
    auto b = ss.find_last_of('C');
    if (a == string::npos || a != b) {
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 0; i < S.length(); ++i) {
        if (i == 0 || i == a + 2) {
            continue;
        }
        if (S[i] < 'a' || 'z' < S[i]) {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    string S;
    cin >> S;
    string T;
    cin >> T;
    bool flag = true;
    REP(i, S.size()){
        if (S[i] != T[i]) flag = false;
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



ll n,k;
double a[200010];


bool ok(double t){
    ll cnt=0;
    rep(i,n){
        double s=a[i]/t;
        
        // cout<<i<<" "<<s<<" ";
        ll x=floor(s);
        // cout<<x<<endl;
        if(abs((double)x-s)<eps) cnt+=x-1;
        else cnt+=x;
    }
    if(cnt<=k) return true;
    else return false;
}




void solve(){
    
    cin>>n>>k;
    
    rep(i,n) cin>>a[i];
    double low=0.0,high=1e10;
    rep(i,100){
        double mid=(low+high)/2;
        if(ok(mid)){
            high = mid;
        } else{
            low = mid;
        }
    }
    ll x=floor(high);
    if(abs((double)x-high)<eps) cout<<x<<endl;
    else cout<<x+1<<endl;
    

}

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


    solve(); 


    return 0;
}


Measured memory_bytes: 5284
import sys
sys.setrecursionlimit(10 ** 6)

N, M, X = map(int, input().split())
C = []
A = []

for i in range(N):
    S = list(map(int, input().split()))
    C.append(S[0])
    A.append(S[1:])

patterns = []

def dfs(buyable, pattern, idx):
    copy = pattern[:]
    if len(copy) == buyable:
        patterns.append(copy)
    elif idx == N:
        return
    else:
        dfs(buyable, copy, idx+1)
        copy.append(idx)
        dfs(buyable, copy, idx+1)

achived = False
_min = sum(C)
for i in range(1, N+1):
    patterns = []
    dfs(i, [], 0)

    for pattern in patterns:
        total = 0
        tmp = [0 for i in range(M)]
        for j in pattern:
            total += C[j]
            for k in range(M):
                tmp[k] += A[j][k]

        if min(tmp) >= X and _min >= total:
            _min = total
            achived = True

if achived:
    print(_min)
else:
    print(-1)


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

int main()
{
    int A,B;
    cin >> A >> B;
    int sum = 0;
    for(int i=A; i<=B; i++){
        string a = to_string(i);
        string b = a;
        reverse(a.begin(),a.end());
        if(a == b){
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define prec 0.00000000000000000001
#define inf (ll)1e18
#define mod 998244353
ll dp[401][401];
vec arr;
vec pre;
ll n;
ll func(ll l,ll r) {
	if(l == r)
		return 0;
	if(dp[l][r] != -1)
		return dp[l][r];
	ll res = inf,i;
	for(i = l ; i <= r - 1 ; i++) {
		res = min(res,func(l,i) + func(i+1,r) + pre[r] - pre[l-1]);
	}
	return dp[l][r] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	arr.resize(n+1);
	pre.resize(n+1,0);
	ll i;
	ll counti = n;
	for(i = 0 ; i <= n ; i++)
		for(int j = 0 ; j <= n ; j++)
			dp[i][j] = -1;
	ll cost = 0;
	for(i = 1 ; i <= n ; i++) {
		cin >> arr[i];
		pre[i] = arr[i] + pre[i - 1];
	}
	cout << func(1,n);
	return 0;
}

Measured memory_bytes: 4932
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
mod=10**9+7
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count=count*3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count=count*2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count=count*1
  else:
    if x.count(a[i])==0:
      count=0
      break
    else:
      count=count*x.count(a[i])
      x[x.index(a[i])]+=1
print(count%mod)

Measured memory_bytes: 14008
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int ses[M];
 main()

{
    fast
    int n,q;
    cin>>n>>q;
    vector< tuple<double,int,int> >vec;
    f(i,1,n)
    {
        int s,t,x;
        cin>>s>>t>>x;
        double lft=s-0.5-x;
        double rgt=t-0.5-x;
        int p=1,q=-1;
        vec.pb(make_tuple(lft,p,x));
        vec.pb(make_tuple(rgt,q,x));
    }
    f(i,1,q)
    {
        int x;
        cin>>x;
        vec.pb(make_tuple(x,0,i));
    }
    sort(vec.begin(),vec.end());
    multiset<int>s;
    for(auto z:vec)
    {
        int typ=get<1>(z);
        double tym=get<0>(z);
        int x=get<2>(z);
        if(typ==1)
        {
           s.insert(x);
        }
        else if(typ==-1)
        {
            s.erase(x);
        }
        else
        {
            if(s.empty())ses[x]=-1;
            else ses[x]=*(s.begin());
        }
    }
    f(i,1,q)
    {
        cout<<ses[i]<<"\n";
    }
    return 0;

}





































Measured memory_bytes: 28088
#include <cstdio>
#include <algorithm>
using namespace std;


int main() {
  long long int n, ans = 1;
  scanf("%lld", &n);
  for (long long int i = 1; i <= n; i++) {
    ans = (ans * i % 1000000007);
  }
  printf("%lld", ans);
  
  return 0;
  
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] W = new int[N];
        for (int i=0; i<N; i++){
            W[i] = sc.nextInt();

        }
        sc.close();

        int first=0,end=0,all=0;
        int min = Integer.MAX_VALUE;
        int a=0,b=0;

        for (int i=0; i<N; i++){
            all += W[i];
        }
        for (int i=0; i<N; i++){
            first += W[i];
            end = all - first;
            if (Math.abs(first - end) < min){
                min = Math.abs(first - end);
                a = first;
                b = end;
            }else{
                break;
            }

        }


        System .out.println(Math.abs(Math.abs(a - b)));

    }
}


Measured memory_bytes: 23764
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    d = np.zeros((9, 9), dtype='i8')

    for i in range(1, N + 1):
        s = str(i)
        a = int(s[0])
        b = int(s[-1])
        if a != 0 and b != 0:
            d[a - 1][b - 1] += 1

    ans = 0
    for i in range(9):
        for j in range(9):
            if i == j:
                ans += d[i][j] * (d[i][j] - 1) + d[i][j]
            else:
                ans += d[i][j] * d[j][i]

    # print(d)
    print(ans)


if __name__ == '__main__':
    solve()


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

#define pb push_back

using namespace std;

int n , k;

int main() {
	cin >> k >> n;
	if(k%2 == 0){
		cout << k/2;
		for (int i = 0; i < n-1; ++i){
			printf(" %d", k);
		}
		puts("");
		return 0;
	}
	vector<int> v;
	for (int i = 0; i < n; ++i){
		v.pb((k+1)/2);
	}
	int op = (n)/2;
	while(op--){
		if(v.back()==1){
			v.pop_back();
		}else{
			v.back()--;
			while(v.size() != n)v.pb(k);
		}
	}
	for (int i = 0; i < v.size(); ++i){
		if(i)printf(" ");
		printf("%d", v[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 3568
object Main {
  val sc = new java.util.Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val map = Map("A" -> "T", "C" -> "G", "T" -> "A", "G" -> "C")

    println(map(sc.next))

  }
}

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

int main () {
  string a , b ;
  cin >> a >> b ;
  
  for(int i = 0 ; i < a.size() ; i++ ) {
    cout << a[i] ;
    if(i < b.size()) cout << b[i] ;
  }
  cout << endl ;
}

Measured memory_bytes: 256
inp = [int(a) for a in input().split()]
X = inp[0]
N = inp[1]
if N == 0:
  print(X)
else:
  P = [int(b) for b in input().split()]

  found = 0
  num = 0
  answer = X
  while(found == 0):
    if not (X - num in P):
      found = 1
      answer = X - num
    elif not (X + num in P):
      found = 1
      answer = X + num
    num += 1
  print(answer)

Measured memory_bytes: 9108
S = input()
a = S[0:2]
b = S[2:4]

def is_month(s):
    if 1 <= int(s) <= 12:
        return True
    else:
        return False


if is_month(a) and is_month(b):
    print("AMBIGUOUS")
elif is_month(a) and is_month(b) == False:
    print("MMYY")
elif is_month(a) == False and is_month(b):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    int k;
    cin >> k;
    bool hh = true;
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            if (a[j]-a[i] > k) {
                hh = false;
            }
        }
    }
    if (hh) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int a=sc.nextInt();
    int b=sc.nextInt();

    int x;

    if((a+b)%2!=0){
      System.out.println((a+b)/2+1);
    }else{
      System.out.println((a+b)/2);
    }

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(i,a,b) for (int i = a; i <= (b); ++i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
cin >> n;
cout << n * n * n << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

const int MAX_V = 500;  //★必要に応じて変える
struct edge { int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

int N, GG, E;
set<int> p;
int a, b;

//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap)
{
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

//増加パスをDFSで探す
int dfs(int v, int t, int f)
{
    if (v == t) return f;
    used[v] = true;
    for (int i=0; i<G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s, int t)
{
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

signed main()
{
    int H, W;
    char c;
    int sy, sx, gy, gx;

    cin >> H >> W;
    REP(i,H) REP(j,W) {
        cin >> c;
        if (c == 'S') {
            add_edge(300, i, INF);
            add_edge(300, 100 + j, INF);
            sy = i;
            sx = j;
        } else if (c == 'T') {
            add_edge(i, 301, INF);
            add_edge(100 + j, 301, INF);
            gy = i;
            gx = j;
        } else if (c == 'o') {
            add_edge(i, 100 + j, 1);
            add_edge(100 + j, i, 1);
        }
    }

    if (sy == gy || sx == gx) {
        cout << -1 << endl;
    } else {
        cout << max_flow(300, 301) << endl;
    }
}


Measured memory_bytes: 896