akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int a, b;

int read() {
  if (scanf("%d%d", &a, &b) < 2) {
    return false;
  }
  return true;
}

void solve() {
  int res = abs(b - a);
  if ((a > 0 && b > 0) || (a < 0 && b < 0)) {
    if (a > b) {
      res += 2;
    }
  } else {
    if (a > b) {
      res = abs(a + b) + 1;
    } else {
      res = min(res, abs(a + b) + 1);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    int h,w;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }

    vector<vector<int>> a(h,vector<int>(w));

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                if(c[i][j] > c[i][k] + c[k][j]){
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }

    LL result = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] != 1 && a[i][j] != -1){
                result += c[a[i][j]][1];
            }
        }
    }

    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int flag[100005];
int main()
{
	int ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		for(int i = x; i <= y; i++) flag[i] = 1;
	}
	for(int i = 1; i <= 100000; i++)
	{
		if(flag[i] == 1) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, W = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    vmax=N*1000
    inf=10**10
    dp=[inf]*(vmax+1)
    dp[0]=0
    for i in range(N):
        w,v=S[i]
        j=vmax
        while j-v>=0:
            dp[j]=min(dp[j-v]+w,dp[j])
            j-=1
    ans=0
    for i, val in enumerate(dp):
        if val<=W:
            ans=i
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 40176
import sys
input = sys.stdin.readline
f = lambda : map(int,input().split())
n,m = f()
ll = sorted([list(f()) for _ in range(n)])

ans = 0
for p, c in ll:
  ans += p*min(m,c)
  m -= c
  if m < 1:
    break

print(ans)

Measured memory_bytes: 28564
fun main(args: Array<String>) {
  val H = readLong()

  var cnt = 0L
  var h = H
  var n = 1L
  while (h > 0) {
    cnt += n
    if (h <= 1L) {
      h = 0
    } else {
      h /= 2
      n *= 2
    }
  }

  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 31848
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef long double LD;


const ll MOD = 10e9 + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 10e5;
const LD EPS = 10e-7;
const LD PI = 3.14159265359;

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

int main() {
	ll n, all=0;
	vector<ll> a, b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll s, t;
		cin >> s >> t;
		a.push_back(s);
		b.push_back(t);
		all += s;
	}
	bool flag=true;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i]) {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << 0 << endl;
		return 0;
	}
	ll tt = INF;
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) {
			tt = min(tt, b[i]);
		}
	}
	cout << all - tt << endl;
	return 0;
}


Measured memory_bytes: 768
fun main(args:Array<String>):Unit {
    var (n, m) = readLine()!!.split(' ').map(String::toInt)
    while(n != 0 || m != 0){
        val points = Array(n + 1){if (it == 0) 0 else readLine()!!.toInt()}
        val pair = points.indices.flatMap {a ->  (a until points.size).map{b -> points[a] + points[b]} }.filter{it <= m}.sorted().toIntArray()
        println(pair.map{point ->
            val idx = pair.binarySearch(m - point).let{if (it < 0) -it - 2 else it}
            if (idx in pair.indices){
                point + pair[idx]
            }else point
        }.max())
        val (nn, mm) = readLine()!!.split(' ').map(String::toInt)
        n = nn
        m = mm
    }
}


Measured memory_bytes: 133640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    string ans = "Yes";
    if (d > s * t) ans = "No";
    cout << ans << endl;
}

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

int main(){
    int a=0,c=1;
    vector<string> v;
    cin >> a;
    string b[a];

    for(int i=0;i<a;i++){
        basic_string<char> x;
        cin >> x;
        v.push_back(x);
    }

    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    cout << v.size();

    return 0;
}

Measured memory_bytes: 17912
import sys

for s in sys.stdin:
	data = list(map(int, s.split(',')))
	dis = data[:10]
	v1, v2 = data[10], data[11]

	for i in range(1, len(dis)):
		dis[i] += dis[i-1]

	time = dis[-1] / (v1+v2)
	meetDis = v1 * time

	for i in range(len(dis)):
		if dis[i] >= meetDis:
			print(i+1)
			break

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ln = br.readLine().split(" ");
        int[] A = new int[100000];
        int n = Integer.parseInt(ln[0]);
        int q = Integer.parseInt(ln[1]);
        for (int j = 0; j<q; j++){
            String[] line = br.readLine().split(" ");
            int com = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int y = Integer.parseInt(line[2]);
            if (com == 1){
                int tot = 0;
                for (int i = x; i < y + 1; i++){
                    tot += A[i];
                }
                System.out.println(tot);
            }else{
                A[x] += y;
            }
        }
        
    }
}

Measured memory_bytes: 65672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  string s = to_string(n);
  rep(i, s.size()) sum += ctoi(s.at(i));
  if (n%sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pi (acos(-1))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;
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;
}
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  if(s[0]=='R' && s[1]=='R' && s[2]=='R') {
    cout << 3 << endl;
  }
  else if(s[0]=='R' && s[1]=='S' && s[2]=='R'){
    cout << 1 << endl;
  }
  else if(s[0]=='S' && s[1]=='S' && s[2]=='R'){
    cout << 1 << endl;
  }
  else if(s[0]=='R' && s[1]=='S' && s[2]=='S'){
    cout << 1 << endl;
  }
  else if(s[0]=='S' && s[1]=='R' && s[2]=='S'){
    cout << 1 << endl;
  }
  else if(s[0]=='S' && s[1]=='S' && s[2]=='S'){
    cout << 0 << endl;
  }
  else {
    cout << 2 << endl;
  }
  return 0;
}
  








  
  

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
		   int x = sc.nextInt();
			int ans = 0;
			if (x == 0) {
				ans = 1;
			}
           System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}


Measured memory_bytes: 35712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
#define foreach(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define MIN 0
#define MAX 160
#define MAXS 20000
#define OFS 150

int p[MAXS  * 2];

int main()
{
                
    for(int x = 0; x < MAX; x++ )for(int y = 0; y < MAX; y++ )
    {
        //cout << x << " " << y << endl;
        if((x == 0&& y == 0) ||(x == 1 && y == 0) || (x == 0 && y == 1)) continue;
        for(int sum = (x * x + y * y) * 2; sum < MAXS; sum +=(x*x)+(y*y))
            p[sum] = 1;
    }
    int ans=0;
    int num;
    int m,n;
    cin >> num;
    while(num--){
        cin >> m >> n;
        if(p[m * m + n * n])
            cout << 'C' << endl;
        else
            cout << 'P' << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
#define P pair<int,int>//cost to
#define int long long
using namespace std;

vector<P>r[100000];
int m[100000];
void DFS(int n, int p) {
	for (P b : r[n]) {
		if (b.second != p) {
			m[b.second] = m[n] + b.first;
			DFS(b.second, n);
		}
	}
}
signed main() {
	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		r[a].push_back({ c,b });
		r[b].push_back({ c,a });
	}
	int q, k; cin >> q >> k;
	k--;
	DFS(k, k);
	for (int i = 0; i < q; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		cout << m[x] + m[y] << endl;
	}
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans=0;
  REP(i,3){
    int div = n%10;
    if(div == 1) ans += 9 * pow(10,i);
    else ans += 1* pow(10,i);
    n/=10;
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<set>
#include<sstream>
#include<climits>
#include<numeric>
#include<map>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int INF = INT_MAX;

int n;
vector<string> v, nv;
string str;
vector<string> ans;

string make_string(vector<int> &used){
  //debug
  //REP(i, used.size()) cout <<used[i] <<", "; cout <<endl;

  stringstream ss;
  ss <<v[used[0]];
  FOR(i, 1, used.size()) ss <<" " <<v[used[i]];
  ss <<".";
  return ss.str();
}

void check(int now, vector<int> &used){
  if(now >= str.size()){
    ans.push_back( make_string(used) );
    return ;
  }
  REP(i, v.size()){
    if(str.substr(now, nv[i].length()) == nv[i]){
      used.push_back(i);
      check(now + nv[i].length(), used);
      used.pop_back();
    }
  }
}

int main(){
  map<char, char> ex;
  char c = 'a';
  for(char cn = '2'; cn <= '9'; cn++){
    int step = (cn == '7' || cn == '9')? 4 : 3;
    REP(j, step){
      ex[c] = cn;
      c += 1;
    }
  }

  while(cin >>n && n){
    ans = vector<string>();
    v = vector<string>(n);
    nv = vector<string>(n);
    REP(i, n){
      cin >>v[i];
      nv[i] = v[i];
      REP(j, nv[i].length()) nv[i][j] = ex[nv[i][j]];
      //debug
      //cout <<v[i] <<endl;
      //cout <<nv[i] <<endl;

    }
    cin >>str;

    vector<int> tmp;
    check(0, tmp);
    REP(i, (int)(ans.size())) cout <<ans[i] <<endl;
    cout <<"--" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
import std.stdio,std.string,std.conv,std.array,std.algorithm;

struct Point
{
	double x,y;

	this(double a,double b)
	{
		this.x = a;
		this.y = b;
	}

	Point opBinary(string s)(Point p) if(s == "-")
	{
		p.x = x - p.x;
		p.y = y - p.y;
		return p;
	}

	double det(Point a)
	{
		return this.x * a.y - this.y * a.x;
	}
}

Point[] convex_hull(Point[] ps)
{
	int n = cast(int)ps.length;
	int k = 0;


	sort!((a, b) 
	{
		if (a.x != b.x)  
		{
			return a.x < b.x;
		}
		else
		{
			return a.y < b.y;
		}
	})(ps);

	Point[] convex = new Point[n*2];


	foreach(i;0..n)
	{
		while (2 <= k && (convex[k-1] - convex[k-2]).det(ps[i] - convex[k-1]) <= 0 )
		{
			k--;
		}
		convex[k++] = ps[i];
	}
	
	for(int i = n-2,t = k; 0 <= i;i--)
	{
		while (t < k && (convex[k-1] - convex[k-2]).det(ps[i] - convex[k-1]) <= 0 )
		{
			k--;
		}
		convex[ k++ ] = ps[i];
	}

	convex.length = k - 1;
	return convex;
}



int main()
{
	int n;
	while((n = readln.chomp.to!int) != 0)
	{
		Point[] ps;
		ps.length = n;

		foreach(i;0..n)
		{
			string[] _s = readln.chomp.split(",");
			ps[i].x = _s[0].to!double;
			ps[i].y = _s[1].to!double;
		}

		Point[] convex = convex_hull(ps);
		writeln(n - convex.length);

	}
	return 0;
}

Measured memory_bytes: 1120
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s.size()==2){
        cout<<s;
    }
    else{
        cout<<s[2]<<s[1]<<s[0]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int cnt[n+1] = {};
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cnt[a[i]]++;
    long long total = 0;
    for (int i = 1; i <= n; i++) total += (long long)cnt[i] * (cnt[i] - 1) / 2;
    for (int i = 0; i < n; i++)
        cout << total - cnt[a[i]] + 1 << endl;
}


Measured memory_bytes: 4096
import java.util.Scanner;

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

        int N = scan.nextInt();
        int Y = scan.nextInt();

        int x = 0; //10000円
        int y = 0; //5000円
        int z = Y/1000; //1000円

        for(int i=0; i<N*10; i++){
            if(x+y+z > N){
                if(y>=2){
                    y = y - 2;
                    x++;
                }else if(z>=5) {
                    z = z - 5;
                    y++;
                }
            }else if(x+y+z < N){
                if(x>0){
                    x--;
                    y = y + 2;
                }else if(y>4){
                    y--;
                    z = z + 5;
                }
            }else{
                break;
            }
        }
        if(x+y+z == N) {
            System.out.println(x + " " + y + " " + z);
        }else{
            System.out.println(-1 + " " + -1 + " " +  -1);
        }
    }
}


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

int main(void) {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;

    int a, c=1;
    cin >> a;
    for(int i=0; i<h; i++) {
        if(i%2) {
            for(int j=0; j<w; j++) {
                cout << c << ' ';
                if(!--a) cin >> a, c++;
            }
            cout << endl;
        } else {
            vector<int> v;

            for(int j=0; j<w; j++) {
                v.push_back(c);
                if(!--a) cin >> a, c++;
            }

            for(auto it = v.rbegin(); it != v.rend(); it++)
                cout << *it << ' ';
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
#define rp
#define pi 	3.14159265358979323846
#define M 1000000
/*
was buried because of depression
     now time to rise up
        music is life
*/

//bruteforce to check prime
/*bool checkprime(ll j)
{
    if(j<=1)
        return false;
    else if(j==2)
        return true;
    else if(j%2==0)
        return false;
    else
    {
        bool prime=true;
        int divisor=3;
        int upperlimit=sqrt(j)+1;
        while(divisor<=upperlimit)
        {
            if(j%divisor==0)
                return false;
            divisor+=2;
        }
        return prime;
    }
}*/
/*int main()
{
    int n,a,i,c=0;
    vector<int>v;
    cin>>n;
    while(n--)
    {
        cin>>a;
        v.pb(a);

    }
    sort(v.begin(),v.end());
    int min=v[0];
    int max=v[n-1];
    for(i=0; i<v.size(); i++)
    {

        if(v[i]>min && v[i]<max)
            c++;

    }
    cout<<c<<endl;

    return 0;
}*/
/*bool prime[M];
bool isprime(ll n)
{
    if(n<2)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    return prime[n]==false;
}
bool seive(ll n)
{
    for(int i=3;i*i<=n;i+=2)
    {
        if(prime[i]==false)
        {
            for(int j=i*i;j<=n;j+=i)
                prime[j]=true;
        }

    }
}*/

int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
        cout<<"7"<<endl;
    else if(s=="MON")
        cout<<"6"<<endl;
    else if(s=="TUE")
        cout<<"5"<<endl;
    else if(s=="WED")
        cout<<"4"<<endl;
    else if(s=="THU")
        cout<<"3"<<endl;
    else if(s=="FRI")
        cout<<"2"<<endl;
    else
        cout<<"1"<<endl;
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> sw[m];
    for(int i = 0; i < m; i++){
        int k;  cin >> k;
        while(k--){
            int x;  cin >> x;
            sw[i].push_back(--x);
        }
    }
    vector<int> p(m);
    for(int i = 0; i < m; i++)  cin >> p[i];
    int ans = 0;
    for(int i = 0; i < 1<<n; i++){
        bool valid = true;
        for(int j = 0; j < m; j++){
            int tmp = 0;
            for(int s : sw[j]){
                tmp += (i>>s)&1;
            }
            if(tmp%2 == p[j])   continue;
            valid = false;
            break;
        }
        if(valid)   ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  map<char,ll> cnt;
  rep(i,n){
    string s;
    cin>>s;
    cnt[s[0]]++;
  }

  string t = "MARCH";
  int m = 5;
  ll ans = 0;
  for(int b=0;b<(1<<m);++b){
    bitset<10> bit(b);
    if(bit.count()!=3)continue;
    ll tmp = 1;
    rep(i,m)if(bit[i])tmp*=cnt[t[i]];
    ans += tmp;
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            string[] arr = str.Split(' ');
            int x = Int32.Parse(arr[0]);
            int y = Int32.Parse(arr[1]);
            Console.WriteLine(x+y/2);
        }
    }
}


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

bool isA(const string& s){
	if( s.size() >= 1 && s[0] != '>' ) return false;
	if( s.size() >= 2 && s[1] != '\'' ) return false;
	
	int cnt1 = 0, cnt2 = 0;
	for(int i=2, j=0 ; i < s.size()-1 ; i++ ){
		if( s[i] == '=' ){
			j? cnt1++ : cnt2++;
		}else if( s[i] == '#' ){
			j++;
		}else{
			return false;
		}
	}
	if( cnt1 == 0 || cnt2 == 0 || cnt1 != cnt2 || s[s.size()-1] != '~' ){
		return false;
	}
	return true;
}

bool isB(const string& s){
	if( s.size() >= 1 && s[0] != '>' ) return false;
	if( s.size() >= 1 && s[1] != '^' ) return false;
	if( s.size() < 6 || s.size() % 2 == 1 ) return false;
	
	bool flag = false;
	for(int i=3 ; i < s.size() - 2 ; i += 2 ){
		if( s[i-1] != 'Q' || s[i] != '=' ){
			return false;
		}
	}
	
	if( s[s.size()-2] != '~' || s[s.size()-1] != '~' ){
		return false;
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	for( ; n-- ; ){
		string s;
		cin >> s;
		
		if( isA( s ) ){
			cout << "A" << endl;
		}else if( isB( s ) ){
			cout << "B" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

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

int main(){
    int n,m,pen=0;
    cin>>n>>m;
    vector<bool> A(n+1,false);
    vector<int> WA(n+1,0);
    for(int i=0; i<m; ++i){
        int p;
        string s;
        cin>>p>>s;
        if(!A[p] && s=="WA") ++WA[p];
        if(s=="AC"){
            A[p]=true;
        }    
    }
    int corr=0;
    for(int i=0; i<n+1; ++i){
        if(A[i]){
            ++corr;
            pen+=WA[i];
        }
    }
    cout<<corr<<" "<<pen<<"\n";
}

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

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

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;


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

  vl l = vl(M, 0);
  vl r = vl(M, 0);

  ll max_l = 0;
  ll min_r = INT_MAX;

  rep(i, M) {
    cin >> l[i] >> r[i];
    if (l[i] > max_l) {
      max_l = l[i];
    }
    if (r[i] < min_r) {
      min_r = r[i];
    }
  }

  int num = min_r - max_l + 1;
  if (num < 0) {
    num = 0;
  }

  cout << num << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  lli n; cin >> n;
  auto ans = "ABC";
  if (n >= 1200) ans = "ARC";
  if (n >= 2800) ans = "AGC";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse = True)
    
    A_half = math.ceil(N/2)
    A_pre = A[:A_half]
    A_post = A[A_half:]
    
    ret = sum(A_pre)
    for i in range(len(A_post)-1):
        ret += min(A_pre[i],A_pre[(i+1)%A_half])
        
    print(ret)
    
solve()

Measured memory_bytes: 32860
#ifndef DEBUG
#pragma GCC optimize("O3,unroll-loops")
#pragma loop_opt(on)
#endif
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define cerr
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define All(v) v.begin(),v.end()
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MOD = 998'244'353;

signed main() {
    FAST;

    ll x;
    cin >> x;
    ll c = 100;
    int i = 0;
    while (c < x) {
        c *= 1.01;
        i++;
    }
    cout << i << endl;

}


Measured memory_bytes: 3652
#include "bits/stdc++.h"

using namespace std;

#define int long long // −9·10^18 to 9·10^18
#define lll __int128_t //−10^38 to 10^38
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7
const double PI = 3.14159265358979323846264;

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}

template<typename... T>
void write(T&&... args) {
	((cout << args << " "), ...);
}

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
int gcd(int p, int q) 
{
	if (p % q == 0) 
		return q;
	return gcd(q, p % q);
}
int min3(int x, int y, int z)
{
	return min(x, min(y, z));
}

void fio()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Desktop/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Desktop/CP/output.txt", "w", stdout);
#endif
}

void solve()
{

	int n; read(n);
	int sum = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
			{
				int mi = min3(i, j, k);
				if (mi == 1) sum += 1;
				else if (!(i % mi) && !(j % mi) && !(k % mi))
					sum += mi;
				else sum += gcd(i, gcd(j, k));
			}

	cout << sum;
}

int32_t main()
{
	fio();
	return solve(), 0;
}


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

using namespace std;

int main() {
  long long q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  long long ans = n * q * 4;
  ans = min(ans, n * h * 2);
  ans = min(ans, n * s);
  ans = min(ans, (n/2) * d + (n&1) * min(s, min(4 * q, 2 * h)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using Matrix = vector< vector<int> >;

const int INF = 1 << 30;
int W, H, ans = 0;

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

void dfs(Matrix &mat, int turn, int pos_x, int pos_y) {
    if(turn > 10) return;
    for(int k=0; k<4; k++) {
        int nx = pos_x, ny = pos_y;
        int px = nx + dx[k], py = ny + dy[k];
        if(px < 0 || px >= H || py < 0 || py >= W) continue;
        if(mat[px][py] == 1) continue;

        while(1) {
            nx += dx[k], ny += dy[k];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) {
                // out of range
                break;
            }
            else if(mat[nx][ny] == 3) {
                // goal
                ans = min(ans, turn);
                break;
            }
            else if(mat[nx][ny] == 1) {
                // obstacle
                mat[nx][ny] = 0;
                dfs(mat, turn+1, nx-dx[k], ny-dy[k]);
                mat[nx][ny] = 1;
                break;
            }
        }
    }
}

int main() {
    while(cin >> W >> H, W) {
        ans = INF;
        Matrix mat(H, vector<int>(W));

        int x = 0, y = 0;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                cin >> mat[i][j];
                if(mat[i][j] == 2) {
                    x = i, y = j;
                }
            }
        }

        dfs(mat, 1, x, y);
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int calc(int n, vector <int>& ans) {
    if (ans[n] >= 0) {
        return ans[n];
    }

    int pc = __builtin_popcount(n);
    ans[n] = calc(n%pc, ans) + 1;
    return ans[n];
}

int main() {
    int N;
    string X;

    cin >> N >> X;

    vector <int> ans(N+2, -1);
    ans[0] = 0;

    for (int i = N+1; i >= 1; --i) {
        calc(i, ans);
    }


    vector <int> pc(2);
    for (int i = 0; i < N; ++i) {
        pc[0] += (X[i] == '1');
    }

    pc[1] = pc[0]+1;
    --pc[0];

    vector <long long> res(2);

    for (int i = 0; i < N; ++i) {
        if (pc[0] > 0) {
            res[0] = (res[0]*2 + (X[i]-'0')) % pc[0];
        }

        res[1] = (res[1]*2 + (X[i]-'0')) % pc[1];
    }

    vector <long long> mul(2, 1);
    vector <int> finalRes(N);

    for (int i = N-1; i >= 0; --i) {
        if (X[i] == '0') { // to be pc[1]
            long long newres = (res[1] + mul[1]) % pc[1];
            // cout << "CASE 1 " << newres << endl;
            finalRes[i] = calc(newres, ans) + 1;
        } else { // pc[0]
            if (pc[0] == 0) {
                finalRes[i] = 0;
            } else {
                long long newres = ((res[0] - mul[0])%pc[0] + pc[0]) % pc[0];
                // cout << "CASE 2 " << newres << endl;
                finalRes[i] = calc(newres, ans) + 1;
            }
        }

        if (pc[0] > 0) {
            mul[0] = mul[0]*2%pc[0];
        }

        mul[1] = mul[1]*2%pc[1];
    }

    for (int i = 0; i < finalRes.size(); ++i) {
        cout << finalRes[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5240
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

#[macro_export]
macro_rules! minimum {
    ($($e:expr),+) => {
        {
            let mut res = Vec::new();
            $(
                res.push($e);
            )+
            res.into_iter().min().unwrap()
        }
    };
}

pub const MOD: usize = 1000000007;

fn main() {
    let n: usize = input();
    let (a, b): (usize, usize) = input_two();
    let p: Vec<usize> = input_vec();

    let mut f = 0usize;
    let mut s = 0usize;
    let mut t = 0usize;

    for i in p {
        if i <= a {
            f += 1;
        } else if i <= b {
            s += 1;
        } else {
            t += 1;
        }
    }

    let ans = minimum!(f, s, t);
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N];
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	ll n;
	cin >> n;
	ll c = 1000;
	ll x = 0;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i ++) {
		c += x * a[i];
		x = 0;
		if (a[i] >= a[i + 1]) continue;
		c += x * a[i];
		x = 0;
		ll cnt = c / a[i];
		c -= cnt * a[i];
		x += cnt;
	}
	c += x * a[n];
	cout << c;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    int x,y;cin>>x>>y;
    int t,c;
    bool flag=1;
    if(y%2==1){
        flag=0;
        cout<<"No";
    }
    if(flag){
        c=2*x-y/2;
        t=y/2-x;
        if(c>=0&&t>=0&&(c+t==x)&&(2*c+4*t==y))cout<<"Yes";
        else cout<<"No";
    }
 
return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#define ll long long
using namespace std;

int n;
ll a[100005],s=0,ss=0,ans[100005],one;
int tmp[100005];

int read(){
	int t=1,s=0;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
	if(c=='-')t=-1,c=getchar();
	while(c>='0'&&c<='9')
	s=s*10+c-'0',c=getchar();
	return s*t;
}

int main(void){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		a[i]=read()+0ll;
		a[i]*=2;
		s+=a[i];
	}
	tmp[1]=1;
	ans[1]=0;
	for(int i=1;i<n;i++){
		ans[i+1]=a[i]-ans[i];
		tmp[i+1]=-1*tmp[i];
	}
	one=(a[n]-ans[n])/2;
	for(int i=1;i<=n;i++)
	printf("%lld ",ans[i]+tmp[i]*one);
}


Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>


using namespace std;


int main()
{
	int x;
	int ans;
	long long sum=360;
	scanf("%d",&x);
	if(sum%x==0)ans=sum/x;
	else
	{
		for(int i=1;;i++)
		{
			sum=i*360;
			if(sum%x==0)
			{
				ans=sum/x;
				break;
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 3720
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll h[100005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 1; i < n; i++) {
		if (h[i] > h[i - 1]) {
			h[i]--;
		}
		else if (h[i] < h[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
		
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1024
num, sum_yen = map(int, input().split())

for n_1000 in range(num+1):
    if 1000*n_1000 > sum_yen:
        break
    if (sum_yen-1000*n_1000)%5000 != 0:
        continue
    if n_1000 == num and 1000*n_1000 == sum_yen:
        print('0 0 ' + str(n_1000))
        exit()
    for n_5000 in range(num+1-n_1000):
        if 1000*n_1000+5000*n_5000 > sum_yen:
            break
        n_10000 = num - n_1000 - n_5000
        if n_10000+n_5000+n_1000 == num and \
              10000*n_10000+5000*n_5000+1000*n_1000 == sum_yen:
            print(str(n_10000) + ' ' + str(n_5000) + ' ' + str(n_1000))
            exit()

print('-1 -1 -1')


Measured memory_bytes: 3064
#pragma GCC optimize ("-O3", "unroll-loops")
#include <bits/stdc++.h>
int a[200000], b[200000];
int i, j, k, lim;
constexpr int block = 8192;
signed main() {
	int ans = 0;
	int n;
	scanf("%d", &n);
	int n_blo = n - block;
	int r = n & 3;
	int u = n - r;
	for (i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	for (i = 0; i < n; ++i)
		scanf("%d", &b[i]);
	for (i = 0; i < u; i += 4) {
		for (j = 0; j <= n_blo; j += block) {
			lim = j + block;
			for (k = j; k < lim; ++k) {
				ans ^= (a[i] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
			}
		}
		for (j = n & ~(block - 1); j < n; ++j) {
			ans ^= (a[i] + b[j]) ^ (a[i + 1] + b[j]);
			ans ^= (a[i + 2] + b[j]) ^ (a[i + 3] + b[j]);
		}
	}
	for (i = u; i < n; ++i) {
		for (j = 0; j <= n_blo; j += block) {
			lim = j + block;
			for (k = j; k < lim; ++k)
				ans ^= a[i] + b[k];
		}
		for (j = n & ~(block - 1); j < n; ++j)
			ans ^= a[i] + b[j];
	}
	printf("%d", ans);
	return 0;
}


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


class UnionFind:
    def __init__(self, n):
        self._parents = list(range(n))
        self._ranks = [0] * n

    def root(self, x):
        if self._parents[x] == x:
            return x
        self._parents[x] = self.root(self._parents[x])
        return self._parents[x]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return

        if self._ranks[rx] < self._ranks[ry]:
            self._parents[rx] = ry
        else:
            self._parents[ry] = rx
            if self._ranks[rx] == self._ranks[ry]:
                self._ranks[rx] += 1


def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"):
    uf = UnionFind(N)

    for xx, yy in zip(x, y):
        uf.unite(xx-1, yy-1)

    ret = 0
    for pp in p:
        if uf.root(pp-1) == uf.root(p[pp-1]-1):
            ret += 1
    print(ret)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]" 
    y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, p, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20004
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;

    int c[9] = {};

    rep(i,0,N){
        int in;
        cin >> in;
        if(in >= 3200){
            c[8]++;
        }else{
            c[in/400]++;
        }
    }
    int ansmi = 0,ansma = 0;
    rep(i,0,8){
        if(c[i]) ansmi++;
    }
    ansma = ansmi;

    if(!ansmi) ansmi++;
    ansma += c[8];

    cout << ansmi << " " << ansma << endl;



    return 0;
}


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

//#define PI 3.14159265359

#define PI 3.1415926535897932384626433832795028841971


int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;

    double h_rad = h*30 + m*0.5;
    double m_rad = m*6;

    double rad = min(abs(h_rad - m_rad), abs(m_rad - h_rad));
    rad = min(abs(360-rad), abs(0-rad));

    double ans;
    ans = sqrt(a*a + b*b - 2*a*b*cos(PI / 180 * rad));

    cout<<fixed<<setprecision(20)<<ans<<endl;

}



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

int main(void){
    int n,k;
    cin >> n >> k;
    int r = min(n,k);
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];

    int ans = -1001001001;
    for(int a=0;a<=r;a++){
        for(int b=0;b<=r-a;b++){
            vector<int> pos;

            for(int i=0;i<a;i++) pos.push_back(v[i]);
            for(int i=0;i<b;i++) pos.push_back(v[n-1-i]);
            sort(pos.begin(),pos.end());

            int away = k-(a+b);
            int sub = 0;
            for(int i=0;i<pos.size();i++){
                if(away>0 && pos[i]<0){
                    away--;
                    continue;
                }
                sub += pos[i];
            }
            ans = max(ans,sub);
            //cout << "a,b = " << a << "," << b << " sub: " << sub << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int A,B;
  cin>>A;
  int N[A-1];
  int M[A+1]={};
  for(int i = 0;i < A-1;i++){
    cin>>N[i];
    M[N[i]]++;
  }
  for(int i  = 1;i < A+1;i++)cout<<M[i]<<endl;
}


Measured memory_bytes: 5188
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])

Measured memory_bytes: 38384
while 1:
    t, d, l = map(int, raw_input().split())
    if t == d == l == 0:
        break
    rest = ans = 0
    for i in xrange(t):
        x = int(raw_input())
        if l <= x:
            rest = d
        elif rest:
            rest -= 1
        if rest and i < t-1:
            ans += 1
    print ans

Measured memory_bytes: 6344