akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define	LL	long long
#define	INF	0x3f3f3f3f
using namespace std;

template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
const int N = 50050,M = 100050;
int n,m,T;
int ex[M],ey[M]; char ans[M]; bitset<50001>v[N];
int main(){
	int i,j; 
	bool vis[N];
	read(n),read(m),read(T);
	for (i = 1; i <= m; ++i) read(ex[i]),read(ey[i]);
	if (T==2){
		int cnt[N],a[N];
		if (n==2){puts("-1");return 0;}
		for (i = 1; i <= n; ++i) cnt[i] = 1,a[i] = i;
		for (i = m; i >= 1; --i){
			int x = ex[i],y = ey[i];
			if (a[x]==a[y]) ans[i]='^';
			else if (cnt[a[x]] >= 2){ --cnt[a[x]]; a[x] = a[y]; ++cnt[a[x]]; ans[i]='v'; }
			else{ --cnt[a[y]]; a[y] = a[x]; ++cnt[a[y]]; ans[i]='^'; }
		}
		for (i = 1; i <= m; ++i) putchar(ans[i]); putchar('\n');
		return 0;
	}
	for (i = 1; i <= n; ++i) v[i].set(i);
	for (i = 1; i <= m; ++i) v[ex[i]] = v[ey[i]] = v[ex[i]] | v[ey[i]];
	for (i = 1; i <= n; ++i) if (v[i].count()==n){
		vis[i] = 1;
		for (j = m; j >= 1; --j) if (vis[ex[j]]) ans[j] = '^',vis[ey[j]] = 1; else if (vis[ey[j]]) ans[j] = 'v',vis[ex[j]] = 1; else ans[j] = 'v';
		for (j = 1; j <= m; ++j) putchar(ans[j]); putchar('\n');
		return 0;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 306816
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    int count = 0;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        while (temp % 2 == 0)
        {

            temp /= 2;
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split()))
count = 1
upd = 0
for i in range(N-1):
  s0 = np.sign(A[i+1] - A[i])
  if upd == 0:
    upd = s0
  elif s0 != 0 and s0 != upd:
    upd = 0
    count += 1
print(count)

Measured memory_bytes: 23088
s = input()
cnt = 1
now = s[0]
index = 1

while True:
    if s[index] == now and index == len(s)-1:
        break
    if s[index] == now:
        now = s[index:index+2]
        index += 2
        cnt += 1
    else:
        now = s[index]
        index += 1
        cnt += 1
    if index >= len(s):
        break

print(cnt)

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int res = (n + (x - 1)) / x * t;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3596
n = gets.chomp.to_i
stack = []
for i in 1..n do 
    a = gets.chomp.to_i
    # print a,stack,"\n"
    if stack.empty?
        stack.push(a)
        next
    end
    head = 0
    tail = (stack.size) -1
    mid = (head+tail)/2
    
    if stack[tail] >= a
        stack.push(a)
        next
    end

    while head < tail
        if stack[mid] >= a
            head = mid+1
        else
            tail = mid
        end
        mid = (head+tail)/2
    end

    stack[mid] = a
end


p stack.size

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int N, M, K;
vector<int> nakama;

class UnionFind {
public:
    vector <int> par; // 各元の親を表す配列
    vector <int> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(int sz_): par(sz_), siz(sz_, 1) {
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);  // resize だとなぜか初期化されなかった
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    int root(int x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) { // 連結判定
        return root(x) == root(y);
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

 

int main() {
    cin >> N >> M >> K;
    int a, b;
    UnionFind Uni(N);
    vector<int> friA(M), friB(M), bloA(K), bloB(K);
    vector<int> ans(N);


    for(int i=0; i<M; i++){
	cin >> a >> b;
	a--;
	b--;
	Uni.merge(a, b);
	friA[i]=a;
	friB[i]=b;
    }
    
    for(int i=0; i<K; i++){
	cin >> a >> b;
	a--;
	b--;
	bloA[i]=a;
	bloB[i]=b;
    }

    for(int i=0; i<N; i++){
    	ans[i]=Uni.size(i)-1;
    }
    for(int i=0; i<M; i++){
    	int tmp = Uni.same(friA[i], friB[i]);
    	ans[friA[i]] -= tmp;
    	ans[friB[i]] -= tmp;
    }

    for(int i=0; i<K; i++){
    	int tmp=Uni.same(bloA[i], bloB[i]);
    	ans[bloA[i]]-=tmp;
    	ans[bloB[i]]-=tmp;	
    }

    for(int i=0; i<N; i++){
    	cout << ans[i] << endl;
    }

}



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

#define EPS (1e-6)

int p, n;
double sp;

int main(){
  while(cin >> p >> n, p || n){
    sp = sqrt(p);

    double maxVal = 0;
    double minVal = 999999999;
    int x = -1, y = -1, u = -1, v = -1;

    // j / i = sp
    for(int i = 1; i <= n; i++){
      int j = (int)floor(sp * i - EPS);
      int k = (int)ceil(sp * i + EPS);

      if(j <= n){
	double div = (double)j / i;

	if(maxVal < div){
	  maxVal = div;
	  u = j;
	  v = i;
	}
      }
      if(k <= n){
        double div = (double)k / i;

	if(minVal > div){
	  minVal = div;
	  x = k;
	  y = i;
	}
      }
    }

    int g = __gcd(x, y);
    x /= g;
    y /= g;

    g = __gcd(u, v);
    u /= g;
    v /= g;

    cout << x << "/" << y << " " << u << "/" << v << endl;
  }
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
    int i[11],j,k;
    for(j=0;j<10;j++){
        scanf("%d",&j[i]);
    }
    for(j=0;j<3;j++){
        for(k=j+1;k<10;k++){
            if(i[j]<i[k]){
                i[10]=i[j];
                i[j]=i[k];
                i[k]=i[10];
            }
        }
    printf("%d\n",i[j]);
    }
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll a,b,c;
    cin >> a >> b >> c;
    if(a%2==0 || b%2==0 || c%2==0) cout << 0 << endl;
    else cout << min({a*b,b*c,a*c}) << endl;
    return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  if(S.size() > N){
      for(int i = 0; i < N; i++){
      cout << S.at(i);
  }
      cout << "..." << endl;
  } else {
      cout << S << endl;
  }
}

Measured memory_bytes: 3628
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let x: i64 = input();
    let l: Vec<i64> = (0..n).map(|_| input()).collect();

    let mut d = vec![0; n + 1];
    for i in 1..n + 1 {
        d[i] = d[i - 1] + l[i - 1];
    }
    println!("{}", d.iter().filter(|&&d| d <= x).count());
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>


int main(){
  int N, M, K;
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &K);
  std::vector<long long> A(N), B(M), Asum(N+1), Bsum(M+1);
  Asum[0]=0;
  Bsum[0]=0;
  for (int i=0; i<N; i++){
    scanf("%lld", &A[i]);
    Asum[i+1]=Asum[i]+A[i];
  }
  for (int i=0; i<M; i++){
    scanf("%lld", &B[i]);
    Bsum[i+1]=Bsum[i]+B[i];
  }
  int ans = 0;
  for (int i=0; i<=N; i++){
    int cnt = i;
    long long sum = Asum[i];
    if (sum>K) break;
    auto itr = std::upper_bound(Bsum.begin(), Bsum.end(), K-sum);
    cnt += (int)(itr-Bsum.begin()-1);
    ans = std::max(ans, cnt);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 9216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());

			double root = Math.sqrt(n);

			int rootInt = (int) root;

			System.out.println(rootInt * rootInt);
		}
	}
}


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

int main(void) {
  int a, b, ans;
  cin >> a >> b;
  ans = 0;
  for (int i = a; i <= b; i++) {
    int head1, head2, tail;
    head1 = i / 10000;
    head2 = i / 1000 - 10 * head1;
    tail = i % 100;
    if (tail == head1 + head2 * 10) {
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
S=input()
x=set(['A','T','C','G'])
ans=0
l=len(S)
for i in range(l+1):
    for j in range(i,l+1):
        #print(i,j,S[i:j])
        for s in S[i:j]:
            if s not in x:
                break
        else:
            ans=max(ans,j-i)
print(ans)

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

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  if (L < R) cout << "Right" << endl;
  else if (L > R) cout << "Left" << endl;
  else cout << "Balanced" << endl;
}

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

int main(){
   int n;
   cin >> n;
   if(n==1){
       cout << "Hello World" << endl;
       return 0;
   }
   int a ,b;
   cin >> a >> b;
   cout << a+b << endl;
   return 0;
}


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

int main(){
  long long h,w,k;
  cin>>h>>w>>k;
  vector<vector<char>>s(h,vector<char>(w));
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      cin>>s[i][j];
    }
  }
  vector<vector<long long>>ans(h,vector<long long>(w));
  long long sum=0;
  long long count=0;
  for(int i=0;i<h;++i){
    long long c=0;
    for(int j=0;j<w;++j){
      if(s[i][j]=='#') ++c;
      if(c==0||c==1){
        ans[i][j]=count+1;
      }
      else ans[i][j]=count+c;
    }
    if(c==0&&count==0) ++sum;
    if(c==0&&count!=0){
      for(int j=0;j<w;++j){
        ans[i][j]=ans[i-1][j];
      }
    }
    count+=c;
  }
  for(int i=0;i<sum;++i){
    for(int j=0;j<w;++j){
      ans[i][j]=ans[sum][j];
    }
  }
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}

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

    
int main(){
    
    int n,k;
    cin >> n ;
    cin >> k ;
    vector<char> s(n);
    for(int i=0;i<n;i++){
        cin >> s.at(i);
    }
    
    if(s.at(k-1)=='A'){s.at(k-1)='a';}
    if(s.at(k-1)=='B'){s.at(k-1)='b';}
    if(s.at(k-1)=='C'){s.at(k-1)='c';}
    for(int i=0;i<n;i++){
        cout << s.at(i);
    }
  cout << endl;
}


Measured memory_bytes: 256
from collections import deque

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

edge = [[] for i in range(N)]
for i in range(M):
    x, y, _ = map(int, input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)

visited = [False] * N

ans = 0
for i in range(N):
    if visited[i]:
        continue
    else:
        ans += 1

    q = deque([i])
    while q:
        cur = q.pop()
        visited[cur] = True

        for next in edge[cur]:
            if visited[next]:
                continue
            visited[next] = True
            q.append(next)

print(ans)

Measured memory_bytes: 27948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
	sc.close();

	int ans = Math.min(N*A, B);
	System.out.println(ans);
	}
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

s = input()

# 整数の入力
#n = int(input())

# スペース区切りの入力
#n, x = input().split()

# スペース区切りの整数の入力
#a, b = map(int, input().split())
#n, x = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#a = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#print("a", a, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#b = []
#for x in range(m):
#  b.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def ton(n, k, x):
  s = ""
  while n > 0:
    s = str(n%k) + s
    n //= k
  return s


#print("a", a, file=sys.stderr)
#print("b", b, file=sys.stderr)

def getEnergy():
  for y in b:
    yield y

def doit2(s = s):
  res = 0
  prev = None
  now = None
  for x in s:
    if now == None:
      now = x
    else:
      now += x
    if prev == now:
      now += x
    else:
      res += 1
      prev = now
      now = None
    print(prev, now, res, file=sys.stderr)

  #print(res, file=sys.stderr)
  return res

def doit():
  return max(doit2(s), doit2(reversed(s)))

def yn():
  if doit():
    return "YES"
  else:
    return "NO"

#print(doit([0] * 4))
#doit(a)
#print(doit())
try:
  #doit()
  print(doit())
  #print(yn())
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 6060
#pragma GCC optimize("3","Ofast","inline")
#include<bits/stdc++.h>
#define _ 0
using namespace std;
typedef long long ll;
template<class T>inline void read(T &x) {
    x=0;T f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-48,ch=getchar();
    x*=f;
}
const int maxn=100005;
int v[maxn],cnt[2][maxn],n;
typedef pair<int,int> pii;
vector<pii>v1,v2;
int main() {
	read(n);
	for(int i=0;i<n;++i)
		read(v[i]),cnt[i&1][v[i]]++;
	for(int i=0;i<maxn;++i)
		v1.push_back(pii(cnt[0][i],i));
	for(int i=0;i<maxn;++i)
		v2.push_back(pii(cnt[1][i],i));
	sort(v1.begin(),v1.end(),greater<pii>());
	sort(v2.begin(),v2.end(),greater<pii>());
	if(v1[0].second!=v2[0].second)
		return 0*printf("%d\n",n-v1[0].first-v2[0].first);
	else
		return 0*printf("%d\n",min(n-v1[1].first-v2[0].first,n-v1[0].first-v2[1].first));
	return ~~(0^_^0);
}

Measured memory_bytes: 3700
#include<stdio.h>
int main(){
  int n,q,i;
  scanf("%d%d",&n,&q);
  char s[n+1];
  int left[n+2];
  scanf("%s",s);
  left[0]=0;
  for(i=1;i<=n;i++){
    left[i]=left[i-1];
    if(s[i-1]=='A' && s[i]=='C')
      left[i]+=1;
  }
  int l,r,ans[q+1];
  for(i=0;i<q;i++){
    scanf("%d%d",&l,&r);
    ans[i]=left[r-1]-left[l-1];
  }
  for(i=0;i<q;i++)
    printf("%d\n",ans[i]);
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int mod=1000000007;
int main() {
  long k,a,b;
  cin >> k>>a>>b;
  long ans=0;
  if(a+1<b){
    if(k>a){
      k-=a-1;
      ans=a+k/2*(b-a)+k%2;
    }
    else{
      ans=k+1;
    }
  }
  else{
    ans=k+1;
  }
  cout<<ans<<endl;  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") {
		cout << "No";
		return 0;
	}
	cout << "Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
#define vec vector<int>
#define For(b) for(int i=0;i<b;i++)
#define all(x) x.begin(),x.end()
#define debug(x) cout<<(#x)<<" "<<"="<<" "<<x<<endl;
using namespace std;

void solve()
{
   int k;
   cin >> k;
   
   for(int i=0;i<k;i++)
   {
       cout<<"ACL";
   }
   cout<<endl;
  
  
}

int32_t main(){ 
  
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);   
 
      solve();
  
    
    return 0;
} 


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
long sort(const long *a,const long *b){
return *a-*b;
}

int main(void){
int n;
  scanf("%d",&n);
  long a[n];
  for(int i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
qsort(a,n,sizeof(a[0]),sort);
  for(int i=0;i<n-1;i++){
	if(a[i]==a[i+1]){
      	printf("NO");
      return 0;
    }
  }
printf("YES");
  return 0;
}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
typedef priority_queue<PA, vector<PA>, greater<PA> > PQ;
typedef map<int, const char*> MAP;
typedef set<PA> SET;
#define fi first
#define se second
#define pb push_back
#define REP(i,j,n) for(ll i = (ll)(j);i < (ll)(n);i++)
#define INF 1000000001
#define MOD 10000
#define MAXD 201
#define MAXN 100001
#define MAXM 1001
int a,b,c;
string s;

int main()
{
    cin >> s;
    REP(i, 0, s.size()){
        if(s[i] == 'a'){
            a++;
        }
        else if(s[i] == 'b'){
            b++;
        }else if(s[i] == 'c'){
            c++;
        }
    }
    if(a == 1 && b == 1 && c == 1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}
/*O(10 ^ 8)　が限界 (2s以内)
    REP(i,a){
        REP(j,b){
4 4
1 2 100
2 3 250
2 4 200
3 4 100

        }
    }
*/



Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
#1_A
"""
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
print(m,end = ": ")
for i in range(len(ans)-1):
    print(ans[i], end = " ")
print(ans[-1])
"""

#1_B
"""
m,n = map(int, input().split())
b = bin(n)[2:]
num = [m]
for i in range(len(b)-1):
    num.append(num[-1]**2%1000000007)
ans = 1
for i in range(len(b)):
    ans *= num[i] if b[len(b)-1-i] == "1" else 1
    ans %= 1000000007
print(ans)
"""

#1_C
"""
import math

l = int(input())
a = list(map(int, input().split()))
dict = {}
for n in a:
    ans = []
    i = 2
    k = math.sqrt(n)
    dic = {}
    while i <= k:
        if n%i == 0:
            n = n//i
            ans.append(i)
            i -= 1
            if n == 1:
                break
        i += 1
    if len(ans) == 0 or n != 1:
        ans.append(n)
    for i in ans:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
    for i in dic.keys():
        if i in dict:
            dict[i] = max(dict[i], dic[i])
        else:
            dict[i] = dic[i]
sum = 1
for x,y in dict.items():
    sum *= x**y
print(sum)
"""

#1_D
"""
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
dic = {}
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
ans = list(set(ans))
sum = m
for i in ans:
    sum *= (1-1/i)
print(int(sum))
"""

#1_E
"""
def gcd(a,b):
    if a==0:
        return b
    return gcd(b%a,a)
a,b = LI()
g = gcd(a,b)
a//=g
b//=g
if b == 1:
    print(0,1)
    quit()
if b < 4:
    f = b-1
else:
    p = []
    x = 2
    m = b
    while x**2 <= b:
        if not m%x:
            p.append(x)
            while not m%x:
                m//=x
        x += 1
    if m != 1:p.append(m)
    f = b
    for i in p:
        f *= (1-1/i)
    f = int(f)
x_ = pow(a,f-1,b)
y_ = (1-a*x_)//b
ans = [x_,y_,abs(x_)+abs(y_)]
for i in range(-10000,10000):
    s = -b*i+x_
    t = a*i+y_
    m = abs(s)+abs(t)
    if m < ans[2]:
        ans = [s,t,m]
    elif m == ans[2] and s <= t:
        ans = [s,t,m]
print(ans[0],ans[1])
"""

#2
#2_A
"""
a,b = LI()
print(a+b)
"""
#2_B
a,b = LI()
print(a-b)



Measured memory_bytes: 8480
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    if((a+b)%2!=0)
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    else
    {
        cout<<(a+b)/2<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void Solve()
    {
        var a = cin.Nextdouble;
        var b = cin.Nextdouble;
        
        if(a < b)
        {
            var t = a;
            a = b;
            b = t;
        }
        if (a - b < 360 + b - a)
        {
            Console.WriteLine((a + b) / 2);
        }
        else
        {
            var c = (360 + b - a) / 2 + a;
            if (c >= 360) c -= 360;
            Console.WriteLine(c);
        }

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}


Measured memory_bytes: 9300
fun main(args: Array<String>) {
  val N = readLine()!!.toLong()
  var n = Math.floor(Math.sqrt(N.toDouble())).toInt()
  for (i in 0..n) {
    if (N%(n-i) == 0L) {
      println(n-i + N/(n-i) -2)
      break
    }
  }
}

Measured memory_bytes: 33724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException
	{
		int i,j,n,m;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String[] nm = br.readLine().split(" ");

		n = Integer.parseInt(nm[0]);//input n
		m = Integer.parseInt(nm[1]);//input m

		int[][] matrix = new int[n][m];
		int[] vsum = new int[m];
		int sum=0;

		for(i=0; i<n; i++)//get matrix
		{
			String[] str = br.readLine().split(" ");

			for(j=0; j<m; j++)
			{
				matrix[i][j] = Integer.parseInt(str[j]);
			}
		}

		for(i=0; i<m; i++)//print reverse
		{
			for(j=0; j<n; j++)
			{
//				System.out.print(matrix[j][i] + " ");
				vsum[i] += matrix[j][i];
			}

//			System.out.println(vsum[i]);
		}

		for(i=0; i<n; i++)//printf
		{
			for(j=0; j<m; j++)
			{
				System.out.print(matrix[i][j] + " ");
				sum += matrix[i][j];
			}

			System.out.println(sum);
			sum = 0;
		}

		for(i=0; i<m; i++)
		{
			System.out.print(vsum[i] + " ");
			sum += vsum[i];
		}

		System.out.println(sum);
	}

}

Measured memory_bytes: 30992
n = input()
base, out, score = [0]*3, 0, 0
while True:
    if n == 0:
        break
    event = raw_input()
    if event == 'OUT':
        out += 1
        if out == 3:
            print score
            base, out, score = [0]*3, 0, 0
            n -= 1
    elif event == 'HIT':
            score += base.pop()
            base.insert(0, 1)
    else:
            score += sum(base)+1
            base = [0] * 3 

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

using namespace std;

#define int int64_t

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int start = a - (n - 1) * d;
    int len = (n - 1) * (d - c);
    int space = 2 * c + (n - 2) * (c - d);
    int end = a + (n - 1) * d;
    if(!(start <= b && b <= end))
    {
        cout << "NO" << endl;
        return 0;
    }
    if(space <= 0)
        cout << "YES" << endl;
    else
        cout << ((b - start) % (space + len) <= len ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1007;


string s;
ll w;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s>>w;
	string ans="";
	ll k=0;
	while(k<s.size()){
		ans += s[k];
		k+=w;
	}
	pri(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long inf = 1LL<<60;
const int limit = 100010;
using edge = struct { int to; long long cost; };
vector<edge> tree[limit];
long long depth[limit];

void dfs(int v, int p, long long d) {
  depth[v] = d;
  for(auto &e: tree[v]) {
    if(e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}

int main() {
  int N; cin >> N;
  for(int i = 0; i < N-1; ++i) {
    int a, b, c; cin >> a >> b >> c;
    a--, b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }
  int q, k; cin >> q >> k; k--;
  dfs(k, -1, 0);
  for(int i = 0; i < q; ++i) {
    int x, y; cin >> x >> y; x--, y--;
    cout << depth[x] + depth[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 14336
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias INCOME = Tuple!(long, "after", long, "salary");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);
    auto job = new INCOME[](0);
    PQueue!(INCOME, "a.salary < b.salary") pq;
    foreach (_; iota(n))
    {
        long a, b;
        scan(a, b);
        job ~= INCOME(a, b);
    }
    job.sort!"a.after < b.after"();
    // job.each!(x => x.writeln());
    long iter, ans;
    foreach (lim; iota(1, m + 1))
    {
        while (iter < n && job[iter].after <= lim)
            pq.insert(job[iter++]);

        if (!pq.empty)
        {
            ans += pq.front.salary;
            pq.removeFront();
        }
    }
    ans.writeln();
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 6328
def main():
    X,N = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    top_diff = 200
    ans = 0
    for i in range(-101,201):
        # print(i,top_diff,ans)
        if not i in P:
            if abs(X-i) < top_diff:
                top_diff = X-i
                ans = i
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int n = s.size();
  string ans = {};
  vi C(26,0);

  if(n < 26){
    rep(i, n) C[s[i]-'a']++;
    rep(i, 26){
      if(C[i] == 0){
        ans = s + (char)('a' + i);
        std::cout << ans << '\n';
        return 0;
      }
    }
  }

  // n = 26
  for (int i = 24; i >= 0; i--) {
    C[s[i+1]-'a']++;
    if(s[i] < s[i+1]){
      rep(j, i) ans += s[j];
      char add;
      rep(j, 26){
        //printf("%c:%d\n",(char)(j+'a'), C[j] );
        //printf("%c %c\n",(char)(j+'a'), s[i] );
        if(C[j] == 1 && (char)(j+'a') > s[i]){
          add = (char)(j+'a');
          break;
        }
      }
      ans += add;
      break;
    }
    if(i == 0) ans = "-1";
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int x[1000000], n, m, maxn;
int main() {
	while (true) {
		cin >> n >> m; maxn = 0;
		if (n == 0 && m == 0) { break; }
		x[0] = 0;
		for (int i = 1; i <= n + m; i++) { cin >> x[i]; }
		sort(x, x + n + m + 1);
		for (int i = 0; i < n + m; i++) {
			maxn = max(maxn, x[i + 1] - x[i]);
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 1252
"""
D - Lazy Faith
"""
# 解説を参考に作成（bisect）
import bisect


def solve():
    # データ読込
    A, B, Q = map(int, input().split())
    si = [-float('inf')] + [int(input()) for i in range(A)] + [float('inf')]
    ti = [-float('inf')] + [int(input()) for i in range(B)] + [float('inf')]
    xi = [int(input()) for i in range(Q)]
    # 問題計算
    for x in xi:
        txi = bisect.bisect_left(ti, x)
        left_t = ti[txi - 1]
        right_t = ti[txi]
        sxi = bisect.bisect_left(si, x)
        left_s = si[sxi - 1]
        right_s = si[sxi]
        print(min(abs(x - min(left_t, left_s)),
                  abs(x - max(right_t, right_s)),
                  abs(x - right_t) + abs(right_t - left_s),
                  abs(x - left_t) + abs(left_t - right_s),
                  abs(x - right_s) + abs(right_s - left_t),
                  abs(x - left_s) + abs(left_s - right_t)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16128
n, m, *ab = map(int, open(0).read().split())
from_1, to_n = set(), set()
for a, b in zip(*[iter(ab)] * 2):
    if a == 1: from_1.add(b)
    if b == n: to_n.add(a)
print('POSSIBLE' if from_1 & to_n else "IMPOSSIBLE")


Measured memory_bytes: 46660
#include<iostream>
using namespace std;
int main()
{
		int t,n,s,f;
	while(1){
		cin>>t;
		if(t==0)break;
		cin>>n;
		int sum=0;
		for(int i=0;i<n;i++){
		cin>>s>>f;
		sum+=f-s;
		}
	if(sum>=t){
			cout<<"OK"<<endl;
		}else{
			cout<<t-sum<<endl;
	  }
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    ans += min(A, K);
    K -= A;
    if (K <= 0) {
        cout << ans << endl;
        return 0;
    }
    K -= B;
    if (K <= 0) {
        cout << ans << endl;
        return 0;
    }
    ans -= min(C, K);

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

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

int main(){
	int temp, n, m, l, r, i, lb=0, rk=200000;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>l>>r;
		if(l>lb){
			lb=l;
		}
		if(r<rk){
			rk=r;
		}
	}
	temp=rk-lb+1;
	if(temp<0){
		temp=0;
	}
	cout<<temp<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long
#define ll long long
#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	string s;
	cin >> s;
	int a = s.find("YAKI");
	if (a == 0)cout << "Yes";
	else cout << "No";
	return 0;
}





Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;

int testNumber = 1;

bool todo = true;

int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cerr << testNum << endl;
        //cout << "Case #" << testNum++ << ": ";
        solve();
        ++testNumber;
        //++timer;
    }

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

void precalc() {

}

//#define int li

//const int mod = 1000000007;

void solve() {
    int n = 6;
    vector<ld> p(n), q(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i] /= 100.0;
    }
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
        q[i] /= 100.0;
    }

    ld res = 1.0;
    for (int a = 1; a <= 100; ++a) {
        for (int b = 1; b <= 100; ++b) {
            ld win = 0;
            for (int i = 0; i < n; ++i) {
                win += max(a * p[i], b * q[i]) / (a + b);
            }
            res = min(res, win);
        }
    }

    cout << res << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  string s,t;
  cin>>s>>t;
  for(ll i=0;i<s.size();i++){
    if(s == t){
      cout<<"Yes\n";
      return 0;
    }
    s = s.back() + s.substr(0,s.size()-1);
  }
  cout<<"No\n";
  return 0;
}

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


def solve(N: int, x: int, a: "List[int]"):
    answer =0
    for i in range(N-1):
        consum = a[i]+a[i+1]
        if consum > x:
            a[i+1]-= min(consum-x,a[i+1])
            answer+=consum-x
        
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15296
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++)
	{
		for (int j = 0; j <= N-i; j++)
		{
			int k = N - i - j;
			int money = 10000 * i + 5000 * j + 1000 * k;
			if (money == Y)
			{
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 384
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V,E = map(int,input().split())

min_dist = [[BIG_NUM]*V for i in range(V)]

for i in range(V):
    min_dist[i][i] = 0

for loop in range(E):
    tmp_from,tmp_to,tmp_cost = map(int,input().split())
    if min_dist[tmp_from][tmp_to] > tmp_cost:
        min_dist[tmp_from][tmp_to] = tmp_cost

for mid in range(V):
    for start in range(V):
        if min_dist[start][mid] == BIG_NUM:
            continue
        for goal in range(V):
            if min_dist[mid][goal] == BIG_NUM:
                continue
            if min_dist[start][goal] > min_dist[start][mid]+min_dist[mid][goal]:
                min_dist[start][goal] = min_dist[start][mid]+min_dist[mid][goal]


neg_FLG = False
#負閉路探し
for i in range(V):
    if min_dist[i][i] < 0:
        neg_FLG = True
        break


if neg_FLG == True:
    print("NEGATIVE CYCLE")
    sys.exit()

for row in range(V):
    if min_dist[row][0] == BIG_NUM:
        print("INF",end = "")
    else:
        print("%d"%(min_dist[row][0]),end = "")
    for col in range(1,V):
        if(min_dist[row][col] == BIG_NUM):
            print(" INF",end = "")
        else:
            print(" %d"%(min_dist[row][col]),end = "")
    print()


Measured memory_bytes: 7056
x, n = input().split()
x = int(x)
n = int(n)

if n==0:
	print(x)
else:
	p = list(map(int, input().split()))

	ans = -1
	mn = 10000

	for i in range(-1, 102):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	print(ans)

Measured memory_bytes: 9140
#include <stdio.h>
#include <string.h>

int main(){
  int i, alp[26] = {};
  char c;
  while((c = getchar()) != EOF) {
    if('a' <= c && c <= 'z') {
      i = (int)(c - 'a');
      alp[i]++;
    }
    if('A' <= c && c <= 'Z') {
      i = (int)(c - 'A');
      alp[i]++;
    }
  }
  c = 'a';
  for(i = 0; i < 26; i++, c++) {
    printf("%c : %d\n", c, alp[i]);
  }
  return 0;
}



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

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

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

using namespace std;

int main() {
	int h, n;
	cin>>h>>n;
	vector<int> arr(n, 0);
	for(int& c: arr) {
		cin>>c;
	}
	while(arr.size() != 0) {
		int x = arr.back();
		arr.pop_back();
		h -= x;
		if(h <= 0) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	if(h > 0)
		cout<<"No"<<endl;
	else 
		cout<<"Yes"<<endl;
	return 0;
}


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

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

  bool operator < ( const Puzzle &p ) const {
    for ( int i = 0; i < N2; 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 < N2; 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 < N2; i++ ) {
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = N2;  // set space
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 30576
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
const ll INF = (1ll << 60);

map<ll, ll> mp;

bool isok(ll h, ll k, ll n, vector<tuple<double, ll, ll>> &tp)
{
    ll ans = 0;
    rep(i, n)
    {
        auto cura = (get<1>(tp[i]));
        auto curb = (get<2>(tp[i]));
        cerr << (cura) << " " << (k / curb) << endl;
        ans += (cura) * (k / curb);
        k -= curb * (k / curb);
        if (ans >= h)
        {
            break;
        }
    }
    cerr << ans << " " << k << endl;
    return ans >= h;
}

ll f(ll h, vector<ll> &a, vector<ll> &b)
{
    //cerr << h << endl;
    if (h <= 0)
    {
        return 0;
    }

    //cerr << "count " << h << endl;
    if (mp.count(h) == 1)
    {
        return mp[h];
    }
    //cerr << "done " << h << endl;

    ll ans = INF;
    rep(i, a.size())
    {
        rep(j, 1, 1 + (h + a[i] - 1) / a[i])
        {
            ll tmp = f(h - j * a[i], a, b) + j * b[i];
            ans = min(ans, tmp);
        }
    }
    //cerr << ans << endl;
    mp[h] = ans;
    return ans;
}

int main(int argc, char const *argv[])
{
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n), b(n);

    rep(i, n)
    {
        cin >> a[i] >> b[i];
    }
    vector<ll> dp(h + 1, INF);
    dp[0] = 0;
    rep(i, n)
    {
        auto next = dp;
        rep(j, h + 1)
        {
            //  cerr << j << " " << a[i] << endl;

            if (j - a[i] < 0)
            {
                dp[j] = min(dp[j], b[i]);
            }
            else
            {
                dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
            }
        }
        for (ll j = h - 1; j >= 0; j--)
        {
            if (dp[j] > dp[j + 1])
                dp[j] = dp[j + 1];
        }
        //rep(j, h + 1) cerr << dp[j] << " ";
        //cerr << endl;
        //dp = next;
    }
    cout << dp[h] << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int N;
vector<ll> C,S,F;

ll solve(int i, ll time){
  // 駅iにtime秒目にいた時に、駅Nに到着する時刻
  if(i == N-1){
    return time;
  } else { 
    if(time <= S[i]){
      return solve(i+1, S[i] + C[i]);
    } else { 
      // time以降で、F[i]で割り切れるときに移動できる
      ll tmp = time % F[i];
      if(tmp == 0){
        return solve(i+1, time + C[i]);
      } else {
        return solve(i+1, time + (F[i] - tmp) + C[i]);
      }
    }
  }
}

int main(){
  cout << setprecision(10);
  cin >> N;
  C.assign(N,0);
  S.assign(N,0);
  F.assign(N,0);
  for(int i = 0; i < N; i++){
    cin >> C[i] >> S[i] >> F[i];
  }

  vector<ll> ans(N,0);
  for(int i = 0; i < N ; i++){
    cout << solve(i,0) << endl;
  }
  
}


Measured memory_bytes: 256