akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    rep(i,q){
        int x;
        cin >> x;
        int a = 0, b = 0;
        int mada = 0;
        ll ans = 0, al = 0;
        rep(j,x){
            if(s[j] == 'D'){
                mada++;
            }else if(s[j] == 'M'){
                b++;
                al += (a += mada);
                mada = 0;
            }else if(s[j] == 'C'){
                ans += al;
            }
        }
        srep(j,x,n){
            if(s[j-x] == 'D'){
                a--, al -= b;
            }else if(s[j-x] == 'M'){
                b--;
            }
            if(s[j] == 'D'){
                mada++;
            }else if(s[j] == 'M'){
                b++;
                al += (a += mada);
                mada = 0;
            }else if(s[j] == 'C'){
                ans += al;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 1948
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x,y;

	while(1){
		cin>>x>>y;
		if(x==0&&y==0)break;
		if(x>y)swap(x,y);
		cout<<x<<" "<<y<<endl;
		}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  map<string, int> blue;
  string keylist[n];
  int keyindex = 0;
  
  for (int i=0; i<n; i++){
    string s;
    cin >> s;
    if (blue.find(s) == blue.end()){
      blue.insert(make_pair(s,1));
      keylist[keyindex] = s;
      keyindex++;
    }
    else{
      blue[s]++;
    }
  }
  
  int m;
  cin >> m;
  
  map<string, int> red;
  for (int i=0; i<m; i++){
    string s;
    cin >> s;
    
    if (red.find(s) == red.end()){
      red.insert(make_pair(s,1));
    }
    else{
      red[s]++;
    }
  }
  
  int max = 0;
  for (int i=0; i<blue.size(); i++){
    int score = blue[keylist[i]];
    if(red.find(keylist[i]) != red.end()){
      score -= red[keylist[i]];
    }
    if (max < score){
      max = score;
    }
  }
  
  cout << max << endl;
}


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

int a[50];
int b[50];
int c[50];
int p[50][500][500];

void solve(){

    int n,ma,mb;
    cin >> n >> ma >> mb;
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }

    rep(i,500){
        rep(j,500){
            rep(k,n+1){
                p[k][i][j]=INF;
            }
        }
    }
    p[0][0][0]=0;
    
    for(int i=1; i<n+1; i++){
        rep(x,450){
            rep(y,450){
                if(x>=a[i-1]&&y>=b[i-1]) p[i][x][y]=min(min(p[i-1][x][y], p[i][x][y]), p[i-1][x-a[i-1]][y-b[i-1]]+c[i-1]);
                else p[i][x][y]=p[i-1][x][y];
            }
        }
    }

    /*
    rep(i,30){
        rep(j,30){
                if(p[n][i][j]!=INF) cout << p[n][i][j] << " ";
                else cout << "?? ";
        }
        cout << endl;
    }
    */
    
    

    int tmp = INF;
    for(int i=1; i<=39; i++){
        if(p[n][i*ma][i*mb]!=INF) {
            tmp = min(tmp,p[n][i*ma][i*mb]);
        }
    }
    if (tmp!=INF) cout << tmp << endl;
    else cout << -1 << endl;

}

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


Measured memory_bytes: 41216
n = int(input())
B = list(map(lambda x: x-1, map(int, input().split())))
ans = []
for i in range(n):
    for j in range(len(B)-1,-1,-1):
        if B[j]==j:
            ans.append(j+1)
            del B[j]
            break
        elif j==0:
            ans = -1
            break
    if ans==-1:
        break

if ans == -1:
    print(ans)
else:
    for _ans in ans[::-1]:
        print(_ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
string a;
int main(){
	cin>>a;
	if(a.size()%2){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<a.size();i++){
		if(i%2){
			if(a[i]!='i'){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(a[i]!='h'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int n;
    string s;
    in2(n, s);
    ll ans = 0;
    rep(i, 10)
    {
        rep(j, 10)
        {
            rep(k, 10)
            {
                int flag = 0;
                rep(l, n)
                {
                    if (s[l] - '0' == i && flag == 0)
                    {
                        flag++;
                        continue;
                    }
                    if (s[l] - '0' == j && flag == 1)
                    {
                        flag++;
                        continue;
                    }
                    if (s[l] - '0' == k && flag == 2)
                    {
                        flag++;
                        continue;
                    }
                }
                if (flag == 3)
                {
                    ans++;
                }
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 384
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    n, m = read_int_array()
    l, r = 1, n
    for i in range(m):
        l1, r1 = read_int_array()
        l = max(l, l1)
        r = min(r, r1)
    write(max(r+1-l, 0))


main()


Measured memory_bytes: 42860
#include<bits/stdc++.h>
using namespace std;
long long n,z,a[100005],c;
struct haha
{
	long long s,gs;
}f[100005];
void quchong()
{
	f[1].s=a[1];f[1].gs=1;c=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i]!=a[i-1])
		f[++c].s=a[i],f[c].gs=1;
		else f[c].gs++;
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	quchong();
	for(int i=1;i<=c;i++)
	if(f[i].gs%2==1)z++;
	cout<<z<<endl;
	return 0;
}

Measured memory_bytes: 2560
import sys
n = int(input())

def _input():
    s = input()
    if s == 'Vacant':
        sys.exit(0)
    return s

# 偶数奇数一致判定
def check(x, y):
    # 性別一致の場合
    if x[1] == y[1]:
        if x[0] % 2 == y[0] % 2:
            return True
        else:
            return False
    else:
        if x[0] % 2 == y[0] % 2:
            return False
        else:
            return True

print(0, flush=True)
s = _input()
left = (0, s)

print(n-1, flush=True)
s = _input()
right = (n-1, s)

print(n//2, flush=True)
s = _input()
center = (n//2, s)

while(True):
    if check(left, center):
        left = center
        new_i = (center[0] + right[0]) // 2
        print(new_i, flush=True)
        center = (new_i, _input())
    else:
        right = center
        new_i = (left[0] + center[0]) // 2
        print(new_i, flush=True)
        center = (new_i, _input())

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

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

    int s = 0;

    for (int i = 1; i <= n; ++i) {
        int a;
        cin >> a;
        if (i % 2 == 0) continue;
        if (a % 2 == 0) continue;
        ++s;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3164
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int a[maxn];
vector<pair<int,int> > num;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		num.push_back({t,i});
	}
	sort(num.begin(),num.end());
	for(int i=0;i<n;i++)
		cout<<num[i].second<<" ";
}



Measured memory_bytes: 1780
import copy
N = int(input())
bscs = [(int(c[-1]), c) for c in input().split(" ")]
sscs = copy.copy(bscs)
for i in range(N):
    j = N - 1
    while j > i:
        if bscs[j][0] < bscs[j - 1][0]:
            tmp = bscs[j]
            bscs[j] = bscs[j - 1]
            bscs[j - 1] = tmp
        j -= 1
print(" ".join([c[1] for c in bscs]))
print("Stable")
for i in range(N):
    minj = i
    for j in range(i, N):
        if sscs[j][0] < sscs[minj][0]:
            minj = j
    tmp = sscs[i]
    sscs[i] = sscs[minj]
    sscs[minj] = tmp
print(" ".join([c[1] for c in sscs]))
print("Stable" if bscs == sscs else "Not stable")

Measured memory_bytes: 8180
#include<stdio.h>
int main(void)
{
	int i,x,w,n,flg;
	while(1)	{
	flg=0;
		scanf("%d",&n);
		if(n==0)	break;
		w=n;
		for(i=0;i<n;i++){
			scanf("%d",&x);
			if(x==0){
			w=w-1;
			}
			if(x>=2){
			flg=1;
			}
		}
		if(flg==1){
		printf("%d\n",w+1);
		}
		else{
			printf("NA\n");
			}
		}	
	return 0;
}

Measured memory_bytes: 1040
H, W = list(map(int, input().split()))
### 片方だけ奇数のマスには行くことができない
### Hが偶数、Wが偶数の場合 → H*W // 2
### Hが奇数、Wが偶数の場合 → H*W // 2 (Wが奇数の場合も同様)
### Hが奇数、Wが奇数の場合 → H*W // 2 + 1
if H == 1 or W == 1:
    print(1)
elif H % 2 != 0 and W % 2 != 0:
    print(int(H * W // 2) + 1)
else:
    print(int(H * W // 2))

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

using namespace std;

int main() {
	int a, b, c;
	cin>>a>>b>>c;
	if(a == b && a != c) cout<<"Yes"<<endl;
	else if(a == c && a != b) cout<<"Yes"<<endl;
	else if(b == c && a != b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    S = sum(A)
    cnt = defaultdict(int)
    for a in A:
        cnt[a] += 1
    for _ in range(int(input())):
        b, c = map(int, input().split())
        nb = cnt[b]
        cnt[c] += nb
        cnt[b] = 0
        S += (c - b) * nb
        print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95040
#include<iostream>
#include<cmath>
#include<vector>
// https://atcoder.jp/contests/abc125/tasks/abc125_b
// ref editrial https://img.atcoder.jp/abc125/editorial.pdf

using namespace std;
int solver(int allStone,vector<int> valueStone,vector<int> costStone){
    int result=0;
    for(int i = 0;i < allStone;i++){
        int tradeOff = 0;
        tradeOff = valueStone[i]-costStone[i];
        if(tradeOff > 0)
            {
                result = result + tradeOff;
            }
    }
    return result;
}

int main(void){
    int N;
    int result;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    
    result = solver(N,V,C);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int n,t,a;
string s;
void input(){
    cin>>s;
}
void src(){
    vector<int> v;
    rep(i,s.length()-2){
        v.push_back(abs(stoi(s.substr(i,3))-753));
    }
    cout<<*min_element(v.begin(),v.end());
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   ll a,b;
   cin >> a >> b;

   if((a+b)%2==0) cout << ((a+b)/2) << endl;
   else cout << "IMPOSSIBLE" << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void north(int *d){
	int n;
	n = d[4];
	d[4] = d[0];
	d[0] = d[1];
	d[1] = d[5];
	d[5] = n;
}
void south(int *d){
	int n;
	n = d[4];
	d[4] = d[5];
	d[5] = d[1];
	d[1] = d[0];
	d[0] = n;
}
void east(int *d){
	int n;
	n = d[3];
	d[3] = d[5];
	d[5] = d[2];
	d[2] = d[0];
	d[0] = n;
}
void west(int *d){
	int n;
	n = d[3];
	d[3] = d[0];
	d[0] = d[2];
	d[2] = d[5];
	d[5] = n;
}

int main(void) {
	int d[6];
	char o;

	scanf("%d %d %d %d %d %d",&d[0],&d[1],&d[2],&d[3],&d[4],&d[5]);

	while(scanf("%c",&o)!=EOF){
		switch(o){
			case 'N':north(d);break;
			case 'S':south(d);break;
			case 'E':east(d);break;
			case 'W':west(d);break;
		}
	}
	printf("%d\n",d[0]);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long

int main()
{
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    int count_takahasi = C / B;
    if(C % B != 0) {
        count_takahasi++;
    }

    int count_aoki = A / D;
    if(A % D != 0) {
        count_aoki++;
    }

    if(count_takahasi <= count_aoki) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3608
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *NOIP 2019 RP++                                           *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//

signed main(){
	#ifdef _WIN32
		// freopen("0.in","r",stdin);
		// freopen("0.out","w",stdout);
		long double be=clock();
	#endif
	int a=read(),b=read(),c=read();
	writeln(Max(0,c-(a-b)));
	#ifdef _WIN32
		long double en=clock();
		printf("Time: %.0Lfms\n",en-be);
		fclose(stdin);fclose(stdout);
	#endif
	return 0;
}

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

int main()
{
    int m, f, r;
    while (true)
    {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
        {
            break;
        }

        int sum_ = m + f;
        if (m == -1 || f == -1)
        {
            cout << "F\n";
        }
        else if (sum_ >= 80)
        {
            cout << "A\n";
        }
        else if (sum_ >= 65)
        {
            cout << "B\n";
        }
        else if (sum_ >= 50 || r >= 50)
        {
            cout << "C\n";
        }
        else if (sum_ >= 30)
        {
            cout << "D\n";
        }
        else
        {
            cout << "F\n";
        }
    }
}


Measured memory_bytes: 3072
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))

D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''



N, K = map(int, input().split())

A = list(map(int,input().split()))


ans = 0
for i in range(1, N):
    if A[i-1] + A[i] > K:

        if A[i-1] <=K:
            #i番目を減らせばよい
            target = K-A[i-1]
            ans += A[i]-target
            A[i] = target

        else:
            # i番目は０にする
            ans += (A[i]+A[i-1]) - K
            A[i] = 0


print(ans)





Measured memory_bytes: 16168
(defun mul (xs &optional (ans 1))
  (cond
    ((null xs) ans)
    ((= ans 0) 0)
    (t (mul (rest xs) (min (+ (expt 10 18) 1) (* ans (first xs)))))))

    
(defun solve (a)
  (if (> a (expt 10 18))
      -1
      a))

(let ((n (read))
      (a (sort (read-from-string
          (concatenate 'string
                       "(" (read-line) ")")) #'<=)))
     (princ (solve (mul a))))

Measured memory_bytes: 56800
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int maxn=1e5+10;
int n;
long long k,pre=0;
pair<int,int> p[maxn];
int main(){
	cin>>n>>k;
	for(int i=0,a,b;i<n;i++){
		cin>>a>>b;
		p[i].first=a;
		p[i].second=b;
	}
	sort(p,p+n);
	int ans;
	for(int i;i<n;i++){
		if(k>pre&&k<=p[i].second+pre){
			ans=p[i].first;
			break;
		}
		pre+=p[i].second;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
h_1 , m_1, h_2, m_2 , k = map(int, input().split())
# study_time = ((h_2*60 + m_2) - (h_1*60 + m_1))
study_time = ((h_2*60 + m_2) - (h_1*60 + m_1))
print(study_time - k)

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

using namespace std;


int main (void) 
{

  // Variable_Proclamation
  int    i;
  int    count;
  string s;

  // Input, Initialize
  cin >> s;
  count = 0;

  // Calculation
  for(i=0; i<3; i++)
  {
    if(s.at(i) == '1')
    {
      count++;
    }
  }
  
  // Output
  cout << count << endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int amount_number = sc.nextInt();
		int answer = 0;

		ArrayList<Integer> array_number = new ArrayList<>();
		for (int i =0; i < amount_number; i++) {
			int input_number = sc.nextInt();
			array_number.add(input_number);
		}

		for (int i =0; i < amount_number; i++) {
			answer = answer + array_number.get(i);
		}

		if (answer % 2 == 0) {
		System.out.println("YES");
		}
		else {
		System.out.println("NO");
		}
	}
}


Measured memory_bytes: 59320
#include<bits/stdc++.h>
#define MAX 200005
using namespace std;
 
int main(){
  int n;
  long long x, a[MAX], ans = 0, d;
  a[0] = 0;
  scanf("%d%lld", &n, &x);
  for(int i = 1; i <= n; i++){
    scanf("%lld", &a[i]);
    a[i] += a[i-1];
  }
  ans = a[n]*5 + (n*2-n/2)*x;
  for(int i = 1; i < n-n/2; i++){
    d = (a[n] - a[n-i])*5 + (i+n)*x;
    int j = n-i, k = 0;
    for(; j > i && d < ans; j -= i, k++)
      d += (a[j] - a[j-i])*(5+k*2);
    d += a[j]*(5+2*k);
    ans = min(ans, d);
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int h, r; cin >> h >> r;
	
	if(h + r == 0) cout << 0 << endl;
	else if(h + r > 0) cout << 1 << endl;
	else if(h + r < 0) cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 3104
/* ex 9_1
   KitamoriFumiya */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11
// スタックの定義
typedef struct stack{
	int size;
	int count;
	char data[SIZE];
	char *top;
} stack;

void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char elem);
char pop(stack *stk);

int main(void){
	stack stk;
	char input[11], *ptr_input; // キーボードでの入力を格納するための配列とポインタ
	initialize_stack(&stk); // スタックを初期化
	scanf("%s", input); // 文字列の入力
	ptr_input = input;
	while(*ptr_input){
		// 文字がBであり、その前の文字があればそれを消す
		if(*ptr_input == 'B'){
			if(stk.count>0){
				pop(&stk);
			}
		}
		// そうでなければデータを追加
		else{
			push(&stk, *ptr_input);
		}
		++ptr_input;
	}
	// 出力
	print_stack(&stk);
	return 0;
}

// スタックの初期化
void initialize_stack(stack *stk){
	stk->count = 0;
	stk->size = SIZE;
	stk->top = &(stk->data[SIZE]);
}

// データの追加
void push(stack *stk, char elem){
	if(stk->count >= stk->size){
		fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
		exit(1);
	}else{
		stk->top--;
		*(stk->top) = elem;
		stk->count++;
	}
}

// データの取り出し
char pop(stack *stk){
	char latest;
	if(stk->count <= 0){
		fprintf(stdout, "Error: stack underflow.\n");
		exit(1);
	}else{
		latest = *(stk->top);
		stk->top++;
		stk->count--;
		return latest;
	}
}

// スタックの中身を逆順に取り出す
void print_stack(stack *stk){
	char output[11], *ptr_output;
	int i;
	ptr_output = stk->top;
	for(i = stk->count; i > 0; i--){
		output[i-1] = *ptr_output;
		ptr_output++;
	}
	printf("%s\n", output);
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define VEC(kata, num) (kata*)malloc(num * sizeof(kata))
#define DB puts("ok")
#define SENTINEL 1000000007
typedef long long lli;

int main()
{
    int H, W, h, w;
    scanf("%d%d%d%d",&H,&W,&h,&w);
    printf("%d",H*W - h*W - H*w + h*w);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;
const ll INF = 1e16;

void solve(){
	ll n,m;
	cin >> n >> m;
  	if(n == 1 || m == 1) {cout << 1 << endl;return ;}
	n *= m;
	cout<<((n+1)>>1LL)<<endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll t=1;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 100005;

// int a[101];
vector<int> a;
int n;
bool lbc[N][2];
bool vis[N][2];

bool go(int ch, int l) {
	if(!ch and l < 0)
		return true;
	if(ch and l < 0)
		return false;

	if(vis[l][ch]) return lbc[l][ch];
	vis[l][ch] = 1;

	if(ch) lbc[l][ch] = true; 

	rep(i,n) {
		// lbc[l][ch] = lbc[l][ch] || go(!ch, l - a[i]);
		if(ch) lbc[l][ch] = lbc[l][ch] and go(!ch, l - a[i]);
		else {
			lbc[l][ch] = lbc[l][ch] or go(!ch, l - a[i]);
		}
	}
	return lbc[l][ch];
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    // cout.precision(12);cout << fixed;
    int k;cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    if(go(0,k)) cout << "First\n";
    else cout << "Second\n";
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll N, M, Q;
    cin >> N >> M >> Q;
    vll l(M), r(M);
    rep(i, M){
        cin >> l[i] >> r[i];
    }
    vll p(Q), q(Q);
    rep(i, Q){
        cin >> p[i] >> q[i];
    }
    
    // 始点x, 終点y
    vvll cnt(N+1, vll(N+1, 0));
    rep(i, M){
        cnt[l[i]][r[i]]++;
    }
    rep(i, N+1) dump(cnt[i]);
    for(ll i = N-1; i >= 1; i--){
        rep(j, N+1){
            cnt[i][j] += cnt[i+1][j];
        }
    }
    rep(i, Q){
        ll ans = 0;
        rep(j, q[i]+1){
            ans += cnt[p[i]][j];
        }
        cout << ans << endl;
    }
    rep(i, N+1) dump(cnt[i]);
    return 0;
}

Measured memory_bytes: 7680
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	ll MAX=3500;
	ll ans[3];
	int flag=0;
	scan(N);
	for(ll b=max(1LL,N/4);b<=MAX;b++){
		for(ll c=max(1LL,N/4);c<=MAX;c++){
			ll a;
			if(4*b*c-N*(b+c)<=0) continue;
			else if(N*b*c%(4*b*c-N*(b+c))==0){
				a=N*b*c/(4*b*c-N*(b+c));
				ans[0]=a,ans[1]=b,ans[2]=c;
				flag=1;
				break;
			}
		}
		if(flag) break;
	}
	printf("%lld %lld %lld\n",ans[0],ans[1],ans[2]);
	return 0;
}


Measured memory_bytes: 256
def main():
    L, R, d = map(int, input().split())
    ans = (R // d) - (L - 1) // d
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9084
n = gets.to_i
a = gets.split.map(&:to_i)
ans = [0] * n
a.each_with_index do |x, i|
  if i.even?
    ans[0] += x
  else
    ans[0] -= x
  end
end
1.upto(n - 1) do |i|
  ans[i] = 2 * a[i - 1] - ans[i - 1]
end
puts ans * ' '

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

typedef pair<int, int> pii;
#define X first
#define Y second
const int N = 505;

int n, m, a[N][N];
char c;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		a[i][0] = 1, a[i][m - 1] = 2;
	for (int i = 0; i < n; i++)
		for (int j = 1; j < m - 1; j++)
			a[i][j] = (i & 1) + 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			cin >> c;
			if(c == '#')
				a[i][j] = 3;
		}
	for (int i = 0; i < n; i++, cout << '\n')
		for (int j = 0; j < m; j++)
			cout << (a[i][j] & 1? '#': '.');
	cout << '\n';
	for (int i = 0; i < n; i++, cout << '\n')
		for (int j = 0; j < m; j++)
			cout << (a[i][j] & 2? '#': '.');
	return 0;
}

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

#define fi first
#define se second
#define endl '\n'
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<class T> inline void gmax(T &A,T B)
{
    (A<B)&&(A=B);
}
template<class T> inline void gmin(T &A,T B)
{
    (A>B)&&(A=B);
}

template<class T> inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

int dp[111111],a[111];

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=1; i<=k; i++)
    {
        for(int j=0; j<n; j++)
        if(i>=a[j]&&!dp[i-a[j]]) dp[i]=1;
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct {
    int parent;
    int leftChild;
    int rightChild;
} Node;

typedef struct {
    Node *node;
    int num;
} Tree;

#define NL -1

bool initializeTree(Tree *tree, int num) {
    if((tree->node = malloc(num * sizeof(Node))) == NULL) {
        return false;
    }

    for(int i = 0; i < num; i++) {
        Node *ptr = &tree->node[i];
        ptr->parent = ptr->leftChild = ptr->rightChild = NL;
    }

    tree->num = num;
    return true;
}

void setParent(Tree *tree, int idx, int parent) {
    tree->node[idx].parent = parent;
}

void setLeftChild(Tree *tree, int idx, int leftChild) {
    tree->node[idx].leftChild = leftChild;
}

void setRightChild(Tree *tree, int idx, int rightChild) {
    tree->node[idx].rightChild = rightChild;
}

int getParent(Tree *tree, int idx) {
    return tree->node[idx].parent;
}

int getLeftChild(Tree *tree, int idx) {
    return tree->node[idx].leftChild;
}

int getRightChild(Tree *tree, int idx) {
    return tree->node[idx].rightChild;
}

int getRoot(Tree *tree) {
    for(int i = 0; i < tree->num; i++) {
        if(tree->node[i].parent == NL) {
            return i;
        }
    }

    return NL;
}

void terminateTree(Tree *tree) {
    free(tree->node);
    tree->node = NULL;
    tree->num = 0;
}

void printPreorder(Tree *tree, int idx) {
    if(idx != NL) {
        printf(" %d", idx);
        printPreorder(tree, getLeftChild(tree, idx));
        printPreorder(tree, getRightChild(tree, idx));
    }
}

void printInorder(Tree *tree, int idx) {
    if(idx != NL) {
        printInorder(tree, getLeftChild(tree, idx));
        printf(" %d", idx);
        printInorder(tree, getRightChild(tree, idx));
    }
}

void printPostorder(Tree *tree, int idx) {
    if(idx != NL) {
        printPostorder(tree, getLeftChild(tree, idx));
        printPostorder(tree, getRightChild(tree, idx));
        printf(" %d", idx);
    }
}

int main(void) {
    Tree tree;
    int n;

    scanf("%d", &n);

    initializeTree(&tree, n);

    for(int i = 0; i < n; i++) {
        int parent, left, right;
        scanf("%d %d %d", &parent, &left, &right);

        setLeftChild(&tree, parent, left);
        setRightChild(&tree, parent, right);
        if(left != NL) {
            setParent(&tree, left, parent);
        } if(right != NL) {
            setParent(&tree, right, parent);
        }
    }
    int root = getRoot(&tree);

    puts("Preorder");
    printPreorder(&tree, root);
    printf("\n");
    
    puts("Inorder");
    printInorder(&tree, root);
    printf("\n");
    
    puts("Postorder");
    printPostorder(&tree, root);
    printf("\n");

    terminateTree(&tree);
    return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> in(n+3,0);
    for(int i = 2; i <= n; i++) {
        int x; cin>> x;
        in[x]++;
    }
    for(int i = 1; i<=n;i++) cout << in[i]<<endl;



    return 0;
}



Measured memory_bytes: 3984
#include <iostream>
using namespace std;
int main(){
   string s;cin>>s;int k;cin>>k;
   int i=0;
   for(;i<s.length();i++){
    if(s[i]!='1') break;
}
if(k<=i) cout<<1<<endl;
else cout<<s[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    REP(i,N) cin >> t[i];
    ll ans = 0;
    int cur = 0;
    for(int i=1;i<N;i++){
        if(i == N-1){
            ans += T;
        }
        if(t[i] > cur + T){
            ans += T;
        }
        else{
            ans += t[i] - t[i-1];
        }
        cur = t[i];
    }
    if(N == 1) cout << T << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){
    int x,n,a,f=0;
    cin>>x>>n;
    int v[1000]={0},u[1000]={0};
    rep(i,0,n){
        cin>>a;
        if(a<x) v[x-a]++;
        else if(a>x) u[a-x]++;
        else f=1;
    }
    if(f==0) return cout<<x,0;
    rep(i,1,1000){
        if(v[i]==0) return cout<<x-i,0;
        if(u[i]==0) return cout<<x+i,0; 
    }
    return 0;
}
 
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
#pragma warning( disable:4996 )
#define repeat(i,n) for(int i=0; i<n; i++)
using namespace std;
int floppy[30];
int rotation[4][5][2] = {
		{ { 1, 28 }, { 2, 29 }, { 3, 30 }, { 15, 16 }, { 19, 21 } },
		{ { 7, 22 }, { 8, 23 }, { 9, 24 }, { 13, 18 }, { 10, 12 } },
		{ { 1, 24 }, { 4, 27 }, { 7, 30 }, { 10, 21 }, { 16, 18 } },
		{ { 3, 22 }, { 6, 25 }, { 9, 28 }, { 12, 19 }, { 13, 15 } }
};
int fin[30] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 6, 6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3 };

typedef struct{
	int puz[30];
	int ans;
	int lastnum;
}aiii;

void rotate(aiii *newpuz, int num){
	repeat(i, 5){
		swap(newpuz->puz[rotation[num][i][0]-1], newpuz->puz[rotation[num][i][1]-1]);
	}
	newpuz->ans++;
	newpuz->lastnum = num;
}

int solve(int* firstpuz){
	if (memcmp(fin, firstpuz, sizeof(int)*30) == 0){
		return 0;
	}
	queue<aiii> q;
	aiii temp;
	memcpy(temp.puz, firstpuz, sizeof(int)*30);
	temp.ans = 0;
	temp.lastnum = -1;
	q.push(temp);
	while (!q.empty()){
		aiii oldpuz = q.front();
		q.pop();
		if (memcmp(fin, oldpuz.puz, sizeof(int) * 30) == 0){
			return oldpuz.ans;
		}
		repeat(i, 4){
			if (i == oldpuz.lastnum){
				continue;
			}
			aiii newpuz = oldpuz;
			rotate(&newpuz, i);
			q.push(newpuz);
		}
	}

}

int main(void){
	int N;
	scanf("%d\n", &N);
	repeat(i, N){
		repeat(j, 30){
			scanf("%d", &(floppy[j]));
		}
		printf("%d\n", solve(floppy));
	}
	return 0;
}


Measured memory_bytes: 2380
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  scanf("%d %d %d %d", a1, a2, a3, a4);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int64_t *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%lld", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 1000
#define NUM2_MAX (NUM_MAX*NUM_MAX)
#define RANK_MAX 3000

int asc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 > aa2) return 1;
    if(aa1 == aa2) return 0;
    return -1;
}

int desc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 > aa2) return -1;
    if(aa1 == aa2) return 0;
    return 1;
}

#define VAL_MAX (int64_t)(1e+10)
#define SUM_MAX (VAL_MAX*3)

struct range {
    int start;
    int end;
};
int lower_bound(int64_t *arr, struct range r, int64_t key) {
    int low = r.start;;
    int high = r.end;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        if(arr[mid] < key) {
            low = mid;
        } else {
            high = mid;
        }
    }
    return low + 1;
}

int main(void) {
    int x, y, z, rank;
    get_int4(&x, &y, &z, &rank);
    static int64_t xrr[NUM_MAX];
    static int64_t yrr[NUM_MAX];
    static int64_t zrr[NUM_MAX];
    fget_array(xrr, x);
    fget_array(yrr, y);
    fget_array(zrr, z);
    int64_t min_sum = VAL_MAX+1;
    int64_t max_sum = 0;
    int i, j;
    for(i = 0; i < z; i++) min_sum = min(min_sum, zrr[i]);
    for(i = 0; i < z; i++) max_sum = max(max_sum, zrr[i]);

    static int64_t pair[NUM2_MAX];
    int idx = 0;
    for(i = 0; i < x; i++) {
        for(j = 0; j < y; j++) {
            pair[idx++] = xrr[i] + yrr[j];
        }
    }
    qsort(pair, idx, sizeof(int64_t), asc);
    min_sum += pair[0];
    max_sum += pair[idx-1];

    static int cache[NUM_MAX];
    static int cnt_map[NUM_MAX];
    static int64_t ans[RANK_MAX];
    int size = x*y*z;
    int64_t prev = min_sum;
    int r;
    for(r = rank; r >= 1; r--) {
        int64_t low = prev-1;
        int64_t high = max_sum+1;
        while(low + 1 < high) {
            int64_t mid = (low + high)/2;
            int cnt = 0;
            for(i = 0; i < z; i++) {
                int64_t pivot = zrr[i];
                struct range r = {cache[i]-1, idx};
                int tmp = lower_bound(pair, r, mid-pivot);
                cnt_map[i] = tmp;
                cnt += tmp;
            }
            if(cnt <= size-r) {
                memcpy(cache, cnt_map, sizeof(int)*z);
                low = mid;
            } else {
                high = mid;
            }
        }
        ans[r-1] = low;
        if(low == max_sum) break;
        prev = low;
    }
    for(i = 0; i < rank; i++) {
        printf("%lld\n", (ans[i]==0) ? max_sum : ans[i]);
    }

    return 0;
}

Measured memory_bytes: 15868
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  map<string,int> mp;
  int n;cin >> n;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  cout << "AC" << " x " << mp["AC"] << endl;
  cout << "WA" << " x " << mp["WA"] << endl;
  cout << "TLE" << " x " << mp["TLE"] << endl;
  cout << "RE" << " x " << mp["RE"] << endl;

  return 0;
}


Measured memory_bytes: 3632