akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
int h, w, k, x1, yy1, x2, y2, d[4] = {1,-1}, mp[2000005], qu[1000005], b, e, inf=1e9;
int main(){
	scanf("%d%d%d", &h, &w, &k); w++;
	scanf("%d%d%d%d", &x1, &yy1, &x2, &y2); x1--; x2--;
	for(int i=0; i<h*w; i++) if(getchar() == '.') mp[i] = inf;
	mp[qu[e++] = x1*w+yy1] = 1;
	d[2] = w; d[3] = -w;
	while(b<e) for(int i=0, x=qu[b++]; i<4; i++) for(int nx=x+d[i], u=0; u<k && 0<=nx && mp[nx]>mp[x]; u++, nx+=d[i]) if(mp[nx] == inf) mp[qu[e++] = nx] = mp[x] + 1;
	printf("%d\n", mp[x2*w+y2] == inf ? -1 : mp[x2*w+y2]-1);
}

Measured memory_bytes: 10436
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, m;
int p[100000];
int a[100000], b[100000], c[100000];
int cnt[100000];

signed main()
{
	int i;
	
	cin >> n >> m;
	for( i = 0; i < m; i++ ){
		cin >> p[i];
		p[i]--;	//0??????n-1????????????
	}
	for( i = 0; i < n - 1; i++ ){	//??????0???n-2?????§??????
		cin >> a[i] >> b[i] >> c[i];
	}
	
	for( i = 0; i < m - 1; i++ ){
		int l = min(p[i], p[i+1]);
		int r = max(p[i], p[i+1]);
		//?§?[l, r]??????????????????[l, r)?????????
		cnt[l]++; cnt[r]--;
	}
	for( i = 1; i < n; i++ ){
		cnt[i] += cnt[i-1];
	}
	
	int ans = 0;
	for( i = 0; i < n - 1; i++ ){
		ans += min(a[i] * cnt[i], b[i] * cnt[i] + c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5060
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MaxN = 3000 + 5;
const int MaxW = 100000 + 5, MaxH = 100000 + 5;
const int Mod = 1000000007;

int H, W, N;
int R[MaxN], C[MaxN];
int Fac[MaxW + MaxH], InvFac[MaxW + MaxH];
int Dp[MaxN];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }
inline int pw(int x, int y) { int z = 1; for (; y; y >>= 1, x = mul(x, x)) if (y & 1) z = mul(z, x); return z; }
inline int inv(int x) { return pw(x, Mod - 2); }
inline int sep(int x, int y) { return mul(x, inv(y)); }
inline int c(int n, int m) { return mul(Fac[n], mul(InvFac[m], InvFac[n - m])); }

void init() {
  scanf("%d %d %d", &H, &W, &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d %d", &R[i], &C[i]);
  Fac[0] = 1;
  for (int i = 1; i <= H + W; ++i) Fac[i] = mul(Fac[i - 1], i);
  InvFac[H + W] = inv(Fac[H + W]);
  for (int i = H + W; i >= 1; --i) InvFac[i - 1] = mul(InvFac[i], i);
}

void solve() {
  N++;
  R[N] = H, C[N] = W;
  static int lnk[MaxN];
  for (int i = 1; i <= N; ++i) lnk[i] = i;
  std::sort(lnk + 1, lnk + 1 + N, [](int x, int y){ return R[x] != R[y] ? R[x] < R[y] : C[x] < C[y]; });
  for (int I = 1; I <= N; ++I) {
    int i = lnk[I];
    Dp[i] = c(R[i] + C[i] - 2, R[i] - 1);
    for (int J = 1; J < I; ++J) {
      int j = lnk[J];
      if (R[j] <= R[i] && C[j] <= C[i])
        Dp[i] = sub(Dp[i], mul(c(R[i] - R[j] + C[i] - C[j], R[i] - R[j]), Dp[j]));
    }
  }
  printf("%d\n", Dp[N]);
}

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

Measured memory_bytes: 1792
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type rule struct {
	x, y int
}

// N :
var N int
var a []int
var r [][]rule

func check(n int) int {
	b := make([]int, N)
	idx := 0
	for n > 0 {
		b[idx] = n % 2
		n /= 2
		idx++
	}

	ret := 0
	for i := 0; i < N; i++ {
		// out(i, N)
		if b[i] == 1 {
			ret++
			// out(i, r[i])
			for _, e := range r[i] {
				if b[e.x] != e.y {
					return -1
				}
			}
		}
	}
	// out(b)
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N = getInt()
	a = make([]int, N)
	r = make([][]rule, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
		for j := 0; j < a[i]; j++ {
			x, y := getInt()-1, getInt()
			r[i] = append(r[i], rule{x, y})
		}
	}

	ans := 0
	n := 1 << uint(N)
	for i := 0; i < n; i++ {
		res := check(i)
		ans = max(ans, res)
	}
	out(ans)
}


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

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

const int MOD=1000000007; //10^9+7

int main() {
    int N;
    string S;
    cin>>N>>S;
    int L=S.size();
    for(int i=0;i<L;i++){
        S.at(i)+=N;
        if(S.at(i)>'Z'){
            S.at(i)-=26;
        }
    }
    cout<<S<<endl;
}


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

using namespace std;


int main()
{
  int N, M;
  map< int, int > xs[100001];
  int sum[100001] = {};

  cin >> N >> M;

  for(int i = 0; i < N; i++) {
    int X;
    cin >> X;
    xs[X % M][X]++;
    sum[X % M]++;
  }


  int ret = sum[0] / 2;

  for(int i = 1; i <= M - i; i++) {
    if(i == M - i) {
      ret += sum[i] / 2;
      break;
    }

    int one1 = 0, one2 = 0;

    priority_queue< int > p, q;

    for(auto &a : xs[i]) {
      if(a.second / 2 > 0) p.push(a.second / 2);
      one1 += a.second % 2;
    }
    for(auto &a : xs[M - i]) {
      if(a.second / 2 > 0) q.push(a.second / 2);
      one2 += a.second % 2;
    }
    while(one1 > 0 || one2 > 0) {

      if(one1 == 0) {
        if(p.empty()) break;
        int k = p.top() - 1;
        p.pop();
        if(k > 0) p.push(k);
        one1++;
      } else {
        --one1;
      }

      if(one2 == 0) {
        if(q.empty()) break;
        int k = q.top() - 1;
        q.pop();
        if(k > 0) q.push(k);
        one2++;
      } else {
        one2--;
      }

      ++ret;
    }

    while(!p.empty()) {
      ret += p.top();
      p.pop();
    }
    while(!q.empty()) {
      ret += q.top();
      q.pop();
    }
  }
  cout << ret << endl;
}


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

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> L(N+1);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i=2; i<N+1; i++){
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  cout << L.at(N) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
/* data type, special numbers, defines */
//#define int ll //use if ded
#define ll long long
#define ld long double
const ll inf=LLONG_MAX;
//const ll mod=1e9+7;
const ll mod=998244353;
const ld pi=acos(-1.0);
#define all(v) v.begin(), v.end()
/* end data type and special numbers */
 
/* fast input.output */
#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define endl pc('\n')
int get_i(){
	char c=gc(); bool neg=false;
	for(; c<'0'||'9'<c; c=gc())
		if(c=='-') neg=true;
	int rs=c-'0'; c=gc();
	for(; '0'<=c && c<='9'; c=gc())
		rs=(rs<<1)+(rs<<3)+(c-'0');
	if(neg) rs=-rs;
	return rs;
}
ll get_l(){
	char c=gc(); bool neg=false;
	for(; c<'0'||'9'<c; c=gc())
		if(c=='-') neg=true;
	ll rs=c-'0'; c=gc();
	for(; '0'<=c && c<='9'; c=gc())
		rs=rs*10ll+(c-'0');
	if(neg) rs=-rs;
	return rs;
}
string get_s(){
	char c=gc();
	for(; c<33 || 126<c; c=gc());
	string s=""; s+=c; c=gc();
	for(; 33<=c && c<=126; c=gc())
		s+=c;
	return s;
}
char get_c(){
	char c=gc();
	for(; c<33 || 126<c; c=gc());
	return c;
}
void print_i(int _n){
	bool neg=false; if(_n<0) {neg=true; _n=-_n;}
	if(neg) pc('-');
	int N=_n, rev, count=0;
	rev=N;
	if(N==0) {pc('0'); return;}
	while((rev%10)==0) {count++; rev/=10;}
	rev=0;
	while(N!=0) {rev=(rev<<3)+(rev<<1)+N%10; N/=10;}
	while(rev!=0) {pc(rev%10+'0'); rev/=10;}
	while(count--) pc('0');
}
void print_l(ll _n){
	ll N=_n, rev, count=0;
	rev=N;
	if(N==0) {pc('0'); return;}
	while((rev%10)==0) {count++; rev/=10;}
	rev=0;
	while(N!=0) {rev=rev*10ll+N%10; N/=10;}
	while(rev!=0) {pc(rev%10+'0'); rev/=10;}
	while(count--) pc('0');
}
void print_s(string a){
	for(int i=0; i<a.size(); i++)
		pc(a[i]);
}
#define endline pc('\n');
#define space pc(' ');
/* end fast input/output */

/*   E N D   O F   T E M P L A T E   */

int n, m, dp[105][105];
char a[105][105];
int main(){
	n=get_i(); m=get_i();
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++){
			a[i][j]=get_c(); dp[i][j]=1e9;
		}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(i==0){
				if(j==0) dp[0][0]=(a[0][0]=='#');
				else dp[0][j]=dp[0][j-1]+(a[0][j-1]=='.' && a[0][j]=='#');
			}else{
				if(j==0) dp[i][0]=dp[i-1][0]+(a[i-1][0]=='.' && a[i][0]=='#');
				else dp[i][j]=min(dp[i-1][j]+(a[i-1][j]=='.' && a[i][j]=='#'), dp[i][j-1]+(a[i][j-1]=='.' && a[i][j]=='#'));
			}
		}
	}
	print_i(dp[n-1][m-1]); endline return 0;
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]

#print(AB)
rest = M
ans = 0
for a, b in sorted(AB, key=lambda x: x[0]):
	
    if (b < rest):
        ans += a*b
        rest -= b
    else:
        ans += (a*rest)
        break
print(ans)

Measured memory_bytes: 65240
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int X,A,B;

signed main(){

    in(X,A,B);
    puts(abs(X-A)<abs(X-B)?"A":"B");

    return 0;
}


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

int main(){
  long N, M;
  std::cin >> N >> M;
  std::vector<std::vector<long>> set(N);
  for(int i = 0; i < M; ++i){
    long A, B;
    std::cin >> A >> B;
    --A; --B;
    set[A].push_back(B);
    set[B].push_back(A);
  }
  std::vector<long> ans(N,-1);

  std::vector<long> next;
  for(int i = 0; i < set[0].size(); ++i){
    next.push_back(set[0][i]);
    ans[set[0][i]] = 0;
  }

  while(next.size() != 0){
    std::vector<long> cand;
    for(long i = 0; i < next.size(); ++i){
      for(long j = 0; j < set[next[i]].size(); ++j){
        if(ans[set[next[i]][j]] == -1){
          cand.push_back(set[next[i]][j]);
          ans[set[next[i]][j]] = next[i];
        }
      }
    }
    next = std::move(cand);
  }
  std::cout << "Yes" << std::endl;
  for(long i = 1; i < ans.size(); ++i){
    std::cout << ans[i] + 1 << std::endl;
  }


  return 0;
}



Measured memory_bytes: 13552
#include <iostream>
#include <string>
#include <cstdio>
#include <string.h>

using namespace std;

int main() {
  string s;
  char buf[200];
  char tmp[200] = {0};
  int m;
  size_t h;

  for (;;) {
    cin >> s;
    if (s == "-") {
      break;
    }
    strncpy(buf, s.c_str(), s.size());

    cin >> m;
    const size_t len = s.size();
    for (int i = 0; i < m; ++i) {
      cin >> h;

      memmove(tmp, buf, h);
      memmove(buf, buf + h, len - h);
      memmove(buf + len - h, tmp, h);
    }
    cout << string(buf, s.size()) << endl;
  }

  return 0;
}

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


int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int K,T;
    cin >> K >> T;
    int maxi = 0;

    int a[T];
    for (int i = 0; i < T; i++){
      cin >> a[i];
      maxi = max( maxi, a[i]);
    }

    cout << max(2 * maxi - K - 1 ,0) << endl;

    return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8')
 
let [a, b]: number[] = input.split('\n')[0].split(' ').map(Number)
let coins = 0
for (let i = 0; i < 2; i++) {
  if (a >= b) {
    coins += a
    a -= 1
  }
  else {
    coins += b
    b -= 1
  }
}
console.log(coins)

Measured memory_bytes: 9420
H, N = map(int, input().split())
List = list(map(int, input().split()))
List.sort()
List.reverse()
#print(List)

i=0
while i<N:
    H-=List[0]
    del List[0]
    i+=1
    
if H<=0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13964
#include<bits/stdc++.h>
#define N 205
#define W 21
using namespace std;

int n,m;
int dp[N][N][W];

int main(){
  
  cin>>n>>m;
  
  int k,s,h;
  vector<int> v[N];
  
  for(int i=0;i<n;i++){
    cin>>k;
    
    for(int j=0;j<k;j++){
      cin>>s>>h;
      for(int l=0;l<h;l++)
	v[i].push_back(s);
    }
  }
  
  memset(dp,-1,sizeof(dp));
  dp[0][0][0]=0;
  
  for(int i=0;i<n;i++){
    
    for(int j=0;j<=m;j++){
      
      for(int l=0;l<W;l++){
	if(dp[i][j][l]==-1)continue;
	
	int sum=0;
	for(int x=0;x<v[i].size();x++){
	  
	  sum+=v[i][x];
	  int w=l;
	  
	  if(x<v[i].size()-1){
	    if(!l)w=v[i][x+1];
	    else w=min(l,v[i][x+1]);
	  }
	  
	  if(j+sum<=m)dp[i+1][j+sum][w]=max(dp[i+1][j+sum][w],dp[i][j][l]+x+1);
	  
	}
	dp[i+1][j][l]=max(dp[i+1][j][l],dp[i][j][l]);
	
      }
      
    }
    
  }

  double ans=0;
  for(int i=0;i<=m;i++){
    for(int j=0;j<W;j++){
      
      if(dp[n][i][j]==-1)continue;
      
      if(j&&1.0*m-i<=j)ans=max(ans,dp[n][i][j]+(1.0*m-i)/j);
      else ans=max(ans,1.0*dp[n][i][j]);
    }
  }

  printf("%.8f\n",ans);
  
  return 0;
}

Measured memory_bytes: 6868
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
let N = lines[0].trim() - 0

const D = []
for (let i = 0; i < N; i++) {
    D[i] = lines[i + 1].split(' ').map(Number)
}

let ans = 'No'

let count = 0
for (let i = 0; i < N; i++) {
    if (D[i][0] === D[i][1]) {
        count++
        if (count === 3) {
            ans = 'Yes'
            break
        }
    } else {
        count = 0
    }
}

console.log(ans)


Measured memory_bytes: 29684
import sys
sys.setrecursionlimit(500000)

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
arr = []

def dfs(A: list):
    if len(A) == N:
        arr.append(A)
        return
    start = 1 if len(A) == 0 else A[-1]
    for i in range(start, M+1):
        dfs(A+[i])

dfs([])

ans = 0
for A in arr:
    tmp = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] == c:
            tmp += d
    if ans < tmp:
        ans = tmp
print(ans)

Measured memory_bytes: 94032
n = int(input())
c = []
for _ in range(n):
    l = int(input())
    c.append(l)
c = sorted(c)
k = sum(c)
if(k%10!=0):
    print(k)
else:
    for i in range(len(c)):
        if(c[i]%10!=0):
            k-=c[i]
            print(k)
            exit()
    print(0)


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

int main(){
  int A,B;
  string ans;
  cin >> A >> B;
  if (A<=8 and B<=8)
    ans = "Yay!";
  else
    ans = ":(";
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	int n,a,b;
  	cin >> n >> a >> b;
  	cout << min(n*a,b)<<endl;
}


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

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

void solve(void){
  ll n, k; cin >> n >> k;
  vector<ll> va(n, 0);
  rep(n, i) cin >> va[i];

  for(ll i = 1; i <= k; ++i) {
    vector<ll> query(n+1, 0);
    rep(n, j) {
      ll l = max(0LL, j-va[j]);
      ll r = min(n-1, j+va[j]);
      ++query[l];
      --query[r+1];
    }
    for(ll j = 1; j < n; ++j) query[j] += query[j-1];

    bool flag = true;
    rep(n, j) {
      if (query[j] != va[j]) flag = false;
    }
    if (flag == true) {
      rep(n, j) {
        cout << query[j];
        (j < n-1) ? cout << " " : cout << endl;
      }
      return;
    }

    rep(n, j) va[j] = query[j];
  }

  rep(n, i) {
    cout << va[i];
    (i < n-1) ? cout << " " : cout << endl;
  }

}

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

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

int main(){
	int a[4];
	int i,j,max;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	max=a[2]*10+a[1]+a[0];
	cout<<max;
}

Measured memory_bytes: 256
/*


*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#define ll long long
#define M
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
int main() {
	int a = read(), b = read();
	if(b % a) cout << b - a;
	else cout << a + b;



	return 0;
}




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

cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]

s = sum(a)
ans = 10 ** 18
for i in range(n-1):
    ans = min(ans, abs(s - 2*cum[i+1]))
print(ans)

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    string t;
    cin >> t;

    for (int pos = 0; pos < n; ++pos) {
        const int len = n - pos;
        if (s.substr(pos) == t.substr(0, len)) {
            cout << pos + n << endl;
            return 0;
        }
    }

    cout << 2 * n << endl;

    return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// 繰り返し二乗法
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n % 2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  REP(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  mint ans = f(n) - 1 - choose(n,a) - choose(n,b);
  cout << ans.x << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <set>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int N;
std::set<int> S;

int main()
{
  scanf( "%d", &N );
  rep( i, N )
  {
    int A;
    scanf( "%d", &A );
    S.insert( A );
  }

  int kind = S.size();

  printf( "%d\n", kind%2?kind:kind-1 );

  return 0;
}

Measured memory_bytes: 4864
import scala.io.StdIn._
object Main extends App{
  val k = readLine().toInt

  var sum = 0
  (1 to k).foreach(h =>{
    (1 to k).foreach(i => {
      (1 to k).foreach(j => {
        sum = sum + gcd(h, i ,j)
      })
    })
  })

  println(sum)

  def gcd(a: Int, b:Int, c: Int):Int = {
    val ab = gcd(a, b)
    if(ab > c) gcd(ab, c)
    else if(ab == c) c
    else gcd(c, ab)
  }

  def gcd(a: Int, b:Int):Int = {
    val remains = a % b
    if(remains == 0) b
    else gcd(b, remains)
  }
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	sort(s.begin(),s.end());
	if(s=="abc")cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll lcm=c*d/gcd(c,d);
	ll cnt=0;
	cnt+=b/c-(a-1)/c;
	cnt+=b/d-(a-1)/d;
	cnt-=b/lcm-(a-1)/lcm;
	cnt=b-a+1-cnt;
	printf("%lld\n",cnt);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int n ;
    cin >> n ;
    vector<int64_t> a(3*n) ;
    for (size_t i = 0; i < 3*n; i++)
    {
        cin >> a.at(i) ;
        a.at(i) *= -1 ;
    }
    sort(a.begin(), a.end() ) ;
    for (size_t i = 0; i < 3*n; i++)
    {
        a.at(i) *= -1 ;
    }
    
    int64_t ans = 0 ;
    for (size_t i = 0; i < n; i++)
    {
        ans += a.at(1+2*i) ;
    }
    cout << ans << endl ;
    
    
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    string a, b ,c;
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front()){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 3592
mod = 10**9+7
N = int(input())
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
dp[0][3][3][3] = 1

for i in range(N):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                if(dp[i][j][k][l] == 0): continue
                for a in range(4):
                    if(a == 2 and l == 1 and k == 0): continue
                    if(a == 1 and l == 2 and k == 0): continue
                    if(a == 2 and l == 0 and k == 1): continue
                    if(a == 2 and l == 1 and j == 0): continue
                    if(a == 2 and k == 1 and j == 0): continue
                    dp[i+1][k][l][a] += dp[i][j][k][l]
                    dp[i+1][k][l][a] %= mod
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += dp[N][j][k][l]
            ans %= mod

print(ans)


Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int dp[100010];

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

    for (int x = 1; x <= N; x++) {
        dp[x] = inf;
        int power = 1;
        while (power <= x) {
            dp[x] = min(dp[x], dp[x-power]+1);
            power *= 6;
        }

        power = 1;
        while (power <= x) {
            dp[x] = min(dp[x], dp[x-power]+1);
            power *= 9;
        }
    }

    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define rep(i,n)  for(int i=0;i<(n);i++)

int main(){
    int n; cin>>n;
    int t[n+1],x[n+1],y[n+1];
    t[0]=x[0]=y[0]=0;
    
    for(int i=1;i<=n;i++)cin>>t[i] >>x[i] >>y[i];
    
    bool ok = true;
    for(int i=0;i<n;i++){
        
        int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        int dt = t[i+1]-t[i];
        
        if(dt<dist){
            ok = false;
            break;
        }
        
        if(dist%2!=dt%2){
            ok = false;
            break;
        }
    }
    cout<<(ok ? "Yes" : "No")<<endl;
    return 0;
}

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

int main(){
  string t;
  cin>>t;
  std::replace(t.begin(), t.end(), '?', 'D');
  cout<<t<<endl;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n ;
  cin >> n;
  
  ll total = 0;
  ll a;
  for(int i=0;i<n;i++){
    cin >> a;
    total += a-1;
  }
  cout << total << endl;
  return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int answer=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]) answer++;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
int main() {
    string w, s;
    int count = 0;
    cin >> w;
    cin >> s;
    while(s != "END_OF_TEXT") {
        for(int i = 0; i < s.size(); i++) {
            char ch = s.at(i);
            if(isalpha(ch) && isupper(ch)) {
                s.at(i) = tolower(ch);
            }
        }
        if(w == s) count++;
        cin >> s;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e5+10;

vector<pair<ll,ll>> graph[maxn];
bitset<maxn> color;
bitset<maxn> visited;

void dfs(int v,int cost,int c){
	if(visited[v]) return;

	//cout << "v = " << v << " cost = " << cost << " color = " << c << '\n';

	visited[v] = 1;

	if(cost%2 == 0) color[v] = c;
	else color[v] = !c;

	for(auto &x:graph[v]){
		dfs(x.ff,cost + x.ss,c);
	}
}

int main(int argc,const char** argv){

	fastio;

	int N;

	cin >> N;

	rep(i,1,N){
		int ui,vi,wi;
		cin >> ui >> vi >> wi;
		graph[ui].pb(ii(vi,wi));
		graph[vi].pb(ii(ui,wi));
	}

	dfs(1,0,0);

	for(int i=1;i<=N;++i){
		cout << color[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 9472
#include<iostream>

using namespace std;

int main() {
	int n, y;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; y - n - 9 * i >= 0; i++) {
		if ((y - n - 9 * i) % 4 == 0 && n - i - (y - n - 9 * i) / 4 >= 0) {
			cout << i << " " << (y - n - 9 * i) / 4 << " " << n - i - (y - n - 9 * i) / 4 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll fp(ll base, ll pw) {
    if (base == 0) return 0;
    if (pw == 1) return base;
    if (pw == 0) return 1;
    ll ret = fp(base, pw / 2) % mod;
    ret = ((ret % mod) * (ret % mod)) % mod;
    if (pw % 2) ret = ((base % mod) * (ret % mod)) % mod;
    return ret;
}
const int N = 2e5 + 5;
ll fact[N];
ll calc(ll a, ll b) {
    ll ret = 1;
    for (ll i = a; i > a - b; i--) ret = ((ret % mod) * (i % mod)) % mod;
    ret = ((ret % mod) * fp(fact[b] % mod, mod - 2)) % mod;
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll res = fp(2, n) - 1;
    res += mod;
    res %= mod;
    fact[1] = 1;
    for (int i = 2; i <= 2e5; i++) fact[i] = ((fact[i - 1] % mod) * (i % mod)) % mod;
    res -= calc(n, a);
    res += mod;
    res %= mod;
    res -= calc(n, b);
    res += mod;
    res %= mod;
    cout << res;
    return 0;
}


Measured memory_bytes: 1792
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
ans=1
cnt=0
for i in range(n):
  limit=(arr[i]+1)//2+cnt
  if i+1>limit:
    ans*=(i+1-cnt)
    ans%=mod
    cnt+=1
for i in range(1,n-cnt+1):
  ans*=i
  ans%=mod
print(ans)

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

int min( int a, int b )
{
    return a < b ? a : b;
}

int max( int a, int b )
{
    return a > b ? a : b;
}

int main()
{
    string s;

    cin >> s;
    s += "a";

    int jcnt = 0, ocnt = 0, icnt = 0, m = 0;
    bool jj = false, oj = false, ij = false;
    for( int i = 0; i < s.size(); i++ )
    {
        if( s[i] == 'J' && ij == false )
        {
            jcnt++;
            jj = true;
        }
        else if( s[i] == 'O' && jj == true )
        {
            ocnt++;
            ij = true;
            oj = true;
        }
        else if( s[i] == 'I' && oj == true )
        {
            jj = false;
            icnt++;
        }
        else
        {
            if( jj == 0 && ij == 1 && oj == 1 && ocnt <= jcnt && ocnt <= icnt )
                m = max( m, ocnt );
            jcnt = 0; ocnt = 0; icnt = 0;
            jj = 0; oj = 0; ij = 0;
            if( i != 0 && ( s[i-1] == 'O' || s[i-1] == 'I' ) && s[i] == 'J' )
                i--;
        }
    }

    cout << m << endl;

    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

int main() {
  double r;
  cin >> r;
  cout << 2.0 * r * 3.14159265359 << endl;

  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <sstream>

std::string encode(std::string s){
    std::stringstream r;
    int l = s.size();
    s.append("a");  //  centinel
    int rl = 1;
    for(int i=0; i<l; i++){
        if(s[i] == s[i+1])
            rl++;
        else{
            r << rl << s[i];
            rl = 1;
        }
    }
    return r.str();
}

int main(){
    int n;
    std::string s;
    while(std::cin >> n, n){
        std::cin >> s;
        for(int i=0; i<n; i++)
            s = encode(s);
        std::cout << s << std::endl;
    }
}

Measured memory_bytes: 1408
#include <vector>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
int main() {
	int N;
	int M;
	int c;

	cin >> N >> M >> c;
	vector<int> B(M);
	for (int i = 0; i < M; i++)
		cin >> B[i];
	vector<vector<int> > T(N, vector<int>(M));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> T[i][j];

		}
	}
	int sum = 0;

	for (int i = 0; i < N; i++)
	{
		int k = 0;
		for (int j = 0; j < M; j++)
			k = k + B[j] * T[i][j];
		k = k + c;
		if (k > 0)
			sum = sum + 1;
	}
	cout <<sum;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll A, B, M;
  cin >> A >> B >> M;

  VL as(A);
  rep(i, A) cin >> as[i];

  VL bs(B);
  rep(i, B) cin >> bs[i];

  ll res = *min_element(all(as)) + *min_element(all(bs));

  rep(i, M) {
    ll x, y, c;
    cin >> x >> y >> c;
    x--, y--;

    chmin(res, as[x] + bs[y] - c);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, a;
    cin >> h >> a;
    int count = 0;
    while(h > 0)
    {
        h = h - a;
        count ++;
    }
    cout << count << endl;


    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long

vector<int> adj[100005];

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

    int n, m;
    cin >> n >> m;
    vector<int> h(n + 1);
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int ok = 1;
        for (int j : adj[i]) {
            if (h[j] >= h[i]) {
                ok = 0;
                break;
            }
        }
        ans += ok;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 8748
#include <bits/stdc++.h>
using namespace std;
vector <char> a;

int main() {
    char c;
    while (cin >> c) {
        if (c == 'B' && a.size()) a.pop_back();
        else if (c == '1' || c == '0') a.push_back(c);
    }
    for (int i = 0; i < a.size(); i++) cout << a[i];
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
#define accum(x) accumulate((x).begin(), (x).end(), 0)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
  int x;
  cin >> x;
  if (x == 0)
    cout << 1 << endl;
  else if (x == 1)
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> t(n);
	rep(i,n) cin >> t.at(i);
	ll ans=0;
	rep(i,n-1){
		if(t.at(i+1)-t.at(i)<m){
			ans+=t.at(i+1)-t.at(i);
		}
		else{
			ans+=m;
		}
	}
	ans+=m;
	cout << ans << endl;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
res = [0] * m

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[x - 1] += 1

ans = sum(1 for x in res if x == n)

print(ans)


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

#define LIMIT 1000000007 //10^9+7

namespace /* combination.cpp */{
  namespace /* modinv.cpp */{
    namespace /* extGCD.cpp */{
      long long extGCD(long long a, long long b, long long &x, long long &y) {
          if (b == 0) {
              x = 1;
              y = 0;
              return a;
          }
          long long d = extGCD(b, a%b, y, x);
          y -= a/b * x;
          return d;
      }
    }
    long long modinv(long long a, long long p){
      long long x, y;
      extGCD(a, p, x, y);
      return (x>0? x: x+p);
    }
  }
  long long l_fac(long long n){
    if(n<0) return -1;
    long long ans = 1;
    for(long long i=1; i<=n; i++){
      ans *= i;
      ans %= LIMIT;
    }
    return ans;
  }
  long long l_nPr(long long n, long long r){
    long long ans = 1;
    for(long long i=0; i<r; i++){
      ans *= (n-i);
      ans %= LIMIT;
    }
    return ans;
  }
  long long l_nCr(long long n, long long r){
    if(r > n/2) r = n-r;
    return l_nPr(n, r) * modinv(l_fac(r), LIMIT) % LIMIT;
  }
}


namespace /* COMfast.cpp */{
  #define COMMAX 1000000 //0.15sで構築可能
  long long fac[COMMAX], finv[COMMAX], inv[COMMAX];
  // テーブルを作る前処理
  void COMinit() {
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < COMMAX; i++){
          fac[i] = fac[i - 1] * i % LIMIT;
          inv[i] = LIMIT - inv[LIMIT%i] * (LIMIT / i) % LIMIT;
          finv[i] = finv[i - 1] * inv[i] % LIMIT;
      }
  }

  // 二項係数計算
  long long COM(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % LIMIT) % LIMIT;
  }
}

#define debug2(x,y) cout<<"("<<#x<<","<<#y<<") = ("<<(x)<<","<<(y)<<")\n"


int main(){
  COMinit();
  int N,K;cin>>N>>K;
  ll a, b, ans;
  for(int i=1; i<=K; i++){
    //a = l_nCr(K-1, i-1);
    a = COM(K-1, i-1) % LIMIT;
    //b = l_nCr(N-K+1, i);
    b = COM(N-K+1, i) % LIMIT;
    //debug2(a,b);
    ans = a * b % LIMIT;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 23680
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static int[] rsp;
        static void Main(string[] args)
        {
            int[] nk = ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ls = new List<long>();
            for (int i = 0; i < nk[0]; i++)
            {
                ls.Add(long.Parse(ReadLine()));
            }
            var tmp = ls.OrderBy(x => x).ToList();
            long ans = long.MaxValue;
            for (int i = 0; i < nk[0] - nk[1]+1; i++)
            {
                if (tmp[i+nk[1]-1] - tmp[i] < ans)
                {
                    ans = tmp[i + nk[1]-1] - tmp[i];
                }
            }
            WriteLine(ans);
        }

        
    }
}


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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n,n){
		map<int,int> data;
		map<string,int> m;
		std::vector<int> v;
		string tmp;
		for(int i =0 ;i < n;i++){
			int x;
			cin>>x;
			stringstream ss;
			ss <<x;
			tmp +=ss.str();
			v.push_back(x);
			data[x]++;
		}
		//cout <<tmp<<endl;
		m[tmp]++;
		std::vector<int> ans;
		int cnt =0;
		map<int,int> t;
		while(1){
			string str ="";
			cnt++;
			ans.clear();
			t.clear();
			for(int i =0;i < v.size();i++){
				stringstream ss;
				ss <<data[v[i]];
				str +=ss.str();
				t[data[v[i]]]++;
				ans.push_back(data[v[i]]);
			}
			if(m[str]){
				break;
			}else{
				m[str]++;
			}
			//cout <<str<<endl;
			v=ans;
			data.clear();
			data =t;
		}
		cout <<cnt-1<<endl;
		for(int i =0;i < ans.size();i++){
			cout <<ans[i];
			if(i!=ans.size()-1)cout <<" ";
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
map<string,ll> mp;
int main(){
    int q; cin >> q;
    multiset<ll> st;
    rep(i,q){
        ll com, x;
        string key;
        cin >> com >> key;
        if(com == 0){
            cin >> x;
            mp[key] = x;
        }else if(com == 1)cout << mp[key] << endl;
        else mp.erase(key);
    }
    return 0;
}


Measured memory_bytes: 27868
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C, D = map(int, input().split())
    l = A + B
    r = C + D
    if l == r:
        print("Balanced")
    elif l > r:
        print("Left")
    else:
        print("Right")
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 4080