akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline
from collections import defaultdict

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

N, X, D = map(int, readline().split())

ans = 0
if X == D == 0:
    ans = 1
elif X == 0:
    ans = N**2-N*(N+1)//2+1
elif D == 0:
    ans = (N+1)
else:
    if D < 0:
        X = -X
        D = -D
    g = gcd(abs(X), abs(D))
    X //= g
    D //= g
    
    LR = defaultdict(list)
    LR[0].append((0, 0))
    for i in range(1, N+1):
        Li, Ri = (i-1)*i//2, i*N - i*(i+1)//2
        LR[(i*X)%D].append((Li+i*X//D, Ri+i*X//D))
    
    for V in LR.values():
        V.sort()
        lp, rp = V[0]
        for l, r in V[1:]:
            if rp < l:
                ans = (ans + rp-lp+1)
                lp, rp = l, r
            else:
                rp = max(r, rp)
        ans = (ans + rp-lp+1)
print(ans)

Measured memory_bytes: 86232
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,p;
    string s;
    cin>>n;
    pair<pair<string,long long>,long long > ss[n];
    f(i,0,n){
        cin>>s>>p;
        ss[i]=make_pair(make_pair(s,-p),i);
    }
    sort(ss,ss+n);
    f(i,0,n){
        cout<<ss[i].second+1<<endl;
    }
    return 0;
}


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

int main(){
	int n, m; cin >> n >> m;
  	vector<int> a(n); for(int i = 0; i < m; i++){cin >> a.at(i);}
  	
  	int d = n - accumulate(a.begin(),a.end(),0);
  	if(d >= 0){cout << d << endl;}
  	else{cout << -1 << endl;}
}

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

int gcd(int x, int y)
{
  return y ? gcd(y,x%y) : x;
}

int main()
{
  int k; cin >> k;
  ll ans = 0;
  for (int p=1; p<=k; p++)
  {
    ans += p;
    for (int q=p+1; q<=k; q++)
    {
      ans += gcd(p, q) * 6;
      for (int r=q+1; r<=k; r++)
        ans += gcd(gcd(p, q), r) * 6;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a,i,j;
	char str[8];
	vector<int> s, memo;
	s.resize(64);
	while (true) {
		for (i = 0; i < 8; i++) {
			for (j = 0; j < 8; j++) {
				cin >> str[j];
				if (str[j] == '1') {
					a = 8 * i + j;
					memo.push_back(a);
				}
			}
		}
		if (cin.eof())break;
		if (memo[1] - memo[0] == 1) {
			if (memo[2] - memo[1] == 7) {
				cout << "A" << endl;
			}
			else if (memo[2] - memo[1] == 1) {
				cout << "C" << endl;
			}
			else if (memo[2] - memo[1] == 8) {
				cout << "E" << endl;
			}
			else if (memo[2] - memo[1] == 6) {
				cout << "G" << endl;
			}
		}
		else if (memo[1] - memo[0] == 8) {
			if (memo[2] - memo[1] == 8) {
				cout << "B" << endl;
			}
			else if (memo[2] - memo[1] == 1) {
				cout << "F" << endl;
			}
		}
		else if (memo[1] - memo[0] == 7) {
			cout << "D" << endl;
		}
		memo.clear();
	}
	return 0;
}

Measured memory_bytes: 3108
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (x1, y1, x2, y2) = get!(i64, i64, i64, i64);

    let x3 = y1 - y2 + x2;
    let y3 = y2 - (x1 - x2);
    let x4 = x1 + (y1 - y2);
    let y4 = y1 - (x1 - x2);

    println!("{} {} {} {}", x3, y3, x4, y4);
}


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



int main(void){
  int n;
  char s[100000][20];
  int i,j,k;
  long int counta[5];
  long int ans=0;
  for(i=0;i<5;i++){
    counta[i]=0;
  }
  //read input
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
    if(s[i][0]=='M'){
      counta[0]++;
    }
    else if(s[i][0]=='A'){
      counta[1]++;
    }
    else if(s[i][0]=='R'){
      counta[2]++;
    }
    else if(s[i][0]=='C'){
      counta[3]++;
    }
    else if(s[i][0]=='H'){
      counta[4]++;
    }
  }
  for(i=0;i<3;i++){
    for(j=i+1;j<4;j++){
      for(k=j+1;k<5;k++){
	ans += counta[i]*counta[j]*counta[k];
      }
    }
  }
  printf("%ld\n",ans);
  
  return 0;
}


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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=2e5+5;
int dy[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,1,n)
	{
		int x;
		scanf("%d",&x);
		dy[x]=i;
	}
	int ans=0;
	int now=0;
	rep(i,1,n)
	{
		if(dy[i]>dy[i-1])++now;
		else now=1;
		if(now>ans)ans=now;
	}
	cout<<n-ans;
}

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

const int d = 365;
int main() {
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<int> t(26);
  for (int i = 0; i < 26; i++) {
    t[i] = i + 1;
  }

  for (int i = 0; i < d; i++) {
    cout << t[rand() % 26] << endl;
  }

  return 0;
}


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

int main(int argc, char const *argv[]) {
    double W, H, x, y, area;
    int judge;
    cin >> W >> H >> x >> y;

    area = W*H/2.0;
    if (W == 2*x && H == 2*y) {
        judge = 1;
    } else {
        judge = 0;
    }

    cout << area << ' ' << judge << endl;

    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10**9 + 7

f = [1, 1]
for i in range(2, n):
    f.append((f[i-1] * i) % mod)

total = 0
for i in range(n - k + 1):
    p = n - i - 1
    q = k - 1

    c = f[p] * pow(f[p-q], mod-2, mod) * pow(f[q], mod-2, mod) % mod
    total += c * (a[-1-i] - a[i])
    total = total % mod

print(total)


Measured memory_bytes: 14040
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int b1, b2, b3;
	cin >> b1 >> b2 >> b3;
	if(b1==1&&b2==1||b3==1){
		cout << "Open" << endl; 
	}else {
		cout << "Close" << endl;
	}
	return 0;
}

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

int par[100000],high[100000];
int find(int x){
	if(x==par[x])return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);y=find(y);
	if(x==y)return;
	if(high[x]>high[y]){
		par[y]=x;
	}
	else{
		par[x]=y;
		if(high[x]==high[y]){
			high[y]++;
		}
	}
}
int main(){
	int n,m;cin>>n>>m;
	rep(i,n){
		par[i]=i;
	}
	rep(i,m){
		int s,t;cin>>s>>t;
		unite(s,t);
	}
	int q;cin>>q;
	rep(i,q){
		int s,t;cin>>s>>t;
		puts(find(s)==find(t)?"yes":"no");
	}
}

Measured memory_bytes: 3868
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int X;

  cin >> X;

  int rank = 0;
  if (X <= 599) {
    rank = 8;
  }
  else if (X <= 799) {
    rank = 7;
  }
  else if (X <= 999) {
    rank = 6;
  }
  else if (X <= 1199) {
    rank = 5;
  }
  else if (X <= 1399) {
    rank = 4;
  }
  else if (X <= 1599) {
    rank = 3;
  }
  else if (X <= 1799) {
    rank = 2;
  }
  else if (X <= 1999) {
    rank = 1;
  }

  cout << rank << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    double r = (c* pi) / 180;
    cout << fixed << setprecision(15);
    cout << (double)(a*b*sin(r)/2) << endl;
    cout << (double)(a+b+sqrt(a*a+b*b-2*a*b*cos(r))) << endl;
    cout << (double)(b*sin(r)) << endl;
}


Measured memory_bytes: 3612
import java.util.*

fun main(args: Array<String>) {
    val s = Scanner(System.`in`)
    val a = s.nextLong()
    val b = s.nextLong()


    fun xors(v: Long): Long {
        var d = 0L
        (1..50).forEach { i ->
            val t = 1L shl i
            val mod = v % t
            val count = Math.max(mod - t / 2 + 1, 0) + (if (i == 1) v / t else 0)
            val b = if (count % 2L == 0L) 0L else 1L

            d = d or (b shl (i - 1))
        }
        return d
    }

    val ret = xors(b) xor xors(Math.max(a - 1, 0))
    println(ret)
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int A,B,result;
  result =0;

  for(int i=0;i<N;i++){
    int xi;
    cin >> xi;
    A = 2*xi;
    B = 2*(K-xi);
    if(A<=B){
      result +=A;
    }else{
      result +=B;
    }
  }
  cout << result << endl;
}


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

vector<pair<int,int> > Edge;
int main()
{
    int i,j,n,k,maxl;
	scanf("%d%d",&n,&k);
    for(i = 2;i <= n;i++)
    	Edge.push_back(make_pair(1,i));
	maxl = (n - 1) * (n - 2) / 2;
	if(k > maxl)
	{
		printf("-1");
		return 0;
	}
	while(maxl > k)	
	{
		for(i = 2;i <= n;i++)
		{
			for(j = i + 1;j <= n;j++)
			{
				maxl--;
				Edge.push_back(make_pair(i,j));
				if(maxl == k) break;
			}
			if(maxl == k) break;
		}
	}
	printf("%d",int(Edge.size()));
	for(unsigned int i = 0;i < Edge.size();i++)
		printf("\n%d %d",Edge[i].first,Edge[i].second);
    return 0;
}

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

int main() {
  int x, y, s;
  int nd[] = {5, 9, 13};
  int smallX[] = {0, -1, 0, 1, 0};
  int smallY[] = {-1, 0, 0, 0, 1};
  int mediumX[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
  int mediumY[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
  int largeX[] = {0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0};
  int largeY[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  int *dropX[3] = {smallX, mediumX, largeX};
  int *dropY[3] = {smallY, mediumY, largeY};
  int paper[10][10];
  int dx, dy;
  int count;
  int max;

  for (int i=0; i<10; i++) {
    for (int j=0; j<10; j++) {
      paper[i][j] = 0;
    }
  }

  while (scanf("%d,%d,%d", &x, &y, &s) == 3) {
    --s;
    for (int i=0; i<nd[s]; i++) {
      dx = x + dropX[s][i];
      dy = y + dropY[s][i];
      if (dx>=0 && dx<10 && dy>=0 && dy<10) ++paper[dx][dy];
    }
  }

  count = 0;
  max = 0;
  for (int i=0; i<10; i++) {
    for (int j=0; j<10; j++) {
      if (!paper[i][j]) count++;
      if (paper[i][j] > max) max = paper[i][j];
    }
  }
  printf("%d\n", count);
  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int>v1,v2;
    for(int i=0; i<n; i++)
    {
        int u,v;
        cin >> u >> v;
        v1.push_back(u+v);
        v2.push_back(u-v);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    n = v2.size()-1;
    cout << max(v1[n]-v1[0],v2[n]-v2[0]) << endl;
}


Measured memory_bytes: 5092
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    v = 0
    tot = sum(A)
    min_d = float('inf')
    for i in range(N-1):
        v += A[i]
        min_d = min(min_d, abs(tot - 2*v))

    return min_d

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 23800
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1e5 + 100, MODD = 1e9 + 7;
 
int dp[N], par_sum[N];
 
int main() {
	int n, k, a;
	cin >> n >> k;
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= k; ++j) {
                        par_sum[j + 1] = par_sum[j] + dp[j];
                        par_sum[j + 1] %= MODD;
                }
		cin >> a;
		for (int j = 0; j <= k; ++j) {
			dp[j] = par_sum[j + 1];
			if (j - a >= 1)
				dp[j] -= par_sum[j - a];
			if (dp[j] < 0)
				dp[j] += MODD;
		}
	}
	cout << dp[k] << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, X; cin >> N >> M >> X;
  int C[N], A[N][M];
  for(int i = 0; i < N; i++){
    cin >> C[i];
    for(int j = 0; j < M; j++) cin >> A[i][j];
  }
  int all = pow(2, N), ans = 10000000, tot_cost;
  int temp[M];
  bool ok;
  for(int dp = 0; dp < all; dp++){
    for(int i = 0; i < M; i++) temp[i] = 0;
    tot_cost = 0;
    for(int i = 0; i < N; i++){
      if((dp >> i) & 1){
        for(int j = 0; j < M; j++) temp[j] += A[i][j];
        tot_cost += C[i];
      }
    }
    ok = true;
    for(int j = 0; j < M; j++){
      if(temp[j] < X){
        ok = false;
        break;
      }
    }
    if(ok) ans = min(ans, tot_cost);
  }
  if(ans == 10000000) cout << "-1";
  else cout << ans;
  return 0;
}

Measured memory_bytes: 4028
import java.util.*;

public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long m1 = sc.nextInt();
		long d1 = sc.nextInt();
		long m2 = sc.nextInt();
		long d2 = sc.nextInt();
      	if (m1==m2) System.out.println("0");
      	else System.out.println("1");
    }
}

Measured memory_bytes: 20820
//13_B ８パズル問題  8 Puzzle

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

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

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

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

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

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

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

  return "unsolvable";
}

int main(){
  Puzzle in;

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



Measured memory_bytes: 30676
#include <stdio.h>

void PrintRectangle(int H,int W){
	int h,w;
	for(h=0;h<H;h++){
		for(w=0;w<W;w++){
			printf("#");
		}
		printf("\n");
	}
}
		
int main(void)
{
	while(1){
		int H,W,h,w;
		scanf("%d %d",&H,&W);
		if (H==0 && W==0)
			break;
		PrintRectangle(H,W);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.printf("%d %d %f\n", a / b, a % b, (double) a / (double) b);
        }
    }
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long result = inputLongArray[0];
            long count = 0;
            while(result > 0)
            {
                result -= inputLongArray[1];
                count++;
            }
            Console.WriteLine(count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k,m,n;cin>>a>>b>>c>>k;
  m=max(a,b);
  m=max(m,c);
  n=m;
  for(int i=0;i<k;i++)n*=2;
  cout<<a+b+c-m+n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N,H;

int main(){
    cin >> N >> H;
    vector<ll> a(N),b(N);
    vector<pair<ll,int>> v;
    rep(i,N){
        cin >> a[i] >> b[i];
        v.push_back(make_pair(a[i],1));
        v.push_back(make_pair(b[i],0));
    }
    sort(all(v));
    reverse(all(v));
    ll sum = 0;
    int idx = 0;
    rep(i,v.size()){
        if(sum >= H){
            cout << i << endl;
            return 0;
        }
        if(v[i].se == 1){
            idx = i;
            break;
        }
        sum += v[i].fi;
    }


    int ans = idx;
    ll rem = H - sum;
    ans += (rem + v[idx].fi - 1) / v[idx].fi;
    cout << ans << endl;
}


Measured memory_bytes: 7792
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <cctype>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef string::const_iterator State;
int q;
string str;

P expression(State &begin,int l,int r);
P term(State &begin,int l,int r);

P term(State &begin,int l,int r){
	if(isdigit(*begin)){
		if(*begin=='0'){
			begin++;
			return P(0,begin-str.begin()-1);
		}
		P ret=P(-2,0);
		if(*begin-'0'>r){
			ret=P(r+1,begin-str.begin());
		}
		if((l>(*begin-'0')*10+9)){
			ret=P(l-1,begin-str.begin());
		}
		int v=0;
		while(isdigit(*begin)){
			v*=10;
			v+=*begin-'0';
			begin++;
		}
		if(ret.first==-2){
			if(v>=10)ret=P(v,begin-str.begin()-1);
			else ret=P(v,begin-str.begin());
		}
		return ret;
	}else{
		return expression(begin,l,r);
	}
}

P expression(State &begin,int l,int r){
	if(isdigit(*begin))return term(begin,l,r);
	int z=0;
	if(*begin=='^')z=1;
	begin+=2;
	P tmp=term(begin,l,r);
	P ret=P(-2,-2);
	if(z==0 && tmp.first==0)ret=tmp;
	if(z==1 && tmp.first==99)ret=tmp;
	if(tmp.first!=-1 && z==0 && l>tmp.first)ret=tmp;
	if(tmp.first!=-1 && z==1 && r<tmp.first)ret=tmp;
	begin++;
	int L=l;
	int R=r;
	if(z==0){
		if(tmp.first!=-1)R=min(R,tmp.first-1);
	}else{
		if(tmp.first!=-1)L=max(L,tmp.first+1);
	}
	P tmp2=term(begin,L,R);
	if(tmp.first==-1 && z==0)tmp.first=110;
	if(tmp2.first==-1 && z==0)tmp2.first=110;
	if(ret.first==-2){
		if(z==0)ret.first=min(tmp.first,tmp2.first);
		else ret.first=max(tmp.first,tmp2.first);
		ret.second=tmp2.second;
	}
	begin++;
	return ret;
}

int main(void){
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		cin >> str;
		State begin=str.begin();
		P res=expression(begin,0,99);
		printf("%d %d\n",res.first,res.second+1);
	}
	return 0;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
vector<int> g[100005];
int col[100005];

bool mark[100005];


int dfs(int v,int p){
  int res=col[v];
  for(auto to:g[v]){
    if(to==p) continue;
    res+=dfs(to,v);
  }
  mark[v]=(res>0);
  return res;
}
int sign[100005];


int ans;
int dfs2(int v,int p){
  int res=0;
  for(auto to:g[v]) if(to!=p && mark[to]){
    int nxt=dfs2(to,v);
    chmax(ans,nxt+res+sign[v]);
    chmax(res,nxt);
  }
  res+=sign[v];
  return res;
}
int main(){
  cin>>n;
  REP(i,n-1){
    int a,b;cin>>a>>b;--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  char tmp[100005];
  scanf("%s",tmp);
  REP(i,n) col[i]=(tmp[i]=='W'?1:0);
  int R=-1;
  REP(i,n) if(col[i]) R=i;
  debug(col,col+n);
  dump(R);
  if(R==-1){
    puts("0");
    return 0;
  }
  dfs(R,-1);

  int tot=0;
  int add=0;
  REP(i,n) if(mark[i]){
    sign[i]=col[i];
    for(auto to:g[i]) if(mark[to]) sign[i]^=1,++tot;
    if(sign[i]) ++add;
  }
  debug(mark,mark+n);
  debug(sign,sign+n);

  dfs2(R,-1);
  dump(tot);dump(ans);dump(add);

  cout<<tot-ans*2+add<<endl;
  return 0;
}





Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
vector<int> weight;
vector<int> value;
long long ans[101][100001];
int main(){
	int N, W, w, v;
	cin>>N>>W;
	weight.resize(N + 1, 0);
	value.resize(N + 1, 0);
	for(int i = 0; i < N; ++i){
		cin>>w>>v;
		weight[i] = w;
		value[i] = v;
	}
	for(int i = 0; i <= N; ++i){
		for(int j = 0; j <= W; ++j){
			if(i == 0 || j == 0){
				ans[i][j] = 0;
			}
			else if(weight[i - 1] <= j){
				ans[i][j] = max(value[i - 1] + ans[i - 1][j - weight[i - 1]], ans[i - 1][j]);
			}
			else{
				ans[i][j] = ans[i - 1][j];
			}
		}
	}
	cout<<ans[N][W]<<endl;
	return 0;
}


Measured memory_bytes: 79104
import math
# input
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

sum_push = 0

for i in range(N):
    A = AB[N - 1 - i][0]
    B = AB[N - 1 - i][1]
    push_i = math.ceil((A + sum_push)/B) * B - A - sum_push
    sum_push += push_i

print(sum_push)

    

Measured memory_bytes: 27380
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_A
 * 
 * @author chrone
 * 
 */
public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            while ((sStr = stdReader.readLine()) != null) {
                String[] inputs = sStr.split(" ");
                
                int m = Integer.valueOf(inputs[0]);
                int f   = Integer.valueOf(inputs[1]);
                int r   = Integer.valueOf(inputs[2]);
                
                if (m == -1 && f == -1 && r == -1) {
                    break;
                    // nothing to do.
                }
                
                if (m==-1 || f == -1 || (m+f <30)) {
                    // F
                    System.out.print("F");
                } else if ( m+f >= 80) {
                    // A
                    System.out.print("A");
                } else if  (m+f < 80 && m+f >=65) {
                    // B
                    System.out.print("B");
                } else if ( (m+f >=50 && m+f < 65) || r>=50) {
                    // C
                    System.out.print("C");
                } else if (m+f>=30 && m+f<50) {
                    // D
                    System.out.print("D");
                } else if (m+f<30) {
                    // F
                    System.out.print("F");
                }
                System.out.println();
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 24032
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
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;}
 
ll int data[100000];
int main(){
  int n;
  cin >> n;
  REP(i, n){
    cin >> data[i];
  }
  bool flag = true;
  for(int i = n - 1; i >= 1; i--){
    if(data[i] < data[i - 1]){
      if(data[i - 1] - data[i] > 2) flag = false;
      else if(data[i - 1] - data[i] == 1){
        data[i - 1]--;
      }else{
        flag = false;
      }
    }
  }

  cout << (flag ? "Yes" : "No") << endl;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int p1 = N * A;
  if (p1 <= B) {
    cout << p1 << endl;
  }
  else{
   cout << B << endl;
  }
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();

    if n == 1 {
        println!("Hello World");
    } else {
        let a: i32 = read();
        let b: i32 = read();
        println!("{}", a + b);
    }
}

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}

int main() {
  int x,a; cin>>x>>a;
  if (x<a) cout<<0<<endl;
  else cout<<10<<endl;
}

Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;
 
int n ,res;

int main(){FAST;    
    cin >> n;
    res = n;
    forp(i ,0 ,n + 1){
        int t = i ,cc = 0;
        while(t > 0)cc += t%6 ,t = t/6;
        t = n - i;
        while(t > 0)cc += t%9 ,t /= 9;
        res = min(res ,cc);
        
    }
    out(res);
}
 










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

int main() {
    string s,t,u;
    cin >> s >> t >> u;
    char c, d, e;
    c = s[0];
    d = t[0];
    e = u[0];
    c += 'A'-'a';
    d += 'A'-'a';
    e += 'A'-'a';
    cout << c << d << e << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0, sum = 0;
	//答え、今までに使った総和（一個前の値と等しい）
	for (int i = 0; i < n; i++) {
		if ((a[i] - sum) % 2 != 0) {
			ans ^= (n - i);
		}
	}
	if (ans == 0) {
		cout << "second\n";
	}
	else {
		cout << "first\n";
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  int n;
  
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int idx = 0;
  int cnt = 0;
  while(a[idx] != -1){
    if(a[idx] == 2)break;
    int pas = idx;
    idx = a[idx] - 1;
    a[pas] = -1;
    cnt ++;
  }
  cout<<(a[idx] == -1?-1:++cnt)<<endl;
}

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

#define ll long long
#define mod ((ll)(1e9 + 7LL))

ll pow10[1000001],pow9[1000001],pow8[1000001];

int main(){
	ll n;
	cin >> n;
	pow10[0] = pow9[0] = pow8[0]=  1LL;
	for(int i = 1;i < 1000001;i++){
		pow10[i] = (pow10[i-1]*10LL) % mod;
		pow9[i] = (pow9[i-1]*9LL) % mod;
		pow8[i] = (pow8[i-1]*8LL) % mod;
	}
	ll ans = (pow10[n] - (pow9[n] + pow9[n] - pow8[n] + mod)%mod + mod)%mod;
	cout<<ans<<"\n";
}

Measured memory_bytes: 27004
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

p = []
for i in range(x):
  if i <= k:
    for j in range(y):
      if (i+1) * (j+1) <= k:
        for l in range(z):
          if (i+1) * (j+1) * (l+1) <= k:
            p.append(a[i]+b[j]+c[l])
          else:
            break
      else:
        break
  else:
    break

p.sort(reverse=True)

for i in range(k):
  print(p[i])

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

using namespace std;

int main(){
    long long int N,L,ok=-1;
    cin >> N >> L;
    vector<long long int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(L<=a[i]){
            ok = i;
        }
    }

    for(int i=1;i<N;i++){
        if(L<=a[i-1]+a[i]){
            ok = i-1;
            break;
        }
    }

    if(ok==-1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;

        for(int i=0;i<ok;i++){
            cout << i+1 << endl;
        }

        for(int i=N-1;ok<i;i--){
            cout << i << endl;
        }
    }
}

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

typedef complex<double> P;
const double EPS = 1e-9;


struct Circle{
  P p;
  double r;
  int c;
  bool upper(const Circle &e){
    double b = abs( p - e.p );
    if( b < r + e.r - EPS ) return true;
    return false;
  }

};

int N;
Circle c[25];
bool dp[(1<<24)];



int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      int x,y,r,s;
      cin >> x >> y >> r >> s;
      c[i] = (Circle){P(x,y),r,s};
    }
    memset(dp,0,sizeof(dp));
    dp[0] = true;
    int res = 0;
    for(int i=0;i<(1<<N);i++){
      int bf[25]={};
      if( !dp[i] ) continue;
      res = max( res, __builtin_popcount(i) );
      // cout << bitset<16>(i) << endl;
      for(int j=0;j<N;j++){
        if( i & (1<<j) ) {
          bf[j] = true; continue;
        }
        for(int k=0;k<j;k++){
          if( !(i&(1<<k)) && c[j].upper(c[k]) ){
            bf[j] = true; break;
          }
        }
        //  cout << bf[j] << endl;
      }
      for(int j=0;j<N;j++){
        if( bf[j] ) continue;
        for(int k=j+1;k<N;k++){
          if( bf[k] ) continue;
          if(c[j].c == c[k].c)
            dp[i|(1<<j)|(1<<k)] = true; 
        }
      }
    }
    cout << res << endl;
  }
}

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

public class Main {

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

  public void run(){

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int k = Integer.parseInt(lines[1]);

      long ans;
      if((k & 1) == 0) {
        long a = n / k;
        long b = n / (k / 2);
        long c = b - a;
        ans = (a * a * a) + (c * c * c);
      } else {
        long a = n / k;
        ans = a * a * a;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

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

	int N,K;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> N >> K;

	while(N!=0){
		N/=K;
		counter++;
	}
	
	answer=counter;
	cout << answer << endl;

	return 0;
}



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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> L(87);

    L.at(0) = 2;
    L.at(1) = 1;

    
    for(int i = 2; i <= n; i++){
        L.at(i) = L.at(i-2) + L.at(i-1);
        
    }
    cout << L.at(n) << endl;
}

Measured memory_bytes: 256
n=[]
while (a=gets)!=nil
n<< a.split.map(&:to_i)
end
n.each{|i|
exit if i[0]==i[1]&&i[0]==0
Array.new(i[0]).map{Array.new(i[1],"#")}.each{|e|puts e.join}
puts
}


Measured memory_bytes: 7344
#include <assert.h>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

/// 集合xsの濃度がcardinalityなら真を返す。
template<typename T>
bool set_is_cardinality(set<T> xs, size_t cardinality) {
  return xs.size() == cardinality;
}

/// setに変換して返す。
template<typename T>
set<T> vector_get_set(vector<T> xs) {
  return set<int>(xs.begin(), xs.end());
}

/// bが真なら"Yes"を返す。そうでなければ"No"を返す。
string get_yes_or_no(bool b) {
  return b ? "Yes" : "No";
}

/// xsがかわいそうなら真を返す。
bool get_is_poor(vector<int> xs) {
  /// 要素数が3でない場合については、かわいそうかどうかが定義されていない。
  assert(xs.size() == 3);
  auto xs1 = vector_get_set(xs);
  auto is_poor = set_is_cardinality(xs1, 2);
  return is_poor;
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  auto xs = vector<int>({A, B, C});
  bool is_poor = get_is_poor(xs);
  auto s = get_yes_or_no(is_poor);
  cout << s << endl;
}

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

bool check(vector<int> A){
  if(A.at(0)==-1 && A.at(1)==-1 && A.at(2)==-1) return true;
  if(A.at(3)==-1 && A.at(4)==-1 && A.at(5)==-1) return true;
  if(A.at(6)==-1 && A.at(7)==-1 && A.at(8)==-1) return true;
  if(A.at(0)==-1 && A.at(3)==-1 && A.at(6)==-1) return true;
  if(A.at(1)==-1 && A.at(4)==-1 && A.at(7)==-1) return true;
  if(A.at(2)==-1 && A.at(5)==-1 && A.at(8)==-1) return true;
  if(A.at(0)==-1 && A.at(4)==-1 && A.at(8)==-1) return true;
  if(A.at(2)==-1 && A.at(4)==-1 && A.at(6)==-1) return true;
  
  return false;
}

int main() {
  vector<int> A(9);
  rep(i, 9) cin >> A.at(i);
  int N;
  cin >> N;
  rep(i, N){
    int x;
    cin >> x;
   rep(i, 9) if(A.at(i) == x) A.at(i)=-1;
  }
  if(check(A)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3604
import java.util.Scanner;

// https://atcoder.jp/contests/abc163/tasks/abc163_a
public class Main {

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

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

		double ans = 2*n*Math.PI;

		System.out.println(ans);
	}
}


Measured memory_bytes: 27100
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

#define INF 1000000

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> G[3 * N];

    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        for(int j = 0; j<3; j++){
            G[3 * a + j].emplace_back(3 * b + (j + 1) %3);
        }
    }

    int s, t;
    cin >> s >> t;
    s--; t--;

    int d[3 * N];
    bool used[3 * N];
    for(int i=0; i<3 * N; i++){
        d[i] = INF;
        used[i] = false;
    }
    d[3 * s] = 0;
    
    queue<int> q;
    q.push(s * 3);
    
    while(!q.empty()){
        int v = q.front(); q.pop();
        int dist = d[v];
        for(int id : G[v]){
            if(!used[id]){
                used[id] = true;
                d[id] = dist + 1;
                q.push(id);
            }
        }
    }

    if(d[3 * t] == INF) cout << -1 << endl;
    else cout << d[3 * t] /3 << endl;

    return 0;

}

Measured memory_bytes: 18176
#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;

int lbound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] >= b){
			e = m;
		}
		else{
			s = m;
		}
	}
	if(v[max(s - 1, 0)] >= b) return max(s - 1, 0);
	else if(v[s] >= b) return s;
	else if(v[min(s + 1, l - 1)] >= b) return min(s + 1, l - 1);
	else return -1;
}

int ubound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] <= b){
			s = m;
		}
		else{
			e = m;
		}
	}
	if(v[max(s - 1, 0)] > b) return max(s - 1, 0);
	else if(v[s] > b) return s;
	else if(v[min(s + 1, l - 1)] > b) return min(s + 1, l - 1);
	else return -1;
}

long long N, M;

vector<pair<long long, long long>> V; // (金額,　日数)
map<long long, vector<long long>> MP;  //(日数, vector<金額>)
vector<long long> D; //vector<distinct(日数)>
map<long long, int> MONEY; //ワーク用、金額を入れていく。

long long getMaxMoney(){
	long long ret = 0;
	long long m;
	int d;
	if(MONEY.size() == 0){
		return 0;
	}
	for(auto itr = MONEY.crbegin(); itr != MONEY.crend(); itr++){
		m = itr->first;
		d = itr->second;
		if(d == 0){
			continue;
		}
		if(d > 0){
			ret = m;
			MONEY[m]--;
			if(MONEY[m] == 0){
				MONEY.erase(MONEY.find(m));
			}
		}
		break;
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M ;
	for(int i=0; i<N; i++){
		long long a, b;
		cin >> a >> b; //日数, 金額
		pair<long long, long long> p = make_pair(b, a);
		V.push_back(p);
	}
	sort(V.begin(), V.end());

	for(int i=0; i<N; i++){
		pair<long long, long long> p = V[i];
		long long m = p.first;
		long long d = p.second;
		MP[d].push_back(m);
	}

	for(auto itr = MP.begin(); itr !=MP.end(); itr++){
		long long d = itr->first;
		D.push_back(d);
	}

	long long ans = 0;
	int dp[100002] = {0};
	for(int i=1; i<=M; i++){
		long long d = ubound(D, i);
		if(d == 0) continue;
		if(d < 0){
			d = D.size();
		}

		vector<long long> &v = MP[D[d - 1]];
		if(dp[D[d - 1]] == 0){
			for(int j=0; j<v.size(); j++){
				long long w = v[j];
				if(MONEY.count(w)==0){
					MONEY[w] = 1;
				}
				else{
					MONEY[w]++;
				}
			}
		}
		ans += getMaxMoney();
		dp[D[d - 1]] = 1;
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int main(){
  vvl t(1,vl(3));
  rep(i,3) cin >> t[0][i];

  int i = 0;
  int ans = 0;
  while(true){
    bool conti = true;
    rep(j,3){
      if(t[i][j]%2 == 1LL) conti = false;
    }
    if(!conti) break;
    ans++;

    vl tmp(3);
    tmp[0] = (t[i][1] + t[i][2])/2LL;
    tmp[1] = (t[i][2] + t[i][0])/2LL;
    tmp[2] = (t[i][0] + t[i][1])/2LL;
    //rep(j,3) cout << tmp[j] << " ";
    //cout << endl;
    t.pb(tmp);

    if(t[i] == t[i+1]){
      ans = -1;
      break;
    }
    i++;
  }

  cout << ans << endl;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int h = nextInt(), n = nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }

        int sum = Arrays.stream(a).sum();
        System.out.println(sum >= h ? "Yes" : "No");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 33880
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
using namespace std;
typedef long long ll;
const int N = 262200;
const ll INF = 1e18;

int A[N];
pair<int, int> dp[N];

void update(pair<int,int> &A, int x) {
	if(x > A.second) {
		A.second = x;
		if(A.second > A.first) {
			swap(A.second, A.first);
		}
	}
}
int main() {
	int n;
	while(~scanf("%d", &n)) {
		int nLen = (1<<n) - 1;
	
		for(int i = 0; i <= nLen; ++i) {
			scanf("%d", &A[i]);
			dp[i] = make_pair(A[i], -1);
		}

		for(int i = 0; i < n; ++i) {
			for(int j = 0; j <= nLen; ++j) {
				if( ((j >> i) & 1) == 0 ) {
					int newI = j | (1 << i);
					int t1 = dp[j].first;
					int t2 = dp[j].second;
					update(dp[newI], t1);
					update(dp[newI], t2);
				}
			}
		}

	//	for(int i = 0; i <= nLen; ++i) printf("%d %d\n", dp[i].first, dp[i].second);
		int ans = -1;
		for(int i = 1; i <= nLen; ++i) {
			ans = max(ans, dp[i].first + dp[i].second);
			printf("%d\n", ans);
		} 
	}
	return 0;
}

Measured memory_bytes: 6144