akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  cpp_int X; cin >> X;
  cpp_int a = 100;
  for (int n = 0; n < 3761; ++n) {
    a *= 101;
    a /= 100;
    if (a >= X) {
      cout << n+1 << CRLF;
      return;
    }
  }
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll K;

int main(void) {
  cin >> K;

  vector< vector<pll> > E(K);
  REP(i, 1, K + 1) {
    E[i % K].push_back(pll((i + 1) % K, 1));
    E[i % K].push_back(pll((i * 10) % K, 0));
  }

  vector<ll> dp(K, INF);
  priority_queue< pll, vector<pll>, greater<pll> > q;
  q.push(pll(1, 1));
  while(!q.empty()) {
    ll d = q.top().first, v = q.top().second;
    q.pop();

    if(dp[v] <= d) continue;
    dp[v] = d;

    if(v == 0) break;

    for(pll p : E[v]) {
      ll nd = d + p.second, nv = p.first;
      if(dp[nv] > nd) q.push(pll(nd, nv));
    }
  }

  cout << dp[0] << endl;
}


Measured memory_bytes: 9208
n,h=map(int,input().split())
th=[]
ma=0
for i in range(n):
    a,b=map(int,input().split())
    ma=max(ma,a)
    th.append([b,a])
ans=0
th.sort(reverse=True)
for i in range (n):
    if h>0 and th[i][0]>ma:
        h-=th[i][0]
        ans+=1
    if h<=0:
        print(ans)
        exit()
if h%ma==0:
    ans+=h//ma
else:
    ans+=1+(h//ma)
print(ans)



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

using namespace std;

typedef long long  ll;

const int MAX_N = 1500 * 1000 + 5;
int size_w[MAX_N], size_h[MAX_N];

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

    int n, m;

    while (cin >> n >> m, n != 0 && m != 0) {
        vector<int> h(n + 1), w(m + 1);

        memset(size_h, 0, sizeof(size_h));
        memset(size_w, 0, sizeof(size_w));

        h[0] = w[0] = 0;
        for (int i = 0; i < n; ++i)
            cin >> h[i + 1];
        for (int i = 0; i < m; ++i)
            cin >> w[i + 1];

        ++n, ++m;
        for (int i = 1; i < n; ++i)
            h[i] += h[i - 1];
        for (int i = 1; i < m; ++i)
            w[i] += w[i - 1];

        for (int l = 0; l < n - 1; ++l)
            for (int r = l + 1; r < n; ++r)
                ++size_h[h[r] - h[l]];
        for (int l = 0; l < m - 1; ++l)
            for (int r = l + 1; r < m; ++r)
                ++size_w[w[r] - w[l]];

        int lim = max(h[n - 1], w[m - 1]);
        int ans = 0;
        for (int d = 1; d <= lim; ++d)
            ans += size_h[d] * size_w[d];

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 12940
h,w,k = map(int,input().split())
a = [list(input()) for i in range(h)]
acc = [[0 for i in range(w+1)] for j in range(h+1)]
for i in range(1,h+1):
  for j in range(1,w+1):
    acc[i][j] = acc[i-1][j]
    if a[i-1][j-1] == "1":
      acc[i][j] += 1
for i in range(1,h+1):
  for j in range(1,w+1):
    acc[i][j] += acc[i][j-1]
ans = 1000000
def cut(x,y,up,left):
  return acc[x][y]-acc[x][left]-acc[up][y]+acc[up][left]
for i in range(2**(h-1)):
  sep = [0]
  for r in range(h-1):
    if i&1<<r:
      sep.append(r+1)
  sep.append(h)
  anstmp = len(sep)-2
  left = 0
  for j in range(1,w):
#    print(i,j,left,list(cut(sep[x],j+1,sep[x-1],left) for x in range(1,len(sep))))
    if max(list(cut(sep[x],j,sep[x-1],left) for x in range(len(sep)))) > k:
      break
    if max(list(cut(sep[x],j+1,sep[x-1],left) for x in range(len(sep)))) > k:
      anstmp += 1
      left = j
  else:
    ans = min(ans,anstmp)
print(ans)

Measured memory_bytes: 51932
import numpy as np
N,K,Q = map(int, input().split())

points = np.array([K-Q] * N)
getpoints = np.array([0] * N)

for i in range(Q):
  ans = int(input())
  getpoints[ans-1] +=1

points += getpoints

for i in range(N):
  if points[i] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 18868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if(a==b){
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26184
#include <stdio.h>

int main()
{
    int x, y, z, ans = 0;
    scanf("%d %d %d", &x, &y, &z);

    x -= z;
    while(x >= y + z){
        x -= z;
        x -= y;
        ans++;
    }

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

    return 0;
}


Measured memory_bytes: 128
q = int(input())
querys = [list(map(int, input().split())) for _ in range(q)]

stack = []
for query in querys:
    if query[0] == 0:
        stack.append(query[1])

    if query[0] == 1:
        print(stack[query[1]])

    if query[0] == 2:
        stack.pop()


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

int n;
int a;
double d;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    scanf("%d",&n);
    while(n--){
        scanf("%d",&a);
        d+=1/(double(a));
    }
    d=1/d;
    printf("%.10lf\n",d);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (ll)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k>a)
    {
        k=k-a;
    }
    else
    {
        cout<<k;
        return;        
    }
    if(k>b)
    {
        k=k-b;
    }
    else
    {
        cout<<a;
        return;
    }
    if(k>c)
    {
        k=k-c;
    }
    else
    {
        cout<<a-k;
        return;
    }
    cout<<a-c;

}
int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    solve();
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < n; i++)
		{
			String str[] = sc.nextLine().split(" ");
			int sum = toInt(str[0]) + toInt(str[1]);
			System.out.println(toMCXI(sum));
		}
	}
	private static int toInt(String str)
	{
		int res = 0;
		int n = 1;
		for (int i = 0; i < str.length(); i++)
		{
			char c = str.charAt(i);
			switch(c)
			{
				case 'm':
					res += n * 1000;
					n = 1;
					break;
				case 'c':
					res += n * 100;
					n = 1;
					break;
				case 'x':
					res += n * 10;
					n = 1;
					break;
				case 'i':
					res += n;
					n = 1;
					break;
				default:
					n = c - '0';
					break;
			}
		}
		return res;
	}
	private static String toMCXI(int n)
	{
		StringBuffer res = new StringBuffer();
		char order[] = {'i', 'x', 'c', 'm'};
		for (int i = 0; i < 4; i++)
		{
			int a = n % 10;
			if (a != 0)
			{
				res.insert(0, order[i]);
				if (a != 1)
				{
					res.insert(0, a);
				}
			}
			n /= 10;
		}
		return res.toString();
	}
}

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

int main(){
  string s;
  cin >> s;
  if(s.at(1)==s.at(2) ){
    cout << "Bad" <<endl;
  }
  else if (s.at(2)==s.at(3)){
    cout << "Bad" <<endl;
  }
 else if(s.at(0)==s.at(1)){
   cout << "Bad" << endl;
 }
  else {
   cout << "Good" <<endl;
  }  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int id;
	int appearnum;
	unsigned long long uriage;
} syain;

int hikaku(const void* x,const void* y) {
	syain* xx=(syain*)x;
	syain* yy=(syain*)y;
	if(xx->appearnum>yy->appearnum)return 1;
	if(xx->appearnum<yy->appearnum)return -1;
	return 0;
}

int main(void) {
	int i;
	int kazu;
	int bangou;
	syain syainlist[4000];
	unsigned long long tanka,uriage;
	int found;
	int nowappearnum;
	while(1) {
		scanf("%d",&kazu);
		if(kazu==0)break;
		for(i=0;i<4000;i++) {
			syainlist[i].id=i+1;
			syainlist[i].appearnum=0;
			syainlist[i].uriage=0;
		}
		nowappearnum=1;
		for(i=0;i<kazu;i++) {
			scanf("%d %llu %llu",&bangou,&tanka,&uriage);
			syainlist[bangou-1].uriage+=tanka*uriage;
			if(syainlist[bangou-1].appearnum==0) {
				syainlist[bangou-1].appearnum=nowappearnum;
				nowappearnum++;
			}
		}
		qsort(syainlist,4000,sizeof(syain),hikaku);
		found=0;
		for(i=0;i<4000;i++) {
			if(syainlist[i].uriage>=1000000ULL) {
				printf("%d\n",syainlist[i].id);
				found=1;
			}
		}
		if(found==0)puts("NA");
	}
	return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;

    for(int i = 1; i < n; i++) {
        int cnt = 0;

        for(char c = 'a'; c <= 'z'; c++) {
            bool left = false;
            bool right = false;

            for(int j = 0; j < i; j++) {

                if(s[j] == c) {
                    left = true;
                }
            }

            for(int j = i; j < n; j++) {

                if(s[j] == c) {
                    right = true;
                }
            }

            if(left && right) {
                cnt++;
            }
        }

        if(ans < cnt) {
            ans = cnt;
        }
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    long long N, P;
    cin >> N >> P;

    if(N == 1)
    {
        cout << P << endl; return 0;
    }

    map<long long, long long> m;

    long long i = 2;
    for (long long i = 2; i * i <= P; i++)
    {
        while (P % i == 0)
        {
            m[i]++;
            P /= i;
        }
    }
    if(P != 1) m[P]++;
    
    long long ans = 1;

    for (auto i = m.begin(); i != m.end(); i++)
    {
        for (long long j = 0; j < i->second / N; j++)
        {
            ans *= i->first;
        }
        
    }    
    
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;


int main() {
	//18日目 

	cin.tie(0); ios::sync_with_stdio(false);

	ll x;
	ll a = 0,b = 0,c = 0,d = 0;
	cin >> x;

	a = x / 11;
	b = x % 11;
	c = a * 2;

	if (b == 0) {
		cout << 2 * a << endl;
		return 0;
	}

	if (b <= 6) {
		d = 1;
	}
	else {
		d = 2;
	}

	cout << c + d << endl;

	return 0;

}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const int mod=1e9+7;
const int M=10100;
string a,b,c,tmp="";
int asz,bsz,csz;
 int dp1[M][2007];
 int dp2[M][2007];
 int dp3[M][2007];
bool chk(int bl,int br,int cl,int cr)
{
    if(br<cl || cr<bl)return true;
    int lft=max(bl,cl);
    int rgt=min(br,cr);
    int len=rgt-lft+1;
    int bst=lft-bl;
    int cst=lft-cl;
    if(dp3[bst][cst]>=len)return true;
    return false;
}
 main()

{
    //fast
    //freopen("005.txt", "r", stdin);
    cin>>a;
    cin>>b;
    cin>>c;
//    cout<<"#"<<a<<endl;
//    cout<<"#"<<b<<endl;
//    cout<<"#"<<c<<endl;
    int ctmp=4002;
    while(ctmp--)tmp+="?";
    int alen=a.size();
    a=a+tmp;
    a=tmp+a;
    asz=a.size();
    bsz=b.size();
    csz=c.size();
   // cout<<alen<<" "<<bsz<<" "<<csz<<endl;
    int al=4002;
    int ar=al+alen-1;
    rf(i,asz-1,0)
    {
        rf(j,bsz-1,0)
        {
            if(a[i]==b[j] || a[i]=='?' ||  b[j]=='?')
            {
                dp1[i][j]=1+dp1[i+1][j+1];
            }
        }
    }
    rf(i,asz-1,0)
    {
        rf(j,csz-1,0)
        {
            if(a[i]==c[j] || a[i]=='?' ||  c[j]=='?')
            {
                dp2[i][j]=1+dp2[i+1][j+1];
            }
        }
    }
    rf(i,bsz-1,0)
    {
        rf(j,csz-1,0)
        {
            if(b[i]==c[j] || b[i]=='?' || c[j]=='?')
            {
                dp3[i][j]=1+dp3[i+1][j+1];
            }
        }
    }
    int ses=alen+bsz+csz;
   f(bst,0,asz-1)
   {
       f(cst,0,asz-1)
       {
           if(dp1[bst][0]==bsz && dp2[cst][0]==csz)
           {
               int bl=bst;
               int br=bst+bsz-1;
               int cl=cst;
               int cr=cst+csz-1;
               if(chk(bl,br,cl,cr)){

               int lft=min(al,bl);
               lft=min(lft,cl);
               int rgt=max(ar,br);
               rgt=max(rgt,cr);
               int sz=rgt-lft+1;
               ses=min(ses,sz);

               }
           }
       }
   }
   cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 176212
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int a[310][310];
bool vis[310][310];
int main(){//kij
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int k=1;k<=n;k++)      
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++){
                if(k!=j&&k!=i&&i!=j){
                    if(a[i][j]==a[i][k]+a[k][j])vis[i][j]=1;
                    if(a[i][j]>a[i][k]+a[k][j]){
                        cout<<"-1"<<endl;
                        return 0;
                    }
                }
            }
	long long cnt=0;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=n;j++){
    		if(!vis[i][j])cnt+=a[i][j];
		}
	}
	cout<<cnt/2<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

ll a[N];
int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
      int n,k;

      Int(n,k);

      for(int i=1;i<=n;++i){
        Int(a[i]);
      }
      sort(a+1,a+n+1);

      ll s=0;
      for(int i=1;i<=k;++i){
        s+=(ll)a[i];
      }
      printf("%lld\n", s);
        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 3768
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

    map<int, int> mp;
    for (int i = 0; i < N; i++){
        mp[a[i]]++;
    }

    int ans = 0;
    for (auto p: mp){
        int x = p.first;    //ある数字
        int y = p.second;   //その数字が何個あるか
        if (x > y){
            ans += y;
        }else{
            ans += y - x;
        }
    }
    cout << ans << endl;
}

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

void solve(long long N, long long T, std::vector<long long> t){
    ll ans = 0;
    for(ll i = 1; i < N; ++i){
        /*
        cout << "t[i]: " << t[i] << endl;
        cout << "t[i-1]: " << t[i-1] << endl;
        cout << "t[i] - t[i-1]: " << t[i] - t[i-1] << endl;
        */
        if(t[i] - t[i-1] > T){
            ans = ans + T;
        }else{
            ans = ans + (t[i] - t[i-1]);
        }
    }
    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
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> aa;
    vector<int> ba;
    vector<int> ca;
    for(int i = 0; i < a; i++){
        int tmp;
        cin >>tmp;
        aa.push_back(tmp);
    }
    for(int i = 0; i < b; i++){
        int tmp;
        cin >>tmp;
        ba.push_back(tmp);
    }
    for(int i = 0; i < c; i++){
        int tmp;
        cin >>tmp;
        ca.push_back(tmp);
    }

    sort(aa.begin(), aa.end(), greater<int>());
    sort(ba.begin(), ba.end(), greater<int>());
    sort(ca.begin(), ca.end(), greater<int>());

    vector<int> all;
    all.insert(all.end(), aa.begin(), aa.begin()+x);
    all.insert(all.end(), ba.begin(), ba.begin()+y);
    all.insert(all.end(), ca.begin(), ca.end());
    sort(all.begin(), all.end(), greater<int>());

    long long ans = 0;

    for(int i = 0; i < x+y; i++){
        ans += all[i];
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3352
#include <cstdio>

void countingSort(int *a, int *b, int k, int n){
    int i, c[k+1];
    for(i=0;i<k+1;i++)c[i]=0;
    for(i=0;i<n;i++)c[a[i]]++;
    for(i=1;i<k+1;i++)c[i]+=c[i-1];
    for(i=n-1;i>=0;i--){
        c[a[i]]--;
        b[c[a[i]]]=a[i];
    }
    return;
}

int main(){
    int i, n;
    scanf("%d",&n);
    int a[n];
    int k = 0;
    for(i=0;i<n;i++){
        scanf("%d",a+i);
        if(a[i]>k)k=a[i];
    }
    int b[n];
    countingSort(a,b,k,n);
    for(i=0;i<n;i++){
        printf("%d",b[i]);
        if(i<n-1)printf(" ");
        else printf("\n");
    }
    return 0;
}



Measured memory_bytes: 18380
N=int(input())
A = [0 for _ in range(10001)]
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            h=x**2+y**2+z**2+x*y+y*z+z*x #2乗は**
            if h <= 10000:
                A[h]+=1;
                #print(x,y,z,h)
for i in range(1,N+1):
    print(A[i])


Measured memory_bytes: 9348
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll A, B; cin >> A >> B;
	string s; cin >> s;
	if (s[A] != '-') {
		cout << "No" << endl;
		return 0;
	}
	rep(i, 0, A) {
		if (s[i] < '0' || s[i] > '9') {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, A + 1, A + 1 + B) {
		if (s[i] < '0' || s[i] > '9') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
if n == 1:
	if a != b:
		print (0)
	else:
		print (1)
elif a > b:
	print (0)
else:
	mn = a + b + (n-2)*a
	mx = a + b + (n-2)*b
	print (mx-mn+1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		System.out.println(Math.min(a, b) + Math.min(c, d));
	}
	
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans =0;
  
  if(a == 1){
    ans += 300000;
  }else if(a == 2){
    ans += 200000;
  }else if(a == 3){
    ans += 100000;
  }
  
  if(b == 1){
    ans += 300000;
  }else if(b == 2){
    ans += 200000;
  }else if(b == 3){
    ans += 100000;
  }
  
  if(a == 1 && b == 1){
    ans += 400000;
  }
  
  cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    string S;

    cin >> N >> S;

    vector<ll> R;
    vector<ll> G;
    unordered_set<ll> B;

    REP(i, S.size()){
        if( S[i] == 'R' ){
            R.push_back(i);
        }else if( S[i] == 'G' ){
            G.push_back(i);
        }else{
            B.insert(i);
        }
    }

    ll count = 0;
    REP(r, R.size()){
        REP(g, G.size()){
            count += B.size();

            ll pos_r = R[r];
            ll pos_g = G[g];
            ll pos_smaller = min(pos_r, pos_g);
            ll pos_bigger = max(pos_r, pos_g);
            ll diff = pos_bigger - pos_smaller;
            if( B.find(pos_smaller - diff) != B.end() ){
                count--;
            }
            if( B.find(pos_bigger + diff) != B.end() ){
                count--;
            }
            if( diff % 2 == 0 && B.find( (pos_bigger+pos_smaller)/2) != B.end() ){
                count--;
            }
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3696
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int n;
  while (cin >> n) {
    string a, b;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
      cout << a[i] << b[i];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	crap;
	ll i,j,k,n;
	cin >> n ;
	n = n%1000 ;
	if(n==0)
	{
		cout << n endl ;
		return 0 ;
	}
	cout << 1000 - n endl ;
	return 0;
}

Measured memory_bytes: 3636
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    n, c = map(int, readline().split())
    cost = [list(map(int, readline().split())) for _ in range(c)]
    color = [list(map(int, readline().split())) for _ in range(n)]

    group = [Counter() for _ in range(3)]

    for i in range(n):
        for j in range(n):
            cur = (i + j) % 3
            group[cur][color[i][j]] += 1

    from itertools import permutations

    ans = INF

    for after in permutations(range(1, c + 1), 3):
        score = 0
        for gn, counter in enumerate(group):
            for key, val in counter.items():
                score += val * cost[key - 1][after[gn] - 1]
        ans = min(score, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46172
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def _make_minimum_prime(N: int):
    # xの最小の素因数表を作成
    min_prime = [x for x in range(N + 1)]
    # min_prime[0] = 0  # 0と1は素数ではない
    # min_prime[1] = 1
    for i in range(2, int(N ** 0.5) + 1):
        if min_prime[i] == i:  # 素数だったら更新
            for j in range(2 * i, N + 1, i):  # iの倍数は素数でない
                if min_prime[j] == j:
                    min_prime[j] = i
    return min_prime


min_prime = _make_minimum_prime(10**6)


from collections import Counter


def fast_factorization(N: int):
    # -> List[Tuple[int,int]] (素数,冪数)を格納
    # 最小素数配列min_primeを使ってO(log N)で因数分解
    if N == 1:
        return Counter()  # 1は素数ではない
    # 素因数分解
    arr = []
    tmp = N
    while tmp != 1:
        p = min_prime[tmp]
        tmp //= p
        arr.append(p)

    return Counter(arr)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from math import gcd


N = a_int()
A = ints()

# setかはすぐわかる
# setでなければ not coprime
# pairは互いに素かをみればいいのか
# つまり因数分解して足してったときにすべての素数のべき数が1以下であれば良い

g_set = 0
cnt = defaultdict(lambda: 0)
flg = 1  # pairwiseであるフラグ
for a in A:
    g_set = gcd(g_set, a)
    for p, n in fast_factorization(a).items():
        if cnt[p] != 0:
            flg = 0
        cnt[p] += n


# print(cnt)
# for v in cnt.values():
#     if v > 1:
#         flg = 0
#         break

if g_set > 1:
    print('not coprime')
elif flg:
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 202656
N = int(input())
A = list(map(int, input().split()))
M = len([0 for a in A if a < 0])

if A.count(0) > 0 or M % 2 == 0:
    print(sum(abs(a) for a in A))
    exit()

print(sum(abs(a) for a in A) - min(abs(a) for a in A) * 2)


Measured memory_bytes: 14412
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		int free = 0;
		int freeB = 0;

	    free = A;
		A = B;
		B = free;
		freeB = A;
		A = C;
		C = freeB;

		System.out.println(A + " " + B + " " +C);
	}
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long n = sc.nextLong();
    long[] a = sc.nextLongArray(5);
    long min = Long.MAX_VALUE;
    for (long val : a) min = Math.min(min, val);
    long groups = n % min == 0 ? n / min : (n / min) + 1L;
    System.out.println(5L + (groups - 1L));
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    string s;
    cin>>n>>s;
    int ans=n;
    repi(i,1,n) if(s[i-1]==s[i]) ans--;
    cout<<ans;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N<=9) {
    cout << N << endl;
  }
  else {
    if (N<=99) {
      cout << 9 << endl;
    }
    else {
      if (N<=999) {
        cout << N-90 << endl;
      }
      else {
        if (N<=9999) {
          cout << 909 << endl;
        }
        else {
          if (N<=99999) {
            cout << N-9090 << endl;
          }
          else {
            cout << 90909 << endl;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx;
    int dy = ty-sy;

    cout << string(dx,'R');
    cout << string(dy,'U');
    cout << string(dx,'L');
    cout << string(dy,'D');
    cout << string(1,'D');
    cout << string(dx+1,'R');
    cout << string(dy+1,'U');
    cout << string(1,'L');
    cout << string(1,'U');
    cout << string(dx+1,'L');
    cout << string(dy+1,'D');
    cout << string(1,'R') << '\n';
}

Measured memory_bytes: 3556
#include<cstdio>
#include<cstring>
#include<algorithm>
#define reg register
#define max(a,b) (a>b?a:b)
typedef long long ll;
char ch[100005];
class Trie{
	private:
		ll len;
		int nxt[100005][2],cnt;
	public:
		void init(){scanf("%lld",&len);cnt=0;}
		void ins(int l,char ch[]){
			for(reg int i=1,pos=0;i<=l;i++){
				if(!nxt[pos][ch[i]^48])nxt[pos][ch[i]^48]=++cnt;
				pos=nxt[pos][ch[i]^48];
			}
		}
		ll query(int l,int dep){
			if(!l&&dep)return (len-dep+1)&(dep-len-1);
			return query(nxt[l][0],dep+1)^query(nxt[l][1],dep+1);
		}
}t;
int main(){
	reg int n;scanf("%d",&n);
	t.init();
	for(reg int i=1;i<=n;i++){
		scanf("%s",ch+1);
		t.ins(strlen(ch+1),ch);
	}
	puts(t.query(0,0)?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 4096
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
ll n ,k ,a ,b;
int main(){FAST;   
    cin >> n >> k;
    a = n/k ,b =( k & 1 ? 0 : (n + (k >> 1))/k);
    cout << a*a*a + b*b*b;
return 0;
}
 










Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class CumulativeSum2D:
    def __init__(self, field):
        self.h = len(field)
        self.w = len(field[0])
        self.h_offset = self.h
        self.w_offset = self.w
        self.field = field
        self.cumsum = [[0] * (self.w + self.w_offset * 2) for _ in range(self.h_offset)]
        for line in self.field:
            self.cumsum.append([0] * self.w_offset + line + [0] * self.w_offset)
        for i in range(self.h_offset):
            self.cumsum.append([0] * (self.w + self.w_offset * 2))
    
    def calc_diagonal_cumsum(self):
        # Calc ul to dr
        for h in range(self.h_offset, self.h_offset + self.h):
            delta = 1
            while delta + h < self.h_offset * 2 + self.h and self.w_offset + delta < self.w_offset * 2 + self.w:
                self.cumsum[h + delta][self.w_offset + delta] += self.cumsum[h + delta-1][self.w_offset + delta-1]
                delta += 1
        for w in range(self.w_offset + 1, self.w_offset + self.w):
            delta = 1
            while delta + w < self.w_offset * 2 + self.w and self.h_offset + delta < self.h_offset * 2 + self.h:
                self.cumsum[self.h_offset + delta][w + delta] += self.cumsum[self.h_offset + delta - 1][w + delta - 1]
                delta += 1
    
    def get_diagonal_sum(self, x1, y1, x2, y2):
        ret = self.cumsum[y2 + self.h_offset][x2 + self.w_offset]
        ret -= self.cumsum[y1 - 1 + self.h_offset][x1 - 1 + self.w_offset]
        return ret

def rotate(field):
    h = len(field)
    w = len(field[0])
    h, w = w, h
    new_field = []
    for col in zip(*field):
        new_field.append(list(reversed(col)))
    return new_field

if __name__ == "__main__":
    n, m = [int(item) for item in input().split()]
    field = [[0] * m for _ in range(n)]
    for i in range(n):
        line = input().rstrip()
        for j in range(m):
            if line[j] == "#":
                field[i][j] = 1

    ans = 0
    for i in range(4):
        n = len(field)
        m = len(field[0])
        cs = CumulativeSum2D(field)
        cs.calc_diagonal_cumsum()
        lu_to_rd = [[] for _ in range(n + m - 1)]
        for i in range(m):
            x = i; y = 0
            delta = 0
            while x + delta < m and y + delta < n: 
                if field[y + delta][x + delta] == 1:
                    lu_to_rd[i].append((x + delta, y + delta))
                delta += 1
        for i in range(1, n):
            x = 0; y = i
            delta = 0
            while x + delta < m and y + delta < n:
                if field[y + delta][x + delta] == 1:
                    lu_to_rd[i + m - 1].append((x + delta, y + delta))
                delta += 1
        for line in lu_to_rd:
            length = len(line)
            if length <= 1:
                continue
            for i in range(length):
                for j in range(i+1, length):
                    x1, y1 = line[i]
                    x2, y2 = line[j]
                    d = abs(x1 - x2)
                    ans += cs.get_diagonal_sum(x1 + d + 1, y1 - d + 1, x2 + d, y2 - d)
        field = rotate(field)[:]
    print(ans)

Measured memory_bytes: 90332
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
vector<bool> seen;
int result[200000];
int add[200000];

void dfs(const Graph &G, int v) {
   // if(v>seen.size()) return;
    seen[v] = true; 
    result[v]+=add[v];
   // cout<<v<<endl;
    for (auto next_v : G[v]) { 
      //  cout<<next_v<<endl;
       
        if (seen[next_v]/*||v>next_v*/) continue; 
         result[next_v]+=result[v];
        dfs(G, next_v); 
    }
}

int main(int argc, char *argv[]){
  int N,Q;
  cin>>N>>Q;
  Graph G(N);
  for(int i=0; i<N-1; i++){
    int a,b;
    cin>>a>>b;
    a=a-1;
    b=b-1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
 
  for(int i=0; i<Q; i++){
    int p,x;
    cin>>p>>x;
    p=p-1;
    add[p]+=x;
   
  }
    seen.assign(N,false);
    dfs(G,0);
    
  
  for(int i=0; i<N; i++){
    cout<<result[i]<<" ";
    
  }
}



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

using namespace std;

int main()
{
   int n;
   int count;
    cin>>n;
    int arr[n][2];
    if(n<3)
    {
    count = 0;
    }
    else
    {
        count =0;
    
    for(int i=0; i<n; i++)
    {
        cin>>arr[i][0]>>arr[i][1];
        if(arr[i][0]==arr[i][1])
        {
            count++;
            if(count<3)
            continue;
            else
            break;
        }
        
        else
        {
            count = 0;
        }
        
        
    }
   }
    if(count>=3)
    cout<<"Yes";
    else
    cout<<"No";
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string s;
void solve()
{
    cin>>s;
    if(s.size()%2)
    {
        cout<<"No";
    }
    else
    {
        for(int i=1;i<s.size();i+=2)
        {
            if(s[i-1]=='h'&&s[i]=='i')continue;
            cout<<"No";
            return;
        }
        cout<<"Yes";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("STRWC.inp","r",stdin);
    //freopen("STRWC.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  ll n, t;
  ll lower, maxDiff = 0, count = 0;
  cin >> n >> t;

  vector<ll> v(n);
  scan(v);

  lower = v[0];
  for (const auto &val : v) {
    if (lower < val) {
      if (maxDiff < val - lower) {
        maxDiff = val - lower;
        count = 1;
        continue;
      }
      if (maxDiff == val - lower) {
        count++;
      }
      continue;
    }

		lower = val;
  }

  cout << count << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 1024
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL h;
    LL w;
    LL ans;
    cin >> h >> w;
    if(w==1 || h==1){
        ans=1;
    }else if(w%2!=0 && h%2!=0){
        ans = (h*w)/2+1;
    }else{
        ans = (h*w)/2;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int A,B,C;
    vector<int> num(3);
    for(int i=0;i<3;i++){
        cin >> num[i];
    }
    sort(num.begin(),num.end());
    A = num[0];
    B = num[1];
    C = num[2];
    int diff2 = num[2] - num[1];
    int diff1 = num[1] - num[0];
    int cnt=0;
    if(diff1%2==0){
        cnt+= diff1/2;
    }
    else{
        cnt++;
        cnt+= diff1/2;
        diff2++;
    }
    cnt+=diff2;
    cout << cnt << endl;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, R: int):
    if N >= 10:
        print(R)
    else:
        print(R+100*(10-N))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(N, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll K;
    cin >> K;
    string S;
    cin >> S;

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }

}


Measured memory_bytes: 3600
n, k = map(int, input().split())
s=input()

before=s[0]

tenkan=0
fortune=0

for i in range(n):
    if s[i]!=before:
        tenkan+=1
    elif i!=0:
        fortune+=1
    before=s[i]

#print(tenkan, fortune)

while k>0:
    if tenkan>=2:
        tenkan-=2
        fortune+=2
        k-=1
    elif tenkan==1:
        tenkan-=1
        fortune+=1
        k-=1
    else:
        k-=1

print(fortune)

Measured memory_bytes: 40432
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include"custom_header.h"
#else
#define openfile 
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define sz(x) (ll)x.size()
#define vvl vector<vl>
#define vpl vector<pll>
const ll mod = 1000000007;
void solve()
{
    ll n,k,d,i,j;cin>>n>>k>>d;
    n = abs(n);
    ll temp = n/d;
    ll temp2 = n%d;
    if(k<temp)
    {
        cout<<n-k*d<<endl;
        return;
    }
    if((k-temp)%2==0)
    {
        cout<<abs(temp2)<<endl;
    }
    else
    {
        cout<<abs(temp2-d)<<endl;
    }
}
int main()
{
    // openfile;fastio;
    ll T = 1; 
    // cin>>T;
    while(T--)
    {solve();}
}

Measured memory_bytes: 3632