akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

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

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

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

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

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

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
set<ll> A;
bool ok = true;

void input() {
  IN(N);
  REP(i, N) {
    IN(t);
    if (A.count(t) == 0) {
      A.insert(t);
    } else {
      ok = false;
    }
  }
}

void solve() {
  PRINT(ok?"YES":"NO");
}

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


Measured memory_bytes: 9600
#include<algorithm>
#include<cstdio>
#include<functional>

using namespace std;

int main() {
    int N;
    scanf("%d",&N);
    int a[N];
    for(int i = 0; i < N; i++) {
        scanf("%d",&a[i]);
    }

    sort(a,a+N,greater<>());

    int alice = 0, bob = 0;
    for(int i = 0; i < N; i++) {
        if(i%2 == 0) {
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    printf("%d\n",alice-bob);
}


Measured memory_bytes: 128
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

h,w = map(int,input().split()) 

d = [[float("inf")]*10 for i in range(10)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(10):
    l = list(map(int,input().split()))
    for j in range(10):
      d[i][j] = l[j]

a = [list(map(int,input().split())) for i in range(h)]
d1 = []
s = warshall_floyd(d)
for i in s:
  d1.append(i[1])
#print(d1)
su = 0
for i in a:
  for j in i:
    if j!=-1:
      su += d1[j]
print(su)

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


int main() {

    int r;
    cin >> r;

    double ans = 2 * M_PI * r;
    cout << std::fixed << std::setprecision(15) << ans << endl;



    return 0;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n, k;
    cin >> n >> k;
    if(n%k == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n==3){
        puts("2 5 63");
        return 0;
    }else if(n<=5002){
        int tw,th;
        if(n%2==0){
            tw = 2;
            th = n-2;
        }else{
            tw = 3;
            th = n-3;
        }
        REP(i,tw){
            cout << (i+1)*2 << " ";
        }
        REP(i,th){
            cout << i*6+3 << ((i==th-1)?("\n"):(" "));
        }
    }else{
        int tw,th;
        th = 5000;
        tw = n-5000;
        int md = tw%3;
        tw -= md;
        REP(i,tw){
            cout << (i+1)*2 << " ";
        }
        if(md==1){
            cout << 2*tw+6 << " ";
        }else if(md==2){
            cout << 2*tw+2 << " ";
            cout << 2*tw+4 << " ";
        }
        REP(i,th){
            cout << i*6+3 << ((i==th-1)?("\n"):(" "));
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int cost = 0;
	int xymin = MIN(x, y);

	// cピザの枚数
	if ( a + b > 2 * c )
	{
		// cピザを買ったほうが良い
		cost += xymin * 2 * c;
		x -= xymin;
		y -= xymin;
	}

	if ( a > 2 * c )
	{
		cost += x * 2 * c;
	}
	else
	{
		cost += x * a;
	}

	if ( b > 2 * c )
	{
		cost += y * 2 * c;
	}
	else
	{
		cost += y * b;
	}

	cout << cost << endl;


	return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, N = il()
    P = il()

    ret = 0
    s = MAX
    for n in range(-101, 102):
        if n not in P and abs(X-n) < s:
            s = abs(X-n)
            ret = n
    print(ret)


if __name__ == '__main__':
    main()


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long int> x(N), y(N), z(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }

  long long int ret = 0;
  for (int k = 0; k < 8; k++) {
    int a = 2 * (k & 1) - 1;
    int b = 2 * (k / 2 & 1) - 1;
    int c = 2 * (k / 4 & 1) - 1;
    vector<long long int> w(N);
    for (int i = 0; i < N; i++) {
      w[i] = x[i] * a + y[i] * b + z[i] * c;
    }
    sort(w.begin(), w.end(), greater<long long int>());
    long long int tmp = 0;
    for (int i = 0; i < M; i++) {
      tmp += w[i];
    }
    ret = max(ret, tmp);
  }
  cout << ret << endl;
}

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

typedef long long int lli;

lli MAX(lli a,lli b){
    return ((a > b) ? a : b);
}

lli MIN(lli a,lli b){
    return ((a > b) ? b : a);
}

int main(void){
    // Here your code !
    long long int n,x,ans = 0;
    cin >> n >> x;
    vector<int> a(n);
    for(int i= 0; i < n; i++) cin >> a[i];
    
    for(int i = 0; i < n - 1; i++){
        int tmp = MAX(a[i] + a[i+1] - x,0);
        ans += tmp;
        a[i + 1] -= MIN(a[i+1] , tmp);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int N = sc.nextInt();

		int[] list = new int[N];

		for (int index=0; index<N; index++) {
			int num = sc.nextInt();
			list[num-1]=index;
		}
		for (int index=0; index<N; index++) {
			System.out.print(list[index]+1);
			System.out.print(" ");
		}
		System.out.println();
	}
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

int main(void) {
  int k;
  cin >> k;
  vec row(8, -1);
  rep(i,k){
    int r, c;
    cin >> r >> c;
    row[r]=c;
  }
  vec v(8);
  rep(i,8){
    v[i] = i;
  }

  do {
    bool ok=true;
    rep(i,8){
      if(row[i] >0 && v[i]!=row[i]){
        ok=false;
      }
    }
    if(!ok) continue;

    rep(i,8){
      rep(j,8){
        if(i==j) continue;
        if(v[j]==v[i]-abs(i-j)) ok=false;
        if(v[j]==v[i]+abs(i-j)) ok=false;
        if(v[j]==v[i]) ok=false;
      }
    }

    if(ok){
      rep(i,8){
        rep(j,8){
          cout << (v[i]==j ? 'Q' : '.');
        }
        cout << "\n";
      }
      return 0;
    }
  } while(next_permutation(all(v)));
}



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

int main() {
	string s,t;
	cin >> s>>t;
	int ans = 0;
	if (s[0] == t[0])++ans;
	if (s[1] == t[1])++ans;
	if (s[2] == t[2])++ans;
	cout << ans << endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] += 32;
  cout << s;
}

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

typedef long long ll;
const int N = 100010;

int n;
char s[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	bool flag = 0;
	for(int i = 1; i <= n; i += 2) {
		if(s[i] == 'h' && s[i + 1] == 'i');
		else flag = 1;
	}
	if(flag) puts("No");
	else puts("Yes");
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	ll n;
 	cin>>n;
 	ll temp = n / 2;
 	if(n & 1){
 		temp++;
 	}
 	cout<<temp<<"\n";
}

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

int main () {
    long long x, ans=0, k;
    cin >> x;

    ans += (x/11)*2;
    k = x%11;

    if (0<k && k<=6) {
        ans += 1;
    }
    else if (6<k){
        ans += 2;
    }

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

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

using namespace std;

int main()
{
  
  int n,k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++){
      cin>>v[i];
  }
   sort(v.begin(),v.end());
   int sum=0;
   for(int i=0;i<k;i++){
       sum=sum+v[i];
   }
   cout<<sum<<endl;
  return 0; 
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

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

    int D; cin >> D;

    string s = "Christmas";
    for (int i = 0; i < 25 - D; ++i) {
        s += " Eve";
    }

    cout << s << std::endl;

    return 0;
}

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

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int lx = x2 - x1;
    int ly = y2 - y1;
    int x3 = x2 - ly;
    int y3 = y2 + lx;
    int x4 = x3 - lx;
    int y4 = y3 - ly;

    cout << x3 <<' '<< y3 << ' ' << x4 << ' ' << y4 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double dp[3500][3500];
 int main()
 {
     int n;
     cin>>n;
   double p[n];
    p[0]=0;
     for(int i=1;i<=n;i++)
     cin>>p[i];
    double sum=0;
    dp[0][0]=1;
     for(int i=1;i<=n;i++)
     {
         for(int j=0;j<=n;j++)
         {
         	if(j>0)
             dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
             else
             dp[i][j]=dp[i-1][j]*(1-p[i]);
         }
     }
     for(int i=(n+1)/2;i<=n;i++)
     {
         sum+=dp[n][i];
     }
     cout<<setprecision(10)<<sum<<endl;


     
 }

Measured memory_bytes: 84224
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n), b(n);
  long long sum_a = 0, sum_b = 0;
  REP(i, n) {
    cin >> a[i];
    sum_a += a[i];
  }
  REP(i, n) {
    cin >> b[i];
    sum_b += b[i];
  }
  if (sum_a < sum_b) {
    cout << -1 << '\n';
    return 0;
  }
  int ans = 0;
  long long amari = 0;
  vector<int> yoyuu;
  REP(i, n) {
    if (a[i] < b[i]) {
      ++ans;
      amari += b[i] - a[i];
    } else yoyuu.push_back(a[i]-b[i]);
  }
  sort(ALL(yoyuu), greater<int>());
  int idx = 0;
  while (amari > 0) {
    amari -= yoyuu[idx];
    ++idx;
    ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define longlong = ll;

int main()
{
    int a, x;
    cin >> x;

    if (x >= 400 && x < 600)
    {
        cout << "8" << endl;
    }
    else if (x >= 600 && x < 800)
    {
        cout << "7" << endl;
    }
    else if (x >= 800 && x < 1000)
    {
        cout << "6" << endl;
    }
    else if (x >= 1000 && x < 1200)
    {
        cout << "5" << endl;
    }
    else if (x >= 1200 && x < 1400)
    {
        cout << "4" << endl;
    }
    else if (x >= 1400 && x < 1600)
    {
        cout << "3" << endl;
    }
    else if (x >= 1600 && x < 1800)
    {
        cout << "2" << endl;
    }
    else if (x >= 1800 && x < 2000)
    {
        cout << "1" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    REP(i, n){
        cin >> a[i];
        ans += a[i];
    }
    ll q;
    cin >> q;
    vector<ll> b(q), c(q);
    REP(i, q){
        cin >> b[i] >> c[i];
    }

    map<ll, ll> mp;
    REP(i, n){
        mp[a[i]] ++;
    }

    REP(i, q){
        ll sum = mp[b[i]] * (c[i] - b[i]);
        mp[c[i]] += mp[b[i]];
        mp[b[i]] = 0;
        ans += sum;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 11348
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int main ()
{
	int n;
	scanf("%d",&n);
	if (n == 1) printf("1");
	if (n >= 2 && n < 4) printf("2");
	if (n >= 4 && n < 8) printf("4");
	if (n >= 8 && n < 16) printf("8");
	if (n >= 16 && n < 32) printf("16");
	if (n >= 32 && n < 64) printf("32");
	if (n >= 64 && n < 101) printf("64");

}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();

        var regex = new Regex("[ACGT]*", RegexOptions.Compiled);
        var matches = regex.Matches(s);
        var l = E.Range(0, matches.Count).Max(x => matches[x].Length);
        Console.WriteLine(l);
    }
}


Measured memory_bytes: 15960
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int N=s.size();
  int i,j;
  for(i=0;i<N;i++){
    if(s[i]=='A'){
      break;
    }
  }
  for(j=N-1;j>=0;j--){
    if(s[j]=='Z'){
      break;
    }
  }
  cout<<j-i+1<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;
const ll mod = 1e9 + 7;

ll mod_pow(ll m, ll n){
    ll ans = 1;
    ll times = m;
    while(n){
        if(n & 1){
            ans = ans * times % mod;
        }
        times = times * times % mod;
        n>>=1;
    }
    return ans;
}

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll m,n; cin>>m>>n;
    cout << mod_pow(m,n) << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  int n,a,b,c;
  string s;
  int p[100];
  cin >> n;
  FOR(i,n){
    cin >> p[i];
  }
  int ans=0;
  FOR(i,n-2){
    if(p[i+1]!=min(p[i],min(p[i+1],p[i+2])) && p[i+1]!=max(p[i],max(p[i+1],p[i+2]))){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

ll twice(ll n) {
  ll ans=0;
  while(n%2==0) {
    n/=2;
    ans++;
  }
  return ans;
}
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  ll d=abs(a-b);
  ll e=abs(a-c);
  ll f=abs(b-c);
  if(a==b&&b==c) {
    if(a%2==1) {
      cout<<"0"<<endl;
    }
    else {
      cout<<"-1"<<endl;
    }
  }
  else {
    cout<<min(min(twice(d),twice(e)),twice(f))<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K,ans;
  cin >> N >> K;
  int l[60];
  for(int i=0;i<N;i++) cin >> l[i];
  sort(l, l + N, greater<int>());
  for(int j=0;j<K;j++) {
    ans += l[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// Aizu Vol-1 0120: Patisserie
// 2017.8.21 bal4u@uu

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

char *gets(char *);
char buf[200], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	if (!*p) return -1;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

typedef struct { int r, n, f; } T;

int lim;
T r[15]; int n, N;
double d[15][15];
#define EQ(a,b) (fabs(a-b)<= 0.000001)

int combi(int m, int i, double w)
{
	int j;
	double x, l;

	if (m == N) {
		x = w + r[i].r;
		return (EQ(x, lim) || x <= lim);
	}
	for (j = 0; j < n; j++) {
		if (r[j].f == r[j].n) continue;
		l = d[r[i].r][r[j].r];
		if (w + l < lim) {
			r[j].f++;
			if (combi(m + 1, j, w + l)) return 1;
			r[j].f--;
		}
	}
	return 0;
}

int main()
{
	int i, j, t, s;
	int c[15];
	
	for (i = 3; i <= 10; i++) for (j = i; j <= 10; j++)
		d[i][j] = d[j][i] = 2.0 * sqrt(i * j);
	while (gets(p = buf) != NULL) {
		lim = getInt();
		memset(c, 0, sizeof(c));
		for (N = s = 0; (t = getInt()) > 0; N++) s += t, c[t]++;
		if (2 * s <= lim) { puts("OK"); continue; }
		for (n = i = 0; i <= 10; i++)
			if (c[i] > 0) r[n].r = i, r[n].n = c[i], r[n++].f = 0;
		if (!EQ(r[0].r, lim) && r[0].r >= lim) { puts("NA"); continue; }

		for (i = 0; i < n; i++) {
			r[i].f++;
			if (combi(1, i, r[i].r)) break;
			r[i].f--;
		}
		puts(i < n ? "OK" : "NA");
	}
	return 0;
}

Measured memory_bytes: 524
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();

    int count = 0;
    for (int i = 1; i <= N; i++) {
      if (String.valueOf(i).length() % 2 == 1) {
        count++;
      }
    }
    System.out.println(count);
  }
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    
    int ans = 1;
    int i;
    for(i = 1; i <= n; i++){
        if(ans <= k){
            ans *= 2;
        }else{
            ans += k;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    rep(i, S.size()) {
        if (i == A&&S[i] != '-') {
            cout << "No" << endl;
            return 0;
        }
        if (i != A&&S[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	char s[100010];
	cin >> s;
	int n = strlen(s);
	vint a(n);
	rep(i, n) {
		a[i] = s[i] - '0';
	}
	int l, r;
	int ans = 0;
	rep(i, n - 1) {
		if (a[i] == -1) {
			continue;
		}
		r = i + 1;
		l = i;
		if (a[l] + a[r] == 1) {
			while (0 <= l&&r < n) {
				if (a[l] + a[r] != 1) {
					break;
				}
				ans += 2;
				a[l] = -1;
				a[r] = -1;
				if (l == 0) {
					break;
				}
				while (0 < l) {
					l--;
					if (a[l] != -1) {
						break;
					}
				}
				if (a[l] == -1) {
					break;
				}
				r++;
			}
		}
		i = r - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
let N = Int(readLine()!)!
var ans = "Yes"
var preT = 0
var preX = 0
var preY = 0
for _ in 0..<N {
  let input = readLine()!.characters.split(" ").map{Int(String($0))!}
  let (t, x, y) = (input[0], input[1], input[2])
  let dist = abs(x - preX) + abs(y - preY)
  let time = t - preT
  let overTime = time - dist
  if overTime < 0 || overTime % 2 > 0 {
    ans = "No"
  }
  (preT, preX, preY) = (t, x, y)
}
print(ans)

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

using namespace std;

void ChristmasEve()
{
  int n;
  int k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  
  int sub;
  int min = h[k - 1] - h[0];
  for (int i = 1; i < n; i++)
  {
    if (i + k <= n)
    {
      sub = h[i + k - 1] - h[i];
      if (min > sub) min = sub;
    }
  }

  cout << min << endl;
  return;
}

int main()
{
  ChristmasEve();
}

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

int main() {
    int n, k; cin >> n >> k;
    double ans = max(0, n - k + 1);
    for (int p = 1; p <= k; p *= 2) {
        int cnt = min(n, (k - 1) / p) - min(n, (k - 1) / (p * 2));
        ans += 0.5 / p * cnt;
    }
    cout << fixed << setprecision(12) << ans / n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	for(int p[6]; ; ) {
		bool end = true;
		rep(i, 6) {
			cin >> p[i];
			end &= p[i] == 0;
		}
		if (end) break;
		
		int a[3];
		rep(i, 3) a[i] = p[i] + p[i + 3];
		
		int mi = min(min(a[0], a[1]), a[2]);
		int ans = 0;
		REP(i, max(0, mi - 10), mi) {
			int t = i;
			rep(j, 3) t += (a[j] - i) / 3;
			ans = max(ans, t);
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,vector<int> > P;

static const double eps = 1e-8;

bool visited[14500000];


int mypow(int x,int n){
	int res = 1;
	while(n>0){		
		if(n & 1) res = res*x;
		x = x * x;
		n>>=1;
	}
	return res;
}


int conv(vector<int>& sets,int n){
	int res = 0;
	for(int i=0;i<sets.size();i++){
		for(int j=0;j<n;j++){
			if(sets[i] & (1<<j)){
				res += i * mypow(3,j);
			}
		}
	}
	return res;
}

int bfs(int m,int n,vector<int>& root,bool* visited){

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,root));
	visited[conv(root,n)] = 0;
	vector<int> tmp;
	vector<int> sets;
	while(!que.empty()){
		int cost = que.top().first;
		
		sets = que.top().second;

		if(sets[1]==0 && sets[2]==0) return cost;
		if(sets[0]==0 && sets[1]==0) return cost;

		if(cost >= m) break;
		que.pop();
		for(int i=0;i+1<sets.size();i++){
			if((sets[i] && sets[i+1] && sets[i] < sets[i+1]) 
				|| (!sets[i] && sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i+1] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i+1] &= ~(1<<pos);
				tmp[i] |= (1<<pos);

				
				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}

			else if((sets[i] && sets[i+1] && sets[i] > sets[i+1]) 
				|| (sets[i] && !sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i] &= ~(1<<pos);
				tmp[i+1] |= (1<<pos);

				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}
		}
	}
	return -1;
}

int main(){

	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<int> sets(3);	
		memset(visited,0,sizeof(visited));
		for(int i=0;i<3;i++){
			int amount;
			scanf("%d",&amount);
			for(int j=0;j<amount;j++){
				int size;
				scanf("%d",&size);
				sets[i] |= (1<<(size-1)); 
			}
		}

		printf("%d\n",bfs(m,n,sets,visited));
	}
	//printf("%d %d %d\n",mypow(3,0),mypow(3,1),mypow(3,2));
}

Measured memory_bytes: 14000
#include<bits/stdc++.h>
#define ll long long int
#define sz  2010
using namespace std;

int main()
{

   ll s=0,b,a,f,k,i;
   ll n;

   cin>>n>>k;
   for(i=1;i<=k;i++)
   {
       cin>>a;
       s+=a;
   }

   if(s>=n)cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i,n)for(urs(n)i=0;i<(n);++i

int main(){
	
string s;
cin >> s;
if(s[1]=='B')
cout << "ARC" << endl;
else cout << "ABC" << endl;







    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int n, k, h[MAX+1];

int main(){
  cin >> n >> k;
  for ( int i = 0; i < n; i++){
    cin >> h[i];
  }

  sort(h, h+n);

  int ans = 1000000000;
  for ( int i = 0; i < n-k+1; i++){
    ans = min(ans, h[i+k-1] - h[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define stkl stack<ll>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
using namespace std;

void solve(){
	int n;
	cin>>n;
	if(n%1000)
		cout<<1000-n%1000<<endl;
	else
		cout<<0<<endl;
}

int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

template<class T> T pow(T a, T b) {
	if (b == 0)return 1;
	if (b % 2) {
		T ret = pow(a, (b - 1) / 2);
		return ret * ret * a;
	}
	else {
		T ret = pow(a, b / 2);
		return ret * ret;
	}
}

int main() {
	init();

	int N, M; cin >> N >> M;
	int ans = (N - M) * 100 + 1900 * M;
	int x = pow(2, M);
	ans *= x;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  map<int, int> m;
  rep(i, N)
  {
    int a;
    cin >> a;
    m[a]++;
  }
  int ans = 0;

  if (m.size() <= K)
  {
    cout << 0 << endl;
  }
  else
  {
    int tmp = m.size() - K;
    vector<int> t(m.size());
    int co = 0;
    for (auto i : m)
    {
      t[co] = i.second;
      co++;
    }
    sort(t.begin(), t.end());
    rep(i, tmp)
    {
      ans += t[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10368
import           Control.Monad
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

primeFactorization :: Int -> [(Int, Int)]
primeFactorization x = pfact x 2 0 []
  where
        sr = floor $ sqrt $ fromIntegral x
        pfact n i r fs | i > sr    = if n > sr then (n,1):fs else fs
                       | otherwise =
                           if n `mod` i == 0
                           then pfact (n `div` i) i (r+1) fs
                           else pfact n (i+1) 0 (if r > 0 then (i,r):fs else fs)
main = do
  n <- getInt

  let p = 10^9 + 7 :: Int
      sr = floor $ sqrt $ fromIntegral n

  v <- VM.new (n+1)
  VM.set v (0::Int)

  forM_ [1..n] $ \x ->
    forM_ (primeFactorization x) $ \(i, r) -> do
      t <- VM.read v i
      VM.write v i (t+r)

  VM.write v 0 (1::Int)
  forM_ [1..n] $ \i -> do
    res <- VM.read v 0
    t <- VM.read v i
    VM.write v 0 (res * (t + 1) `mod` p)

  ans <- VM.read v 0
  print ans

Measured memory_bytes: 892
from collections import deque
s = [deque(input()) for _ in range(3)]
d = {"a":0, "b":1, "c":2}
D = {0:"A", 1:"B", 2:"C"}
player = 0
for _ in range(301):
    x = s[player].popleft()
    player = d[x]
    if not s[player]:
        print(D[player])
        exit()

Measured memory_bytes: 9296
s = input()
first = int(s[:2])
second = int(s[2:])

month = [False,False]


if(1 <= first and first <= 12):
    month[0] = True

if(1 <= second and second <= 12):
    month[1] = True
    
if(month[0] & month[1]):
    print('AMBIGUOUS')
elif(month[0]):
    print('MMYY')
elif(month[1]):
    print('YYMM')
else:
    print('NA')



Measured memory_bytes: 8960
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n; ll k;
	cin >> n >> k;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	vector<int> s;
	vector<int> ord(n + 1, -1);
	int c = 1, l = 0;
	{
		int v = 1;
		while (ord[v] == -1)
		{
			ord[v] = s.size();
			s.push_back(v);
			v = a[v - 1];
		}
		c = s.size() - ord[v];
		l = ord[v];
	}
	if (k < l) cout << s[k] << endl;
	else {
		k -= l;
		k %= c;
		cout << s[l + k] << endl;
	}
}

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

	solve();
}


Measured memory_bytes: 5820
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
from operator import itemgetter
def main():
    n=int(input())
    V=[int(_) for _ in input().split()]
    even,odd=V[0::2],V[1::2]
    even_c,odd_c=Counter(even),Counter(odd)
    even_ci,odd_ci=list(even_c.items()),list(odd_c.items())
    even_ci.sort(key=itemgetter(1),reverse=True)
    odd_ci.sort(key=itemgetter(1),reverse=True)
    if even_ci[0][0]==odd_ci[0][0]:
        if len(even_ci)>1 and len(odd_ci)>1:
            print(min(sum(even_c.values())-even_ci[1][1]+sum(odd_c.values())-odd_ci[0][1],
                        sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[1][1]))
        elif len(even_ci)>1 and len(odd_ci)==1:
            print(sum(even_c.values())-even_ci[1][1])        
        elif len(even_ci)==1 and len(odd_ci)>1:
            print(sum(odd_c.values())-odd_ci[0][1])        
        else:
            print(n//2)   
    else:
        print(sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1])

if __name__=='__main__':
    main()

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

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   string s;
   
   getline(cin,s);
   if(s.size()>7)REP(i,s.size()-7){
      //cout << count(s.begin()+i,s.begin()+i+7,'Y')<< endl;
      if(2==count(s.begin()+i,s.begin()+i+8,'A'))
      if(1==count(s.begin()+i,s.begin()+i+8,'I'))
      if(1==count(s.begin()+i,s.begin()+i+8,'D'))
      if(1==count(s.begin()+i,s.begin()+i+8,'U'))
      if(2==count(s.begin()+i,s.begin()+i+8,'N'))
      if(1==count(s.begin()+i,s.begin()+i+8,'Y')){
         s.replace(i,8,"AIZUNYAN");
         i+=7;
      }
   }
   cout << s << endl;
}

Measured memory_bytes: 1188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            long t = in.nextLong();

            long total = t;
            long pre = in.nextLong();
            for (int i = 0; i < n - 1; i++) {
                long ct = in.nextLong();
                if (pre + t <= ct) {
                    pre = ct;
                    total += t;
                } else {
                    total += ct - pre;
                    pre = ct;
                }
            }

            out.println(total);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 24276
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    char at[11];
    scanf("%s",at);
    int max=0;
    int cnt=0;
    for(int i=0;i<(int)strlen(at);i++){
        if(at[i]=='A' ||at[i]=='C' ||at[i]=='G' ||at[i]=='T' ){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt>max){
            max =cnt;
        }
    }
    printf("%d",max);
}


Measured memory_bytes: 1732
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String line = sc.nextLine();
		String result = "";
		if(line.length()%2 == 1) {
			result = "No";
		}else {
			int halfPoint = line.length()/2;
			String priStr = line.substring(0, halfPoint);
			String endStr = line.substring(halfPoint,line.length());
			if(priStr.equals(endStr)) {
				result = "Yes";
			}else {
				result = "No";
			}
		}
		System.out.println(result);
		
		
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<cmath>
#include<stack>
#include<map>
#include<set>
//ios::sync_with_stdio(false);
#define ull unsigned long long
#define endl "\n"
#define int long long
#define double long double
using namespace std;
#define PI  3.1415926535898
#define eqs 1e-17
const long long max_ = 1e6 + 7;
//haxi = 137， haximod = 998244353;
const int mod = 998244353;
const int inf = 1e9 + 7;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline void write(int x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
int node[max_];
signed main() {
	int n = read();
	for (int i = 3; i <= n; i += 3) {
		node[i] = 1;
	}
	for (int i = 5; i <= n; i +=5) {
		node[i] = 1;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!node[i])ans += i;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11276