akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	char c;
	cin>>c;
	if(c <= 'Z'){
		cout<<'A'<<endl;
	}else{
		cout<<'a'<<endl;
	}
	return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main(void)
{
	ll n, k;
	cin >> n >> k;
	ll s = 1;
	for (ll i = 0; i < n; i++) {
		s *= k;
		s %= mod;
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 3104
x,y=map(int, input().split())
import math
x1=math.ceil(x*12.5)
x2=math.ceil((x+1)*12.5)-1
y1=math.ceil(y*10)
y2=math.ceil((y+1)*10)-1
if x1>y2 or y1>x2:
	print (-1)
else:
	print (int(max(x1,y1)))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値(N)
		int numN = scan.nextInt();

		//入力値(N)
		int[] listA = new int[numN];
		int[] listB = new int[numN];
		int[] listC = new int[numN-1];

		for (int i = 0; i < numN; i++) {
			listA[i] = scan.nextInt();
		}

		for (int i = 0; i < numN; i++) {
			listB[i] = scan.nextInt();
		}

		for (int i = 0; i < numN - 1; i++) {
			listC[i] = scan.nextInt();
		}

		int sum = 0;
		for (int i = 0; i < numN; i++) {
			sum += listB[i];
		}

		int extra = 0;
		for (int i = 0; i < numN - 1; i++) {
			if (listA[i+1] - listA[i] == 1) {
				extra += listC[listA[i] - 1];
			}
		}

		System.out.println(sum + extra);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A>>B>>C;
  int N = 10*B+C;
  if(N %4 ==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}



Measured memory_bytes: 256
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

use std::cmp::Ordering;

trait BinarySearch<T> {
    fn upper_bound(&self, &T) -> usize;
    fn lower_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => low = mid + 1,
                Ordering::Greater => high = mid,
            }
        }
        low
    }

    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => low = mid + 1,
                Ordering::Equal | Ordering::Greater => high = mid,
            }
        }
        low
    }
}

fn main() {
    let _n = input!(i64);
    let mut a = input!(i64; n);
    let b = input!(i64; n);
    let mut c = input!(i64; n);

    a.sort();
    c.sort();

    let mut cnt: usize = 0;
    for x in b.iter() {
        cnt += a.lower_bound(x) * (c.len() - c.upper_bound(x));
    }
    println!("{}", cnt);
}


Measured memory_bytes: 13560
def resolve():
    n, k = map(int, input().split())
    Mod = 1000000007
    ans = 0
    for i in range(n - k + 2):
        j = i + k
        start = j * (j - 1) / 2
        final = (n * 2 - j + 1) * j / 2
        add = final - start + 1
        ans = (ans + add) % Mod
    print(int(ans))

resolve()

Measured memory_bytes: 9200
n = int(input())
A = [0]*n
B = [0]*n
C = [0]*n

A[0], B[0], C[0] = map(int, input().split())
for i in range(1, n):
  a, b, c = map(int, input().split())
  A[i] = max(B[i-1]+a, C[i-1]+a)
  B[i] = max(A[i-1]+b, C[i-1]+b)
  C[i] = max(A[i-1]+c, B[i-1]+c)
print(max(A[n-1], B[n-1], C[n-1]))

Measured memory_bytes: 14924
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

bool cmp(pii a,pii b){
	return a.S<b.S;
}

int find(vector<int> &dp,int t){
	int hi=sz(dp)-1,lo=-1;
	while(hi-lo>1){
		int m=(hi+lo)/2;
		if(dp[m]<=t) lo=m;
		else hi=m;
	}
	return hi;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int mx=0;
	int t;
	For(i,1,n){
		cin>>t;
		if(t<=mx-2){
			cout<<"No\n";
			return 0;
		}
		mx=max(mx,t);
	}
	cout<<"Yes\n";
	return 0;
}



























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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	int h,w;
	cin >> h >> w;
	string s[h];
	FOR(i,h){
		cin >> s[i];
	}

	int hor[h][w];
	FOR(i,h) FOR(j,w) hor[i][j]=0;

	FOR(i,h){
		int j=0;
		while(j < w){

			while(j< w && s[i][j]=='#') j++;
			int k=j,count=0;
			while(k < w && s[i][k]=='.') {
				k++;
				count++;
			}
			for(int l=j;l<min(k,w);l++){
			 	hor[i][l]=count;
			 	
			}
			
			j=k;
			
		}
		
	}
	
	int ver[h][w];
	FOR(i,h) FOR(j,w) ver[i][j]=0;

	FOR(i,w){
		int j=0;
		while(j < h){
			while(j < h && s[j][i]=='#') j++;
			int k=j,count=0;
			while(k < h && s[k][i]=='.') {
				k++;
				count++;
			}
			for(int l=j;l < min(k,h);l++){
			 	ver[l][i]=count;
				
			}
			j=k;
		}
	}
	int maxAns=-1;
	FOR(i,h)
		FOR(j,w)
			maxAns=max(hor[i][j]+ver[i][j]-1,maxAns);
	cout << maxAns;

	return 0;
}

Measured memory_bytes: 42480
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES":"NO");}
void Yn(bool z){cout<<(z?"Yes":"No");}
void yn(bool z){cout<<(z?"yes":"no");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  cout << (a%2&&b%2 ? "Odd" : "Even") << endl;
  return 0;
}

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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


void go(){
	string s;
	cin >> s;
	int ans=0;
	int cnt=0;
	for(int i=0;i<sz(s);i++) {
		ans=max(ans,cnt);
		if(s[i]=='R') {
			cnt++;
			ans=max(ans,cnt);
		}else {
			cnt=0;
		}
	}
	cout << ans;
}
int main(){
   fastio();
   go();

   return 0;
}




Measured memory_bytes: 3588
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
a,b=map(int,input().split())
print(max(a*b,a+b,a-b))

Measured memory_bytes: 38256
N = int(input())
A = list(map(int,input().split()))

#Bi = Ai - iなる数列Bを作成し、ソートした数列の変化点となる値をｘとする。これが、悲しさを最小値とする’ｂ’となる。
B = []
for i in range(N):
    b = A[i] -(i + 1)
    B.append(b)

B = sorted(B,reverse = False)
x = B[N//2]
ans = 0

for i in range(N):
    ans += abs(A[i]-(x + i + 1))

print(ans)

Measured memory_bytes: 26016
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

// keyを超えない最大のインデックス
func binSearch(a []int, key int) int {
	low, high := 0, len(a)
	for low < high-1 {
		mid := (low + high) / 2
		if a[mid] > key {
			high = mid
		} else {
			low = mid
		}
	}
	return low
}

func upperBound(a []int, key int) int {
	l, r := 0, len(a)-1
	for l <= r {
		mid := (l + r) / 2
		if a[mid] <= key {
			l = mid + 1
		} else {
			r = mid - 1
		}
	}
	return l
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m, k := nextInt3()
	a := nextInts(n)
	b := nextInts(m)

	sa, sb := make([]int, n+1), make([]int, m+1)
	for i := 1; i <= n; i++ {
		sa[i] = sa[i-1] + a[i-1]
	}
	for i := 1; i <= m; i++ {
		sb[i] = sb[i-1] + b[i-1]
	}

	ans := 0
	for i := 0; i <= n; i++ {
		rem := k - sa[i]
		if rem == 0 {
			ans = max(ans, i)
			continue
		} else if rem < 0 {
			continue
		}
		idx := binSearch(sb, rem)
		ans = max(ans, i+idx)
	}

	puts(ans)
}


Measured memory_bytes: 11124
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	if (a >= 0 && b <= 0 || a <= 0 && b >= 0)
		cout << "Zero" << endl;
	else if (a< 0 && b < 0) {
		if (abs(a - b) % 2 == 0)
			cout << "Negative" << endl;
		else
			cout << "Positive" << endl;
	}
	else if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	for (int i = 0; i < s.size(); i++)
		if (((i + 1) % 2 == 1 && s[i] == 'L') || ((i + 1) % 2 == 0 && s[i] == 'R')) {
			cout<<"No\n";
			return 0;
		}
	cout<<"Yes\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
const int N=360005;
int n,m;
vector<int>g[N];
double ans,f[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
void solve(int id)
{
	f[n]=0;
	for(int i=n-1;i;i--)
	{
		int du=g[i].size();
		double sum=0,ma=0;
		for(int j=0;j<g[i].size();j++)
		{
			int v=g[i][j];
			sum+=f[v];
			ma=max(ma,f[v]);
		}
		if(i==id&&du>1)
		{
			sum-=ma;
			du--;
		}
		f[i]=sum/du+1;
	}
	ans=min(ans,f[1]);
}
signed main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		g[x].push_back(y);
	}
	ans=1e9;
	for(int i=0;i<n;i++)solve(i);
	printf("%.8lf\n",ans);
}

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

int main(void) 
{
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(abs(e-a)>k) cout << ":(" << "\n";
  else cout << "Yay!" << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


class LCA:
    def __init__(self, n):
        self.edges = [[] for _ in range(n)]
        self.n = n
        self.logn = len(bin(n)[2:])
        self.parent = [[-1] * self.n for _ in range(self.logn)]
        self.depth = [0] * self.n

    def add(self, u, v):
        self.edges[u].append(v)
        self.edges[v].append(u)

    def initialize(self, root=0):
        self.dfs(root, -1, 0)
        for k in range(self.logn - 1):
            for v in range(self.n):
                p_ = self.parent[k][v]
                if p_ >= 0:
                    self.parent[k + 1][v] = self.parent[k][p_]

    def dfs(self, v, p, dep):
        self.parent[0][v] = p
        self.depth[v] = dep
        for e in self.edges[v]:
            if e != p:
                self.dfs(e, v, dep + 1)

    def get_lca(self, u, v):
        if self.depth[u] > self.depth[v]:
            u, v = v, u
        dep_diff = self.depth[v] - self.depth[u]
        for k in range(self.logn):
            if (dep_diff >> k & 1) != 0:
                v = self.parent[k][v]
        if u == v:
            return u
        for k in range(self.logn - 1, -1, -1):
            if self.parent[k][u] != self.parent[k][v]:
                u = self.parent[k][u]
                v = self.parent[k][v]
        return self.parent[0][u]


N = int(input())
lca = LCA(N)
for i in range(N):
    kc = list(map(int, input().split()))
    k = kc[0]
    for c in kc[1:]:
        lca.add(i, c)

lca.initialize()
Q = int(input())
for _ in range(Q):
    u, v = map(int, input().split())
    print(lca.get_lca(u, v))




Measured memory_bytes: 143424
n = int(input())
L = []
for i in range(n):
	L.append([int(i) for i in input().split()])

x = L[0][0]
y = L[0][1]

for i in range(n-1):
  n = max(-(-x//L[i+1][0]), -(-y//L[i+1][1]))
  x = n*L[i+1][0]
  y = n*L[i+1][1]

print(x+y)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
struct UnionFind{
    vector<int> parent;
    vector<int> rank; // tree's depth

    UnionFind(int n){
        parent.resize(n);
        rank.resize(n);
        init(n);
    }

    // initialize
    void init(int n){
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    // find root
    int find(int x){
        if(parent[x] == x){
            return x;
        }else{
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            parent[x] = y;
        }else{
            parent[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
   int n, m; cin >> n >> m;
   vector<pair<int,int>> edge(m);

   rep(i, m){
       int x, y; cin >> x >> y;
       x--, y--;
       edge[i].first = x; 
       edge[i].second = y;
    }

    int ans = 0;
    rep(i, m){
        UnionFind UF(n);
        rep(j, m){
            if(i != j) UF.unite(edge[j].first, edge[j].second);
        }
        set<int> se;
        rep(j, n){
            if(UF.parent[j] == j) se.insert(UF.parent[j]);
        }
        if(se.size() >= 2) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
//    abc155ProblemA()
    abc155ProblemB()
}

fun abc155ProblemA() {
    val (a, b, c) = readLine()!!.split(" ").map(String:: toInt)
    if ((a == b && b == c) ||
        (a != b && b != c && a != c)) {
        println("No")
    } else {
        println("Yes")
    }
}

fun abc155ProblemB() {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map(String::toInt)
    var isApproved = true
    for (a in list) {
        if (a % 2 != 0) {
            continue
        }
        if (a % 3 != 0 && a % 5 != 0) {
            isApproved = false
            break
        }
    }
    if (isApproved) {
        println("APPROVED")
    } else {
        println("DENIED")
    }
}

Measured memory_bytes: 38124
// BEGIN CUT HERE
#ifdef _MSC_VER
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <agents.h>
#else
// END CUT HERE
#include <bits/stdc++.h>
// BEGIN CUT HERE
#endif
// END CUT HERE

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;


int main(){
	int n;
	cin >> n;
	vector<int> h(n + 1), a(n + 1), d(n + 1), s(n + 1);
	rep(i, n + 1) cin >> h[i] >> a[i] >> d[i] >> s[i];

	ll ans = 0;
	ll sum = 0;
	vector<pair<int, int>> e;
	FOR(i, 1, n + 1){
		int dmg = a[i] - d[0];
		if (dmg <= 0) continue;
		if (s[i] > s[0]) ans += dmg;
		if (d[i] >= a[0]){
			cout << -1 << endl;
			return 0;
		}
		int x = a[0] - d[i];
		int turn = (h[i] + x - 1) / x;

		e.push_back(MP(dmg, turn));
		sum += dmg;
	}
	if (sum >= 2e9){
		cout << -1 << endl;
		return 0;
	}
	sort(ALL(e), [](const pair<int, int> &lhs, const pair<int, int> &rhs){return 1.*lhs.second / lhs.first < 1.*rhs.second / rhs.first; });

	for (auto p : e){
		ans += sum*p.second - p.first;
		if (ans >= h[0]){
			ans = -1;
			break;
		}
		sum -= p.first;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2260
// Oh boi here we go again
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 2e5 + 7;
const int INF = 1e9 + 7;

int a[N], b[N];
int n;

ll fact (ll x){
    if (x == 0)
        return 1;
    return x * fact(x - 1);
}

main(){
    cin >> n;
    ll s1 = 1, s2 = 1;
    for (int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++){
        int c = 0;
        for (int j = i + 1; j <= n; j++){
            if (a[j] < a[i])
                c++;
        }
        s1 += c * fact(n - i);
    }
    for (int i = 1; i <= n; i++){
        scanf("%d", &b[i]);
    }
    for (int i = 1; i <= n; i++){
        int c = 0;
        for (int j = i + 1; j <= n; j++){
            if (b[j] < b[i])
                c++;
        }
        s2 += c * fact(n - i);
    }
    cout << abs(s1 - s2);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++)
			h[i] = sc.nextInt();
		int cnt = 0;
		int max = 0;
		for (int i = N - 1; i > 0; i--) {
			if (h[i] <= h[i-1]) cnt++;
			else cnt = 0;
			max = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 51000
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005
int main(){
    int a,b,m;
    scanf("%d %d %d",&a,&b,&m);
    int x[100005],y[100005];
    int Minx=1e9+7,Miny=1e9+7;
    for(int i = 1;i<=a;i++){
        scanf("%d",&x[i]);
        Minx=min(Minx,x[i]);
    }
    for(int i = 1;i<=b;i++){
        scanf("%d",&y[i]);
        Miny=min(Miny,y[i]);
    }
    int ans=Minx+Miny;
    for(int i = 0;i<m;i++){
        int aa,bb,cc;
        scanf("%d %d %d",&aa,&bb,&cc);
        ans=min(ans,x[aa]+y[bb]-cc);
    }
    printf("%d\n",ans);
}
/*
[1,2,4,3,5,6]
concat(sorted([4,2,1]),sorted([5,3,6]))
concat(shuffle([2,1]),shuffle([2,3]))
concat(shuffle([2,1,3]),shuffle([3]))
*/

Measured memory_bytes: 1024
import hashlib

n = int(input())
s = input()


def output():
    left, right = 0, n//2+1
    while left < right-1:
        mid = (left+right)//2
        if check(mid):
            left = mid
        else:
            right = mid
    return left


def check(x):
    hashes = set()
    for i in range(n - 2*x + 1):
        hashes.add(s[i: i+x])
        if s[i+x: i+2*x] in hashes:
            return True
    return False


print(output())

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

int main(){
	int x,y,s=0;
	cin>>x>>y;
	
	if(x==3)s+=100000;
	if(x==2)s+=200000;
	if(x==1)s+=300000;
	if(y==3)s+=100000;
	if(y==2)s+=200000;
	if(y==1)s+=300000;
	if(x == y && x == 1)s+=400000;
	
	cout<<s<<'\n';
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int c=0,i,n;
    long long int a[100000],b[100000],max=0,min=1000000000;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]<0){
            c++;
            b[i]=-1*a[i];
        }else b[i]=a[i];
        if(min>b[i])min=b[i];
    }

    if(c%2){
        for(i=0;i<n;i++){
            if(a[i]<0)a[i]=-1*a[i];
            max+=a[i];
        }
        max=max-2*min;
    }else{
        for(i=0;i<n;i++){
            if(a[i]<0)a[i]*=-1;
            max+=a[i];
        }
    }
    printf("%lld\n",max);
    return 0;
}

Measured memory_bytes: 896
while True:
    n=int(input())
    x=[]
    if n==0:
        break
    else:
        for i in range(n):
            s=int(input())
            x.append(s)
        for i in range(0,10):
            a=x.count(i)
            if a==0:
                print("-")
            else:
                print("*"*a)


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

int main() {
    string s; cin >> s;

    if(s == "RRR") cout << 3 << endl;
    else if(s == "SRR" || s == "RRS") cout << 2 << endl;
    else if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int add(int, int);

int main() {
	int x, y, s, max, a;

	while (true) {
		int max = 0;
		cin >> x >> y >> s;

		if (x == 0 && y == 0 && s == 0)	break;

		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if ((add(i, x) + add(j, x)) == s) {
					a = (add(i, y) + add(j, y));
					if (a > max)	max = a;
				}
			}
		}
		cout << max << endl;
	}

	return 0;
}

int add(int a, int t) {
	return a*(100 + t)/100;
}

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

using namespace std;


int main() {

    int N, H;
    scanf("%d %d", &N, &H);

    int a[N], b[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d %d", &a[i], &b[i]);
    }

    int a_max = *max_element(a, a + N);

    sort(b, b + N, greater<int>());

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (b[i] > a_max) {
            H -= b[i];
        } else {
            break;
        }

        ans++;

        if (H <= 0) break;
    }

    while (H > 0) {
        H -= a_max;
        ans++;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1024
d,g=map(int,input().split())
P=[]
C=[]
for i in range(d):
	p,c=map(int,input().split())
	P.append(p)
	C.append(c)
v=sum(P)

for i in range(1<<d):
	t=0
	c=0
	L=[i for i in range(d)]
	for j in range(d):
		if i&(2**j):
			L.remove(j)
			t+=(j+1)*100*P[j]+C[j]
			c+=P[j]
	if t>=g:
		v=min(v,c)
	else:
		if L:
			s=max(L)
			for k in range(P[s]-1):
				t+=100*(s+1)
				c+=1
				if g<=t:
					v=min(v,c)
					break
print(v)

Measured memory_bytes: 3064
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest083-B
#  https://atcoder.jp/contests/abc080/tasks/abc080_b

def sumKeta(number):
	number2Str = str(number)
	numberLength=len(number2Str)
	thisNumberSum = 0
	ketaRange = range(0,numberLength,1)
	for i in ketaRange:
		thisNumberKeta = int(number2Str[i])
		thisNumberSum = thisNumberKeta + thisNumberSum

	return thisNumberSum


def  isThisHarshadNumber(objectNumber):
	digitSumNumber=sumKeta(objectNumber)
	modNumber = objectNumber % digitSumNumber
	if modNumber ==  0:
		answer = "Yes"
	else:
		answer = "No"
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	solution=isThisHarshadNumber(N)
	print(solution)


Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 100005

typedef struct node{
  int p,l,r;
}Node;

Node T[MAX];
int n,D[MAX];

int rec(int);
void print(int);


int c[MAX];

int main(){
  int i,j,d,num;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=-1;

  for(i=0;i<n;i++){
    scanf("%d%d",&num,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c[j]);

      T[c[j]].p=num;

      if(j==0)
	T[num].l=c[0];

      else T[c[j-1]].r=c[j];
    }
  }

  for(i=0;i<n;i++)
    D[i]=rec(i);

  for(i=0;i<n;i++)
    print(i);
  
  return 0;
}
int rec(int u){
  int d = 0;
  
  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  
  return d;
}

void print(int u){
  int i,cnt=0;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==-1) printf("root, [");
  else if (T[u].l==-1) printf("leaf, [");
  else printf("internal node, [");

  u=T[u].l;
  while(u != -1){
    if(cnt == 0)
      printf("%d",u); 
  
    else
      printf(", %d",u);
    
    u = T[u].r;
    cnt++;
  }
  printf("]\n"); 
}

Measured memory_bytes: 2564
#include <iostream>
#include <map>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
long long sum[maxn];
map<long long,int> mp;
long long c(long long n)
{
	if(n < 2)
	{
		return 0;
	}
	return n * (n - 1) / 2;
}
int main()
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		cin>>a[i];
		sum[i] = a[i] + sum[i - 1];
		mp[sum[i]]++;
	}
	long long ans = 0;
	for(map<long long,int> ::iterator iter = mp.begin();iter != mp.end(); ++iter)
	{
		if(iter->first == 0)
		{
			ans += (c(iter->second)) + (iter->second);
		}
		else
		{
			if(iter->second >= 2)
			{
				ans += c(iter->second);
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15104
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int vali = a * b;
		int rnd = 2 * a + 2 * b;
		
		System.out.println(vali + " " + rnd);
	}
}


Measured memory_bytes: 26028
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100
struct P{int x,y,t;}p[MN*2+5];
bool cmp(const P&a,const P&b){return a.x!=b.x?a.x<b.x:a.t<b.t;}
set<int> st;
set<int>::iterator it;
int main()
{
	int n=read(),i,ans=0;
	for(i=1;i<=n;++i)p[i].x=read(),p[i].y=read(),p[i].t=1;
	for(i=1;i<=n;++i)p[i+n].x=read(),p[i+n].y=read();
	sort(p+1,p+n+n+1,cmp);
	for(i=1;i<=n+n;++i)
	{
		if(p[i].t)st.insert(p[i].y);
		else
		{
			it=st.lower_bound(p[i].y);
			if(it!=st.begin())++ans,st.erase(--it);
		}
	}
	printf("%d",ans);
}

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

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		int l = Integer.parseInt(strs[2]);

		int[][] list01 = new int[n][m];
		int[][] list02 = new int[m][l];
		long[][] list03 = new long[n][l];

		for (int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			for (int j = 0; j < m; j++) {
				list01[i][j] += Integer.parseInt(str[j]);
			}
		}

		for (int i = 0; i < m; i++) {
			String[] str = br.readLine().split(" ");
			for (int j = 0; j < l; j++) {
				list02[i][j] += Integer.parseInt(str[j]);
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				for (int k = 0; k < l; k++) {
					list03[i][k] += (long) (list01[i][j] * list02[j][k]);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < (l - 1); j++) {
				System.out.print(list03[i][j] + " ");
			}
			System.out.println(list03[i][l - 1]);
		}

	}
}

Measured memory_bytes: 36512
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b, p, m, x;
  cin >> a >> b;
  p = a + b;
  m = a - b;
  x = a * b;
  if (x >= m && x >= p) cout << x;
  else if (m >= x && m >= p) cout << m;
  else cout << p;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vector<map<ll,ll>> a(n);
  for(ll i=0;i<n;i++) {
    ll tmp;
    cin >> tmp;
    while(tmp--) {
      ll x,y;
      cin >> x >> y;
      x--;
      a[i][x]=y;
    }
  }
  ll ans=0;
  for(ll i=0;i<(1<<n);i++) {
    bitset<15> bit(i);
    ll f=1;
    for(ll j=0;j<n;j++) {
      if(bit.test(j)) {
        for(auto p:a[j]) {
          if(bit.test(p.first)!=p.second) f=0;
        }
      }
    }
    if(f) ans=max(ans,(ll)bit.count());
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 10000007 //10^9+7

ll N, M;

int main() {
    cin >> N >> M;
    vector<int> A(N);
    rep(i,0,N) cin >> A[i];
    ll total = 0;
    rep(i,0,N) total += A[i];
    ll threshold = (total + 4*M -1) / (4*M);
    int ans = 0;
    rep(i,0,N) {
        if(A[i] >= threshold) {
            ans++;
        }
        if(ans == M) break;
    }

    cout << (ans == M?"Yes":"No") << endl;
    return 0;
}

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

int main() {
    int a,b,c,d; cin>>a>>b>>c>>d;
    const int low=max(a,c);
    const int high=min(b,d);
    int count=max(0,high-low);
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e18
#define EPS 1e-9
#define int long long
int fun(int wts[], int vals[], int n, int w){
    int sum_of_vals = 0LL;
    for(int i = 1; i <= n; i++){
        sum_of_vals += vals[i];
    }
    int dp[n+1][sum_of_vals+1];
    /*dp[i][j] = minimum total wt that makes value j considering the 1st i items*/

    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= sum_of_vals; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0LL;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= sum_of_vals; j++){
            if(j < vals[i]) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j], dp[i-1][j-vals[i]] + wts[i]);
        }
    }
    int maxi = 0LL;
    for(int j = 0; j <= sum_of_vals; j++){
        //cout << dp[n][j] << " ";
        if(dp[n][j] <= w){
            maxi = j;
        }
    }
    return maxi;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T=1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": ";
       int n, w;
       cin >> n >> w;
       int vals[n+1], wts[n+1];
       FOR1(i, n){
           cin >> wts[i] >> vals[i];
       }
       cout << fun(wts, vals, n, w);
		cout<<'\n';
	}
	return 0;
}


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

int main() {
  ll N = 0, M = 0;
  cin >> N >> M;
  if(N*500 >= M){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3596
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-12 20:03:51
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  char c; cin >> c;
  cout << (char)(c + 1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  long long x=stoll(s);
  int a=0;
  for(int i=0;i<s.size();i++){
    a+=(int)(s[i]-'0');
  }
  if(x%a == 0)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools as it

def main():
    N, M, Q = map(int,input().split())

    li = []
    for q in range(Q):
        li.append(list(map(int, input().split())))
    
    maxp = 0

    comb = it.combinations_with_replacement(list(range(1, M+1)), N+2)
    
    for v in comb:
        if v[0] != 1 or v[N+1] != M:
            continue
        point = 0
        for q in li:
            if v[q[1]] - v[q[0]] == q[2]:
                point += q[3]
        
        if point > maxp:
            maxp = point
    
    print(maxp)



if __name__ == '__main__':
    main()

Measured memory_bytes: 73336
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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() {
	int H, W, N;
	cin >> H >> W >> N;
	
	int high = max(H,W);
	
	int ans = (N+(high -1))/ high;
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;

int a[5000],b[5001];

int main(int argc, char const *argv[])
{
	int n;
	b[0]=0;
	while(cin>>n,n)
	{
		int ma=-5000*100000;
		for (int i = 0; i < n; ++i)
		{
			cin>>a[i];
			/*if (ma<a[i])
			{
				ma=a[i];
			}*/
		}
	 	for (int i = 0; i < n; ++i)
		{
			b[i+1]=b[i]+a[i];
		}
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 0; i+j <= n; ++j)
			{
				if(ma<b[i+j]-b[j])
				{
					ma=b[i+j]-b[j];
				}
			}
		}
		cout<<ma<<"\n";
	}
	return 0;
}

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

def solve(N: int, H: int, a: "List[int]", b: "List[int]"):
    ab = list(zip(a,b))

    max_a = 0
    for i in range(N):
        if max_a < a[i]:
            max_a = a[i]

    b_sort = sorted(ab,key=lambda x: -x[1])
    answer = 0
    Hitpoint = H

    for _,bb in b_sort:
        ## 最初高いものから刀を投げつけて、最後に切る
        if bb <= max_a:
            break

        Hitpoint -= bb
        answer += 1

        if Hitpoint <= 0:
            print(answer)
            return
    answer += math.ceil(Hitpoint/max_a)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, H, a, b)

if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin>>n;
  int sumc=1000;
  for(int i=1;i<n;i++){
    int a=i;
    int b=n-i;
    int suma=0;
    int sumb=0;
    while(a!=0){
      suma+=a%10;
      a/=10;
    }  
    while(b!=0){
      sumb+=b%10;
      b/=10;
    }
      
    sumc=min(sumc,suma+sumb);
  }
  cout<<sumc<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	cout << (n + 999) / 1000 * 1000 - n << endl;
	return 0;
}


Measured memory_bytes: 3228
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int N, K; cin >> N >> K;

    vector<int> neg, pos; 
    REP(i, N) { 
        int tmp; cin >> tmp;
        if (tmp < 0) neg.push_back(tmp); 
        else pos.push_back(tmp);
    }

    reverse(ALL(neg));
    
    int res = INF;
    FOR(i, 0, K) {
        if (i > neg.size() || K-i > pos.size()) continue;

        int n = 0, p = 0;
        if (i != 0) n = neg[i - 1];
        if (i != K) p = pos[K - i - 1];
        chmin(res, 2 * min(-n, p) + max(-n, p));
    }

    cout << res << endl;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong a,b,c,d,ans;
    cin >> a >> b >> c >> d;
    ans = a*c;
    if(ans < a*d) ans = a*d;
    if(ans < b*c) ans = b*c;
    if(ans < b*d) ans = b*d;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,w,n;
    cin >> h >> w >> n;

    int a = max(h,w);

    cout << (n+a-1)/a << endl;



}

Measured memory_bytes: 256