akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 90005

struct LOC{
	void set(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W,D;
int table[305][305];
LOC loc[NUM]; //数字のある場所
vector<int> V[NUM];

int get_index(int number){

	if(number%D == 0){

		return number/D-1;

	}else{

		return number/D;
	}
}

int main(){

	scanf("%d %d %d",&H,&W,&D);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			scanf("%d",&table[row][col]);
			loc[table[row][col]].set(row,col); //数字とその位置を記録
		}
	}

	int pre,next;

	//剰余ごとに、累積和テーブルを作る
	for(int start = 1; start <= D; start++){

		pre = start;
		next = start+D;
		V[start%D].push_back(0);

		while(next <= H*W){

			V[start%D].push_back(abs(loc[pre].row-loc[next].row)+abs(loc[pre].col-loc[next].col));
			pre = next;
			next += D;
		}

		for(int i = 1; i < V[start%D].size(); i++){

			V[start%D][i] += V[start%D][i-1];
		}
	}

	int num_query;
	scanf("%d",&num_query);

	int L,R;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&L,&R);

		printf("%d\n",V[L%D][get_index(R)]-V[L%D][get_index(L)]);
	}

	return 0;
}


Measured memory_bytes: 6400
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int v;
		scanf("%d", &v);
		a[i] = (v - 1 + k) % k;
	}
	map<int, int> cnt;
	cnt[0] = 1;
	int s = 0;
	long long ans = 0;
	vector<int> pref = { 0 };
	for (int i = 0; i < n; i++) {
		int v = a[i];
		s = (s + v) % k;
		pref.push_back(s);
		int j = i + 1 - k;
		if (j >= 0) cnt[pref[j]]--;
		ans += cnt[s];
		cnt[s]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 13812
#include<iostream>
using namespace std;
int main()
{
	int k,s,ans=0;cin>>k>>s;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			int x=s-i-j;
			if(x>=0&&x<=k)ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
// https://abc098.contest.atcoder.jp/tasks/abc098_a

function parse(input) {
  return input
    .trim()
    .split(" ")
    .map(number => parseInt(number, 10))
}

function avoidNegativeZero(number) {
  return number + 0 // -0に0を足すと0になる
}

function f(a, b) {
  const sum = a + b
  const difference = a - b
  const product = a * b

  var max = sum
  max = difference > max ? difference : max
  max = product > max ? product : max

  return avoidNegativeZero(max)
}

module.exports = {
  parse,
  f,
}

function Main(input) {
  const arr = parse(input)
  const a = arr[0]
  const b = arr[1]

  console.log(f(a, b))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7496
#include <iostream>
#include <vector>
#include <string>
#include <stddef.h>
#include <algorithm>

class Dice {
private:
	std::vector<int> faces;

	void setFaces(int f1, int f2, int f3, int f4, int f5, int f6) {
		faces[0] = f1;
		faces[1] = f2;
		faces[2] = f3;
		faces[3] = f4;
		faces[4] = f5;
		faces[5] = f6;
	}
	void toTop(int idx) {
		switch (idx) {
		case 0:
			break;
		case 1:
			roll('N');
			break;
		case 2:
			roll('W');
			break;
		case 3:
			roll('E');
			break;
		case 4:
			roll('S');
			break;
		case 5:
			roll('N');
			roll('N');
			break;
		}

	}
	void rotate() {
		setFaces(faces[0], faces[3], faces[1], faces[4], faces[2], faces[5]);
	}
	bool facesEqual(Dice dice2) {
		if (faces.size() == dice2.faces.size()) {
			for (int i = 0; i < faces.size(); i++) {
				if (faces[i] != dice2.faces[i])
					return false;
			}
			return true;
		}
		else
			return false;

	}
public:
	Dice() {}
	void readInValues() {
		int val;
		faces.clear();
		for (int i = 0; i < 6; i++) {
			std::cin >> val;
			faces.push_back(val);
		}
	}

	int getTop() {
		return faces[0];
	}
	int getFront() {
		return faces[1];
	}
	int getRight() {
		return faces[2];
	}
	int getLeft() {
		return faces[3];
	}
	int getBack() {
		return faces[4];
	}
	int getBot() {
		return faces[5];
	}

	void roll(char dir) {
		switch (dir) {
		case 'N':
			setFaces(faces[1], faces[5], faces[2], faces[3], faces[0], faces[4]);
			break;
		case 'S':
			setFaces(faces[4], faces[0], faces[2], faces[3], faces[5], faces[1]);
			break;
		case 'W':
			setFaces(faces[2], faces[1], faces[5], faces[0], faces[4], faces[3]);
			break;
		case 'E':
			setFaces(faces[3], faces[1], faces[0], faces[5], faces[4], faces[2]);
			break;
		default:
			break;
		}
	}

	bool findTopFront(int top, int front) {
		ptrdiff_t top_pos = std::find(faces.begin(), faces.end(), top) - faces.begin();
		if (faces.size() > top_pos) {
			toTop(top_pos);
		}
		ptrdiff_t front_pos = std::find(faces.begin(), faces.end(), front) - faces.begin();
		if (faces.size() - 1 > front_pos) {
			while (getFront() != front) {
				rotate();
			}
		}
		else
			return false;
		return true;

	}

	bool isSame(Dice dice2) {
		std::string sequence = "NWWWN ";
		for (std::string::iterator it = sequence.begin(); it < sequence.end(); it++) {
			for (int i = 0; i < 4; i++) {
				if (facesEqual(dice2))
					return true;
				rotate();
			}
			roll(*it);
		}
		return false;
	}


};

int main()
{
	std::vector<Dice> dice;
	int diceCount;
	std::cin >> diceCount;
	bool allUnique = true;

	for (int i = 0; i < diceCount; i++) {
		Dice newDie;
		newDie.readInValues();
		for (int j = 0; j < dice.size(); j++) {
			if (dice[j].isSame(newDie)) {
				allUnique = false;
				break;
			}
		}
		dice.push_back(newDie);
	}
	if(allUnique)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}



Measured memory_bytes: 3248
#include<iostream>
#include<stdio.h>
#include<ios>
#include<cmath>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<assert.h>
#include<bitset>
#include<tuple>
#include<climits>
#include<deque>
#include<utility>
#include<unordered_map>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int           int64_t
#define double        long double
#define nitro         ios_base::sync_with_stdio(false);cin.tie(0);
#define vi            vector<int64_t>
#define pub           push_back
#define puf           push_front
#define pob           pop_back
#define pof           pop_front
#define fi            first
#define se            second
#define PI            3.1415926535897932384626433
#define linp(a)       for(auto& x : a) cin>> x
#define endl          '\n'
#define gap           ' '
#define min3(a,b,c)   min(a, min(b, c))
#define max3(a,b,c)   max(a, max(b, c))
#define MOD           10000000007
#define Y             "YES"
#define N             "NO"
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n;cin>>n;
    string s;cin>>s;
    if(s.size()<=n) cout<<s;
    else cout<<s.substr(0,n)<<"...";
    return 0;
}


Measured memory_bytes: 3656
def main():
    a, b = map(int, input().split())
    if a <= 0 <= b:
        print("Zero")
        return
    elif b < 0:
        if (b - a) % 2 == 0:
            print("Negative")
        else:
            print("Positive")
    else:
        print("Positive")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38484
def solve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())

    ans = 0
    for k in range(K):
        slicedT = T[k::K]
        dp = [[0] * 3 for i in range(len(slicedT)+1)]

        for i in range(len(slicedT)):
            for frm in range(3):
                for to in range(3):
                    if frm == to:
                        continue
                    dp[i+1][to] = max(dp[i+1][to], dp[i][frm] + calcPoint(to,
                                                                        slicedT[i],
                                                                        R,
                                                                        S,
                                                                        P ))
                    
        ans += max(*dp[-1])
    
    print(ans)

# 0 -> R, 1 -> S, 2 -> P
def calcPoint(player, opponent, R, S, P):
    if player == 0 and opponent == 's':
        return R
    if player == 1 and opponent == 'p':
        return S
    if player == 2 and opponent == 'r':
        return P
        
    return 0

if __name__ == '__main__':
    solve()


Measured memory_bytes: 60024
N = int(input())

a_list = list(map(int, input().split()))

max_num = -1
min_num = 10000000000

for i in range(N):
    num = a_list[i]
    if num > max_num:
        max_num = num
    if num < min_num:
        min_num = num

print(max_num - min_num)


Measured memory_bytes: 2940
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18
const long MOD = 1000000007;

long n, m;

std::vector<long> edge[100005];
long dist[100005];
long par[100005];

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 0; i < m; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        dist[i] = -1;
    }
    dist[1] = 0;
    std::queue<long> que;
    que.push(1);
    while(!que.empty()){
        long vis = que.front();
        que.pop();
        for(int i = 0; i < edge[vis].size(); i++){
            long nx = edge[vis][i];
            if(dist[nx] == -1){
                dist[nx] = dist[vis] + 1;
                que.push(nx);
                par[nx] = vis;
            }
        }
    }
    printf("Yes\n");
    for(long vis = 2; vis <= n; vis++){
        printf("%ld\n", par[vis]);
    }
    return 0;
}


Measured memory_bytes: 13944
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//union find木(グループわけができる)
int par[200010];
int unifind(int n) {
             for (int i = 0; i < n; i++) {
                           par[i] = i;
             }
             return 0;
}
             //木の根を求める
int unifind_root(int x) {
             if (par[x] == x) {
                           return x;
             }
             else {
                           return par[x] = unifind_root(par[x]);
             }
}
             //同じグループか判定
bool unifind_same(int x, int y) {
             return unifind_root(x) == unifind_root(y);
}
             //グループ併合
int unifind_unite(int x, int y) {
             x = unifind_root(x);
             y = unifind_root(y);
             if (x == y) {
                           return 0;
             }
             par[x] = y;
}
 

const long long int mod=1000000007;
int main(){
	cout << fixed << setprecision(18);
	long long int n,m,h,w,res=0,l,r,memo[200004][2]={};
	string str[500];
	char ch;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>str[i];
	}
	unifind(200000);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j!=0&&str[i][j-1]!=str[i][j]){
				unifind_unite(w*i+j-1,w*i+j );
			
			}
			if(i!=0&&str[i-1][j]!=str[i][j]){
				unifind_unite(w*(i-1)+j, w*i+j);
			}
			if(j!=w-1&&str[i][j+1]!=str[i][j]){
				unifind_unite(w*i+j+1, w*i+j);
			}
			if(i!=h-1&&str[i+1][j]!=str[i][j]){
				unifind_unite(w*(i+1)+j, w*i+j);
			}
		}
	}
	

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(str[i][j]=='#'){
				memo[unifind_root(w*i+j)][1]++;
				
			
			}else{
				memo[unifind_root(w*i+j)][0]++;
				
				
			}
		}
	}
	
	for(int i=0;i<w*h;i++){
		res+=memo[i][0]*memo[i][1];
	}
	cout<<res<<endl;
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
		int numbersOf = (N - 1) / 1 + 1;
		int ans = (numbersOf + 1) * numbersOf / 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include<stdio.h>

int main(void)
{
   int i,tmp;
   char a[4];

   scanf("%s",a);

   if((a[0] != a[1]) && (a[1]!=a[2]) && (a[2]!=a[0]))
     printf("Yes\n");
   else printf("No\n");

   return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>

int main() {
    while (1) {
        int s[1000] = {};
        int n, sum = 0;
        double m, a2 = 0.0;
        scanf("%d", &n);
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            scanf("%d", &s[i]);
            sum += s[i];
        }
        m = (double)sum / n;
        for (int i = 0; i < n; i++) {
            a2 += pow((s[i] - m), 2);
        }
        a2 /= n;
        a2 = sqrt(a2);
        printf("%f\n", a2);
    }
    return 0;
}


Measured memory_bytes: 2704
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def size(p):
        return (p[2]-p[0])*(p[3]-p[1])

    def cut(p,s):
        u,l,d,r = p
        x = r-l
        y = d-u
        s %= 2*(x+y)
        if s < x:
            a,b = [u,l,d,l+s], [u,l+s,d,r]
        elif s < x+y:
            s -= x
            a,b = [u,l,u+s,r], [u+s,l,d,r]
        elif s < 2*x+y:
            s -= x+y
            s = x-s
            a,b = [u,l,d,l+s],[u,l+s,d,r]
        else:
            s -= 2*x+y
            s = y-s
            a,b = [u,l,u+s,r], [u+s,l,d,r]
        if size(b) < size(a):
            a,b = b,a
        return a,b

    while 1:
        n,w,h = LI()
        if n == w == h == 0:
            break
        q = [[0,0,h,w]]
        for _ in range(n):
            i,s = LI()
            i -= 1
            p = q.pop(i)
            a,b = cut(p,s)
            q.append(a)
            q.append(b)
        s = [size(p) for p in q]
        s.sort()
        print(*s)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 6508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int m, d; scanf("%d%d", &m, &d);
	int ans = 0;
	FOR(i, 1, m+1){
		FOR(j, 1, d+1){
			if((j%10) * (j/10) == i && j%10 >= 2 && j/10 >= 2){
			 	ans++;
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl v(n, vl(3));  // v[i][j] : i日目の活動jの幸福度
    rep(i, n) {
        rep(j, 3) {
            cin >> v[i][j];
        }
    }
    
    vvl dp(n+1, vl(3));  // dp[i+1][j] : i日目に活動jをしたときのi日目までの幸福度の総和の最大値
    rep(i, n) {
        rep(j, 3) {  // i日目に活動jをしたとする
            rep(x, 3) {  // i-1日目に活動xをしたとする
                if(j != x) {
                    chmax(dp[i+1][j], dp[i][x] + v[i][j]); 
                }
            }
        }
    }

    ll ans = 0;
    rep(j, 3) {
        chmax(ans, dp[n][j]);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef unsigned long long Ull;
Ull gcd(Ull a, Ull b)
{
    return a % b == 0 ? b : gcd(b, a % b);
}
vector<Ull>Prime;
void IsPrime(Ull num)
{
	if (num < 2) return;
	else if (num == 2) {
	    Prime.push_back(num);
	    return;
	}
	else if (num % 2 == 0) return;
	for (Ull i = 3; i * i <= num; i += 2)
	{
		if (num % i == 0)
		{
			return;
		}
	}
    Prime.push_back(num);
	return;
}
int main() {
	Ull N, M; cin >> N >> M;
	Ull const X = max(N, M);
	Ull const Y = min(N, M);
	Ull const Z = gcd(X, Y);
	IsPrime(Z);
	for (Ull i = 2; i * i <= Z; i++) {
		if (Z % i == 0) {
		    IsPrime(i);
		    if (i * i != Z) IsPrime(Z / i);
		}
	}
	cout << Prime.size() + 1 << endl;
}


Measured memory_bytes: 384
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
c, d, e = 0, 0, 0
for x in p:
    if x <= a:
        c += 1
    elif x <= b:
        d += 1
    else:
        e += 1
print(min(c, d, e))


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

int main(){
	string s;
	cin >> s;
	string t;
	cin >> t;
	
	bool ans = true;
	rep(i, s.size()) {
		if (s.at(i) != t.at(i)) {
			ans = false;
			break;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ll inf=1e9;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    int n,k;
    cin>>n>>k;
    vll h(n+1);
    int i=0;
    h[0]=0;
    fwd(i,1,n)cin>>h[i];
    vll dp(n+1);
    dp.assign(dp.size(),inf);
    dp[0]=0;
    dp[1]=0;
    fwd(i,2,n){
       for(int j=i-1;j>=max(i-k,1);j--){
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
       }
    }
    cout<<dp[n]<<endl;
}






Measured memory_bytes: 1792
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++)
        os << v[i] << (i+1<v.size()?", ":"");
    os << "}";
    return os;
}

class range {
  struct Iterator {
    int val, inc;
    int operator*() {return val;}
    bool operator!=(Iterator& rhs) {return val < rhs.val;}
    void operator++() {val += inc;}
  };
  Iterator i, n;
public:
  range(int e) : i({0, 1}), n({e, 1}) {}
  range(int b, int e) : i({b, 1}), n({e, 1}) {}
  range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

static const unsigned MODVAL = 1000000007;
struct mint {
    unsigned val;
    mint():val(0){}
    mint(int      x):val(x%MODVAL) {}
    mint(unsigned x):val(x%MODVAL) {}
    mint(LL       x):val(x%MODVAL) {}
};
mint& operator+=(mint& x, mint y) { return x = x.val+y.val; }
mint& operator-=(mint& x, mint y) { return x = x.val-y.val+MODVAL; }
mint& operator*=(mint& x, mint y) { return x = LL(x.val)*y.val; }
mint operator+(mint x, mint y) { return x+=y; }
mint operator-(mint x, mint y) { return x-=y; }
mint operator*(mint x, mint y) { return x*=y; }
int main(){
    iostream_init();
    int N, L;
    while(cin >> N >> L) {
        vector<int> x(N);
        vector<int> a(N);
        REP(i, N) cin >> x[i];
        REP(i, N) cin >> a[i];
        vector<mint> dp(L);
        vector<mint> sum(L+1);
        for(int d = x[0]; d < L; d += a[0]) {
            dp[d] = 1;
            if(a[0] == 0) break;
        }
        REP(i, L){
            sum[i+1] = sum[i] + dp[i];
        }

        for(int k = 1; k < N; k++) {
            vector<mint> ndp(L);

            for(int d = x[k]; d < L; d += a[k]) {
                ndp[d] += sum[d];
                if(a[k] == 0) break;
            }

            dp.swap(ndp);
            sum[0] = 0;
            REP(i, L){
                sum[i+1] = sum[i] + dp[i];
            }
        }

        cout << sum[L].val << endl;
    }

    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 1300
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static long rec(int i, int j, int n, int[] a, long[][] dp) {
        if (dp[i][j] != Long.MAX_VALUE) {
            return dp[i][j];
        }

        int turn = n - (j - i);
        long d;
        if (turn % 2 == 0) {
            d = Math.max(rec(i + 1, j, n, a, dp) + a[i],
                    rec(i, j - 1, n, a, dp) + a[j - 1]);
        } else {
            d = Math.min(rec(i + 1, j, n, a, dp) - a[i], rec(i, j - 1, n, a, dp) - a[j - 1]);
        }

        return dp[i][j] = d;
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] a = new int[n];
        long[][] dp = new long[n + 1][n + 1];
        for (int i = 0; i < dp.length; i++) {
            Arrays.fill(dp[i], Long.MAX_VALUE);
        }

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

        for (int i = 0; i <= n; i++) {
            dp[i][i] = 0;
        }

        rec(0, n, n, a, dp);


        System.out.println(dp[0][n]);
    }
}


Measured memory_bytes: 131920
L,R=map(int,input().split())
l1=L//2019
l2=L%2019
r1=R//2019
r2=R%2019
if l1!=r1 or l2==0:
  print(0)
else:
  a = [2020]
  for i in range(l2,r2):
    for j in range(i+1,r2+1):
      c = (i*j)%2019
      a.append(c)
  print(min(a))

Measured memory_bytes: 113492
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int A, B; cin >> A >> B;
  int G = GCD(A, B);
  INTV P;
  for(int num = 1; num*num <= G; num++){
    if(G % num != 0) continue;
    int rnum = G / num;
    P.eb(num);
    if(num != rnum) P.eb(rnum);
  }
  int ans = 0;
  for(int num : P){
    if(num == 1) ans++;
    else {
      bool prime = 1;
      for(int i = 2; i*i <= num; i++){
        if(num % i == 0) prime = 0;
      }
      if(prime) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}


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 M = sc.nextInt();
    ArrayList<Integer> A = new ArrayList<Integer>();
    int sum = 0;
    for (int i = 0; i < N  ; i++) {
      int x = sc.nextInt();
      A.add(x);
      sum = sum +x;
    }
    Collections.sort(A);
    Collections.reverse(A);
    int y = (sum+(4*M)-1) / (4*M);
    // System.out.println(y);

    for (int j = 0; j < M; j++) {
      // System.out.println(A.get(j)); 
      if(y <= A.get(j)){
        // System.out.println(A.get(j));
      }else{
        System.out.println("No"); 
        return;
      }
    } 
    System.out.println("Yes"); 
    return;
  }
}



Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}

//大きい順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

//変換(文字から整数)
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}


int main(void){
    int N;
    scanf("%d",&N);
    if(N%10==3){
        printf("bon");
        return 0;
    }else if(N%10==0 ||N%10==1 ||N%10==6 ||N%10==8){
        printf("pon");
        return 0;
    }else{
        printf("hon");
    }
    
}

    




Measured memory_bytes: 1732
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2 * 1000 * 100 + 47;
const int MIN = 404;
const int MOD = INF;


VI G[MAX];


int dfs(int v, int p = -1)
{
    int g = 0;
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (to == p)continue;
        int gt = dfs(to, v);
        g ^= gt + 1;
    }
    return g;
}

int main()
{
    // freopen("in.txt", "r", stdin);
    int n, m;
    scanf("%d", &n);
    FOR(i, 0, n-1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        G[x].PB(y);
        G[y].PB(x);
    }
    if (!dfs(0))printf("Bob\n");
    else printf("Alice\n");
    
    return 0;
}





Measured memory_bytes: 12800
N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int, input().split())
    a,b=a-1,b-1
    G[a].append((b,i))
    G[b].append((a,i))

ans=[-1]*(N-1)
cmx=0
stk=[0]
while stk:
    v=stk.pop()
    cs=set()
    for to,toi in G[v]:
        if ans[toi]>=0: cs.add(ans[toi])
    c=1
    for to,toi in G[v]:
        if ans[toi]>=0: continue
        while c in cs: c+=1
        ans[toi]=c
        cmx = max(cmx, c)
        cs.add(c)
        stk.append(to)

print(cmx)
for a in ans:
    print(a)

Measured memory_bytes: 72224
use std::io::*;
use std::cmp::*;


fn zsearch(s: String) -> Vec<usize> {
    let s: Vec<char> = s.chars().collect();
    let n = s.len();
    let mut a = vec![0; n];
    let mut c = 0;
    for i in 1..n {
        if i+a[i-c] < c+a[c] {
            a[i] = a[i-c]
        }
        else {
            let mut j = max(i, c+a[c]) - i;
            while i+j < n && s[j] == s[i+j] { j += 1 }
            a[i] = j;
            c = i;
        }
    }
    a
}


fn solve(buf: String) -> usize {
    let it: Vec<&str> = buf.split_whitespace().collect();
    let n: usize = it[0].parse().unwrap();
    let s: String = it[1].parse().unwrap();

    let mut ans = 0;
    for i in 0..n {
        let a = zsearch(s[i..].to_string());
        for j in 0..a.len() {
            if a[j] <= j {
                ans = max(ans, a[j])
            }
        }
    }
    ans
}


fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    println!("{}", solve(buf));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const long long Mod=1e9+7;
long long n,a[200010],sum[200010],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=(sum[i-1]+a[i-1])%Mod;
	}
	for(int i=1;i<=n;i++)
		ans=(ans+sum[i]*a[i])%Mod;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n,a=0,ans=0;
    vector<int> f(200100);

    cin >> n;
    a = n + 1;

    for(int i=1;i<=n;i++){
        cin >> f.at(i);
        a = min(a,f.at(i));
        if(a == f.at(i)){
            ans++;
        }
    }

    cout << ans << endl;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B;
    cin >> A >> B;

    string S;
    cin >> S;

    bool ans = true;
    for(int i = 0; i < A+B-1; i++){
        if(i == A){
            if(S[i] != '-') ans = false;
        } else {
            if(S[i] == '-') ans = false;
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;

signed main(){
    int n;
    cin>>n;
    int h[114514];
    int cnt[114514]={};
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(i==0)cnt[i]=0;
        else if(h[i]<=h[i-1])cnt[i]=cnt[i-1]+1;
        else cnt[i]=0;
    }
    sort(cnt,cnt+n);
    cout<<cnt[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<utility>
using namespace std;

int p[100005];
int link[100000+5];

int find(int x){
	return x==link[x] ? x:link[x]=find(link[x]);
}

void unite(int a, int b){
	a=find(a);
	b=find(b);
	if(a==b) return;
	if(a>b) swap(a,b);
	link[b]=a;
}

int main(){
	int n,m; cin >> n >> m;
	for(int i=1;i<=n;i++) cin >> p[i];
	for(int i=1;i<=n;i++) link[i]=i;

	while(m--){
		int x,y;
		cin >> x >> y;
		unite(p[x],p[y]);
	}

	int res=0;
	for(int i=1;i<=n;i++){
		if(find(i)==find(p[i])) res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
class Dice:
    def __init__(self):
        self.dice = {'N':2, 'E':4, 'S':5, 'W':3}
        self.currTop = 1

    def top(self):
        return self.currTop

    def rot(self, direction):
        newTop = self.dice[direction]
        currTop = self.currTop
        self.currTop = newTop
        if direction == 'N':
            self.dice['N'] = 7 - currTop
            self.dice['S'] = currTop
        elif direction == 'S':
            self.dice['N'] = currTop
            self.dice['S'] = 7 - currTop
        elif direction == 'E':
            self.dice['E'] = 7 - currTop
            self.dice['W'] = currTop
        elif direction == 'W':
            self.dice['E'] = currTop
            self.dice['W'] = 7 - currTop

    def yaw(self, direction):
        newDice = {}
        if direction == 'E':
            newDice['N'] = self.dice['E']
            newDice['E'] = self.dice['S']
            newDice['S'] = self.dice['W']
            newDice['W'] = self.dice['N']
        if direction == 'W':
            newDice['N'] = self.dice['W']
            newDice['E'] = self.dice['N']
            newDice['S'] = self.dice['E']
            newDice['W'] = self.dice['S']
        self.dice = newDice

faces = list(map(int, input().split()))
q = int(input())
d = Dice()

for i in range(q):
    top, front = list(map(int, input().split()))
    topIdx = faces.index(top) + 1
    frontIdx = faces.index(front) + 1

    if d.top() != topIdx:
        # search topIdx and rotate to make topIdx top.
        key = [k for k,v in d.dice.items() if topIdx == v]
        if len(key) == 0:
            d.rot('N')
            key = [k for k,v in d.dice.items() if topIdx == v]
        d.rot(key[0])

    # rotate(yaw) to make frontIdx front.
    while True:
        if d.dice['N'] == frontIdx:
            break
        d.yaw('E')

    print(faces[d.dice['W']-1])

Measured memory_bytes: 7924
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

ll N, M, K;
vector<ll> A, B;
ll ans = 0;
/*
void dfs(ll count, ll index, ll time){
    if (time > K) return;
    if (index >= N && index >= M){
        ans = max(ans, count);
        return;
    }
    if (index < N) dfs(count+1, index+1, time+A[index]);
    if (index < M) dfs(count+1, index+1, time+B[index]);
    if (index < N && index < M) dfs(count+2, index+1, time+A[index]+ B[index]);
    dfs(count, index+1, time);

    ans = max(ans, count);

}
*/


int main(){
    cin >> N >> M >> K;
    A.assign(N,0);
    B.assign(M,0);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];
    vector<ll> A_sum(N+1,0), B_sum(M+1,0);
    
    ll a_max_index = -1;
    ll b_max_index = -1;

    for ( ll i = 0; i < N; i++){
        A_sum[i+1] = A_sum[i] + A[i];
    }
    
    //cout << ans << endl;
    for (ll i = 0; i < M; i++){
        B_sum[i+1] = B_sum[i] + B[i];
    }
    

    //cout << ans << endl;
    ll time = A_sum[a_max_index];
    ll B_index = 0;    
    rep(i,N+1){
        time = A_sum[i];
        if (time > K) continue;
        ll index = upper_bound(B_sum.begin(), B_sum.end(), K-time)-B_sum.begin()-1;
        ans = max(ans, i+index);
    }
    


    cout << ans << endl;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << a + b/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 1<<18


int main(){
	int a[N];
	int b[20];
	int m1[N];
	int m2[N];
	int n, k;
	int x, y, z;
	int max;
	scanf("%d", &n);
	n = 1 << n;
	b[0] = 1;
	f(i, 19)b[i + 1] = b[i] * 2;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	if (a[0] < a[1]){
		m1[1] = 1;
		m2[1] = 0;
	}
	else{
		m1[1] = 0;
		m2[1] = 1;
	}
	max = a[m1[1]] + a[m2[1]];
	printf("%d\n",max);

	for (int i = 2; i < n; i++){
		if (a[0] < a[i]){
			m1[i] = i;
			m2[i] = 0;
		}
		else{
			m1[i] = 0;
			m2[i] = i;
		}
		f(j, 18){
			if ((i%b[j + 1]) >= b[j]&&i!=b[j]){
				if (a[m1[i - b[j]]]>a[m1[i]]){
					m2[i] = m1[i];
					m1[i] = m1[i - b[j]];
				}
				else if (a[m1[i - b[j]]]>a[m2[i]] && m1[i - b[j]] != m1[i]){
					m2[i] = m1[i - b[j]];
				}
				if (a[m2[i - b[j]]]>a[m2[i]] && m2[i - b[j]] != m1[i]){
					m2[i] = m2[i - b[j]];
				}
			}
		}
		if (max < a[m1[i]] + a[m2[i]])max = a[m1[i]] + a[m2[i]];
		printf("%d\n",max);
	}

	return 0;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
   
int main() {
    int k,a,b;
    cin>>k>>a>>b;
    bool ans=true;
    for(int i=0;i<1000;i++){
        if(a<=k*i && k*i<=b){
        cout<<"OK";
        ans=false;
        break;
        }
    }
    if(ans) cout<<"NG";
    
}
    


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if (N%10 == 3){
    cout << "bon";
  }
  else if (N%10 == 0 || N%10 == 1 ||N%10 == 6||N%10 == 8){
    cout << "pon";
  }
  else cout << "hon";
  return 0;
}

Measured memory_bytes: 3568
#include<iostream>
using namespace std;
static const int N = 100;

int main()
{
	int M[N][N];  
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			M[i][j] = 0;
		}
	}
	int n,u,k,v;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> u >> k;
		u--;
		for(int j=0;j<k;j++){
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j) cout << " ";
			cout << M[i][j];
		}
		cout <<endl;
	}
	
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> table(N+1, 0);
    for(int i=1; i<=N; i++){
        for(int j=i; j<=N; j+=i){
            table[j]++;
        }
    }

    ll ans = 0;
    FOR(i,1,N+1){
        ans += i*table[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81396
n = int(input())
v = list(map(int, input().split()))
from collections import Counter
odd_ary = v[::2]
even_ary = v[1::2]

# 最頻値top2
oc = Counter(odd_ary).most_common(2)
ec = Counter(even_ary).most_common(2)

if len(oc) == 1:
    oc.append((0, 0))
if len(ec) == 1:
    ec.append((0, 0))

if oc[0][0] != ec[0][0]:
    print(n - (oc[0][1] + ec[0][1]))
else:
    print(n - max(oc[0][1] + ec[1][1], oc[1][1] + ec[0][1]))


Measured memory_bytes: 20776
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        if (a >= k) {
            a = a - k;
        } else {
            b = b - (k - a);
            a = 0;
        }

        if (b < 0) {
            b = 0;
        }

        // 出力
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 23764
N = int(input())
A = list(map(int, input().split()))
A.sort()
dic = {}
for nums in A:
  if nums in dic:
    dic[nums] += 1
  else:
    dic[nums] = 1
a = list(dic.keys())
b = list(dic.values())
i = 0
ans = 0
while i < len(a):
  if a[i] > b[i]:
    ans += b[i]
    i += 1
  else:
    ans += b[i]-a[i]
    i += 1
print(ans)

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

#define MAX_N 100005

long long num[MAX_N];
int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N + 1]; // is_prime[i]がtrueならiは素数
// n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return p;
}

long long Q;
long long l[100005];
long long r[100005];

int main(){
	cin >> Q;
	for(long long i = 0; i < Q; i++){
		cin >> l[i] >> r[i];
	}


	long long n = sieve(100002);
	for(long long i = 0; i < MAX_N - 2; i++){
		if(i%2 == 1 && is_prime[i] && is_prime[(i+1)/2])
			num[i+1] = num[i] + 1;
		else
			num[i+1] = num[i];
	}

	for(long long i = 0; i < Q; i++){
		cout << num[r[i] + 1] - num[l[i]] << endl;
	}


}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    vi a(n);
    read(a, n);
    ll ans = a[0];
    Fori(i, 1, n) {
        ans ^= a[i];
    }
    Fori(i, 0, n) {
        ll fin = ans ^ a[i];
        cout << fin << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include <climits>
#include<queue>
#include<vector>
#include <string.h>
#include <math.h>
#include<map>
#include<string.h>
#define ll long long
using namespace std;
ll a[60];
int main()
{
    int n,i,j;
    ll ans=0,op=0;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    bool flag=1;
    while(flag)
    {
        flag=0;
        for(i=1;i<=n;i++)
        {
            op=a[i]/n;
            if(a[i])
            {
                a[i]%=n;
                ans+=op;
            }
            for(j=1;j<=n;j++)
            {
                if(i!=j)
                {
                    a[j]+=op;
                }
            }
        }
        ll minn=0;
        for(i=1;i<=n;i++)
        {
            minn=max(minn,a[i]);
        }
        if(minn>=n)
        {
            flag=1;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	string a;
	cin >> n;
	int h=0,maxx=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i] == 'I'){
			h++;
		}
		else if(a[i] == 'D'){
			h--;
		}
		maxx=max(maxx,h);
	}
	cout << maxx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    int count = 0;

    for (int i=a; i<=b; i++){
        if (i%c == 0){
            count++;
        }
    }
    printf("%d\n", count);


    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int n=s.size();
    int a[n];
    for(int i=0;i<n;i++) a[i]=1; 
    for(int i=0;i<n-2;i++){
        if(s.at(i)=='R'&&s.at(i+1)=='R'){
            a[i+2]+=a[i];
            a[i]=0;
        }
    }
    for(int i=n-1;i>=2;i--){
        if(s.at(i)=='L'&&s.at(i-1)=='L'){
            a[i-2]+=a[i];
            a[i]=0;
        }
    }
    for(int i=0;i<n;i++) cout<<a[i]<<" ";
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int A,B,C,D;
	scanf("%d %d %d",&A,&B,&C);
	if(C-A-B<=1)
	{  	
		D=C+B;
	printf("%d",D);	
	}
	else{
		D=A+B+1+B;
		printf("%d",D);

	}
	
}

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

int main(){
  int X;
  cin >> X;
  
  if (400 <= X && X <= 599)
    cout << 8 << endl;
  else if (600 <= X && X <= 799)
    cout << 7 << endl;
  else if (800 <= X && X <= 999)
    cout << 6 << endl;
  else if (1000 <= X && X <= 1199)
    cout << 5 << endl;
  else if (1200 <= X && X <= 1399)
    cout << 4 << endl;
  else if (1400 <= X && X <= 1599)
    cout << 3 << endl;
  else if (1600 <= X && X <= 1799)
    cout << 2 << endl;
  else if (1800 <= X && X <= 1999)
    cout << 1 << endl;
}

Measured memory_bytes: 3608