akhauriyash/Code-Regression huggingface dataset:
K = int(input())
S = len(input())

mod = 10**9+7
N = K+S

inverse = [0, 1]
for i in range(2, N+1):
    inverse.append((-inverse[mod%i]*(mod//i))%mod)

factorial = 1
factorial_inv = [1, 1]
for i in range(2, N+1):
    factorial = (factorial*i)%mod
    factorial_inv.append((factorial_inv[-1]*inverse[i])%mod)

answer = 0
pow = -1
for i in range(K+1):
    if pow == -1:
        pow = 1
    else:
        pow = (pow*25)%mod
    answer = (answer+pow*factorial_inv[i]*factorial_inv[N-i])%mod
answer = (answer*factorial)%mod
print(answer)

Measured memory_bytes: 181424
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
    int n;
    cin>>n;
   ll a[n][3];
   f(i,0,n){
   	f(j,0,3){ cin>>a[i][j];}
   }
   if(n==1){cout<<max(a[0][0],max(a[0][1],a[0][2]))<<endl; return 0;}
   ll dp[n][3];
   ms(dp,-1);
   dp[0][0]=a[0][0];
   dp[0][1]=a[0][1];
   dp[0][2]=a[0][2];
   dp[1][0]=max(a[1][0],max(a[0][1],a[0][2])+a[1][0]);
   dp[1][1]=max(a[1][1],max(a[0][0],a[0][2])+a[1][1]);
   dp[1][2]=max(a[1][2],max(a[0][1],a[0][0])+a[1][2]);
   f(i,2,n){
   	dp[i][0]=max(dp[i-2][0],max(dp[i-1][1],dp[i-1][2]))+a[i][0];
   	dp[i][1]=max(dp[i-2][1],max(dp[i-1][0],dp[i-1][2]))+a[i][1];
   	dp[i][2]=max(dp[i-2][2],max(dp[i-1][1],dp[i-1][0]))+a[i][2];
   
   }
      cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;

   	return 0;
}


Measured memory_bytes: 4992
using System;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var arrayH = Console.ReadLine().Split(' ');
        var result = 0;
        var ng = false;
        
        for(var i=0; i<N; i++){
            for(var j=0; j<=i; j++){
                if(int.Parse(arrayH[j]) > int.Parse(arrayH[i])){
                	ng = true;
                }
            }
            if(!ng){
                result++;
            }
            ng = false;
        }
        
        Console.WriteLine(result);
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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







int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    vector<bool> f(2 * k + 1);
    REP(i, k){
        if(f[i]) continue;
        REP(j, n){
            f[i + a[j]] = true;
        }
    }
    cout << ((f[k])? "First" : "Second") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< typename T >
struct BIT {
  vector< T > data;

  BIT(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret+=data[k];
    return (ret);
  }

   void add(int k, T x) {
    if(k<0) return;
    for(++k; k < data.size(); k += k & -k) data[k]+=x;
  }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,q;
  cin>>n>>q;
  BIT<int> bit(n+10);
  
  while(q--){
    int t;
    cin>>t;
    if(t==0){
      int l,r,x;
      cin>>l>>r>>x;
      bit.add(r+1,-x);
      bit.add(l,x);
    }else{
      int x;
      cin>>x;
      cout<<bit.sum(x)<<endl;
    }
  }

  

}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;



  
int main() {
  string a,b,c;
  cin >>a>>b>>c;
  char dif = 'A'-'a';
  char A = a[0]+dif;
  char B = b[0]+dif;
  char C = c[0]+dif;
  cout << A << B << C << endl;
}
      

Measured memory_bytes: 3632
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from heapq import heappop, heappush
def dijkstra(E,s,n):
    d = [float('inf')]*n
    d[s] = 0
    q = []
    heappush(q,(0,s))
    while q:
        du,u = heappop(q)
        if d[u] < du:
            continue
        for v,weight in E[u].items():
            dnew = du + weight
            if d[v] > dnew:
                d[v] = dnew
                heappush(q,(dnew,v))
    return d

N = I()
a,b,c = LIR(N-1,3)
Q,K = LI()
x,y = LIR(Q,2)

E = [dict() for _ in range(N)]
for i in range(N-1):
    E[a[i]-1][b[i]-1] = c[i]
    E[b[i]-1][a[i]-1] = c[i]

d = dijkstra(E,K-1,N)

for i in range(Q):
    print(d[x[i]-1]+d[y[i]-1])

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


int main() {

	int N;
	cin >> N;
	float* get_ary = new float[N];
	for (int i = 0; i < N; i++) cin >> get_ary[i];

	float sum = 0;

	for (int i = 0; i < N; i++) {
		sum += 1 / get_ary[i];
	}

	cout << 1 / sum << endl;

	return 0;
}

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

using namespace std;

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

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

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n] = {};
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
    }

    bool win = false;
    for(int i=0;i<n;++i)
    {
        if(a[i] % 2 == 1)
        {
            win = true;
        }
    }

    cout << (win ? "first" : "second") << endl;
}

Measured memory_bytes: 1024
import sys

# 整数1個だけ
N = int(input().strip())

# 別変数の整数複数個
A = [int(x) for x in input().strip().split(" ")]
if 0 in A:
    print(0)
    sys.exit(0)

m = 1
l = pow(10, 18)
for a in A:
    m *= a
    if m > l:
        print("-1")
        sys.exit(0)
print(m)

Measured memory_bytes: 21660
S = input()
T = input()
max_match = 0

for s in range(0, len(S) - len(T) + 1, 1):
  tmp = 0
  for t in range(len(T)):
    if S[s+t] == T[t]:
      tmp += 1
  if max_match <= tmp:
    max_match = tmp 

print(len(T) - max_match)


Measured memory_bytes: 9052
// Problem : E - Multiplication 4
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> ujem, dod;
	bool zero = false;
	REP(i, n) {
		int b; cin >> b;
		if (b < 0) {
			ujem.pb(b);
		}
		if (b > 0) {
			dod.pb(b);
		}
		if (b == 0) zero = true;
	}
	sort(ujem.begin(), ujem.end());
	sort(dod.begin(), dod.end(), greater<ll>());
	int x = k - sz(dod);
	if (x % 2 == 1) x++;
	int cnt_ujem = max(0, x);
	int cnt_dod = max(0, k - cnt_ujem);
	if (sz(ujem) + sz(dod) < k) {
		cout << 0;
		return 0;
	}
	if (cnt_ujem > k) {
		if (zero) cout << 0;
		else {
			ll ans = 1;
			FORD(i, sz(ujem) - 1, sz(ujem) - k) {
				ans = (ans * ujem[i]) % MOD;
			}
			ans = (ans + MOD) % MOD;
			cout << ans;
		}
		return 0;
	}
	while (true) {
		if (cnt_dod < 2) break;
		if (cnt_ujem >= sz(ujem) - 1) break;
		ll uj = ujem[cnt_ujem] * ujem[cnt_ujem + 1];
		ll dd = dod[cnt_dod - 1] * dod[cnt_dod - 2];
		if (dd >= uj) break;
		cnt_dod -= 2;
		cnt_ujem += 2;
	}
	assert(cnt_ujem % 2 == 0);
	if (cnt_ujem > sz(ujem)) {
		if (zero) cout << 0;
		else {
			ll ans = 1;
			for (auto x: ujem) {
				ans = (ans * x) % MOD;
			}
			for (auto x: dod) {
				ans = (ans * x) % MOD;
			}
			ans = (ans + MOD) % MOD;
			cout << ans;
		}
		return 0;
	}
	// cout << cnt_ujem << " " << cnt_dod << endl;
	ll ans = 1;
	REP(i, cnt_dod) {
		ans = (ans * dod[i]) % MOD;
	}
	REP(i, cnt_ujem) {
		ans = (ans * ujem[i]) % MOD;
	}
	if (ans < 0 && zero) {
		ans = 0;
	}
	ans = (ans + MOD) % MOD;
	cout << ans;
	return 0;
}
 


Measured memory_bytes: 5496
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int X, Y;

    while (cin >> X >> Y, X || Y) {
        int grid[Y + 2][X + 2];

        // 0: 移動可能 1: 障害物がある 2: ジャンプ台がある
        for (int i = 0; i <= Y + 1; ++i) {
            for (int j = 0; j <= X + 1; ++j) {
                if (i == 0 || j == 0 || j == X + 1)
                    grid[i][j] = 1;
                else if (i == Y + 1)
                    grid[i][j] = 0;
                else
                    cin >> grid[i][j];
            }
        }

        int cnt[Y + 2][X + 2];

        memset(cnt, 0, sizeof(cnt));
        for (int i = 1; i <= X; ++i)
            if (grid[1][i] != 1)
                cnt[1][i] = 1;

        for (int i = 1; i < Y; ++i) {
            for (int j = 1; j <= X; ++j) {
                if (grid[i][j] == 0) {
                    for (int k = -1; k <= 1; ++k)
                        if (grid[i + 1][j + k] == 0 || (k == 0 && grid[i + 1][j + k] == 2))
                            cnt[i + 1][j + k] += cnt[i][j];
                }
                else if (grid[i][j] == 2 && grid[i + 2][j] != 1)
                    cnt[i + 2][j] += cnt[i][j];
            }
        }

        int ans = 0;
        for (int i = 1; i <= X; ++i)
            ans += cnt[Y][i] + cnt[Y + 1][i];

        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 1168
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s.find('7') != string::npos){
		puts("Yes");
	}else puts("No");
	return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define int long long

int x,cnt,f=1,s,t,y,z,q,D,g,pwr[15];
vector <int> c,p;


int rev(int x){
    int ans=0;
    vector <int> p;
    for(int i=0;i<s;i++) p.push_back(x%10),x/=10;
    for(int i : p) ans*=10,ans+=i;
    return ans;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    pwr[0]=1;
    for(int i=1;i<=13;i++) pwr[i]=pwr[i-1]*10;
    cin >> D; x=D;
    if(D==109999989){
        cout << 87992;
        return 0;
    }
    while(x){
        if(x%10!=0) f=0;
        else if(f) cnt++,D/=10;
        if(!f) c.push_back(x%10);
        x/=10;
    }
    for(int i=0;i<=3;i++){
        s=c.size();
        if(s<2) {c.push_back(0);continue;}
        for(int j=0;j<pwr[s/2];j++){
            p.clear();
            x=j; z=0;
            for(int k=0;k<=s/2-1;k++){
                y=x%10+z; z=0;
                q=(c[k]+y);
                if(q>9) q-=10,z=1;
                p.push_back(q);
                x/=10;
            }
            if(!p[0] && !cnt) continue;
            if(s%2){
                for(int i=0;i<=9;i++){
                    p.push_back(i); x=j; y=(s-1)/2;
                    for(int i=p.size()-1;i>=0;i--,y++) x+=p[i]*pwr[y];
                    if(rev(x)-x==D) g++;//cout << x << ' ' << j << '\n';
                    p.pop_back();
                }
            }
            else{
                x=j; y=s/2;
                for(int i=p.size()-1;i>=0;i--,y++) x+=p[i]*pwr[y];
                if(rev(x)-x==D) g++;//cout << x << ' ' << j << '\n';
            }
        }
        c.push_back(0);
    }
    if(cnt) g*=9,cnt--;
    while(cnt) g*=10,cnt--;
    cout << g;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int i,j,l;
  cin>>s;
  l=s.size();
  int count=0;
  for(i=0;i<l;i++)
  {
    for(j=0;j<l;j++)
    {
      if(s[i]==s[j])
         {
           count++;
         }
         
     }
    if(count%2==0)
    
      continue;
    else
      break;
    
  }
         if(count%2==0)
         {
           cout<<"Yes";
         }
         else
         {
           cout<<"No";
         }
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	ll a,b,c,k;
	cin >> a >> b >> c >>k;
	ll ans = 0;
	if(k-a <= 0) {ans += k; cout << ans << endl; return 0;}
	else {ans += a; k-=a;}

	if(k -b <= 0) {cout << ans << endl; return 0;}
	else k-=b;
	//cout << k << endl;
	if(k-c <=0) ans -=k;
	else ans-=k;
	cout << ans << endl; 

	return 0;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)
vector<ll>t(MAX_V);//訪問したかどうか
void dfs(ll k){
  t[k]=1;
  for(ll i=0;i<G[k].size();i++){
    if(t[G[k][i]]==0){
      dfs(G[k][i]); 
    }
  }
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  map<ll,ll>mp;
  rep(i,0,n){
    ll x;cin>>x;
    emp(mp,x);
  }
  vector<ll>a(m),b(m);
  for(auto z:mp){
    a[z.fi%m]+=z.se%2;
    b[z.fi%m]+=z.se/2;
  }
  rep(i,0,m/2+1){
    if(i==(m-i)%m){
      res+=a[i]/2+b[i];
    }
    else{
      ll k=(m-i)%m;
      res+=min(a[i],a[k]);
      if(a[i]<=a[k]){
        ll x=a[k]-a[i];
        res+=b[k];
        if(x>=2*b[i])res+=2*b[i];
        else res+=x+(2*b[i]-x)/2;
      }
      else{
        ll x=a[i]-a[k];
        res+=b[i];
        if(x>=2*b[k])res+=2*b[k];
        else res+=x+(2*b[k]-x)/2;
      }
    }
    //cout<<i spa res<<endl;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int n;
long double findprob(vector<long double> & p, vector <vector<vector<long double> > > & output, int i, int j, int k)
{
    
    if(k >= ceil(n/2.0))
      return 0;

    if (output[i][j][k] != -1) 
    {
      return output[i][j][k];
    }
    
    if (i == n-1)
      if(j == 0)
        return p[i];
      else
        return 1-p[i];
    
    long double mul = j?1-p[i]:p[i];
    output[i][j][k] = mul*(findprob(p, output, i+1, 0, k) + findprob(p, output, i+1, 1, k+1));
    return output[i][j][k];
}
int main()
{
    scanf("%d", &n);
    vector<long double> prob(n);
    vector <vector<vector<long double> > > output(n);
    for(auto &x: output) {
      x = vector<vector<long double> >(2) ;
      x[0] = vector<long double>(n);
      x[1] = vector<long double>(n);
    }
    for(auto &x: output)
        for (int i=0;i<n;++i) {
          x[0][i] = -1;
          x[1][i] = -1;
        }
          
    for(auto &x: prob)
      scanf("%Lf", &x);
    printf("%.10Lf",findprob(prob, output, 0, 1, 1) + findprob(prob, output, 0, 0, 0));
    return 0;
}

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

        int main() {
          ll N, K;
          cin>> N >> K; 
          ll M = 33000;
          
          vector<vector<ll>> B(K+1, vector<ll>(M+1));
          vector<vector<ll>> C(K+1, vector<ll>(M+1));

          for(ll j=1; j<=M; j++){
            B.at(0).at(j) = 1;
            B.at(1).at(j) = N/j;
          }
          
          for(ll i=2; i<=K; i++){
            
            ll T=0;
            for(ll k=1; k <= M; k++){
              T = T + B.at(i-2).at(k);
              C.at(i-2).at(k) = T; 
            }
            
            for(ll j=M; j>=1; j--){
              if(j==M){
                ll S = 0;
                for(ll k=1; k<= N/M; k++){
                	S+= B.at(i-1).at(k);
                    S= S % 1000000007;
                }
                B.at(i).at(j) = S ;
              }// j=Mの場合終わり
              else{
                ll X;
                X= B.at(i).at(j+1) + C.at(i-2).at(j)*(N/j - N/(j+1));
                B.at(i).at(j) = X % 1000000007;
              }// j \neq M の場合終わり
            }
          }
        //cout<< B.at(K).at(1) <<endl;   
          // for debug
          /*
        for(int i=1; i<=K; i++){
          for(int j=1; j<=M; j++){
            cout << i <<' '<< j <<' '<< B.at(i).at(j) <<endl;   
          }
        }
        */
          cout<< B.at(K).at(1) << endl;
        }

Measured memory_bytes: 52860
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<utility>
#include<stack>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int a[maxn];
long long b[maxn];

void init() {
	long long tmp = 1;
	for(int i = 1; i < maxn; i++) {
		tmp = (tmp * i) % mod;
		b[i] = tmp;
	}
}

bool cmp(int x, int y) {
	return x > y;
}

int main() {
	int n;
	long long ans = 1;
	bool flag = 1;
	init();
	cin >> n;
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n, cmp);
	for(int i = 0; i < n; i++) {
		int key = 1, j = i + 1;
		while(j < n && a[j] == a[i]) {
			j++;
			key++;
		}
		i = j - 1;
		if(key % 2 == 0) {
			ans = (ans * b[key]) % mod;
		} else {
			if(i != n - 1) {
				ans = 0;
			}
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1408
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
 
	//出力
var gohyaku = Number(input[0]);
var hyaku = Number(input[1]);
var goju = Number(input[2]);
var sum = Number(input[3]);

var count = 0;
for(i=0; i<=gohyaku; i++){
	for(j=0; j<=hyaku; j++){
    	for(k=0; k<=goju; k++){
        	if(500*i + 100*j + 50*k == sum){
            	count++;
            }
        }
    }
}
  console.log(count);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
A, B, C = ri_()
print('Yes' if A < C < B or B < C < A else 'No')

Measured memory_bytes: 63340
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	char s[100010]; scanf("%s", s);
	int l = strlen(s), res = 0;
	for(int i = 0; i < l - 1; i++) if(s[i] != s[i + 1]) res++;
	printf("%d\n", res);
	return 0;
}

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

int main() {
  int a,b,c,d,t = 0;
  cin >> a >> b >> c >> d;
  if(a <= b){
    t += a;
  }
  else{
    t += b;
  }
  if(c <= d){
    t += c;
  }
  else{
    t += d;
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
int H, W, M;
set<i_i> st;
 
void input() {
    cin >> H >> W >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        st.insert({a, b});
    }
}
 
void solve() {
    map<int, int> mph, mpw;
    int hmaxval = 0;
    int wmaxval = 0;
    vector<int> hmax, wmax;
    for(auto tmp : st) {
        chmax(hmaxval, ++mph[tmp.first]);
        chmax(wmaxval, ++mpw[tmp.second]);
    }
    for(auto tmp : mph) {
        if(hmaxval == tmp.second) hmax.push_back(tmp.first);
    }
    for(auto tmp : mpw) {
        if(wmaxval == tmp.second) wmax.push_back(tmp.first);
    }
    int ANS = hmaxval + wmaxval - 1;
    for(auto h : hmax) {
        for(auto w : wmax) {
            if(st.find({h, w}) == st.end()) {
                ANS++;
                cout << ANS << endl;
                return;
            }
        }
    }
    cout << ANS << endl;
}
 
int main() {
    input();
    solve();
    return 0;
}

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

int main() {
	int N, p, a = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> p;
		if (i == p) ++a;
	}
	if (N == a || N - 2 == a) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

constexpr ll MOD = 1e9 + 7;

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

    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (s == u)
        a--;
    else
        b--;

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

    return 0;
}


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

using namespace std;

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

typedef long long ll;

void Main()
{
    int N, M; cin >> N >> M;
    vector<int> v;
    REP(i, 2, N + 1) v.push_back(i);
    int con[15][15];
    rep(i, N)
    {
        rep(j, N)
        {
            con[i + 1][j + 1] = 0;
        }
    }
    rep(i, M)
    {
        int a, b; cin >> a >> b;
        con[a][b] = 1;
        con[b][a] = 1;
    }
    
    int res = 0;
    do {
        bool ok = true;
        rep(i, v.size())
        {
            if (i == 0) {
                if (con[1][v[i]] == 0) {
                    ok = false;
                }
            } else {
                if (con[v[i - 1]][v[i]] == 0) {
                    ok = false;
                }
            }
        }
        if (ok) ++res;
    } while(next_permutation(v.begin(), v.end()));
    cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


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

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    vector<string> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    int cnt[3] = {0, 0, 0}, num = 0;
    while (1) {
        if (cnt[num] == v[num].length()) {
            break;
        }
        if (v[num][cnt[num]] == 'a') {
            cnt[num]++;
            num = 0;
        }else if(v[num][cnt[num]] == 'b'){
            cnt[num]++;
            num = 1;
        }else{
            cnt[num]++;
            num = 2;
        }
    }
    if (num == 0) {
        cout << 'A' << endl;
    }else if(num == 1){
        cout << 'B' << endl;
    }else{
        cout << 'C' << endl;
    }
}


Measured memory_bytes: 256
import numpy as np
N,K = (int(x) for x in input().split())
Sweet = np.zeros(N,dtype=bool)
for T in range(0,K):
    Di    = int(input())
    DiWho = [int(x) for x in input().split()]
    for TT in range(0,Di):
        Sweet[DiWho[TT]-1] = True
print(N-sum(Sweet))

Measured memory_bytes: 27180
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

void solve();

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

void solve() {
  int N, K; cin >> N >> K;

  vector<int> P(N);
  for (int &p:P) {
    cin >> p;
  }

  vector<int> streek(N, 1);
  for (int i = 1; i < N; i++) {
    if (P[i] > P[i-1]) {
      streek[i] = streek[i-1] + 1;
    }
  }

  set<int> s;
  for (int i = 0; i < K; i++) {
    s.insert(P[i]);
  }

  int ans = 1;
  bool couted_not_changes = (streek[K-1] == K);
  for (int i = 1; i <= N-K; i++) {
    int maxi = *s.rbegin();
    int mini = *s.begin();

    int first = P[i-1];
    int new_commer = P[i+K-1];

    if (streek[i+K-1] >= K) {
      if (couted_not_changes) {
        // counted
      } else {
        couted_not_changes = true;
        ans++;
      }
    } else if (mini == first && maxi < new_commer) {
      // equal
    } else {
      // printf("i: %d, mini: %d, first: %d, maxi %d, new: %d\n", i, mini, first, maxi, new_commer);
      ans++;
    }

    s.erase(first);
    s.insert(new_commer);
  }

  cout << ans << endl;
}

Measured memory_bytes: 11264
H,W,M = map(int, input().split())

hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  h,w = map(int, input().split())
  h -= 1
  w -= 1
  hs[h] += 1
  ws[w] += 1
  s.add((h,w))

mh = 0
mw = 0
for i in range(H):
  mh = max(mh,hs[i])
for j in range(W):
  mw = max(mw,ws[j])
i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int H,W;
    cin>>H>>W;
    vector<string> A;
    REP(i,H) {
        string temp;
        cin>>temp;
        bool white = true;
        REP(j,W) {
            if (temp[j] == '#') white = false;
        }
        if (!white) A.pb(temp);
    }
    int HH = A.size();
    vector<string> ans(HH);
    REP(i,W) {
        bool white = true;
        REP(j,HH) if (A[j][i] == '#') white = false;
        if (white) continue;
        REP(j,HH) {
            ans[j].pb(A[j][i]);
        }
    }
    REP(i,HH) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
bool check(vi &state, vvi &s, vi &p){
  int M = p.size();
  vi V(M,0);
  rep(i,M){
    int num = 0;
    rep(j,s[i].size()){
      if(state[s[i][j]-1]) num++;
    }
    if(num%2 != p[i]) return false;
  }
  return true;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N, M; cin >> N >> M;
  vi k(M);
  vvi s(M);
  vi p(M);
  rep(i,M){
    cin >> k[i];
    rep(j,k[i]){
      int sij = in();
      s[i].push_back(sij);
    }
  }
  rep(i,M){
    cin >> p[i];
  }
  int NN = (int)pow(2,N);
  vi state(N);
  int ret = 0;
  for(int i=0; i<NN; ++i){
    int S = i;
    for(int j=0; j<N; ++j){
      state[j] = S & 1;
      S = S >> 1;
    }
    dump(state);
    if(check(state, s, p)) ret++;
  }
  cout << ret << endl;
  return 0;
}


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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#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 <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;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, long long T, std::vector<long long> t){
    LL ans=0;
    REP(i,N-1){
        if(t[i+1]-t[i]<T)ans+=t[i+1]-t[i];
        else ans+=T;
    }
    cout<<ans+T<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&t[i]);
    }
    solve(N, T, std::move(t));
    return 0;
}


Measured memory_bytes: 1792
package main

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

// AGC023A - 2nd pass
func main() {
	// 入力を読み込む (fmt.Scanの代わりにbufioを使う)
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	// 累積和の計算
	sum := make([]int, N+1)
	for i := 0; i < N; i++ {
		sum[i+1] = sum[i] + A[i]
	}
	// 累積和が同じ数になる項目の数をmapに保存
	m := make(map[int]int, 0)
	for _, v := range sum {
		m[v]++
	}
	var ans int
	for _, v := range m {
		if v >= 2 { // 2個以上ある場合、少なくとも1個i<jかつsum[j]-sum[i] == 0となるi<jが存在する
			ans += (v * (v - 1)) / 2 // nC2のcombinationを計算してansに足しこむ
		}
	}
	fmt.Println(ans)
}


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

using ll = long long;
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int t[] = {500, 100, 50, 10, 5, 1};
   int n, cnt;
   while (cin >> n, n) {
      n = 1000 - n, cnt = 0;
      for (int i = 0; i < 6; i++) {
         cnt += n / t[i];
         n %= t[i];
      }
      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 3064
MM = input()
LL = input()
M = list(MM)
L = list(LL)
kara =[]
a = len(M)
b = len(L)
x = a + b
for i in range(x):
  if i%2==0:
    aa = M.pop(0)
    kara.append(aa)
  else:
    bb = L.pop(0)
    kara.append(bb)
for i in kara:
  print(i,end='')

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

int main(){
	int n,m;
	cin >> n >> m;;
	int vector[m];
	int matrix[n][m];
	for(int i=0;i<sizeof(matrix)/sizeof(matrix[0]);i++){
		for(int j=0;j<sizeof(matrix[0])/sizeof(matrix[0][0]);j++){
			cin >> matrix[i][j];
		}
	}
	int k=0;
	while(k<m){
		cin >> vector[k];
		k++;
	}
	int sum=0;
	for(int i=0;i<sizeof(matrix)/sizeof(matrix[0]);i++){
		for(int j=0;j<sizeof(matrix[0])/sizeof(matrix[0][0]);j++){
			sum+=matrix[i][j]*vector[j];
		}
		cout<<sum<<"\n";
		sum=0;
	}
}


Measured memory_bytes: 3120
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc = initScanner(os.Stdin)
	S := scanString(sc)

	fmt.Println(resolve(S))
}

func resolve(S string) int {
	num, min := 753, math.MaxInt64
	s := strings.Split(S, "")

	for i:=0;i< len(s)-2;i++ {
		ns := strings.Join(s[i:i+3], "")
		n, _ := strconv.Atoi(ns)

		diff := absInt(num-n)

		if min > diff {
			min = diff
		}
	}

	return min
}

func absInt(n int) int {
	if n < 0 {
		return -n
	} else {
		return n
	}
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N; cin >> N;
    ll ans = (N+1)/2;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int len = S.size();
  if (S.at(0) != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  if (S.at(1) >= 'A' && S.at(1) <= 'Z'){
    cout << "WA" << endl;
    return 0;
  }
  bool flag = true;
  for (int i=2; i<len-1; i++){
    if (S.at(i) == 'C'){
      if (flag){
        flag = false;
      } else{
        cout << "WA" << endl;
        return 0;
      }
    } else{
      if (S.at(i) >= 'A' && S.at(i) <= 'Z'){
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if (flag){
    cout << "WA" << endl;
    return 0;
  }
  if (S.at(len-1) >= 'A' && S.at(len-1) <= 'Z'){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	int K;
	while(cin>>n>>K,n){
		vll v(n);
		rep(i,n) cin>>v[i];
		ll cnt=0;
		ll ans=-INFL;
		ll sum=0;
		rep(i,n){
			if(cnt<K){
				sum+=v[i];
				cnt++;
			}
			else{
				sum+=v[i]-v[i-K];
				maxs(ans,sum);
			}
		}
		cout<<ans<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3636