akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

#define for(i, n) for(int i = 0; i < n; i++)

void func(int &a, int &b){
	if(a % 2 == 1){
		a--;
	}
	b += a / 2;
	a /= 2;
}

int main(){

	int a, b, k;
	cin >> a >> b >> k;

	bool turn = true;

	for(i, k){
		if(turn){
			func(a, b);
		}
		else{
			func(b, a);
		}
		turn = !turn;
	}

	out(a);
	out(b);

	return 0;
}

Measured memory_bytes: 256
// ABC052 B - Increment Decrement
'use strict'

function Main(input) {
    const tmp = input.trim().split('\n');
    const N = Number(tmp[0])
    const S = tmp[1].split('')
    // console.log(N, S);

    let result = 0;
    let x = 0;
    for (const v of S) {
        if (v === 'I') {
            x++;
        } else if (v === 'D') {
            x--;
        }
        if (x > result) {
            result = x;
        }
    }
    
    console.log(result);
}

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

Measured memory_bytes: 7372
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<Integer>();
		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()) {
			Integer input = scan.nextInt();
			if(input == 0) {
				System.out.println(stack.pop());
			}else {
				stack.push(input);
			}
		}
		scan.close();

	}

}


Measured memory_bytes: 25992
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string O, E;
  cin >> O >> E;
  
  for (int i = 0; i < O.size() + E.size(); i++)
  {
    if (i % 2 == 0) cout << O.at(i / 2);
    else cout << E.at(i / 2);
  }
  cout << endl;
}

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

namespace AOJ1_9_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string str = Console.ReadLine();
                if (str == "-") break;
                int n= int.Parse(Console.ReadLine());
                string H;
                int h;
                for (int i = 0; i<n; i++)
                {
                    H = Console.ReadLine();
                    h = int.Parse(H);
                    //if (h == str.Length - 1)
                        str = str.Substring(h) + str.Substring(0, h);
                    //else
                    //    str = str.Substring(h) + str.Substring(0, h);//0~h-1のh個
                }
                Console.WriteLine(str);
            }
        }
    }
}




Measured memory_bytes: 15932
#include<bits/stdc++.h>
#define ll long long 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 
#define pb push_back 
#define mp make_pair 
#define P(a,b) pair<a,b> 
#define M(a,b) map<a,b> 
#define V(i) vector<i> 

using namespace std;

//int _mergeSort(int arr[], int temp[], int left, int right); 
//int merge(int arr[], int temp[], int left, int mid, int right); 
//  
///* This function sorts the input array and returns the  
//number of inversions in the array */
//int mergeSort(int arr[], int array_size) 
//{ 
//    int temp[array_size]; 
//    return _mergeSort(arr, temp, 0, array_size - 1); 
//} 
//  
///* An auxiliary recursive function that sorts the input array and  
//returns the number of inversions in the array. */
//int _mergeSort(int arr[], int temp[], int left, int right) 
//{ 
//    int mid, inv_count = 0; 
//    if (right > left) { 
//        /* Divide the array into two parts and  
//        call _mergeSortAndCountInv()  
//        for each of the parts */
//        mid = (right + left) / 2; 
//  
//        /* Inversion count will be sum of  
//        inversions in left-part, right-part  
//        and number of inversions in merging */
//        inv_count += _mergeSort(arr, temp, left, mid); 
//        inv_count += _mergeSort(arr, temp, mid + 1, right); 
//  
//        /*Merge the two parts*/
//        inv_count += merge(arr, temp, left, mid + 1, right); 
//    } 
//    return inv_count; 
//} 
//  
///* This funt merges two sorted arrays  
//and returns inversion count in the arrays.*/
//int merge(int arr[], int temp[], int left, 
//          int mid, int right) 
//{ 
//    int i, j, k; 
//    int inv_count = 0; 
//  
//    i = left; /* i is index for left subarray*/
//    j = mid; /* j is index for right subarray*/
//    k = left; /* k is index for resultant merged subarray*/
//    while ((i <= mid - 1) && (j <= right)) { 
//        if (arr[i] <= arr[j]) { 
//            temp[k++] = arr[i++]; 
//        } 
//        else { 
//            temp[k++] = arr[j++]; 
//  
//            /* this is tricky -- see above  
//            explanation/diagram for merge()*/
//            inv_count = inv_count + (mid - i); 
//        } 
//    } 
//  
//    /* Copy the remaining elements of left subarray  
//(if there are any) to temp*/
//    while (i <= mid - 1) 
//        temp[k++] = arr[i++]; 
//  
//    /* Copy the remaining elements of right subarray  
//(if there are any) to temp*/
//    while (j <= right) 
//        temp[k++] = arr[j++]; 
//  
//    /*Copy back the merged elements to original array*/
//    for (i = left; i <= right; i++) 
//        arr[i] = temp[i]; 
//  
//    return inv_count; 
////} 
//	int ans = mergeSort(arr, n);
//	cout<<ans<<"\n"; 

void test(){
	int n;
	cin>>n;
	ll a[10][10];
	memset(a,0,sizeof(a));
	fr(i,1,n+1){
		string s=to_string(i);
		a[s[0]-'0'][i%10]++;
	}
	ll count=0;
	f(i,10){
		f(j,10){
			count+=(a[i][j]*a[j][i]);
		}
	}
	cout<<count<<"\n";
}

int main(){
	int t=1;
//	cin>>t;
	while(t-->0){
		test();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, k;
    cin >> n >> k;

    int ans = 0;

    while(n > 0){
        ans++;
        n /= k;
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0511

#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

//テ」ツδ榲」ツつッテ」ツδュテ・ツョツ堙ァツセツゥ
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//テ・ツョツ堙ヲツ閉ー
#define INF 2000000000000
#define MAX 10

//DEBUGテァツ板ィ
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

vector<int> cards;

void kcut(int k){
	vector<int> a;
	vector<int> b;
	
	REP(i, 0, k){
		a.push_back(cards[i]);
	}
	
	REP(i, k, cards.size()){
		b.push_back(cards[i]);
	}
	
	cards.clear();
	
	rep(i, b.size()){
		cards.push_back(b[i]);
	}
	
	rep(i, a.size()){
		cards.push_back(a[i]);
	}
	return;
}

void riffle(){
	vector<int> tmp;
	int n=cards.size()/2;
	
	rep(i, n)
	{
		tmp.push_back(cards[i]);
		
		if(i+n > cards.size()){
			// Do Nothing...
		}else{
			tmp.push_back(cards[i+n]);
		}
	}
	
	cards.clear();
	rep(i, tmp.size()){
		cards.push_back(tmp[i]);
	}
}

int main()
{
	int n=0;
	int m=0;
	cin >> n;
	cin >> m;
	
	REP(i,1,2*n+1){
		cards.push_back(i);
	}
	
	//PRINT(cards);
	
	int k;
	int count=0;
	while(count < m)
	{
		cin >> k;
		if(k == 0){
			riffle();
		}else{
			kcut(k);
		}
		count++;
	}
	
	//PRINT(cards);
	rep(i,cards.size()){
		cout << cards[i] << endl;
	}
	
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    cin >> a >> b;
    cout << (ll)((a + b) / 2.0 + 0.9) << endl;
}


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

int main(){
  double w,h,area;
  int x,y;
  cin>>w>>h>>x>>y;
  
  if(x==w/2&&y==h/2){
   
    area=w*h/2;
    cout<<area<<" " <<1<<endl;
  }
  
  else{

    area=w*h/2;
  cout<<area<<" "<<0<<endl;
      
  }
}

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

int main(){

    int n;
    cin >> n;
    vector<long long int> a(n+1), b(n);

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

    long long int ans = 0;

    for(int i = 0; i < n; ++i){
        if(b[i] > a[i]){
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }else {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        } 

        if(b[i] > a[i+1]){
            ans += a[i+1];
            a[i+1] = 0;
        }else{
            ans += b[i];
            a[i+1] -= b[i];
        }
    }

    cout << ans << endl;    

}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<vector<int>> G(N+1, vector<int> (N+1,0));
  for(int i=0; i<M; i++){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    G[l][r]++;
  }
  vector<vector<int>> S(N+1, vector<int> (N+1,0));
  for(int i=0; i<N; i++){
    for(int j=i; j<N; j++){
      S[i][j+1] = S[i][j] + G[i][j];
    }
  }
  for(int i=0; i<Q; i++){
    int p,q;
    cin >> p >> q;
    p--;
    q--;
    int sum = 0;
    for(int j=p; j<=q; j++){
      sum += S[j][q+1];
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
ll vis[1000007];
bool a[1000007];
bool m[1000007];
#define d 1000000
main()
{
   ll n,i,cnt=0,j;
   scanf("%lld",&n);
   ll ara[n+1];
   for(i=1;i<=n;i++)
   {
       scanf("%lld",&ara[i]);
       //ara[i]=1000000;
       vis[ara[i]]++;
   }
   vector<ll>v;
   for(i=1;i<=n;i++)
   {
       if(m[ara[i]]==0)
       {
           v.push_back(ara[i]);
           m[ara[i]]=1;
       }
   }
   //cout<<v.size()<<endl;
   for(i=0;i<v.size();i++)
   {

       for(j=2*v[i];j<=d;j+=v[i])
       {
           a[j]=1;
       }
   }
   for(i=1;i<=n;i++)
   {
       //cout<<vis[ara[i]]<<" "<<a[ara[i]]<<endl;
       if(vis[ara[i]]>=2)
       {
           continue;
       }
       if(a[ara[i]]==1)
       {
           continue;
       }
       cnt++;
   }
   printf("%lld\n",cnt);
}



Measured memory_bytes: 16148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 300010
ll n,a[N];
int main(){
 cin>>n;
 for(int i=0;i<n;i++)cin>>a[i];
 ll cnt=0;
 for(int i=0;i<n-1;i++){
  cnt+=(a[i]<=a[i+1]);   
 }
 ll q,x,y;
 cin>>q;
 ll ans=1e17;
 for(ll i=0;i<q;i++){
     if(cnt==n-1){
      ans=min(ans,i);   
     }
     cin>>x>>y; x--,y--;
     unordered_set<ll> s;
     if(x>0)s.insert(x-1);
     if(x+1<n)s.insert(x);
     if(y>0)s.insert(y-1);
     if(y+1<n)s.insert(y);
     for(auto t:s){
      cnt-=(a[t]<=a[t+1]);   
     }
     swap(a[x],a[y]);
     for(auto t:s){
      cnt+=(a[t]<=a[t+1]);   
     }
 }
 if(cnt==n-1)ans=min(ans,q);
 if(ans==1e17)ans=-1;
 cout<<ans<<endl;
 return 0;   
}


Measured memory_bytes: 5468
from functools import reduce

n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

pattern = []
for i in range(2 ** 10):
    temp = [0] * 10
    for j in range(10):
        if (i >> j) & 1:
            temp[j] = 1
    pattern.append(temp)
pattern.remove([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

ans = -10 ** 10
for i in range(len(pattern)):
    my_store = pattern[i]
    profit = 0
    for j in range(n):
        same_open = [x & y for (x, y) in zip(pattern[i], f[j])]
        profit += p[j][sum(same_open)]
    ans = max(ans, profit)

print(ans)


Measured memory_bytes: 3684
import sys
n,m = map(int,input().split())

if abs(n-m) >= 2:
    print(0)
    sys.exit()

if abs(n-m) == 1:
    x = max(n,m)
    for i in range(1,min(n,m)+1):
        x = x*i**2 % (10**9 + 7)

else:
    x = 2
    for i in range(1,n+1):
        x = x*i**2 % (10**9 + 7)
print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


#define INF 10000000

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

	int n, m, i, j, k, a, b, s, t, d;
	cin >> n >> m;
	vector<vector<int>> adj(n + 1);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
	}
	cin >> s >> t;

	vector<vector<int>> dp(n + 1, vector<int>(3, INF));
	dp[s][0] = 0;
	queue<pair<int, int>> q;
	q.push({ s, 0 });
	while (!q.empty()) {
		a = q.front().first;
		b = q.front().second;
		q.pop();

		d = dp[a][b];
		b = (b + 1) % 3;
		for (auto p : adj[a]) {
			if (dp[p][b] > d + 1) {
				dp[p][b] = d + 1;
				q.push({ p, b });
			}
		}
	}

	if (dp[t][0] == INF) cout << "-1\n";
	else cout << dp[t][0] / 3 << "\n";


	return 0;
}


Measured memory_bytes: 11264
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools





def main():
    a, b = map(int, input().split())

    if b == 1:
        print(0)
        sys.exit()

    ans = 1 + math.ceil((b - a) / (a - 1))
    print(ans)





if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
fun main(args:Array<String>) {
    val (n,x) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map { it.toInt() }

    var pos = 0
    for(i in (0..list.size)) {
        if(i == 0) {
            continue
        }
        val newPos = pos + list[i-1]
        if(newPos > x) {
            println(i)
            return
        }
        pos = newPos
    }
    println(n + 1)
}


Measured memory_bytes: 36032
import sys

input = sys.stdin.readline


def main():
    K, Q = map(int, input().split())
    D = list(map(int, input().split()))

    for _ in range(Q):
        n, x, m = map(int, input().split())
        md = [D[i] % m for i in range(K)]
        smda = 0
        mda0 = 0
        for i in range((n - 1) % K):
            if md[i] == 0:
                mda0 += 1
            smda += md[i]
        smd = smda
        md0 = mda0
        for i in range((n - 1) % K, K):
            if md[i] == 0:
                md0 += 1
            smd += md[i]
        roop = (n - 1) // K
        res = n - 1 - (x % m + sum(md) * roop + smda) // m - md0 * roop - mda0
        print(res)


main()


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> pf(N + 1, 0);
    for (int i = 2; i <= N; i++) {
        int x = i;
        for (int j = 2; j <= x; j++) {
            while (x % j == 0) {
                pf[j]++;
                x /= j;
            }
        }
    }
    ll ans = 1, MOD = 1e9 + 7;
    rep(i, N + 1) {
        //cout << pf[i] << " ";
        ans = (ans * (pf[i] + 1)) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y; 
 
  int resx=x;
  int resy=y;
  
 for(int i=0;i<n;i++){
    cin >> x;
      resx=max(resx,x);
   }
 for(int i=0;i<m;i++){
    cin >>y;
    resy=min(resy,y);
 
 } 
 
  if(resx<resy) cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
N=int(input())
B=list(map(int,input().split()))
sum=0
if N==2:
  sum+=B[0]*2
else:
  for i in range(N-2):
    sum+=min(B[i],B[i+1])
  sum+=B[N-2]
  sum+=B[0]
print(sum)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int result = (N - K) / (K - 1);
  cout << 1 + ((N - K) % (K - 1) != 0 ? ++result : result) << endl;
  return 0;
}


Measured memory_bytes: 640
from collections import deque

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
blacks = deque([])
for h in range(H):
  for w in range(W):
    if A[h][w] == "#":
      blacks.append((h, w))
count = 0
while len(blacks) > 0:
  newblacks = deque([])
  while len(blacks) > 0:
    b = blacks.popleft()
    for y, x in zip((b[0]-1, b[0], b[0], b[0]+1), (b[1], b[1]-1, b[1]+1, b[1])):
      if y < 0 or y >= H or x < 0 or x >= W:
        continue
      if A[y][x] == ".":
        newblacks.append((y, x))
      A[y][x] = "#"
  blacks = newblacks
  count += 1
print(count-1)



Measured memory_bytes: 115420
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
d = inp
t = na(n+1)
d.each do |dd|
  t[dd] += 1
end
ans = 1
sumc = 0
mae = 1
if(t[0] != 1 or d[0] != 0)
  puts 0
  exit
end
t.each do |dd|
  if(dd == 0)
    if (sumc == n)
      puts ans
      exit
    else
      puts 0
      exit
    end
  end
  ans *= mae**dd
  ans %= 998244353
  mae = dd
  sumc += dd
end
puts ans


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int UF_MAX = 1010;

class UF{
	int x[UF_MAX];
	int co;
	
public:
	
	UF(){
		fill(x,x+UF_MAX,-1);
		co = 0;
	}
	
	int boss(int a){
		int s = a;
		while(x[s] > -1) s = x[s];
		if(s != a) x[a] = s;
		return s;
	}
	
	void uni(int a , int b){
		int s = boss(a);
		int t = boss(b);
		if(s != t){
			++co;
			if(x[s] < x[t]){
				x[s] += x[t];
				x[t] = s;
			} else {
				x[t] += x[s];
				x[s] = t;
			}
		}
	}
	
	bool find(int a , int b){
		return boss(a) == boss(b);
	}
	
	int count(){
		return co;
	}
	
	int member(int a){
		return -x[boss(a)];
	}
};

const LL mod = 1e9 + 7;
int N,M;
LL X;
vector<tuple<LL,int,int>> V;

LL solve(int a){
	UF uf;
	LL ret = get<0>(V[a]);
	uf.uni(get<1>(V[a]),get<2>(V[a]));
	repp(i,0,M) if(!uf.find(get<1>(V[i]),get<2>(V[i]))){
		ret += get<0>(V[i]);
		uf.uni(get<1>(V[i]),get<2>(V[i]));
	}
	return uf.member(1) == N ? ret : 1e16;
}

int main(){
	cin >> N >> M >> X;
	repp(i,0,M){
		int a,b; LL c; cin >> a >> b >> c;
		V.PB(make_tuple(c,a,b));
	}
	sort(V.begin(),V.end());
	LL ans = 0;
	LL z = 2;
	repm(i,M-1,0){
		LL p = solve(i);
		if(p >= X){
			if(p > X) (ans *= 2) %= mod;
			else (ans += z) %= mod;
			z = z * 2 % mod;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
    }
    let mut ans = 0;
    for i in 1..=n {
        if i % 3 == 0 || i % 5 == 0 {
            continue;
        }
        ans += i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
import sys
import math
import itertools


def main():
    N,M = map(int,input().split())
    S={}
    P=[0] * (M+1)
    List=[]
    for i in range(1,M+1):
        array = list(map(int, input().split()))
        for s in range(1,len(array)):
            
            if i in S.keys():
                S[i].append(array[s])
            else:
                S[i]=[]
                S[i].append(array[s])

    array = list(map(int, input().split()))
    for i in range(1,M+1):
        P[i]=array[i-1]

    for i in range(N):
        List.append(i+1)

    comb=[]
    count=0
    for i in range(1,N+1):
        for l in itertools.combinations(List,i):
            comb=l       
            flag=-1
            for j in range(1,M+1):
                
                cnt=0
                for k in range(0,len(comb)):
                    if comb[k] in S[j]:
                        cnt+=1
                if cnt%2==P[j]:
                    flag=1
                else:
                    flag=-1
                    break
            if flag==1:
                count+=1

    for j in range(1,M+1):
        if(0==P[j]):
            flag=1
        else:
            flag=-1
            break
    if flag==1:
        count+=1
        
    print(count)
                    
                               
if __name__ == "__main__":
    main()


  

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

int main(){
    string s;
    cin>>s;
    string out="";
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='1')out.push_back('1');
        if(s.at(i)=='0')out.push_back('0');
        if(s.at(i)=='B'){
            if(!out.empty())out.pop_back();
        }        
    }
    cout<<out<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll N,K;
    cin>>N>>K;
    if(N<K){
        cout<<min(N,K-N)<<endl;
    }else{
        N=N%K;
        cout<<min(N,K-N)<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n,x,y,o,p,i,a,b;
     
    scanf("%d", &n);
     
    for (i = 0; i < n; i++){
        scanf("%d %d %d %d", &x, &y, &o, &p);
         
        if (o >= 5 && p >= 2){
            x = x/10*8;
            y = y/10*8;
            a= o*x + p*y;
        }
        else if (o < 5 && p < 2){
            a= o*x + p*y;
             
            p = 2;
            o = 5;
            b= o*x/10*8 + p*y/10*8;
             
            if (a >b) a= b;
        }
         
        else if (o < 5){
            a = o*x + p*y;
             
            o = 5;
            b= o*x/10*8 + p*y/10*8;
             
            if (a>b) a = b;
        }
         
        else if (p < 2){
            a = o*x + p*y;
             
            p = 2;
            b = o*x/10*8 + p*y/10*8;
             
            if (a > b)a = b;
        }
        printf("%d\n", a);
    }
     
    return (0);
}

Measured memory_bytes: 600
def main():
    from collections import deque, defaultdict
    n, m = map(int, input().split())
    g = [[] for _ in range(n + 1)]
    ref = defaultdict(list)
    q = deque([])
    visited = set()
    inf = 10 ** 10
    dist = [-inf] * (n + 1)

    for i in range(m):
        a, b, k = map(int, input().split())
        g[a].append(b)
        g[b].append(a)
        ref[(a, b)] = k


    def dfs(u):
        q.append(u)
        while q:
            v = q.pop()
            visited.add(v)
            for x in g[v]:
                if x not in visited:
                    if ref[(v, x)] != []:
                        y = ref.get((v, x))
                        if dist[x] == -inf and dist[v] == -inf:
                            continue
                        elif dist[x] == -inf:
                            dist[x] = dist[v] + y
                        elif dist[v] == -inf:
                            dist[v] = dist[x] - y
                        elif dist[x] != dist[v] + y:
                            #print(v, x, dist[v], dist[x], y)
                            print("No")
                            exit()
                    else:
                        y = ref.get((x, v))
                        if dist[x] == -inf and dist[v] == -inf:
                            continue
                        elif dist[v] == -inf:
                            dist[v] = dist[x] + y
                        elif dist[x] == -inf:
                            dist[x] = dist[v] - y
                        elif dist[v] != dist[x] + y:
                            #print(v, x, dist[v], dist[x], y)
                            print("No")
                            exit()
                    q.append(x)


    for i in range(1, n + 1):
        if i not in visited:
            #print(len(visited))
            dist[i] = 1
            dfs(i)
    print("Yes")
if __name__ == '__main__':
    main()

Measured memory_bytes: 171868
#include <iostream>
#include <vector>
#include <queue>
#include <cassert>
#include <algorithm>
using namespace std;
#define INF (-(1<<29))
int A_(int x,int y){ return x+y; }
int B_(int x,int y){ return x-y; }
int C_(int x,int y){ return -x+y; }
int D_(int x,int y){ return -x-y; }
priority_queue< pair<int,int> > Q[3][4];
int (*f[4])(int x,int y) = {A_,B_,C_,D_};

pair<int,int> item[100000];

int used[100000];
int get(priority_queue< pair<int,int> > &A , priority_queue< pair<int,int> > &B){
	if(A.size() == 0 || B.size() == 0) return 0;
	//if(A.top().second == B.top().second) return INF;
	return A.top().first + B.top().first;
}



int get2(priority_queue< pair<int,int> > &A , int B){
	if(A.size() == 0) return 0;
	//if(A.top().second == B.top().second) return INF;
	return A.top().first + B;
}

int chk(int A,int B){
	if(Q[1][0].size()==0){
		return 0;
	}else{
		int ans = 0;
		ans = max( ans , get2(Q[1][0],f[3](item[A].first,item[A].second) ) );
		ans = max( ans , get2(Q[1][1],f[2](item[A].first,item[A].second) ) );
		ans = max( ans , get2(Q[2][0],f[3](item[B].first,item[B].second) ) );
		ans = max( ans , get2(Q[2][1],f[2](item[B].first,item[B].second) ) );
		return ans;
	}
}
int chkk(int A,priority_queue< pair<int,int> > R[4]){
	int ans = 0;
	ans = max( ans , get2(R[0],f[3](item[A].first,item[A].second) ) );
	ans = max( ans , get2(R[1],f[2](item[A].first,item[A].second) ) );
	return ans;
}
int put(int A,int B){
	if(A != -1) for(int j = 0 ; j < 4 ; j++) Q[1][j].push(make_pair(f[j](item[A].first,item[A].second),A));
	if(B != -1) for(int j = 0 ; j < 4 ; j++) Q[2][j].push(make_pair(f[j](item[B].first,item[B].second),B));
	if(A != -1) used[A] = true;
	if(B != -1) used[B] = true;
}

int main(){
	int n;
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		int x,y;
		cin >> x >> y;
		item[i] = make_pair(x,y);
		for(int j = 0 ; j < 4 ; j++){
			Q[0][j].push(make_pair(f[j](x,y),i));
		}
	}
	//int lastDistance;
	while(Q[0][0].size()){
		int sub = -1 , h = -1 , aa , bb;
		for(int i = 0 ; i < 3 ; i++){
			for(int j = 0 ; j < 4 ; j++){
				int r = get( Q[0][j] , Q[i][3-j] );
				if( r > sub){
					sub = r;
					h = i;
					aa = Q[0][j].top().second;
					bb = Q[i][3-j].top().second;
				}
			}
		}
		if(h==0){
			if( max( chkk(aa,Q[1]) , chkk(bb,Q[2]) ) > max( chkk(aa,Q[2]) , chkk(bb,Q[1]) ) ){
				put(bb,aa);
			}else{
				put(aa,bb);
			}
		}else if(h==1){
			put(-1,aa);
		}else{
			put(aa,-1);
		}
		
		for(int i = 0 ; i < 4 ; i++){ while(Q[0][i].size() && used[Q[0][i].top().second]) Q[0][i].pop(); }
		//cout << aa << " " << bb << "<" << endl;
		//for(int j = 0 ; j < 10 ; j++) cout << used[j] ; cout << endl;
		//cout << "[" << Q[0][0].size() << "]" << h << " " << Q[1][0].size() << " " << Q[2][0].size() << endl;
		//cout << endl;
	}
	int ans = 0;
	for(int i = 1 ; i < 3 ; i++){
		for(int j = 0 ; j < 4 ; j++){
			int r = get( Q[i][j] , Q[i][3-j] );
			ans = max( ans , r );
		}
	}	
	cout << ans  << endl;
}

Measured memory_bytes: 0
s=input()
a=s[(len(s)-1)//2::-1]
b=s[len(s)//2:]
if a[0]!=b[0]:
    print(len(s)//2)
else:
    c=str(1-int(a[0]))
    m = (a+c).find(c)
    n = (b+c).find(c)
    print(len(s)//2+min(m,n))

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

#define int long long

int n, ans;
vector<int> s;

signed main(void) {
    cin >> n;

    s.resize(n);

    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        ans += s[i];
    }

    sort(s.begin(), s.end());

    if (ans % 10 != 0) cout << ans << endl;
    else {
        for (int i = 0; i < n; ++i) {
            if (s[i] % 10 != 0) {
                cout << ans - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }



    return 0;
}

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

using namespace std;

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

    vector<int> h(n);
    for(int i=0;i<n; i++){
        cin >> h[i];
    }

    int maxH = 0, cnt = 0;
    for(int i=0; i<n;i++){
        if(maxH<=h[i]){
            cnt++;
            maxH = h[i];
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k,ans=0,flag;
  scanf("%d%d",&n,&k);
  int d[k+1],a[k+1][n+1],s[n+1];
  
  for(int i=0;i<=n;i++){
    s[i]=0;
  }
  
  for(int i=1;i<=k;i++){
    for(int j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
  
  for(int i=1;i<=k;i++){
    scanf("%d",&d[i]);
    for(int j=1;j<=d[i];j++){
      scanf("%d",&a[i][j]);
    }
  }
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      s[a[j][i]]+=1;
    }
  }
  
  for(int i=1;i<=n;i++){
    if(s[i]==0){ans+=1;}
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1744
#include"bits/stdc++.h"
    using namespace std;
    int a,b;
     
    int main(){
    	cin>>a>>b;
    	if(a>0)cout<<"Positive";
    	else if(a==0||(a<0&&b>0))cout<<"Zero";
    	else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    	else cout<<"Negative";
    	return 0;
    }

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;
static const cc MAX = 100000;

cc N, K, i, j, k, sub = 0, n = 0, X, Y, A[MAX], B[MAX];
cc judge = 0, Ans, J[MAX];
string S;
/*
vector<cc> vec1(MAX), vec2(MAX);
vector<pair<cc, cc>> pairs(MAX);
*/



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

	i = N + K;
	j = N - K;
	k = N * K;
	Ans = max(i, j);
	Ans = max(Ans, k);


	cout << Ans << endl;
	return 0;

}

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

int main() {

	long long  n = 0;
	cin >> n;
    long long a[n];

    

    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << "0";
            return 0;
        }
    }

    long long ans = 1;
    for(long long i = 0;i < n;i++){
        
        if(a[i] <= 1000000000000000000/ans){
            ans *= a[i];
        }else{
          cout << "-1";
            return 0;
        }
    }
     cout << ans;

}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    string s;
    cin >> s;
    map<char, int> cnt;
    for (int i = 0; i < N; i++) {
        cnt[s[i]]++;
    }
    ll ans = 1;
    for (int i = 0; i < 26; i++) {
        if (cnt['a' + i] == 0) continue;
        else if (cnt['a' + i] == 1) {
            ans = (ans * 2) % MOD;
        }
        else {
            ans = (ans * (cnt['a' + i] + 1)) % MOD;
        }
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A)


def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a]


def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True


def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20016
import collections
n = int(input())
v = list(map(int,input().split()))
even = v[0::2]
odd = v[1::2]
ce = collections.Counter(even)
oe = collections.Counter(odd)
if len(set(odd)) ==1 and len(set(even)) == 1:
    if ce.most_common()[0][0] != oe.most_common()[0][0]:
        print("0")
    else:
        print(int(n/2))
elif len(set(odd)) ==1 and len(set(even)) != 1:
    print(int(n/2-ce.most_common()[0][1]))
elif len(set(odd)) !=1 and len(set(even)) == 1:
    print(int(n/2-oe.most_common()[0][1]))
else:
    if ce.most_common()[0][0] != oe.most_common()[0][0]:
        print(n-ce.most_common()[0][1]-oe.most_common()[0][1])
    else:
        print(n - max(ce.most_common()[1][1]+oe.most_common()[0][1], oe.most_common()[1][1]+ce.most_common()[0][1]))


Measured memory_bytes: 20156
n ,m = list(map(int,input().split(" ")))
a = list(map(int,input().split(" ")))
s = 0
for i in range(n):
    s += a[i]
cnt = 0
for i in range(n):
    if a[i] >= (s + 4 * m - 1) // (4 * m) :
        cnt+=1
if cnt >= m :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<(b*1900+(a-b)*100)*pow(2,b)<<endl;
	return 0;
}


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

int main() {
    int c[3][3], sum = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
            sum += c[i][j];
        }
    }

    if (3 * (c[0][0] + c[1][1] + c[2][2]) == sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main(){
    int a[5];
    for(int i = 0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i = 0; i < 5; i++)
    {
        if(a[i]==0)
        printf("%d",i+1);
    }
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0)
        cout << "Zero" << endl;
    else if (b < 0 && (b - a + 1) % 2 == 1)
        cout << "Negative" << endl;
    else
        cout << "Positive" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		s.nextLine();
		
		int[] heights = new int[n];
				
		for(int i = 0; i < n; i++) {
			heights[i] = s.nextInt();
		}
		
		int[] minAtN = new int[n];
		
		minAtN[0] = 0;
		
		if(minAtN.length > 1) {
			minAtN[1] = Math.abs(heights[1] - heights[0]);
		}
		
		for(int i = 2; i < n; i++) {
			int min1 = minAtN[i - 1] + Math.abs(heights[i] - heights[i - 1]);
			int min2 = minAtN[i - 2] + Math.abs(heights[i] - heights[i - 2]);
			minAtN[i] = Math.min(min1, min2);
		}
		
		System.out.println(minAtN[n-1]);
		
	}
}


Measured memory_bytes: 53012
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,K,s,res=0;
  cin >> N >> K;
  for(ll i=K+1;i<=N;i++){
    res += (N/i)*(i-K);
    s = N % i;
    res += max(s-K+1,0LL);
  }
  if(K == 0)
    res += -N;
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	cout << (N + M - 1) / M << endl;
	return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
int a[100001]={0};
int sum = 0;

int main(){
  scanf("%d",&n);
  REP(i,n){
    int x;
    scanf("%d",&x);
    a[x]++;
  }
  REP(i,100001){
    if(a[i]>1){
      sum += a[i]-1;
    }
  }
  if(sum%2==0){
    printf("%d\n",n-sum);
  }else{
    printf("%d\n",n-sum-1);
  }
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

class taskb {
 public:
  void solveOne(istream &in, ostream &out) {

  }

  void solve(std::istream &in, std::ostream &out) {
    int n, m, v, p;
    in >> n >> m >> v >> p;
    vector<int> a(n);
    for (int i =0 ; i < n; ++i) {
      in >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    if (v > p) {
      int res = p - 1;
      int64 inner = 0;
      int left = p - 1;
      int innerBy = 0;
      for (int i = p - 1; i < n; ++i) {
        int64 slack = m * (int64) (n - 1 - i);
        if (left < i && a[left] > m + a[i]) {
          break;
        }
        inner -= (innerBy - a[i]) * (int64) (i - left);
        slack += inner;
        innerBy = a[i];
        inner += m;
        if (slack >= m * (int64) (v - p)) {
          ++res;
        }
      }
      out << res << endl;
    } else {
      int res = p;
      for (int i = p; i < n; ++i) {
        if (a[i] + m >= a[p - 1]) {
          ++res;
        }
      }
      out << res << endl;
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  taskb solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 640
from functools import reduce

result = 0

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

n = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(n)]
Y = [0 for i in range(n)]
for i in range(1, n):
    X[i] = gcd(X[i-1], A[i-1])
for i in range(n-1)[::-1]:
    Y[i] = gcd(Y[i+1], A[i+1])
print(max(gcd(X[i], Y[i]) for i in range(n)))


Measured memory_bytes: 14704
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
using namespace std;
int x,d;
int n;
ll l[200005];
ll r[200005];

ll sumrange(int l,int r)
{
	return 1LL*(l+r)*(r-l+1)/2;
}

ll same(ll l1,ll r1,ll l2,ll r2,ll k)
{
	l1+=k;
	r1+=k;
	l1=max(l1,l2);
	r1=min(r1,r2);
	if(l1>r1) return 0;
	return (r1-l1+1);
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>x>>d;
	ll res=0;
	for(int i=0;i<=n;i++)
	{
		l[i]=sumrange(0,0+i-1);
		r[i]=sumrange(n-1-i+1,n-1);
		if(d==0) l[i]=r[i]=0;
		res+=r[i]-l[i]+1;
	}
	int bx,bd;
	if(x==0)
	{
		bx=1;
		bd=0;
	}
	else
	{
		int g=__gcd(x,d);
		bx=d/g;
		bd=x/g;
	}
	
	if(bx<0)
	{
		bx=-bx;
		bd=-bd;
	}
	bd=-bd;
	for(int i=0;i<=n;i++)
	{
		if(i+bx>n) break;
		res-=same(l[i],r[i],l[i+bx],r[i+bx],bd);
	}
	cout<<res<<endl;
	return 0;
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let p: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut ans = 1;
    let mut m = p[0];

    for i in 0..n {
        if p[i] < m {
            ans += 1;
            m = p[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;

int main()
{
  	int n, k, x, y;
  	int ans = 0;
  
  	cin >> n >> k >> x >> y;
  	
  	if (n <= k) {
      ans += n * x;
    }
  	else {
      ans += k * x;
      n -= k;
      ans += n * y;
    }
  
  	cout << ans << endl;
  
  	return (0);
}
   
  	

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M;
vector<pii> A;
vector<pii> B;

void input() {
  cin >> N >> M;
  A.resize(N);
  B.resize(M);
  rep(i, 0, N - 1) { cin >> A[i].first >> A[i].second; }
  rep(i, 0, M - 1) { cin >> B[i].first >> B[i].second; }
}
void solve() {
  for (auto l : A) {
    int x = l.first;
    int y = l.second;
    int mini = INF;
    int mini_ind = INF;
    rrep(i, M - 1, 0) {
      int ds = abs(B[i].first - x) + abs(B[i].second - y);
      if (ds <= mini) {
        mini = min(ds, mini);
        mini_ind = i + 1;
      }
    }
    cout << mini_ind << endl;
  };
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256