akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

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

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	V<int> u(N+2,0);
	V<double> v(N+2,0);
	FOR(i,1,N+1) cin >> u[i];
	FOR(i,1,N+1) cin >> v[i];
	int MAX_t = 100 * 200 * 2 + 2, SUM_t = 0;
	V<double> dp(MAX_t, 1e15);
	REP(i,N+2){
		for (int t = SUM_t,j = 0; 0 <= t; --t, ++j) dp[t] = min(dp[t], v[i] + j*0.5);
		for (int t = SUM_t; t < SUM_t + 2*u[i]; ++t) dp[t] = min(dp[t], v[i]);
		for (int t = SUM_t + 2*u[i],j = 0; t < MAX_t; ++t, ++j) dp[t] = min(dp[t], v[i] + j*0.5);
		SUM_t += 2*u[i];
	}
	printf("%.10f", 0.5*accumulate(dp.begin(), dp.begin() + SUM_t, 0.));
	
	return 0;
}



Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {

  static FastScanner sc = new FastScanner();

  public static void main(String[] args) {

    int N = sc.nextInt();

    if (N == 1) {
      System.out.println("Hello World");
    } else if (N == 2) {
      System.out.println(sc.nextInt() + sc.nextInt());
    }

  }

  static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
      skipUnprintable();
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      return (int) nextLong();
    }
  }

}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    map<string, int> mp;
    int m = 0;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
        chmax(m, mp[s]);
    }
    for (auto x : mp) {
        if (x.se == m) cout << x.fi << endl;
    }
}

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


Measured memory_bytes: 19296
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int dp[310][310];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> w(n);
    rep(i,n) cin >> w[i];
    rep(i,310) rep(j,310) dp[i][j] = 0;
    REP(i,2,n+1) rep(l,n) {
      int r = l+i;
      if(r > n) continue;
      REP(j,l,r+1) {
        chmax(dp[l][r], dp[l][j] + dp[j][r]);
      }
      if(dp[l+1][r-1] == r-l-2 && abs(w[l]-w[r-1]) <= 1) {
        chmax(dp[l][r], r-l);
      }
      else chmax(dp[l][r], dp[l+1][r-1]);
    }
    cout << dp[0][n] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3548
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long A[110000];
long long B[110000];
long long C[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%lld",A+i);
	for(int i=0;i<a;i++)scanf("%lld",B+i);
	long long req=0;
 
	int ret=0;
	for(int i=0;i<a;i++){
		req+=max(0LL,B[i]-A[i]);
		C[i]=-max(0LL,A[i]-B[i]);
		if(A[i]<B[i])ret++;
	}
	std::sort(C,C+a);
	for(int i=0;i<a;i++){
		if(req<=0)break;
		req+=C[i];ret++;
	}
	if(req>0)ret=-1;
	printf("%d\n",ret);
 
}

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

int main(){
    ll a,b,c,d,tmp,x,hoge,r,tmpc,tmpd;
    cin >> a >> b >> c >> d;
    x = c*d;
  tmpc = c;
  tmpd = d;

    if(tmpc<tmpd){
    tmp = tmpc;
    tmpc = tmpd;
    tmpd = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = tmpc % tmpd;
  while(r!=0){
    tmpc = tmpd;
    tmpd = r;
    r = tmpc % tmpd;
  }
  hoge = x / tmpd;

  ll ans;
  ll huga = b/c - (a-1)/c + b/d -(a-1)/d - b/hoge + (a-1)/hoge;
  ans = b - a - huga + 1;
  cout << ans << endl;
  return 0;

}

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

#define N 10000
#define MAX 2000001

void cs(int *,int *,int );
int n,i,j,A[MAX],B[MAX],C[MAX];
int main(){
 

  scanf("%d",&n);


  for(i=1;i<=n;i++){
    scanf(" %d",&A[i]);
  }
  cs(A,B,N);

  for(i=1;i<=n-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);

  return 0;
}


void cs(int *A,int *B,int k){
  for(i=0;i<=k;i++){
    C[i]=0;
  }
    for(j=1;j<=n;j++){
      C[A[j]]++;
    }
  


  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
    for(j=n;j>=1;j--){
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
  
}



Measured memory_bytes: 17384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int md=1000000007;
int n,m,i,j,k,a[20],f[20][100000],ans,jc[100000],rjc[100000],inv[100000],num[100000];
int C(int n,int m)
{
	if(n<0||m<0||m>n)
		return 0;
	return 1ll*jc[n]*rjc[m]%md*rjc[n-m]%md;
}
int main()
{
	scanf("%d%d",&n,&m);
	inv[1]=1;
	for(i=2;i<=(1<<n);++i)
		inv[i]=1ll*inv[md%i]*(md-md/i)%md;
	jc[0]=rjc[0]=1;
	for(i=1;i<=(1<<n);++i)
		jc[i]=1ll*jc[i-1]*i%md,rjc[i]=1ll*rjc[i-1]*inv[i]%md;
	for(i=1;i<=m;++i)
	{
		scanf("%d",a+i);
		a[i]--;
	}
	for(i=1;i<(1<<n);++i)
		num[i]=num[i^(i&-i)]+1;
	f[m+1][0]=1;
	for(i=m+1;i>1;--i)
		for(j=0;j<(1<<n);++j)
			if(f[i][j])
			{
				f[i-1][j]=(f[i-1][j]+f[i][j])%md;
				for(k=0;k<n;++k)
					if(!(j>>k&1))
						f[i-1][j|(1<<k)]=(f[i-1][j|(1<<k)]+1ll*f[i][j]*C((1<<n)-1-a[i-1]-j,(1<<k)-1)%md*jc[1<<k])%md;
			}
	for(j=0;j<(1<<n);++j)
		ans=(ans+1ll*(num[j]&1?md-1:1)*f[1][j]%md*jc[(1<<n)-1-j]%md)%md;
	ans=1ll*ans*(1<<n)%md;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <cstdlib> 
using namespace std;
typedef long long ll;
const ll INF = 100100100100100100;

int main(){
    int n,k;
    cin >> n >> k;
    ll h[n];
    ll dp[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
        //一緒に初期化もやる
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < k; j++){
            if(i+j>=n)break;
            ll tmp1 = abs(h[i+j] - h[i-1]);
            dp[i+j] = min(dp[i-1]+tmp1, dp[i+j]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
// ConsoleApplication1.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <set>
#include <map>

//047 B

using namespace std;
int main()
{
	int N, M;
	string s;
	map<string, int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		mp[s]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> s;
		mp[s]--;
	}

	int ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans = max(ans, it->second);
	}
	cout << ans << endl;


	return 0;
}





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

int main(){
	int a,b,c,d,p;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	int x=a*p;
	int y=b; if(c<p) y+=(p-c)*d;
	printf("%d\n",min(x,y));
}

Measured memory_bytes: 1188
//http://blog.livedoor.jp/dgd17/archives/10628100.html
//https://www.slideshare.net/Ryosuke839/kbkz-tech8-lt
//https://qiita.com/vs4sh/items/096d6035eb9258e6987a
//https://marycore.jp/prog/cpp/stream-format-float/
#include <iostream>
#include <cmath>
#include <valarray>
#include <iomanip> //setprecision使うときに必要
using ld = long double;
using std::cin;
using std::cout;
using std::endl;
using std::valarray;

int main()
{
    int n;

    while (cin >> n && n != 0) //'0'だとchar型になるので×
    {
        valarray<ld> s(0.0, n); //vectorの初期化と逆
        for (int i = 0; i < n; i++)
        {
            cin >> s[i];
        }
        ld ave = s.sum() / s.size();

        s -= ave;
        s *= s;
        ld val = s.sum() / s.size();

        ld dev = sqrt(val);

        cout << std::fixed; //resetはstd::defaultfloat
        cout << std::setprecision(10) << dev << endl;
    }
    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
typedef long long ll;
ll dp[55][55 * 55];
int k;
int n;
int main()
{
    cin >> n >> k;
    int x;
    dp[0][0] = 1ll;
    repd(i, 1, n)
    {
        cin >> x;
        for (int j = i - 1; j >= 0; j--)
        {
            for (int w = 0; w <= 55 * j; w++)
            {
                dp[j + 1][w + x] += dp[j][w];
            }
        }
    }
    ll ans = 0ll;
    repd(i, 1, n)
    {
        ans += dp[i][i * k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from functools import lru_cache
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m=map(int, readline().split())
ls=[[0 for i in range(n)] for j in range(8)]
p=list(itertools.product([1,-1],repeat=3))
for k in range(n):
  a=tuple(map(int, readline().split()))
  for j, i in enumerate(p):
    ls[j][k]=a[0]*i[0]+a[1]*i[1]+a[2]*i[2]
sum=[]
for i in range(8):
    sum.append(0)
    ls[i]=sorted(ls[i])
    for j in range(1,m+1):
        sum[i]+=ls[i][-j]
#print(ls)
#print(sum)
print(max(sum))

Measured memory_bytes: 41564
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
using namespace std;
int main()
{
    int n,q,a,b,c;
    cin>>n;
    vector<int>v(n);
    vector<int>::iterator it1,it2;
    for(int i=0;i<n;i++)
      cin>>v[i];
    cin>>q;
    while(q--){
        cin>>a>>b>>c;
        it1=v.begin()+a;
        it2=v.begin()+b;
        cout<<count(it1,it2,c)<<endl;

    }

return 0;
}


Measured memory_bytes: 3104
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
  #ifndef ONLINE_JUDGE
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif 
  string s;
  cin>>s;
  int k;cin>>k;
  set<string> sub;
  int n=s.length();
  for(int l=0;l<n;l++)
    {
      for(int r=l;r<l+k and r<n;r++)
      {
        string t="";
        for(int i=l;i<=r;i++)t+=s[i];
          sub.insert(t);
      }
    }

  
  vector<string> a;
  for(auto i:sub)a.push_back(i);
  cout<<a[k-1];
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}	
bool u[101];
int main()
{
	int h,w;
	cin>>h>>w;
	string s[101],q="";
	for(int i=1;i<=w;i++)
	{
		q+='.';
	}
	int zz=1;
	for(int i=1;i<=h;i++)
	{
		cin>>s[zz];
		if(s[zz]!=q)
		{
			zz++;
		}
	}
	for(int i=0;i<w;i++)
	{
		for(int j=1;j<zz;j++)
		{
			if(s[j][i]!='.')
			{
				goto A;
			}
		}
		u[i]=true;
		A:
		continue;
	}
	for(int i=1;i<zz;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(u[j])
			{
				continue;
			}
			cout<<s[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input()#.split()

# inputb = input()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# inputList = list(inputb)
#
# inputList[b-1] = inputList[b-1].lower()
#
# ans = "".join(inputList)

dic = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}

ans = dic[str(inputa[0])]
print(ans)

# inputList.sort()
#
# list = [a+b, b+c ,c+a]
#
# ans = min(list)
# print(ans)


#
# flg = 1
#
# if int(inputa[4])-int(inputa[0]) > int(inputList[5]):
#     flg = 0
#
# if flg == 0:
#     print(":(")
# else:
#     print("Yay!")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){

int a,b,c,d;
cin>>a>>b>>c>>d;

int y=a/d;
if(a%d!=0){y++;}
int x=(y)*b;
if(x>=c){cout<<"Yes";}
else{cout<<"No";}
}


Measured memory_bytes: 3588
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 2000000;
const int MAX_E2 = 1 << 22;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeMax {
  int n, e2;
  T nodes[MAX_E2], is[MAX_E2];

  SegTreeMax() {}
  SegTreeMax(int _n) { init(_n); }

  void init(int _n) {
    n = _n;
    for (e2 = 1; e2 < n; e2 <<= 1);
    memset(nodes, -1, sizeof(nodes));
    memset(is, 0, sizeof(is));
  }

  int maxi() { return is[0]; }
  T getmax() { return nodes[0]; }
  T get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    is[j] = i;
    j = (j - 1) / 2;

    for (;;) {
      int j0 = j * 2 + 1, j1 = j0 + 1;
      if (nodes[j0] > nodes[j1])
	nodes[j] = nodes[j0], is[j] = is[j0];
      else
	nodes[j] = nodes[j1], is[j] = is[j1];
      if (j == 0) break;
      j = (j - 1) / 2;
    }
  }
};

/* global variables */

SegTreeMax<int,MAX_E2> st(MAX_H);

/* subroutines */

/* main */

int main() {
  int h = 0;

  for (;;) {
    char op[16];
    int tmp = scanf("%s", op);

    if (op[0] == 'i') {
      int x;
      tmp = scanf("%d", &x);

      st.set(h++, x);
    }
    else if (op[1] == 'x') {
      int x = st.getmax();
      st.set(st.maxi(), -1);
      
      printf("%d\n", x);
    }
    else break;
  }

  return 0;
}



Measured memory_bytes: 35972
#include<stdio.h>
#define N 101
int n,m[N][N],s[N],d[N],f[N],cntd=1,cntf=0,count=0;

int pop(int top){
  if(top==0)return -1;
  return top-1;
}
int push(int num,int top){
  top++;
  s[top]=num;
  return top;
}

int dfs(int num){
  int i,j,top=1;
  if(count!=0)d[num]=++cntd;
  d[1]=1;
  s[top]=num;
  for(i=1;i<=n;i++)m[i][num]=0;
  while(top!=0){
     for(i=1;i<=n;i++){
          if(m[s[top]][i]==1){
              for(j=1;j<=n;j++)m[j][i]=0;
              top=push(i,top);
              cntd++;
              if(d[i]==0)d[i]=cntd;
              break;
          }
          else if(i==n){
            cntf=++cntd;
            f[s[top]]=cntf;
            top=pop(top);
           }      
        }
        
  }
  for(i=2;i<=n;i++){
    if(d[i]==0){
      count++;
      return dfs(i);
  }
  }
            
  return 0;

}

int main(){
  int i,j,num,k,num1;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&num,&k);
    for(j=1;j<=n;j++)m[i][j]=0;
    for(j=1;j<=k;j++){
      scanf("%d",&num1);
      m[i][num1]=1;
    }
  }
  for(i=1;i<=n;i++){
    d[i]=0;
    f[i]=0;
  }
  k=dfs(1);
for(i=1;i<=n;i++){
      printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}




Measured memory_bytes: 2104
import * as fs from 'fs';

//in
// 2019/04/30
//out
// Heisei
const main = (inp: string) => {
    if (inp <= '2019/04/30') {
        console.log('Heisei');
    } else {
        console.log('TBD');
    }
};

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



Measured memory_bytes: 7372
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut h:usize = read!();
    let mut n:usize = read!();
    let mut v:usize = 0;
    for i in 0..n {
        let a:usize = read!();
        v += a;
    }
    if h<=v {
        println!("Yes");
        exit(0);
    }
    println!("No");
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int n,m,c;cin>>n>>m>>c;
  vi b(m);
  rep(i,m)cin>>b[i];
  vvi a(n,vi(m));
  rep(i,n){
    rep(j,m)cin>>a[i][j];
  }

  int ans=0;
  rep(i,n){
    int total=0;
    rep(j,m){
      total+=b[j]*a[i][j];
    }
    total+=c;
    if(total>0)ans++;
  }
  cout<<ans<<endl;

  return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// 最後にどの桁をみたか
// 現時点で何文字を残すと決めたか
// 現時点で残すとっ決まった部分の文字列
// S = 869120
// dp[3][2][89]:
// -> dp[4][2][89] or dp[4][3][891]のどちらかに分岐
// DPで求めることができる
bool dp[303030][4][1010];
string S;
int N;

int main() {
    cin >> N >> S;
    dp[0][0][0] = true;

    for (int i = 0; i < N; ++i) {
        for (int len = 0; len <= 3; ++len) {
            for (int sum = 0; sum < 1000; ++sum) {
                if (!dp[i][len][sum]) continue;
                dp[i+1][len][sum] = true;
                if (len <= 2) {
                    dp[i+1][len + 1][sum * 10 + (S[i] - '0')] = true;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 1000; ++i) {
        if (dp[N][3][i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 121992
#include <stdio.h>

int main(void){
    int h;
    int i, j, k;

    while(1){
        scanf("%d", &h);
        if(h == 0){
            break;
        }

        int puzzle[h][5];
        for(i = 0; i < h; i++){
            for(j = 0; j < 5; j++){
                scanf("%d", &puzzle[i][j]);
            }
        }
        
        int flag;
        int count;
        int sum = 0;
        int point = -1;

        while(point != 0){
            /* for(i = 0; i < h; i++){
                for(j = 0; j < 5; j++){
                    printf("%d " ,puzzle[i][j]);
                }
                printf("\n");
            }
            printf("\n"); */

            point = 0;
            for(i = 0; i < h; i++){
                for(j = 0; j < 5; j++){
                    if(j == 0){
                        flag = puzzle[i][j];
                        count = 1;
                    }

                    else{
                        if(flag == puzzle[i][j]){
                            count++;
                            if(j == 4){
                                point += flag * count;
                                for(k = 5 - count; k <= 4; k++){
                                    puzzle[i][k] = 0;
                                }
                            }
                        }
                        else{
                            if(j <= 2){
                                flag = puzzle[i][j];
                                count = 1;
                            }
                            else{
                                if(count >= 3){
                                    point += flag * count;
                                    for(k = j - count; k < j; k++){
                                        puzzle[i][k] = 0;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }

            for(i = h - 1; i > 0; i--){
                for(j = 0; j < 5; j++){
                    if(puzzle[i][j] == 0){
                        k = i - 1;
                        while(1){
                            if(puzzle[k][j] != 0){
                                puzzle[i][j] = puzzle[k][j];
                                puzzle[k][j] = 0;
                                break;
                            }
                            if(k == 0){
                                break;
                            }
                            k--;
                        }
                    }
                }
            }

            sum += point;
        }

        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2052
class Dice():
    def __init__(self, a, b, c, d, e, f):
        """面の数字とindexを一致させるために0を挿入"""
        self.s = [0, a, b, c, d, e, f]

    def rotate(self, dir):
        if dir == "N":
            self.s[0] = self.s[1] #s[0]に一時的にs[1]を保持
            self.s[1] = self.s[2] 
            self.s[2] = self.s[6]
            self.s[6] = self.s[5]
            self.s[5] = self.s[0]
            return

        elif dir == "W":
            self.s[0] = self.s[1]
            self.s[1] = self.s[3] 
            self.s[3] = self.s[6]
            self.s[6] = self.s[4]
            self.s[4] = self.s[0]
            return

        elif dir == "S":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5] 
            self.s[5] = self.s[6]
            self.s[6] = self.s[2]
            self.s[2] = self.s[0]
            return

        elif dir == "E":
            self.s[0] = self.s[1]
            self.s[1] = self.s[4] 
            self.s[4] = self.s[6]
            self.s[6] = self.s[3]
            self.s[3] = self.s[0]
            return
        
        elif dir == "R":
            self.s[0] = self.s[2]
            self.s[2] = self.s[3] 
            self.s[3] = self.s[5]
            self.s[5] = self.s[4]
            self.s[4] = self.s[0]
            return

        else:
            return

    def equal(self, dice2):
        FLG = False
        if set(self.s[1:]) != set(dice2.s[1:]):
            pass 

        elif self.s[1:] != dice2.s[1:]:
            for _ in range(3):
                if self.s[1:] != dice2.s[1:]:
                    for __ in range(4):
                        if self.s[1:] != dice2.s[1:]:
                            dice2.rotate("R")
                        else:
                            FLG = True
                            break
                    if FLG:
                        break

                    dice2.rotate("S")
                    for __ in range(4):
                        if self.s[1:] != dice2.s[1:]:
                            dice2.rotate("R")
                        else:
                            FLG = True
                            break
                    if FLG:
                        break
                    dice2.rotate("E")
                else:
                    FLG = True 
                if FLG:
                    break
        else:
            FLG = True

        return FLG

n = int(input())
*dices, = [Dice(*map(int, input().split())) for _ in range(n)]
FLG = True

for i in range(n):
    for j in range(i+1, n):
        if dices[i].equal(dices[j]):
            FLG = False
            break
    if not FLG:
        break

if FLG:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5628
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int gcd(ll a, ll b){ //最大公約数 O(log(min(a,b)))
    if(b==0) return a;
    return gcd(b,a%b);
}


int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll g=gcd(c,d);
    ll l=c*d/g;
    ll n=b/c+b/d-b/l;
    ll m=(a-1)/c+(a-1)/d-(a-1)/l;
    ll ans=b-a+1-(n-m);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {

	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	int x=fs.nextInt();
	if(x>=400&&x<=599) {
		System.out.println(8);
	}
	else if(x>=400&&x<=599) {
		System.out.println(8);
	}
	else if(x>=600&&x<=799) {
		System.out.println(7);
	}
	else if(x>=800&&x<=999) {
		System.out.println(6);
	}
	else if(x>=1000&&x<=1199) {
		System.out.println(5);
	}
	else if(x>=1200&&x<=1399) {
		System.out.println(4);
	}
	else if(x>=1400&&x<=1599) {
		System.out.println(3);
	}
	else if(x>=1600&&x<=1799) {
		System.out.println(2);
	}
	else if(x>=1800&&x<=1999) {
		System.out.println(1);
	}
	}
	static void sort(int[] a ) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


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

void print(vector<int> v) {
	vector<int>::iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		cout << *it;
	}
	cout << endl;
}

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

	int N; cin >> N;
	int s[110000];
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	int t;
	int q; cin >> q;
	int ans = 0;
	for (int i = 0; i < q; i++) {
		int* pos;
		cin >> t;
		pos = lower_bound(s, s + N, t);
		if (*pos == t)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3476
import math

n,a,b = map(int,input().split())

def mod_inv(x,mod):
    return pow(x,mod-2,mod)

def mod_inv_table(k):
    table = [-1] * (k+1)
    for i in range(1,k+1):
        table[i] = mod_inv(i,10**9+7)
    return table

def binomial(n,k,table):
    ret = 1
    for i in range(k):
        ret *= n-i
        ret *=table[i+1]
        ret %= 10**9+7
    return ret
    

tablea = mod_inv_table(a)
tableb = mod_inv_table(b)
ka = binomial(n,a,tablea)
kb = binomial(n,b,tableb)
alla = pow(2,n,10**9+7)
z = alla - ka -kb -1
print(z%(10**9+7))

Measured memory_bytes: 18792
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi a(N+1,-INF); FOR(i,1,N+1)cin >> a[i];
    
    vl s(N+1, 0);
    FOR(i, 1, N) s[i] = s[i-1] + a[i];

    ll sum = 0;
    FOR(i, 1, N + 1) sum += a[i];

    ll ans = LINF;
    FOR(i,1,N) {
        ans = min(ans, abs(s[i] - (sum - s[i])));
    }

    cout << ans << endl;

    return 0;
}

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

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

 int p[5000];
 for(int i=0; i<N; i++){
  cin >> p[i];
 }

 int min_sum = 20000;

 for(int  I=0; I<=p[0]; I++){
  int q[5000];
  for(int i=0; i<N; i++){
   q[i] = p[i];
  }

  int sum = I;
  q[0] -= I;

  for(int i=0; i<=N-2; i++){
   if(q[i]<=0) continue;
   
   sum += q[i]*2;
   q[i+1] -= q[i];
  }
 
  if(q[N-1]>0){
   sum += q[N-1];
  }

  min_sum = min(min_sum, sum);
 }

 cout << min_sum << endl;
 
 return 0;
} 

Measured memory_bytes: 3120
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=jp
 */

import java.util.*;

public class Main {
	int m = 0;
	int count = 0;
	int[] g = new int[100];

	void insertionSort(int[] array, int g) {
		for (int i = g; i < array.length; i++) {
			int v = array[i];
			int j = i - g;
			while (j >= 0 && array[j] > v) {
				array[j+g] = array[j];
				j = j - g;
				count++;
			}
			array[j+g] = v;
		}
	}
	void shellSort(int[] array) {
		count = 0;
		int h = array.length;
		while (true) {
			h /= 2;
			g[m++] = h;
			if (h <= 1) break;
		}
		for (int i = 0; i < m; i++) {
			insertionSort(array, g[i]);
		}
	}
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		shellSort(array);
		System.out.println(m);
		for (int i = 0; i < m; i++) {
			System.out.print(g[i] + " ");
		}
		System.out.println();
		System.out.println(count);
		for (int i = 0; i < array.length; i++) {
			System.out.println(array[i]);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 298840
N = int(input())
ANS = [0]*4
for i in range(N):
    S = input()
    if S == 'AC':
        ANS[0] +=1
    if S == 'WA':
        ANS[1] +=1
    if S == 'TLE':
        ANS[2] +=1
    if S == 'RE':
        ANS[3] +=1

print('AC x '+str(ANS[0]))
print('WA x '+str(ANS[1]))
print('TLE x '+str(ANS[2]))
print('RE x '+str(ANS[3]))

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

int main(){

   long long a, b, c,d;
   cin >> a >> b >> c >> d;

   long long ad = a * d;
   long long ac = a * c;
   long long bc = b * c;
   long long bd = b * d;

   long long max_num = max({ad, ac, bc, bd});
   
   cout << max_num << endl;

}


Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  char s[100];
  int i,j,l,c=0,b[100]={0};
  long long a=1;
  scanf("%s",s);
  for(l=0;s[l];l++)b[s[l]-'a']++;
  for(i=0;i<26;i++)c+=b[i]%2;
  if(c-l%2){
    printf("0\n");
    return 0;
  }
  l/=2;
  for(i=0;i<26;i++){
    b[i]/=2;//if(b[i])printf("%d\n",b[i]);
    for(j=0;j<b[i];j++){
      a*=l--;
      a/=j+1;
    }
  }
  printf("%lld\n",a);
  return 0;
}
   

Measured memory_bytes: 536
#include <bits/stdc++.h>
typedef long long ll;
using std::cout ;
using std::endl ;
using std::cin ;
using std::string ;
using std::vector ;
using std::set ;
using std::map ;
using std::pair ;
#define rep(i,n) for(int i=0, i##_end=(n); i<i##_end; i++)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
template<class T>bool updateMax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool updateMin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(c) c.begin(),c.end()
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int C[N];
    int A[N][M];
    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }
    
    int min = 100000000;
    rep(i, 1 << N) {
        int Ctotal = 0;
        int Atotal[M];
        rep(j, M) {
            Atotal[j] = 0;
        }
        rep(j, N) {
            if((1 << j) & i) {
                Ctotal += C[j];
                rep(k, M) {
                    Atotal[k] += A[j][k];
                }
            }
        }
        
        bool ok = 1;
        rep(j, M) {
            if(Atotal[j] < X) {
                ok = 0;
                break;
            }
        }
        if(ok) {
            updateMin(min, Ctotal);
        }
    }
    
    cout << (min == 100000000 ? -1 : min) << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
 
int n, m;
int a[N];
 
int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	set<int> s;
	int l = 2;
	for(int i = 1; i <= n; i++)
	{
		int x = a[i];
		int c = 0;
		while(x % 2 == 0)
		{
			x /= 2;
			c++;
		}
		s.insert(c);
		l = l * a[i] / __gcd(l, a[i]);
		if(l > 2 * m)
		{
			cout << 0;
			return 0;
		}
	}
	if(s.size() > 1)
	{
		cout << 0;
		return 0;
	}
	cout << (2 * m / l + 1) / 2;
	return 0;
}

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



int main(){
    int n; cin >> n;
    vector<int> t(n),x(n),y(n);
    REP(i,n) cin >> t[i] >> x[i] >> y[i];
    int tt = 0,tx = 0, ty = 0;
    REP(i,n){
        int dt = t[i] - tt;
        int dx = abs(x[i] - tx);
        int dy = abs(y[i] - ty);
        if(dt < dx + dy || dt % 2 != (dx + dy) % 2 ){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int h, a;
  cin >> h >> a;
  int ans = h / a;
  if (h % a != 0) {
    ans++; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> p(n);
    rep (i, n) cin >> p[i];

    *max_element(p.begin(), p.end()) /= 2;
    cout << accumulate(p.begin(), p.end(), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


vector<string> split(const string &str, const string& delimiter = " ")
{
	vector<string> res;
	string::size_type i = 0, pos;
	while ((pos = str.find(delimiter, i)) != string::npos)
	{
		res.push_back(str.substr(i, pos - i));
		i = pos + 1;
	}
	res.push_back(str.substr(i, str.size() - i));
	return res;
}
int main()
{
	int n, m;
	while (cin >> n >> m, n | m)
	{
		map<string, string> parent;
		string indent_to_name[1024];


		string line;
		getline(cin, line);

		getline(cin, line);
		indent_to_name[0] = line;
		rep (i, n - 1)
		{
			getline(cin, line);
			int indent = line.find_first_not_of(' ');
			string name = line.substr(indent);
			indent_to_name[indent] = name;

			parent[name] = indent_to_name[indent - 1];
		}

		rep (i, m)
		{
			getline(cin, line);
			vector<string> hoge = split(line);
			string x = hoge[0], y = hoge.back();
			y.erase(y.size() - 1);
			string query = hoge[3];

			if (query == "descendant")
			{
				query = "ancestor";
				swap(x, y);
			}
			else if (query == "child")
			{
				query = "parent";
				swap(x, y);
			}

			bool res = false;
			if (query == "parent")
				res = x == parent[y];
			else if (query == "sibling")
				res = parent[x] == parent[y];
			else if (query == "ancestor")
			{
				while (parent.count(y))
				{
					y = parent[y];
					if (x == y)
					{
						res = true;
						break;
					}
				}
			}

			cout << (res ? "True" : "False") << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int s[3][3];
  rep(i,3){
    rep(j,3){
      cin >> s[i][j];
    }
  }
  string ans="Yes";
  int b1=s[0][0],b2=s[0][1],b3=s[0][2],a1=0,a2=s[1][0]-b1,a3=s[2][0]-b1;
  if(b2+a2!=s[1][1] || b3+a2!=s[1][2] || a3+b2!=s[2][1] || a3+b3!=s[2][2]){
    ans="No";
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
int n;
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	map<int, int> mp;
	FOR(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	int ret = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second & 1) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int m = h[0], count= 1;
	for (int i = 1; i < n; i++) {
		if (m <= h[i]) {
			count++;
			m = max(m, h[i]);
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,M;
	cin>>N>>M;
	vec(A)
	vec(B)
	vec(C)
	vec(D)
	fx(N){
		vecp(A)
		vecp2(B)
	}
	fx(M){
		vecp(C)
		vecp2(D)
	}
	
	fx(N){
		int ans=0;
		int mini=1000000000;
		fy(M){
			int some=abs(A.at(x)-C.at(y))+abs(B.at(x)-D.at(y));
			if(mini>some){
				ans=y+1;
				mini=some;
			}
		}
		ce(ans)
	}
	
}

Measured memory_bytes: 256