akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <utility>
using namespace std;
int N, Q;
string s;
vector<char> t(200000),d(200000);
int tou(int x){
	int ans=x;
	for(int i=0;i<Q;i++){
		if(ans < 0 || ans >= N)break;
		if(t[i] == s[ans]){
			if(d[i] == 'L')ans--;
			else ans++;
		}
	}
	return ans;
}
int main(){
	cin >> N >> Q;
	cin >> s;
	for(int i=0;i<Q;i++){
		cin >> t[i] >> d[i];
	}
	int mid1 = N / 2;
	int last1 = N - 1;
	int first1 = 0;
	while(last1 - first1 > 0){
		if(tou(mid1) < 0){
			first1 = mid1 + 1;
		}
		else{
			last1 = mid1 - 1;
		}
		mid1 = (last1 - first1) / 2 + first1;
	}
	int mid2 = N / 2;
	int last2 = N - 1;
	int first2 = 0;
	while(last2 - first2 > 0){
		if(tou(mid2) >= N){
			last2 = mid2 - 1;
		}
		else{
			first2 = mid2 + 1;
		}
		mid2 = (last2 - first2) / 2 + first2;
	}
	if(tou(mid1) < 0)mid1++;
	if(tou(mid2) >= N)mid2--;
	cout << mid2 - mid1 + 1 << endl;
}

Measured memory_bytes: 1024
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

TMPMAX = -float('inf')
for j in range(2):

    types = []
    last = [-1] * 26
    S = 0
    for d in range(D):
        # search type
        M = -float('inf')
        for tt in range(26):
            _last = last[:]
            tmp = s[d][tt]

            _last[tt] = d
            for i in range(26):
                tmp -= c[i] * (d - _last[i])

            if tmp > M:
                M = tmp
                M_tt = tt

        S += s[d][M_tt]

        last[M_tt] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        types.append(M_tt)


    cands = [0] * D
    last = [-1] * 26
    S = 0

    if j == 0:
        r = list(range(D))
    else:
        r = list(reversed(range(D)))
    for d in r:
        seq = []
        for tt in range(26):
            _last = last[:]
            tmp = s[d][tt]

            _last[tt] = d
            for i in range(26):
                tmp -= c[i] * (d - _last[i])

            seq.append([tmp, tt])

        seq.sort(reverse=True)

        tmpmax = -float('inf')
        for i in range(15):
            tt = seq[i][1]
            _last = last[:]
            _types = types[:]
            _types[d] = tt
            _S = S

            for dd in range(d, D):
                _S += s[dd][_types[dd]]
                _last[_types[dd]] = dd
                for i in range(26):
                    _S -= c[i] * (dd - _last[i])

            if _S > tmpmax:
                cand = tt
                tmpmax  = _S

        cands[d] = cand + 1
        S += s[d][cand]
        last[cand] = d
        for i in range(26):
            S -= c[i] * (d - last[i])

    if S > TMPMAX:
        TMPMAX = S
        ans = cands

for _ans in ans:
    print(_ans)


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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];

main(){
  ll n,k,ans=0;
  cin>>n>>k;
  ll pos=0;
  rep(i,0,n){
    cin>>a[i];
    if(a[i]==1){pos=i;}
 }
 ans=ceil((ld)(n-1)/(k-1));
  cout<<ans;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


using Graph = vector<vector<int>>;

vector<vector<bool>> seen(55, vector<bool>());
vector<pair<int, int>> bridge;

void dfs(const Graph &G, int v, int b) {
    seen[b][v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if(seen[b][next_v]) continue; // next_v が探索済だったらスルー
        if((v == bridge[b].first && next_v == bridge[b].second) || (v == bridge[b].second && next_v == bridge[b].first)) {
            continue;
        }

        dfs(G, next_v, b); // 再帰的に探索
    }
}

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

    vector<ll> ans;
    for(auto itr = mp.begin(); itr != mp.end(); itr++) {
        if(itr->second >= 2) {
            rep(i, min((ll)2, itr->second/2)) {
                ans.push_back(itr->first);
            }
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());

    if(ans.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << ans[0]*ans[1] << endl;
    }

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
//#define min(A,B) ((A>B)?B:A)
//#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

#define M_PI 3.14159265358979

#define TOP 0
#define SOUTH 1
#define EAST 2
#define WEST 3
#define NORTH 4
#define BOTTOM 5

class Dice {
public:

	Dice(int args[]){
		for (int i = 0; i < 6; ++i) {
			labels[i] = args[i];
		}
	}
	void move(char d){
		int tmp[6];
		for (int i = 0; i < 6; ++i) {
			tmp[i] = labels[i];
		}

		switch(d){
	    case 'N':
	      labels[TOP] = tmp[SOUTH];
	      labels[SOUTH] = tmp[BOTTOM];
	      labels[BOTTOM] = tmp[NORTH];
	      labels[NORTH] = tmp[TOP];
	      break;
	    case 'S':
	      labels[SOUTH] = tmp[TOP];
	      labels[BOTTOM] = tmp[SOUTH];
	      labels[NORTH] = tmp[BOTTOM];
	      labels[TOP] = tmp[NORTH];
	      break;
	    case 'E':
	      labels[TOP] = tmp[WEST];
	      labels[WEST] = tmp[BOTTOM];
	      labels[BOTTOM] = tmp[EAST];
	      labels[EAST] = tmp[TOP];
	      break;
	    case 'W':
	      labels[WEST] = tmp[TOP];
	      labels[BOTTOM] = tmp[WEST];
	      labels[EAST] = tmp[BOTTOM];
	      labels[TOP] = tmp[EAST];
	      break;
		}
	}

	void prt(){
		for (int i = 0; i < 6; ++i) {
			cout << labels[i] << " ";
		}
		cout << endl;
	}

	int getPosOfLabel(int label){
		for (int i = 0; i < 6; ++i) {
			if(labels[i]==label)
				return i;
		}
		return -1;
	}

	int labels[6];
};

int main(){
	int labels[6];
	for (int i = 0; i < 6; ++i) {
		cin >> labels[i];
	}
	Dice *d;
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int t ,s;
		cin >> t >> s;
		d = new Dice(labels);
		switch(d->getPosOfLabel(s)){
		case SOUTH:
			break;
		case NORTH:
			d->move('S');d->move('S');
			break;
		case EAST:
			d->move('W');d->move('S');
			break;
		case WEST:
			d->move('E');d->move('S');
			break;
		case TOP:
			d->move('S');
			break;
		case BOTTOM:
			d->move('N');
			break;
		}

		while(d->labels[TOP]!=t){
			d->move('W');
		}
		println(d->labels[EAST]);
		delete d;
	}

	return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int n, k;
	cin >> n >> k;
	VI a(n);
	rep(i, n) cin >> a[i];

	rep(i, n-k){
		if(a[k+i] > a[i]){
			cout << "Yes" << endl;
		}else cout << "No" << endl;
	}

}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

//#define debug_mode

#ifdef debug_mode
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
using std::endl;
#endif

#ifndef debug_mode
using namespace std;
#endif

void func_to_be_create();

int main(){

    #ifdef debug_mode
    int TEST_NUM = 2;
    while( TEST_NUM --){
    #endif

        func_to_be_create();

    #ifdef debug_mode
    }
    #endif
    return 0;

}

int gcd(int a , int b){
    if( a < b){
        return gcd(b, a);
    }else{
        if( b == 0){
            return a;
        }else{
            return gcd(b , a % b);
        }
    }

}

int gcd(int a, int b , int c){
    int d = gcd(a, b);
    return gcd(d, c);
}

void func_to_be_create(){
    unsigned int K;
    cin >> K;
    unsigned long  sum = 0;
    unsigned int index = 1;
    for(int i = 1; i <= K ; i++){
        for(int j = 1 ; j <= K ; j++){
            for(int k = 1; k <= K ; k++){
                sum += gcd(i, j, k);
            }
        }
    }
    cout <<  sum << endl;
}

Measured memory_bytes: 3600
def LI():
    return list(map(int, input().split()))


X, Y, A, B, C = LI()
red = LI()
green = LI()
mu = LI()
red.sort(reverse=True)
green.sort(reverse=True)
ans = red[:X]+green[:Y]+mu
ans.sort(reverse=True)
total = 0
for i in range(X+Y):
    total += ans[i]
print(total)


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

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



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    string s;
    cin>>s;
    cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = [0] + list(map(int, input().split())) + [0]

for _ in range(k):
    f = 1
    for i in range(1, n+1):
        if a[i] != n:
            f = 0
            break
    if f:
        break
    memo = [0] * (n+1)
    for i in range(1, n+1):
        l = max(1, i-a[i])
        r = min(n, i+a[i])
        memo[l-1] += 1
        memo[r] += -1
    b = [0]
    for memoi in memo:
        b.append(b[-1]+memoi)
    a = b

print(" ".join(list(map(str, a[1:n+1]))))

        




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

int main(){
  int N,count=0,ans=0;
  cin>>N;
  vector<int> H(N);
  for(int i=0; i<N; i++){
    cin>>H.at(i);
  }
  for(int i=0; i<N-1; i++){
    if(H.at(i)>=H.at(i+1)){
      count++;
      ans=max(ans,count);
      //cout<<ans<<endl;
    }
    else{
      count=0;
    }
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){

	int a, b, c, d, e, f;
	int sum = 0;

	cin >> a >> b >> c >> d >> e >> f;

	sum = a + b + c + d - min(a, min(b, min(c, d))) + max(e, f);

	cout << sum << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string S,T;
    ll N,ans=0;
    set<int> A;
    bool F=true;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        int a;
        cin>>a;
        A.insert(a);
    }

    cout<<A.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int n;
scanf("%d",&n);

int low= n % 10;
int middle = ((n % 100) - low) / 10;
int high= (n - (middle + low)) / 100;

if(middle < low)
 middle++;

if(high < middle)
 high++;

printf("%d", high*100+high*10+high);
return 0;
}



Measured memory_bytes: 128
def main():
    K, N = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    A.append(A[0] + K)
    distances = [A[i + 1] - A[i] for i in range(N)]
    print(K - max(distances))


if __name__ == '__main__':
    main()

Measured memory_bytes: 26436
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	if (x>=30) cout<<"Yes";	
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {
		
		while (sc.hasNext()){

		int n = sc.nextInt();
		int x = 0;

		for (int i = 3; i <= n; i = i + 2) {
			for (int j = 3; j <= Math.sqrt(i); j = j + 2) {
				int y = i % j;
				if (y == 0) {
					x = x + 1 ;
					break;
				}
			}
		}
		if ( n == 1){
			System.out.println(0);
		}else{
		if (n % 2 == 0){
			n = n/2 ;
		}else{
			n = (n + 1)/ 2;
		}
		System.out.println(n-x);
		}
		}
	}
}

Measured memory_bytes: 26316
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
#include "math.h"
#include <string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int muri = 0;
	int pt = 0;
	int pa = 0;
	int pb=0;
	int nt, na, nb;
	for (int i = 1; i <= n; i++) {
		cin >> nt >> na >> nb;
		if((nt-pt)<(abs(na-pa)+abs(nb-pb)))muri++;
		else if ((abs((abs(na - pa) + abs(nb - pb)) - (nt - pt))) % 2 == 1)muri++;
		pt = nt;
		pa = na;
		pb = nb;
	}
	if (muri == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

const int mod = 1000000007;
struct mint {
  int x; // typedef long long ll;
  mint(int x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(int t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int count(int a){
  int ans=0;
  while(1){
    if(a%2!=0){
      return ans;
    }
    a/=2;
    ans++;
  }
}

int ketaSouwa(int n){
  int a=0;
  while(1){
    if(n/10==0) return a+n;
    a+=n%10;
    n/=10;
  }
}

main(){
    char moji;
    cin>>moji;
    printf("%c\n", moji+1);
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    A = list(mi())

    # Aの最大公約数
    g = A[0]
    for i in range(N):
        g = math.gcd(A[i], g)

    # Aのmax
    m = max(A)
    
    if K%g==0 and m >= K:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')






if __name__ == '__main__':
    main()

Measured memory_bytes: 20436
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;  
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; }

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N));
  vector<vector<bool>> edge(N, vector<bool>(N, true));
  rep(i, N) rep(j, N)
    cin >> A[i][j];
  rep(i, N) rep(j, N) rep(k, N) {
    if (i!=j && j!=k && i!=k){
      if (A[j][k] > A[j][i]+A[i][k]) {
        cout << -1 << endl;
        return 0;
      }
      if (A[j][k] == A[j][i]+A[i][k])
        edge[j][k] = false;
    }
  }
  ll ans = 0;
  rep(i, N) rep(j, i) {
    if (edge[i][j])
      ans += A[i][j];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
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();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //int a,b,c,d;
    string st;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    cin>>st;
    if(st=="000")printa(0);
    else if(st=="001")printa(1);
    else if(st=="010")printa(1);
    else if(st=="100")printa(1);
    else if(st=="011")printa(2);
    else if(st=="110")printa(2);
    else if(st=="101")printa(2);
    else if(st=="111")printa(3);
    return 0;
}

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

int main() {
  char input;
  cin >> input;
  
  string alph = "abcdefghijklmnopqrstuvwxyz";
  
  for (int i=0; i<25; i++) {
    if (alph.at(i) == input) {
      cout << alph.at(i+1) << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,A[110];
	long double sum;
	cin >> a;
	for (int i = 0; i < a; ++i)
	{
		cin >> A[i];
	}
	sort(A,A+a);
	sum = A[0];
	for (int i = 1; i < a; ++i)
	 {
	 	sum = (sum+A[i])/2.0;
	 } 
	cout << sum;
	return 0; 
}

Measured memory_bytes: 256
import math
step_n, max_jump = map(int, input().split())

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

dp_table = [math.inf] * (step_n)
dp_table[0] = 0

for i in range(1, step_n):
    min_from = max(0, i - max_jump)
    dp_table[i] = min(dp_table[j] + abs(step_list[i] - step_list[j]) for j in range(min_from, i))

print(dp_table[step_n-1])



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

#include <stdio.h>
using namespace std;

int main(void) {
	string s, p;
	bool isCorrect = false;
	cin >> s >> p;
	for (int i = 0; i < s.length(); i++) {
		if (isCorrect) break;
		if (s[i] == p[0]) {
			for (int j = 0; j < p.length(); j++) {
				if (s[(i + j) % s.length()] != p[j]) {
					isCorrect = false;
					break;
				}
				else isCorrect = true;
			}
		}
	}
	if (isCorrect) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;

    cin >> s;
    smatch smatch;
    if (regex_match(s, smatch, std::regex("(hi)+")))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

using namespace std;

int main() {
int N,M;
cin >> N >> M;
int X[110000];
for (int i = 0; i < M; ++i) cin >> X[i];
int sub_X[110000];
sort(X, X + M);
for(int j = 0; j < M-1; ++j){
    sub_X[j] = X[j+1] - X[j];
}
sort(sub_X, sub_X + M-1, greater<int>());
int ans = 0;
for(int k = N-1; k< M-1; k++){
ans += sub_X[k];
}
cout << ans << endl;
return 0;








}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
#define eps 1e-6
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
int n,k;
double num[maxn];
bool less2(double a,double b)
{
	if((a-b)<(0+eps))return 1;
	return 0;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		int p;
		scanf("%d",&p);
		num[i]=(p*1.0+1.0)/2.0;
	}
	double sum=0;
	for(int i=0;i<k;i++)sum+=num[i];
	double bst=sum;
	for(int j=k;j<n;j++)
	{
		double cur=sum+num[j]-num[j-k];
		if(less2(bst,cur))bst=cur;
		sum=cur;
	}
	printf("%.12lf\n",bst);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define rap(i,j,k) for(int i=j;i>=k;--i)
#define ser(i,j)   for(int i=e[j].y;i;i=e[i].n)
#define ll         long long
using namespace std;
int read()
{
	int num=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())num=(num<<1)+(num<<3)+c-48;
	return num*f;
}
const int mn=100010;
int n,m,t,len,ans,a[mn];
void fre()
{
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
}
void init()
{
	n=read();
}
void bf_work()
{
	
}
void work()
{
	if(n==1)
	{
		printf("Hello World");
	}
	else
	{
		int x=read(),y=read();
		printf("%d",x+y);
	}
}
void re_zero()
{
	
}
int main()
{
	//fre();
		init();
		bf_work();
		work();
		re_zero();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N;
	vector<int> p;
	void ans() {
		cin >> N;
		p.resize(N);
		int mx = 0;
		int mx_id;
		REP(i, N) {
			cin >> p[i];
			if (p[i] > mx) {
				mx = p[i];
				mx_id = i;
			}
		}
		p[mx_id] /= 2;
		int sum = 0;
		REP(i, N) sum += p[i];
		cout << sum << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}


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


using namespace std;

const long long MOD_CONST = 1000000007;


int main() {

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	a.emplace_back(0);

	priority_queue<int> cnt;
	int c = 0;
	for (int i = 1; i <=n; i++) {
		c++;
		if (a[i] != a[i - 1]) {
			
			cnt.push(c);
			c = 0;
		}
	}

	for (int i = 0; i < k && !cnt.empty();i++) {
		cnt.pop();
	}

	int ans = 0;
	while (!cnt.empty()) {
		ans += cnt.top();
		cnt.pop();
	}

	cout << ans << endl;


}

Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1)
  {
  	c-=b;
    if(c<=0)
    {cout<<"Yes";return 0;}
    a-=d;
    if(a<=0)
    {cout<<"No";return 0;}
 }
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define rep(i, n) for(int i = 0;i < n; i++)
typedef long long ll;
using namespace std;

int main () {

   ll n; cin >> n;
   vector<string> s (n);
   
   rep(i, n) {
      cin >> s[i];
   }

   sort(s.begin(), s.end());

   int cot = 0;
   int count = 1;
   string g = s[cot];
   for(int i = 0; i < n; i++) {
      if(s[cot] != s[i]) {
         count ++;
         cot = i;
      }
   }

   cout << count << endl;
}
         
      
      

   

   

   


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

int main(void) {
  string s;
  while (cin >> s) {
    string ans;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '@') {
        i++;
        int num = s[i] - '0';        
        i++;
        while (num--) {
          ans += s[i];
        }
      } else {
        ans += s[i];
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    string s;
    cin >> s;

    if(s.size()%2==1) {
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<s.size();i++) {
        if((i%2==0&&s.at(i)=='h')||(i%2==1&&s.at(i)=='i')) ;
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll a[100010],b[100010];
int main(){
  cin>>N;
  rep(i,N) cin>>a[i];
  rep(i,N) cin>>b[i];  
  ll cnt1=0,cnt2=0; 
  rep(i,N){
    if(a[i]<b[i]){
      cnt2+=(b[i]-a[i])/2;
    }
    else if(a[i]>b[i]){
      cnt1+=a[i]-b[i];
    }
  }
  if(cnt1<=cnt2) prin("Yes");
  else prin("No");
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};


int main(){
    while(true){
        int n,p;
        cin >> n >> p;
        if(n == 0 and p == 0) break;
        int inip = p;
        vector<int> V(n);
        int now = 0;
        while(true){
            if(p == 0){
                if(*max_element(all(V)) == inip){
                    cout << max_element(all(V)) - V.begin() << endl;
                    break;
                }else{
                    p += V[now];
                    V[now] = 0;
                }
                now = (now+1)%n;
            }else{
                V[now]++;
                p--;
                now = (now+1)%n;
            }
        }
    }
    return 0;

}

Measured memory_bytes: 1196
import numpy as np
import sys
readline = sys.stdin.readline
read = sys.stdin.read

b = readline().rstrip()
ans = 0
i = 0
while i < len(b):
	cnt = 0
	while i < len(b) and (b[i] == 'A' or b[i] == 'T' or b[i] == 'G' or b[i] == 'C'):
		cnt += 1
		i += 1
	if cnt > ans:
		ans = cnt
	i += 1
print(ans)


Measured memory_bytes: 12504
from sys import stdin
# stdin = open("sample.txt")

a = int(stdin.readline().rstrip())

b = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(b[a-1])

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long a[] = new long[N];
        int tmp;
        int ans = 0;
        for (int z = 0; N > z; z++) {
            a[z] = sc.nextInt();
        }
        Arrays.sort(a);
        if (N == 1 && a[0] > 1) {
            ans = 1;
        } else {
            for (int j = 0; N > j; j++) {
                if (j == 0 || a[j] != a[j - 1]) {
                    tmp = 1;
                    for (int i = j+1; N > i; i++) {
                        if (a[j] == a[i]) {
                            tmp++;
                        }
                        else{
                            break;
                        }
                    }
                    
                    if (tmp > a[j]) {
                        ans += tmp - a[j];
                    } else if (tmp < a[j]) {
                        ans += tmp;
                    }
                
                }
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int s[111];

int main(){
	scanf("%d" , &N);
	int z = 0;
	repp(i,0,N){
		scanf("%d" , s + i);
		z += s[i];
	}
	if(z%10==0){
		sort(s,s+N);
		bool b = 1;
		repp(i,0,N){
			if(s[i]%10!=0){
				z -= s[i];
				b = 0;
				break;
			}
		}
		if(b) z = 0;
	}
	printf("%d\n" , z);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    for(int i=0;i<s.length();i++){
      if(i%2==0) System.out.print(s.charAt(i));
    }
    System.out.println("");
  }
}

Measured memory_bytes: 31112
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
  
using namespace std;
const int inf = 1e9 + 7;

int dist(int a, int b) {
	return abs(a - b);
}



signed main() {
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

 	cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for(int i = 0;i < a;i++) cin >> p[i];
    for(int i = 0;i < b;i++) cin >> q[i];
    for(int i = 0;i < c;i++) cin >> r[i];
    sort(p.begin(), p.end(), [](int v1, int v2) {return v1 > v2;});
	sort(q.begin(), q.end(), [](int v1, int v2) {return v1 > v2;});
	sort(r.begin(), r.end(), [](int v1, int v2) {return v1 > v2;});

	x--;
	y--;

	int res = 0;
	for(int i = 0;i <= x;i++) res += p[i];
	for(int i = 0;i <= y;i++) res += q[i];
	for(int id = 0;id < c;id++) {
		if (y == -1 || (x != -1 && p[x] < q[y])) {
			if (x == -1 || r[id] < p[x]) break;
			res -= p[x];
			x--;
			res += r[id];
		}else{
			if (y == -1 || r[id] < q[y]) break;
			res -= q[y];
			y--;
			res += r[id];
		}
	}

	cout << res;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int ans = 0;
	int min = 1000000;
	int P[N];
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		if (min >= P[i]) {
			min = P[i];
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<list>
#define rep(i,n) for(i = 0; i < n; i++)
#define rep2(i,s,l) for(i = s; i < l; i++)

using namespace std;

bool dfs(int, int);

int main() {
	int i, j,k;
	int n; cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];

	long long sum = 0;
	rep(i, n) sum += d[i];
	sum = sum * sum;
	rep(i, n) sum -= d[i] * d[i];

	cout << sum / 2 << endl;
}


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

int len(int x) {
    int ans = 0;
    while (x > 0) {
        x /= 10;
        ans++;
    }
    return ans;
}

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (len(i) & 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
res=100000000000000000000
for i in range(n-k+1):
    l=a[i]
    r=a[i+k-1]
    if l<=0<=r:
        res=min(res,(-l+r)*2-max(-l,r))
    elif r<0:
        res=min(res,-l)
    else:
        res=min(res,r)
print(res)


Measured memory_bytes: 20332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;

int main(){
    ll n,m;
    ll h[MAX]={};

    cin>>n>>m;
    rep(i,n){
        cin>>h[i];
    }

    ll judge[MAX]={};
    ll a,b;
    rep(i,m){
        cin>>a>>b;
        if(h[a-1]>h[b-1]){
            judge[b-1]=1;
        }else if(h[a-1]<h[b-1]){
            judge[a-1]=1;
        }else{
            judge[b-1]=1;
            judge[a-1]=1;
        }
    }
    int ans=0;
    rep(i,n){
        if(judge[i]==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
int n,a[20],x[20][20],y[20][20];
int cal(int s)
{
    int ans=0;
    for(int i=0;i<n;++i)
    {
        if(s>>i&1)
        {
            for(int j=0;j<a[i];++j)
            {
                if(y[i][j]!=(s>>x[i][j]&1))
                    return 0;
            }
            ++ans;
        }
    }
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        scanf("%d",&a[i]);
        for(int j=0;j<a[i];++j)
        {
            scanf("%d%d",&x[i][j],&y[i][j]);
            --x[i][j];
        }
    }
    int ans=0;
    for(int s=0;s<(1<<n);++s)
        ans=max(ans,cal(s));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def kasanari(A, B, C, D):
    if B < C or A > D:
        return 0
    elif B <= D:
        if A >= C:
            return [A, B]
        else:
            return [C, B]
    else:
        if A >= C:
            return [A, D]
        else:
            return [C, D]

N, M = map(int, input().split())
L = []
for _ in range(M):
    L.append(list(map(int, input().split())))

tmp = [L[0][0], L[0][1]]
L.pop(0)
for i in L:
    L1 = tmp[0]
    R1 = tmp[1]
    tmp = kasanari(L1, R1, i[0], i[1])
    if tmp == 0:
        print(0)
        exit()
print(tmp[1]-tmp[0]+1)

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

int main(){
    int n,k;
    string s;
    cin >> n >> k;
    cin >> s;
    string s2;
    s2=s[k-1];
    if(s2=="A"){
        s[k-1]='a';
    }
    else if(s2=="B"){
        s[k-1]='b';
    }
    else{
        s[k-1]='c';
    }

    cout << s << endl;
    

    return 0;
}

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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    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
}
/*
think fast
think simple
*/
struct node {
    int a, b, c;
    node() {};
    node(int a, int b)
    {
        this->a = a;
        this->b = b;
    }
};

int n, m;
vector<vector<char>>v;
int x, y, fx, fy;
int dx[] = { -1, 1, 0, 0};
int dy[] = {  0, 0, -1, 1};

int dxx[] = { -2, -1, 0, 1, 2, -2, 2, -2, 2, -2,  2, -2, -1,  0, 1,  2};
int dyy[] = {  2, 2,  2, 2, 2,  1, 1,  0, 0, -1, -1, -2, -2, -2, -2, -2};

int dis[1009][1009];
bool check(int x, int y)
{
    if ((0 < x) and (x <= n) and (0 < y) and (y <= m) and (v[x][y] == '.'))
        return 1;
    return 0;
}
void bfs(int x, int y)
{
    deque<node>q;
    q.pb(node(x, y));
    dis[x][y] = 0;
    while (q.size())
    {
        auto fr = q.front();
        q.pop_front();
        for (int i = 0; i < 4; i++)
        {
            int nx = fr.a + dx[i];
            int ny = fr.b + dy[i];

            if (check(nx, ny))
            {
                // cout << "here\n";
                if (dis[nx][ny] > dis[fr.a][fr.b])
                {
                    dis[nx][ny] = dis[fr.a][fr.b];
                    q.push_front(node(nx, ny));
                }
            }
        }
        for (int x = fr.a - 2; x <= fr.a + 2; x++)
            for (int y = fr.b - 2; y <= fr.b + 2; y++)
                if (check(x, y))
                {
                    if (dis[x][y] > dis[fr.a][fr.b] + 1)
                    {
                        dis[x][y] = dis[fr.a][fr.b] + 1;
                        q.pb(node(x, y));
                    }
                }
    }
}
void mysol()
{
    for (auto &i : dis)
        for (auto &a : i)
            a = 1e10;

    cin >> n >> m;

    v.resize(n + 9);
    for (auto &i : v)
        i.assign(m + 9, '#');

    cin >> x >> y >> fx >> fy;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> v[i][j];

    bfs(x, y);

    cout << (dis[fx][fy] >= 1e10 ? -1 : dis[fx][fy]);
}

int32_t main()
{
    fast();
    // w(t)
    {
        mysol();
    }
    //cerr << sizeof(dp)*(1e-6) << " megabytes\n";
    return 0;
}


Measured memory_bytes: 12872
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}

int n, m, t, x, y;

bool dp1[20000], dp2[20000];

int main(void) {
	speed();
	int n, k; cin >> n >> k;
	vector<lint> d(n);
	bool h = false;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	lint ans = INF;
	for (int i = 0; i <= n - k; i++) {
		lint a = d[i];
		lint b = d[i + k - 1];
		if (a <= 0 && b >= 0) ans = min(ans, min(-a, b) + abs(a - b));
		else if (b < 0) ans = min(ans, abs(a));
		else ans = min(ans, abs(b));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3988
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  unordered_set<long> st;
  long N;
  cin >> N;
  rep (i, N) {
    long a;
    cin >> a;
    if (st.count(a)) {
      auto it = st.find(a);
      st.erase(it);
    } else {
      st.insert(a);
    }
  }
  cout << st.size() << endl;
}

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


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


int main(){
	int N;
	cin >> N;
	vector<int> A(N+1);
	vector<int> B(N);
	for (int i = 0; i < N + 1; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}
	
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		int firstKills = min(A[i], B[i]);
		A[i] -= firstKills;
		B[i] -= firstKills;
		int secondKills = min(A[i + 1], B[i]);
		A[i + 1] -= secondKills;
		B[i] -= secondKills;
		ans += firstKills + secondKills;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::{max, min, Ordering};
use std::collections;
use std::io::{stdin, BufRead};
use std::fmt;

macro_rules! get
{
  ($rd:ident; V; $t:ty) => {
    scanl($rd, b'\n')
      .split_whitespace()
      .map(|w| get_inner!{w; $t})
      .collect::<Vec<_>>()
  };
  ($rd:ident; T; $($t:ty),+) => {
    {
      let s = scanl($rd, b'\n');
      let mut i = s.split_whitespace();
      ( $( get_inner!{i.next().unwrap(); $t}),+ )
    }
  };
  ($rd:ident; $t:ty) => (get_inner!{scanl($rd, b'\n'); $t});
}

macro_rules! get_inner
{
  ($src:expr; $t:ty) => {
    $src.parse::<$t>().expect("Parse Error")
  };
}

macro_rules! gets
{
  ($rd:ident; $n:expr; $($tok:tt)*) => {
    (0..)
      .take($n)
      .map(|_| get!{$rd; $($tok)*})
      .collect::<Vec<_>>()
  };
}

fn solve(rd: &mut BufRead)
{
  let (s, t) = get!(rd; T; String, String);
  println!("{}{}", t, s);
}

fn scanl(rd: &mut BufRead, delim: u8) -> String
{
  let mut buf = Vec::new();
  let _ = rd.read_until(delim, &mut buf).expect("Read Failed");
  String::from_utf8(buf)
    .expect("Invalid UTF-8 String")
    .trim_right()
    .to_string()
}

fn main()
{
  let rd = stdin();
  let mut rd = rd.lock(); // std::io::StdinLock
  solve(&mut rd);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
const int INF = 1001001001;
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n){
    //rep(j,m) cin >> a[i][j]; 
  //}
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n-1);
  rep(i,n) cin >> b[i];
  a[0]=b[0];
  rep(i,n-2) a[i+1]=min(b[i],b[i+1]);
  a[n-1]=b[n-2];
  int ans=0;
  rep(i,n) ans+=a[i];
  cout << ans << endl;
}    

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 101010
using namespace std;

vi pr(MAXN , 0);
vi ra(MAXN , 1);

inline int find_set(int v){
	return pr[v] == v ? v : pr[v] = find_set(pr[v]);
}

void union_sets(int a , int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
		if(ra[a] < ra[b])
			swap(a , b);
		ra[a] += ra[b];
		pr[b] = a;
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vector<pii> x(n) , y(n);
	
	rep(i , n){
		int u , v;
		cin >> u >> v;
		x[i] = {u , i};
		y[i] = {v , i};
		pr[i] = i;
	}
	
	
	SORT(x);
	SORT(y);
	
	vector<pair<int , pii>> g(2 * (n - 1));
	
	rep(i , n - 1){
		g[2 * i] = {x[i + 1].fi - x[i].fi , {x[i].se , x[i + 1].se}};
		g[2 * i + 1] = {y[i + 1].fi - y[i].fi , {y[i].se , y[i + 1].se}};
	}
	
	SORT(g);
	
	ll ans = 0;
	int reb = 0;
	
	rep(i , 2 * (n - 1)){
		auto e = g[i].se;
		if(find_set(e.fi) != find_set(e.se)){
			ans += g[i].fi;
			union_sets(e.fi , e.se);
			++reb;
		}
		if(reb == n - 1){
			break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int a,b;
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();

		int ca = a + b;
		int cb = a - b;
		int cc = a * b;
		
		int ans = Math.max(ca, Math.max(cb, cc));
			System.out.println(ans);
	}
}


Measured memory_bytes: 21844
from bisect import bisect_left, bisect_right

N, Q = map(int, input().split())
A = list(map(int, input().split()))
X = [int(input()) for _ in range(Q)]

A.reverse()

evenA = [0] * (N + 1)
accA = [0] * (N + 1)

for i in range(1, N + 1):
    evenA[i] = evenA[i - 1] + (A[i - 1] if i % 2 == 1 else 0)
    accA[i] = accA[i - 1] + A[i - 1]

borders = []
scores = []

for i in range(1, N // 2 + N % 2):
    border = (A[i] + A[i * 2]) // 2 + 1
    borders.append(border)

    score = accA[i] + (evenA[N] - evenA[i * 2])
    scores.append(score)

scores.append(accA[N // 2 + N % 2])

borders.reverse()
scores.reverse()

for x in X:
    i = bisect_right(borders, x)
    print(scores[i])


Measured memory_bytes: 26996