akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A = LIST()
A.sort()

if any(A[i]%2 == 0 for i in range(3)):
	print(0)
else:
	print(A[0]*A[1])


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

int main() 
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a == c && b == c){
    cout << "No" << endl;
  } else if(b != a && a != c && b != c){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	double D = 0, T = 0, S = 0;

	std::cin >> D >> T >> S;

	if ((D / S) <= T)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}



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

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    ans+=(n/k)*(n/k)*(n/k);
    if(k%2==0){
        ll count;
        count=(n-k/2)/k + 1;
        if(n<k/2) count=0;
        ans += count*count*count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	var d = make([]int, n)
	for i := range d {
		fmt.Scan(&d[i])
	}

	sort.Ints(d)

	num1 := d[n/2-1]
	num2 := d[n/2]
	
	fmt.Println(num2 - num1)
}


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

#define int                 long long
#define pb                  push_back
#define all(v)              v.begin(),v.end()
#define INF                 (int)1e14
#define speed               ios_base::sync_with_stdio(false);cin.tie(NULL);cout.flush()
#define MOD                 (int)(998244353)
#define fi                  first
#define se                  second
#define sq(a)               a*a
#define ld                  long double
#define Error(x)            cout<< #x << " = " << (x) <<endl;
#define Error2(a,b)         cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c)       cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d)     cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = \
                            ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define popcount            __builtin_popcountll
#define ign                 cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define PI                  acos(-1.0)

int abso(int a) { return a>0 ? a : (-a); }
int cdiv(int a,int b) { return a/b + ( (a%b) > 0 ); }
int mul(int a,int b) { int res=0; while(b){ if(b&1) res=(res+a)%MOD; a=(a+a)%MOD; b=b/2; } return res; }
int bexp(int a,int b) { int res=1; while(b){ if(b&1) res=mul(res,a); a=mul(a,a); b=b/2; } return res; }
int inv(int a) { return bexp(a,MOD-2); }

int power(int a,int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=res*a;
        a=a*a;
        b=b>>1;
    }
    return res;
}

const int N=2e5;
int dp[N][2],arr[N],n;

int gg(int idx,int pre) {
    if(idx==n) {
        return 1;
    }
    int& ans=dp[idx][pre];
    if(ans!=-1) return ans;
    if(idx==0) {
        return ans=gg(idx+1,1)|gg(idx+1,0); //Dec by 1, do nothing
    } else {
        int pnum=arr[idx-1]-pre;
        int curr=arr[idx];
        if(pnum<curr) {
            return ans=gg(idx+1,1)|gg(idx+1,0); //Try both
        } else if(pnum==curr){
            return ans=gg(idx+1,0);
        } else {
            return ans=0;
        }
    }
}

void solve() {
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    int x=gg(0,0);
    if(x) {
        cout<<"Yes\n";
    } else {
        cout<<"No\n";
    }
}

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

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int sum = 0;
    rep(i,k){
        sum += vec[i];
    }
    cout << sum << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,a,b,c,d; cin >>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    string s; cin >> s;
    bool is_res = false;
    if(c<d){
        bool is_c = true;
        bool is_d = true;
        for(int i=b;i+1<=d;i++){
            if(s[i]!='.'&&s[i+1]!='.')is_d=false;
        }
        for(int i=a;i+1<=c;i++){
            if(s[i]!='.'&&s[i+1]!='.')is_c=false;
        }
        if(is_c&&is_d)is_res = true;
    }
    else{
        //bからdまで3つマスが必要
        s=s+'#';
        for(int i=b;i<=d;i++){
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')is_res=true;
        }
    }
    
    if(is_res)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 720
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[] task=new int[3];
    for(int i=0;i<3;i++){
      task[i]=sc.nextInt();
    }
    Arrays.sort(task);
    int sum=0;
    for(int i=0;i<2;i++){
      sum+=task[i+1]-task[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 20948
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans += d[i] * d[j]

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut d: Vec<usize> = Vec::new();
    let mut a: Vec<Vec<usize>> = Vec::new();
    for _ in 0..k {
        input! {
            _d: usize,
            _a: [usize; _d]
        }

        d.push(_d);
        a.push(_a);
    }

    solve(n, k, d, a);
}

fn solve(n: usize, k: usize, d: Vec<usize>, a: Vec<Vec<usize>>) {
    let mut snuke = vec![true; n];

    for i in 0..k {
        for j in 0..d[i] {
            snuke[a[i][j] - 1] = false;
        }
    }

    let mut s = 0;
    for i in 0..n {
        if snuke[i] {
            s += 1;
        }
    }

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


Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>

using namespace std;

int cnt[500][500][2];
int ch[500][500][2];
bool used[500][500];
char s[500][500];
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int h,w;

/*void dfs(int x,int y,int wh,int b){
  if(used[x][y])return;
  used[x][y]=true;
  cnt[x][y][0]=wh;
  cnt[x][y][1]=b;
  if(s[x][y]=='.')cnt[x][y][0]++;
  else cnt[x][y][1]++;
  for(int i=0;i<4;i++){
    if(x+dx[i]<0 || x+dx[i]>=h || y+dy[i]<0 || y+dy[i]>=w)continue;
    if(used[x+dx[i]][y+dy[i]])continue;
    if(s[x+dx[i]][y+dy[i]]!=s[x][y]){
      if(s[x][y]=='.'){
        dfs(x+dx[i],y+dy[i],wh,b);
        cnt[x][y][1]+=cnt[x+dx[i]][y+dy[i]][1];
      }
      else {
        dfs(x+dx[i],y+dy[i],wh,b);
        cnt[x][y][0]+=cnt[x+dx[i]][y+dy[i]][0];
      }
      //cnt[x][y][1]+=cnt[x+dx[i]][y+dy[i]][1];
      //cnt[x][y][0]+=cnt[x+dx[i]][y+dy[i]][0];
    }
  }
}*/

long long dfs(int x, int y, int px, int py){
  used[x][y]=true;
  ch[x][y][0]=px;
  ch[x][y][1]=py;
  long long sum = 0;
  for(int i=0;i<4;i++){
    if(x+dx[i]<0 || x+dx[i]>=h || y+dy[i]<0 || y+dy[i]>=w)continue;
    if(used[x+dx[i]][y+dy[i]])continue;
    if(s[x+dx[i]][y+dy[i]]!=s[x][y]){
      if(s[x][y]=='.'){
        sum += dfs(x+dx[i],y+dy[i],px,py);
        //cnt[x][y][1]+=cnt[x+dx[i]][y+dy[i]][1];
      }
      else {
        sum += dfs(x+dx[i],y+dy[i],px,py);
        //cnt[x][y][0]+=cnt[x+dx[i]][y+dy[i]][0];
      }
      //cnt[x][y][1]+=cnt[x+dx[i]][y+dy[i]][1];
      //cnt[x][y][0]+=cnt[x+dx[i]][y+dy[i]][0];
    }
  }
  if(s[x][y]=='#')sum++;
  return sum;
}

int main(){
  long long int i,j,k,ret=0;
  cin >> h >> w;
  for(i=0;i<h;i++)for(j=0;j<w;j++)cin >> s[i][j];
  //dfs(0,0,0,0);
  for(i=0;i<h;i++)for(j=0;j<w;j++){
    if(!used[i][j])cnt[i][j][1]=dfs(i,j,i,j);
  }
  for(i=0;i<h;i++)for(j=0;j<w;j++){
    if(s[i][j]=='.')ret+=cnt[ch[i][j][0]][ch[i][j][1]][1];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int main (){
  int a, b, c;
  cin >> a >> b >> c ;
  if(a==5 && b==5 && c==7) cout << "YES" ;
  else if(a==5 && b==7 && c==5) cout << "YES" ;
  else if(a==7&& b==5 && c==5) cout << "YES" ;
  else cout << "NO" ;
}

Measured memory_bytes: 256
n, x = map(int, input().split())

print('Yes' if 1 < x < (2 * n - 1) else 'No')
if 1 < x < (2 * n - 1):
    cnt = [i for i in range(2, 2 * n - 1) if i != x]
    ans = cnt[n - 2:] + [1, x, 2 * n - 1] + cnt[:n - 2]
    print(*ans, sep='\n')


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

namespace {
template<class T>void cinc(T& c){for (auto&& e : c) cin >> e;}
template<class T>void rsort(T& c){::sort(begin(c), end(c), greater<>());}
}

int main()
{
  int n;
  cin >> n;
  valarray<int64_t> a(n), b(n), c(n);
  cinc(a);
  cinc(b);
  c = a - b;
  int ans = count_if(begin(c), end(c), [](auto e){return e < 0;});
  int64_t s = c.apply([](int64_t e){return e > 0 ? 0 : e;}).sum();
  rsort(c);
  for (int i = 0; i < n && s < 0 && c[i] > 0; i++) {
    s += c[i];
    ans++;
  }
  cout << (s < 0 ? -1 : ans) << endl;
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int CC = 1e6;
const ll INF = 1e9;

const int MAXN = 310000;
ll cnt[MAXN];
int k, n;
vector<vector<int> > vv;
vector<int> cv;


void gen(int x, int l) {
	cv.push_back(x);
	vv.push_back(cv);
	if (l <= 1) {
		cv.pop_back();
		return;
	}
	for (int i = 1; i <= k; ++i)
		gen(i, l - 1);
	cv.pop_back();
}

int main() {
	cin >> k >> n;
	if (k == 1) {
		n = (n + 1) / 2;
		for (int i = 0; i < n; ++i)
			printf("1 ");
		printf("\n");
		return 0;
	}
	if (k % 2 == 0) {
		printf("%d", k / 2);
		for (int i = 1; i < n; ++i)
			printf(" %d", k);
		printf("\n");
		return 0;
	}
	cnt[0] = 0;
	for (int i = 1; i <= n; ++i) {
		cnt[i] = min(cnt[i - 1] * k + k, INF);
	}
	for (int i = 0; i < n; ++i) {
		if (cnt[n - i - 1] > CC) {
			vv.push_back({0});
			continue;
		}
		int cur = vv.size() + cnt[n - i - 1];
		int curd = 0;
		int st = (k + 1) / 2;
		while (cur < CC && curd + st < k) {
			++curd;
			cur += cnt[n - i - 1] * 2;
		}
		for (int j = st - curd; j <= st + curd; ++j) {
			cv.clear();
			gen(j, n - i);
		}
		int cnt = vv.size();
		cnt = (cnt - 1) / 2;
		for (int j = 0; j < i; ++j)
			printf("%d ", st);
		for (int j: vv[cnt])
			printf("%d ", j);
		printf("\n");
		break;
	}
	return 0;
}




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

using namespace std;

const int MOD = 998244353;

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

long long calcInv(long long a){
    return modPow(a, MOD-2);
}

void ntt(vector<long long>& v, int inv){
    const int n = v.size();
    auto w = modPow(3, (MOD-1)/n);
    if(inv == -1) w = calcInv(w);
    int rev = 0;
    for(int i=1;i<n-1;i++){
        for(int j=n/2;j>(rev^=j);j/=2);
        if(i < rev) swap(v[i], v[rev]);
    }
    for(int m=1;m<n;m*=2){
        auto cur = 1;
        auto rot = modPow(w, n/(2*m));
        for(int i=0;i<m;i++){
            for(int j=i;j<n;j+=2*m){
                auto p = v[j];
                auto q = v[j+m] * cur % MOD;
                v[j] = (p + q) % MOD;
                v[j+m] = (p + MOD - q) % MOD;
            }
            cur = (cur * rot) % MOD;
        }
    }
}

vector<long long> convolution(const vector<long long>& a, const vector<long long>& b){
    int _n = a.size() + b.size();
    int n = 1;
    while(n < _n) n *= 2;
    vector<long long> na(n, 0), nb(n, 0);
    for(int i=0;i<a.size();i++) na[i] = a[i];
    for(int i=0;i<b.size();i++) nb[i] = b[i];
    ntt(na, 1);
    ntt(nb, 1);
    for(int i=0;i<n;i++) na[i] = na[i] * nb[i] % MOD;
    ntt(na, -1);
    auto inv = calcInv(n);
    for(int i=0;i<n;i++) na[i] = na[i] * inv % MOD;
    return na;
}

int main(){
    int N, M; cin >> N >> M;
    vector<long long> a(N), b(M);
    for(auto& t : a) cin >> t;
    for(auto& t : b) cin >> t;
    auto res = convolution(a, b);
    for(int i=0;i<N+M-1;i++) cout << res[i] << " ";
    cout << endl;
}

Measured memory_bytes: 27744
# include "iostream"
# include "cstdio"

using namespace std;

char B;

int main(){
	B=getchar();
	switch(B){
		case 'A':
			putchar('T');
			break;
		case 'T':
			putchar('A');
			break;
		case 'G':
			putchar('C');
			break;
		case 'C':
			putchar('G');
			break;
	}
	return 0;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


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


const int MOD = 1000000007;

//////////////////////////////////////////


int a, b;

void Input() {

    cin >> a >> b;
}

void Solve() {

    if(a - (2*b) < 0) cout << 0;
    else cout << a - (2*b);
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();
  return 0;

}



Measured memory_bytes: 256
def check_evens_divisible_3and5(A):
  for val in A:
    if val%2==0:
      if (val%3 != 0) and (val%5 != 0): return "DENIED"
  return "APPROVED"

N = int(input())
A = map(int, input().split())

print(check_evens_divisible_3and5(A))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int N, M;
        cin >> N;
        vector<string> b(N);
        for (int i = 0; i < N; i++)
        {
                cin >> b[i];
        }

        cin >> M;
        vector<string> r(M);
        for (int i = 0; i < M; i++)
        {
                cin >> r[i];
        }

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
                int cb = 0, cr = 0;
                for (int j = 0; j < N; j++)
                {
                        if (b[i] == b[j])
                        {
                                cb++;
                        }
                }
                for (int j = 0; j < M; j++)
                {
                        if (b[i] == r[j])
                        {
                                cr++;
                        }
                }
                ans = max(ans, cb - cr);
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	long long n;
	long long x[5];
	cin >> n;
	rep(i, 5)cin >> x[i];



	cout << (n - 1) / *min_element(x, x + 5) + 5 << endl;



	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    if(a > b) cout << "Alice" << endl;
    else if(a < b) cout << "Bob" << endl;
    else if(a == b) cout << "Draw" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int INF = 1e9;
using P = pair<int,int>;

int main(){
  int h, w, k, sx, sy;
  cin >> h >> w >> k;
  char a[h][w];
  rep(i,h) {
    rep(j,w) {
      cin >> a[i][j];
      if(a[i][j] == 'S') {
        sx = i; sy = j;
      }
    }
  }
  int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
  vector<vector<int>> dps(h,vector<int>(w,INF));
  dps[sx][sy] = 0;
  queue<P> que;
  que.push(P(sx,sy));
  while(!que.empty()) {
    P p = que.front();
    que.pop();
    rep(i,4) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(nx >= 0 && nx < h && ny >= 0 && ny < w && a[nx][ny] == '.') {
        int d = dps[p.first][p.second] + 1;
        if(dps[nx][ny] > d) {
          dps[nx][ny] = d;
          if(d < k) que.push(P(nx,ny));
        }
      }
    }
  }
  vector<vector<int>> dp(h,vector<int>(w,INF));
  rep(i,h) {
    rep(j,w) {
      if(dps[i][j] <= k) {
        dp[i][j] = 0;
        que.push(P(i,j));
      }
    }
  }
  while(!que.empty()) {
    P p = que.front();
    que.pop();
    rep(i,4) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(nx >= 0 && nx < h && ny >= 0 && ny < w) {
        int d = dp[p.first][p.second] + 1;
        if(dp[nx][ny] > d) {
          dp[nx][ny] = d;
          que.push(P(nx,ny));
        }
      }
    }   
  }
  int ans = INF;
  rep(i,h) ans = min(ans,min(dp[i][0],dp[i][w-1]));
  rep(j,w) ans = min(ans,min(dp[0][j],dp[h-1][j]));
  cout << 1 + (ans+k-1)/k << endl;
  return 0;
}

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

using namespace std;
 
int main() {
	int n; cin >> n;
	vector<int> a(n);
	long long sum = 0;
	for (int i = 0; i < n; ++i)
		cin >> a[i], sum += a[i];
	long long ans = sum;
	for (int i = 1; i < n; i+=2)
		ans -= 2*a[i];
	cout << ans;
	for (int i = 0; i < n - 1; ++i) {
		ans = 2 * a[i] - ans;
		cout << " " << ans;
	}
	cout << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;

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

	int a, b;
	string s;
	cin >> a >> s >> b;
	if(s == "+"){
		cout << a + b << endl;
	}else{
		cout << a - b << endl;
	}
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	result := 1
	for n > 0 {
		n--
		if result+k < result*2 {
			result += k
		} else {
			result *= 2
		}
	}
	fmt.Println(result)
}


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


int main(){
                                                                     

    char x, y, k;


    cin >> x >> y;


    if( x > y ) k = '>';

    else if( x == y ) k = '=';

    else k = '<';


    cout << k << endl;
    

    return 0;

    }

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

int main() {
  int N;
  int A[200];
  int result = 0;
  bool isOdd = false;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  while (!isOdd) {
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) {
        isOdd = true;
        break;
      }
      A[i] /= 2;
    }
    if (!isOdd) {
      result++;
    }
  }
  
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 10000000000000003;
 
int n,m,b[li],a[li],k,flag,t,p[li];
int cev;
string s;
map<int,int> mpp,st;
vector<int> v;
 
inline int mul(int x,int y){
	return (x%mod)*(y%mod)%mod;
}
 
inline int add(int x,int y){
	int xx=(x%mod);
	int yy=(y%mod);
	if(x+y>=mod)return x+y-mod;
	return x+y;
}
 
main(void){
	fio();
	cin>>n>>s;
	//~ int n=(int)s.size();
	int bas=1;
	int son=(n)/2;
	//~ cout<<ort<<endl;
	p[0]=1;
	for(int i=1;i<=n;i++){
		p[i]=mul(p[i-1],37);
	}
	while(bas<=son){
		cev=0;
		flag=0;
		mpp.clear();
		for(int i=0;i<ort;i++){
			cev=add(cev,mul(p[ort-i-1],(s[i]-'a'+1)));
		}
		st[cev]=ort-1;
		mpp[cev]=1;
		//~ if(ort==3)cout<<cev<<endl;
		for(int i=ort;i<n;i++){
			cev=add(cev-mul(p[ort-1],(s[i-ort]-'a'+1)),mod);
			cev=mul(cev,37);
			cev=add(cev,s[i]-'a'+1);
			if(mpp[cev]==0)st[cev]=i;
			//~ if(ort==3)cout<<cev<<endl;
			mpp[cev]++;
			if(mpp[cev]>=2 && i-st[cev]>=ort){flag=1;break;}
		}
		if(flag==1){bas=ort+1;}
		else son=ort-1;
	}
	cout<<max(son,0ll)<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main(){
  int n,i,now,count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&now);
    while(now%2!=1){
      now/=2;
      count++;
    }
  }
  printf("%d",count);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include <cmath>
using namespace std;
int a, b, c;
int main() {
    cin >> a >> b >> c;
    if(a==b) cout << c << endl;
    if(b==c) cout << a << endl;
    if(a==c) cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=210;
int T,n;
ll a[maxn],b[70],x;
char s[maxn];
bool flag;
int main() {
	//freopen("1.txt","r",stdin);
	read(T);
	while (T--) {
		read(n);
		for (int i=1;i<=n;i++) read(a[i]);
		scanf("%s",s+1);
		memset(b,0,sizeof(b));
		flag=0;
		for (int i=n;i>=1;i--) {
			x=a[i];
			for (int j=63;j>=0;j--)
				if (x&(1LL<<j)) x^=b[j];
			if (s[i]=='1') {
				if (x) { flag=1; break; }
			} else {
				for (int j=63;j>=0;j--)
					if (x&(1LL<<j)) {
						b[j]^=x;
						break;
					}
			}
		}
		printf("%d\n",flag);
	}
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 3756
import math

n, d = map(int, input().split())
x = []
for i in range(n):
	xx = list(map(int, input().split()))
	x.append(xx)

cnt = 0
for i in range(n):
	for j in range(i+1,n):
		dist = 0
		for k in range(d):
			dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
		distsqrt = math.floor(math.sqrt(dist))
		if dist == distsqrt * distsqrt:
			cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	int i,j,k;
	int a,b,c;

	scanf("%d",&k);

	for(i = 0; i < k;i++)
	{
		scanf("%d",&a);	scanf("%d",&b);	scanf("%d",&c);
		if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a + b == c) or (a + c == b) or (b + c == a)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector

int main(){
    char a,b,c,d,e,f,g,h,i;cin>> a>>b>>c>>d>>e>>f>>g>>h>>i;
    cout<<a<<e<<i<<endl;
    return 0;
}


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

template <typename T>
T ext_gcd(T a, T b, T &x, T &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	T g = ext_gcd(b, a % b, x, y);
	T z = x - a / b * y;
	x = y;
	y = z;
	return g;
}

template <typename T>
T mod_rev(T a, T mod)
{
	T x, y;
	assert(ext_gcd(a, mod, x, y) == 1);
	x %= mod;
	if (x < 0)
	{
		x += mod;
	}
	return x;
}

int64_t nCr_mod(int64_t n, int64_t r, int64_t mod)
{
	if (r < 0 || n < r)
	{
		return 0;
	}

	int64_t ret = 1;
	for (int64_t i = n; (n - r) < i; i--)
	{
		(ret *= i) %= mod;
	}
	for (int64_t i = 1; i <= r; i++)
	{
		(ret *= mod_rev(i, mod)) %= mod;
	}
	return ret;
}

int main()
{
	int64_t x, y, mod = 1000000007;
	cin >> x >> y;

	if ((x + y) % 3 != 0)
	{
		cout << 0 << endl;
		return 0;
	}

	int64_t t = (x + y) / 3;

	if (x < t || y < t)
	{
		cout << 0 << endl;
		return 0;
	}

	x -= t;
	y -= t;

	cout << nCr_mod(x + y, x, mod) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String S = sc.next();
   String ans ="b";
   
   if(S.equals("a")) ans = "b";
   else if(S.equals("b")) ans = "c";
   else if(S.equals("c")) ans = "d";
   else if(S.equals("d")) ans = "e";
   else if(S.equals("e")) ans = "f";
   else if(S.equals("f")) ans = "g";
   else if(S.equals("g")) ans = "h";
   else if(S.equals("h")) ans = "i";
   else if(S.equals("i")) ans = "j";
   else if(S.equals("j")) ans = "k";
   else if(S.equals("k")) ans = "l";
   else if(S.equals("l")) ans = "m";
   else if(S.equals("m")) ans = "n";
   else if(S.equals("n")) ans = "o";
   else if(S.equals("o")) ans = "p";
   else if(S.equals("p")) ans = "q";
   else if(S.equals("q")) ans = "r";
   else if(S.equals("r")) ans = "s";
   else if(S.equals("s")) ans = "t";
   else if(S.equals("t")) ans = "u";
   else if(S.equals("u")) ans = "v";
   else if(S.equals("v")) ans = "w";
   else if(S.equals("w")) ans = "x";
   else if(S.equals("x")) ans = "y";
   else if(S.equals("y")) ans = "z";

   System.out.println(ans);
 }
}

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

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

    Int N; cin >> N;
    Int maxL = 0, sumL = 0;
    rep(i, 0, N) {
        Int L; cin >> L;
        maxL = max(maxL, L);
        sumL += L;
    }

    if (maxL < sumL-maxL) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

ll inf=(ll)2e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,k,u,v;
    ll x,a,b,c,d,y,l,p;
    cin >> n;
    vi no(5e6);
    for(int i=1; i<=100; i++){
        for(int j=1; j<=100; j++){
            for(int k=1; k<=100; k++){
                no[i*i+j*j+k*k+i*j+i*k+j*k]++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << no[i] << el;
    }
    return 0;
}


Measured memory_bytes: 22716
#include <bits/stdc++.h>
/**
AHMAD;HASSAN;SAEED
*/
using namespace std;
int n;
long long rm=1e9+7;
int cnt=0;
vector<vector<int> >adj2;
vector<vector<long long> >dp;
long long slv(int v=0,int pr=0,int prnt=-1){
    cnt++;
    int cntt=0;
    long long ret=1ll;
    if(dp[v][pr]!=-1ll)
        return dp[v][pr];
    for(int i=0;i<adj2[v].size();i++){
        if(adj2[v][i]!=prnt){
            ///cout<<v<<' '<<adj2[v][i]<<'\n';
            cntt++;
            long long ttl=0ll;
            ttl+=slv(adj2[v][i],0,v);
            ttl%=rm;
            if(pr==0)
                ttl+=slv(adj2[v][i],1,v);
            ttl%=rm;
            ret*=ttl;
            ret%=rm;

        }
    }


    return dp[v][pr]=ret;
}
int main()
{

    cin>>n;
    vector<vector<int> >adj(n);
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        x--;  y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    adj2=adj;
    dp=vector<vector<long long> >(n,vector<long long>(2,-1ll));
    cout<<(slv(0,0,-1)+slv(0,1,-1))%rm<<'\n';
    ///cout<<cnt<<'\n';
/**
10
8 5
10 8
6 5
1 5
4 8
2 10
3 6
9 2
1 7
*/
    return 0;
}


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

#include <iostream>
using namespace std;
#include <vector>



int main()
{
    
    int X, Y;
    cin >> X >> Y;
    int total_money = 0;
    int first_place_award = 300000;
    int second_place_award = 200000;
    int third_place = 100000;
    int bonus_award = 400000;
  
     
    if( Y == 1 && X == 1) {
       
        total_money = total_money + first_place_award + first_place_award + bonus_award;
       
    }
    if(Y == 1 && X != 1) {
          total_money = total_money + first_place_award;
    }
     if(X == 1 && Y != 1) {
        total_money = total_money + first_place_award;
    }
    if(X == 2){
        total_money = total_money + second_place_award;
    }
  if(Y  == 2) {
        total_money = total_money + second_place_award;
    }
    
     if(X == 3) {
        total_money = total_money + third_place;
    }
     if(Y == 3) {
        total_money = total_money + third_place;
    } else {
        total_money = total_money + 0;
    }
     cout << total_money << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
MAX_N = 10**5

# Construct factorial table
fac = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD

fac_inv = [1] + [0] * MAX_N
fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD

s = int(input())

ans = 0
for num in range(1, s+1):
    if num * 3 > s:
        continue
    rest = s - num * 3
    ans += mod_nCr(rest + num - 1, num - 1)
    ans %= MOD
print(ans)

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

struct hoge{
    string name;
    int start;
    hoge(string name, int start) : name(name), start(start){ }
};
bool operator < (const hoge &a, const hoge &b){
    return a.start < b.start;
}

int main(void){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<hoge> v;
        for(int i=0; i<n; i++){
            string name;
            int start, weekday, s;
            cin >> name >> weekday >> start;
            s=weekday*24*60+start/100*60+start%100;
            v.push_back(hoge(name, s));
        }
        sort(v.begin(), v.end());
        int p;
        cin >> p;
        bool timezone[12000], tf=true;
        fill(timezone, timezone+12000, false);
        
        for(int i=0; i<p; i++){
            string str;
            cin >> str;
            for(int j=0; j<n; j++){
                if(tf){
                    if(v[j].name==str){
                        if(!timezone[v[j].start] && !timezone[v[j].start+29]){
                            for(int t=v[j].start; t<v[j].start+30; t++){
                                timezone[t]=true;
                            }
                        }else{
                            tf=false;
                            break;
                        }
                    }
                }
            }
        }
        int count=p;
        if(! tf) cout << -1 << "\n";
        else{
            for(int i=0; i<n; i++){
                //cout << v[i].name << " time=" << v[i].start << "\n";
                if(! timezone[v[i].start] && !timezone[v[i].start+29]){
                    //cout << "OK=" << v[i].name << "\n";
                    for(int j=v[i].start; j<v[i].start+30; j++){
                        timezone[j]=true;
                    }
                    count++;
                }
            }
            cout << count << "\n";
        }
        
        
    }
    
    
    return 0;
}


Measured memory_bytes: 3076
from sys import stdin
import numpy as np
n, q = map(int, stdin.readline().rstrip().split())
s = input()
lr = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]
cum = np.array([0 for _ in range(n-1)])
for i in range(n-1):
    if s[i:i+2] == "AC":
        cum[i] = 1
cum2 = np.cumsum(cum)
for l, r in lr:
    if l == 1: print(cum2[r-2])
    else: print(cum2[r-2] - cum2[l-2])


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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

int a,b;
int main(){
	cin>>a>>b;
	
	cout<<(a+b)%24<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<string, int> P;


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

	return 0;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc083/tasks/arc088_a

import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

def main():
    X, Y = map(int, input().split())
    s = X
    ans = 0
    while s <= Y:
        ans += 1
        s *= 2
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for (int i = A; i <= B; i++) {
        string str = to_string(i);
        if (str[0] == str[4] & str[1] == str[3]) {
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            string ans="AB";
    int n;
    cin>>n;
    if(n<=999)
        ans+='C';
    else
        ans+='D';
    cout<<ans;

    }
  return 0;
  }



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    priority_queue<int> b;
    
    int a=0,roop,hp,stk;
    cin >> roop >> hp;
    for(int i=0;i<roop;i++){
        cin >> stk;
        a = max(stk,a);
        cin >> stk;
        b.push(stk);
    }
    int co = 0;
    while(hp>0){
        if(b.empty()){
            co+=(a+hp-1)/a;
            hp=-1;
        }
        else if(a<b.top()){
            hp-=b.top();
            b.pop();
            co++;
        }else{
            co+=(a+hp-1)/a;
            hp=-1;
        }
    }
    cout << co << endl;
}


Measured memory_bytes: 892
K, Q = map(int, input().split())
D = [int(a) for a in input().split()]
for _ in range(Q):
    N, X, M = map(int, input().split())
    t = X%M
    for i in range(K):
        t += ((D[i]-1) % M + 1) * ((N-i-2) // K + 1)
    print(N - 1 - t//M)

Measured memory_bytes: 47076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <sstream>
using namespace std;

#define namefile ""
#define inifile freopen(namefile".inp","r",stdin); freopen(namefile".out","w",stdout)
#define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef unsigned int uint;
typedef unsigned long ulong;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<string> VS;
typedef vector< VI > VVI;
typedef vector< VL > VVL;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;
typedef set<int> SETI;
typedef set<long> SETL;
typedef map<int,int> MII;
typedef map<long,long> MLL;

const long long MOD = 1e9+7;
const long long INFMAX = 1e9;
const long long INFMIN = -1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const double epsilon = 1e-9;
const double PI = acos(-1.00);
const int MAXN = 1e5+5;

int n,k,q,a[MAXN];

int cnttrue[MAXN];

void Input()
{
    scanf("%d %d %d",&n,&k,&q);
    for (int i=1; i<=q; i++)
    {
        scanf("%d",&a[i]);
        cnttrue[a[i]]++;
    }
}

void Solve()
{
    for (int i=1; i<=n; i++)
    {
        if (k - (q - cnttrue[i]) <= 0) cout << "No\n"; else cout << "Yes\n";
    }
}

int main()
{
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 1408
# from functools import reduce
# from math import gcd
import math

N = int(input())
result = 0
# print(sum([reduce(gcd, [i, j, k]) for i in range(1, N+1) for j in range(1, N+1) for k in range(1, N+1)]))
for i in range(1, N+1):
    for j in range(1, N+1):
        tmp = math.gcd(i, j)
        for k in range(1, N+1):
            result += math.gcd(tmp, k)

print(result)

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

int main() {
  int n,m,d; cin>>n>>m>>d;
  double res=1.0/n;
  if (d!=0) res*=2.0*(n-d)/n;
  res*=(m-1.0);
  cout<<setprecision(10)<<res<<endl;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n, m;cin>>n>>m;

	vector<int> A;

	rep(i,n){
		int tmp;cin>>tmp;
		A.push_back(tmp);
	}
	vector<pair<int,int>> bc;

	rep(i,m){
		int b,c;cin>>b>>c;

		bc.push_back(make_pair(c,b));
	}
	sort(bc.begin(),bc.end(),greater<pair<int,int>>());

	ll cnt =0;
	rep(i,m){
		pair<int,int> p = bc[i];
		cnt +=p.second;
		rep(j,p.second){
			A.push_back(p.first);
		}
		if(cnt >=n)break;
	}

	sort(A.begin(),A.end(),greater<int>());

	ll ans =0;
	rep(i,n){
		ans +=A[i];
	}
	writeln(ans);



}


Measured memory_bytes: 2288
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100;
int N, T;
int c[MAX_N], t[MAX_N];

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

  cin >> N >> T;
  rep(i, N) cin >> c[i] >> t[i];

  int ans = INFINT;
  rep(i, N) {
    if (t[i] <= T) ans = min(ans, c[i]);
  }

  if (ans == INFINT) cout << "TLE" << endl;
  else cout << ans << endl;

  return 0;

}



Measured memory_bytes: 888
#include<stdio.h>

int main(void){

    int x,y,i,j,a,b,n,dp[20][20]={0};
    int fail_a,fail_b;


    while(scanf("%d %d",&a,&b),a|b){
    scanf("%d",&n);

    i = 0;

    while(i<n){
        scanf("%d %d",&x,&y);
        dp[x-1][y-1] = -1;
        i++;
    }

    i = 0;
    fail_a = 0;
    fail_b = 0;
    while(i < a){
        j = 0;
        while(j < b){
            if(dp[i][j] == -1){
                dp[i][j] = 0;
                if(i == 0){
                    fail_a = 1;
                }else if(j == 0){
                    fail_b = 1;
                }
            }else if(i == 0 || j == 0){
                if(i == 0 && fail_a || j == 0 && fail_b)dp[i][j] = 0;
                else dp[i][j] = 1;
            }else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            j++;
        }
        i++;
    }

    printf("%d\n",dp[a-1][b-1]);
    }

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
   ll a,b,x;
   cin>>a>>b>>x;
   ll option1 = b/x;
   ll option2 = (a-1)/x;
   if(a==0){
   	cout<<option1+1<<endl;
   }else{
   	cout<<option1-option2<<endl;
   }
}


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

using namespace std;

typedef pair<int, int> P;

int main() {
  int N, M;
  while(cin >> N >> M && (N|M)) {
    P ps[N];
    for(int i=0; i<N; i++) {
      cin >> ps[i].second >> ps[i].first;
      ps[i].first = -ps[i].first;
    }

    sort(ps, ps+N);
    for(int i=0; i<N; i++) {
      ps[i].first = -ps[i].first;
    }
    
    int psum = 0;
    for(int i=0; i<N; i++) {
      if(M>ps[i].second) {
	M -= ps[i].second;
      }
      else {
	psum += -M*ps[i].first; M = 0;
	psum += ps[i].first*ps[i].second;
      }
    }
    
    cout << psum<< endl;
  }
  
  return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

int main(void){
	int x,y,z,i;

	scanf("%d %d",&x,&y);
	if (x < y){
		int t=x;
		x=y;
		y=t;
	}
	while(1){
			z=x%y;
			if(z==0) break;
			x=y;
			y=z;
	}
	printf("%d\n",y);


	return 0;

}

Measured memory_bytes: 592
//2019.5.15 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN {
    int n;
    vector<pair<int,int>> ans;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)
            for(res j=i+1;j<=n;j++)
                if(i+j!=n+(!(n&1)))ans.push_back(make_pair(i,j));
        printf("%d\n",ans.size());
        for(auto i:ans)printf("%d %d\n",i.first,i.second);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

int main() {
    lint n, m;
    cin >> n >> m;

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    lint sum = accumulate(a.begin(), a.end(), 0LL);

    if(n < sum) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }
}

Measured memory_bytes: 11176