akhauriyash/Code-Regression huggingface dataset:
class SWAG():
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.construct(data)
    def construct(self,data):
        self.fold_r=[self.unit]
        self.fold_l=[self.unit]
        self.data_r=[]
        self.data_l=[]
        sep=len(data)//2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep-1::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 121020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll INF=(1LL << 60);
vector<vector<ll>> dp(1001,vector<ll> (10001,INF));
int main(){
    int h,n;
    cin >> h >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    dp[0][0]=0;
    for (int i=0;i<n;i++){
        for (int j=0;j<= h;j++){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i+1][min(j+a[i],(ll)h)]=min(dp[i+1][min(j+a[i],(ll)h)],dp[i+1][j]+b[i]);
        }
    }
    //for (int i=0;i < n;i++){
    //    for (int j=0;j<=h;j++){
    //        if (dp[i][j]==INF) cout << "#" << " ";
    //        else cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    cout << dp[n][h] << endl;
    return 0;  
}


Measured memory_bytes: 78592
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    ll ans = 0;
    ans += 1000*(x/500);
    x %= 500;
    ans += 5*(x/5);
    cout << ans << endl;
    return 0;
}

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

int n,mw;
int w[100],v[100];
long long dp[101][100001];

int main(){
    cin >> n >> mw;
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    //品物iについて、選ぶか選ばないかの二択がある。
    //dp[i][j]:=i番目以降の品物で重さがj以内になるよう選ぶ時の価値の最大値　とする。
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<=mw;j++){
            if(j>=w[i]) dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            else dp[i][j] = dp[i+1][j];
        }
    }
    cout << dp[0][mw] << endl;
    return 0;
}

Measured memory_bytes: 78336
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);

public static void main(String[] args) {
	int n = s.nextInt();
	int[][] a = new int[n][n];
	StringBuilder sb = new StringBuilder();

	for(int i = 0;i < n;i++) {
		int ap = s.nextInt();
	int k = s.nextInt();
	for(int j = 1;j <= k;j++) {
		int u = s.nextInt();
		if(u <= n && u > 0) {
		a[i][u-1]++;
	}
	}
	}
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < n;j++) {
			if(j == n-1) {
				sb.append(a[i][j] + "\n");
			}else {
				sb.append(a[i][j] + " ");
			}
		}
	}
	System.out.print(sb);
	}
}



Measured memory_bytes: 30328
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int[] A;
        static long[,] dp;
        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            A = Sarray();
            var amax = A.Max();
            if(A.Sum()<K)
            {
                WriteLine(0);
                return;
            }
            dp = new long[N, K + 1];
            for (var i = 1; i < N; ++i)
                dp[i, 0] = 1;
            for (var i = 0; i <= A[0]; ++i)
                dp[0, i] = 1;
            var sum = A[0];
            for (var i = 1; i < N; ++i)
            {
                sum = Min(sum + A[i], K);
                for (var j = 1; j <= sum; ++j)
                {
                    dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    if (0 < j - A[i])
                        dp[i, j] -= dp[i - 1, j - A[i] - 1];
                    if (dp[i, j] < 0)
                        dp[i, j] += Mod;
                    dp[i, j] %= Mod;
                }
            }
            WriteLine(dp[N - 1, K]);
        }
    }
}

Measured memory_bytes: 90068
n, m = map(int, input().split())
E = [int(input()) for i in range(m)]
s = set()
E.reverse()

F = []
for e in E:
    if e in s:
        continue
    s.add(e)
    F.append(e)
for i in range(1, n+1):
    if i in s:
        continue
    F.append(i)
*_,=map(print,F)

Measured memory_bytes: 22456
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int res = 0;
	for(int i=0;i<s.length();i++) {
		if (s[i] == '+') {
			res ++;
		} else res --;
	}
	cout<<res;
}


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

int main(){
  int n,i,j,rank,s=0;
  bool card[4][13];
  for (i=0;i<4;i++){
    for (j=0;j<13;j++)card[i][j]=true;
  }
  string suit;
  cin>>n;
  for (i=0;i<n;i++){
    cin>>suit>>rank;
    if (suit=="S")card[0][rank-1]=false;
    else if (suit=="H")card[1][rank-1]=false;
    else if (suit=="C")card[2][rank-1]=false;
    else if (suit=="D")card[3][rank-1]=false;
  }
  for (i=0;i<4;i++){
    for (j=0;j<13;j++){
      if(card[i][j]){
        if (i==0)cout<<"S "<<j+1<<endl;
        else if (i==1)cout<<"H "<<j+1<<endl;
        else if (i==2)cout<<"C "<<j+1<<endl;
        else if (i==3)cout<<"D "<<j+1<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3100
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 x=sc.nextLong();
		
		long result=func(b,x)-func(a-1,x);
		
		System.out.println(result);
		
		
		sc.close();


	}

	public static long func(long n,long x) {
		
		if(n>=0) {
			return n/x+1;
		}else {
			return 0;
		}
		
	}

}



Measured memory_bytes: 23892
N = int(input())
X = list(map(int, input().split()))

Y = X.copy()
Y.sort()

med_min = Y[N//2-1]
med_max = Y[N//2]

for x in X:
    if x<= med_min:
        print(med_max)
    else:
        print(med_min)

Measured memory_bytes: 26180
#include<stdio.h>
#include<math.h>

#define ll long long int

ll array[2000 + 1][2000 + 1] = {{0}};

ll conv(int n, int k) {
  if(array[n][k] != 0) return array[n][k] % (ll)(pow(10, 9) + 7);
  if(n < k) return 0;
  if(n == k) return array[n][k] = 1;
  if(k == 0) return array[n][k] = 1;
  if(k == 1) return array[n][k] = n;
  array[n][k] = (conv(n - 1, k) % (ll)(pow(10, 9) + 7))
              + (conv(n - 1, k - 1) % (ll)(pow(10, 9) + 7));
  return array[n][k];
}

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int i;
  for(i = 1; i <= k; i++) {
    ll a = conv(n - k + 1, i) % (ll)(pow(10, 9) + 7);
    ll b = conv(k - 1, i - 1) % (ll)(pow(10, 9) + 7);
    printf("%lld\n", a * b % (ll)(pow(10, 9) + 7));
  }
  return 0;
}


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

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

  int count = 0;
  
  if( S.at(0) == S.at(1) ){
    count++;
  }else if( S.at(0) == S.at(2) ){
    count++;
  }else if( S.at(0) == S.at(3) ){
    count++;
  }
  
  if( S.at(1) == S.at(2) ){
    count++;
  }else if( S.at(1) == S.at(3) ){
    count++;
  }
  
  if( S.at(2) == S.at(3) ){
    count++;
  }
  
  if( count == 2 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
import sys
W,H,N = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
field = [[1 for _ in range(H)] for _ in range(W)]
x = [0]*N
y = [0]*N
a = [0]*N# 1 == 左の面、2 == 右, 3 == 下 4 == 下
for i in range(N):
    x[i], y[i], a[i] = [int(n) for n in input().split()]
    if(a[i] == 1):
        for k in range(x[i]):
            field[k] = [0 for _ in range(H)]
    elif(a[i] == 2):
        for k in range(x[i],W):
            field[k] = [0 for _ in range(H)]
    elif(a[i] == 3):
        for k in range(W):
            for j in range(y[i]):
                field[k][j] = 0
    elif(a[i] == 4):
        for k in range(W):
            for j in range(y[i],H):
                field[k][j] = 0
    # for k in range(W):
        # print(field[k])
ans = 0
for i in range(W):
    ans+=sum(field[i])
    # print(field[i])
print(ans)


Measured memory_bytes: 3188
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, a, b = map(int, input().split())
ans = 0
tmp = 0
ans = (n//(a+b))*a
tmp = n % (a+b)
ans += min(tmp, a)
print(ans)


Measured memory_bytes: 38768
M, K = map(int, input().split())
if (M == 1 and K == 1) or (K > 2**M-1):
  print(-1)
  exit()

arr = list(range(2**M))
if K == 0:
  print(' '.join(list(map(str, list(sorted(arr + arr))))))
  exit()

arr2 = arr[:K] + arr[K+1:]
print(' '.join(list(map(str, arr2 + [K] + arr2[::-1] + [K]))))

Measured memory_bytes: 27888
object Main {
  def main(args: Array[String]): Unit = {
    for(line <- io.Source.stdin.getLines() if line != "0 0") {
      val H = line.split(" ")(0).toInt
      val W = line.split(" ")(1).toInt

      for (i <- 0 until H) {
        println("#" * W)
      }
      println()
    }
  }
}

Measured memory_bytes: 44896
package main

import "fmt"

func main() {

	var x [5]int

	fmt.Scan(&x[0], &x[1], &x[2], &x[3], &x[4])

	for i, j := range x {
		if j == 0 {
			fmt.Println(i + 1)
			break
		}
	}

}


Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  double ans=0,x;
  string u;
  REP(i,n) {
    cin >> x >> u;
    ans += u=="JPY" ? x : x*380000;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int X, Y, Z;
	int K, S;
	long long ans;
	// get input ---------------------------------
	cin >> K >> S;
	// count -------------------------------------
	ans = 0;
	for (X = 0; X <= K; X++) {
		for (Y = 0; Y <= K; Y++) {
			Z = S - X - Y;
			if (0 <= Z && Z <= K) {
				ans++;
			}
		}
	}
	// disp answer -------------------------------
	cout << ans << endl;
	return 0;
}



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

int main(){
  int n; cin>>n;
  int a,b; cin>>a;
  bool flg=true;

  --a;
  for(int i=0; i<n-1; ++i){
    cin>>b;
    if(a<b)a=b-1;
    else if(a==b)a=b;
    else{flg=false; break;}
  }

  if(flg)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = new int[n];
        for(int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        int now = 0;
        int ans = 1;
        for(int i = 0; i < n; i++) {
            now += l[i];
            if(now <= x) ans++; 
        }
        System.out.println(ans);
    } 
}

Measured memory_bytes: 22740
#include <iostream>
#include <bits/stdc++.h> //for all of STL
#include <numeric> //for accumulate(v.begin(),v.end(),0)
// #include <algorithm>
// #include <vector>

using namespace std;
int64_t n,t,i,j,k,l,flag,c,s,m,a,b,d;
int main()
{
    //long n;
    // cout<<__builtin_popcount(num)<<endl; //for counting number of set (1) bits in a number
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    // cout.tie(NULL);
    // for faster I/O fr CP
    
    cin>>a>>b>>c>>d;
    i=0;
    while(a>0 && c>0){
        if(i%2!=0){
            a=a-d;
        }
        else{
            c=c-b;
        }
        i++;
    }
    if(a<=0){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }
return 0;
}



Measured memory_bytes: 3608
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int total = a + b + c;
    int ans = total - Math.max(Math.max(a,b),Math.max(b,c));
    System.out.println(ans);
  }
}

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

int gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> x(N);

    rep(i,N){
        cin>>x[i];
    }

    int res = abs(K-x[0]);
    for(int i=1;i<N;i++){
        int tmp = abs(K-x[i]);
        res = gcd(res,tmp);
    }
    cout<<res;
}

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

#define ll long long
#define ull unsigned long long
#define mod 998244353
#define INF 1 << 30
#define MAX 1 << 18

int solve(int src, int count, vector<vector<int>>& adj, vector<bool>& color, int* dp) {

    if(dp[src] != -1) {
        return dp[src];
    }

    int ans = MAX;

    bool flag = false;

    int tmp;

    for(auto node: adj[src]) {
        flag = true;
        if(color[node]) {
            tmp = solve(node, 0, adj, color, dp);
        } else {
            tmp = solve(node, 0, adj, color, dp);
        }

        if(color[node] || (color[node] == color[src])) {
            ans = min(ans, (count + tmp));
        } else {
            ans = min(ans, (count + tmp + 1));
        }
    }

    if(flag)
        return dp[src] = ans;

    return dp[src] = count;
}

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

    int h, w;

    cin >> h >> w;

    int n = h*w;

    vector<vector<int>> adj(n);
    vector<bool> color(n);

    char ch;

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> ch;

            int node = i*w + j;

            if(ch == '#') {
                color[node] = false;
            } else {
                color[node] = true;
            }

            if((node + 1) < n && (j+1) < w) {
                adj[node].push_back(node+1);
            }
            if((node + w) < n && (i+1) < h) {
                adj[node].push_back(node+w);
            }
        }
    }

    int dp[n];

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

    int ans;

    if(color[0]) {
        ans = solve(0, 0, adj, color, dp);
    } else {
        ans = solve(0, 1, adj, color, dp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
n, l = map(int, input().split())
val = [l + i for i in range(n)]
min_v = 100
min_i = 0

for i in range(n):
    abs_v = abs(val[i])
    if abs_v < min_v:
        min_v = abs_v
        min_i = i

print(sum(val) - val[min_i])


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

#define int long long

signed main() {
    int Q, H, S, D;
    int N;
    cin >> Q >> H >> S >> D;
    cin >> N;
    int cost1 = min({4 * Q, 2 * H, S});
    int cost2 = min(2 * cost1, D);
    int ans = N / 2 * cost2 + N % 2 * cost1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=0,S[1000];
void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}



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

ll ebob(ll a, ll b){
	if(a==0) return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a,b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, m; cin>>n>>m;
	ll arr[n];
	for(ll i = 0; i < n; i++){
		cin>>arr[i];
	}
	for(ll i = 0; i < n; i++){
		arr[i] /= 2;
	}
	ll x = 1;
	for(ll i = 0; i < n; i++){
		x = ekok(x, arr[i]);
		if(x > m){
			cout<<0;
			return 0;
		}
	}
	for(int i = 0; i < n; i++){
		if(x/arr[i] % 2 == 0){
			cout<<0; return 0;
		}
	}
	ll check = m/x;
	if(check % 2) cout<<(check+1)/2;
	else cout<<check/2;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
    char s[100] = {};
    cin >> s;

    for(int i = 0; i < 100; i++){
        if(s[i] == 'C'){
            for(int j = i; j < 100; j++){
                if(s[j] == 'F'){
                    cout << "Yes" << endl;
                    return 0;
                }
            }

        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
        for (int i=1;i<=5;i++)
        {
            ll x;
            cin>>x;
            if(x==0)
            {
                cout<<i;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
  string s = readln.chomp;

  if (s[0] != 'A') {
    writeln("WA");
    return;
  }
  if (s[2..$-1].count('C') != 1) {
    writeln("WA");
    return;
  }
  
  string po = s.toLower;
  for (int i = 0; i < s.length; i++) {
    if ((s[i] != 'A' && s[i] != 'C') && s[i] != po[i]) {
      writeln("WA");
      return;
    }
  }

  writeln("AC");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cassert>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
const int p=1000000007;
int t,tot,ans;
LL n,m,f[100][2];

LL getLL()
{
    char ch;
    while (!isdigit(ch=getchar()));
    LL x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void dfs(LL x,LL y,int k)
{
    if (!k)
    {
        ans=(ans+(m-x-y)/y+1)%p;
        if (n>=x+y)
            ans=(ans+(n-x-y)/y+1)%p;
        return;
    }
    for (LL z=x+y*((!x)+1); z<=m; z+=y)
    {
        //assert(y*f[k][0]+z*f[k][1]>0 && y*f[k-1][0]+z*f[k-1][1]>0);
        if (y*f[k][0]+z*f[k][1]>m || y*f[k-1][0]+z*f[k-1][1]>n)
            break;
        if (z!=x+y*((!x)+1) && k>1)
            dfs(y*f[k-2][0]+z*f[k-2][1],y*f[k-1][0]+z*f[k-1][1],0);
        else
            dfs(y,z,k-1);
    }
}

void solve()
{
    n=getLL(),m=getLL();
    if (n>m)
        swap(n,m);
    for (tot=0; f[tot][1]<=n && f[tot+1][1]<=m; ++tot);
    if (--tot<=1)
    {
        printf("1 %d\n",n%p*m%p);
        return;
    }
    ans=0,dfs(0,1,tot-1);
    printf("%d %d\n",tot,ans);
}

int main()
{
    f[0][1]=f[1][0]=f[1][1]=1;
    repu(i,2,90)
        f[i][0]=f[i-1][0]+f[i-2][0],f[i][1]=f[i-1][1]+f[i-2][1];
    for (scanf("%d",&t); t--; solve());
    return 0;
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
    static boolean[] bits;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x=sc.next();
        int mod=0;
        for(int i=0;i<x.length();i++){
            mod+=Integer.parseInt(x.substring(i,i+1));
        }
        System.out.println(Integer.parseInt(x)%mod==0?"Yes":"No");
  

    }
    
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define vec vector<int>
using namespace std;
int main()
{
    int N, sum = 0;

    cin >> N;
    for (int i = 1000000000; i >= 1; i /= 10)
    {
        sum += N / i % 10;
    }
    if (N % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;



int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int w = 0, n = 0;
	std::cin >> w >> n;

	std::vector<int> A(w + 1);
	std::iota(A.begin(), A.end(), 0);

	for (int i = 0; i < n; i++) {

		int a = 0, b = 0;
		std::string temp;
		std::cin >> temp;
		a = std::stoi(temp.substr(0, temp.find(',', 0)));
		b = std::stoi(temp.substr(temp.find(',', 0) + 1, temp.length()));
		std::swap(A[a], A[b]);

	}

	for (int i = 1; i <= w; i++) {
		std::cout << A[i] << std::endl;
	}

}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n >> m;
    ll arr[n+1];
    for(i = 1; i <= n; i++){
        cin >> arr[i];
    }
    vector <bool> fl(n+1,true);
    for(i = 0; i < m; i++){
        cin >> x >> y;
        if(arr[x] > arr[y]){
            fl[y] = false;
        }
        else if(arr[x] < arr[y]){
            fl[x] = false;
        }
        else{
            fl[x] = false;
            fl[y] = false;
        }
    }
    for(i = 1; i <= n; i++){
        if(fl[i]){
            sum++;
        }
    }
    cout << sum;

    return 0;
}


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

string decode_string( const string& input )
{
	string res = input;

	for ( string::iterator it = res.begin(); it != res.end(); it++ )
	{
		*it = (*it) - 3;
		if ( *it < 'A' )
		{
			*it = 'Z' - ( 'A' - (*it) - 1 );
		}
	}

	return res;
}

int main( void )
{
	string in;
	cin >> in;

	string decoded = decode_string( in );
	cout << decoded << endl;

	return 0;
}

Measured memory_bytes: 0
import sys

def main():
    H,W,K=map(int,input().split())
    gyou=[]
    retu_index=[]
    retu=[0 for _ in range(W)]
    black=0
    for i in range(H):
        s=input()
        gyou.append(s.count("#"))
        tmp=[]
        for j in range(W):
            if s[j]=="#":
                retu[j]+=1
                black+=1
                tmp.append(j)
        retu_index.append(tmp)

    p=black-K
    if p<0:
        print(0)
        sys.exit()


    gyou.extend(retu)
    matrix=gyou

    res=0
    for i in range(pow(2,H+W)):
        n=0
        matrix_=matrix[:]
        for j in range(H+W):
            if (i & (1<<j))!=0:
                if j<H:
                    for k in retu_index[j]:
                        matrix_[H+k]-=1
                n+=matrix_[j]

        if n==p:
            res+=1
    print(res)


if __name__=="__main__":
    main()

Measured memory_bytes: 68312
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int b,w;
    cin>>b>>w;
    mod_build(2*b+2*w);
    ll white=0,black=0;
    rep(i,b+w){
        white+=comb(i-1,w-1)*powmod(inv[2],i);
        black+=comb(i-1,b-1)*powmod(inv[2],i);
        white%=mod;
        black%=mod;
        ll ans=white+(2*mod+1-black-white)*inv[2]%mod;
        cout<<ans%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 11520
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int MAX_N=55;
const int MAX_L=35;
ll ans=inf;
int n,len[MAX_N];
ll c[MAX_N],dp[MAX_N][MAX_L][2];
char s[MAX_N][MAX_L];
ll dfs(int id,int pos,int dir)
{
	if(pos>len[id]) return dp[id][pos][dir]=0;
	if(~dp[id][pos][dir]) return dp[id][pos][dir];
	ll &tmp=dp[id][pos][dir];
	tmp=inf;
	bool flag=true;
	if(!dir){ for(int st=pos,ed=len[id];st<ed;st++,ed--)if(s[id][st]!=s[id][ed]){ flag=false; break; } } 	
	else{ for(int st=pos,ed=1;st>ed;st--,ed++)if(s[id][st]!=s[id][ed]){ flag=false; break; } } 
	if(flag) return dp[id][pos][dir]=0;
	repi(i,1,n){
		flag=true;
		int j,k;
		if(!dir){
			for(j=pos,k=len[i];j<=len[id]&&k>=1;j++,k--)if(s[id][j]!=s[i][k]){ flag=false; break; }
			if(flag){
				if(k<1) tmp=min(tmp,c[i]+dfs(id,j,0));
				else tmp=min(tmp,c[i]+dfs(i,k,1));
			} 
		}
		else{
			for(j=pos,k=1;j>=1&&k<=len[i];j--,k++)if(s[id][j]!=s[i][k]){ flag=false; break; }
			if(flag){
				if(j<1) tmp=min(tmp,c[i]+dfs(i,k,0));
				else tmp=min(tmp,c[i]+dfs(id,j,1));
			}
		}
	}
	return tmp;
}
int main()
{
	si(n); memset(dp,-1,sizeof(dp));
	repi(i,1,n) ss(s[i]+1),sl(c[i]),len[i]=strlen(s[i]+1);
	repi(i,1,n) ans=min(ans,c[i]+dfs(i,1,0));
	printf("%lld\n",(ans==inf)?-1:ans);
	return 0;
}


Measured memory_bytes: 3840
import math
n = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break
  
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
p[3::2] = [0 for x in range(3,r,2)]
for i in range(2,sqrt,2):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)] 
  
for i in n:
     print sum(p[:i])

Measured memory_bytes: 37108
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;

int const Max_N = 1e6+5;

vector<int>Head[Max_N];
bool vis[Max_N]; 
int d1[Max_N];
int d2[Max_N];

void dfs1(int u)
{
	vis[u] = true;
	for(int i = 0; i < Head[u].sz; ++i)
	{
		int v = Head[u][i];
		if(vis[v]) continue;
		d1[v] = d1[u] + 1;
		dfs1(v);
	}	
}

void dfs2(int u)
{
	vis[u] = true;
	for(int i = 0; i < Head[u].sz; ++i)
	{
		int v = Head[u][i];
		if(vis[v]) continue;
		d2[v] = d2[u] + 1;
		dfs2(v);
	}	
}



int n;



int main()
{
	cin >> n;
	rep(i,1,n)
	{
		int u,v;
		cin >> u >> v;
		Head[u].pb(v);
		Head[v].pb(u);
	} 
	mem0(d1);
	mem0(d2);
	d1[1] = 1;
	d2[n] = 1;
	mem0(vis); 
	dfs1(1);//黑先手
	mem0(vis);
	dfs2(n);
//	cout << "d1 n " << d1[n] << endl;
	int t = (d1[n]+1)/2;
	
	queue<int>que;
	int ans = 0;
	mem0(vis);
	vis[1] = true;
//	rep(i,1,n+1) cout << d1[i] << (i == n?'\n':' ');
//	rep(i,1,n+1) cout << d2[i] << (i == n?'\n':' '); 
	que.ph(1);
//	cout << "t =  " << t << endl;
	while(que.sz)
	{
		int u = que.front();
	//	cout << u << endl;
		++ans;
		que.pop();
		for(int i = 0; i < Head[u].sz;++i)
		{
			int v = Head[u][i];
			if(vis[v]||(d1[v] > t&&(d1[v]+d2[v] == d1[1] + d2[1]))) continue;
			
			vis[v] = true;
			que.ph(v);
		}
	}
	if(ans>n-ans) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
//	cout << ans << endl;
	
	return 0;
}
	//freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);



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

#define int long long
#define endl '\n'

struct dsu {
    int connected;
    vector<int> par, siz;

    dsu(int n) {
        init(n);
    }

    void init(int n) {
        connected = n;
        par.resize(n + 1);
        siz.resize(n + 1);
        for (int i = 1; i <= n; i++) {   
            par[i] = i;
            siz[i] = 1;
        }
    }

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

    int size(int x) {
        return siz[find(x)];
    }

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

    void merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)  return;
        connected--;
        if (siz[x] < siz[y])   swap(x, y);
        par[y] = x;
        siz[x] += siz[y];
        siz[y] = 0;
    }
};

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<pair<int, int>> edges(m);
    for (auto &i: edges)    cin >> i.first >> i.second;
    int res = n * (n - 1) / 2;
    vector<int> ans(m, 0);
    dsu d(n);
    for (int i = m - 1; i >= 0; i--) {
        ans[i] = res;
        int x = edges[i].first, y = edges[i].second;
        if (d.same(x, y))   continue;
        res -= d.size(x) * d.size(y);
        d.merge(x, y);
    }
    for (auto i: ans)   cout << i << endl;
}


Measured memory_bytes: 5248
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 300000;

int n, a[N], l[N], r[N], t[N];

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> t[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++)
	{
		l[i] = 1;
		r[i] = 1e9;
	}

	for (int i = 1; i <= n; i++)
	{
		if (t[i] != t[i - 1])
		{
			l[i] = max(l[i], t[i]);
			r[i] = min(r[i], t[i]);
		}
		else
		{
			r[i] = min(r[i], t[i]);
		}
	}
	for (int i = n; i; --i)
	{
		if (a[i] != a[i + 1])
		{
			l[i] = max(l[i], a[i]);
			r[i] = min(r[i], a[i]);
		}
		else
		{
			r[i] = min(r[i], a[i]);
		}
	}

	long long ans = 1;
	for (int i = 1; i <= n; i++)
	{
		//cout << l[i] << "%" << r[i] << endl;

		if (l[i] > r[i])
		{
			ans = 0;
		}
		else
		{
			ans = ans*(r[i] - l[i] + 1) % bs;
		}
	}
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1792
def lcm(a, b)
  x = a * b
  a, b = b, a if a < b

  r = a % b
  until r.zero?
    a = b
    b = r
    r = a % b
  end
  x / b
end

def anti_division(a, b, c, d)
  c_div1 = (a - 1) / c
  c_div2 = b / c
  d_div1 = (a - 1) / d
  d_div2 = b / d

  lcm = lcm(c, d)
  l_div1 = (a - 1) / lcm
  l_div2 = b / lcm

  c_count = c_div2 - c_div1
  d_count = d_div2 - d_div1
  l_count = l_div2 - l_div1

  b - (a - 1) - c_count - d_count + l_count
end

a, b, c, d = gets.split.map(&:to_i)
puts anti_division(a, b, c, d)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int i=1;
	while(a>0  && c>0 ){
		if(i%2)
			c-=b;
		else
			a-=d;

		i++;
	}

	if(a<=0){
		cout<<"No"<<endl;
	}
	else
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i) 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod = 1e9;
const int N = 1e5+10;
/*=======================================================================*/

int n;
int a[N], b[N], c[N];
// ll ab, ac, ba, bc, ca, cb;
ll aa, bb, cc;
ll ans = 0;

int main() {
   scanf("%d", &n);
   for1(i, n) {
      scanf("%d%d%d", &a[i], &b[i], &c[i]);
   }
   for1(i, n) {
      if(i == 1) {
         aa += a[i];
         bb += b[i];
         cc += c[i];
      } else {
         int ta = aa, tb = bb, tc = cc;
         aa = max(tb + a[i], tc + a[i]);
         bb = max(ta + b[i], tc + b[i]);
         cc = max(ta + c[i], tb + c[i]);
      }
   }
   ans = max(ans, aa);
   ans = max(ans, cc);
   ans = max(ans, bb);
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll N=in<ll>(),M=in<ll>();
	ll sum = 0;
	map<ll,ll> T;
	T.insert(make_pair(0,1));
	REP(i,N){
		sum += in<ll>();
		ll val = sum%M;
		if(T.find(val)==T.end()){
			T.insert(make_pair(val,1));
		}
		else{
			T[val]++;
		}
	}
	
	ll num = 0;
	for(auto& x:T){
		num += (x.second*(x.second-1))/2;
	}
	cout << num <<endl;
	return 0;
}


Measured memory_bytes: 4224
// B - TAKOYAKI FESTIVAL 2019
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi D(N);
	rp(i, 0, N) cin>>D[i];
	int ans = 0;
	rp(i, 0, N-1) rp(j, i+1, N) ans += D[i] * D[j];
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
  int i;
  char s[102];
  int l;

  scanf("%s",s);
  l=strlen(s);

  for(i=0;i<l;i++){
    printf("x");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-6;
long long dp[2003][2003],pref[2003][2003];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int> a(n+1),b(m+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>b[i];
    dp[0][0]=pref[0][0]=1;
    for(int i=1;i<=n;i++)
        pref[i][0]=1;
    for(int i=1;i<=m;i++)
        pref[0][i]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            dp[i][j]=(a[i]==b[j]?pref[i-1][j-1]:0),
            pref[i][j]=(pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+dp[i][j]+MOD)%MOD;
    cout<<pref[n][m];
    return 0;
}



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

using namespace std;

typedef long long ll;

const int N = 5e5 + 5;
const ll mod = 1e9 + 7;

ll f[N], inv[N];

ll bigmod(ll x, ll y) {
  ll res = 1;
  while(y) {
    if(y & 1) res = (res * x) % mod;
    y >>= 1;
    x = (x * x) % mod;
  }
  return res;
}

void work() {
  f[0] = 1;
  for(int i = 1; i < N; i++) {
    f[i] = (f[i - 1] * i) % mod;
  }
  inv[N - 1] = bigmod(f[N - 1], mod - 2);
  for(int i = N - 2; i >= 0; i--) {
    inv[i] = (inv[i + 1] * (i + 1)) % mod;
  }
}

ll comb(ll n, ll r) {
  if(n + r - 2 < r - 1 or r - 1 < 0) return 0;
  ll up = (f[n + r - 2]);
  ll down = (inv[n - 1] * inv[r - 1]) % mod;
  return (up * down) % mod;
}

int main() {
  work();
  ll h, w, a, b; cin >> h >> w >> a >> b;
  ll ways = 0;
  for(ll c = b + 1; c <= w; c++) {
    ways = (ways + (comb(h - a, c) % mod * comb(a, w - c + 1) % mod)) % mod;
  }
  cout << ways << '\n';
}

Measured memory_bytes: 8192
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: usize = it.next().unwrap().parse().unwrap();
    let a: usize = it.next().unwrap().parse().unwrap();
    let ans = (h + a - 1) / a;
    println!("{}", ans);
}

fn main() {
    run();
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<ll>>nabct(n+1, vector<ll>(5,0));
	for (int i = 0; i < n; i++) cin >> nabct.at(i+1).at(0);
	nabct.at(0).at(4) = 1;
	for (int i = 1; i < n + 1; i++) {
		ll m = 0;
		if (nabct.at(i).at(0) == nabct.at(i - 1).at(1))m++;
		if (nabct.at(i).at(0) == nabct.at(i - 1).at(2))m++;
		if (nabct.at(i).at(0) == nabct.at(i - 1).at(3))m++;
		nabct.at(i).at(4) = nabct.at(i - 1).at(4) * m;
		nabct.at(i).at(4) %= 1000000007;
		if (nabct.at(i).at(0) == nabct.at(i - 1).at(1)) {
			nabct.at(i).at(1) = nabct.at(i - 1).at(1) + 1;
			nabct.at(i).at(2) = nabct.at(i - 1).at(2);
			nabct.at(i).at(3) = nabct.at(i - 1).at(3);
		}
		else if (nabct.at(i).at(0) == nabct.at(i - 1).at(2)) {
			nabct.at(i).at(2) = nabct.at(i - 1).at(2) + 1;
			nabct.at(i).at(1) = nabct.at(i - 1).at(1);
			nabct.at(i).at(3) = nabct.at(i - 1).at(3);
		}
		else if (nabct.at(i).at(0) == nabct.at(i - 1).at(3)) {
			nabct.at(i).at(3) = nabct.at(i - 1).at(3) + 1;
			nabct.at(i).at(2) = nabct.at(i - 1).at(2);
			nabct.at(i).at(1) = nabct.at(i - 1).at(1);
		}
	}
	cout << nabct.at(n).at(4) << endl;

}

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

int main(){
  int a, b;
  cin >> a >> b;
  int M=10*b;
  int cnt=0;
  rep(i,10){
    if(floor((M+0.0)*0.08)==a){
      cout << M;
      return 0;
    }
    M++;
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 3652
X=int(input())
N=int(-0.5+(0.25+2*X)**0.5)

for k in range(N+2):
    if 0.5*N*(N-1)<X<=0.5*N*(N+1):
        print(N)
        break
    N+=1

'''
count=0
x=[[0]]
for k in range(0,1000000):
    if X in x[k]:
        print(k)
        break
    x.append(list(set(x[k])))
    for j in range(len(x[k])):
        x[k+1].append(x[k][j]+k+1)
        x[k+1].append(x[k][j]-k-1)
    x[k+1]=list(set(x[k+1]))
'''

Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int H,W; cin>>H>>W;
    int N; cin>>N;
    vector<int>a(N);
    rep(i,N)cin>>a[i];
    vector<int>st(H*W);
    vector<vector<int>>ans(H,vector<int>(W));
    int cnt=1;
    int c=0;
    rep(i,N){
        rep(j,a[i]){
            st[c]=cnt;
            c++;
        }
        cnt++;
    }
    cnt=0;
    rep(i,H){
        rep(j,W){
            ans[i][j]=st[cnt];
            cnt++;
        }
    }
    rep(i,H-1){
        if(ans[i][W-1]==ans[i+1][0]){
            reverse(ans[i+1].begin(),ans[i+1].end());
        }
    }
    rep(i,H){
        rep(j,W){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}




Measured memory_bytes: 384
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
	let cin = stdin();
	let cin = cin.lock();
	let mut sc = Scanner::new(cin);
        let (a,b): (usize, usize) = (sc.read(), sc.read());
        if a+b == 15 {
            println!("+");
        } else if a*b == 15 {
            println!("*");
        } else {
            println!("x");
        }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
        cin >> a.at(i);

    vector<int> log;
    map<int, int> mp;
    vector<int> junkan;
    int position = 1;
    mp[position]++;
    int to_junkan_length = 0;
    bool is_junkan = false;
    rep(i, 3 * n)
    {
        int next_position = a.at(position - 1);
        log.push_back(position);
        mp[next_position]++;
        if (is_junkan == false)
        {
            to_junkan_length++;
        }
        if (mp[next_position] == 2)
        {
            is_junkan = true;
            junkan.push_back(next_position);
        }
        position = next_position;
    }

    to_junkan_length -= (int)junkan.size();

    if (k <= to_junkan_length)
    {
        cout << log.at(k) << endl;
    }
    else
    {
        cout << junkan.at((k - to_junkan_length) % ((int)junkan.size())) << endl;
    }
}

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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin >> n;
    unsigned ll ans;
    rep(i, n){
        ll x; cin >> x;
        if(i==0) ans = x;
        else{
            ans = ans/gcd(x, ans) *x;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#include <vector>
#include <limits>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)


void solve() {
    string s;
    cin >> s;
    int ch['Z' - 'A'] = {};
    FOR(i, 0, 4) {
        ch[s[i] - 'A']++;
    };
    int fifty = 0;
    for(int cnt : ch) {
        if (cnt == 2) {
            fifty++;
        }
    }
    cout << (fifty == 2 ? "Yes" : "No") << endl;

}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
struct edge{
    int v,len,cost;
    edge(int _v,int _len,int _cost):v(_v),len(_len),cost(_cost){}
};
vector<edge> adjList[10005];
priority_queue<pii,vector<pii>,greater<pii> > pq;
int N,M;

int Dijkstra(int s)
{
    int dist[10005];
    int path[10005];//????????????,path[u]=v := u?????????????????????v??°??????
    int cost[10005];//cost[v] := ????????????v???????????????,??°???v?????±???????¶????
    memset(dist,0x3f3f,sizeof(dist));
    dist[s] = 0;
    pq.push(make_pair(0,s));
    while(!pq.empty()){
        int d = pq.top().first;
        int u = pq.top().second;
        pq.pop();
        for(int j=0;j<adjList[u].size();j++){
            edge e = adjList[u][j];
            if(dist[u]+e.len < dist[e.v]){
                dist[e.v] = dist[u]+e.len;
                cost[e.v] = e.cost;
                pq.push(make_pair(dist[e.v],e.v));
            }
            if(dist[u]+e.len == dist[e.v])
                cost[e.v] = min(cost[e.v],e.cost);
        }
    }
    int sum = 0;
    for(int i=2;i<=N;i++){
        sum += cost[i];
    }
    return sum;
}


int main()
{   
    // freopen("in","r",stdin);
    
    while(scanf("%d%d",&N,&M)&&(N+M)){
        for(int i=0;i<=N;i++) adjList[i].clear();
        int u,v,d,c;
        for(int i=0;i<M;i++){
            scanf("%d%d%d%d",&u,&v,&d,&c);
            adjList[u].push_back(edge(v,d,c));
            adjList[v].push_back(edge(u,d,c));
        }
        int ans = Dijkstra(1);
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 3152