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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();++i){
        if(s[i] == 'U' || s[i] == 'D') continue;
        if(s[i] == 'R' && i%2 == 0) continue;
        if(s[i] == 'L' && i%2 == 1) continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Wed Aug 28 19:07:36 2019
//
package main

import "fmt"

func main() {
	var a int
	var s string
	fmt.Scan(&a)
	fmt.Scan(&s)

	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,a,b;
   cin>>n>>a>>b;
   long long int k=n/(a+b);
    long long ans=k*a;
    k=n%(a+b);
    ans+=min(a,k);
    cout<<ans;
}


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

int main(void)
{
    string s;
    cin >> s;
    if(s == "RRR") cout << 3;
    else if(s == "RRS" || s == "SRR") cout << 2;
    else if(s == "SSS") cout << 0;
    else cout << 1;
    cout << endl;
    return 0;
}

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

N = int(input())
arare = input().split()

check_p = 0
check_w = 0
check_g = 0
check_y = 0
for i in arare:
    if i == "P":
        check_p = 1
    elif i == "W":
        check_w = 1
    elif i == "G":
        check_g = 1
    else:
        check_y = 1

if check_p + check_w + check_g + check_y == 3:
    print("Three")
else:
    print("Four")

Measured memory_bytes: 3060
from heapq import heappop as pop
from heapq import heappush as push

INF = 10 ** 20

n = int(input())
m = int(input())

edges = [[] for _ in range(n)]

for _ in range(m):
    a, b, c, d = map(int, input().split(","))
    a, b = a - 1, b - 1
    edges[a].append((b, c))
    edges[b].append((a, d))
s, g, v, p = map(int, input().split(","))
s, g = s - 1, g - 1


def dij(s, g):
    que = [(0, s)]
    costs = [INF for _ in range(n)]
    costs[s] = 0
    while que:
        cost, num = pop(que)
        if num == g:
            return cost
        for edge in edges[num]:
            to, fee = edge
            if costs[to] > cost + fee:
                costs[to] = cost + fee
                push(que, (cost + fee, to))

print(v - p - dij(s, g) - dij(g, s))


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int n;
   cin >> n;
   map<int, int> mp;
   rep (i, n) {
      int a;
      cin >> a;
      mp[a]++;
   }

   ll ans = 0;
   for (auto x : mp) {
      if (x.second % 2 == 1) ans++;
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 4864
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            max = Math.max(max, x - min);
            min = Math.min(min, x);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 68632
import itertools
def main():
    n = int(input())
    A = [0 for i in range(5)]
    for _ in range(n):
        s = input()
        if s[0] in "MARCH":
            A["MARCH".index(s[0])] += 1
    ans = 0
    for i, j, k in itertools.combinations(range(5), 3):
        ans += A[i] * A[j] * A[k]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
  
#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 IINF    INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long               ll;
typedef pair <int, int> ii;
  
/*
struct point{
    ll x;
    ll y;
    point(){x = 0;y = 0;}
    point(ll x, ll y):x(x), y(y){}
};
*/
 
int main() {
 
    int w, h;
    while(cin >> w >> h, w, h){
        vector<ll> tate(w), yoko(h);
        map<ll, ii> mp;
        rep(i, w) {
            cin >> tate[i];
            mp[tate[i]].first++;
        }
        rep(i, h) {
            cin >> yoko[i];
            mp[yoko[i]].second++;
        }
        rep(i, w){
            ll tmp = tate[i];
            REP(j, i+1, w){
                tmp += tate[j];
                mp[tmp].first++;
            }
        }
        rep(i, h){
            ll tmp = yoko[i];
            REP(j, i+1, h){
                tmp += yoko[j];
                mp[tmp].second++;
            }
        }
         
        ll ans = 0;
        for(auto it = mp.begin(); it != mp.end(); ++it){
            ans += (it->second.first * it->second.second);
        }
         
        cout << ans << endl;
    }
 
    return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<int, int> P;

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

int main(){
    int n, k;
    cin >> n >> k;

    vector<double> p(n);
    vector<double> kakuritsu(n-k+1, 0);

    REP(i, n) {
        cin >> p[i];
        p[i] = (1 + p[i]) / 2.0;
    }

    REP(i, k) kakuritsu[0] += p[i];

    REP(i, n-k) kakuritsu[i+1] = kakuritsu[i] - p[i] + p[i+k];

    sort(kakuritsu.begin(), kakuritsu.end());

    printf("%.8f\n", kakuritsu[n-k]);

    return 0;
}

Measured memory_bytes: 3328
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N=II()
A=LI()
cnt=[0]*((10**6)+1)
for elem in A:
  cnt[elem]+=1
unique=[]
for i in range((10**6)+1):
  if cnt[i]==1:
    unique.append(i)
cnt=[0]*((10**6)+1)
A=list(set(A))
for elem in A:
  for m in range(elem*2,10**6+1,elem):
    cnt[m]=1
ans=0
for i in unique:
  if cnt[i]==0:
    ans+=1
print(ans)  

Measured memory_bytes: 47464
from heapq import heappop,heappush

def dijkstra(G, start):
    n = len(G)
    dist = [float("inf")]*n
    visited = set()
    heap = []
    heap.append((0, start))

    while heap and len(visited) != n:
        d, cur = heappop(heap)
        if cur in visited:
            continue
        visited.add(cur)
        dist[cur] = d
        for to in range(10):
            if to not in visited:
                heappush(heap, (d+G[cur][to], to))
    return dist

h,w = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
rc = [[0]*10 for i in range(10)]
for i in range(10):
    for j in range(10):
        rc[i][j] = c[j][i]
a = [list(map(int, input().split())) for i in range(h)]
dist = dijkstra(rc, 1)
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += dist[a[i][j]]
print(ans)

Measured memory_bytes: 73936
s=input()
l=["a","b",'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(s)):
  try:
    l.remove(s[i])
  except:
    continue
try:
  print(l[0])
except:
  print("None")

Measured memory_bytes: 9164
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[3010][3010];

int main(){
  string s,t; cin >> s >> t;
  int sn=s.size();
  int tn=t.size();
  rep(i,sn+1){
    rep(j,tn+1){
      if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
      chmax(dp[i+1][j],dp[i][j]);
      chmax(dp[i][j+1],dp[i][j]);
    }
  }
  //cout << dp[sn][tn] << endl;
  int i=sn,j=tn;
  string u;
  while(dp[i][j]>0){
    while(dp[i][j-1]==dp[i][j]){
      j--;
    }
    while(dp[i-1][j]==dp[i][j]){
      i--;
    }
    u+=s[i-1];
    i--; j--;
  }
  reverse(all(u));
  cout << u << endl;
  /*
  rep(i,sn+1){
    rep(j,tn+1){
      cout << dp[i][j];
    }cout << endl;
  }*/
}

Measured memory_bytes: 35584
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
	"strings"
)

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func ifval(cond bool, a interface{}, b interface{}) interface{} {
	return map[bool]interface{}{true: a, false: b}[cond]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for {
		scanner.Scan()

		arr, _ := mapf(strconv.Atoi, strings.Split(scanner.Text(), " ")).([]int)
		x, y := arr[0], arr[1]
		if x == 0 && y == 0 {
			break
		}

		if x < y {
			fmt.Printf("%d %d\n", x, y)
		} else {
			fmt.Printf("%d %d\n", y, x)
		}
	}
}



Measured memory_bytes: 1956
#define pb push_back
#define ll long long
#define maxn 30000000
#include <bits/stdc++.h>
using namespace std;

int arr[1000006], dp[1000006], n, k;

int rec(int pos){
    if(dp[pos] != -1) return dp[pos];
    if(pos >= n) return 0;
    int res = INT_MAX;
    for(int i=1;i<=k;i++){
        if(pos+i <= n){
            res = min(res, abs(arr[pos] - arr[pos+i]) + rec(pos+i) );
        }
    }
    return dp[pos] = res;
}


int main() {
    memset(dp, -1, sizeof dp);
    cin >> n ;
    k = 2;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }
    cout << rec(1) << endl;


    return 0;
}


Measured memory_bytes: 11008
import java.awt.datatransfer.SystemFlavorMap;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int a = sc.nextInt();
                String op = sc.next();
                int b = sc.nextInt();
                int answer;
                switch(op){
                    case "+":
                        answer = a + b;
                        break;
                    case "-":
                        answer = a - b;
                        break;
                    case "*":
                        answer = a * b;
                        break;
                    case "/":
                        answer = a / b;
                        break;
                    default:
                        return;
                }
                System.out.println(answer);
            }
        }
    }
}


Measured memory_bytes: 26220
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        long A = stdIn.nextLong();
        long B = stdIn.nextLong();
        long K = stdIn.nextLong();
        long N_A=0;
        long N_B=0;

        if(A>K){
            N_A = A-K;
            N_B = B;
        }
        else{
            N_A = 0;
            if(B-(K-A) >0)
                N_B = B-(K-A);
            else
                N_B = 0;
        }
        System.out.print(N_A+" "+ N_B);
    }
}

Measured memory_bytes: 21204
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,a,b;cin>>n>>a>>b;
  cout << min(n*a, b) << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int a[n];
    for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    int cnt=0,ans=0;
    while(cnt<m){
        ans+=a[cnt];
      cnt++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc173/tasks/abc173_c

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int H_MAX = 6;
const int W_MAX = 6;

int H, W, K;
vector<string> c;

int main() {
  cin >> H >> W >> K;
  c = vector<string>(H);
  REP(i, H) cin >> c[i];

  int ans = 0;
  int SH = 1 << H;
  int SW = 1 << W;
  REP(sh, SH) REP(sw, SW) {
    int x = 0;
    REP(i, H) {
      if (sh >> i & 1) continue;
      REP(j, W) {
       if (sw >> j & 1) continue;
       if (c[i][j] == '#') x++;
      }
    }
    if (x == K) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>

using namespace std;

int n, k, w[100000];

bool check(int p){
  int cnt = 1;
  long long total = 0;

  for(int i = 0;i < n;i++){
    if(w[i] > p) return false;
    if(total + w[i] <= p) total += w[i];
    else{
      cnt++;
      total = w[i];
    }
  }

  if(cnt <= k) return true;
  else return false;
}

int main(){

  cin >> n >> k;
  for(int i = 0;i < n;i++) cin >> w[i];

  long long left = 0, right = 100000 * 10000;
  while(left < right){
    int mid = (left + right) / 2;

    if(check(mid)) right = mid;
    else left = mid + 1;
  }

  cout << left << endl;

  return 0;
}



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

int main()
{
    int k, t;
    std::cin >> k >> t;

    std::vector<int> a(t);
    for (int i = 0; i < t; i++) {
        std::cin >> a[i];
    }

    std::cout << std::max(0, 2 * *std::max_element(a.begin(), a.end()) - k - 1) << std::endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
	private static final int debt = 100000;

	public static void main(String[] a) throws IOException {
		Scanner sc = new Scanner(System.in);
		int len = sc.nextInt();
		sc.close();
		int debtSum = debt;
		for (int i = 0; i < len; i++) {
			int no = 1000;
			debtSum = (int) (Math.ceil((debtSum * 1.05) / no) * no);
		}
		System.out.println(debtSum);
	}
}

Measured memory_bytes: 26240
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n, m = lmi()

l = [0] * (n+1)
l[0] = 1

a = 0
if m != 0:
    a = int(input())
k = 1
for i in range(n+1):

    if i != a:
        if i == 1:
            l[i] = 1
        elif i >= 2:
            l[i] = l[i-1] + l[i-2]
            l[i] %= 1000000007
    else:
        k += 1
        if k <= m:
            a = int(input())



#print(l)
print(l[n] % 1000000007)


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

const int MAX = 10;
int main() {
	int N, A[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	int ans = 1, del = 1;
	for (int i = 0;i < N;i ++) {
		ans *= 3;
		del *= A[i] % 2 == 0 ? 2 : 1;
	}
	cout << ans - del;
	return 0;
}

// 全てのbのうち、全ての項が奇数であるものの補集合
// 最大は3^10<=4^10=2^20よりint

Measured memory_bytes: 256
class SegTree():
    def segfunc(self, x, y):
        return x+y

    def __init__(self, ide, n, init_val):
        self.ide_ele = ide
        self.num = 2**(n-1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i+self.num-1] = init_val[i]    
        for i in range(self.num-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    def query(self, p, q):#p <= x < q
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res

def main():
    q = int(input())
    ans = []
    query = [list(map(int, input().split())) for _ in range(q)]
    a_arr = []
    for arr in query:
        if arr[0] == 1:
            a_arr.append(arr[1])
    a_arr.sort()
    dic = {}
    rev_dic = {}
    p = 0
    for v in a_arr:
        if not v in dic:
            dic[v] = p
            rev_dic[p] = v
            p += 1
    seg_arr = [0]*p
    seg = SegTree(0, p, seg_arr)
    b_sum = 0
    cnt = 0
    add = 0
    f = False
    range_L, range_R = -1, -1
    for arr in query:
        if arr[0] == 1:
            x = dic[arr[1]]
            b_sum += arr[2]
            seg_arr[x] += 2
            seg.update(x, seg_arr[x])
            cnt += 1
            if f:
                if range_L <= x <= range_R:
                    add += 0
                elif x < range_L:
                    add += rev_dic[range_L] - arr[1]
                else:
                    add += arr[1] - rev_dic[range_R]
        L, R = -1, p-1
        while L+1 < R:
            P = (L+R+1)//2
            if seg.query(0, P+1)-cnt >= 0:
                R = P
            else:
                L = P
        range_L = R
        L, R = 0, p
        while L+1 < R:
            P = (L+R)//2
            if seg.query(P, p)-cnt >= 0:
                L = P
            else:
                R = P
        range_R = L
        f = True
        if arr[0] == 2:
            ans.append([rev_dic[range_L], b_sum + add])
    for a, b in ans:
        print(a, b)

if __name__ == "__main__":
    main()

Measured memory_bytes: 147060
#include<bits/stdc++.h>
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
using namespace std;
int n,v,ans;
int main(){
/*#ifndef ONLINE_JUDGE
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif*/
	scanf("%d%d",&n,&v);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n-i;j++){
			if(i*10000+j*5000+(n-i-j)*1000==v){
				cout<<i<<" "<<j<<" "<<n-i-j<<endl;
				return 0;
			}
		}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

vector<int> g[MAXN];

int pai[MAXN], h[MAXN], ap[MAXN];

int find(int x) {
	if(pai[x] == x) return x;
	return pai[x] = find(pai[x]);
}

void join(int a, int b) {
	a = find(a), b = find(b);
	if(a == b) return;
	
	if(h[a] == h[b]) {
		h[a]++;
		pai[b] = a;
		return;
	}
	if(h[a] < h[b])
		swap(a, b);
	pai[b] = a;
}

int32_t main() {
	FAST;
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		pai[i] = i;
	
	for(int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		join(a, b);
		
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) 
		if(ap[find(i)]++ == 0) ans++;
	cout << ans << endl;
	

}


Measured memory_bytes: 4992
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			int m = cin.nextInt();
			int x = cin.nextInt();
			int[] c = new int[n];
			int[,] a = new int[n, m];

			for (int i = 0; i < n; i++)
			{
				c[i] = cin.nextInt();
				for (int j = 0; j < m; j++)
				{
					a[i, j] = cin.nextInt();
				}
			}
			int ans = int.MaxValue;

			for (int i = 0; i < Math.Pow(2, n); i++)
			{
				int money = 0;
				bool ok = true;

				int[] mth = new int[m];

				for (int j = 0; j < n; j++)
				{
					if (Math.Floor((i / Math.Pow(2, j))) % 2 == 1)
					{
						for (int k = 0; k < m; k++)
						{
							mth[k] += a[j, k];
						}
						money += c[j];
					}
				}

				for (int p = 0; p < m; p++)
				{
					if (mth[p] < x) ok = false;
				}
				if ((ans > money) && ok) ans = money;
			}

			if (ans == int.MaxValue) ans = -1;

			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 28020
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int maxi=2000000000;
const int maxq=1000000000;
const ll mod=1000000007LL;
#define f(i,a,b) for(int  i=(a); i<(b);++i)
/*
unsigned int countSetBits(unsigned int n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}
*/

/*
const int maxx=9000000;
void SieveOfEratosthenes(vector<int> &primes){
    bool IsPrime[maxx+1];
    memset(IsPrime, true, sizeof(IsPrime));
    for(int p=2;p*p<=maxx ;p++){
        if(IsPrime[p]){
            for(int i=p*p;i<maxx ;i+=p) IsPrime[i]=false;
        }
    }
    f(p,2,maxx +1){
        if(IsPrime[p]) primes.push_back(p);
    }
    }
*/
//int b[100];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin>>a;
    if(a>='A' && a<='Z') cout<<"A\n";
    else cout<<"a\n";
    return 0;
}




Measured memory_bytes: 3648
#include <vector>
#include <iostream>
#include <cstdio>

using namespace std;

const int N = 1e5 + 5;

int n, m, degIn[N], degOut[N];
vector<int> g[N];
int dp[N];

int DP(int u)
{
    if (~dp[u])
        return dp[u];
    if (degIn[u] == 0)
        return dp[u] = 0;;
    dp[u] = 0;
    for (int v : g[u])
        dp[u] = max(dp[u], DP(v) + 1);
    return dp[u];
}

int main()
{
//    freopen("input.inp", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        degOut[x]++;
        degIn[y]++;
        g[y].push_back(x);
    }
    for (int i = 1; i <= n; ++i)
        dp[i] = -1;
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        if (degOut[i] == 0)
            ans = max(ans, DP(i));
    cout << ans;
    return 0;
}


Measured memory_bytes: 9984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static CS_AtCoder.Utils;
using static CS_AtCoder.Scan;
//using static CS_AtCoder.Library;


namespace CS_AtCoder {
	using Li = List<int>;
	using LLi = List<List<int>>;

	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
        Scan cin = new Scan();
		public void Solve() {
            int N = cin.ReadInt();
            int sec = 1;
            while (sec*2<=N) {
                sec *= 2;
            }
            sec.WL();
			return;
		}

	}

	public class Scan {
		public Scan() { }
		public int ReadInt() => int.Parse(Console.ReadLine());
		public int[] ReadInt(char separator) => Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
		public double ReadDouble() => double.Parse(Console.ReadLine());
		public double[] ReadDouble(char separator) => Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
		public long ReadLong() => long.Parse(Console.ReadLine());
		public long[] ReadLong(char separator) => Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
		public string ReadLine() => Console.ReadLine();
		public string[] ReadLine(char separator) => Console.ReadLine().Split(separator).ToArray();
	}
	public static class Utils {
		public static string Docking<T>(this IEnumerable<T> collection,string separator="") {
			return string.Join(separator, collection);
		}
		public static void WL(this object obj) => Console.WriteLine(obj);
		public static void WL<T>(this IEnumerable<T> collection) {
			foreach (var item in collection) {
				item.WL();
			}
		}
		public static void REP(int n,Action<int> act) {
			for (int i = 0; i < n; i++) act(i);
		}
		public static long Mod(long x) => x % ((long)1e9 + 7);
		public static long ModPow(long x,long a) {long tmp = 1;	while (a!=0) {if (a%2==1) {	tmp = Mod(tmp * x);	}x = Mod(x * x);a /= 2;	}return tmp;}
		public static long DivMod(long x, long y) => (Mod(x * ModPow(y, (long)1e9 + 5)));
		public static int ManhattanDistance(int x1, int y1, int x2, int y2) => (Abs(x2 - x1) + Abs(y2 - y1));
	}
}


Measured memory_bytes: 13140
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();

    let c: isize = iterator.next().unwrap().parse().unwrap();
    let d: isize = iterator.next().unwrap().parse().unwrap();

    let mut m: isize = max(a * c, b * d);
    m = max(m, a * d);
    m = max(m, b * c);
    m.to_string()
}


Measured memory_bytes: 2164
/*
g++ -std=c++11 -o2 -Wall Yahoo2019B.cpp -o .\out\Yahoo2019B.out
.\out\Yahoo2019B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int towns[] = {1, 2, 3, 4};

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<pair<int, int>> paths;
  int a, b;
  for (int i = 0; i < 3; ++i) {
    cin >> a >> b;
    paths.push_back(make_pair(a, b));
    paths.push_back(make_pair(b, a));
  }
  bool ans;
  bool found;
  do {
    ans = true;
    for (int i = 0; i < 3; ++i) {
      a = towns[i];
      b = towns[i+1];
      found = false;
      for (int j = 0; j < paths.size(); ++j) {
        if (a == paths[j].first && b == paths[j].second) {
          found = true;
        }
      }
      ans &= found;
    }
    if (ans) {
      cout << "YES\n";
      return 0;
    }
  } while (next_permutation(begin(towns), end(towns)));
  cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
typedef long long ll;
pair<int, int> a[200010], f[10001];
ll dp[2010][2010];
int main()
{
    int n, k;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a + 1, a + 1 + n);
    ll ans = 0;

    for (int i = n; i >= 1; i--)
    {
        int st = a[i].second;
        int num = a[i].first;
        int cnt = n - i + 1;
        for (int j = 1; j <= cnt + 1; j++)
        {
            int l = j, r = n - (cnt - j) - 1;

            dp[l][r] = max(r + 1 <= n ? dp[l][r + 1] + 1ll * num * abs(r + 1 - st) : 0, l - 1 >= 1 ? dp[l - 1][r] + 1ll * num * abs(l - 1 - st) : 0);
            ans = max(dp[l][r], ans);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 26424
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
 
using ll = long long;
 
#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))
 
#define pb push_back
#define mp make_pair

#define ft first
#define sd second

using vp = vector<pair<int, int>>;

int n;

int pow(int a, int x) {
	if(x==0)return 1;
	int p = pow(a, x/2);
	return p*p*(x%2?a:1);
}

vp factor(int m) {
    vp list;
    int i = 2, c = 0;
    while(i<=n) {
        if(n%i==0) {
            n /= i;
            c++;
        } else {
        	if(c>0)list.pb(mp(i, c));
        	i++;
        	c = 0;
        }
    }
    list.pb(mp(i, c));
    return list;
}

int eulerphi(vp l) {
    int r = 1;
    rep(i, l.size())r *= pow(l[i].ft, l[i].sd-1)*(l[i].ft-1);
    return r;
}

int main(){
    cin.tie(0);
     
    cin>>n;
    
    cout<<eulerphi(factor(n))<<endl;
     
    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>



int main(){
	char c[20];

	scanf("%s",&c);
	int i;

	for(i=0;i<20;i++){
		if((int(c[19-i])!=-52)&&(int(c[19-i]!=0))){
			printf("%c",c[19-i]);
		}
	}printf("\n");


	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  char p[50001]={1,1};
  int i,j,c,n;
  for(i=2;i*i<50001;i++){
    if(p[i])continue;
    for(j=i*i;j<50001;j+=i)p[j]=1;
  }
  while(scanf("%d",&n),n){
    c=0;
    for(i=3;i*2<=n;i++){
      if(p[i]+p[n-i])continue;
      c++;
    }
    if(!p[n-2])c++;
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 656
#include<cstdio>
int N,M,Q;
char S[2010][2010];
int sum[2010][2010][3];
int gs(int x1,int y1,int x2,int y2,int k){
	return sum[x2][y2][k]-sum[x1][y2][k]-sum[x2][y1][k]+sum[x1][y1][k];
}
int main(){
	scanf("%d%d%d",&N,&M,&Q);
	for(int i=0;i<N;i++)scanf("%s",S[i]);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			for(int k=0;k<3;k++)
				sum[i][j][k]=sum[i][j-1][k]+sum[i-1][j][k]-sum[i-1][j-1][k]+(S[i-1][j-1]=='1'&&S[i-1][j-1]==(!k?'1':k==1?S[i-1][j]:S[i][j-1]));
	while(Q--){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",gs(x1-1,y1-1,x2,y2,0)-gs(x1-1,y1-1,x2,y2-1,1)-gs(x1-1,y1-1,x2-1,y2,2));
	}
}

Measured memory_bytes: 52992
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  string s;
  cin>>s;
  int ans=0;
  rep(i,(s.size()+1)/2)
    if(s[i]!=s[s.size()-i-1])
      ans++;
  cout<<ans<<endl;
  return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/

//	d.erase(unique(all(d)), d.end());

int main()
{
	SPEED;
	ll n,k,t,c=0,i,j,m,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
      	ll a,b;
		cin>>a>>b>>c;
		// n=s.length();
		// ll a[n];
        c=min((b/a),c);
		
		cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, D = map(int, input().split())

i = 0
while True:
    if i % 2 == 0:
        C -= B
        if C <= 0:
            print("Yes")
            break
    else:
        A -= D
        if A <= 0:
            print("No")
            break
    i += 1



Measured memory_bytes: 9416
#include<iostream>
using namespace std;
int main(){
  int n,w,h,i,j,k,l,s,t,x,y;
  int p[501][501]={};
  cin >> n;
  while(n!=0){
    cin >> w >> h;
    for(i=0;i<w;i++){
      for(j=0;j<h;j++){
	p[i][j]=0;
      }
    }
    for(i=0;i<n;i++){
      cin >> x >> y;
      p[x-1][y-1]=1;
    }
    int o=0,m=0;
    cin >> s >> t;
    for(i=0;i<w-s+1;i++){
      for(j=0;j<h-t+1;j++){
	m=0;
	for(k=i;k<i+s;k++){
	  for(l=j;l<j+t;l++){
	    m+=p[k][l];
	  }
	}
	if(o<m) o=m;
      }
    }
    cout << o << endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 2148
n=int(input())
ab=[[int(i) for i in input().split()] for _ in range(n)]
cd=[[int(i) for i in input().split()] for _ in range(n)]
inab=[sum(map(lambda x:x[0]>a and x[1]>b,cd)) for a,b in ab]
incd=[sum(map(lambda x:x[0]<c and x[1]<d,ab)) for c,d in cd]
ans=0
while 1:
  f=1
  mab=1000
  for i in range(n):
    if inab[i] > 0 and mab > inab[i]:
      f=0
      mab=inab[i]
  if f:
    break
  mcd=1000
  tmp=(-1,-1)
  ans+=1
  for i in range(n):
    if mab==inab[i]:
      a,b=ab[i]
      for j in range(n):
        if incd[j]==0:continue
        c,d=cd[j]
        if a<c and b<d and mcd>incd[j]:
          mcd=incd[j]
          tmp=(i,j)
  ta,tb=ab[tmp[0]]
  tc,td=cd[tmp[1]]
  inab[tmp[0]]=0
  incd[tmp[1]]=0
  for i in range(n):
    a,b=ab[i]
    c,d=cd[i]    
    if inab[i]:
      if a<tc and b<td:
        inab[i]-=1
    if incd[i]:
      if c>ta and d>tb:
        incd[i]-=1  
print(ans)


Measured memory_bytes: 45168
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	ans := 1
	c := k
	for n >= c {
		c *= k
		ans++
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
//0061
#include<stdio.h>
#include<map>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	map<int, int> i2s;
	map<int, int> s2r;	//d¡·éÊðêÂÉ·éæ¤
	int num,solvCount;
	while( scanf("%d,%d", &num, &solvCount), num)
	{
		i2s[num] = solvCount;
		s2r[solvCount] = 0;	//Æè ¦¸lðüêé¾¯
	}
	while(scanf("%d", &num) == 1)
	{
		int rank = 1;
		for(map<int, int>::iterator ite = s2r.begin();
			ite != s2r.end(); ++ite)
		{
			if(ite->first > i2s[num])
				rank++;
		}
		printf("%d\n", rank);
	}
	return 0;
}

Measured memory_bytes: 0
n = gets.to_i
bars = gets.split.map(&:to_i)

sum = bars.inject(:+)
current_sum = 0
answer = Float::INFINITY

0.upto(bars.size - 1).each do |index|
  current_sum += bars[index]

  remain = sum - current_sum
  diff = (remain - current_sum).abs

  answer = diff if diff < answer
end

puts answer


Measured memory_bytes: 16132
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N % 2 == 0){
    cout << N << endl;
  }else{
    cout << 2 * N << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  reverse(ALL(a));
  ll ans = 0;
  REP(i, n) {
    if (i == 0) {
      continue;
    }
    ans += a[i / 2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

ll n, k;
vector<ll> vec(n);

//return the number of ng
//left always ng. right always ok
long long nibun_search(ll val) {
    long long left = -1;
    long long right = val;
    while (right - left > 1) {
        long long mid = (left + right) / 2;
        if(mid == 0){
            return 1;
        }
        ll count = 0;
        rep(i, n){
            if(vec[i] % mid == 0){
                count += ((vec[i] / mid) - 1);
                
            }else{
                count += (vec[i] / mid);
            }
        }
        if(count <= k){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    cin >> n >> k;
    vec.resize(n);
    
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    cout << nibun_search(1000000000) << endl;

}

Measured memory_bytes: 4800
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  string s,a;
  
  cin>>n;
  for(int j=0;j<n;++j){
  cin>>s;
  a=s[0];
  int pos=0;
  for(i=3;i<s.size();i+=3){
    if(s[i-1]=='>'){
      if(s[i]==a[pos+1]){
	pos++;
	continue;
      }
      a+=s[i];
      pos++;
    }else if(s[i-1]=='-'){
      if(s[i]==a[pos-1]){
	pos--;
	continue;
      }
      a=s[i]+a;
      pos--;
      if(pos<0) pos=0;
    }
  }
  cout<<a<<endl;
  }
  return 0;
}

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

using namespace std;

const int N = 500017;

int n, k;

bool read() {
    if (!(cin >> n >> k))
        return false;

    return true;
}

void solve() {
    int t = n * (n - 1) / 2 - n + 1;

    if (t < k) {
        cout << "-1\n";
        return ;
    }

    cout << n - 1 + t - k << endl;

    for (int i = 2; i <= n; ++i)
        cout << 1 << ' ' << i << endl;

    for (int i = 2; i <= n && t > k; ++i)
        for (int j = i + 1; j <= n && t > k; ++j, --t)
            cout << i << ' ' << j << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
n = int(input())
task = []
for i in range(n):
  m = list(map(int,input().split()))
  m[0],m[1]=m[1],m[0]
  task.append(m)
task.sort()
K = 0
ans = 1
for i in range(n):
  K += task[i][1]
  if (K>task[i][0]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
  


Measured memory_bytes: 51172
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n =Console.ReadLine().ToInt32(); ;
        var a = Console.ReadLine();
        var b = Console.ReadLine(); ; ;
        var c = Console.ReadLine(); ;

        var count = 0;
        for (int i = 0; i < n; i++)
        {
            var aa = a[i];
            var bb = b[i];
            var cc = c[i];
            if (aa == bb && bb == cc)
            {

            }
            else if (aa != bb && bb != cc && cc != aa)
            {
                count += 2;
            }
            else
            {
                count++;
            }
        }
        Console.WriteLine(count);

        Console.ReadLine();
    }

    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    
  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int sum = 0;
    for(int i = 0; i < k; ++i) {
        sum += a[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3628