akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi a(n),b(n);
		rep(i,1,n){
			cin>>a[i]>>b[i];
		}
		vi x(n),y(n);
		x[0]=0; y[0]=0;
		int l=0,r=0,u=0,d=0;
		rep(i,1,n){
			if(b[i]==0){
				x[i]=x[a[i]]-1;
				y[i]=y[a[i]];
			}else if(b[i]==1){
				x[i]=x[a[i]];
				y[i]=y[a[i]]-1;
			}else if(b[i]==2){
				x[i]=x[a[i]]+1;
				y[i]=y[a[i]];
			}else if(b[i]==3){
				x[i]=x[a[i]];
				y[i]=y[a[i]]+1;
			}
			l=min(l,x[i]);
			r=max(r,x[i]);
			u=max(u,y[i]);
			d=min(d,y[i]);
		}
		o(r-l+1<<" "<<u-d+1);
	}
}

Measured memory_bytes: 1200
#include<stdio.h>
int main(void){
    int n[101]={0},a,kai=0,i;
    while(scanf("%d",&a)!=EOF){
        n[a]++;
        if(kai<n[a])kai=n[a];
    }
    for(i=0;i<101;i++)if(kai==n[i])printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
 	int N, x, a[N];
  	cin >> N >> x;
  
	for(int i=0; i < N; i++){
      cin >> a[i];
    }
  	sort(a, a+N);
  
	for(int i=0; i < N; i++){
      x -= a[i];
      if(x < 0 ){
        cout << i <<endl;
        break;
      }
      else if(x == 0){
        cout << i+1 <<endl;
      	break;
      }
      else if(i == N-1)
        cout << i <<endl;
    }
}

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

long long a,b,c,mx,ans;

int main(){
	cin>>a>>b>>c;
	ans=a+b+c;
	mx=max(max(a,b),c);
	cout<<ans-mx<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cassert>
#include <unordered_set>
#include <set>
#include <bitset>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
using namespace std;
 
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
 
const int MOD = (int) 1e9 + 7;

long long dp[305][305][305];
 
int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    a.push_back(0);
    ++n;

    for (int i = 0; i <= n; ++i ){
        for (int j = 0; j <= k; ++j) {
            for (int last = 0; last < n; ++last) {
                dp[i][j][last] = dp[i][j][last] = (long long) 1e18;
            }
        }
    }

    dp[0][0][n - 1] = a[0];
    for (int i = 0; i + 1 < n; ++i) {
        for (int j = 0; j <= k; ++j) {
            for (int t = 0; t < n; ++t) {
                if (dp[i][j][t] == (long long) 1e18)
                    continue;

                dp[i + 1][j + 1][t] = min(dp[i + 1][j + 1][t], dp[i][j][t] - (a[t] < a[i] ? abs(a[t] - a[i]) : 0) + (a[i + 1] > a[t] ? abs(a[i + 1] - a[t]) : 0));
                dp[i + 1][j][i] = min(dp[i + 1][j][i], dp[i][j][t] + (a[i + 1] > a[i] ? abs(a[i + 1] - a[i]) : 0));

                // cout << i << " " << j << " " << t << " " << dp[i][j][t] << "\n";

                // if (cur <= a[i + 1]) { 
                //     dp[i + 1][j][i + 1] = min(dp[i + 1][j][i + 1], dp[i][j][t] + abs(cur - a[i + 1]));
                //     dp[i + 1][j + 1][t] = min(dp[i + 1][j + 1][t], dp[i][j][t] + abs(cur - a[i + 1]));
                //     if (i == t) {
                //         dp[i + 1][j + 1][i + 1] = min(dp[i + 1][j][i + 1], dp[i][j][t] + abs(cur - a[i + 1]));
                //     }
                // } else {
                //     dp[i + 1][j][i + 1] = min(dp[i + 1][j][i + 1], dp[i][j][t] + abs(cur - a[i + 1]));
                //     dp[i + 1][j + 1][t] = min(dp[i + 1][j + 1][t], dp[i][j][t]);                    
                // }
            }
        }
    }

    long long ans = (long long) 1e18;

    for (int j = 0; j <= k; ++j) {
        for (int t = 0; t < n; ++t) {
            if (dp[n - 1][j][t] == (long long) 1e18)
                continue;

            ans = min(ans, dp[n - 1][j][t] + a[n - 1]);
        }
    } 

    cout << ans << "\n";
}


Measured memory_bytes: 221440
import math
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([math.ceil(max(0, h - x * B) / (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while r - l > 1:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m
    # print(r, l, m)
        
print(r)

Measured memory_bytes: 11032
#include<iostream>
using namespace std;
string n,s;
int main()
{
	cin>>n;
	s=n;
	swap(n[0],n[3]);
	swap(n[1],n[2]);
	for(int i=0;i<n.size();i++)
	 n[n.size()-i-1]=s[i];
	for(int i=0;i<n.size();i++)
	{
		if(n[i]=='b') n[i]='d';
		else if(n[i]=='d') n[i]='b';
		else if(n[i]=='p') n[i]='q';
		else if(n[i]=='q') n[i]='p';
	}
	if(s==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
package main

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

func main() {
	n := readInt()

	h := make([]int, n)
	for i := range h {
		h[i] = readInt()
	}

	dp := make([]int, n)
	for i := range dp {
		dp[i] = math.MaxInt64
	}
	dp[0], dp[1] = 0, abs(h[0]-h[1])

	for i := 2; i < n; i++ {
		c1 := dp[i-2] + abs(h[i-2]-h[i])
		c2 := dp[i-1] + abs(h[i-1]-h[i])
		dp[i] = min(c1, c2)
	}

	fmt.Println(dp[n-1])
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> ans(N);

    for (int x = 1; x <= N; ++x) {
        for (int y = x+1; y <= N; ++y) {
            int d = y - x;
            int p = abs(X-x) + 1 + abs(Y-y);
            ans[min(d,p)]++;
        }
    }
    
    for (int i = 1; i < N; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
int main(){
    int w, h,x,y,r;scanf("%d%d%d%d%d", &w,&h,&x,&y,&r);
    if(x-r >=0&&y-r>=0&&x+r<=w&&y+r<=h) puts("Yes");
    else puts("No");
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
std::random_device rnd_dev;
std::mt19937 rnd(rnd_dev() ^ time(NULL));

std::vector<int> init(int n, const std::vector<int> &c, const std::vector<std::vector<int> > &val) {
	(void) val;
	double par[26];
	for (int i = 0; i < 26; i++) par[i] = std::sqrt(c[i]);
	double sum = std::accumulate(par, par + 26, 0.0);
	int times[26];
	double acc = 0;
	for (int i = 0; i < 26; i++) {
		acc += par[i];
		times[i] = (acc + 0.00001) / sum * n;
	}
	for (int i = 25; i--; ) times[i + 1] -= times[i];
	// for (auto &i : times) i--;
	//for (auto i : times) std::cerr << i << std::endl;
	std::vector<int> res;
	for (int i = 0; i < 26; i++) for (int j = 0; j < times[i]; j++) res.push_back(i);
	std::shuffle(res.begin(), res.end(), rnd);
	assert(res.size() == n);
	return res;
}


std::vector<int> solve(int n, const std::vector<int> &c, const std::vector<std::vector<int> > &val) {
	auto score = [&] (const std::vector<int> &all) {
		int last[26];
		for (auto &i : last) i = -1;
		int res = 0;
		for (int i = 0; i < n; i++) {
			int cur = all[i];
			last[cur] = i;
			for (int j = 0; j < 26; j++) res -= c[j] * (i - last[j]);
			res += val[i][cur];
		}
		return res;
	};
	clock_t start = clock();
	
	auto r26 = init(n, c, val);
	
	std::vector<int> cur = r26;
	int cur_score = score(cur);
	int best_score = -1000000000;
	std::vector<int> best;
	
	while (1) {
		clock_t cur_time = clock();
		if (cur_time - start > 1.95 * CLOCKS_PER_SEC) break;
		int r0 = std::uniform_int_distribution<>(0, n - 1)(rnd);
		int r1 = std::uniform_int_distribution<>(0, n - 1)(rnd);
		std::swap(cur[r0], cur[r1]);
		double threshold = 1.95 - (double) (cur_time - start) / CLOCKS_PER_SEC;
		// std::cerr << threshold << std::endl;
		int new_score = score(cur);
		if (new_score >= best_score) cur_score = new_score;
		else std::swap(cur[r0], cur[r1]);
		if (best_score < cur_score) best_score = cur_score, best = cur;
	}
	
	return best;
}

void input() {
	int n = ri();
	std::vector<int> c(26);
	for (auto &i : c) i = ri();
	std::vector<std::vector<int> > val(n, std::vector<int>(26));
	for (auto &i : val) for (auto &j : i) j = ri();
	for (auto i : solve(n, c, val)) printf("%d\n", i + 1);
}

void random_test() {
	int n = 365;
	std::vector<int> c(26);
	for (auto &i : c) i = std::uniform_int_distribution<>(0, 100)(rnd);
	std::vector<std::vector<int> > val(n, std::vector<int>(26));
	for (auto &i : val) for (auto &j : i) j = std::uniform_int_distribution<>(0, 20000)(rnd);
	
	auto res = solve(n, c, val);
	
	
	int last[26];
	for (auto &i : last) i = -1;
	int score = 0;
	for (int i = 0; i < n; i++) {
		last[res[i]] = i;
		for (int j = 0; j < 26; j++) score -= c[j] * (i - last[j]);
		score += val[i][res[i]];
	}
	printf("%d\n", score);
}

int main() {
#	ifdef LOCAL
	random_test();
#	else
	input();
#	endif
	return 0;
}



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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> b[i];
	}
	ll ans = 0;
	for (int j = 0; j < 29; ++j)
	{
		ll num = 0;
		vector<ll> d(n);
		for (int i = 0; i < n; ++i)
		{
			d[i] = b[i]&((1<<(j+1))-1);
		}
		sort(d.begin(), d.end());
		for (int i = 0; i < n; ++i)
		{
			ll c = a[i]&((1<<(j+1))-1);
			num += (upper_bound(d.begin(), d.end(), (1<<(j+1))-1-c) - d.begin()) - (lower_bound(d.begin(), d.end(), (1<<j)-c) - d.begin()) - 1 + n-1 - (lower_bound(d.begin(), d.end(), 3*(1<<j)-c) - d.begin());
		}
		ans += (num&1)<<j;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

vi a(5);

int main(){
	while(1){
		cin>>a[0];
		if(!a[0]) break;
		a[0]--;
		for(int i=1;i<5;i++){
			cin>>a[i];
			a[i]--;
		}
		vb tmp(3);
		for(int i=0;i<5;i++) tmp[a[i]]=1;
		int num=0;
		for(int i=0;i<3;i++){
			if(tmp[i]) num++;
		}
		if(num==1||num==3){
			for(int i=0;i<5;i++) cout<<3<<endl;
		}
		else{
			int w,l;
			if(tmp[0]&&tmp[1]) w=0;
			if(tmp[1]&&tmp[2]) w=1;
			if(tmp[2]&&tmp[0]) w=2;
			for(int i=0;i<5;i++){
				if(a[i]==w) cout<<1<<endl;
				else cout<<2<<endl;
			}
		}
	}
}

Measured memory_bytes: 1192
import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*;

public class Main {

	String text, max;
	int ans;

	class Node implements Comparable<Node> {
		String word = "";
		int fre = 1;
		int len;

		Node(String word) {
			this.word += word;
			this.len = word.length();
		}

		public int compareTo(Node b) {
			return b.fre - fre;
		}
	}

	Node node[];

	void in(String str) {
		if (ans == 0) {
			node[0] = new Node(str);
			ans++;
			return;
		}
		for (int i = 0; i < ans; i++) {
			if (str.equals(node[i].word)) {
				node[i].fre++;
				return;
			}
		}
		node[ans] = new Node(str);
		ans++;
	}

	void getWords() {
		String str = "";
		for (int i = 0; i < text.length(); i++) {
			if (text.charAt(i) != ' ')
				str += text.charAt(i);
			if (text.charAt(i) == ' ' || i == text.length() - 1) {
				in(str);
				if (str.length() > max.length()) {
					max = "";
					max += str;
				}
				str = "";
			}
		}
	}

	void run() throws Exception {
		while (cin.hasNext()) {
			node = new Node[1000];
			max = "";
			ans = 0;
			text = cin.nextLine();
			getWords();
			Arrays.sort(node, 0, ans);
			System.out.println(node[0].word + " " + max);
		}
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	static Scanner cin = new Scanner(new BufferedInputStream(System.in));
}

Measured memory_bytes: 17192
//2020.1.21
//s1270188 xxxmk2
//icpc 2019 pre1

#include<stdio.h>
#define N 1000

int main(){
  int d[N], n, m;
  int i, j, a;

  while(1){
    
    //input n m
    scanf("%d %d",&n,&m);
    if(n==0 && m==0) break;
  
    //reset
    for(i=0;i<n;i++) d[i]=0;

    //input data
    for(i=0;i<m;i++){
      for(j=0;j<n;j++){
	scanf("%d",&a);
	d[j]+=a;
      }
    }

    //judge
    a=0;
    for(i=0;i<n;i++){
      if(d[i]>a) a=d[i];
    }

    //output
    printf("%d\n",a);

  }
  
  return 0;
}



Measured memory_bytes: 2052
#include<cstdio>
int main(){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(0<=x-r && 0<=y-r && x+r<=w && y+r<=h){
			printf("Yes\n");
	}else {
		printf("No\n");
	}
}

Measured memory_bytes: 2640
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int R,G;
  cin>>R>>G;
  cout<<2*G-R<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int r = sc.nextInt();
			int n = sc.nextInt();
			if(r==0 && n==0)
				break;
			
			int[] xl = new int[n];
			int[] xr = new int[n];
			int[] h = new int[n];
			for(int i=0;i<n;i++){
				xl[i] = sc.nextInt();
				xr[i] = sc.nextInt();
				h[i] = sc.nextInt();
			}
			
			solve(r, n, xl, xr, h);
		}
	}

	public void solve(int r, int n, int[] xl, int[] xr, int[] h) {
		
		
		int[] cover = new int[2*r];
		for(int i=0;i<xl.length;i++){
			xl[i]+=r;
			xr[i]+=r;
			xl[i] = xl[i]<0 ? 0 : xl[i];
			xr[i] = xr[i]<0 ? 0 : xr[i];
			
			int ll = Math.min(xl[i], xr[i]);
			int rr = Math.min(r*2, Math.max(xl[i], xr[i]));
			
			int c = h[i];
			for(int j=ll;j<rr;j++){
				cover[j] = Math.max(cover[j], c);
			}
		}
		
//		System.out.println(Arrays.toString(cover));
		double res = 100000.0;
		for(int i=0;i<cover.length;i++){
			int xx = i-r>0 ? i-r+1 : r-i-1;
			double t1 = cover[i] + r*(1-Math.sin(Math.acos((double)Math.abs(r-i)/r)));
			double t2 = cover[i] + r*(1-Math.sin(Math.acos((double)xx/r)));
			res = Math.min(res, Math.min(t1,t2));
		}
		
		System.out.println(String.format("%.4f",res));
	}

}

Measured memory_bytes: 26156
# x 以下でc, d 両方で割れない条件を満たす自然数の個数をf(x, c, d) とすると
# 求める値は f(b, c, d) - f(a-1, c, d)
# x 以下でk で割れる自然数の個数を g(x, k)とすれば
# f(x, c, d) = x - (g(x, c) + g(x, d) - g(x, lcm(c,d)))
# よって計算すべきは
# g(b, c) + g(b, d) - g(b, lcm(c,d)) - ( g(a-1, c) + g(a-1, d) - g(a-1, lcm(c,d)))
 
def gcd (p, q):
    temp = max(p, q)
    q = min(p, q)
    p = temp
    if q == 0:
        return p
    else:
        return gcd(q, p%q)
    
def lcm(p, q):
    return p * q // gcd(p, q)
 
def g(x, k):
    return x//k
 
def f(x, c, d):
    return x - (g(x, c) + g(x, d) - g(x, lcm(c,d)))
 
a,b,c,d = list(map(lambda x:int(x) ,input().split()))
 
print(f(b, c, d) - f(a-1, c, d))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
struct block {
    int w, s, v;
    block(int a,int b, int c)
    {
      this->w = a;
      this->s = b;
      this->v = c;
    }
};
// 比較関数
bool comp(block a, block b) { return a.w + a.s < b.w + b.s; }

void solve(void)
{
  
  int N;cin>>N;
  vector<block> BLOCK;
  for (int i = 0; i < N; i++)
  {
    int W,S,V;
    cin>>W>>S>>V;
    // int b = (W,S,V);
    BLOCK.emplace_back(W,S,V);
  }
  sort(BLOCK.begin(),BLOCK.end(),comp);
  vector<vector<int> > DP (1009,vector<int>(20009,0));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= 20000; j++)
    {
      DP[i+1][j] = DP[i][j];
      if(j >= 1) DP[i+1][j] = max(DP[i+1][j],DP[i+1][j-1]);
      if(j>=BLOCK[i].w && j - BLOCK[i].w <= BLOCK[i].s)
      DP[i+1][j] = max(DP[i+1][j],DP[i][j-BLOCK[i].w]+BLOCK[i].v);
      // DEBUG(BLOCK[i].w);
    }
    
  }
  cout<<DP[N][20000]<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { // 最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    int count = m;

    rep(i, m)
            cin >>
        a[i] >> b[i];

    rep(i, m)
    {
        UnionFind tree(n + 1);

        rep(j, m)
        {
            if (j == i)
                continue;

            tree.unite(a[j], b[j]);
        }
        count -= tree.same(a[i], b[i]);
    }

    cout << count << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
ll n,k,sum,mod=1000000007;
ll s;
int a[2100];
ll c[2100],c2[2100];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        {cin>>a[i];}
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                continue;
            if(a[i]>a[j])
            {   //cout<<a[i]<<' '<<a[j]<<endl;
                c[i]++;
                if(i>j)
                {
                    c2[i]++;
                }
            }
        }
    }

    for(int i=0;i<n;i++)
    {   ll f=k*(k-1)/2;
        f%=mod;
        sum+=((c[i]-c2[i])*k%mod)+(c[i]*f)%mod ;
        sum%=mod;
    }
    cout<<sum;
   return 0;
}




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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int L = a + b, R = c + d;
  if (L > R)
    cout << "Left" << endl;
  else if (L == R)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    out.println(Math.max(reader.nextInt() * reader.nextInt(), reader.nextInt() * reader.nextInt()));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, t; cin >> n >> t;
	vl h(n); REP(i, n) cin >> h[i];

	vl interval(n);
	vl start(n);
	REP(i, n) {
		if (i == 0) {
			interval[i] = h[i];
			start[i] = 0;
		} else {
			start[i] = start[i - 1] + h[i - 1];
			if (h[i] >= interval[i - 1]) interval[i] = h[i];
			else interval[i] = interval[i - 1];
		}
		if (t - start[i] < 0) cout << 1 << endl;
		else cout << (t - start[i]) / interval[i] + 1 + ((t - start[i]) % interval[i] >= h[i] ? 1 : 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 5204
A,B,M = map(int,input().split())

reizou = input()
reizou_list = reizou.split()

renji = input()
renji_list = renji.split()
cupon_list = []

price = int(min(reizou_list)) + int(min(renji_list))

for i in range(int(M)):
    # coupon = input()
    # coupon_sub_list = coupon.split()
    # cupon_list.append(coupon_sub_list)
    
    a,b,c = map(int,input().split())
    price_coupon = int(reizou_list[int(a) - 1]) + int(renji_list[int(b) - 1]) - int(c)
    if price > price_coupon: price = price_coupon

print(price)

Measured memory_bytes: 18376
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n=int(input())
AB=[input_array() for _ in range(n)]

sort_AB=sorted(AB,key=lambda x:x[1])

ans=0
flag=True
for i in sort_AB:
	ans+=i[0]
	if ans > i[1]:
		flag=False
		break

if flag:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 48620
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int sumofdigits(int s)
{
	int ans = 0;
	while(s)
	{
		ans += s%10;
		s /= 10;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a,b;
	cin>>n>>a>>b;
	int sum = 0;
	for(int i = 1; i<=n; i++)
	{
		int d = sumofdigits(i);
		if(d>=a && d<=b) sum += i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner src = new Scanner(System.in);
	public static void main(String[] args) {
		String str = src.next();
		char c = str.charAt(str.length() - 1);
		if(c == '3') {
			System.out.println("bon");
		}else if(c == '0' || c == '1' || c == '6' || c == '8') {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35696
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1),b(n+1,0);
    cins(all(a));
    rep(i,n){
        b[n-i-1] = b[n-i]+a[n-i-1];
    }
    if (n == 0){
        if (a[0] == 1) PRINT(1);
        else PRINT(-1);
        return 0;
    }
    //array_output(all(b));
    ll ans = 1-a[0],c = 1-a[0];
    rep(i,1,n){
        if (c*2 <= a[n]+b[i]){
            if (c*2 < a[i]){
                PRINT(-1);
                return 0;
            }
            else{
                ans += c*2;
                c = c*2-a[i];
            }
        }
        else{
            if (c*2 < a[i]){
                PRINT(-1);
                return 0;
            }
            else{
                ans += a[n]+b[i];
                c = a[n]+b[i+1];
            }
        }
    }
    if (c*2 >= a[n]){
        ans += a[n];
    }
    else{
        PRINT(-1);
        return 0;
    }
    PRINT(ans);
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	set<int> s = { 1, 2, 3 };
	for (int i = 2; i--; )
	{
		int x;
		cin >> x;
		s.erase(x);
	}

	cout << *s.begin();

	return 0;
}


Measured memory_bytes: 256
dice = [
	[1, 2, 4, 3, 5],
	[5, 2, 0, 3, 4],
	[1, 5, 4, 0, 3],
	[1, 0, 4, 5, 2],
	[0, 2, 5, 3, 1],
	[1, 3, 4, 2, 0]
]

def getRound(D, top):
	result = []
	for index in dice[top]:
		result.append(D[index])
	return result

def compareRound(l1, l2):
	if l1[4] != l2[4]:
		return False
	elif l1[0] not in l2:
		return False
	offset = l2.index(l1[0])
	
	for i in range(4):
		if l1[i] != l2[(i+offset)%4]:
			return False
	return True

def compare(D1, D2, i1):
	if D1[i1] not in D2:
		return False
	i2 = D2.index(D1[i1])
	return compareRound(getRound(D1, i1), getRound(D2, i2))

D1 = input().split(" ")
D2 = input().split(" ")
isSame = False
for i in range(6):
	if compare(D1, D2, i):
		isSame = True
if isSame:
	print("Yes")
else:
	print("No")

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll x;
    cin>>x;

    ll dep = 100;
    double tmp = dep;

    while(dep < x){
        tmp = dep;tmp *= 1.01;
        
        dep = (ll)tmp;
        ++ans;
        //db2(dep,ans);ln;
    }

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

long N, n;
vector<int> p;

int main(void) {
  cin >> N;

  for(n = 50; n > 0; n--) if(N >= (1L << n) - 1) break;
  N -= (1L << n) - 1;

  for(int i = 1; i <= n; i++) p.push_back(i);
  for(int i = 1; i <= n; i++) p.push_back(i);

  for(int i = n - 1; i >= 0; i--)
    if(N >= (1L << i)) {
      N -= (1L << i);
      n++;
      p.insert(p.begin() + i, n);
      p.push_back(n);
    }

  cout << p.size() << endl;
  for(int i = 0; i < p.size(); i++) cout << p[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int lx = 0, ly = 0, ux, uy;
  int n;
  int x, a, y;
  cin >> ux >> uy >> n;

  REP(i,n){
      cin >> x >> y >> a;
      if(a==1){
          lx = max(lx, x);
      }else if(a==2){
          ux = min(ux, x);
      }else if(a==3){
          ly = max(ly,y );
      }else{
          uy = min(uy, y);
      }
  }
  cout << max(0,(ux-lx))*max(0,(uy-ly)) << endl;
}






Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);

  d = a / b;
  r = a % b;
  f = (double)a/b;

  printf("%d %d %f\n",d,r,f);

  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main() {
    	string x;
      	cin >> x;
      	bool check = true;
      	for (int i = 0; i < x.length() - 1; i++) {
        	if (x[i] == x[i + 1])
              check = false;
        }
      	if (!check) {
        	printf("Bad");
        }
      	else printf("Good");
    }

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

using namespace std;

const int N = 1000001;

int _cnt[N], *cnt = _cnt + 1;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    cnt[a]++;
  }
  int mx = 0;
  for (int num = 0; num <= 100000; num++) {
    mx = max(mx, cnt[num - 1] + cnt[num] + cnt[num + 1]);
  }
  printf("%d\n", mx);
  return 0;
}

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


int main() {
    int n;

    cin >> n;

    if(n % 2 == 0){
        cout << n / 2 << endl;
    }
    else{
        cout << n/2 + 1 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N;
  long long Y;
  scanf("%d%lld",&N,&Y);

  for(int i = 0;i <= N;i++){
    if(i*10000 > Y) break;
    for(int j = 0;j <= N-i;j++){
      if(i*10000+j*5000 > Y) break;
      int k = N-i-j;
      if(i*10000+j*5000+k*1000 == Y){
        printf("%d %d %d\n",i,j,k);
        return 0;
      }
    }
  }

  printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
		
		string str;cin>>str;
		int len = str.size();
		vector<int> v;
		v.push_back(3);
		for(int i=0;i<len;i++){
				if(str[i]=='B' && v.back()==3)continue;
				if(str[i]=='0')v.push_back(0);
				if(str[i]=='1')v.push_back(1);
				if(str[i]=='B'){
					v.pop_back();
					}
			}
		int s = v.size();	
		for(int i=1;i<s;i++){
				cout<<v[i];	
		}
		return 0;
	}


Measured memory_bytes: 3644
def f(a, b):
    for x in range(n - m + 1):
        for y in range(n - m + 1):
            ok = True
            for i in range(m):
                for j in range(m):
                    if b[i][j] != a[i + x][j + y]:
                        ok = False
                    if not ok:
                        break
                if not ok:
                    break
            if ok:
                return 'Yes'
    return 'No'


n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print(f(a, b))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int s[105];
int main()
{
	int n,k;
	cin>>k>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	sort(s,s+n);
	int flag=k;
	for(int i=0;i<n;i++)
	{
		if(s[i]>k||i==n-1)
		{
			int a=k;
			int b=k;
			while(1)
			{
			
			int x=0;
			for(int j=i;j>=0;j--)
			{
				if(s[j]==a)
				x=1;
			}
			if(!x)
			{
				flag=a;
				break;
			}
			a--;
			int y=0;
			for(int j=i-1;j<n;j++)
			{
				if(s[j]==b)
				y=1;
				}
				if(!y)
				{
					flag=b;
					break;
					}
						b++;
			}
		break;	
		}
		
	}
	cout<<flag<<endl;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int cnt=0;
  for(int i=1;i<=n;i+=2){
    cnt++;
  }
  printf("%s\n",cnt>=k?"YES":"NO");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        while (true) {
            if (a + 1 == b) {
                System.out.println("Borys");
                return;
            }

            a++;

            if (b - 1 == a) {
                System.out.println("Alice");
                return;
            }

            b--;
        }
    }
}


Measured memory_bytes: 23508
n,k = map(int,input().split())
sun=[]

for i in range(n):
    sun.append(0)

for i in range(k):
    d=int(input())
    tmp=list(map(int,input().split()))
    for j in tmp:
        sun[j-1]=sun[j-1]+1
    
ans=0

for i in range(n):
    if(sun[i]==0):
        ans=ans+1


print(ans)


Measured memory_bytes: 9204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X;
	cin >> X;

	if(X >= 30){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;

}


Measured memory_bytes: 3640
N,M=map(int,input().split())
if abs(N-M)>1:
    print(0)
    quit()
if abs(N-M)==1:
    a=1
else:
    a=2
MOD=10**9+7
def factorials(M):#M!までのリストｘと其の逆元のリストyを返すmod INF
    INF=int(1e9+7)
    fac=[0]*(M+1)
    finv=[0]*(M+1)
    inv=[0]*(M+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,M+1):
        fac[i]=(fac[i-1]*i)%INF
        inv[i]=INF-(inv[INF%i]*(INF//i))%INF
        finv[i]=finv[i-1]*inv[i]%INF
    return fac,finv
def nCr(n,r):
    INF=int(1e9+7)
    if n<r or r<0 or n<0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%INF)%INF

fac,finv=factorials(max(N,M))

print((a*fac[N]*fac[M])%MOD)


Measured memory_bytes: 41968
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k,ans;
pii w[N];
string s;
map<int, int>v;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>k>>n;
	for(int i = 1;i<=n;i++){
		int x;
		cin>>x;
		v[x] = 1;
	}

	pii cara = {200000000, -1};
	for(int i = k - 300; i <= k + 300; i++){
		if(!v[i])cara = min(cara, pii(abs(i - k), i));
	}
	cout<<cara.s<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3652
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;sc.hasNextInt();){

			LinkedList<Integer> v = new LinkedList<Integer>();

			v.add(1);

			v.add(2);

			for(;;){

				int a = sc.nextInt();

				int b = sc.nextInt();

				if((a|b)==0) break;

				if(v.contains((Object)a)){

					v.remove((Object)a);

				}else{

					v.add(a);

				}

				a = b;

				if(v.contains((Object)a)){

					v.remove((Object)a);

				}else{

					v.add(a);

				}

			}

			System.out.println(v.isEmpty()?"OK":"NG");

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

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

int main(){
  string s;
  cin >> s;
  int ex = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'o') ex++;
  }
  
  cout << 700 + 100 * ex << endl;
  
  return 0;
}

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

  val aList = mutableListOf(bList[0])
  for (i in 1 until bList.size) {
    aList.add(Math.min(bList[i - 1], bList[i]))
  }
  aList.add(bList[bList.size - 1])

  println(aList.sum())
}



Measured memory_bytes: 36036
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる

#define ll long long
using namespace std;

int h,w;
int MAX_H=50,MAX_W=50;
char s[50][51];
// int visited[MAX_H][MAX_W];

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

int visit(int x,int y){
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(0<=nx<h && 0<=ny<w && s[nx][ny]=='#'){
      return true;
    }
  }
  return false;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
      // visited[i][j]=0;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        if(!visit(i,j)){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
n, m ,c  = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in a:
    s = 0
    for j in range(m):
        s += i[j]*b[j]
    s += c
    if s > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 1;
        for(;i<1000;i++){
            String str = sc.nextLine();
            if(str!=null){
            String[] str2 = str.split(" ");
            int x = Integer.parseInt(str2[0]);           
            int y = Integer.parseInt(str2[1]);

            if(x == 0 || y==0){
                break;
            }
            else{
                for(int j=0;j<x;j++){
                for(int k=0;k<y;k++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            }
            System.out.print("\n");
        }
        }  
    }
}              

    


Measured memory_bytes: 37260
N, M = map(int, input().split())
# ここの入力方法調べる
mat = list(list(map(int, input().split())) for i in range(N))
mat = sorted(mat, key=lambda x: x[0])

i = 0
cost = 0
num = 0
while num<M:
    if M-num >= mat[i][1]:
        num += mat[i][1]
        cost += mat[i][1] * mat[i][0]
        i += 1
    else:
        cost += mat[i][0] * (M-num)
        num += M-num
print(cost)

Measured memory_bytes: 29796
INF = int(1e9) + 7

n = int(input())
a = list(map(int, input().split()))
col = [0, 0, 0]
ans = 1
for i in range(n):
    m = 0
    for j in range(3):
        if a[i] ==col[j]:
            m = col.count(a[i])
    ans *= m
    
    for j in range(3):
        if a[i]==col[j]:
            col[j] +=1
            break
        else:
            continue
    ans = ans%INF

print(ans)


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define pb push_back
#define ll long long int
#define P pair<ll, ll>


int main() {
  int n;
  cin >> n;
  int d[2][2*n];
  REP(i, 2)REP(j, 2*n) d[i][j] = -1;
  REP(i, n){
    int a, b;
    cin >> a >> b;
    d[0][a] = b;
  }
  REP(i, n){
    int a, b;
    cin >> a >> b;
    d[1][a] = b;
  }
  int ans = 0;
  vector<int> que;
  REP(i, 2*n){
    if(d[0][i] != -1) que.pb(i);
    else{
      int mx = -1, ind = 0;
      for(int e: que){
        if(d[0][e] < d[1][i] && mx < d[0][e]){
          mx = d[0][e];
          ind = e;
        }
      }
      if(mx != -1){
        int t;
        REP(j, que.size()){
          if(que[j] == ind) t = j;
        }
        que.erase(que.begin()+t);
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256