akhauriyash/Code-Regression huggingface dataset:
//
// Created by kuribohkute on 29/12/2018.
//

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

using namespace std;

typedef long long cc;

const int N = 1000006, md = 1000000000 + 7;

int cnt[N];
int cnt_a[N], cnt_b[N];

bool ina[N], inb[N];

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> a, b;
    a.resize(n);
    b.resize(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        if (cnt[a[i]] > 1) {
            cout << 0;
            return 0;
        }
        cnt_a[a[i]]++;
        ina[a[i]] = true;
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        cnt[b[i]]++;
        if (cnt[b[i]] > 2) {
            cout << 0;
            return 0;
        }
        cnt_b[b[i]]++;
        inb[b[i]] = true;
    }

    for (int i = 1; i < N; i++) {
        cnt_a[i] += cnt_a[i - 1];
    }
    for (int i = 1; i < N; i++) {
        cnt_b[i] += cnt_b[i - 1];
    }

    cc res = 1;
    for (int i = m * n; i >= 1; i--) {
        cc cur = i;
        if (cnt[i] == 2) {
            cur = 1;
        } else {
            if (ina[i]) {
                cur = m - cnt_b[i];
            } else
                if (inb[i]) {
                    cur = n - cnt_a[i];
                } else {
                    cc x = n - cnt_a[i];
                    cc y = m - cnt_b[i];
                    cur = x * y - n * m + i;
                    if (cur < 0) cur = 0;
                }
        }
        res = (1ll * res * cur) % md;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 8576
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	int N;
	cin >> N;
	if (N > 2) {
		int B, B2;
		cin >> B;
		vector<int>A(N);
		A.at(0) = B;
		cin >> B2;
		for (size_t i = 1; i < N - 1; i++)
		{
			A.at(i) = min(B, B2);
			B = B2;
			if (i != N - 2) {
				cin >> B2;
			}
		}
		A.at(N - 1) = B2;
		int max = 0;
		for (size_t i = 0; i < N; i++)
		{
			max += A.at(i);
		}
		cout << max << endl;
	}
	else {
		int B;
		cin >> B;
		cout << B * 2 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  int ans = INF;
  int t1 = 0;
  int t2 = 0;
  rep(i,s.size()){
    if((s[i]-'0')==(i%2))t1++;
  }
  rep(i,s.size()){
    if((s[i]-'0')==(1-(i%2)))t2++;
  }
  chmin(ans,t1);
  chmin(ans,t2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
S = input()

n = 0
s = 0
e = 0
w = 0

for i in range(len(S)):
	if S[i]=='N':
		n = 1
	elif S[i]=='S':
		s = 1
	elif S[i]=='E':
		e = 1
	else:
		w = 1

if abs(n-s)==1 or abs(e-w)==1:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 3064
import Control.Applicative

main :: IO ()
main = do
  xs <- (map read . words) <$> getLine
  if (xs !! 0) == 0 && (xs !! 1) == 0 then return ()
    else do
    {
      putStrLn $ (solve (xs !! 0) (xs !! 1));
      main
    }
         
solve :: Int -> Int -> String
solve x y
  | x < y = show x ++ " " ++ show y
  | otherwise = show y ++ " " ++ show x

Measured memory_bytes: 3920
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#include <ctime>
#include <set>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define MACRO(a) for(int a = 1; a < 1001; a++)

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	vector<int> vec(3, 0);
	for (int i = 0; i < 3; i++) cin >> vec[i];
	sort(vec.begin(), vec.end());

	int ret = vec[2] - vec[1];
	vec[1] += ret;
	vec[0] += ret;

	int dist = vec[1] - vec[0];
	int time = dist / 2;
	if (dist % 2) time += 1;

	ret += time;
	vec[0] += time * 2;

	if (vec[0] != vec[1])
		ret += 1;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}
vector<ll> Lagrange(vector<ll> &pts, vector<ll> &value, ll mod) {
    int K = pts.size();
    vector<ll> prod(K+1, 0), res(K, 0);
    prod[0] = 1;
    for (int i = 0; i < K; i++) {
        for (int j = i+1; j > 0; j--) {
            prod[j] = (prod[j-1]+prod[j]*(mod-pts[i])) % mod;
        }
        prod[0] = prod[0] * (mod-pts[i]) % mod;
    }
    
    for (int i = 0; i < (int)value.size(); i++) {
        if (value[i] == 0) continue;
        ll coef = 1;
        for (int j = 0; j < K; j++) {
            if (i == j) continue;
            coef *= pts[i]-pts[j]+mod;
            coef %= mod;
        }
        coef = modinv(coef, mod) * value[i] % mod;
        ll high = 1;
        for (int j = K-1; j >= 0; j--) {
            res[j] += high * coef % mod;
            high = (high * pts[i] + prod[j]) % mod;
        }
    }
    
    for (int i = 0; i < K; i++) res[i] %= mod;
    
    return res;
}

int main() {
    ll p;
    cin >> p;
    vector<ll> pts(p), value(p);
    iota(pts.begin(), pts.end(), 0);
    for (int i = 0; i < p; i++) cin >> value[i];
    vector<ll> ans = Lagrange(pts, value, p);
    for (int i = 0; i < p; i++) {
        if (i < p-1) printf("%lld ", ans[i]);
        else printf("%lld\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  ll x;
  cin >> x;

  ll a=0,b=0;
  bool fminus = false;
  for(ll i=-120;i<=120;i++){
    bool flag = false;
    fminus = false;
    ll a5 = i*i*i*i*i;
    a = i;
    ll b5 = a5-x;
    int cnt = 0;
    ll b5_abs = b5;
    if(b5_abs < 0){
      b5_abs *= -1;
      fminus = true;
    }
    //b5_absの約数を求める
    ll r = b5_abs;
    for(ll j=1;j<=2000;j++){
      b5_abs = r;
      if(b5_abs%j==0){
        b5_abs/=j;
        if(b5_abs%j==0){
          b5_abs/=j;
          if(b5_abs%j==0){
            b5_abs/=j;
            if(b5_abs%j==0){
              b5_abs/=j;
              if(b5_abs == j){
                b = j;
                flag = true;
              }
            }
          }
        }
      }
    }
    if(flag){
      break;
    }
  }

  if(fminus){
    b *= -1;
  }

  cout << a << " " << b << endl;
}


Measured memory_bytes: 3636
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int r;
    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include<cstdio>
#include<cctype>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{
    while(true){
        char b[1001]="0";
        cin.getline(b,sizeof(b));
        char c[strlen(b)];
        strcpy(c,b);
        if(c[0]!='0'){
            int x=0;
            for(int k=0;k<strlen(c);k++){
                int n;
                n=c[k]-'0';
                x+=n;
            }cout<< x<<endl;
        }else{
            break;
        }
    }

    
    return 0;
}


Measured memory_bytes: 3148
#!/usr/bin/env python3


def main():
    n = input()
    l = [int(x) for x in list(str(n))]
    if l[-1]==2 or l[-1]==4 or l[-1]==5 or l[-1]==7 or l[-1]==9:
        print("hon")
    elif l[-1]==0 or l[-1]==1 or l[-1]==6 or l[-1]==8:
        print("pon")
    elif l[-1]==3:
        print("bon")

if __name__ == '__main__':
    main()

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

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

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

using namespace std;

int main() {
    
    int a, b;
    cin >> a >> b;
    int temp = 1;
    int ans = 0;
    while(temp < b){
        temp += a - 1;
        ans++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int count=0;
  for(int x=1;x<=N;x+=2){
    int num=0;
    for(int y=1;y<=x;y++)
      if(x%y==0) num++;
    if(num==8) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
var c = 0;

(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var A = p.shift().split(' ', n).map(Number);

    mergeSort(A, 0, A.length);

    console.log(A.join(' '));
    console.log(c);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function mergeSort(array, left, right) {
    if (left + 1 < right) {
        var mid = Math.floor((left + right) / 2);
        mergeSort(array, left, mid);
        mergeSort(array, mid, right);
        mergeSortSub(array, left, mid, right);
    }

    function mergeSortSub(array, left, mid, right) {
        var n1 = mid - left;
        var n2 = right - mid;
        var leftArray = [];
        var rightArray = [];
        for (var i = 0; i < n1; i++) {
            leftArray.push(array[left + i]);
        }
        for (var i = 0; i < n2; i++) {
            rightArray.push(array[mid + i]);
        }
        leftArray.push(Infinity);
        rightArray.push(Infinity);
        var i = j = 0;
        for (var k = left; k < right; k++) {
            c++;
            if (leftArray[i] <= rightArray[j]) {
                array[k] = leftArray[i];
                i++;
            } else {
                array[k] = rightArray[j];
                j++;
            }
        }
    }
}

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

int main()
{
    int n,i,j;
    cin>>n;
    if(n<4)
	{
		cout<<"No";
		return 0;
	}
    else
    {
    	for(i=0;i<=n/4;i++)
    		for(j=0;j<=(n-4*i)/7;j++)
    			if(4*i+7*j==n) 
    			{
    				cout<<"Yes";
					return 0;
				}
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vector<ll> P(N);
    loop(i, N)
    {
        cin >> P[i];
        P[i]--;
    }
    vector<ll> A(N), B(N);
    loop(i, N)
    {
        A[i] = N * (i + 1);
        B[i] = 1000000000 - A[i];
    }
    loop(i, N)
    {
        A[P[i]] += i;
    }
    loop(i, N)
    {
        cout << A[i];
        if (i != N - 1)
            cout << " ";
        else
            putout("");
    }
    loop(i, N)
    {
        cout << B[i];
        if (i != N - 1)
            cout << " ";
        else
            putout("");
    }
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,n[3];
	cin>>a>>b;
	n[0]=a+b;
	n[1]=a-b;
	n[2]=a*b;
	sort(n,n+3);
	cout<<n[2];
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; ++i) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());  // a[0:N] を大きい順にソート
    int i = 0;
    int sum = 0;
    while (i < K) {
        sum += l[i];
        i++;
    }
    cout << sum << endl;
}

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

int main(){
	int m, d;
	int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	
	while( scanf(" %d %d", &m, &d)*m != 0 ){
		int i=0, c=0;
		while(i<=m-2){
			c+=days[i];
			++i;
		}
		c+=d;
	
		//printf("%d\n", c);
		if(c%7==1) printf("Thursday\n");
		else if(c%7==2) printf("Friday\n");
		else if(c%7==3) printf("Saturday\n");
		else if(c%7==4) printf("Sunday\n");
		else if(c%7==5) printf("Monday\n");
		else if(c%7==6) printf("Tuesday\n");
		else if(c%7==0) printf("Wednesday\n");
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> d;
  d.resize(N);
  for(int i=0; i < N; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  
  cout << d.size() << endl;
  return 0;

}

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

template<typename T>
class MaxHeap{
private:
	vector<T> d;
public:
	void push(T t){
		d.push_back(t);
	}
	void maxHeapify(int k){
		int l = 2 * k + 1;
		int r = 2 * k + 2;
		T largest;
		if(l < d.size() && d[l] > d[k]) largest = l;
		else largest = k;

		if(r < d.size() && d[r] > d[largest]) largest = r;

		if(largest != k){
			swap(d[k], d[largest]);
			maxHeapify(largest);
		}
	}
	void buildMaxHeap(){
		for(int i = d.size() / 2; i >= 0; i--){
			maxHeapify(i);
		}
	}
	void printHeap(){
		for(int i = 0; i < d.size(); i++){
			cout << " " << d[i];
		}
		cout << endl;
	}
};

int main(){
	int h;
	cin >> h;
	MaxHeap<int> mh;
	for(int i = 0; i < h; i++){
		int a;
		cin >> a;
		mh.push(a);
	}
	mh.buildMaxHeap();
	mh.printHeap();
}

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

int main(){
    double A, B; cin >> A >> B;
    double P, Q, R; cin >> P  >> Q >> R;

    cout << setprecision(10) << fixed << B +  (P * B - Q * (B - A)) / (Q + R) << endl;
}


Measured memory_bytes: 3280
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        string str;
                        cin>>str;
                        for(char ch:str)
                                if(ch=='7'){
                                        cout<<"Yes\n";
                                        return ;
                                }
                        cout<<"No\n";
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 3652
#include <stdio.h>
int main () {
  int a,b,c,d,s,e,t;
  scanf ("%d%d%d%d",&a,&b,&c,&d);
  if (a < c) {
    s = c;
  } else {
    s = a;
  }
  if (b < d) {
    e = b;
  } else {
    e = d;
  }
  t = e - s;
  if (t >= 0) {
    printf ("%d\n", t);
  } else {
    printf ("0\n");
  }
  return 0;
}

Measured memory_bytes: 1724
// Problem : D - Sum of Large Numbers
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;
const int MOD=1e9+7;

ll Pow(ll x,ll p){
	ll ret=1;x%=MOD;
	for(;p;p>>=1,x=x*x%MOD) if(p&1) ret=ret*x%MOD;
	return ret;
}

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

int main()
{
	ll n,k;cin>>n>>k;
	ll ans=0;
	for(int i=k;i<=n+1;++i){
		ans+=sum(n-i+1,n)-sum(0,i-1)+1;
		// cout<<sum(n-i+1,n)-sum(0,i-1)+1<<endl;
	}	
	cout<<ans%MOD<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int x;
  cin>>x;
  if(x >= 400 && x <= 599)
    cout<<8;
  else if(x >= 600 && x <= 799)
    cout<<7;
  else if(x >= 800 && x <= 999)
    cout<<6;
  else if(x >= 1000 && x <= 1199)
    cout<<5;
  else if(x >= 1200 && x <= 1399)
    cout<<4;
  else if(x >= 1400 && x <= 1599)
    cout<<3;
  else if(x >= 1600 && x <= 1799)
    cout<<2;
  else if(x >= 1800 && x <= 1999)
    cout<<1;
    

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define inc(a) sort(a.begin(), a.end())
#define dec(a) sort(a.rbegin(), a.rend())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll n; cin>>n;
    vector<pair<ll, ll>> e(n);
    loop(n){
        cin>>e[i].first;
        e[i].second = i+1;
    }

    inc(e);
    loop(n) cout<<e[i].second<<" ";
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define for(i,s,n) for(int i=s;i<=n;++i)

int main(){
    double d,t,s;
    cin>>d>>t>>s;
    double cur = d/t;
    if(cur > s){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n + 2);
  for(int i = 1; i <= n; ++i) cin >> v[i];
  v[0] = 0;
  v[n + 1] = 0;
  long long scheduled = 0;
  for(int i = 0; i <= n; ++i){
    scheduled += abs(v[i] - v[i + 1]);
  }
  for(int i = 1; i <= n; ++i){
    cout << scheduled + abs(v[i - 1] - v[i + 1]) - abs(v[i - 1] - v[i]) - abs(v[i] - v[i + 1]) << endl;
  }
}

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



int main(){
  int N;
  cin >> N;
  
  if(N>=30) cout << "Yes"  << endl;
  else cout << "No"  << endl;
 


}

Measured memory_bytes: 3628
#include <stdio.h>
#include <algorithm>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
#define LIM_A 100001
int a, b;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &a, &b);
}

void solve() {
	int ans = 0;
	ans = a - 2 * b;
	ans = ans < 0 ? 0 : ans;

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

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 128
//しゃきょ〜〜〜〜〜〜〜〜〜〜〜〜〜	

#include <bits/stdc++.h>

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int dp[105][4][2];//0埋めされている
int main()
{
	string s ;
	cin >> s ;
	int n = s.size();//桁数がn
	int K ;
	cin >> K ;
	dp[0][0][0] = 1 ;
	//配る
	rep(i,n) rep(j,4) rep(k,2) {//iが小さい順にやるのが大事
		int nd = s[i] -'0' ; //nの今の桁
		rep(d,10){
			//次の桁を0~9野どれにするか
			int ni = i+1 , nj = j , nk = k; //遷移先
			if(d != 0) nj ++ ;
			if(nj > K) continue; //遷移先は無い
			if(k==0) {
				if(d > nd) continue;//超えちゃう
				if(d < nd) nk = 1 ;//以下になることが確定
			}
			dp[ni][nj][nk] += dp[i][j][k]; 
		}
	}
	int ans = dp[n][K][0] + dp[n][K][1];
	cout <<ans << endl;
}


Measured memory_bytes: 256
import math

N = int(input())

memo = [0]*26
for i in range(26):
    memo[i] = 5**(i+1)

if N % 2 == 0:
    ans = 0
    for j in range(26):
        ans += (N//memo[j])//2
    print(ans)
else:
    print(0)

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

int main(){
  int N;
  cin >> N;
  
  int f=0;
  for(int i=0; N>=pow(10,i); i++){
    f += (N/(int)pow(10,i))%10;
  }
  
  if(N%f==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
   long int b,c,sum,i,j,count=0;
   char a[50];
  gets(a);
  for(i=0;i<strlen(a);i++)
  {
      if(a[i]=='o')
      {
          count++;
      }
  }
  printf("%ld",700+(count*100));
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main(){
  int i = 0, n, total = 0;
  int num[10000];

  scanf("%d", &n);
  while((scanf("%d", &num[i])) != EOF) {
    i++;
  }

  for(i = 0; i < n; i++) {
    if(isPrime(num[i])) total++;
  }
  printf("%d\n", total);

  return 0;
}

int isPrime(int num) {
  int i;

  if (num == 2) return 1;
  if (num < 2 || num%2 == 0) return 0;

  i = 3;
  while (i <= sqrt(num)) {
    if(num%i==0) return 0;
    i += 2;
  }
  return 1;
}

Measured memory_bytes: 628
n=int(input())
a=[int(x) for x in input().split()]
s=[]
ans=0
for i in range(len(a)):
    if a[i]%2==0:
        s.append(a[i])
for i in range(len(s)):
    if s[i]%3==0:
        ans+=1
    elif s[i]%5==0:
        ans+=1
if ans==len(s):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
//typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};
 
 
typedef vector<char> vec;
typedef vector<vec> mat;
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
int X, Y;
 
struct State{
    int d,pn;
    char c;
    mat f;
    bool operator<(const State& right) const{
        return d == right.d ? pn < right.pn : d > right.d;
    }
};
 
int paint(int y, int x, char c, char nc, mat& f){
    f[y][x] = nc;
    int ret = 1;
    for(int i=0;i<4;i++){
        int nx = x+dx[i], ny = y+dy[i];
        if(nx<0||X<=nx||ny<0||Y<=ny||f[ny][nx]!=c) continue;
        ret += paint(ny, nx, c, nc, f);
    }
    return ret;
}
 
const char color[] = {'R','G','B'};
 
int main(){
    while(cin >> X >> Y, X){
        mat field(Y, vec(X));
        for(int i=0;i<Y;i++){
            for(int j=0;j<X;j++){
                cin >> field[i][j];
            }
        }
        priority_queue<State> que;
        int d[101];fill(d,d+101,INF);
        d[0] = 0;
        que.push((State){0,0,field[0][0],field});
        bool ans_found = false;
        while(que.size()){
            State p = que.top(); que.pop();
            if(d[p.pn]<p.d) continue;
            for(int i=0;i<3;i++){
                if(p.c==color[i])continue;
                mat nf = p.f;
                int npn = paint(0,0,p.f[0][0],color[i],nf);
                if(npn == X*Y){
                    ans_found = true;
                    break;
                }
                if(npn <= p.pn) continue;
                if(d[npn]<p.d+1) continue;
                d[npn] = p.d+1;
                que.push((State){p.d+1,npn,color[i],nf});
            }
            if(ans_found){
                cout << p.d << endl;
                break;
            }
        }
    }
 
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pii;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(int argv, char* argc[])
{
    FASTIO

    ll n,k;
    cin>>n>>k;
    ll g = n/k;
    n-=g*k;
    ll ans = min(n,abs(n-k));
    cout<<ans;

    return 0;
}



Measured memory_bytes: 3660
_,m,*A=map(int,open(0).read().split());S=l=3*m;D=[0]*l
for a,b in zip(A,A[1:]):
 b+=m*(b<a);k=b-a;S+=k
 if k>1:D[a+2]+=1;D[b+1]-=k;D[b+2]+=k-1
exec("for i in range(l):D[i]+=D[i-1]\n"*2);print(S-l-max(D[a]+D[a+m]for a in A))

Measured memory_bytes: 17732
#include<stdio.h>
int main(void)
{
	int n,i,a[100],b[100],max=0,j;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<100;i++) b[i]=1;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]==a[j]) a[j]=0;
		}
	}
	for(i=0;i<n;i++) if(a[i]!=0) max++;
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
fn main() {
    let mut s: Vec<char> = {
        let s = read::<String>();
        s.chars().into_iter().collect()
    };

    for i in 0..s.len() {
        s[i] = 'x';
    }

    println!("{}", s.into_iter().collect::<String>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(args[0] * args[1]);

        }

    }

}

Measured memory_bytes: 28236
#include <bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
} a[100005];
//int ans[200005];
int l[200005],r[200005];
int main ()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
        scanf("%d%d",&a[i].x,&a[i].y);
    for(int i=1; i<=n; i++)
        l[i]=r[i]=i;
    sort(a,a+m,[](node xx,node yy)
    {
        return xx.x<yy.x;
    });
    for(int i=0;i<m;i++)
    {
        l[a[i].y+1]=min(l[a[i].y],l[a[i].y+1]);
        r[a[i].y]=max(r[a[i].y],r[a[i].y+1]);
    }
    printf("%d",r[1]-l[1]+1);
    for(int i=2;i<=n;i++)
        printf(" %d",r[i]-l[i]+1);
    puts("");
}

Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> memo = {-A[0]};
    rep2(i, 1, N) {
        int tmp = upper_bound(ALL(memo), -A[i]) - memo.begin();
        if (tmp == memo.size()) memo.push_back(-A[i]);
        else memo[tmp] = -A[i];
    }
    cout << memo.size() << endl;
}


Measured memory_bytes: 4252
N,K = map(int,input().split())
if N<3:
    print(0)
    exit()

table = [[0]*5 for i in range(11)]
for i in range(11):
    for j in range(5):
        t = 9*(j+2 + 7*(i+1))
        table[i][j] = t%11

c = [0]
for row in table:
    c.append(c[-1] + row.count(K))

d,m = divmod(N-2, 11)
ans = c[m] + c[-1]*d
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	long long int a,b;
	cin >> a >> b;
	if(a*b < 0){
		cout << "Zero" <<endl;
	}else if(a == b){
		if(a > 0) cout << "Positive" <<endl;
		else if(a == 0) cout << "Zero" << endl;
		else cout << "Negative" << endl;
	}else if(a > 0){
		cout << "Positive" << endl;
	}else if((b-a)%2 == 1){
		cout << "Positive" << endl;
	}else{
		cout << "Negative" <<endl;
	}
	return 0;
}


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

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int h, w, counter = 0;
	cin >> h >> w;
	vector<string> a(h);
	rep(i, 0, h - 1)
	{
		cin >> a[i];
	}
	queue<pair<int, int>> q;
	int d[] = { 1,0,-1,0 };
	vector<string> checker(h);
	rep(i, 0, h - 1)
	{
		string s = "";
		rep(j, 0, w - 1)
		{
			s += "#";
		}
		checker[i] = s;
	}
	rep(i, 0, h - 1)rep(j, 0, w - 1)
	{
		if (a[i][j] == '#')q.push({ i,j });
	}
	while (!q.empty())
	{
		if (a == checker)
		{
			break;
		}
		vector<pair<int, int>> vec;
		while (!q.empty())
		{
			int y = q.front().first;
			int x = q.front().second;
			vec.push_back({ y,x });
			q.pop();
		}
		rep(i, 0, vec.size() - 1)
		{
			rep(j, 0, 3)
			{
				int ny = vec[i].first + d[j];
				int nx = vec[i].second + d[j ^ 1];
				if (0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.')
				{
					a[ny][nx] = '#';
					q.push({ ny,nx });
				}
			}
		}
		++counter;
	}
	cout << counter << endl;
}

Measured memory_bytes: 17644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k;string s;cin>>k>>s;
  if(s.length()<=k) print(s);
  else {
    string ans=s.substr(0,k);
    rep(i,3) ans+='.';
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 3652
N,C,K=map(int,input().split())
T=sorted([int(input()) for _ in range(N)]) + [10000000]

ans=0
c=0
t=0

for i in range(N):
    if c==0:
        ans+=1
        t=T[i]

    c+=1

    if c==C or T[i+1]>t+K:
        c=0

print(ans)




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

int main()
{
  int n;
  cin >> n;
  
  map<int,int> p;
  long long ans=0;
  long long wa,sa,data;
  for(int i=0;i<n;i++){
    cin>>data;
    sa = i - data;
    ans += p[sa];
    wa = i + data;
    p[wa]++;
  }

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

Measured memory_bytes: 20556
n,d = map(int, input().split())
x = [[int(i) for i in input().split()] for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        dd = 0
        for m in range(d):
            dd += (x[i][m] - x[j][m]) ** 2
        dd = dd**0.5
        if dd.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3064
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long [] a = new long[n * 3];
        for (int i = 0; i < 3 * n; ++i) {
            a[i] = scanner.nextLong();
        }
        final PriorityQueue<Long> firstHalf = new PriorityQueue<>();
        final PriorityQueue<Long> secondHalf = new PriorityQueue<>(Comparator.reverseOrder());
        long [] leftSum = new long[n + 1];
        long [] rightSum = new long[n + 1];
        for (int i = 0; i < n; ++i) {
            firstHalf.add(a[i]);
            leftSum[0] += a[i];
        }
        for (int i = n; i < 2 * n; ++i) {
            firstHalf.add(a[i]);
            long head = firstHalf.poll();
            leftSum[i - n + 1] = leftSum[i - n] + a[i] - head;
        }
        for (int i = 3 * n - 1; i >= 2 * n; --i) {
            secondHalf.add(a[i]);
            rightSum[n] += a[i];
        }
        for (int i = 2 * n - 1; i >= n; --i) {
            secondHalf.add(a[i]);
            long head = secondHalf.poll();
            rightSum[i - n] = rightSum[i - n + 1] + a[i] - head;
        }
        long result = Long.MIN_VALUE;
        for (int i = 0; i <= n; ++i) {
            result = Math.max(result, leftSum[i] - rightSum[i]);
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 98444
using System;

namespace ALDS1_5_D
{
    public static class Algorithm
    {
        public static long Count;

        public static void MergeSort<T>(this T[] a) where T : IComparable<T>
        {
            Count = 0;
            MergeSort(a, 0, a.Length);
        }

        private static void Merge<T>(this T[] a, int l, int m, int r) where T : IComparable<T>
        {
            int n1 = m - l, n2 = r - m;
            T[] a1 = new T[n1], a2 = new T[n2];
            for (int i = 0; i < n1; i++) a1[i] = a[l + i];
            for (int i = 0; i < n2; i++) a2[i] = a[m + i];
            int i1 = 0, i2 = 0, k = l;
            while (i1 < n1 && i2 < n2)
            {
                if (a1[i1].CompareTo(a2[i2]) <= 0) a[k++] = a1[i1++];
                else
                {
                    a[k++] = a2[i2++];
                    Count+=n1-i1;
                }
            }
            while (i1 < n1) a[k++] = a1[i1++];
            while (i2 < n2) a[k++] = a2[i2++];
        }
        private static void MergeSort<T>(this T[] a, int s, int t) where T : IComparable<T>
        {
            if (s + 1 < t)
            {
                var mid = (s + t) >> 1;
                MergeSort(a, s, mid);
                MergeSort(a, mid, t);
                Merge(a, s, mid, t);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            a.MergeSort();
            Console.WriteLine(Algorithm.Count);
        }
    }
}

Measured memory_bytes: 36148
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static int[] memo;

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
        }
        memo = new int[n];
        Arrays.fill(memo, -1);
        System.out.println(frog(h, n-1));
//        if(n==0){
//            System.out.println(0);
//            return;
//        }
//        int pp = 0;
//        int p = Math.abs(h[0]-h[1]);
//        for(int i = 2; i < n; i++){
//            int aux = Math.min(pp+Math.abs(h[i]-h[i-2]), p+Math.abs(h[i]-h[i-1]));
//            pp = p;
//            p = aux;
//        }
//        System.out.println(p);

    }

    public static int frog(int[] h, int n){
        if(n==0) return 0;
        if(n==1) return (int)Math.abs(h[1]-h[0]);
        if(memo[n]!=-1) return memo[n];
        memo[n] = Math.min( frog(h,n-1) + Math.abs(h[n-1]-h[n]), frog(h,n-2) + Math.abs(h[n-2]-h[n] ));
        return memo[n];
    }
}


Measured memory_bytes: 63032
def EatCandy(a, b, x):
    if a + b <= x:
        pass
    else:
        if a <= x:
            b = x - a
        else:
            b = 0
            a = x
    return (a, b)

def solve():
    N, x = [int(_) for _ in input().split()]
    A = [int(_) for _ in input().split()]
    st = sum(A)
    for i in range(N - 1):
        A[i], A[i + 1] = EatCandy(A[i], A[i + 1], x)
    return st - sum(A)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 63984
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int f[120][120];
int p[55][55];
int tmp[55][55];
int n,m;
int adj;
P ans;
void rotate()
{
    memset(tmp,-1,sizeof(tmp));
    for(int j=0;j<m;j++)
    {
        for(int i=m-1;i>=0;i--)
        {
            tmp[j][m-1-i]=p[i][j];
        }
    }
    memcpy(p,tmp,sizeof(tmp));
    for(int i=0;i<m;i++)
    {
        if(p[0][i]!=-1)
        {
            adj=i;
            return;
        }
    }
}
bool check(int x,int y)
{
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(p[i][j]==-1)continue;
            if(x+i<0||x+i>=n||y+j<0||y+j>=n)return false;
            if(f[x+i][y+j]!=p[i][j])return false;
        }
    }
    return true;
}
void solve()
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(check(i,j))
            {
                ans=min(ans,mp(i,j+adj));
                return;
            }
        }
    }
    return;
}
int main()
{
    while(1)
    {
        ans=mp(INF,INF);
        memset(f,-1,sizeof(f));
        scanf("%d %d",&n,&m);
        if(n==0&&m==0)break;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                scanf("%d",&f[i][j]);
            }
        }
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<m;j++)
            {
                scanf("%d",&p[i][j]);
            }
        }
        for(int i=0;i<4;i++)
        {
            rotate();
            solve();
        }
        if(ans.fi==INF)puts("NA");
        else printf("%d %d\n",ans.sec+1,ans.fi+1);
    }
    return 0;
}

Measured memory_bytes: 1296
// 2014/07/14 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a,b,x,y,ans=0;
  cin>>n>>a>>b;
  cin>>y;
  fr(i,n-1){
    x=y;cin>>y;
    ans+=min((y-x)*a,b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;
int a,b,c,k;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(a>=b&&a>=c){
		for(int i=1;i<=k;i++) a=a*2;
	}
	else if(b>=a&&b>=c){
		for(int i=1;i<=k;i++) b=b*2;
	}
	else if(c>=a&&c>=b){
		for(int i=1;i<=k;i++) c=c*2;
	}
	printf("%d\n",a+b+c);
}

Measured memory_bytes: 256
# すぬけくんはレストランに通うのが好きです。
# すぬけくん行きつけのレストランは何を食べても 1食800円で、
# 15食食べる毎にその場で200円もらえます。
# すぬけくんは今までで合計 N食食べました。
# 今までに払った金額を x円、レストランからもらった金額を y円として、
# x − y を求めなさい。

# 標準入力から食事回数（N）を取得する
input_num = int(input())

# x - y （円）を計算し出力する。
x = input_num * 800 # x：今までに払った金額
y = int(input_num / 15) * 200  # y：レストランからもらった金額
result = x - y  # 差額

print(result)


Measured memory_bytes: 8956
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [n,k] <- r'
    forM_ [1..k] (\i -> do
        print $ (binom (fromIntegral $ n-k+1) (fromIntegral i) * binom (fromIntegral $ k-1) (fromIntegral $ i-1)) `mod` divis
        --print $ ((n,k,i), n-k+1, (k-1, i-1))
        )


binom :: Integer -> Integer -> Integer
binom n 0 = 1
binom 0 k = 0
binom n k = ((binom (n-1) (k-1)) * n `div` k)

divis = 10^9 + 7


Measured memory_bytes: 2428
/* Note:Your choice is C IDE */
#include<stdio.h>
int main()
{
	int i,j,a[10],t,k;
	for(i=0;i<=9;i++)
	scanf("%d",&a[i]);
    for(i=0;i<3;i++)
    {
    	j=i;
    	for(k=i+1;k<10;k++)
    	if(a[k]>a[j])
    	j=k;
    	if(i!=j)
    	{t=a[i];a[i]=a[j];a[j]=t;}
    }
    for(i=0;i<3;i++)
    printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 0
macro_rules! input {
    // ?
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };

    // stdinの生成 値の読み込み開始
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    // ?
    ($next:expr) => {};
    // ?
    ($next:expr, ) => {};

    // 変数名:型の読み込みの繰り返し
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    // 値を読み込むベース 型,の繰り返し
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    // 配列の読み込み
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    // 文字列Vec<char>の読み込み
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    // usize1?の読み込み
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // 指定した型で読み込み
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: u64,
    };

    println!("{}", solve(n));
}

fn solve(n: u64) -> u64{
    if n % 2 == 1 {
        return n * 2;
    } else {
        return n;
    }
}

macro_rules! tests {
    ($($name:ident:[$( $args:expr ),*] => $output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output,super::solve($($args),*));
                }
            )*
        }
    }
}


tests! {
    //テスト名:[引数]=>expected
    test1:[10]=>10,
    test2:[3]=>6,
    test3:[999999999]=>1999999998,
}


Measured memory_bytes: 4352