akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, k;
    cin >> n >> k;
    if(n == 1)
    {
      if(k == 1) cout << 1 << " " << 2 << " " << 3 << endl;
      else cout << -1 << endl;
      return 0;
    }
    vector<ll> nmax(n+1);
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        nmax[i] = k + 2 * n + i;
        sum += nmax[i];
    }
    ll su = 0;
    set<ll> s;
    for(int i = 0; i < 2*n; i++)
    {
        ll cand = k + i;
        s.insert(cand);
        su += cand;
    }
    if(su > sum)
    {
        cout << -1 << endl;
        return 0;
    }
    ll start = *s.rbegin();
    ll ls = nmax[n-1]-start;
    int i = 0;
    vector<vector<ll>> ans;
    while(true)
    {
        ll h = nmax[n-1-i];
        ll m = start;
        ll l = h - m;
        if(l >= m) break;
        s.erase(m);
        s.erase(l);
        ans.push_back({l, m, h});
        start -= 2;
        i++;
    }
    start = *s.rbegin();
    int j = 0;
    while(j < n-i)
    {
        ll h = nmax[n-1-i-j];
        ll m = start;
        ll l = h - m;
        if(l >= ls) break;
        s.erase(m);
        s.erase(l);
        ans.push_back({l, m, h});
        start -= 2;
        j++;
    }
    int size = n-i-j;
    while(size)
    {
        ll h = nmax[size-1];
        ll l = *s.begin();
        ll m = *s.rbegin();
        ans.push_back({l, m, h});
        s.erase(m);
        s.erase(l);
        size--;
    }
    for(int i = 0; i < n; i++)
    {
      cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
    }
      
}




Measured memory_bytes: 15152
#include <stdio.h>
#include <stdlib.h>

int main() {
  int a,b,i;
  scanf("%d",&a);
  scanf("%d",&b);
  int counter = 0;
  for(i=a;i<b+1;i++) {
    if(i%10==i/10000 && (i/10)%10==(i/1000)%10) {
      counter++;
    }
  }
  printf("%d\n",counter);
}


Measured memory_bytes: 888
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int n;
  cin >> n;
  vector<int> a;
  int t;
  REP(i,n){
    cin >> t;
    a.push_back(t);
  }
  t = 0;
  for(;;){
    REP(i,n){
      if (a[i]%2!=0) {
        cout << t;
        return 0;
      } else {
        a[i]/=2;
      }
    }
    t++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;
 
const int INF = 1e9 + 7;
 
using namespace std;
 
int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;

	cout << max({a-b, a+b, a*b}) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, K;
vector<pair<int, int>> ans;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;

	rep(i, 1, N) ans.push_back({ 0, i });

	int k = (N - 1) * (N - 2) / 2;
	if (k < K) {
		cout << -1 << endl;
		return;
	}

	rep(i, 1, N) rep(j, i + 1, N) {
		if (K == k) break;

		ans.push_back({ i, j });
		k--;
	}

	int n = ans.size();
	printf("%d\n", n);
	fore(p, ans) printf("%d %d\n", p.first + 1, p.second + 1);
}







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

using namespace std;

int main() {
    string s;
    cin >> s;
    int i = 0, j = s.size() - 1;
    int res = 0;
    while (i < j) {
        if (s[i] != s[j]) res++;
        i++; j--;
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    int n,k;
    cin >> n >> k;
    vl v(n);
    rep(i,n)cin >> v[i];
    cout << (n+k-3)/(k-1) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

ll l[100100];
int u[100100];
int n, q, k;
vector<pii> v[100100];

void dfs(int ver, ll lvl = 0){
	u[ver] = 1;
	l[ver] = lvl;
	for(int i = 0; i < sz(v[ver]); ++i){
		int to = v[ver][i].f;
		ll w = v[ver][i].s;
		if(!u[to]){
			dfs(to, w + lvl);
		}
	}
}

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d", &n);
	for(int i = 0, x, y, z; i < n - 1; ++i){
		scanf("%d%d%d", &x, &y, &z);
		x--; y--;
		v[x].pb(mp(y, z));
		v[y].pb(mp(x, z));
	}
	scanf("%d%d", &q, &k);
	dfs(k - 1);
	for(int i = 0, x, y; i < q; ++i){
		scanf("%d%d", &x, &y);
		x--; y--;
		cout << l[x] + l[y] << "\n";
	}
	return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<math.h>

int main()
{
	int n, i, sum, s[1000] = {};
	double a, average;
	while (1)
	{
		a = 0; sum = 0;
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}
		for (i = 0; i < n; i++)
		{
			scanf("%d", &s[i]);
			sum += s[i];
		}
		average = (double)sum / (double)n;
		for (i = 0; i < n; i++)
		{
			a += pow(s[i] - average, 2.0);
		}
		printf("%f\n", sqrt(a / (double)n));
	}

	return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long zero = 0;
  long minus = 0;
  long sum = 0;
  for (long i = 0; i < n; i++) {
    if (a[i] == 0) {
      zero++;
    }
    if (a[i] < 0) {
      minus++;
      a[i] *= -1;
    }
    sum += a[i];
  }
  if (zero != 0 || minus%2 == 0) {
    printf("%ld\n", sum);
    return 0;
  }
  qsort(a, n, sizeof(long), cmpnum);
  sum -= a[0]*2;
  printf("%ld\n", sum);

  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int64_t>kil(n);
  int64_t s=0,a=0,k=0,b=0;
  for(int i=0;i<n;i++){
    cin >> kil.at(i);
    s+=kil.at(i);
  }
  while(a<s/2){
    a+=kil.at(k);
    k++;
  }
  if(abs(a-s/2)>abs(a-kil.at(k-1)-s/2)){
    a-=kil.at(k-1);
    k--;
  }
  while(k<kil.size()){
    b+=kil.at(k);
    k++;
  }
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 4800
N = gets.chomp.to_i
W = []
N.times do |n|
  W[n] = gets.chomp
end

flag = true
flag = false if W.uniq.size() != W.size()
N.times do |n|
  if n != 0 then
    flag = false if W[n-1][-1] != W[n][0]
  end
end
flag ? print("Yes") : print("No")


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const ll mod = 1000000007;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define NN 9

struct Puzzle{
    int f[NN];
    int space;
    string path;

    bool operator < (const Puzzle &p) const{
        for(int i = 0; i < NN; i++){
            if(f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p){
    for(int i = 0; i < NN; i++){
        if(p.f[i] != (i + 1)) return false;
    }
    return true;
}

string bfs(Puzzle s){
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        if(isTarget(u)) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for(int r = 0; r < 4; r++){
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if(!V[v]){
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}

int main(){
    Puzzle in;

    for(int i = 0; i < NN; i++){
        cin >> in.f[i];
        if(in.f[i] == 0){
            in.f[i] = NN;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;

    return 0;
}

Measured memory_bytes: 30628
#include <bits/stdc++.h>
#define endl '\n'
#define _USE_MATH_DEFINES
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    int i,in[5],ans = 0;
    for(i = 0;i<5;i++){
    	cin>>in[i];
    	if(in[i] == 0) ans = i;
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	char buf[2];

	scanf("%s",buf);

	if(buf[0] >= 'A' && buf[0] <= 'Z'){

		printf("A\n");

	}else{

		printf("a\n");
	}

	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 100005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 

#define mod  1000000007



int main()
{
	FAST;
	string s;
	 int w;
	 cin >> s >> w;
	for(int i = 0 ;i < s.size(); i += w){
		cout << s[i];
	} 
	return 0;
	
}

Measured memory_bytes: 3620
#include <iostream>
void N1() {printf("Hello World\n");}
void N2() {
  int A,B; scanf("%d%d", &A, &B);
  printf("%d\n", A+B);
}
int main() {
  int N; scanf("%d", &N);
  if      (N==1) {N1();}
  else if (N==2) {N2();}
}

Measured memory_bytes: 256
N = int(input())
TXY = []
for n in range(N):
    TXY.append([int(i) for i in input().split()])
temp = [0,0,0]
ans = True
for txy in TXY:
    dist = (txy[1]-temp[1]) + (txy[2]-temp[2])
    if (txy[0]-temp[0]) % 2 == dist % 2 and (txy[0]-temp[0]) >= dist:
        temp = txy
    else:
        ans = False
print("Yes") if ans else print("No")

Measured memory_bytes: 21108
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = [0]*N
    index = 0
    for i in range(N)[::-1]:
        if index <0:
            B[index] = A[i]
            index *= -1
        else:
            B[index] = A[i]
            index = -index -1
    print(' '.join(map(str, B)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 28680
from fractions import gcd
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

def lcm(a, b):
    return (a*b) // gcd(a, b)

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M // k


if b % 2 == 0:
    r = int(b/2)
else:
    r = int((b + 1) / 2)

for a in A[1:]:
    if k // a % 2 == 0:
        r = 0
        break

print(r)

Measured memory_bytes: 85856
#include<algorithm>
#include<iostream>
using namespace std;
int a[100100],n,k=2;
bool no=true;
int main()
{
	cin>>n;
	for(int i=0;i<100000;i++)
		a[i]=999999999;
	a[1]=n;
	while(1>0)
	{
		if(n%2==0)
			n=a[k]=n/2;
		else
			n=a[k]=3*n+1;
		for(int i=1;i<k;i++)
		{
			if(a[i]==a[k])
			{
				no=false;
				break;
			}
		}
		if(no==false)
		{
			cout<<k<<endl;
			break;
		}
		k++;
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#define maxN 300000
#define repeat(i, N, M) for(int i = N; i < M; i++)

int
main(int argc, char *argv[])
{
  int n; char s[maxN + 1]; int w[maxN] = {}, e[maxN] = {};
  scanf("%d", &n);
  scanf("%s", s);
  
  repeat(i, 1, n){
    w[i] = w[i - 1] + (s[i - 1] == 'W' ? 1 : 0);
    e[i] = e[i - 1] + (s[i - 1] == 'E' ? 1 : 0);
  }

  int arr[maxN]; int ans = maxN;

  repeat(i, 0, n - 1){
    arr[i] = w[i] + e[n - 1] + (s[n - 1] == 'E' ? 1 : 0) - e[i + 1];
    ans = (arr[i] < ans ? arr[i] : ans);
  }
  arr[n - 1] = w[n - 1];
  ans = (arr[n - 1] < ans ? arr[n - 1] : ans);

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

  return 0;
}


Measured memory_bytes: 2816
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

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

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

	cin >> N;
	vector<long long int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		M ^= v[i];
	}
	for (int i = 30; i >=0; i--) {
		if (M >> i & 1) {
			bool flag = false;
			for (int j = 0; j < N; j++) {
				if (v[j] % (int)pow(2, i) == 0 && v[j] % (int)pow(2, i + 1)) {
					flag = true;
				}
			}
			if (!flag) {
				cout << "-1\n";
				return 0;
			}
			M ^= (int)pow(2, i);
			M ^= (int)(pow(2, i) - 1);
			K++;
		}
	}
	if (!M) {
		cout << K << endl;
	}
	else {
		cout << "-1\n";
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int INF = 1e9 + 7;

signed main()
{
	string s; cin >> s;
	int n = s.size();
	int k; cin >> k;

	vector<string> A;

	rep(i, n) {
		string t = "";
		rep(j, min(k, 5ll)) {
			if (i + j < n) {
				t += s[i + j];
				A.PB(t);
			}
		}
	}

	sort(all(A));
	unique(all(A));

	cout << A[k - 1] << endl;
}


Measured memory_bytes: 1660
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
q = INT()
p = [0]*q
flag = 0
c0 = c1 = ''

for i in range(q):
        p[i] = input()
        if p[i][0] == '1':
                flag = 1 - flag
        else:
                t, f, c = p[i].split()
                if (f == '1' and flag == 0) or (f == '2' and flag == 1):
                        c0 = c + c0
                else:
                        c1 = c1 + c

s = c0 + s + c1
print(s if flag == 0 else s[::-1])

Measured memory_bytes: 25104
use std::io::{stdin, Read};
 
fn main() {
    let mut buffer = String::new();
    let mut stdin = stdin();
 
    stdin.read_to_string(&mut buffer).unwrap();
    match &*buffer {
        "ABC\n" => println!("ARC"),
        "ARC\n" => println!("ABC"),
        _ => println!(""),
    }
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    string S; cin >> S;
    ll ln = sz(S);
    rep(_,ln) cout << 'x';
    print("");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct query{
    ll s,t,x;
};

int main(){
    ll n,q;
    cin >> n >> q;
    vector<query> que(n);
    rep(i,n) cin >> que[i].s >> que[i].t >> que[i].x;
    map<ll,ll> ans;
    set<ll> st;
    rep(i,q){
        ll d;
        cin >> d;
        ans[d] = -1;
        st.insert(d);
    }

    sort(que.begin(),que.end(),[](const query &l,const query &r){
        return l.x < r.x;
    });

    rep(i,n){
        ll a = que[i].s - que[i].x;
        ll b = que[i].t - que[i].x;
        auto it = st.lower_bound(a);
        
        if(*it >= b) continue;
        while(it != st.end()){
            ans[*it] = que[i].x;
            it = st.erase(it);
            if(it == st.end()) break;
            if((*it) >= b) break;
        }

    }

    for(auto p:ans) cout << p.second << endl; 

    return 0;
}

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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var m = long.Parse(inputs[1]);

            if (n == m)
            {
                Console.WriteLine("Draw");
                return;
            }

            if (n == 1)
            {
                Console.WriteLine("Alice");
                return;
            }
            if (m == 1)
            {
                Console.WriteLine("Bob");
                return;
            }

            if (n > m)
            {
                Console.WriteLine("Alice");
                return;
            }
            else
            {
                Console.WriteLine("Bob");
                return;
            }
        }
    }
}


Measured memory_bytes: 27136
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define LL long long
using namespace std;
inline int get_num() {
    char c;
    int f = 1, num = 0;
    while ((c = getchar()) == ' ' || c == '\n' || c == '\r')
        ;
    if (c == '-')
        f = -1;
    else
        num = c - '0';
    while (isdigit(c = getchar())) num = num * 10 + c - '0';
    return num * f;
}
int main() {
    string s;
    cin >> s;
    stack<char> v;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'S') {
            v.push(s[i]);
        } else if (s[i] == 'T') {
            if (!v.empty() && v.top() == 'S') {
                ans++;
                v.top();
                v.pop();
            } else {
                v.push(s[i]);
            }
        }
    }
    cout << s.size() - ans * 2;
    return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define PI 3.14159265358979323846264338327950L
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[2000006];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<2000006;i++)
	{
		if(sieve[i])
		{
			for(int j=i*i;j<2000006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}
int kadane(int* a,int n)
{
	int loc=a[0],glo=a[0];
	for(int i=1;i<n;i++)
	{
		loc=max(a[i],loc+a[i]);
		glo=max(glo,loc);
	}
	return glo;
}

int dp[1001][1001];

int solve(int i,int j,vector<vector<char>>& a,int m,int n)
{
	if(i>=m or j>=n) return 0;

	if(i==m-1 and j==n-1) return 1;

	if(a[i][j]=='#') return 0;

	if(dp[i][j]!=-1) return dp[i][j];
	return dp[i][j]=(solve(i+1,j,a,m,n)%mod+solve(i,j+1,a,m,n)%mod)%mod;
}
int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	
	
	memset(dp,-1,sizeof dp);
	int m,n;
	cin>>m>>n;


	vector<vector<char>>a(m,vector<char>(n,0));
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	cout<<solve(0,0,a,m,n)%mod<<endl;
}



Measured memory_bytes: 8208
import java.util.Scanner;

// https://atcoder.jp/contests/abc164/tasks/abc164_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		sc.close();

		if(w>=s) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}


	}
}


Measured memory_bytes: 27004
s=input()
w=["dream","dreamer","erase","eraser",""]
while True:
    

    if s[0:5]==w[0]:
        if s[5:7]=="er": #dremaerかeraserかerase
            if s[7]=="a": #erはeraseかeraserのer
                s=s[5:]
            else:
                s=s[7:]
        else:
            s=s[5:]

    elif s[0:5]==w[2]:
        if s[5]=="r": 
            s=s[6:]
        else:
            s=s[5:]
    else:
        print("NO")
        exit()

    if len(s)<=7:
        if s in w:
            print("YES")
            exit()
        else:
            print("NO")
            exit()
    
    #print(s)

Measured memory_bytes: 3188
def solve():
    N,X,Y = [int(i) for i in input().split()]
    distance_cnt = {}
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            distance = min(j-i, abs(X-i)+abs(Y-j)+1)
            distance_cnt[distance] = distance_cnt.get(distance, 0) + 1
    for i in range(1, N):
        print(distance_cnt.get(i, 0))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9432
A = "AC"
N, Q = map(int, input().split())
S = list(input())
ans = [0]
cnt = 0
for j in range(N - 1):
    tmp1 = S[j] + S[j + 1]
    if tmp1 == A:
        cnt += 1
    ans.append(cnt)

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])



Measured memory_bytes: 54520
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    bool a = 0,b = 0,c = 0,d = 0;
    char x;
    REP(i, 4){
        cin >> x;
        if(x == '1') a = 1;
        if(x == '4') b = 1;
        if(x == '7') c = 1;
        if(x == '9') d = 1;
    }
    if(a && b && c && d) YOUT;
    else NOUT;
}



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrepn(i, n) for (int i = ((int)(n)); i > 0; --i)
#define SZ(x) ((int)(x).size())
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;
}
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y) {
    bool flg = false;
    rep(i, X + 1) {
        if (i * 2 + (X - i) * 4 == Y) flg = true;
    }
    if (flg)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(X, Y);
    return 0;
}


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

int main(){
  string s,hazime,gyaku,mae,usiro,maehazime,maegyaku,usirohazime,usirogyaku;
  cin >> s;
  hazime = s;
  reverse(s.begin(),s.end());
  gyaku = s;
  
  for(int i = 0;i < (s.length() - 1) / 2;i ++){
    mae += s[i];
  }
  maehazime = mae;
  reverse(mae.begin(),mae.end());
  maegyaku = mae;
  
  for(int i = 0;i < (s.length() - 1) / 2;i ++){
    usiro += s[i + (s.length() + 1) / 2];
  }
  usirohazime = usiro;
  reverse(usiro.begin(),usiro.end());
  usirogyaku = usiro;
  
  if(hazime == gyaku && maehazime == maegyaku && usirohazime == usirogyaku)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

typedef unsigned long long ull;

int main()
{
    using namespace std;

    int n;
    cin >> n;

    vector<ull> T(n, 0);
    vector<ull> V(n, numeric_limits<ull>::max());

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

    V[0] = T[0];
    int length = 1;
    for( int i=1; i<n; ++i ) {
        if ( T[i] > V[length-1] ) {
            V[length] = T[i];
            ++length;
        } else {
            *lower_bound(V.begin(), V.begin() + length + 1, T[i]) = T[i];
        }
    }

    cout << length << endl;
}

Measured memory_bytes: 2592
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

int dx[]={0,0,0,0,1,1,1,1};
int dy[]={0,1,2,3,0,1,2,3};
int fx[]={-1,0,0,1};
int fy[]={0,-1,1,0};
signed main(){
	int a,b;
	while(cin>>a>>b,a||b){
		int c,d,e,f,g;
	scanf("%d%d%d%d%d",&c,&d,&e,&f,&g);
	c--;d--;e--;f--;
	char h[100][100]{};
	for(int i=0;i<g;i++){
		int j,k,l,m;
		scanf("%d%d%d%d",&j,&k,&l,&m);
		l--;m--;
		if(k){
			for(int n=0;n<8;n++)h[l+dx[n]][m+dy[n]]=j;
		}
		else{
			for(int n=0;n<8;n++)h[l+dy[n]][m+dx[n]]=j;
		}
	}
	queue<P>Q;
	int s[100][100];
for(int ss=0;ss<a;ss++){
	for(int qq=0;qq<b;qq++)s[ss][qq]=-1;
}
	s[c][d]=0;
	Q.push(P(c,d));
	while(Q.size()){
		P w=Q.front();
		Q.pop();
		if(w==P(e,f)){break;}
		for(int z=0;z<4;z++){
			int lx=(w).first+fx[z];
			int ly=(w).second+fy[z];
			if(lx>=0&&lx<a&&ly>=0&&ly<b&&h[lx][ly]==h[c][d]&&s[lx][ly]==-1){
				s[lx][ly]=s[(w).first][(w).second]+1;
				Q.push(P(lx,ly));
			}
		}
	}
if(s[e][f]!=-1)printf("OK\n");
else printf("NG\n");
	}
}

Measured memory_bytes: 3184
#include <iostream>

using namespace std;

int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    int ans=0;
    for(int i=0;i<N;i++){
        if(s[i]=='R'){
            ans++;
        }else{
            ans--;
        }
    }
    if(ans>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	vector<int> a(4);
	vector<int> b(4);
	while (cin>>a[0]){
	int hit_count=0;
	int blow_count=0;
	REP(i,3){
		cin>>a[i+1];
	}
	REP(i, 4){
		cin >> b[i];
	}
	REP(i, 4){
		if (a[i] == b[i]){
			hit_count++;
		}
	}
	REP(i, 4){
		REP(j, 4){
			if (i==j)continue;
			if (a[i] == b[j]){
				blow_count++;
			}
		}
	}
	cout << hit_count << " "<<blow_count<<endl;
	}
}

Measured memory_bytes: 3056
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, res;

signed main() {
	cin >> n >> m;
	for (int i=1; i*i<=m; i++) if (m%i==0) {
		if (m/i>=n) chmax(res,i);
		if (i>=n) chmax(res,m/i);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cfenv>
#include <cmath>

using namespace std;

int main() {
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;

  if(x1 == 0)
    cout<<1<<endl;
  else if(x2==0)
    cout<<2<<endl;
  else if(x3==0)
    cout<<3<<endl;
  else if(x4==0)
    cout<<4<<endl;
  else if(x5==0)
    cout<<5<<endl;
  

  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

#define max_3(a, b, c) max(a, max(b, c))
using namespace std;

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

    typedef vector <int> v_int;
    v_int swim_happiness(no_of_days + 1);
    v_int bug_happiness(no_of_days + 1);
    v_int homework_happiness(no_of_days + 1);

    for(int i = 1; i <= no_of_days; i++)
        cin >> swim_happiness[i] >> bug_happiness[i] >> homework_happiness[i];

    const int NO_OF_TYPES = 3;
    vector <v_int> maximum_happiness(no_of_days + 1, v_int(NO_OF_TYPES, 0));

    const int SWIM_TODAY = 0, BUG_TODAY = 1, HOMEWORK_TODAY = 2;
    for(int i = 1; i <= no_of_days; i++)
    {
        maximum_happiness[i][SWIM_TODAY] = swim_happiness[i] + max(maximum_happiness[i - 1][BUG_TODAY], maximum_happiness[i - 1][HOMEWORK_TODAY]);

        maximum_happiness[i][BUG_TODAY] = bug_happiness[i] + max(maximum_happiness[i - 1][HOMEWORK_TODAY], maximum_happiness[i - 1][SWIM_TODAY]);

        maximum_happiness[i][HOMEWORK_TODAY] = homework_happiness[i] + max(maximum_happiness[i - 1][SWIM_TODAY], maximum_happiness[i - 1][BUG_TODAY]);
    }

    int overall_happiness = max_3(maximum_happiness[no_of_days][SWIM_TODAY], maximum_happiness[no_of_days][BUG_TODAY], maximum_happiness[no_of_days][HOMEWORK_TODAY]);

    cout << overall_happiness;
    return 0;
}


Measured memory_bytes: 6912
import java.util.*; 
class Main 
{
public static void main(String []args) 
{
Scanner sc = new Scanner(System.in); 
int x1 = sc.nextInt(); 
int x2 = sc.nextInt(); 
int x3 = sc.nextInt(); 
int x4 = sc.nextInt(); 
int x5 = sc.nextInt();   
  
if(x1==0)  
{
System.out.println("1");
} 
else if(x2==0)  
{
System.out.println("2");
} 
else if(x3==0)  
{
System.out.println("3");
} 
else if(x4==0)  
{
System.out.println("4");
} 
else  
{
System.out.println("5");
}  
} 
}

Measured memory_bytes: 35648
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
  map<string,int> m;
  string s;
  int maxn = 0;
  string maxns;
  string maxls;
  while(cin >> s) {
    if(++m[s] > maxn) {
      maxn = m[s];
      maxns = s;
    }
    if(s.size() > maxls.size()) maxls = s;
  }
  cout << maxns << " " << maxls << endl;
  return 0;
}

Measured memory_bytes: 1196
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
T = list(input())

lens = len(S)
lent = len(T)
maxcnt = 0
for i in range(lens-lent+1):
    cnt = 0
    for j in range(lent):
        if S[i+j]==T[j]:
            cnt += 1
    maxcnt = max(maxcnt, cnt)
print(lent-maxcnt)

Measured memory_bytes: 65264
#include<stdio.h>
int w[105];
int main()
{
    int n,i,t,m,q=200;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
      scanf("%d",&w[i]);
    for(t=1;t<=n;t++)
    {
        int sum1=0,sum2=0;
        for(i=1;i<=t;i++)
           sum1+=w[i];
        for(i=t+1;i<=n;i++)
            sum2+=w[i];
        if(sum1>sum2)
        {
            m=sum1;
            sum1=sum2;
            sum2=m;
        }
        if(sum2-sum1<q)
           q=sum2-sum1;
    }
    printf("%d\n",q);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static string w;
        
        

        public static void Input()
        {
            var cin = new Scanner();
            w = Console.ReadLine();
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            bool ok = true;
            for(var i = 0; i < w.Length; i++)
            {
                if (w.Count(x => x == w[i]) % 2 != 0)
                {
                    ok = false;
                    break;
                }
            }
            Console.WriteLine(ok ? "Yes" : "No");
            
            //Console.Out.Flush();

        }





    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 11220
#include <iostream>

using namespace std;

struct Person{
    int A; //体力
    int B; //攻撃力
    
    void attack(Person& rival){
        rival.A=rival.A-B;
    }
};


int main(int argc, const char * argv[]) {
    
    Person takahashi,aoki;
    
    cin>>takahashi.A>>takahashi.B>>aoki.A>>aoki.B;
    
    while(true){
        
        takahashi.attack(aoki);
        if(aoki.A<=0){
            cout<<"Yes"<<endl;
            break;
        }else if(takahashi.A<=0){
            cout<<"No"<<endl;
            break;
        }
        aoki.attack(takahashi);
        if(aoki.A<=0){
            cout<<"Yes"<<endl;
            break;
        }else if(takahashi.A<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ll a,v,b,w,t; cin >>a >>v >>b >>w >>t;
  if(a>b){
    v*=-1; w*=-1;
    if(a+t*v<=b+t*w) cout <<"YES";
    else cout <<"NO";
  }
  else{
    if(a+t*v>=b+t*w) cout <<"YES";
    else cout <<"NO";
  }
return 0;}

Measured memory_bytes: 3636
n = int(input())

dp = [10**10] * (n+1)
dp[0] = 0

for i in range(1,n+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 6
        
for i in range(1,n+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9
        
print(dp[-1])
    



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  if(k == 1) {
    cout << 0 << "\n";
    return 0;
  }
  
  cout << n-k << "\n";

}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> a(W*H);
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++) {
      cin >> a.at(W*j+i);
    }
  }
  for (int k = 0; k < W+2; k++) {
    cout << "#";
  }
  cout << endl;
  for (int m = 0; m < H; m++) {
    cout << "#";
    for (int l = 0; l < W; l++) {
      cout << a.at(W*m+l);
    }
    cout << "#" << endl;
  }
  for (int k = 0; k < W+2; k++) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
S=input()
N=len(S)

if "C" in S and "F" in S:
  c=S.index("C")
  S=S[::-1]
  f=N-S.index("F")-1
  #print(c,f)
  print("Yes" if c<f else "No")
else: 
  print("No")

Measured memory_bytes: 2940
from fractions import gcd

A, B, C, D = map(int, input().split())
N = B - A + 1
lcm_CD = (C * D) // gcd(C, D)

sumB = B - B // C - B // D + B // lcm_CD
sumA = (A - 1) - (A - 1) // C - (A - 1) // D + (A - 1) // lcm_CD

print(sumB - sumA)

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



int main()
{
    int N,k[100],ans,min,max=0;

    cin >> N;
    
    for (int i = 0; i < N;i++) {
        cin >> k[i];
        if (i == 0) {
            min = k[i];
        }
        if (max < k[i]) {
            max = k[i];
        }
        if (min > k[i]) {
            min = k[i];
        }
    }
    ans = max - min;

    cout << ans;
        
    cout << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> MA;
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, MA[a]++;

  long sum = 0;
  for (auto ma : MA) sum += (long)ma.second * (ma.second - 1) / 2;

  for (int i = 0; i < N; i++) {
    long a = MA[A.at(i)];
    cout << sum - a * (a - 1) / 2 + (a - 1) * (a - 2) / 2 << "\n";
  }
}

Measured memory_bytes: 8320
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n;
  rep(i, n) {
    cin >> a;
    mp[a]++;
    if (mp[a] % 2 == 1)
      ans++;
    else
      ans--;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 7260
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

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

using namespace std;

int main(){
    int n;
    while(cin >> n){
        if(n==0) break;
        string str;
        int left = 0; int right = 0;
        int cnt = 0;
        bool on_step = false;

        REP(i,n){
            cin >> str;
            if(str=="lu") left = 1;
            else if(str=="ru") right = 1;
            else if(str=="ld") left = 0;
            else if(str=="rd") right = 0;

            if(!on_step && left+right==2){
                cnt++;
                on_step=true;
            }else if(on_step && left+right==0){
                cnt++;
                on_step=false;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <iomanip>

using namespace std;

int main(){

  int a,b;
  double f;

  cin >> a >> b;

  cout << (a/b) << " " << ( a%b)  << " " ;

  cout << fixed << setprecision(5) << ( double(a) / b ) << endl;
  

}


Measured memory_bytes: 3280
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MAX = 1e9;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  ll S;
  while (cin >> N >> K >> S) {
    vector<ll> res(N);
    for (int i = 0; i < K; i++) res[i] = S;
    ll rem;
    if (S == MAX) {
      rem = MAX - 1;
    } else {
      rem = S + 1;
    }
    for (int i = K; i < N; i++) res[i] = rem;
    for (ll x : res) cout << x << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2048