akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int gcm(int a,int b){
  if (b>a){
    return gcm(b,a);
  }
  if (a==b) return a;
  else if (b==0) return a;
  else return gcm(b,a%b);
}

int main(){
  int n,x,dum,res,mins=1000000001;
  cin >> n >> x;
  mins=min(x,mins);
  vector<int> arx;
  arx.push_back(x);
  for(int i=0;i<n;i++){
    cin >> dum;
    arx.push_back(dum);
    mins=min(dum,mins);
  }
  for(int i=0;i<=n;i++){
    arx[i]-=mins;
    //cout << arx[i] << "  ";
  }
  //cout << endl;
  res=arx[0];
  //cout << res << "  ";
  for(int i=1;i<=n;i++){
    res=gcm(res,arx[i]);
    //cout << res << "  ";
  }
  //cout  << endl;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 892
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

cnt=0
ans=0
Z=1
for i in range(n):
    Q=lcm(Z,A[i])
    cnt*=Q//Z
    Z=Q
    cnt+=Q//A[i]
print(cnt%mod)

Measured memory_bytes: 44636
#include<iostream>
#include<set>
#include<vector>
#include<map>
using namespace std;
typedef long long li;
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int cnt(vector<int>& vx,vector<int>& vy,set<pair<int,int>>& st,int ans){
  for(int x:vx) for(int y:vy) if(st.count({x,y})==0) return ans;
  return ans-1;
}

int main(){
  int h,w,m; cin >>h >>w >>m;
  set<pair<int,int>> pos;
  map<int,int> row,col;
  rep(i,m){
    int a,b; cin >>a >>b;
    row[a]++;
    col[b]++;
    pos.insert({a,b});
  }
  int mx=0,my=0;
  for(pair<int,int> x:row) maximize(mx,x.second);
  for(pair<int,int> y:col) maximize(my,y.second);
  vector<int> vx,vy;
  for(pair<int,int> x:row) if(x.second==mx) vx.push_back(x.first);
  for(pair<int,int> y:col) if(y.second==my) vy.push_back(y.first);
  if(df){
    print(vx);
    print(vy);
  }
  if(vx.size()>m/vy.size()+1){
    print(mx+my);
    return 0;
  }
  print(cnt(vx,vy,pos,mx+my));
}


Measured memory_bytes: 49620
#include <iostream>

int main()
{
	int A = 0, B = 0, C= 0, ans = 0;
	std::cin >> A >> B >> C;

	int c1 = A - B;
	if (C < c1){
		c1 = C;
	}
	ans = C - c1;

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int k;
    while(cin>>k)
    {
        if(k%2==0)
        {
            cout<<k*k/4<<endl;
        }
        else
        {
            cout<<(k-1)*(k+1)/4<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 500005;
const ll MOD = 1000000007;

string str;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> str;

    ll ans = 0;

    int cnt = 0;
    for (int i=SZ(str)-1; i>=0; i--) {
        if (str[i] == 'A') {
            ans += cnt;
        } else if (i>0&&str[i]=='C'&&str[i-1]=='B') {
            cnt++;
            i--;
        } else {
            cnt = 0;
        }
    }

    cout << ans << endl;
}


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

const int maxn = 305, mod = 1e9 + 7;

int n, m;
int f[maxn][maxn][maxn];
vector<pair<int, int> > vec[maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline void inc(int &a, int b) {a += b; if (a >= mod) a -= mod;}

inline bool check(int r, int j, int k)
{
	for (int i = 0; i < vec[r].size(); ++i)
		if (1 + (vec[r][i].first <= j) + (vec[r][i].first <= k) != vec[r][i].second) return 0;
	return 1;
}

int main()
{
	n = gi(); m = gi();
	for (int l, r, x, i = 1; i <= m; ++i) {
		l = gi(); r = gi(); x = gi();
		vec[r].push_back(make_pair(l, x));
	}

	if (check(1, 0, 0)) f[1][0][0] = 3;
	for (int i = 1; i < n; ++i)
		for (int j = 0; j < i; ++j)
			for (int k = 0; k < i; ++k) {
				if (!f[i][j][k]) continue;
				if (check(i + 1, j, k))
					inc(f[i + 1][j][k], f[i][j][k]);
				if (check(i + 1, i, k))
					inc(f[i + 1][i][k], f[i][j][k]);
				if (check(i + 1, j, i))
					inc(f[i + 1][j][i], f[i][j][k]);
			}

	int ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			inc(ans, f[n][i][j]);
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 108928
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
  static void Main()
  {
    int[] NC = Console.ReadLine().Split().Select(int.Parse).ToArray();
    List<int[]> X = new List<int[]>();
    for(int i = 0; i < NC[1]; i++){
      X.Add(Console.ReadLine().Split().Select(int.Parse).ToArray());
    }
    List<int[]> Y = new List<int[]>();
    for(int i = 0; i < NC[0]; i++){
      Y.Add(Console.ReadLine().Split().Select(int.Parse).ToArray());
    }
    List<int[]> Z = new List<int[]>();
    for(int i = 0; i < 3; i++){
      Z.Add(new int[NC[1]]);
    }
    for(int i = 0; i < NC[0]; i++){
      for(int j = 0; j < NC[0]; j++){
        Z[(i+j)%3][Y[i][j]-1] += 1;
      }
    }
    int R = 2000000000;
    for(int i = 0; i < NC[1]; i++){
      int tr = 0;
      for(int l = 0; l < NC[1]; l++){
        tr += Z[0][l]*X[l][i];
      }
      for(int j = 0; j < NC[1]; j++){
        if (i==j){continue;}
        int tr2 = 0;
        for(int l = 0; l < NC[1]; l++){
          tr2 += Z[1][l]*X[l][j];
        }
        for(int k = 0; k < NC[1]; k++){
          if (i==k ^ j==k){continue;}
          int tr3 = 0;
          for(int l = 0; l < NC[1]; l++){
            tr3 += Z[2][l]*X[l][k];
          }
          R = Min(R, tr+tr2+tr3);
//          Console.WriteLine("{0} {1} {2} {3}", i, j, k, tr+tr2+tr3);
        }
      }
    }
    Console.WriteLine(R);
  }
}


Measured memory_bytes: 18628
#include <iostream>
#include <stdio.h>
#define MAX 2000000


int n, H[MAX];

void maxHeapify(int i) {
    int max_index;
    int left = i * 2;
    int right = i * 2 + 1;
    if (H[left] > H[right]) max_index = left;
    else max_index = right;
    if (H[i] < H[max_index]) {
        std::swap(H[i], H[max_index]);
        if (max_index*2 <= n || max_index*2+1 <= n) maxHeapify(max_index);
    }
}

void buildMaxHeap() {
    for (int i = n/2; i >= 1; i--) {
        maxHeapify(i);
    }
}

int main() {
    int key;
    scanf("%d", &n);
    
    for (int i = 1; i <= n; i++) H[i] = -1;
    
    for (int i = 1; i <= n; i++) {
        scanf("%d", &key);
        H[i] = key;
    }
    
    buildMaxHeap();
    
    for (int i = 1; i <= n; i++) {
        printf(" %d", H[i]);
    }
    printf("\n");
    
    return 0;
}



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

using namespace std;

int dp[101][10001];

int main() {
  int N,W;
  vector<int> v, w;
  cin>>N>>W;
  for (int i=0;i<N;++i) {
    int vv, ww;
    cin>>vv>>ww;
    v.push_back(vv);
    w.push_back(ww);
  }

  for (int i=1;i<=N;++i) {
    for (int j=0;j<=W;++j) {
      if (j-w[i-1] < 0) {
        dp[i][j] = dp[i-1][j];
      }
      else {
        dp[i][j] = max(dp[i][j-w[i-1]]+v[i-1], dp[i-1][j]);
      }
    }
  }

  cout<<dp[N][W]<<endl;

  return 0;
}


Measured memory_bytes: 7096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    string S, T; cin >> S >> T;

    string SC = S, TC = T;

    sort(all(SC));
    sort(all(TC));

    deque<ll> deqs, deqt;

    ll jj = 1;
    rep(i, SC.size()-1) {
        if (SC[i] == SC[i + 1]) {
            ++jj;
        }
        else {
            deqs.push_back(jj);
            jj = 1;
        }
    }
    if (SC[SC.size() - 2] == SC[SC.size() - 1]) deqs.push_back(jj);

    jj = 1;
    rep(i, TC.size() - 1) {
        if (TC[i] == TC[i + 1]) {
            ++jj;
        }
        else {
            deqt.push_back(jj);
            jj = 1;
        }
    }
    if (TC[TC.size() - 2] == TC[TC.size() - 1]) deqt.push_back(jj);

    sort(all(deqs));
    sort(all(deqt));

    if (deqs.size() != deqt.size()) {
        cout << "No" << endl;
        return 0;
    }
    else {
        ll a = deqs.size();
        rep(i, a) {
            if (deqs[i] != deqt[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }


}

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

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

  vector<int> X(N), Y(N), H(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i) >> H.at(i);
  }

  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      int Hprev = -1, Htmp;
      bool flag = true;
      for (int i = 0; i < N; i++) {
        if (H[i] == 0) continue;
        Htmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy);
        if (Hprev == -1) {
          Hprev = Htmp;
        } else if (Htmp != Hprev) {
          flag = false;
          break;
        }
      }
      if (flag) {
        for (int i = 0; i < N; i++) {
          if (H[i] == 0) {
            int dx = abs(X[i] - cx);
            int dy = abs(Y[i] - cy);
            if (0 < Htmp - abs(X[i] - cx) - abs(Y[i] - cy)) {
              flag = false;
              break;
            }
          }
        }
      }
      if (flag) {
        cout << cx << ' ' << cy << ' ' << Hprev << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a;
    cin>>a;
    sort(a.begin(),a.end());
    
    string b;
    cin>>b;
    sort(b.begin(),b.end());
    sort(b.rbegin(),b.rend());
    
    if(a<b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
 return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    string s ;
    cin >> s ;
    size_t n = s.length();
    bool f1 = false , f2 = false ; 
    for(int i = 0 ; i < n ; i++){
        if(s[i] == 'C'){
            f1 = true ;
        }
        if(f1 == true && s[i] == 'F'){
            f2 = true ;
        }
    }
    if(f1 == true && f2 == true){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }
   
}

Measured memory_bytes: 3624
a,b,c,d = map(int, input().split())
x,y = c-a,d-b
s = "U"*y+"R"*x+"D"*y+"L"*x
s += "L"+"U"*(y+1)+"R"*(x+1)+"DR"+"D"*(y+1)+"L"*(x+1)+"U"
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
#include<cstring>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> cnt(100);
	for (int i = 2; i <= n; i++) {
		int ki = i;
		for (int j = 2; j * j <= i; j++) {
			if (ki % j == 0) {
				int cntj = 0;
				while (ki % j == 0) {
					cntj++;
					ki /= j;
				}
				cnt[j] += cntj;
			}
		}
		if (ki != 1) cnt[ki]++;
	}
	int ans = 0;
	if (cnt[2] >= 74) ans++;
	for (int i = 2; i <= 98; i++) {
		for (int j = i + 1; j < 99; j++) {
			if (cnt[i] >= 2 && cnt[j] >= 24) ans++;
			if (cnt[i] >= 24 && cnt[j] >= 2) ans++;
			if (cnt[i] >= 4 && cnt[j] >= 14) ans++;
			if (cnt[i] >= 14 && cnt[j] >= 4) ans++;
		}
	}
	for (int i = 2; i <= 97; i++) {
		for (int j = i + 1; j <= 98; j++) {
			for (int k = j + 1; k <= 99; k++) {
				if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ans++;
				if (cnt[i] >= 4 && cnt[j] >= 2 && cnt[k] >= 4) ans++;
				if (cnt[i] >= 4 && cnt[j] >= 4 && cnt[k] >= 2) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	V a(n + 1);
	rep1(i, n) {
		cin >> a[i];
	}
	V dp(n + 1, upper);
	dp[1] = 0;
	rep1(i, n) {
		if (i - 1 >= 0) chmin(dp[i], dp[i - 1] + abs(a[i - 1] - a[i]));
		if (i - 2 >= 0) chmin(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]));
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> tree1[20],tree2[20];
bool visited[20];
int cost[20][20],parent[20],sum=0;
void make_tree(int pos) {
	visited[pos]=true;
	for(int i=0;i<tree1[pos].size();i++) {
		if(visited[tree1[pos][i]]) continue;
		tree2[pos].push_back(tree1[pos][i]);
		parent[tree1[pos][i]]=pos;
		make_tree(tree1[pos][i]);
	}
}
void lower(int pos,int c) {
	visited[pos]=true;
	for(int i=0;i<tree2[pos].size();i++) {
		if(visited[tree2[pos][i]]) continue;
		if(tree2[tree2[pos][i]].size()==0) continue;
		lower(tree2[pos][i],cost[pos][tree2[pos][i]]);
	}
	sum+=c*2;
}
void upper(int pos) {
	sum=0;
	while(pos!=-1) {
		visited[pos]=true;
		for(int i=0;i<tree2[pos].size();i++) {
			if(visited[tree2[pos][i]]) continue;
			if(tree2[tree2[pos][i]].size()==0) continue;
			lower(tree2[pos][i],cost[pos][tree2[pos][i]]);
		}
		if(parent[pos]!=-1) {
			sum+=cost[parent[pos]][pos];
		}
		pos=parent[pos];
	}
}
int main() {
	int N;
	while(scanf("%d",&N),N) {
		int a,b,t;
		for(int i=0;i<N;i++)
			tree1[i].clear();
		memset(cost,0,sizeof(cost));
		for(int i=0;i<N-1;i++) {
			scanf("%d %d %d",&a,&b,&t); a--; b--;
			tree1[a].push_back(b);
			tree1[b].push_back(a);
			cost[a][b]=cost[b][a]=t;
		}
		int ans=1<<30;
		for(int i=0;i<N;i++) {
			memset(visited,0,sizeof(visited));
			memset(parent,-1,sizeof(parent));
			for(int j=0;j<N;j++)
				tree2[j].clear();
			make_tree(i);
			memset(visited,0,sizeof(visited));
			upper(0);
			ans=min(ans,sum);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1052
N=int(input())
S=input()
from itertools import product
l=list(product(["0","1","2","3","4","5","6","7","8","9"], repeat=3))
a=0
for i in l:
    for j in range(N):
        if i[0]==S[j]:
            for k in range(j+1,N):
                if i[1]==S[k]:
                    for m in range(k+1,N):
                        if i[2]==S[m]:
                            a+=1
                            break
                    break
            break
print(a)

Measured memory_bytes: 42972
N,M,X = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
now = X
left = 0
right = 0
loop do
    now -= 1
    left += 1 if A.include?(now)
    break if now == 0
end

now = X
loop do
    now += 1
    right += 1 if A.include?(now)
    break if now == N+1
end
puts [left, right].min

Measured memory_bytes: 1788
const main = input => {
  const numberList = input.split(' ')
  const number1 = parseInt(numberList[0], 10)
  const number2 = parseInt(numberList[1], 10)
  
  if (number1 * number2 % 2 === 0) {
  	console.log('Even')
  } else {
  	console.log('Odd')
  }
}

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

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

int dp[110][10100];
int N;
int W;
int val[110];
int wei[110];

int main(void){

    cin>>N>>W;
    
    for(int i=0;i<N;i++) cin>>val[i]>>wei[i];
    
    for(int w=0;w<=N;w++) dp[0][w] = 0;
    
    for(int i=0;i<N;i++){
        for(int w=0;w<=W;w++){
            if(w>=wei[i])
                dp[i+1][w] = max(dp[i][w] , dp[i][w-wei[i]] + val[i]);
            else 
                dp[i+1][w] = dp[i][w];
        }
    }
    
    cout<<dp[N][W]<<"\n";
    
}



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

int a,b,m;
int minA = 1000000;
int minB = 1000000;
int minC = 1000000;

int main() {
  cin >> a >> b >> m;
  std::vector<int> fridge(a);
  std::vector<int> micro(b);
  for (size_t i = 0; i < a; i++) {
    cin >> fridge.at(i);
  }
  for (size_t i = 0; i < b; i++) {
    cin >> micro.at(i);
  }
  std::vector<vector<int>> chicket(3,std::vector<int>(m));
  for (size_t i = 0; i < m; i++) {
    cin >> chicket.at(0).at(i);
    cin >> chicket.at(1).at(i);
    cin >> chicket.at(2).at(i);
  }
  for (size_t i = 0; i < a; i++) {
    minA = min(minA, fridge.at(i));
  }
  for (size_t i = 0; i < b; i++) {
    minB = min(minB, micro.at(i));
  }
  for (size_t i = 0; i < m; i++) {
    minC = min(minC, fridge.at(chicket.at(0).at(i) - 1) + micro.at(chicket.at(1).at(i) - 1) - chicket.at(2).at(i));
  }
  cout << min(minA + minB, minC) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int h,w;
  while(true){
      cin >>h>>w;
      if (h==0 && w==0){
          break;
      }
      for (int i=0; i<h; i++){
          for(int j=0; j<w; j++){
              if (i==0 || i==h-1 || j==0 || j==w-1){
                  printf("#");
              }else{
                  printf(".");
              }
          }
          printf("\n");
      }
      printf("\n");
  }
}


Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
char s1[4],s2[4];
int ans=0;
int main(){
//    gets(s1);
//    gets(s2);
	cin >> s1 >> s2;
	for(int i=0;i<3;i++){
		if(s1[i]!=s2[i]) ans++; 
	}
	printf("%d\n",3 - ans);
	return 0;
}

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

/*int main()
{
    string s,t,n;
    cin>>s>>t;

}*/

/*long long main()
{
    long long t;
    cin>>t;
    string s1,s2;
    for (long long i = 0; i < 2*k; ++i)
    {
        cin>>s1>>s2;
    }
    for (long long i = s1.length(); i > 0; --i)
    {
        
    }
}*/

/*int main()
{
    long long t,nl,l,r;
    cin>>t;
    while(t--)
    {
        cin>>nl>>l;
        cin>>nr>>r;
    }
}*/
int lcs(string x,string y,int m,int n)
{
    if(m==0 || n==0)
        return 0;
    if(x[m-1]==y[n-1])
        return 1+lcs(x,y,m-1,n-1);
    else
        return max(lcs(x,y,m-1,n),lcs(x,y,m,n-1));
}
/*int f(int p)
{
    int k=p,o,last=p%10,cnt=0;
    while()
    {
        o=k%10;
        k=k/10;
        if(last!=o)
        {

        }
    }
}*/

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int dp[s1.length()+1][s2.length()+1];
    for (int i = 0; i < s1.length()+1; ++i)
    {
        dp[i][0]=0;
    }
    for (int i = 0; i < s2.length()+1; ++i)
    {
        dp[0][i]=0;
    }
    for (int i = 1; i <= s1.length(); ++i)
    {
        for (int j = 1; j <= s2.length(); ++j)
        {
            if(s1[i-1]!=s2[j-1])
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            else
                dp[i][j]=1+dp[i-1][j-1];
        }
    }
    int index=dp[s1.length()][s2.length()];
    //cout<<index;
    vector<char> v;
    int y=s1.length(),x=s2.length();
    while(y>0 && x>0)
    {
        if(s1[y-1]==s2[x-1])
        {
            v.push_back(s1[y-1]);
            y--;
            x--;
            index--;
        }
        else if(dp[y-1][x]>dp[y][x-1])
            y--;
        else
            x--;
    }
    if(v.size()==0)
        cout<<"";
    else
    {
        for (int i = v.size()-1; i >= 0; i--)
        {
            cout<<v[i];
        }
    }
}

Measured memory_bytes: 35456
a = list(map(int, input().split()))
number = 0
pic = []
for i in range(a[0] + 1):
    str_number = str(number)
    p =  list(str_number)
    now_line = list(map(int, p))
    sum_a = sum(now_line)
    
    # print(now_line)
    # print(sum_a)
    
    if a[1] <= sum_a <= a[2]:
        pic.append(number)
        # print(number)
        
    number += 1 
    
    
print(sum(pic))

Measured memory_bytes: 3444
#include<cstdio>
#define MN 20005
int n,a[MN],i,x;
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&x),a[x]=i+1;
  for(i=1;i<=n;i++)printf("%d%c",a[i]+i*MN,i<n?' ':'\n');
  for(i=1;i<=n;i++)printf("%d ",(n-i+1)*MN);
  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
namespace Solve
{
	int N,K;
	void work()
	{
		scanf("%d%d",&N,&K);
		int fig=0;
		while(N)
		{
			fig++;
			N/=K;
		}
		if(!fig) fig++;
		printf("%d\n",fig);
		return;
	}
}
int main()
{
	#ifdef LOCAL
	freopen("00test.in","r",stdin);
	freopen("00test.out","w",stdout);
	#endif
	Solve::work(); 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  cout << max(A*B, C*D) << endl;
}

Measured memory_bytes: 256
import math

X = int(input())

num_list = [i ** 5 for i in range(-120, 121)]

for i in range(len(num_list)-1):
    for j in range(i,len(num_list)):
        if num_list[j] - num_list[i] == X:
            A = -120 + j
            B = -120 + i
            print(A, B)
            break
    else:
        continue
    break

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using std::vector;
using std::pair;
using pii = pair<int, int>;
int arr[200010];

struct indexed_tree {
	vector<pii> tree;
	int k = 1;
	indexed_tree(int n) {
		while (k < n)k *= 2;
		tree.resize(k * 2 + 10, { 0x7fffffff,-1 });
	}
	void update(int idx, pii a) {
		idx += k;
		while (idx) {
			tree[idx] = std::min(tree[idx], a);
			idx /= 2;
		}
	}
	pii getRange(int left, int right) {
		left += k; right += k;
		pii ret = { 0x7fffffff,-1 };
		while (left <= right) {
			if (left % 2 == 1)ret = std::min(ret, tree[left]);
			if (right % 2 == 0)ret = std::min(ret, tree[right]);
			left = (left + 1) / 2;
			right = (right - 1) / 2;
		}
		return ret;
	}
};
struct node {
	pair<pii,pii> q;
	int l, r;
	bool operator>(const node& p) const{
		return q > p.q;
	}
};
int main() {
	int n;
	scanf("%d", &n);

	indexed_tree odd(n), even(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		if (i % 2 == 0)even.update(i, { arr[i],i });
		else odd.update(i, { arr[i],i });
	}
	std::priority_queue<node, vector<node>, std::greater<node>> heap;
	auto tmp = even.getRange(0, n - 1);
	heap.push({ {tmp,odd.getRange(tmp.second+1,n - 1)},0,n - 1 });
	std::string print = "";
	int cnt = 0;
	while (!heap.empty()) {
		cnt++;
		int L = heap.top().l;
		int R = heap.top().r;
		int one = heap.top().q.first.second;
		int two = heap.top().q.second.second;
		int a = heap.top().q.first.first;
		int b = heap.top().q.second.first;
		heap.pop();
		char str[50];
		sprintf(str,"%d %d ", a, b);
		print += str;
		if (one > two)std::swap(one, two);
		vector<pii> segs = { { L, one - 1 },{ one + 1,two - 1 },{ two + 1,R } };
		if (L + 1 != R) {
			for (pii s : segs) {

				int l = s.first;
				int r = s.second;
				if (l+1 > r)continue;
				
				assert((r - l + 1) % 2 == 0);
				if (l % 2 == 0) {

					auto e = even.getRange(l, r);
					auto o = odd.getRange(e.second+1, r);
					heap.push({ {e,o},l,r });
				}
				else {
					auto o = odd.getRange(l, r);
					auto e = even.getRange(o.second + 1, r);
					heap.push({ {o,e},l,r });
				}
			}
		}
	}
	//assert(cnt == n / 2);
	printf("%s", print.c_str());
}

Measured memory_bytes: 13744
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    int n;cin >> n;
    LL xa=LINF,xb=-LINF,ya=LINF,yb=-LINF;
    vector<LL> v[4];
    for (int i = 0; i < n; i++) {
        LL x,y;
        char d;
        cin >> x >> y >> d;
        if(d=='L'){
            v[0].pb(x);
            ya = min(ya,y);
            yb = max(yb,y);
        }
        else if(d=='R'){
            v[1].pb(x);
            ya = min(ya,y);
            yb = max(yb,y);
        }
        else if(d=='D'){
            v[2].pb(y);
            xa = min(xa,x);
            xb = max(xb,x);
        }
        else{
            v[3].pb(y);
            xa = min(xa,x);
            xb = max(xb,x);
        }
    }
    for (int i = 0; i < 4; i++) {
        sort(ALL(v[i]));
    }
    vector<double> t;
    t.pb(0);
    if(v[0].size()){
        if(xa!=LINF) t.pb(abs(xa - v[0].front()));
        if(xb!=-LINF) t.pb(abs(xb - v[0].back()));
    }
    if(v[1].size()){
        if(xb!=-LINF) t.pb(abs(xb - v[1].back()));
        if(xa!=LINF) t.pb(abs(xa - v[1].front()));
    }
    if(v[0].size()&&v[1].size()){
        t.pb(abs(v[0].back() - v[1].back()) / 2.);
        t.pb(abs(v[0].front() - v[1].front()) / 2.);
    }
    if(v[2].size()){
        if(ya!=LINF) t.pb(abs(ya - v[2].front()));
        if(yb!=-LINF) t.pb(abs(yb - v[2].back()));
    }
    if(v[3].size()){
        if(yb!=-LINF) t.pb(abs(yb - v[3].back()));
        if(ya!=LINF) t.pb(abs(ya - v[3].front()));
    }
    if(v[2].size()&&v[3].size()){
        t.pb(abs(v[2].back() - v[3].back()) / 2.);
        t.pb(abs(v[2].front() - v[3].front()) / 2.);
    }
    double ans = 1e20;
    for (int i = 0; i < t.size(); i++) {
        double txb=xb,txa=xa,tyb=yb,tya=ya;
        for (int k = 0; k < 4; k++) {
            for (int j = 0; j < v[k].size(); j++) {
                if(k==0){
                    double x;
                    x = v[k][j] - t[i];
                    txb = max(txb,x);
                    txa = min(txa,x);
                }
                else if(k==1){
                    double x;
                    x = v[k][j] + t[i];
                    txb = max(txb,x);
                    txa = min(txa,x);
                }
                else if(k==2){
                    double y;
                    y = v[k][j] - t[i];
                    tyb = max(tyb,y);
                    tya = min(tya,y);
                }
                else{
                    double y;
                    y = v[k][j] + t[i];
                    tyb = max(tyb,y);
                    tya = min(tya,y);
                }
            }
        }
        ans = min(ans,(txb-txa)*(tyb-tya));
    }
    cout << setprecision(30) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>

int main(void)
{
    int i,N,color,max=0,min=0,sum=0;
    int kind[9]={};

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&color);
        if(0<color&&color<=399)kind[0]=1;
        else if(400<=color&&color<=799)kind[1]=1;
        else if(800<=color&&color<=1199)kind[2]=1;
        else if(1200<=color&&color<=1599)kind[3]=1;
        else if(1600<=color&&color<=1999)kind[4]=1;
        else if(2000<=color&&color<=2399)kind[5]=1;
        else if(2400<=color&&color<=2799)kind[6]=1;
        else if(2800<=color&&color<=3199)kind[7]=1;
        else if(3200<=color)kind[8]++;
    }
    for(i=0;i<8;i++)sum+=kind[i];
    max=sum+kind[8];
    if(sum==0&&kind[8]>0)min=1;
    else min=sum;
    printf("%d %d\n",min, max);
    
    return 0;
}

Measured memory_bytes: 128
pragma(inline, true)
void chmin(T)(ref T a, T b) {
    if (a > b) a = b;
}
 
int[] init() {
    enum INF = 1 << 28;
    int[] dp = new int[100010];
    foreach (i; 1..100001) {
        dp[i] = INF;
        int p6 = 1, p9 = 1;
        while (p6 <= i || p9 <= i) {
            if (i - p6 >= 0)
                chmin(dp[i], dp[i - p6] + 1);
            if (i - p9 >= 0)
                chmin(dp[i], dp[i - p9] + 1);
            p6 *= 6; p9 *= 9;
        }
    }
    return dp;
}
void main() {
    import std.conv : to;
    import core.stdc.stdio : printf, scanf;
    import std.string : chomp;
    enum dp = init();
    int n; scanf("%d", &n);
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;
#define inf 100000000

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
	
	int smov[26];
	int tmov[26];
	rep(i,0,26){
		smov[i] = -1;
		tmov[i] = -1;
	}

	rep(i,0,t.size()){
		if(smov[s[i]-'a'] == -1){
			smov[s[i]-'a'] = t[i]-'a';
		}
		if(tmov[t[i]-'a'] == -1){
			tmov[t[i]-'a'] = s[i]-'a';
		}
		if(smov[s[i]-'a'] != -1 && smov[s[i]-'a'] != t[i]-'a'){
			cout << "No" << endl;
			return 0;
		}else if(tmov[t[i]-'a'] != -1 && tmov[t[i]-'a'] != s[i]-'a'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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


Measured memory_bytes: 3636
n,m=map(int,input().split())
l=[]
for i in range(m):
    p,s=input().split()
    l.append((int(p),s))
w=[0]*n
a=[0]*n
for i in range(m):
    if a[l[i][0]-1]==0:
        if l[i][1]=="AC":
            a[l[i][0]-1]=1
        else:
            w[l[i][0]-1]+=1
for i in range(n):
    w[i]*=a[i]
AC=sum(a)
WA=sum(w)
print(AC,WA)

Measured memory_bytes: 20552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200005;

int n;
ll a[N], total;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= (i + 1);
        total += a[i];
    }
    sort(a, a + n);
    
    ll ldist = 0, rdist = 0;
    for (int i = 1; i < n; i++) rdist += a[i] - a[0];
    
    ll sadness = rdist;
    for (int i = 1; i < n; i++) {
        ldist += i * (a[i] - a[i - 1]);
        rdist -= (n - i) * (a[i] - a[i - 1]);
        // cout << i << ' ' << ldist << ' ' << rdist << '\n';
        sadness = min(sadness, ldist + rdist);
    }
    
    cout << sadness;
}

    


Measured memory_bytes: 1792
<?php
  
  fscanf(STDIN,"%d %d %d",$n,$m,$x);
$a_li = explode(" ",trim(fgets(STDIN)));
$cost_up=0;
$cost_d=0;
$j=$x;
for($i=$x;$i<=$n;$i++){
  if(in_array($i,$a_li)){
    $cost_up++;
  }
 
}

for($j=$x;$j>0;$j--){
  if(in_array($j,$a_li)){
    $cost_d++;
  }
 
}

echo min($cost_up,$cost_d)."\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int n;
  cin >> n;
  string w[n];
  REP(i, n) cin >> w[i];
  int ans = 0;

  REP(i, n){
    if(i != 0){
      for(int j = 0; j < i; j++){
        if(w[j] == w[i]){
          ans++;
        }
      }
    }
  }
  int s;
  REP(i, n - 1){
    s = w[i].size();
    if(w[i][s - 1] != w[i + 1][0]){
      ans++;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    int d[3*n-2];
    for (int i = 0; i < n - 1; i++) {
        d[i] = b[i] ^ b[i+1];
    }
    d[n-1] = -1;
    for (int i = 0; i < 2 * n - 2; i++) {
        d[n+i] = a[i%n] ^ a[(i+1)%n];
    }

    int z[3*n-2];
    z[0] = n - 1;
    for (int i = 1, j0 = 0, j1 = 0; i < 3 * n - 2; i++) {
        if (i >= j1) {
            j0 = j1 = i;
        }
        if (z[i-j0] + i < j1) {
            z[i] = z[i-j0];
        } else {
            j0 = i;
            while (j1 < 3 * n - 2 && d[j1] == d[j1-j0]) {
                j1++;
            }
            z[i] = j1 - j0;
        }
    }

    for (int i = n; i < 2 * n; i++) {
        if (z[i] == n - 1) {
            cout << i - n << " " << (a[i-n] ^ b[0]) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9728
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,t=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
dp=[[-1]*t for i in range(n+1)]
dp[0][0]=0
ans=0
for i in range(n):
    a,b=ab[i]
    for j in range(t):
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
        if dp[i][j]>=0:
            if j+a>=t:
                ans=max(ans, dp[i][j]+b)
            else:
                dp[i+1][j+a]=max(dp[i+1][j+a], dp[i][j]+b)
for i in range(t):
    ans=max(ans, dp[-1][i])
print(ans)
# print(dp)

Measured memory_bytes: 137560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r;
  
  cin >> r;
  if(0<=r && r<1200){
    cout << "ABC" << endl;
  }
  else if(r<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int n; cin>>n;
    string c; cin>>c;
    Int ans=0;
    Int r=0;
    for(int i=0; i<n; i++){
        if(c[i]=='R') r++;
    }
    for(int i=0; i<r; i++){
        if(c[i]!='R') ++ans;
    }
    cout<<min(ans,n-ans)<<endl;
    return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>
int main(){
 int i,n,v[20]={},c[20]={},ans=0;
 scanf("%d",&n);
 for(i=0;i<n;i++)scanf("%d",&v[i]);
 for(i=0;i<n;i++)scanf("%d",&c[i]);
 for(i=0;i<n;i++)if(v[i]>c[i])ans+=v[i]-c[i];
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int>S;
int main()
{
	int H,W,i,j;
	char a[99][99];
	while(scanf("%d%d",&W,&H),W)
	{
		for(i=0;i<H;++i)scanf("%s",a[i]);
		int dp[99][99]={};
		for(i=H-1;i>=0;--i)
			for(j=W-1;j>=0;--j)
				if(isdigit(a[i][j]))
					dp[i][j]=max(dp[i+1][j],dp[i][j+1])+1;
		vector<S>u,v;
		for(i=0;i<H;++i)
			for(j=0;j<W;++j)
				u.push_back(S(j,i));
		int f=1;
		for(; u.size(); u=v,v.clear(),f=0)
		{
			int maxC=1,maxD=0;
			for(i=0;i<u.size();++i)
			{
				S s=u[i];
				int x=s.first,y=s.second;
				if(f&&a[y][x]=='0')continue;	
				if(maxC<dp[y][x])
				{
					maxC=dp[y][x];
					maxD=a[y][x];
				}
				else if(maxC==dp[y][x]&&maxD<a[y][x])
					maxD=a[y][x];
			}
			if(!maxD)break;
			putchar(maxD);
			for(i=0;i<u.size();++i)
			{
				S s=u[i];
				int x=s.first,y=s.second;
				if(dp[y][x]==maxC&&a[y][x]==maxD)
				{
					v.push_back(S(x+1,y));
					v.push_back(S(x,y+1));
				}
			}
			sort(v.begin(),v.end());
			v.erase(unique(v.begin(),v.end()),v.end());
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int main()
{
	int H, A;
	cin >> H >> A;
	int ans = (int)H / A + 1;
	if (H % A == 0) ans--;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int h, w, d;
    cin >> h >> w >> d;
    map<int, pair<int, int>> mp;
    rep(i, h) rep(j, w)
    {
        int a;
        cin >> a;
        mp[a] = make_pair(i + 1, j + 1);
        dump(i);
        dumpl(j);
    }
    ll cost[h * w + 1];
    rep(i, h * w + 1) cost[i] = 0;
    rep(i, 1, d + 1)
    {
        int now = i;
        now += d;
        while (now <= h * w)
        {
            cost[now] = cost[now - d] + abs(mp[now].first - mp[now - d].first) + abs(mp[now].second - mp[now - d].second);
            now += d;
        }
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << cost[r] - cost[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 7424
n = gets.to_i
p = gets.split.map(&:to_i)

count = 0
0.upto(n - 3) do |i|
  if p[i + 1] != p[i, 3].min && p[i + 1] != p[i, 3].max
    count += 1
  end
end

puts count

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

#ifdef SG
        #include <debug.h>
#else
        #define show(...)
        #define debug(...)
        #define deepen(...)
        #define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

struct Input {

    ll n, x;

        bool read () {
        if (!(cin >> n >> x)) return 0;
                return 1;
        }

        void init (const Input &input) {
                *this = input;
        }
};

struct Data: Input {

    ll ans;

        void write () {
        cout << ans << '\n';
        }
};

struct Solution: Data {

    ll calc(ll a, ll b) {
        debug(a, b);
        if (a > b) return calc(b, a);
        if (b % a == 0) {
            return (2ll * (b / a) - 1) * a;
        }
        return 2ll * (b / a) * a + calc(a, b % a);
    }

        void solve () {
            ans = n + calc(x, n - x);
        }

        void clear () {
                *this = Solution();
        }
};

Solution sol;

int main () {
        cout.setf(ios::showpoint | ios::fixed);
        cout.precision(20);
#ifdef SG
        while (sol.read()) {
                sol.solve();
                sol.write();
                sol.clear();
        }
#else
        sol.read();
        sol.solve();
        sol.write();
#endif
        return 0;
}


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

int main()
{
  int n,m,ans=0;
  cin >> n>>m;
  rep(i,n){
    ans+=i;
  }
  rep(i,m){
    ans+=i;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H'){
            cout<<"H"<<endl;
        }
        else{
            cout<<"D"<<endl;
        }
    }
    else{
        if(b=='D'){
            cout<<"H"<<endl;
        }
        else{
            cout<<"D"<<endl;
        }
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






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

int main()
{
    double a,b,ab;
    string s;
    cin>>a>>b;
    ab=stod(to_string((int)a)+to_string((int)b));
    ceil(sqrt(ab))!=floor(sqrt(ab))?s="No":s="Yes";
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	while(1)
	{
		int a, b;
		char c;
		scanf("%d %c %d", &a, &c, &b);
		if(c == '?') break;
		switch(c)
		{
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		}
		
	}
	return 0;
}

Measured memory_bytes: 2752
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(k>a)
    {
        k-=a;
        ans+=a;
        if(k>b)
        {
            k-=b;
            ans-=k;
        }
    }
    else
        ans+=k;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let mut a = Vec::new();
    for _ in 0..n {
        let x = it.next().unwrap().parse::<i32>().unwrap();
        let l = it.next().unwrap().parse::<i32>().unwrap();
        a.push((x-l, x+l));
    }
    a.sort_by_key(|x| x.1);
    let mut last = -(1<<30);
    let mut res = 0;
    for &p in &a {
        if last <= p.0 {
            last = p.1;
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 8444