akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    vi v(N);
    vi c(N);
    rep(i, 0, N) {
        cin >> v[i];
    }
    rep(i, 0, N) {
        cin >> c[i];
    }
    int ans = 0;
    rep(i, 0, N) {
        if (v[i] - c[i] > 0) ans += (v[i] - c[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long int
using namespace std ;

const ll maxn = 1000+4;

#define mod 1000000007

ll min(ll a, ll b)
{
    if (a <= b) return a;
    return b;
}


ll max(ll a, ll b)
{
    if( a > b) return a;
    return b;
}


ll abs(ll x)
{
    if(x<0)
        return (-1*x);
    return x;
}

char grid[maxn][maxn];
ll r, c;


ll dp[maxn][maxn];

ll ans = 0;

ll cal (ll x, ll y)
{
    if(x == r and y == c)
    {
        return 1 ;
    }

    if( dp[x][y]!= -1 )  return dp[x][y];
    ll res1 = 0, res2 = 0 ;

    if( x <= r and y+1<=c  and  grid[x][y+1]=='.')
    {
        res1 =  cal( x, y+1) % mod;
    }
    if( x+1 <= r and y<=c and  grid[x+1][y]=='.')
    {
        res2 =  cal(x+1,y) % mod;
    }

    dp[x][y] = (res1+res2) % mod;

    return dp[x][y]  ;
}


int main()
{

    cin >> r >> c ;


    for(int i=1 ; i<=r+2 ; i++)
    {
        for(int j=1 ; j<=c+2 ; j++)
            dp[i][j] = -1;

    }



    for(int i=1 ; i<=r ; i++)
    {
        for(int j=1 ; j<=c ; j++)

            cin >> grid[i][j];
    }


    cout << cal(1,1) % mod << endl ;

//    cout << "bug \n";
//     for(int i=1 ; i<=r ; i++)
//    {
//        for(int j=1 ; j<=c ; j++)
//           cout << grid[i][j];
//           cout <<endl;
//    }



    return 0 ;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main(){
	int n,a,m, soma =0;
	cin >> n >> m;
	for(int i = 0; i < m;i++){
		cin >> a;
		soma+=a;
	}
	if(n - soma >= 0){
		cout << n - soma << endl;
	}else{
		cout << -1 << endl;	
	}
	return 0;
}

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

int n,rs=0;

int Cal(int x)
{
	int cnt=0;
	while(x>0)
	{
		x/=10;
		cnt++;
	}
	return cnt;
}

int main() 
{
	ios_base::sync_with_stdio(false);
	//freopen(".inp","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		if(Cal(i)%2==1)
			rs++;
	cout<<rs;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int S,W;
  cin>>S>>W;
  
  if(S<=W)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cassert>
#include<algorithm>
#include<vector>
#include<stack>
#include<list>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)


void simulate(int n,vector<pair<int,int> > & in,const int lim,int l,int r){
  vector<int> a(n);
  rep(i,n)a[i] = i+1;
  for(int i=in.size()-1;i>=0;i--){

  }
  rep(i,lim){

  }
}

/*
  l-rÌRÌª¾¯ðÛµÄAãë©çð¢Ä¢­B
  Rªªô·é±Æª Á½ç»ê¼êÊÉª¯ÄâÁÄµÜÁÄ¢¢BiÍ¸j
  [l,r]
  inÍ[first,second]ðÅèµÄ¼ðXbv·é
  1-origin
 */
int ans = 0;
void solve(const int n,vector<pair<int,int> > &in,int now,const int lim,int l,int r,const int p,const int q){
  //cout << l <<" " << r << endl;
  if (r < l)return;
  if (now == in.size()){
    if (q < l || r < p)return;
    ans += min(r,q)-max(l,p)+1;
    return;
  }
  int p1=in[now].first-1,p2=in[now].second-in[now].first+1,p3=n-p1-p2;//eRÌTCY
  swap(p1,p3);

  if (in[now].second < r){//[max(in[now].second+1,l)..r]ÜÅðãÉÁÄ¢­
    int nextl=in[now].second < l?l-in[now].second:1;
    int nextr=nextl + r-max(in[now].second+1,l);//
    //cout <<l <<" " << r <<" " << in[now].first <<" " << in[now].second << " type:1 " << nextl <<" " << nextr << endl;
    solve(n,in,now+1,lim,nextl,nextr,p,q);
  }
  
  //»ÌÜÜ
  if (!(r < in[now].first || in[now].second < l)){
    int newl = max(in[now].first,l),newr=min(in[now].second,r);
    int nextl = l < in[now].first ? 1+p1 : 1+p1 + l-in[now].first;
    int nextr = nextl + newr-newl;
    //cout <<l <<" " << r <<" " << in[now].first <<" "<< in[now].second <<" type:2 " << nextl <<" " << nextr << endl;
    solve(n,in,now+1,lim,nextl,nextr,p,q);
  }

  if (l < in[now].first){//[l..min(in[now].first-1,r)] ðºÜÅÁÄ¢­B
    int nextl=p1+p2+l;
    int nextr=nextl+min(in[now].first-1,r)-l;
    //cout <<l <<" " << r << " " << in[now].first <<" " << in[now].second << " type:3 " << nextl <<" "<< nextr << endl;
    solve(n,in,now+1,lim,nextl,nextr,p,q);
  }

}

main(){
  int n,m;
  while(cin>>n && n){
    ans = 0;
    int m,l,r,lim;
    cin>>m;
    cin>>l>>r>>lim;
    vector<pair<int,int> > in(m);
    rep(i,m){
      cin>>in[i].first>>in[i].second;
      in[i].first++;
    }
    //reverse(in.begin(),in.end());
    solve(n,in,0,lim,1,lim,l,r);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; string s; cin >> n >> s;
    queue<char> que;

    string ans = "";
    rep(i, n){
        if(s[i] == '(') que.push('(');
        else{
            if(!que.empty()) que.pop();
            else ans += "(";
        }
    }
    ans += s + string(que.size(), ')');
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    Q, H, S, D = ILI()
    N = II()
    return (Q, H, S, D, N)


def solve(Q, H, S, D, N):
    l_all = []
    l_all.append((Q * 8, "q"))
    l_all.append((H * 4, "h"))
    l_all.append((S * 2, "s"))
    l_all.append((D, "d"))
    l_all.sort(key= lambda x: x[0])
    if N % 2 == 0:
        ans = (N // 2) * l_all[0][0]
    else:
        ans = (N // 2) * l_all[0][0]
        if l_all[0][1] != "d":
            ans += l_all[0][0] // 2
        else:
            ans += l_all[1][0] // 2
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include<stdio.h>

int main(){
  int a = 0, b = 0, c = 0;
  int n = 0, y = 0;
  int s = 0;
  scanf("%d %d", &n, &y);
//  printf("n = %d, y =  %d\n", n, y);

  for(int i = 0; i <= n; i++){
    for(int j = 0; j + i <= n; j++){
      //  printf("1000, 5000, 10000 : %d %d %d\n", n-i-j, j, i);
        if ( y == i*10000 + j*5000 + (n-i-j)*1000 ){
          printf("%d %d %d\n", i, j, n-i-j);
        //  printf("y = %d\n", i*10000 + j*5000 + (n-i-j)*1000);
          s = 1;
          goto OUT;
        }
      }
    }
  OUT:
  if( s == 0){
    a = -1;
    b = -1;
    c = -1;
    printf("%d %d %d\n", a, b, c);
  }




  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define pri 998244353 
#define nonod 1000001
#define pr pair <ll,ll>
#define mnx  1000001
#define inf 100000000000000001
#define prin(x) cout<<setprecision(9)<<fixed<<x<<endl;
using namespace std;





void masterstroke(ll ta){
ll n;cin>>n;
ll ze=0;
ll pre[n];
ll w[n];
ll po=0;
for(ll i=0;i<n;i++){
	cin>>w[i];
	po+=w[i];
	pre[i]=po;
}
ll mx=pri;
for(ll i=0;i<n;i++){
	ll s1=pre[i];
	ll s2=po-pre[i];
	mx=min(mx,abs(s1-s2));
}
cout<<mx<<endl;

    }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke(i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[9999999];
int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i = 2; i < n; i++){
        dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }

    cout << dp[n-1] <<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

	int main(){
	
		int a[4],b[4],i,x,y,z;
		
		
		while( scanf("%d",&a[0]) != EOF){
			x=0;
			y=0;
			
			for(i=1;i<4;i++){
				scanf("%d",&a[i]);
			}
			for(i=0;i<4;i++){
				scanf("%d",&b[i]);
			}
			
			for(i=0;i<4;i++){
				if(a[i]==b[i]){
					x++;
				}
				if(a[i]==b[0] || a[i]==b[1] || a[i]==b[2] || a[i]==b[3]){
					y++;
				}
			}
			
			z=y-x;
			printf("%d %d\n",x,z);
		}
		
	
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    int coins[] = {500, 100, 50, 10, 5};
    while (cin >> n, n) {
        int ans = 0;
        int m = 1000 - n;
        rep(i, 5) {
            ans += m / coins[i];
            m %= coins[i];
        }
        ans += m;
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    for (int i = N; i < 1000; ++i) {
        if (i / 100 == i % 10 && i / 100 == ((i % 100) - (i % 10)) / 10) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;


struct edge{
	ll pre, to, cost;
	edge(ll p, ll t) :pre(p), to(t), cost(0){}
	edge(ll p, ll t, ll c) :pre(p), to(t), cost(c){}
};

template<typename T>
struct node{
	ll num,pare;
	T value;
	vl children;
	node() :num(-1), pare(-1){}
	node(ll n) :num(n){}
	node(ll n, T v) :num(n), value(v){}
};

//木の生成O(N+E)
template<typename T>
struct tree{
	ll root;
	vector<node<T> > nodes;
	vector<edge> edges;

	tree(ll r,vector<T> ns, vvl es):root(r){
		nodes = vector<node<T>>(ns.size());
		vb table(ns.size(), false);
		table[root] = true;
		queue<ll> q;
		q.push(root);
		while (!q.empty()){
			ll now = q.front();
			q.pop();
			nodes[now].value = ns[now];
			table[now] = true;
			for (ll n : es[now]){
				if (table[n]) continue;
				nodes[now].children.push_back(n);
				nodes[n].pare = now;
				edges.push_back(edge(now,n));
				q.push(n);
			}
		}
	}

	ll dfs(ll n){
		stack<ll> q;
		q.push(n);
		while (!q.empty()){
			ll now = q.top();
			q.pop();

			//ここでしたい処理
			if (now != 0){
				nodes[now].value += nodes[nodes[now].pare].value;
			}

			for (ll next : nodes[now].children){
				q.push(next);
			}
		}
		return 0;
	}

	ll bfs(ll n){
		queue<ll> q;
		q.push(n);
		while (!q.empty()){
			ll now = q.front();
			q.pop();

			//ここでしたい処理

			for (ll next : nodes[now].children){
				q.push(next);
			}
		}
		return 0;
	}
};

int main(){
	ll n, q; cin >> n >> q;
	vvl e(n);
	rep(i, n-1){
		ll a, b; cin >> a >> b;
		a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	tree<ll> t(0,vl(n,0),e);
	rep(i, q){
		ll p, x;
		cin >> p >> x;
		p--;
		t.nodes[p].value += x;
	}
	t.dfs(0);
	rep(i, n - 1) cout << t.nodes[i].value << " ";
	cout << t.nodes[n - 1].value << endl;
	return 0;
}

Measured memory_bytes: 47212
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long
const int inf = 1 << 30;
#define INF 1e+9
#define MAX_V 100008


int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> grid(h);
  rep(i, 0, h){
    cin >> grid[i];
  }

  int ans = 0;
  for(int bith = 0; bith<(1<<h); bith++){
    for(int bitw =0; bitw < (1<<w); bitw++){
      int tmp = 0;
      for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
          if(bith & (1<<i) && bitw & (1<<j)){
            if(grid[i][j] == '#')tmp++;
          }
        }
      }
      if(tmp == k)ans++;
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 3616
import sys
from itertools import accumulate

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
A = LMI()

ans = INF
accum = list(accumulate(A))
for s in accum:
    t = accum[-1] - s
    ans = min(ans, abs(s - t))
print(ans)

Measured memory_bytes: 91084
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
const int N = 1e5+10;

int col[N] = {0};

vector<int> g[N];

void dfs(int curr, int par, int c)
{
    col[curr] = c;
    for(auto x: g[curr])
    {
        if(x != par && col[x] == 0)
        {
            dfs(x, curr, c);
        }
    }
}

int main()
{
    int n, m, x, y, z;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int j = 0;
    for(int i=1;i<=n;i++)
        if(col[i] == 0)
        {
            j++;
            dfs(i, -1, j);
        }
    cout<<j<<endl;
}


Measured memory_bytes: 10752
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

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

int main()
{
	int A = 0, B = 0, ans = 0;
	scanf("%d %d", &A, &B);
	ans = A - (2 * B);
	if (ans < 0) {
		ans = 0;
	}
	printf("%d\n", ans);
    return 0;
}


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



int main(){
    ll N;cin>>N;
    ll m=floor(sqrt(2*N))-1;
    rep(i,0,3){
        if(m*(m+1)/2>=N)break;
        m++;
    }
    while(N>0){
        if(N-m<=0){
            cout<<N<<endl;
            return 0;
        }
        cout<<m<<endl;
        N=N-m;
        m--;
    }
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

//nを素因数分解する
vector<pair<ll, ll>> prime_factorize(ll n) {

	vector<pair<ll, ll>> res;
	for (ll p = 2; p*p <= n; ++p) {
		if (n%p != 0) continue;//nをpで割り切れなければ、nの約数ではない
		int num = 0;
		while (n%p == 0) {//指数を求める(p^num=n)
			++num;
			n /= p;
		}
		res.push_back(make_pair(p, num));//素数とその指数を格納する
	}

	if (n != 1) res.push_back(make_pair(n, 1));//残った約数を格納する(指数が1)

	return res;//配列を返す

}

int N;
map<ll, ll> sisuu;// sisuu[p] := 素因数分解における素数 p の指数

ll rec(map<ll, ll>::iterator p, ll mul) {
	if (p == sisuu.end()) {//空ならば
		if (mul == 1) return 1;//約数をちょうど1個もつ
		else return 0;
	}
	ll res = 0;

	for (int i = 0; i < p->second + 1; ++i) {
		if (mul % (i + 1) != 0) continue;//mulが割り切れなければ、処理をしない
		res += rec(++p, mul / (i + 1));
		--p;
	}

	return res;
}


int main() {

	cin >> N;
	for (int i = 2; i <= N; i++) {//N!を素因数分解する
		auto ps = prime_factorize(i);//配列をpsに代入
		for (auto it : ps) sisuu[it.first] += it.second;//Nまでを素因数分解したときの指数を合計する
	}

	cout << rec(sisuu.begin(), 75) << endl;//mapの一番最初の値の位置を渡す


	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
ll cnt[MAX];
ll fact[MAX];
ll dv[MAX];
void precoumpute(){
  for(int i=1;i<MAX;i++)
  {
    for(int j=i;j<MAX;j+=i)
      dv[j]++;
  }
}
int main() 
{

	  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    string s;
    int m;
    precoumpute();
    cin>>m;
    ll ans=0;
    for(int i=1;i<=m;i++)
      ans=ans+((ll)(i)*(dv[i]));
    cout<<ans;
}

Measured memory_bytes: 81764
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
using namespace std;

int main()
{
	ll int k,n,i,f=0,m=0,p,x;
	cin>>k>>n;
	vector<ll int> a;
	vector<ll int > v;
	for(i=0;i<n;i++)
	{
		cin>>x;
		a.push_back(x);
	}
	a.push_back(a[0]);
	

	for(i=0;i<n;i++)
	{
		if (a[i+1]>a[i])
		{
			v.push_back(a[i+1]-a[i]);
		}
		else
		{
			v.push_back(a[i+1]+k-a[i]);
		}
	}

	sort(v.begin(),v.end());
	cout<<k-v[n-1]<<endl;


	
	
	
	
}
	
 


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  IN(N);
  IN(A);
}

void solve() {
  PRINT((N+A-1)/A);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	sort.Ints(A)

	cate := make([]bool, 8)
	other := 0
	for i := 0; i < N; i++ {
		if A[i] >= 3200 {
			other++
		} else {
			cate[A[i]/400] = true
		}
	}
	count := 0
	for i := 0; i < len(cate); i++ {
		if cate[i] {
			count++
		}
	}
	if count == 0 {
		fmt.Println(1, other)
	} else {
		fmt.Println(count, count+other)

	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int A, B, C;
   cin >> A >> B >> C;
   if (A == B) cout << C << endl;
   else if (B == C) cout << A << endl;
   else cout << B << endl;
   return 0;
}


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


int main() {
  int n;
  cin >> n;
  int mx, ans = 1;
  cin >> mx;
  rep(i,n-1) {
    int x;
    cin >> x;
    if(x<mx) continue; 
    ans++;
    mx = x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3524
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> d(n);
	set<int> fnd;
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
		fnd.insert(d[i]);
	}

	cout << fnd.size() << endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import math

N, A, B = map(int, input().split(' '))
hn = [int(input()) for i in range(N)]

maxT = max(hn) // B + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if (h - B*T) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = (maxT + minT) // 2
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)


Measured memory_bytes: 11080
import math

while True:
    n = input()
    if n == 0:
        break
    s = map(int,raw_input().split())
    a2 = 0
    m = sum(s)/float(n)
    for i in s:
        a2 += (i - m)**2
    a2 = a2/float(n)
    print math.sqrt(a2)

Measured memory_bytes: 6460
#include<bits/stdc++.h>
using namespace std;
#define N 10010
char a[N];
int main()
{
    int i,j,k,n,ans,l,r,mid;
    scanf("%d",&n);
    ans=0;
    l=0;
    r=0;
    mid=0;
    for(i=0;i<n;i++)
    {
        scanf("%s",a);
        k=strlen(a);
        if(a[0]=='B'&&a[k-1]=='A')
            mid++;
        else
        {
            if(a[0]=='B')
                r++;
            if(a[k-1]=='A')
                l++;
        }
        for(j=0;j<k-1;j++)
        if(a[j]=='A'&&a[j+1]=='B')
            ans++;
    }
    if(l>0&&r>0)
    {
        l--;
        r--;
        ans=ans+mid+1;
        ans=ans+min(l,r);
    }
    else
    {
        if(l>0)
            ans=ans+mid;
        else
        if(r>0)
            ans=ans+mid;
        else
            ans=ans+max(0,mid-1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,int> >G[1<<17];
vector<pair<int,int> >visit;
int color[1<<17];
int fixedid=-1;
int S[1<<17];
bool dfs(int u,int col)
{
	color[u]=col;
	for(pair<int,int>p:G[u])
	{
		if(color[p.first]==0)
		{
			visit.push_back(make_pair(p.second,u));
			if(dfs(p.first,3-col))return true;
			visit.pop_back();
		}
		else if(color[p.first]==col)
		{
			fixedid=p.first;
			long sum=p.second;
			int u;
			do{
				u=visit.back().second;
				sum=visit.back().first-sum;
				visit.pop_back();
			}while(u!=p.first);
			S[fixedid]=sum%2?-1:sum/2;
			return true;
		}
	}
	return false;
}
long SS[1<<17];
bool dfs2(int u,long now)
{
	color[u]=5;
	SS[u]=now;
	for(pair<int,int>p:G[u])
	{
		if(color[p.first]!=5)
		{
			if(dfs2(p.first,p.second-now))return true;
		}
		else if(p.second-now!=SS[p.first])return true;
	}
	return false;
}
int L[1<<17],R[1<<17];
void dfs3(int u)
{
	for(pair<int,int>p:G[u])
	{
		if(L[p.first]<0)
		{
			L[p.first]=max(1,p.second-R[u]);
			R[p.first]=max(0,p.second-L[u]);
			dfs3(p.first);
		}
		else
		{
			L[p.first]=max(L[p.first],p.second-R[u]);
			R[p.first]=min(R[p.first],max(0,p.second-L[u]));
		}
	}
}
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;a--,b--;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	if(dfs(0,1))
	{
		queue<int>P;
		P.push(fixedid);
		bool flag=S[fixedid]>0;
		while(!P.empty())
		{
			int u=P.front();P.pop();
			for(pair<int,int>p:G[u])
			{
				if(S[p.first]>0)
				{
					if(S[u]+S[p.first]!=p.second)
					{
						flag=false;
						break;
					}
				}
				else
				{
					S[p.first]=p.second-S[u];
					if(S[p.first]<=0)
					{
						flag=false;
						break;
					}
					P.push(p.first);
				}
			}
		}
		cout<<flag<<endl;
		return 0;
	}
	if(dfs2(0,0))
	{
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<N;i++)L[i]=-1;
	L[0]=1;
	R[0]=1e9;
	dfs3(0);
	int id=0;
	for(int i=0;i<N;i++)if(R[id]-L[id]>R[i]-L[i])id=i;
	for(int i=0;i<N;i++)if(id!=i)L[i]=-1;
	dfs3(id);
	int ans=1e9;
	for(int i=0;i<N;i++)ans=min(ans,R[i]-L[i]+1);
	cout<<max(ans,0)<<endl;
}

Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

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

  cout << max(0, a - 2 * b) << endl;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int duration = h2 * 60 + m2 - (h1 * 60 + m1);
    cout << duration - k << endl;
}

Measured memory_bytes: 3660
def prime_factorize(n):
    a = []
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            a.append([i, cnt])
    if tmp != 1:
        a.append([tmp, 1])
    if not len(a) and n != 1:
        a.append([n, 1])
    return a


N = int(input())

ans = prime_factorize(N)
count = 0
for ls in ans:
    target = ls[1]
    tmp = 1
    while True:
        if target - tmp >= 0:
            target = target - tmp
            tmp += 1
            count += 1
        else:
            break
print(count)


Measured memory_bytes: 9484
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string str;
	cin >> str;
	if(str[1] == 'B') str[1] = 'R';
	else str[1] = 'B';
	cout << str << '\n';
}



Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String line = readLine();
		String[] strArray = line.split(" ");
		int[] array = new int[strArray.length];
		for(int i = 0; i < array.length; i++ ) {
			array[i] = Integer.parseInt(strArray[i]);
		}
		int distanceA = Math.abs(array[0] - array[1]);
		int distanceB = Math.abs(array[0] - array[2]);
		if(distanceA < distanceB) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}


	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}
}

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

main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  for(int ii=0;ii<N;ii++){
    cin >> h[ii];
  }
  int cnt=0;
  for(int ii=0;ii<N;ii++){
    if(h[ii]>=K)cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple

int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n; string s; cin>>s;
	if(n>=3200) cout<<s;
	else cout<<"red";
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
//#include<iostream>
#include<iostream>
#include<cmath>
typedef long long int ll;
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	ll stool=0;
	for(ll i=0;i<n;++i)
	{
		cin>>arr[i];
	}
	for(int i=1;i<n;i++)
	{
		if(arr[i]<arr[i-1])
		{
		
			stool+=(arr[i-1]-arr[i]);
			arr[i]=arr[i-1];
		}
	}
	cout<<stool;
}

Measured memory_bytes: 5124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    map<string, ll> m;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1;

    string S;
    cin >> S;
    cout << m[S] << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <sstream>
#include <string>
#include <time.h>
#include <math.h>

using namespace std;

int main() {
  long long int N;
  cin >> N;
  int odd=0;
  int gu=0;
  long long int A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A % 2 == 1) odd++;
    else gu++;
  }
  while (1) {
    if (odd <= 1 && gu <= 1) break;
    if (odd >= 2) {
      odd -= 2;
      gu++;
    }
    if (gu >= 2) {
      gu -= 2;
      gu++;
    }
  }
  if (odd == 1 && gu == 1) {
    cout << "NO" << endl;
  }
  else if (odd == 0 && gu == 0) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    long x[N], y[N], h[N];
    int able_h = 0;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0){
            able_h = i;
        }
    }
    for(long i = 0; i <= 100; i++){
        for(long j = 0; j <= 100; j++){
            long H = abs(x[able_h] - i) + abs(y[able_h] - j) + h[able_h];
            bool is_ok = true;
            for(int k = 0; k < N; k++){
                if(max(H - abs(x[k] - i) - abs(y[k] - j), 0l) != h[k]){
                    is_ok = false;
                    break;
                }
            }
            if(is_ok){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
tmp = [list(map(int, input().split())) for _ in range(M)]

A, B = [], []
for t in tmp:
    A.append(t[0])
    B.append(t[1])

is_good_arr = [True] * N

for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        is_good_arr[B[i] - 1] = False
    elif H[A[i]-1] < H[B[i]-1]:
        is_good_arr[A[i] - 1] = False 
    else:
        is_good_arr[A[i]-1], is_good_arr[B[i]-1] = False, False

print(is_good_arr.count(True))

Measured memory_bytes: 34408
from functools import lru_cache

N = input()
K = int(input())

@lru_cache(maxsize=None)
def search(d, cnt, isLess):
    if d == len(N):
        return cnt == K

    a = int(N[d])

    if isLess:
        return search(d + 1, cnt + 1, isLess) * 9 + search(d + 1, cnt, isLess)

    ret = 0
    for i in range(a + 1):
        ret += search(d + 1, cnt + (i != 0), i < a)
    return ret

print(search(0, 0, False))

Measured memory_bytes: 4828
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

void dump(Vec<Vec<int> >& table, int h);

int del(Vec<Vec<int> >& table, int h) {
    int score = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j <= 2; j++) {
            int end = j + 1;
            while (1) {
                if (table[i][j] == table[i][end]) {
                    end++;
                } else {
                    end--;
                    break;
                }
            }
            if (end - j >= 2) {
                score += table[i][j] * (end - j + 1);
                for (int k = j; k <= end; k++) {
                    table[i][k] = -k;
                }
                break;
            }
        }
    }
    return score;
}

void drop(Vec<Vec<int> >& table, int h) {
    while (1) {
        Vec<Vec<int> > new_table = table;
        for (int i = h - 1; i > 0; i--) {
            for (int j = 0; j < 5; j++) {
                if (new_table[i][j] == -j) {
                    new_table[i][j] = new_table[i - 1][j];
                    new_table[i - 1][j] = -j;
                }
            }
        }

        if (new_table == table) {
            break;
        } else {
            table = new_table;
        }
    }
    return;
}

int main(void) {
    while (1) {
        int h;
        cin >> h;
        if (h == 0) {
            break;
        }
        Vec<Vec<int> > table(h, Vec<int>(5));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> table[i][j];
            }
        }
        int score = 0;
        while (1) {
            int this_score = del(table, h);
            if (this_score == 0) {
                break;
            } else {
                score += this_score;
                drop(table, h);
            }
        }
        cout << score << endl;
    }

    return 0;
}

void dump(Vec<Vec<int> >& table, int h) {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < 5; j++) {
            cout << table[i][j] << " ";
        }
        cout << endl;
    }
    return;
}

Measured memory_bytes: 3088
N = int(input())
A = list(map(int, input().split()))

ans = 1
mod = 10 ** 9 + 7
a = [0] * N
for i in range(N):
    if A[i] == 0:
        ans *= (3 - a[0])
        a[0] += 1
    else:
        ans = (ans * (a[A[i]-1] - a[A[i]])) % mod
        a[A[i]] += 1

print(ans)

Measured memory_bytes: 14004
#include<stdio.h>
   double W,H,x,y;
   double e;
   int main()
   {
   while(scanf("%lf%lf%lf%lf",&W,&H,&x,&y)!=EOF)
	  {
	  e=W*H/2;
	  printf("%lf ",e);
	  if(x==W/2&&y==H/2)
	  printf("1\n");
	  else
	  printf("0\n");
      }
   }
 // 

Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
        HashSet<Integer> hs = new HashSet<Integer>();
        for(int i = 0 ;i < 3;i++)hs.add(scanner.nextInt());
		System.out.println(hs.size());
		scanner.close();
	}


}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string s;

int main() {
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

static const int INFTY = (1 << 29);
static const int WHITE = 0; //?????¢?´¢
static const int GRAY = 1; //??¢?´¢??????
static const int BLACK = 2; //?¨??????????

int n, M[101][101];

void dijkstra(void) {
	int dist[101]; //?§????????????????i????§????????????????????????????
	int color[101]; //?¨??????¶???(???or??°or???)

	//?????????????????§?????????????¨??????¶???????????§?????????
	REP(i, n) {
		dist[i] = INFTY;
		color[i] = WHITE;
	}

	dist[0] = 0; //?§????0??????0?????§???????????????0
	color[0] = GRAY; //0?????¢?´¢??????	

	//?????¢?´¢???????????????????????????????°??????????????§????????????????????????´??°????????????
	int minCost;
	while (true) {
		minCost = INFTY; //????°??????????????????????
		int minNode = -1; //????°?????????????????????????????????????
		REP(i, n) {
			if (minCost > dist[i] && color[i] != BLACK) {
				minNode = i;
				minCost = dist[i];
			}
		}
		if (minNode == -1) break; //-1???????????¨???????????¨????????????????????????????????£?????¨???????????¨

		color[minNode] = BLACK; //????°??????????????????????????§??????????????¨???????????????????

		//??¢?´¢????????????????????????????????´??°??????
		REP(v, n) {
			if (color[v] != BLACK && M[minNode][v] != INFTY) {
				if (dist[v] > dist[minNode] + M[minNode][v]) {
					dist[v] = dist[minNode] + M[minNode][v];
					color[v] = GRAY;
				}
			}
		}
	}
	
	REP(i, n) {
		cout << i << " " << (dist[i] == INFTY ? -1 : dist[i]) << endl;
	}

}

int main() {
	cin >> n;

	//??£??\???????????????????????§?????????
	REP(i, n) {
		REP(j, n) {
			M[i][j] = INFTY;
		}
	}

	//??£??\??????????????????
	int u, k, v, c;
	REP(i, n) {
		cin >> u >> k;
		REP(j, k) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}

	dijkstra();

	
	return 0;
}

Measured memory_bytes: 3076
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
struct dta{
	int x,y,h;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
	vector<dta> A(n);
	for(int i = 0; n > i; i++){
		cin>>A[i].x>>A[i].y>>A[i].h;
	}
	for(int i = 0; 100 >= i; i++){
		for(int j = 0; 100 >= j; j++){
			bool ok = true;
			int h = 0;
			for(int k = 0; n > k; k++){
				if(A[k].h){
					h = abs(i-A[k].x)+abs(j-A[k].y)+A[k].h;
					break;
				}
			}
			for(int k = 0; n > k; k++){
				if(!A[k].h){
					if(h > abs(i-A[k].x)+abs(j-A[k].y)){
						ok = false;
						break;
					}
				}else if(max(0,abs(i-A[k].x)+abs(j-A[k].y)+A[k].h) != h){
					ok = false;
					break;
				}
			}
			if(ok){
				cout << i << " " << j << " " << h << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<(N);I++)
#define REPP(I, N) for(int I=1;I<=(N);I++)
#define SZ(x) (int)(x).size()
#define P pair<int, int>
#define F first
#define S second
#define PB(x) push_back(x)
#define endl "\n"
#define ll long long
//#define int long long

//===================================================//

#define N 200
#define modn 1000000007

using namespace std;
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
int n,m,r,u,v,c,pt,ans;
int rd[N+5][N+5];
bool vis[N+5];
vector<int> que;
void DFs(int tk, int npt, int dis){
    if(tk==r) ans = min(ans, dis);
    else{
        for(auto to:que) if(!vis[to]){
            vis[to] = true;
            DFs(tk+1, to, dis + rd[npt][to]);
            vis[to] = false;
        }
    }
}
int32_t main(void){
    RIII(n,m,r);
    REP(i,r){
        RI(pt);
        que.PB(pt);
    }
    REP(i,m){
        RIII(u,v,c);
        rd[u][v] = c;
        rd[v][u] = c;
    }
    REPP(k,n) REPP(i,n) REPP(j,n){
        if(i==j|| !rd[i][k]|| !rd[k][j]) continue;
        if(rd[i][j]){
            rd[i][j] = min(rd[i][j], rd[i][k] + rd[k][j]);
        }
        else {
            rd[i][j] = rd[i][k] + rd[k][j];
        }
    }
    ans = 1e9;
    for(auto to:que){
        vis[to] = true;
        DFs(1, to, 0);
        vis[to] = false;
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384