akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct SegmentTree{
    int dat[10000000]{},n=1;
    SegmentTree(int N){
        while(n<N)n*=2;
    }
    void update(int x,int a){
        x+=n-1;
        dat[x]+=a;
        while(x>0){
            x=(x-1)/2;
            dat[x]+=a;
        }
    }
    int query2(int a,int b,int x,int l,int r){
        if(r<=a || b<=l)return 0;
        if(a<=l && r<=b)return dat[x];
        return query2(a,b,x*2+1,l,(l+r)/2)+query2(a,b,x*2+2,(l+r)/2,r);
    }
    int query(int a,int b){
        return query2(a,b+1,0,0,n);
    }
};
signed main(){
  int N,Q,A[1000000];
  cin>>N>>Q;
  for(int i=0;i<N;i++){
    cin>>A[i];
    A[i]--;
  }
  pair<pair<int,int>,int> B[1000000];
  for(int i=0;i<Q;i++){
    cin>>B[i].first.second>>B[i].first.first;
    B[i].first.first--,B[i].first.second--;
    B[i].second=i;
  }
  sort(B,B+Q);
  int C[1000000],D[1000000];
  for(int i=0;i<N;i++)C[i]=-1;
  SegmentTree S(N);
  int n=0;
  for(int i=0;i<N;i++){
    if(C[A[i]]!=-1)S.update(C[A[i]],-1);
    S.update(i,1);
    C[A[i]]=i;
    for(;n<Q && B[n].first.first==i;n++)
      D[B[n].second]=S.query(B[n].first.second,B[n].first.first);
  }
  for(int i=0;i<Q;i++)cout<<D[i]<<endl;
}

Measured memory_bytes: 117268
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    K = I()
    ans = 0

    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                ans += gcd(gcd(a, b), c)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74328
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, w;

    while (cin >> h >> w, h || w) {
        vector<string> map(h);
        vector<vector<bool> > memo(h, vector<bool>(w));

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

        int x, y;
        x = y = 0;
        while (true) {
            if (memo[y][x]) {
                cout << "LOOP" << endl;
                break;
            }
            memo[y][x] = true;
            if (map[y][x] == '.') {
                cout << x << " " << y << endl;
                break;
            }
            
            if (map[y][x] == '>') 
                x++;
            else if (map[y][x] == '<')
                x--;
            else if (map[y][x] == 'v')
                y++;
            else
                y--;
        }
    }

    return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll>pi;
ll ara[100006];
bool check(ll val,ll n)
{
    ll cnt=1;
    for(ll i=0;i<n;i++)
    {
        if(__gcd(ara[i],val)!=val)
        {
//            cout<<ara[i]<<" "<<val<<endl;
            if(cnt==1)cnt=0;
            else return false;
        }
    }
    return true;
}
int main()
{

        ll n;cin>>n;
        ll mn=10000000001;
        ll pos;
        for(ll i=0;i<n;i++)
        {
            cin>>ara[i];
            if(mn>ara[i])
            {
                mn=ara[i];
                pos=i;
            }
        }
        ll dd=10000000001;
        for(ll i=0;i<n;i++)
        {
            if(i!=pos)
            {
                if(dd>ara[i])
                    dd=ara[i];
            }
        }
//        cout<<mn<<" "<<dd<<endl;
        ll ans=1;
        if(n==1)cout<<ara[0]<<endl;
        else
        {
            for(ll i=1;i*i<=mn;i++)
            {
                if(mn%i==0)
                {
                    ll temp=1;
                    ll a=i,b=mn/i;
                    if(check(a,n)==1)temp=a;
                    if(check(b,n)==1)temp=max(b,temp);
                    ans=max(ans,temp);
                }
            }
            int sq=sqrt(dd);
//            cout<<"sq v= "<<sq<<endl;
            for(ll i=1;i<=sq;i++)
            {
                if(dd%i==0)
                {
                    ll temp=1;
                    ll a=i,b=dd/i;
                    if(check(a,n)==1)temp=a;
//                    cout<<"temp for "<<a<<" "<<temp<<endl;
                    if(check(b,n)==1)temp=max(b,temp);
//                    cout<<"val for "<<b<<" "<<temp<<endl;

                    ans=max(ans,temp);
                }
            }
            cout<<ans<<endl;
 

        }
}


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

namespace _1_3_C_DoublyLinkedList
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var linkedList = new LinkedList<int>();
            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                int num = 0;
                var command = input[0];
                if (input.Length > 1)
                {
                    num = int.Parse(input[1]);
                }

                switch (command)
                {
                    case "insert":
                        linkedList = Insert(linkedList, num);
                        continue;

                    case "delete":
                        linkedList = Delete(linkedList, num);
                        continue;

                    case "deleteFirst":
                        linkedList = DeleteFirst(linkedList);
                        continue;

                    case "deleteLast":
                        linkedList = DeleteLast(linkedList);
                        continue;
                }
            }
            Console.WriteLine(string.Join(" ",linkedList));
        }

        public static LinkedList<int> Insert(LinkedList<int> list, int num)
        {
            list.AddFirst(num);
            return list;
        }

        public static LinkedList<int> Delete(LinkedList<int> list, int num)
        {
            var deleteIndex = list.Find(num);
            if (deleteIndex == null)
            {
                return list;
            }
            list.Remove(deleteIndex);
            return list;
        }

        public static LinkedList<int> DeleteFirst(LinkedList<int> list)
        {
            list.RemoveFirst();
            return list;
        }

        public static LinkedList<int> DeleteLast(LinkedList<int> list)
        {
            list.RemoveLast();
            return list;
        }
    }
}



Measured memory_bytes: 71248
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
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 h: usize = read();
    let w: usize = read();
    let k: usize = read();
    let mut board: Vec<Vec<char>> = vec![vec![' '; w]; h]; //列、行

    for i in 0..h {
        board[i] = read::<String>().chars().collect();
    }

    let mut ans = 0;
    //2次元のbit全探索
    for h_bit in 0..1 << h {
        for w_bit in 0..1 << w {
            let mut black_count = 0;
            for i in 0..h {
                for j in 0..w {
                    //行列で両方を選ぶ（赤く塗らない場合）
                    if (h_bit & 1 << i) != 0 && (w_bit & 1 << j) != 0 {
                        //黒マスか判定
                        if board[i][j] == '#' {
                            black_count += 1;
                        }
                    }
                }
            }
            //黒マス総数のチェック
            if black_count == k {
                ans += 1;
            }
        }
    }

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


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

struct Node
{
    int parent = -1, left = -1, right = -1;
};


void preorder(int node_id, vector<Node> &T) {
    if (node_id == -1)
        return;
    
    cout << " " << node_id;
    preorder(T.at(node_id).left, T); // 左の子へ
    preorder(T.at(node_id).right, T); // 右の子へ
}

void inorder(int node_id, vector<Node> &T) {
    if (node_id == -1)
        return;

    inorder(T.at(node_id).left, T);
    cout << " " << node_id;
    inorder(T.at(node_id).right, T);
}

void postorder(int node_id, vector<Node> &T) {
    if (node_id == -1)
        return;

    postorder(T.at(node_id).left, T);
    postorder(T.at(node_id).right, T);
    cout << " " << node_id;
}

int main() {
    int N;
    cin >> N;

    vector<Node> T(N);

    for (int i = 0; i < N; i++)
    {
        int node_i, left_c, right_c;
        cin >> node_i >> left_c >> right_c;

        T.at(node_i).left = left_c;
        T.at(node_i).right = right_c;

        if (left_c != -1)
            T.at(left_c).parent = node_i;
        if (right_c != -1)    
            T.at(right_c).parent = node_i;
    }

    int root;
    for (int i = 0; i < N; i++)
    {
        if (T.at(i).parent == -1)
            root = i;
    }

    // Preorder
    cout << "Preorder" << endl;
    preorder(root, T);
    cout << endl;

    // Inorder
    cout << "Inorder" << endl;
    inorder(root, T);
    cout << endl;

    // Postorder
    cout << "Postorder" << endl;
    postorder(root, T);
    cout << endl;
}


Measured memory_bytes: 3088
n = int(input())

def sieve(n):
    # 1.9 seconds.

    # 1 and n are divisors for every n.
    is_prime = [2]*(n + 1)
    is_prime[0], is_prime[1] = 0, 0

    # is_prime holds the number of positive divisors of N. Instead of being a bool of 0/1 for prime/not prime. for example of N=24--->  is_prime[24] = 6 (1, 2, 3, 4, 6 ,24)

    for num in range(2, n+1//2):
        for mult in range(2*num, n+1, num):
            is_prime[mult] += 1
        
    ans = 1

    # i is N. elem is f(N)
    for i, elem in enumerate(is_prime[2:]):
        ans += (elem)*(i + 2)

    print(ans)

def geothermal(n):
    # Source: https://codeforces.com/blog/entry/79438
    # Let's reframe the problem by considering the total contribution each divisor makes to the answer. For any given i, i contributes K to the sum for each K from 1 to N such that K is a multiple of i.
    ans = 0
    for i in range(1, n+1):
        mult = n//i
        ans += (mult*(mult + 1)*i)//2
    print(ans)

geothermal(n)






Measured memory_bytes: 63300
#include <iostream>

using namespace std;

long long gcd(long long x, long long y) {
  if (y == 0) { return x;}
  else { return gcd(y, x%y); }
}
long long lcm(long long x, long long y) {
  return x/gcd(x,y)*y;
}

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

  // b以下でcでもdでも割り切れないもの
  long long bb = b - b/c - b/d + b/lcm(c, d);
  long long aa = (a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c, d);
  cout << bb-aa << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn max_index(vs: Vec<usize>) -> (usize, usize) {
    let mut max = (0, 0);
    for (i, v) in vs.iter().enumerate() {
        if v > &max.1 {
            max = (i, *v);
        }
    }
    max
}

fn solve(l: usize, r: usize, max: usize, v: Vec<usize>) {
    let raw_d = if v[l] > v[r] {
        v[l] - v[r]
    } else {
        v[r] - v[l]
    };
    if raw_d % 2 == 0 {
        println!("{}", (raw_d + 1)/ 2 + max - std::cmp::max(v[l], v[r]));
    } else {
        println!("{}", (raw_d + 1)/ 2 + max - std::cmp::max(v[l], v[r]) + 1);
    }
}

fn main() {
    input! {
        v: [usize; 3],
    }
    let max = max_index(v.clone());
    if max.0==0 {
        solve(1,2, max.1, v.clone());
    } else if max.0 == 1 {
        solve(0,2, max.1, v.clone());
    } else {
        solve(0,1, max.1, v.clone());
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
  char x;cin>>x;
  if(x>='A' && x<='Z') cout<<'A';
  else cout<<'a';
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
#define MAX (256)

char field[MAX][MAX];

int main(){
	int w, h;
	while(cin >> w >> h, w || h){
		for(int i=0; i < w; i++){
			for(int j=0; j < h; j++){
				cin >> field[i][j];
			}
		}
		int x=0, y=0;
		while(1){
			switch(field[x][y]){
				case '>':
					field[x][y] = '#';
					y++;
					break;
				case 'v':
					field[x][y] = '#';
					x++;
					break;
				case '<':
					field[x][y] = '#';
					y--;
					break;
				case '^':
					field[x][y] = '#';
					x--;
					break;
				case '.':
					field[x][y] = '%';
					cout << y << ' ' << x << endl;
					break;
				case '#':
					field[x][y] = '%';
					cout << "LOOP" << endl;
					break;
			}
			if(field[x][y] == '%') break;
		}
	}
}

Measured memory_bytes: 1184
#include<iostream>
using namespace std;
int s[110][110]={0};
int main(){
    int n,m,x,i;
    cin >> n >> m;
    x=m;
    for(i=1;i<n;i++){
        x*=(m-1);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    rp(i,n){
        char ch;
        cin >> ch;
        if(ch=='Y'){
            print("Four");
            return;
        }
    }
    print("Three");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3540
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  x,n =I()
  p = LI()
  for i in range(51):
    if x - i not in p:
      ans = x - i
      break
    if x + i not in p:
      ans = x + i
      break
  print(ans)
if __name__ == '__main__':
  main()

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

int main()
{
    int n; 
    string a; cin>>a;
    n=a.length();
    int c1=0,c2=0;
    for(int i=0;i<n;i++)
    {   
        
        if(i&1)
        {
            if(a[i]!='1') c1++;
            if(a[i]!='0') c2++;
        }
        else
        {
            if(a[i]!='1') c2++;
            if(a[i]!='0') c1++;
        }
    }
    
    cout<<min(c1,c2)<<endl;
    
    
}

Measured memory_bytes: 512
<?php

$input = trim(fgets(STDIN));
$input = explode(" ", $input);
$n = (int) $input[0];
$t = (int) $input[1];

$count = 0;
while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	$args[] = [
		'c' => (int) $input[0],
		't' => (int) $input[1],
	];
	++$count;
	if ($count >= $n) {
		break;
	}
}

usort($args, 'my_sort');

foreach ($args as $root) {
	if ($root['t'] <= $t) {
		echo $root['c'];
		exit(0);
	}
}
echo 'TLE';










function my_sort($a, $b){
	if ($a["c"] == $b["c"]) {
		return $a["t"] < $b["t"] ? -1 : 1;
	}else{
		return $a["c"] < $b["c"] ? -1 : 1;
	}
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
vector<P>vec;
signed main(){
    int n,m,ans=0,made=0;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        vec.push_back(make_pair(b,a));
    }
    sort(vec.begin(),vec.end());
    rep(i,m){
        if(vec[i].S>made){
            ans++;
            made=vec[i].F-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
int a, b, C;
double S, L, h , c;
double PI = acos(-1);

cin >> a >> b >> C;

double rad_C = C * PI / 180;
S =  a * b * sin(rad_C) / 2.0;
c   = sqrt( a * a + b * b - 2.0 * a * b * cos(rad_C) ) ;
L = a + b + c;
h = 2.0 * S / a;

printf("%.8f\n%.8f\n%.8f\n", S ,L , h);
return 0;
}


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

using namespace std;

int main(){
	vector<vector<int>> c(3,vector<int>(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c.at(i).at(j);
		}
	}
	bool ok=true;
	for(int i=0;i<2;i++){
		int last=c.at(i).at(0)-c.at(i+1).at(0);
		for(int j=0;j<3;j++){
			int diff = c.at(i).at(j)-c.at(i+1).at(j);
			if(diff!=last){
				ok=false;
				break;
			}
			last=c.at(i).at(j)-c.at(i+1).at(j);
		}
	}
	for(int i=0;i<2;i++){
		int last=c.at(0).at(i)-c.at(0).at(i+1);
		for(int j=0;j<3;j++){
			int diff = c.at(j).at(i)-c.at(j).at(i+1);
			if(diff!=last){
				ok=false;
				break;
			}
			last=c.at(j).at(i)-c.at(j).at(i+1);
		}
	}
	
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Node extends ArrayList<Integer>{
}
  
class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int Q = sc.nextInt();
    List<Node> edges = new ArrayList<Node>(N);
    for(int i=0; i<N; i++){
      Node a = new Node();
      edges.add(a);
    }
    int count[] = new int[N];
    for(int i=0; i<N-1; i++){
      int a = sc.nextInt()-1;
      int b = sc.nextInt()-1;
      edges.get(a).add(b);
      edges.get(b).add(a);
    }
    boolean use[] = new boolean[N];
    for(int i=0; i<Q; i++){
      int p = sc.nextInt()-1;
      int x = sc.nextInt();
      count[p] += x;
    }
    Queue<Integer> queue = new ArrayDeque<>();
    queue.add(0);
    while(!queue.isEmpty()){
      int tmp = queue.poll();
      for(int a : edges.get(tmp)){
        if(!use[a]){
          count[a] += count[tmp];
          queue.add(a);
        }
      }
      use[tmp] = true;
    }
    for(int i=0; i<N; i++) out.print(count[i] + " ");
  }
}

Measured memory_bytes: 88204
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int h, a;
    cin >> h >> a;
    cout << (h-1)/a+1 << endl;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  auto b = new long[](n);

  struct P { int v, i; }
  auto p = new P[](n);
  foreach (i; 0..n) p[i] = P(a[i], i);

  auto st = new SegmentTree!(P, (a, b) => a.v == b.v ? (a.i < b.i ? a : b) : (a.v > b.v ? a : b))(p, P(0, 0));
  auto h = heapify(Array!long());

  auto x = st[0..$].i;
  foreach (i; x..n)
    if (a[i] < a[x])
      h.insert(a[i]);

  while (x > 0) {
    auto y = st[0..x].i;
    b[x] = (n-x-h.length).to!long*(a[x]-a[y]);

    while (!h.empty && h.front >= a[y]) {
      b[x] += h.front-a[y];
      h.removeFront();
    }

    foreach (i; y..x)
      if (a[i] < a[y])
        h.insert(a[i]);

    x = y;
  }

  b[0] = (n-h.length).to!long*a[0];
  while (!h.empty) {
    b[0] += h.front;
    h.removeFront();
  }

  foreach (bi; b) writeln(bi);
}

class SegmentTree(T, alias pred = "a + b")
{
  import core.bitop, std.functional;
  alias predFun = binaryFun!pred;

  const size_t n, an;
  T[] buf;
  T unit;

  this(size_t n, T unit = T.init)
  {
    this.n = n;
    this.unit = unit;
    an = n == 1 ? 1 : (1 << ((n-1).bsr + 1));
    buf = new T[](an*2);
    if (T.init != unit) buf[] = unit;
  }

  this(T[] init, T unit = T.init)
  {
    this(init.length, unit);
    buf[an..an+n][] = init[];
    foreach_reverse (i; 1..an)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  void opIndexAssign(T val, size_t i)
  {
    buf[i += an] = val;
    while (i /= 2)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  pure T opSlice(size_t l, size_t r)
  {
    l += an; r += an;
    T r1 = unit, r2 = unit;
    while (l != r) {
      if (l % 2) r1 = predFun(r1, buf[l++]);
      if (r % 2) r2 = predFun(buf[--r], r2);
      l /= 2; r /= 2;
    }
    return predFun(r1, r2);
  }

  pure T opIndex(size_t i) { return buf[i+an]; }
  pure size_t opDollar() { return n; }
}


Measured memory_bytes: 9020
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}

const ll mod=1000000007;
const int N=2003;

ll dp[N];
int s;

int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
        
    cin>>s;
    dp[0]=1;
    for(int i=3;i<=s;i++)
        for(int j=3;j<=i;j++)
            if(i-j>=0)
                dp[i]=(dp[i]+dp[i-j])%mod;
    cout<<dp[s];
    
    
    
    
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	map<char, int>f,b;
	int ans = 0;
	int count;
	for (int i = 1; i < n-1; i++) {
		count = 0;
		f.clear();
		b.clear();
		for (int j = 0; j < i; j++) {
			f[s[j]]++;
		}
		for (int j = i; j < n; j++) {
			b[s[j]]++;
		}
		for (char c = 'a'; c <= 'z'; c++) {
			if (f[c] > 0 && b[c] > 0) {
				count++;
			}
		}
		ans = max(ans, count);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;     
   cin >> i;
   h = i / 3600;
   m=i/60-h*60;
   s=i%60;
   cout << h <<":"<<m<<":"<<s<< endl;
   return 0;
}


Measured memory_bytes: 3076
s = input()
t = input()

S, T = len(s), len(t)
dp = [[0]*(T+1) for _ in range(S+1)]
prev = [[(-1,-1)]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T): 
        r = max(dp[i][j-1], dp[i-1][j])
        p = (i, j-1) if r == dp[i][j-1] else (i-1, j)
        if s[i] == t[j]:
            r = max(dp[i-1][j-1] + 1, r) 
            p = (i-1, j-1) if r == dp[i-1][j-1] + 1 else p
        dp[i][j] = r
        prev[i][j] = p


ans = ''
i, j = S - 1, T - 1
while i >= 0 and j >= 0:
    if prev[i][j] == (i-1, j-1):
        ans += s[i]
    i, j = prev[i][j]

print(ans[::-1])

Measured memory_bytes: 428824
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int cnt = 0;
  while(a > 0 && c > 0){
    if(cnt % 2 == 0){
      c -= b;
    } else{
      a -= d;
    }
    cnt++;
  }
  if(a > 0) cout << "Yes" << ln;
  else cout << "No" << ln;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  int N, M;
  std::cin >> N >> M;

  std::vector<int> Xs(M);
  for (auto& Xi : Xs) {
    std::cin >> Xi;
  }

  if (N > M) {
    std::cout << 0 << std::endl;
    return 0;
  }

  std::sort(Xs.begin(), Xs.end());

  std::vector<int> Ls(M - 1);
  for (int i = 0; i < M - 1; ++i) {
    Ls[i] = std::abs(Xs[i + 1] - Xs[i]);
  }
  std::sort(Ls.begin(), Ls.end(), std::greater<int>{});

  const auto ans = std::accumulate(Ls.cbegin() + (N - 1), Ls.cend(), 0);

  std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define ll long long
int main(){
	ll a,b; cin>>a>>b;
	if(a==b) cout<<"Yes"; else cout<<"No";


}


Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#pragma warning(disable : 4996)



int left(int i) {
	return i * 2;
}
int right(int i) {
	return i * 2 + 1;
}

void maxHeapify(std::vector<int> &A, int i) {
	int l = left(i);
	int r = right(i);
	int largest = i;
	if ((A.size() > l) && (A[l] > A[i])) {
		largest = l;
	}
	if ((A.size() > r) && (A[r] > A[largest])) {
		largest = r;
	}
	if (largest != i) {
		int tmp = A[largest];
		A[largest] = A[i];
		A[i] = tmp;
		maxHeapify(A, largest);
	}
}
void buildMaxHeap(std::vector<int> &A) {
	for(int i = (A.size()-1)/2+1; i >= 1; --i) {
		maxHeapify(A, i);
	}
}

int main(void) {
	int h;
	scanf("%d", &h);
	std::vector<int> A;
	A.push_back(-1); // dummy
	for (int i = 0; i < h; ++i) {
		int v;
		scanf("%d", &v);
		A.push_back(v);
	}
	buildMaxHeap(A);
	for (int i = 1; i < h+1; ++i) {
		printf(" %d", A[i]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 4452
#include "bits/stdc++.h"
using namespace std;
int main(){
  long long int n,s;
  cin >> n >>s;
  long long int w[n],v[n];
  for(auto i=0;i<n;i++){
    cin >> w[i] >>v[i];
  }
  long long int ans[n+1][s+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=s;j++){
      if(i==0||j==0){
        ans[i][j]=0;
      }
      else if(j>=w[i-1]){
        ans[i][j]=max((v[i-1]+ans[i-1][j-w[i-1]]),ans[i-1][j]);
      }
      else{
        ans[i][j]=ans[i-1][j];
      }
    }
  }
  cout << ans[n][s];
  return 0;
}


Measured memory_bytes: 79104
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;



	printf("%.12lf\n", 2 * N * 3.14159265358979);

	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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

int main()
{
	ll N;
	cin >> N;

	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	if (A[0] != 0) {
		PRINT(-1);
		return 0;
	}
	A.push_back(0);
	ll pre = A[0];
	ll ans = 0;
	FOR(i, 1, N+1) {
		if (pre >= A[i]) {
			ans += pre;
		} else if (pre+1 == A[i]) {
			//ans += A[i] - pre;
		} else {
			PRINT(-1);
			return 0;
		}
		pre = A[i];
	}
	PRINT(ans);
	return 0;
}


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

int main(void){

  int a,b,c;
  cin >> a >> b >> c;

  vector<int> v;
  v.push_back(a+b);
  v.push_back(a+c);
  v.push_back(b+c);

  sort(v.begin(),v.end());
  cout << v.front() << endl;

  return 0;
}



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

constexpr int MAX = 1000;

int h, w;
int board[MAX][MAX];//j:0,o:1,i:2
bool res[MAX - 1][MAX - 1];
int target[2][2];

bool check(int x, int y) {
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			if (board[i + y][j + x] != target[i][j])
				return false;
		}
	}
	return true;
}

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

int solve() {
	int ans = 0;
	for (int i = 0; i < h - 1; ++i) {
		for (int j = 0; j < w - 1; ++j) {
			if (check(j, i)) {
				++ans;
				res[i][j] = true;
			}
		}
	}

	int r = 0, cnt = 0;

	for (int change = 0; change < 3; ++change) {
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				int nx, ny, a = board[i][j];
				board[i][j] = change;
				for (int k = 0; k < 4; ++k) {
					nx = j + dx[k];
					ny = i + dy[k];
					if (0 <= nx&&nx < w - 1 &&
						0 <= ny&&ny < h - 1) {
						if (check(nx, ny)) {
							if (!res[ny][nx])
								++cnt;
						}
						else if (res[ny][nx])
							--cnt;
					}
				}
				r = std::max(r, cnt);
				cnt = 0;
				board[i][j] = a;
			}
		}
	}
	ans += r;
	return ans;
}

int main() {
	std::cin >> h >> w;
	char ch;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			std::cin >> ch;
			switch (ch) {
			case 'O':
				board[i][j] = 1; break;
			case 'I':
				board[i][j] = 2; break;
			}
		}
	}
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			std::cin >> ch;
			switch (ch) {
			case 'O':
				target[i][j] = 1; break;
			case 'I':
				target[i][j] = 2; break;
			}
		}
	}
	std::cout << solve() << std::endl;
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=4e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll sum[MAXn][MAXn],dp[MAXn][MAXn];
ll d[MAXn],s[MAXn];
int main(){
  IOS();
  ll n;
  cin >> n;
  REP (i,n) {
    cin >> d[i];
    if (i == 0) s[i] = d[i];
    else s[i] = s[i-1]+d[i];
  }
  REP (i,n) REP (j,i+1) sum[j][i] = s[i]-(j == 0 ?0LL:s[j-1]);
  REP (i,n) REP (j,n) dp[i][j] = INF;
  REP (i,n) dp[i][i] = d[i];

  REP1 (dis,n-1) {
    REP (l,n) {
      ll r = l+dis;
      if (r >= n) continue;
      for (ll i=l;i<r;i++) {
        dp[l][r] = min(dp[l][r],dp[l][i]+dp[i+1][r]+sum[l][r]);
      }
    }
  }

  cout << dp[0][n-1]-sum[0][n-1] << endl;
}


Measured memory_bytes: 2816
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    int A[N],B[N],C[N-1];
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(int i=0;i<N;i++){
        scanf("%d",&B[i]);
    }
    for(int i=0;i<N-1;i++){
        scanf("%d",&C[i]);
    }

    int score = B[A[0]-1];
        

    for(int i=1;i<N;i++){
        score += B[A[i]-1];
        if(A[i]==A[i-1]+1){
            score += C[A[i-1]-1];
        }
    }
    printf("%d",score);
    return 0;
}

Measured memory_bytes: 128
cn = int(input())
enm = input().split(" ")
brv = input().split(" ")
taoshita = int(0)

for i in range(0,cn):
    taoshita = taoshita + min(abs(int(brv[i])),abs(int(enm[i])))  
    enm[i] = int(enm[i]) - int(brv[i])
    if int(enm[i]) < 0:
        brv[i] = abs(int(enm[i]))
        enm[i] = 0
        if (int(enm[i+1]) - int(brv[i])) < 0:
            taoshita = taoshita + int(enm[i+1])
            enm[i+1] = 0
        if (int(enm[i+1]) - int(brv[i])) >= 0:
            enm[i+1] = int(enm[i+1]) - int(brv[i])
            taoshita = taoshita + int(brv[i])
print(taoshita)

Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <tuple>
#include <stack>
using namespace std;
typedef long long ll;

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

int lcm(int a,int b){
    return a*b/gcd(a,b);
}

int main(){
    ll a,b,d,e,m,n,o1=0,o2=0,o3=0,p,q,r,x,y,z,max1=0,ans=0,o=0,a1,b1;
    string s,t,u;
    cin>>x;
    a1=x/100;
    b1=x%100;
    
    for(ll i=0;i<50;i++){
        a=a1-i;
        b=b1+100*i;
         o=0;
        o+=b/5;
        b%=5;
        o+=b/4;
        b%=4;
        o+=b/3;
        b%=3;
        o+=b/2;
        b%=2;
        o+=b;
        if(o<=a){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
 
  int main(){
      lint n,k;
      cin>>n>>k;
      vector<lint> a(n);
      lint lo;
      rep(i,n)cin>>a[i];
      cout<<(n+k-3)/(k-1);
    
  }
  
     


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int con(string s){
  if(s=="yotta") return 24;
  if(s=="zetta") return 21;
  if(s=="exa") return 18;
  if(s=="peta") return 15;
  if(s=="tera") return 12;
  if(s=="giga") return 9;
  if(s=="mega") return 6;
  if(s=="kilo") return 3;
  if(s=="hecto") return 2;
  if(s=="deca") return 1;
  if(s=="deci") return -1;
  if(s=="centi") return -2;
  if(s=="milli") return -3;
  if(s=="micro") return -6;
  if(s=="nano") return -9;
  if(s=="pico") return -12;
  if(s=="femto") return -15;
  if(s=="ato") return -18;
  if(s=="zepto") return -21;
  if(s=="yocto") return -24;
  return 0;
}
int main(){
  int n;
  int i,j,k,x;
  cin >> n;
  while(n--){
    x=0;
    string s1="",s2="",s3="";
    cin >> s1 >> s2;
    while(con(s2)!=0) {
      x+=con(s2);
      //cout << x << endl;
      cin >> s2;
    }
    s3=s2;
    if(s1[0]=='0'){
      k=1; 
      j=0;
      while(s1[k]!='.') {
        k++;
        j++;
      }
      k++;
      while(s1[k]=='0') {
        k++;
      }
      cout << s1[k];
      if(k!=s1.size()-1){
        cout << ".";
        for(i=k+1;i<s1.size();i++) cout << s1[i];        
      }
      cout << " * 10^" << x-(k-1)+j;
      cout << " " << s3 << endl;
    }else{
      k=1;
      bool f=false;
      if(s1.size()==1) {
        f=true;
        cout << s1[0];
      }else{
        while(s1[k]!='.') {
          k++;
          if(k>=s1.size()) {
            f=true;
            break;
          }
        }
        cout << s1[0];
        if(k!=1){
          //cout << k<<endl;
          cout << ".";
          for(i=1;i<k;i++) cout << s1[i]; 
          if(f&&k<s1.size()) cout << s1[k];  
          for(i=k+1;i<s1.size();i++)cout << s1[i];   
        }else{
          cout << ".";
          for(i=k+1;i<s1.size();i++) cout << s1[i];   
        }
      }
      //cout << (int)x+(int)(s1.size()-1)  << endl;
      if(f) cout << " * 10^" << (int)x+(int)(s1.size()-1);
      else cout << " * 10^" << x+k-1;
      cout << " " << s3 << endl;
    }
     
  }
  return 0;
}

Measured memory_bytes: 1224
function knapsack(){
   var C=[];
   for(var i=0;i<=N;i++)C[i]=[];
   for(var i=0;i<=W;i++)C[0][i]=0;
   for(var i=0;i<=N;i++)C[i][0]=0;
   for(var i=1;i<=N;i++){
      for(var j=1;j<=W;j++){
         if(items[i].w<=W){
            if(items[i].v+C[i-1][j-items[i].w]>C[i-1][j]){
               C[i][j]=items[i].v+C[i-1][j-items[i].w];
            }else{
               C[i][j]=C[i-1][j];
            }
         }else{
            C[i][j]=C[i-1][j];
         }  
      }   
   }
   return C[N][W];
}    
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var NW=(Arr.shift()).split(" ").map(Number);
var N=NW[0];
var W=NW[1];
var items=[null];
for(var i=1;i<=N;i++){
   var arr=(Arr.shift()).split(" ").map(Number);
   items[i]={v:arr[0], w:arr[1]};
}
var max=knapsack();
console.log(max);

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,k;
    cin>>n>>k;
    array<ll,3> ans[n];
    if(n%2){
        for(int i=0;i<n;i++){
            if(i==0) ans[i] = {k,k+n*2-1,k+2*n+n/2};
            else if(i<=n/2) ans[i] = {k+i,k+2*n-1-i*2,k+2*n+n/2-i};
            else ans[i] = {k+i,k+2*n-i+n-i-1,k+3*n-i+n/2};
        }
        for(int i=0;i<n;i++){
            if(ans[i][0]+ans[i][1] > ans[i][2]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    else{
        for(int i=0;i<n;i++){
            if(i<n/2) ans[i] = {k+i,k+2*n-1-i-i-1,k+2*n+n/2-1-i};
            else ans[i] = {k+i,k+2*n-1-i+n-i,k+n*3-1-i+n/2};
        }
        for(int i=0;i<n;i++){
            if(ans[i][0]+ans[i][1] > ans[i][2]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << "\n";
    }
}

Measured memory_bytes: 4608
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

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

Measured memory_bytes: 256