akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int l[200010];
int r[200010];
int t[4 * 200010];
int p[4 * 200010];
int N, M;
vector <int> start[200010];
const int inf = 1e9;

void pushdown(int c) {
	int l = c << 1;
	int r = l + 1;
	t[l] += p[c];
	p[l] += p[c];
	t[r] += p[c];
	p[r] += p[c];
	p[c] = 0;
}
void update(int x, int y, int add, int c = 1, int b = 0, int e = M+1) {
	if(x <= b && e <= y) {
		t[c] += add;
		p[c] += add;
		return ;
	}
	if(y < b || e < x) return ;
	pushdown(c);
	int m = (b + e) >> 1;
	int l = c << 1;
	int r = l + 1;
	update(x, y, add, l, b, m);
	update(x, y, add, r, m+1, e);
	t[c] = max(t[l], t[r]);
}
int query(int x, int y, int c = 1, int b = 0, int e = M+1) {
	if(x <= b && e <= y) {
		return t[c];
	}
	if(y < b || e < x) return -inf;
	pushdown(c);
	int l = c << 1;
	int r = l + 1;
	int m = (b + e) >> 1;
	return max(query(x, y, l, b, m), query(x, y, r, m+1, e));
}

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

	cin >> N >> M;	
	for(int i = 1; i <= N; i++) {
		cin >> l[i] >> r[i];
		start[l[i]].push_back(r[i]);
	}
	for(int i = 0; i <= M+1; i++) {
		update(i, i, -(M - i + 1));
	}
	int ans;
	int mx = INT_MIN, mn = INT_MAX;
	for(int i = 1; i <= N; i++) {
		mx = max(mx, l[i]);
		mn = min(mn, r[i]);
	}
	if(mx < mn) {
		ans = N - (mx + (M - mn + 1));
	} else {
		ans = N - M;
	}
	for(int i = 0; i <= M; i++) {
		for(auto j : start[i]) {
			update(0, j, 1);
		}
		ans = max(ans, query(i + 1, M + 1) - i);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 16384
#include <iostream>
using namespace std;
typedef long long ll;
ll N, T, c, t, ans;
const ll INF = 1000000000000;
int main(void){
    // Your code here!
    ans = INF;
    cin >> N >> T;
    for (ll i = 0; i < N; i++){
        cin >> c >> t;
        if (t <= T){
            ans = min(ans, c);
        }
    }
    if (ans == INF){
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)


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

int main() {
  int D, N;
  cin >> D >> N;
  int ans = 1;
  for (int i = 0; i < D; i++) ans *= 100;
  int copy_ans = ans;
  ans *= N;
  if (N == 100) ans += copy_ans;
  cout << ans << endl;
}


Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n) { cin >> a[i] >> b[i]; }
    ll index[n];
    iota(index, index + n, 0);
    sort(index, index + n, [&](ll i, ll j) { return b[i] < b[j]; });

    ll time = 0;
    bool judge = true;
    rep(i, n) {
        ll num = index[i];
        time += a[num];
        if (time > b[num]) {
            judge = false;
        }
    }
    if (judge) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n;
		cin >> n;
	vector<int> V;
	V.push_back(n);
	int ans=0;
	int c=0;
	while(1){
		c++;
		int l=(n%2?3*n+1:n/2);
		for(int i=0;i<V.size();i++){
			if(l==V[i]){
				ans=c+1;
				break;
			}
		}
		if(ans)
			break;
		V.push_back(l);
		n=l;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline




def solve():
    def normalize(v,basis):
        for b in basis:
            if v > v^b: v ^= b
        return v
    
    n, = map(int,readline().split())
    *a, = map(int,readline().split())
    s = input()
    
    basis = []
    b0 = []

    for e,si in zip(a[::-1],s[::-1]):
        if si=="0":
        	for b in basis:
        	    if e > e^b: e ^= b
        	if e: basis.append(e)

        if si=="1":
            v = normalize(e,basis)
            if v!=0:
                print(1)
                return

    
    print(0)
    return
        
        


t = int(input())
for _ in range(t):
    solve()











Measured memory_bytes: 68616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int A, B, C; cin >> A >> B >> C;
    if (A <= C and C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import math
import itertools

def distance(a, b):
    return math.sqrt((b[0] - a[0])**2 + (b[1] - a[1])**2)

def average(a):
    return (sum(a) / len(a))

N = int(input())
S = [list(map(int, input().split())) for i in range(N)]
l = list(itertools.permutations([i for i in range(N)]))

dist_list = []

for i in l:
    dist = 0
    for j in range(N - 1):
        dist += distance(S[i[j]], S[i[j+1]])
    dist_list.append(dist)

# print(dist_list)
print(average(dist_list))

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

int main(int argc, char **argv)
{
    char s[200001];
    scanf("%s", s);

    int ap;
    int zp;
    int len = strlen(s);
    for (int i = 0; i < len; ++i) {
        if (s[i] == 'A') {
            ap = i;
            break;
        }
    }
    for (int i = len-1; i >= 0; --i) {
        if (s[i] == 'Z') {
            zp = i;
            break;
        }
    }
    printf("%d\n", (zp-ap+1));
    return 0;
}

Measured memory_bytes: 384
import Data.List

main = do
  (h:w:_) <- getLine >>= return . map read . words :: IO [Int]
  s <- getContents >>= return . lines :: IO [String]

  let
    vrt = map (\x -> f ('.' : x ++ ".")) s
    hrz = transpose $ map (\x -> f ('.' : x ++ ".")) (transpose s)

  putStrLn $ if elem 2 $ concat (zipWith (zipWith (+)) vrt hrz) then "No" else "Yes"
  
  where
    f (_:_:[]) = []
    f (x:y:z:xs) = (if y=='#' then length $ filter (=='#') [x,y,z] else 0) : (f (y:z:xs))



Measured memory_bytes: 1020
str = input()
if str == 'SUN':
  print (7)
elif str == 'MON':
    print (6)
elif str == 'TUE':
    print (5)
elif str == 'WED':
    print (4)
elif str == 'THU':
    print (3)
elif str == 'FRI':
    print (2)
else:
  	print (1)
  

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

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

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;




class UnionFind{
public:
    int uf[200005];
    UnionFind(){
        memset(uf,-1,sizeof uf);
    }
    
    int parent(int i){
        if (uf[i] < 0) return i;
        return uf[i] = parent(uf[i]);
    }
    
    void join(int i, int j){
        int pi = parent(i);
        int pj = parent(j);
        if (pi == pj) return;
        if (size(pi) < size(pj)) swap(pi,pj);
        uf[pi] += uf[pj];
        uf[pj] = pi;
        
    }
    
    int size(int i){
        int pi = parent(i);
        return abs(uf[pi]);
    }
    
    void init(){
        memset(uf,-1,sizeof uf);
    }
};





void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int primes[1000000] = {};
    
    
    bool dame = false;
    
    for(int ii = 0; ii < n; ii++){
        
        int v = a[ii];
        //if (v==1) dame = true;
        
        bool ok = false;
        while (v && v%2 == 0){
            v/=2;
            ok = true;
        }
        if (ok){
            if (primes[2] == 1) dame = true;
            else primes[2] = 1;
        }
        
        for (int i = 3; i <= sqrt(v); i = i+2){
            ok = false;
            while (v && v%i == 0){
                ok = true;
                v = v/i;
            }
            if (ok){
                if (primes[i] == 1) dame = true;
                else primes[i] = 1;
            }
        }
        
        if (v > 2){
            if (primes[v] == 1) dame = true;
            else primes[v] = 1;
        }
    }
    
    
    if (dame == 0){
        cout << "pairwise coprime"; return;
    } 
    else{
        int ap = gcd(a[0],a[1]);
        for(int i = 2; i < n;i++){
            ap = gcd(ap,a[i]);
        }
        if (ap==1){
            cout << "setwise coprime";
        }
        else cout << "not coprime";
        
    }
    

        
};



int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 11168
n = int(input())
X = []
for _ in range(n):
    x, l = map(int, input().split())
    X.append((x - l, x + l))

count = 0
current = -1 * float('inf')
for x in sorted(X, key=lambda x: x[1]):
    if x[0] >= current:
        count += 1
        current = x[1]
print(count)

Measured memory_bytes: 19044
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N, D;
	int X[10][10];
	cin >> N >> D;
	for(int i=0; i<N; i++){
		for(int j=0; j<D; j++) cin >> X[i][j];
	}
	
	set<int> st;
	for(int i=0; i<=10000; i++){
		st.insert(i*i);
	}
	
	int ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			int tmp = 0;
			for(int k=0; k<D; k++){
				tmp += (X[i][k]-X[j][k])* (X[i][k]-X[j][k]);
			}
			if(st.count(tmp) == 1) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

ll n, m;

bool check(ll mid){
    if(max(ll(0), mid - n) * 2 + mid * 2 <= m){
        return true;
    }else{
        return false;
    }
}

int main(void){
    cin >> n >> m;

    ll s = -1;
    ll e = 100000000000000;
    while(e - s != 1){
        ll mid = (e + s) / 2;
        if(check(mid)){
            s = mid;
        }else{
            e = mid;
        }
    }
    cout << s << endl;
}


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

using namespace std;

template< typename T >
struct PairingHeap
{
  struct Node
  {
    T key;
    Node *head, *next;
  } *root = nullptr;
  bool rev;

  PairingHeap(bool rev = false) : rev(rev) {}

  Node *merge(Node *x, Node *y)
  {
    if(!x || !y) return x ? x : y;
    if((x->key > y->key) ^ rev) swap(x, y);
    y->next = x->head;
    x->head = y;
    return x;
  }

  Node *push(const T &key)
  {
    auto t = new Node({key, nullptr, nullptr});
    root = merge(root, t);
  }

  T top()
  {
    return root->key;
  }

  Node *_pop(Node *s)
  {
    Node *p = nullptr;
    while(s) {
      Node *a = s, *b = nullptr;
      s = s->next;
      a->next = nullptr;
      if(s) {
        b = s;
        s = s->next;
        b->next = nullptr;
      }
      a = merge(a, b);
      a->next = p;
      p = a;
    }
    while(p) {
      Node *j = p;
      p = p->next;
      s = merge(j, s);
    }
    return s;
  }

  void pop()
  {
    auto *temp = root;
    root = _pop(root->head);
  }

  bool empty() const
  {
    return !root;
  }

  void merge(PairingHeap< T > &p)
  {
    root = merge(root, p.root);
  }
};

using int64 = long long;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};


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

  vector< PairingHeap< int64 > > heap(n);
  for(int i = 0; i < n; i++) {
    heap[i].push(a[i]);
  }

  UnionFind uf(n);
  for(int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x = uf.find(x);
    y = uf.find(y);
    uf.unite(x, y);
    if(uf.find(x) != x) swap(x, y);
    heap[x].merge(heap[y]);
  }
  if(m == n - 1) {
    cout << 0 << endl;
    return 0;
  }

  PairingHeap< int64 > base;
  int64 ans = 0, cnt = 0;
  for(int i = 0; i < n; i++) {
    if(uf.find(i) == i) {
      ans += heap[i].top();
      heap[i].pop();
      base.merge(heap[i]);
      cnt++;
    }
  }

  while(m * 2 + cnt < (n - 1) * 2) {
    if(base.empty()) {
      cout << "Impossible" << endl;
      return 0;
    }
    ans += base.top();
    base.pop();
    cnt++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 5760
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", a * a - b);
	
	Please AC;
}


Measured memory_bytes: 888
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [f64; n],
    }
    let mut l = 0.0;
    let mut r = 100000000000.0 as f64;
    while r - l > 0.00001 {
        let m = (l + r) / 2.;
        let mut count = 0;
        for i in 0..n {
            count += (a[i] / m) as usize;
        }
        if count <= k {
            r = m;
        } else {
            l = m;
        }
    }
    eprintln!("{} {}", l, r);
    println!("{}", (l + 0.5).round());
}


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

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int S[N+100]={0};
  
  for(int i=N;i>0;--i){
    int j=i;
    while(j>0){
      S[i]=S[i]+j%10;
      j=j/10;
    }
  }
  int sum=0;
  for(int i=1;i<N+1;i++){
    if((S[i]>=A)&&(S[i]<=B)){
      sum=sum+i;
    }
  }
  cout<<sum<<endl;
  return 0;
}



  

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0;
  for(int i=min(A, B); i>0; i--) {
    if(A % i == 0 && B % i == 0)
      count++;
    if(count == K) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int ans = s.size();
    for(int i = 0;i<s.size();i++){
        if(s[i] == 'S'){
            cnt++;
        }
        else{
            if(cnt != 0){
                cnt--;
                ans = ans - 2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> H(N);
	vector<int> rec(N,1);
	vector<int> A(M,0);
	vector<int> B(M, 0);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	for (int i = 0; i < M; i++) {
		if (H[A[i]] < H[B[i]]) {
			rec[A[i]] = 0;
		}
		else if (H[B[i]]<H[A[i]]){
			rec[B[i]] = 0;
		}
		else {
			rec[B[i]] = 0;
			rec[A[i]] = 0;
		}
	}
	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (rec[i] > 0) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
    
    int n,x,t=0;
    
    while(1){
        cin >> n >> x;
        
        if ( n == 0 && x == 0) break;
        
        for ( int i = 1 ; i < n + 1 ; i++ ){
            for ( int j = 1 ; j < n + 1 ; j++ ){
                for ( int k = 1 ; k < n + 1 ; k++ ){
                    if ( i + j + k == x && i != j && j != k && k != i ){
                        t += 1;
                    }
                }
            }
        }
        t /= 6;
        cout << t << endl;
        t = 0;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
bool godie=0;
const int maxn=10005;
int n,f[maxn],f2[maxn],g[maxn],a[maxn];
vector<int> son[maxn];
const int inf=1e9;
inline void dfs(int x){
	for(int w:son[x])dfs(w);
	rep(i,0,a[x])f[i]=inf;f[0]=0;
	for(int w:son[x]){
		rep(i,0,a[x])f2[i]=inf;
		rep(i,0,a[x])if(f[i]!=inf){
			if(i+a[w]<=a[x])
				f2[i+a[w]]=min(f2[i+a[w]],f[i]+g[w]);
			if(i+g[w]<=a[x])
				f2[i+g[w]]=min(f2[i+g[w]],f[i]+a[w]);
		}
		rep(i,0,a[x])f[i]=f2[i];
	}
	g[x]=inf;
	rep(i,0,a[x])g[x]=min(g[x],f[i]);
	if(g[x]==inf)godie=1;
}
int main(){
	read(n);
	rep(i,2,n){
		int x;read(x);
		son[x].pb(i);
	}
	rep(i,1,n)read(a[i]);
	dfs(1);
	puts(godie?"IMPOSSIBLE":"POSSIBLE");
	return 0;
}


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

int main(){
	int m, f, r;
SAIKI:
	cin >> m >> f >> r;
	if( m + f + r == -3 ){ return 0; }
	if( m == -1 || f == -1 ){ cout << "F" << endl; }
	else if( m + f >= 80 ){ cout << "A" << endl; }
	else if( m + f >= 65 ){ cout << "B" << endl; }
	else if( m + f >= 50 ){ cout << "C" << endl; }
	else if( m + f >= 30 ){ if( r >= 50 ){ cout << "C" << endl; } else { cout << "D" << endl; } }
	else if( m + f < 30 ){ cout << "F" << endl;}
goto SAIKI;
return 0;
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c;
    cin >> k;

    while (k--)
    {
        if (b <= a)
            b *= 2;
        else
            c *= 2;
    }

    if (a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n), orig(n);

    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> q[i];
    }

    iota(orig.begin(), orig.end(), 1);

    vector<vector<int>> dict;
    vector<int> perm = orig;

    do {
        dict.push_back(perm);
        next_permutation(perm.begin(), perm.end());
    } while (perm != orig);
    sort(dict.begin(), dict.end());

    auto ploc = find(dict.begin(), dict.end(), p) - dict.begin();
    auto qloc = find(dict.begin(), dict.end(), q) - dict.begin();

    cout << (ploc > qloc ? ploc-qloc : qloc-ploc) << endl;
}


Measured memory_bytes: 3256
n,a,b = map(int, input().split())
s = str(input())

counter1 = counter2 = 1
for char in s:
    if (counter1 <= (a+b)) & (char == 'a'):
        print("Yes")
        counter1 += 1
    elif (counter1 <= (a+b)) & (char == 'b') & (counter2 <= b):
        print("Yes")
        counter1 += 1
        counter2 += 1
    else:
        print("No")

Measured memory_bytes: 9272
#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 2e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const ll    inf  = 1e9 + 10;
const double pi   = acos(-1.0);
const double eps  = 1e-8;
using namespace std;
std::vector<int> mp[maxn];
int a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	int ans = 0;
	for(int i = 1;i <= n;i++){
		int flag = 0;
		for(auto it : mp[i]){
			if(a[it] >= a[i]) flag = 1;
		}
		if(!flag) ans++;
	}
	printf("%d\n",ans );
}

Measured memory_bytes: 11644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	ll x,k,d; cin>>x>>k>>d;
	x=abs(x);
	if(k<=x/d){
		cout<<x-d*k<<endl;
	}
	else{
		ll j=x%d;
		k-=x/d;
		if(k%2==0)cout<<j<<endl;
		else cout<<d-j<<endl;
	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//	if(n==1)return false;
//	T i = 2;
//	while(i*i<=n){
//	   if(n%i==0)return false;
//	   i+=1;
//	}
//    return true;
//}

// bool prime[100005];
// void seive()
// {
// 	memset(prime,true,sizeof(prime));
// 	prime[0]=0;
// 	prime[1]=0;
// 	for(ll p=2;p*p<=100000;p++)
// 	{
// 		if(prime[p]==true)
// 		{
// 			for(ll i=p*2;i<=100000;i+=p)
// 			prime[i]=false;
// 		}
// 	}	
// }

// ll power(ll n,ll k, ll mod){
// 	if(k==0)
// 		return 1;
// 	if(k==1)
// 		return n%mod;

// 	ll get=power(n,k/2,mod);
// 	ll ret = ((get%mod)*(get%mod))%mod;

// 	if(k%2)
// 		ret = ((ret%mod)*(n%mod))%mod;

// 	return ret%mod;
// }


ll dp[SIZE][3];

int main(){
    
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    FAST;
	
	int n; cin>>n;
	rep(i,3){
		dp[0][i] = 0;
	}

	repp(i,1,n+1){
		vll a(3);
		rep(j,3)cin>>a[j];
		rep(j,3){
			rep(k,3){
				if(j!=k){
					dp[i][k] = max(dp[i][k],dp[i-1][j]+a[k]);
				}
			} 
		}
	}

	pn(max({dp[n][0],dp[n][1],dp[n][2]}));
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void)
{
    long long N,K,count = 0;
    cin >> N >> K;
    for(long long b = K+1;b<=N;b++)
    {
        long long n = (N)/b;
        if(K ==0)
        {
            count += (b-K)*n +  max((long long)0,N-b*n);
        }
        else 
        {
          count += (b-K)*n +  max((long long)0,N-b*n-K+1);
        }
    }
    cout << count << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>

using namespace std;

void Solution()
{
    int a, b;
    
    int d, r;
    double f;
    
    cin>>a>>b;
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    cout<<d<<" "<<r<<" "<<fixed<<setprecision(5)<<f<<endl;
    
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ull;
#define st first 
#define nd second 
#define pb push_back
#define mp make_pair 
#define MAX 1000000009
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define For(ii,aa,bb) for(ll ii = aa; ii < bb;ii++)  
#define Rof(ii,aa,bb) for(ll ii = aa - 1; ii >= bb;ii--)
#define IT iterator 
#define ln "\n"
#define mid (start + end)/2
#define R(ii) (ii * 2) + 1
#define L(ii) (ii * 2)
#define pp pair<ll,ll> 
#define vi vector<ll> 
#define all(vv) vv.begin(),vv.end()
#define N 3005
using namespace std;
string s, s2;
ll LCS[N][N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> s >> s2;
    s = " " + s;
    s2 = " " + s2;
    memset(LCS, 0, sizeof LCS);
    For(i, 0, s.size()){
        For(q, 0, s2.size()){
            if (i == 0 || q == 0){
                LCS[i][q] = 0;
            }
            else if (s[i] == s2[q]){
                LCS[i][q] = LCS[i - 1][q - 1] + 1;
            }
            else {
                LCS[i][q] = max(LCS[i - 1][q], LCS[i][q - 1]);
            }
        }
    }
    string ans = "";
    ll i = s.size() - 1, q = s2.size();
    while (i >= 1 && q >= 1){
        if (s[i] == s2[q]){
            ans += s[i];
            i--;
            q--;
        }
        else if (LCS[i - 1][q] > LCS[i][q - 1]){
            i--;
        }
        else {
            q--;
        }
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}

Measured memory_bytes: 70784
#include<cmath>
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;



int main() {
	int r, c;
	int a[101][101] = {};
	cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
			a[r][c] += a[i][j];
		}

		
	}
	for (int k = 0; k < r + 1; k++) {
		for (int h = 0; h < c + 1; h++) {
			cout << a[k][h];
			if (0 <= h&&h < c)cout << ' ';

		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: isize = read();
    let s: String = read();

    let v: Vec<char> = s.chars().collect();
    let mut ans = 0;
    let mut last: char = '0';
    for i in v {
        if i != last {
            ans += 1;
        }
        last = i;
    }

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long

vector<int> v,x;

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int x; cin >> x; v.push_back(x);
  }
  x = v;
  sort(v.begin(),v.end());
  int m1 = v[n/2-1];
  int m2 = v[n/2];
  for(int i = 0; i < n; i++){
    if(x[i] <= m1) cout << m2 << endl;
    else if(x[i] >= m2) cout << m1 << endl;
  }

  return 0;
}


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

int main(void){
    int a,b;
    cin>>a>>b;
    if(a+b > a-b && a+b > a*b){
        cout<<a+b<<endl;
    }else if(a-b > a*b){
        cout<<a-b<<endl;
    }else{
        cout<<a*b<<endl;
    }
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
z = sum(a) / N
if z - z // 1 >= z // 1 + 1 -z:
	x = int(z // 1 + 1)
else:
	x = int(z // 1)
s = 0
for i in range(N):
	s += (a[i] - x) ** 2
print(s)

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

using namespace std;

int main() {
  string s;
  int k;
  cin >> s;
  cin >> k;
  set<string> ss;

  for (int i = 0; i < s.size(); i++) {
      for (int j = 1; j <= k && i + j <= s.size(); j++) {
          ss.insert(s.substr(i, j));
      }
  }
  vector<string> ans(ss.begin(), ss.end());
  cout << ans[k-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
int lcs(string x, string y){
    
    int m = x.size();
    int n = y.size();
    int c[m+1][n+1];
    int Max = 0;
    string X = " " + x;
    string Y = " " + y;
    for(int j = 0; j <= m; j++){
        c[j][0] = 0;
    }
    for(int j = 1; j <= n; j++){
        c[0][j] = 0;
    }
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(X[i] == Y[j]){
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            Max = max(Max, c[i][j]);
        }
    }
    
    return Max;
}
int main(){
    //std::stack<int> stack;
    
    int n;
    cin >> n;
    vector<int> fib(45);
    fib[0] = 1;
    fib[1] = 1;
    for(int i = 2; i < 45; i++){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
}






Measured memory_bytes: 3108
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &k)
	var sum, temp = 0, 0
	if a >= k {
		fmt.Println(k)
		return
	} else {
		sum = a
		temp = k - a
	}
	if b >= temp {
		fmt.Println(sum)
		return
	} else {
		temp -= b
	}
	fmt.Println(sum - temp)
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main()
{
	int N, M;
	cin >> N >> M;
	
	vector<int> Ai(N, 0);
	int all_vote = 0;
	rep(i, N)
	{
		cin >> Ai.at(i);
		all_vote += Ai.at(i);
	}

	int ans = 0;
	rep(i, N)
	{
		if (Ai.at(i) >= 1.0 / (4.0*M)*all_vote)
		{
			ans++;
		}
	}

	if (M <= ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3552
#include<stdio.h>

int main(void){
   int a[10000], b[10000], n, i;
   scanf("%d", &n);
   for(i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }
   for(i = 0; i < n; i++){
      b[n - i - 1] = a[i];
   }
   printf("%d", b[0]);
   for(i = 1; i < n; i++){
      printf(" %d", b[i]);
   }
   printf("\n");
   return 0;
}

Measured memory_bytes: 1800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int N, mid;
    	int[] a;
    	
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	a = in.nextIntArray(N);
        	Arrays.sort(a);
        	
        	int diff = Integer.MAX_VALUE;
        	for (int i = 0; i < N - 1; ++i) {
        		int curDiff = Math.abs(2*a[i] - a[N - 1]);
        		if (curDiff < diff) {
        			mid = a[i];
        			diff = curDiff;
        		}
        	}
        	
        	out.println(a[N - 1] + " " + mid);
        }
    }
    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        
        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 39460
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n, x;
    cin>>x>>n;
    vi v(n);
    map<int, int>u;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        u[v[i]]++;
    }
    int l = x, r = x;
    while(u[l]&&l>=0)l--;
    while(u[r]&&r<=100)r++;
    if(abs(x-l)>abs(x-r))cout<<r;
    else cout<<l;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3660
import sys
A,B,C,K = map(int,input().split())
ans = 0

if K >= A:
    ans += A
else:
    ans += K
K -= A
if  K <= 0:
    print(ans)
    sys.exit()
K -= B
if K > 0:
    if K >= C:
        ans += (-1*C)
    else:
        ans += (-1*K)
print(ans)


Measured memory_bytes: 9152
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<queue>
#define x first
#define y second
using namespace std;
const int mod=998244353;
int N;

int x[205],y[205],power[205];

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&x[i],&y[i]);
	}
	int ans;
	power[0]=1;
	for(int i=0;i<N;i++)
	{
		power[i+1]=(power[i]<<1)%mod;
	}
	ans=power[N]-N-1;

	for(int i=0;i<N;i++)
	for(int j=0;j<i;j++)
	{
		int cnt=0;
		for(int k=0;k<j;k++)
		{
			if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))
			cnt++;
		}
		ans=(ans-power[cnt]+mod)%mod;
	}
		printf("%d\n",ans);
}

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

int main() {
    char a,b;
    cin >> a >> b;
    if(a=='H'&&b=='H'){
        cout << "H";
    }
    else if(a=='H'&&b=='D'){
        cout << "D";
    }
    else if(a=='D'&&b=='D'){
        cout << "H";
    }
    else{
        cout << "D";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    unsigned int num;                /* 情報量の格納用変数 */
    unsigned int house[4][3][10];    /* 部屋情報の格納用変数 */
    unsigned int bil;                /* 棟番号の格納用変数 */
    unsigned int flor;               /* 階数の格納用変数 */
    unsigned int room;               /* 部屋番号の格納用変数 */
    signed int  riside;              /* 入居者数の格納用変数 */
    unsigned int i, j, k;            /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                house[i][j][k] = 0;
            }
        }
    }

    /* 情報量の入力 */
    scanf("%d", &num);
    /* 入居者変更情報の入力 */
    for(i = 0;i < num;i++){
        /* 入居者変更情報の入力 */
        scanf("%d %d %d %d", &bil, &flor, &room, &riside);
        /* 入居者変更情報の加算 */
        house[bil - 1][flor - 1][room - 1] += riside;
    }

    /* 部屋情報の出力 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                /* 各部屋の入居者の出力 */
                printf(" %d", house[i][j][k]);
            }
            /* 階の区切り */
            printf("\n");
        }
        /* 第四棟でない場合棟を区切る */
        if(i != 3){
           /* 棟の区切り */
           printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2100
#include "bits/stdc++.h"
using namespace std;

int main(){
	int y,m,d;
  	char c1 ,c2;
  cin >> y >> c1 >> m >> c2 >> d;
	if(m<=4) cout <<"Heisei" << endl;
  	else cout << "TBD" << endl;
  }
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,H;
vector<P1> Katana;


int maxSwingPower;
int throwPower[100005];

int AttackCount(int n){
    int h = H-n*maxSwingPower;
    int it = upper_bound(throwPower,throwPower+N,h)-throwPower;
    if(throwPower[it-1]==h)it--;
    //cout<<h<<" "<<n<<endl;
    //cout<<n*maxSwingPower<<" "<<throwPower[it]<<" "<<it<<endl;
    if(h<=0)return n;
    else if(h-throwPower[it]>0)return INF;
    else return n + it;
}


int a[100005];
int b[100005];

signed main(){
    cin>>N>>H;
    for(int i=0;i<N;++i){
        int s,t;
        cin>>s>>t;
        Katana.push_back(P1(t,s));
        maxSwingPower = max(s,maxSwingPower);
        a[i] = s;
        b[i] = t;
    }
    sort(b,b+N);
    //cout<<maxSwingPower<<endl;
    sort(Katana.begin(),Katana.end(),greater<P1>());
    for(int i=1;i<=N;++i){
        throwPower[i] = throwPower[i-1] + Katana[i-1].first;
        //cout<<throwPower[i]<<endl;
    }
    /*int l=0,r=1000000000;
    int minAttackCount = INF;
    for(int i=0;i<1000005;++i){
        minAttackCount=min(minAttackCount,AttackCount(i));
    }
    cout<<minAttackCount<<endl;*/
    int it=upper_bound(b,b+N,maxSwingPower)-b;
    int h=H-throwPower[N-it];
    int p=h/maxSwingPower;
    if(maxSwingPower*p<h)p++;
    if(h<0){
        for(int i=0;i<=N;++i){
            if(H<=throwPower[i]){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    //cout<<h<<" "<<p<<" "<<N-it<<endl;
    cout<<p+N-it<<endl;
}


Measured memory_bytes: 4336
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 29;
const int maxn=2e5+5;

int n,l;
int a[maxn];

int main(){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int cnt=-1;
	for(int i=1;i<=n-1;i++)if(a[i]+a[i+1]>=l){cnt=i;break;}
	if(cnt==-1){puts("Impossible");return 0;}
	puts("Possible");
	for(int i=1;i<=cnt-1;i++){
		printf("%d\n",i);
	}
	for(int i=n-1;i>=cnt+1;i--){
		printf("%d\n",i);
	}
	printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,t,a,h;
    cin >> n >> t >> a >> h;
    int ans = 1;
    double minDifference = abs(t - h * 0.006 - a);
    for(int i = 2; i <= n; i++){
        cin >> h;
        double difference = abs(t - h * 0.006 - a);
        if(difference < minDifference){
            ans = i;
            minDifference = difference;
        }
    }
    
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int numbers[3],sum=0;
	REP(i,3){
		cin>>numbers[i];
		sum+=numbers[i];
	}

	REP(i,4){
		if(i==3) puts("No");
		else if(sum-2*numbers[i]==0){
			puts("Yes");
			break;
		}
	}
	return 0; 
}



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

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

vector<pair<long int,int>> factorize(long int N){
    vector<pair<long int, int>> res;
    for (long int i = 2; i * i <= N; ++i){
        if(N%i)
            continue;
        res.emplace_back(i, 0);
        while( N%i ==0 ){
            N /= i;
            res.back().second++;
        }
    }
    if( N != 1 )
        res.emplace_back(N, 1);
    return res;
}

int main()
{

    long int a, b;
    cin >> a >> b;
    long int g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;


    return 0;
}

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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n,pre=0;
	int a[101],b[101];
	cin>>n;
	forn(i,0,n) cin>>a[i]>>b[i];
	forn(i,0,n){
		if (pre==3){
			cout<<"Yes"<<endl;
			return 0;
		}
		if (a[i]==b[i]){
			pre++;
		}
		else{
			pre=0;
		}
	}
	if (pre==3){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3644
k = int(input())
A = list(map(int,input().split()))

ans = [2,2]
for a in A[::-1]:

  if a > ans[1]:
    print(-1)
    exit()
  ans[1] = (ans[1]//a) *a+ (a-1)
  if ans[0] <= a:
    ans[0] = a
  else:
    if ans[0]%a != 0:
      ans[0] = (ans[0]//a+1)*a
  if ans[0] >ans[1]:
    print(-1)
    exit()
print(*ans)

Measured memory_bytes: 63984
require 'prime'

a,b,k = gets.split.map(&:to_i)

primes = Prime.prime_division(a.gcd(b)).map do |n, p|
  [n]*p
end.flatten


divisors = (1..primes.size).to_a.map do |n|
  primes.combination(n).map do |arr|
    arr.inject(:*)
  end
end.flatten + [1]

puts divisors.uniq.sort.reverse.at(k-1)


Measured memory_bytes: 3964
#include<iostream>
#include<string>
#include<map>
#include<set>
using namespace std;main(){int n;string s;map<string,set<int> >z;map<string,set<int> >::iterator q;set<int>::iterator x;while(cin>>s>>n)z[s].insert(n);for(q=z.begin();q!=z.end();cout<<endl){cout<<(s=q++->first)<<endl;for(x=z[s].begin(),n=0;x!=z[s].end();cout<<*x++)if(n++)cout<<" ";}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char z;
  string ans;
  cin >> z;
  if(z=='a'||z=='i'||z=='u'||z=='e'||z=='o'){
  	ans = "vowel";
  }
  else{
  	ans = "consonant";
  }
 cout << ans << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s[200005];
int main()
{
    ios::sync_with_stdio(false);
    int a,b,c,d,count1=0;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        if(count1%2)
        {
            a-=d;
            if(a<=0)
                {
                    cout<<"No"<<endl;
                    return 0;
                }
        }
        else
        {
            c-=b;
            if(c<=0)
               {
                    cout<<"Yes"<<endl;
                    return 0;
                }
        }
        count1++;
    }
}


Measured memory_bytes: 9908