akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<algorithm>
#include<string.h>
#define MAX 100000

int head, tail;
struct Proc {string name; int t;};
Proc Q[MAX];

void enqueue(Proc x) {
        Q[tail] = x;
        tail = (tail + 1) % MAX;
}

Proc dequeue() {
        Proc x = Q[head];
        head = (head + 1) % MAX;
        return x;
}

int main() {
        int elaps = 0, c, i, q, n;
        Proc u;
        cin >> n >> q;
        for(i = 0; i < n; i++) {
                cin >> Q[i].name >> Q[i].t;
        }
        head = 0; tail = n;
        while(head != tail) {
                u = dequeue();
                c = min(q, u.t);
                u.t -= c;
                elaps += c;
                if(u.t > 0) enqueue(u);
                else {
                        cout << u.name << " " << elaps << endl;
                }
        }
        return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int a[70], n, sum,i,j;
int main(){
    cin >> n;
    for(i=1; i<=n; i++)
        cin >> a[i];
    for(i=1; i<n; i++)
        for(j=i+1; j<=n; j++)
            sum += a[i]*a[j];
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b;
  cin >>a>>b;
  int ans = 0;
  if(a>=b){
    ans += a;
    a--;
  }
  else{
    ans += b;
    b--;
  }
  ans += max(a,b);
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  REP(i, 1000) {
    string i_str = to_string(i);
    string pin = string(3 - i_str.length(), '0') + to_string(i);
    int match_count = 0;
    REP(j, s.length()) { match_count += (s[j] == pin[match_count]); }
    if (match_count >= 3) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cerr << v[__k]; if(__k != v.size()-1) cerr << " "; else cerr << endl; }
using namespace std;

int d(char c) { return c -  'a'; }

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

	const ull MOD = 1000000007;

	int N;
	string s, t;
	cin >> N >> s >> t;

	vector<vector<ull> > dp(N, vector<ull>(26, 0));
	dp[0][d(s[0])] = 1;
	FOR(i, 1, N) {
		dp[i][d(s[i])] += dp[i-1][d(t[i])]; // 来られるなら追加する
		dp[i][d(s[i])] %= MOD;
		// cerr << d('z') << endl;
		REP(j, 26) {
			dp[i][j] += dp[i-1][j]; // 継承
			dp[i][j] %= MOD;
		}
	}
	cout << dp[N-2][d(t[N-1])] << endl;
	//REP(i, N) print_array(dp[i]);
}


Measured memory_bytes: 27156
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
constexpr ld PI = acos(-1);

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

constexpr int MAXN = 2e5;

vector<int> g[MAXN];

void run() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v), g[v].push_back(u);
    }
    vector<int> dist(n, -1), pr(n, -1);
    int cnt = 0;
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    while (q.size()) {
        cnt++;
        int v = q.front();
        q.pop();
        for (auto u : g[v]) {
            if (dist[u] == -1) {
                dist[u] = dist[v] + 1;
                pr[u] = v;
                q.push(u);
            }
        }
    }
    if (cnt != n) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for (int i = 1; i < n; i++) {
            cout << pr[i] + 1 << '\n';
        }
    }
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 16164
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll test[501][501];
signed main() {
	ll n, m, a = 0, b = 0, c = 0, cn = 0, cnt = 0, ans = 0; cin >> n >> m;
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cin >> test[h][i];
			if (test[h][i] % 2 == 1) { c++; }
		}
	}
	if (c % 2 == 1) { c--; }
	for (int h = 1; h <= n; h++) {
		if (h % 2 == 1) {
			for (int i = 1; i <= m; i++) {
				if (cn == c) { break; }
				if (cnt == 0 && test[h][i] % 2 == 1) {
					cnt++; a = h; b = i; cn++;
				}
				else if (cnt == 1 && test[h][i] % 2 == 1) {
					cnt = 0; cn++;
				}
			}
		}
		else {
			for (int i = m; i >= 1; i--) {
				if (cn == c) { break; }
				if (cnt == 0 && test[h][i] % 2 == 1) {
					cnt++; a = h; b = i; cn++;
				}
				else if (cnt == 1 && test[h][i] % 2 == 1) {
					cnt = 0; cn++;
				}
			}
		}
	}
	cnt = 0; cn = 0;
	for (int h = 1; h <= n; h++) {
		if (h % 2 == 1) {
			for (int i = 1; i <= m; i++) {
				if (cn == c) { break; }
				if (cnt == 0 && test[h][i] % 2 == 1) {
					cnt++; cn++;
				}
				else if (cnt == 1 && test[h][i] % 2 == 1) {
					cnt = 0; cn++;
				}
				if (cnt == 1) { ans++; }
			}
		}
		else {
			for (int i = m; i >= 1; i--) {
				if (cn == c) { break; }
				if (cnt == 0 && test[h][i] % 2 == 1) {
					cnt++; cn++;
				}
				else if (cnt == 1 && test[h][i] % 2 == 1) {
					cnt = 0; cn++;
				}
				if (cnt == 1) { ans++; }
			}
		}
	}
	cout << ans << endl; cnt = 0; cn = 0;
	for (int h = 1; h <= n; h++) {
		if (h % 2 == 1) {
			for (int i = 1; i <= m; i++) {
				if (cn == c) { break; }
				if (cnt == 0 && test[h][i] % 2 == 1) {
					cnt++; cn++;
				}
				else if (cnt == 1 && test[h][i] % 2 == 1) {
					cnt = 0; cn++;
				}
				if (cnt == 1) {
					if (i == m) { cout << h << ' ' << i << ' ' << h + 1 << ' ' << i << endl; }
					else { cout << h << ' ' << i << ' ' << h << ' ' << i + 1 << endl; }
					ans++;
				}
			}
		}
		else {
			for (int i = m; i >= 1; i--) {
				if (cn == c) { break; }
				if (cnt == 0 && test[h][i] % 2 == 1) {
					cnt++; cn++;
				}
				else if (cnt == 1 && test[h][i] % 2 == 1) {
					cnt = 0; cn++;
				}
				if (cnt == 1) {
					if (i == 1) { cout << h << ' ' << i << ' ' << h + 1 << ' ' << i << endl; }
					else { cout << h << ' ' << i << ' ' << h << ' ' << i - 1 << endl; }
					ans++;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5596
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll a,b,c,d,e,f,A,B,ans,rs;
int i,j,k,t;
double mx;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>c>>d>>e>>f;
	a*=100,b*=100;
	for(i=0;i<=30;i++)
	{
	  if(i*a<=f)
	  {
	  	for(j=0;j<=30;j++)
	    {
	 	  A=i*a+j*b;
	      if(A<=f)
		  {
		  	 for(t=0;t<=3000;t++)
		     {
		  	    if(A+t*c<=f)
				{
				  for(k=0;k<=3000;k++)
	              {
	   	             B=t*c+k*d;
	   	             if(A+B>f)break;
	   	             if((B/e+(B%e!=0))*100<=A && (double)(100*B)/(double)(A+B)>mx)
	   	              mx=(double)(100*B)/(double)(A+B),ans=A+B,rs=B;
	              } 	
				}
	            else break;
		     }
		  }
		  else break;
	    }
	  }
	  else break;
	}
	if(!ans)cout<<a<<" "<<0<<endl;
	else cout<<ans<<" "<<rs<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,l,r) for(int i=l; i<(int)(r); i++)
#define max(l,r) (l>r?l:r)
#define min(l,r) (l<r?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;

int main(){
    char s[101010]; scanf("%s",s);
    ll n = strlen(s);
    int cnt[5] = {0};
    rep(i,n) cnt[s[i]-'a']++;

    int ok = 0;
    if(n%3 == 0){
        if(cnt[0] == cnt[1] && cnt[1] == cnt[2]) ok = 1;
    }else if(n%3 == 1){
        rep(i,3){
            if(cnt[i] == cnt[(i+1)%3] && cnt[(i+2)%3] == cnt[i]+1) ok = 1;
        }
    }else{
        rep(i,3){
            if(cnt[i] == cnt[(i+1)%3] && cnt[(i+2)%3] == cnt[i]-1) ok = 1;
        }
    }

    if(ok) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

#define MAX_V 100000
int V;
struct edge{int to, cost;};
vector<edge> G[MAX_V];

void add_edge(int from, int to, int cost){
    G[from].push_back(edge({to, cost}));
}

void add_edge2(int v1, int v2, int cost){
    add_edge(v1, v2, cost);
    add_edge(v2, v1, cost);
}

void erase_edge(int from, int to){
    vec e(0);
    REP(i, G[from].size()){
        if(G[from][i].to == to) e.push_back(i);
    }
    IREP(i, e.size()) G[from].erase(G[from].begin() + e[i]);
}

void erase_edge2(int v1, int v2){
    erase_edge(v1, v2);
    erase_edge(v2, v1);
}

int d[MAX_V], b[MAX_V];
void dijkstra(int s, int t){
    priority_queue<Pii, vector<Pii>, greater<Pii>> que;
    fill(d, d + V, INF);
    d[s] = 0; b[s] = -1;
    que.push(Pii(0, s));

    while(!que.empty()){
        Pii p = que.top(); que.pop();
        int v = p.second;
        if(v == t) return;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                b[e.to] = v;
                que.push(Pii(d[e.to], e.to));
            }
        }
    }
}

signed main(){

    int N; cin >> N; V = N;
    int A, B;
    REP(i, N - 1){
        cin >> A >> B;
        add_edge2(A - 1, B - 1, 1);
    }

    dijkstra(0, N - 1);

    vec root(1, N - 1);
    int now = N - 1;
    while(b[now] != -1){
        now = b[now];
        root.push_back(now);
    }

    REVERSE(root);
    int rootL = root.size();
    int v1 = root[(rootL - 1) / 2], v2 = root[(rootL - 1) / 2 + 1];

    erase_edge2(v1, v2);

    dijkstra(0, -1);

    int bnum = 0;
    REP(i, N) if(d[i] < INF) bnum++;
    
    if(bnum * 2 > N){
        cout << "Fennec";
    }else{
        cout << "Snuke";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k, n;
	int a[200000];
	int ans;
	cin >> k >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	sort(a, a + n);
	ans = a[1] - a[0];
	for(int i = 1;i < n - 1;i++){
		ans = max(ans, a[i + 1] - a[i]);
	}
	ans = max(ans, a[0] + k - a[n - 1]);
	cout << (k - ans) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    ll n, s;
    cin >> n >> s;
    if(n < s){
        cout << -1 << endl;
        return 0;
    }
    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }
    
    for(int i = 2; (ll)i * i <= n; ++i){
        ll x = n;
        ll S = 0;
        while(x > 0){
            S += x % i;
            x /= i;
        }
        if(S == s){
            cout << i << endl;
            return 0;
        }
    }
    vector<ll> div;
    for(int i = 1; (ll)i * i <= n - s; ++i){
        if((n - s) % i == 0){
            div.emplace_back(i);
            if((ll)i * i != n - s)  div.emplace_back((n - s) / i);
        }
    }
    sort(div.begin(), div.end());
 
    for(ll d : div){
        ll S = 0;
        ll b = d + 1;
        ll val = n;
        while(val > 0){
            S += val % b;
            val /= b;
        }
        if(S == s){
            cout << b << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3668
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        scanner.close();

        ArrayList<String> calcs = calc(n);

        ArrayList<String> result = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            result.add(calcs.get(i));
        }

        System.out.println(String.join(" ", result));

        // System.out.println(System.currentTimeMillis() - startTime);
    }

    public static ArrayList<String> calc(int count) {

        ArrayList<String> result = new ArrayList<>();

        int ptr = 0; // 得られた素数の数
        int[] prime = new int[55555]; // 素数を格納する配列

        prime[ptr++] = 2; // 素数2を登録
        prime[ptr++] = 3; // 素数3を登録

        for (int n = 5; n <= 55555; n += 2) { // 対象は奇数のみ
            boolean wflag = false; // 割り切れたかどうか
            for (int i = 1; prime[i] * prime[i] <= n; i++) {
                // 対象の数の平方根以下の全ての素数で除算する
                if (0 == n % prime[i]) { // 割り切れたら素数ではない
                    wflag = true;
                    break;
                }
            }
            if (!wflag) { // 最後まで割り切れなかったら
                prime[ptr++] = n; // 素数として新たに登録
                if ((n % 5) == 1) {
                    result.add(String.valueOf(n));
                }
            }
        }
        return result;
    }
}

Measured memory_bytes: 20948
using System;
class Program
{
	static void Main(string[] args)
	{
	    string s = Console.ReadLine();
	    int N = int.Parse(s);
	    
	    double d = 0.0;
	    string[] input = new string[N];
	    for (var i = 0; i < N; i++) {
	        input = Console.ReadLine().Split(' ');
	        if (input[1].Equals("JPY")) {
	            d += double.Parse(input[0]);
	        } else {
	            d += double.Parse(input[0]) * 380000.0;
	        }
	    }
	    
	    Console.WriteLine(d.ToString());
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

signed main(){
	int N, ans = 1;
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++){
		ans = (ans * i) % p;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
sentence = input()
s = input()

sentence = sentence+sentence

flg = True
for i in range(len(sentence)-len(s)):
    if sentence[i:i+len(s)] == s:
        print("Yes")
        flg = False
        break
    else:
        continue
        
if flg:
    print("No")


Measured memory_bytes: 6852
# coding: utf-8
target = list(input())
char_dict = {}
for s in target:
  if s in char_dict:
    char_dict[s] += 1
  else:
    char_dict[s] = 1
flag = 0
for i in char_dict.values():
  if i % 2 == 1:
    flag = 1
if flag == 0:
  print("Yes")
elif flag == 1:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ARC099C - Minimization
  // 長さNの数列A、Aは1, 2, 3, 4,…, Nを並び替えたもの
  // 2 <= K <= N <= 10^5
  // 最小値で置き換える → 全て1にする
  // 1の位置を見つけて前後に何個あるかを求める
  // cnt:1より前にある数の個数、N-cnt-1:1より後ろにある数の個数
  // 1回の操作で1にできる個数はK-1個まで→K-1で徐算
  // 除算は繰り上げするので a/b を (a+(b-1))/b とする
  // 7 3
  // 7 5 4 1 2 3 6
  // このときの答えは3（前後で分けてしまうと4）
  // 7 4
  // 7 5 4 2 3 1 6
  // このときの答えは2（前後で分けてしまうと3）
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N){
    cin >> A.at(i);
  }
  int cnt = 0; // 1より前にある数の個数
  REP(i, N){
    if(A.at(i) == 1){
      break;
    }
    cnt++;
  }
  int ans, a, b, x, y;
  a = cnt / (K - 1);
  b = cnt % (K - 1);
  x = (N-cnt-1) / (K - 1);
  y = (N-cnt-1) % (K - 1);
  if(b == 0 && y == 0){
    ans = a + x;
  }else if(b+y+1 <= K){
    ans = a + x + 1;
  }else{
    ans = a + x + 2;
  }
  cout << ans << endl;
}

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

using namespace std;

int main(void) {
  long N;
  cin >> N;
  unordered_map<long, long> left;
  unordered_map<long, long> right;
  for (long i = 0; i < N; i+=2) {
    long tmp;
    cin >> tmp;
    left[tmp]++;
    cin >> tmp;
    right[tmp]++;
  }
  long left_value_1 = 0;
  long left_count_1 = 0;
  long left_value_2 = 0;
  long left_count_2 = 0;
  long right_value_1 = 0;
  long right_count_1 = 0;
  long right_value_2 = 0;
  long right_count_2 = 0;
  for(auto it : left) {
    if (left_count_1 <= it.second) {
      left_value_2 = left_value_1;
      left_count_2 = left_count_1;
      left_value_1 = it.first;
      left_count_1 = it.second;
    } else if (left_count_2 < it.second) {
      left_value_2 = it.first;
      left_count_2 = it.second;
    }
  }
  for(auto it : right) {
    if (right_count_1 <= it.second) {
      right_value_2 = right_value_1;
      right_count_2 = right_count_1;
      right_value_1 = it.first;
      right_count_1 = it.second;
    } else if (right_count_2 < it.second) {
      right_value_2 = it.first;
      right_count_2 = it.second;
    }
  }
  if (left_value_1 != right_value_1) {
    cout << N - left_count_1 - right_count_1 << endl;
    return 0;
  }
  if (left_count_1 + right_count_2 < left_count_2 + right_count_1) {
    cout << N - left_count_2 - right_count_1 << endl;
    return 0;
  }
  cout << N - left_count_1 - right_count_2 << endl;
  return 0;
}


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

int main() {
  int n, l, r;
  cin >> n;
  int count = 0;
  int i;
  for (i = 0; i < n; i++) {
    cin >> l >> r;
    count += r - l + 1;
  }
  cout << count << endl;
  return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long a;
  scanf("%lld", &a);
  long long b;
  scanf("%lld", &b);

  ll ans = a + b;
  chmax(ans, a - b);
  chmax(ans, a * b);
  cout << ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[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]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
n, m=map(int, input().split())
l = [[] for _ in range(n+1)]
pl=list()
cnt=0
for _ in range(m):
  p, s=map(str, input().split())
  l[int(p)].append(s)
for i in range(1, n+1):
  pen=0
  for h in l[i]:
    if h=="AC":
      cnt+=1
      pl.append(pen)
      break
    else:
      pen+=1
      continue
print(cnt, sum(pl))
    
                 

Measured memory_bytes: 26264
#include<iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b)
{
    return b ? gcd(b, a % b) : a;
}

int main(){
    int k;
    cin >> k;
    ll sum = 0;
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < k; j++)
        {
            for (int l = 0; l < k; l++)
            {
                sum += gcd(gcd(i+1, j+1), l+1);
            }
        }
        
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>



using namespace std;

void printarray(vector<int> &a, int n) {
  for (int i = 0; i < n - 1; i++) {
    cout << a[i] << " ";
  }
  cout << a[n - 1] << endl;
}

int main() {
  int n;
  vector<int> a(100);
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  printarray(a, n);
  for (int i = 1; i < n; i++) {
    int key = a[i];
    int j;
    for (j = i - 1; j >= 0 && a[j] > key; j--) {
      a[j + 1] = a[j];
    }
    a[j + 1] = key;
    printarray(a, n);
  }
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int X[100005];

int main() {
  int n;
  S(n);
  while(n--) {
    int l,r;
    S2(l,r);
    X[r+1]--;
    X[l]++;
  }
  int ans = 0;
  rep(i,1,100005) {
    X[i] += X[i-1];
    ans += X[i] > 0;
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,K;
	cin>>N>>K;
	cout<<N-K+1<<endl;
	
}

Measured memory_bytes: 764
H, W, M = map(int, input().split())
bombs_h = [0] * H
bombs_w = [0] * W
B = []
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    B.append((h, w))
    bombs_h[h] += 1
    bombs_w[w] += 1

max_h = max(bombs_h)
max_w = max(bombs_w)
hs = [i for i, x in enumerate(bombs_h) if x == max_h]
ws = [i for i, x in enumerate(bombs_w) if x == max_w]
k = len(hs)*len(ws)
cnt = 0
for h, w in B:
    if bombs_h[h] == max_h and bombs_w[w] == max_w:
        cnt += 1
ans = max_w + max_h - (cnt == k)
print(ans)

Measured memory_bytes: 77780
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    int K[N];
    for(int i=1;i<N;i++)K[i]=0;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            int m;
            m=min(j-i,min(abs(X-i)+1+abs(Y-j),abs(Y-i)+1+abs(X-j)));
            K[m]++;
        }
    }
    for(int i=1;i<N;i++)cout<<K[i]<<endl;
}


Measured memory_bytes: 3604
s = input()

frommap = []
for d in range(10):
    frommap.append([0] * 13)
    for m in range(13):
        m2 = (m * 10 + d) % 13
        frommap[d][m2] = m

dp = [1] + [0] * 12
for c in s:
    if c == '?':
        dp = [sum(dp[f] for f in fromlist) % 1000000007 for fromlist in zip(*frommap)]
    else:
        f = frommap[int(c)]
        dp = [dp[f[m]] for m in range(13)]

print(dp[5])

Measured memory_bytes: 3188
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <iostream>
#include <vector>
using namespace std;


int main(){
	int n;
	cin >> n;
	long long MARCH[5] = {0};

	string tmp;
	for (int i = 0; i < n; ++i){
		cin >> tmp;
		if (tmp[0] == 'M'){
			++MARCH[0];
		}
		else if(tmp[0] == 'A'){
			++MARCH[1];
		}
		else if(tmp[0] == 'R'){
			++MARCH[2];
		}
		else if(tmp[0] == 'C'){
			++MARCH[3];
		}
		else if(tmp[0] == 'H'){
			++MARCH[4];
		}
	}

	long long total = 0;
	for(int i=0; i<3; ++i){
		for(int j=i+1; j<4; ++j){
			for(int k=j+1; k<5; ++k){
				total += MARCH[i]*MARCH[j]*MARCH[k];
			}
		}
	}

	cout << total << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int K, X;
    cin >> K >> X;

    if(500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#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(){
	string s, t, u;
  	int a, b;
  	cin >> s >> t >> a >> b >> u;
  
  	if(u == s) a--;
  	else b--;
  	cout << a << " " << b << endl;
}

Measured memory_bytes: 3580
while(1):
    e = int(input())
    if e == 0:
        break
    m, z = 10 ** 15, 0
    while z**3 <= e:
        y = int((e - z**3) ** 0.5)
        x = e - z**3 - y ** 2
        m = min(m, x + y + z)
        z += 1
    print(m)


Measured memory_bytes: 5724
import sys
sys.setrecursionlimit(4100000)

x = int(input())
a = 1
ans = 0 
while a >= 0:
    if x >= 500:
        x -= 500
        ans += 1000
    else:
        break
while a >= 0:
    if x >= 5:
        x -= 5
        ans += 5
    else:
        break
print(str(ans))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

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

cNtN = [[0] * 2 for i in range(N)]
for i in range(N):
    cNtN[i][0], cNtN[i][1] = map(int, input().split())

min_c = float('inf')
for i in range(N):
    if cNtN[i][1] <= T and cNtN[i][0] < min_c:
        min_c = cNtN[i][0]

if min_c == float('inf'):
    print('TLE')
else:
    print(min_c)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

typedef struct{
    char a[1];
    int n;
}card;

int main(){
    int i, j, k;
    int N;
    int nmin, ans=0;
    card C1[200], C2[200];
    card tmp;

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%1s%d", &C1[i].a, &C1[i].n);
        C2[i] = C1[i];
        //printf("%1s%d ", C1[i].a, C1[i].n);
    }

    for(i=0; i<N; i++){
        for(j=N-1; j>i; j--){
            if(C1[j].n<C1[j-1].n){
                tmp = C1[j];
                C1[j] = C1[j-1];
                C1[j-1] = tmp;
            }
        }
    }

    for(i=0; i<N-1; i++){
        nmin = i;
        for(j=i+1; j<N; j++){
            if(C2[j].n<C2[nmin].n){
                nmin = j;
            }
        }
        if(i!=nmin){
            tmp = C2[i];
            C2[i] = C2[nmin];
            C2[nmin] = tmp;
        }
    }

    for(i=0; i<N; i++){
        if(i>0){
            printf(" ");
        }
        printf("%s%d", C1[i].a, C1[i].n);
    }
    printf("\nStable\n");

    for(i=0; i<N; i++){
        if(i>0){
            printf(" ");
        }
        printf("%s%d", C2[i].a, C2[i].n);
    }
    printf("\n");

    for(i=0; i<N; i++){
        //printf("%s%s\n", C1[i].a, C2[i].a);
        if(strcmp(C1[i].a, C2[i].a)){
            ans = 1;
        }
    }
    if(ans == 0){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    return 0;
}


Measured memory_bytes: 2080
fun main(args: Array<String>) {
    val (h, w, k) = readIntList()
    val c = MutableList(h) { "0" }

    for (i in 0 until h) {
        c[i] = readString()
    }

    var ans = 0
    for (maskR in 0 until (1 shl h)) {
        for (maskC in 0 until (1 shl w)) {
            var black = 0
            for (i in 0 until h) {
                for (j in 0 until w) {
                    if (((maskR shr i) and 1) == 0 && ((maskC shr j) and 1) == 0 && c[i][j] == '#') {
                        black++
                    }
                }
            }
            if (black == k) {
                ans++
            }
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

 int main() {
 int N, X; cin >> N >> X;
 vector<int> D(N + 1);
 D[0] = 0;
 for (int i = 0; i < N; ++i) {
 int x; cin >> x;
 D[i + 1] = D[i] + x;
 }
 int ans = 0;
 for (int i = 0; i <= N; ++i) {
 if (D[i] <= X) {
 ans++;
 }
 }
 cout << ans << endl;
 return 0;
 }

Measured memory_bytes: 256
s = input()
op = ['+', '-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            t = ''.join([s[0], op[i], s[1], op[j], s[2], op[k], s[3]])
            if eval(t) == 7:
                print(t + '=7')
                quit()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n, x; cin >> n >> x;
	V v(n); input(v);
	int ans = 0;
	rep(i, 0, n - 1) {
		int sum = v[i] + v[i + 1];
		if (sum > x) {
			ans += max(0ll, sum - x);
			v[i + 1] = max(0ll, v[i + 1] - (sum - x));
		}
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     PI                       acos(-1)
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=0;
string st;
int main(){
    GO();
    cin>>st;
    if(st[2]==st[3]&&st[4]==st[5]){
        cout<<"Yes\n";

    }
    else{
        cout<<"No\n";

    }
}












































































































Measured memory_bytes: 256
/*---------------------------------------------*/
/*
    ABC177 D
 */
/*---------------------------------------------*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }
const int64_t INF = 0x3fffffffffffffff;

std::vector<int64_t> do_look(200000, 0);

int64_t bfs ( Graph G , int64_t start_num ) {
    std::vector<int64_t> seen(G.size(), 0);
    queue<int64_t> q;
    q.push(start_num);
    int64_t ans = 1;
    while ( !q.empty() ) {
        int64_t num = q.front();
        seen[num] = 1;
        q.pop();
        // rep(i, G[num].size())
        for (auto&(see) : (G[num])) {
            // int64_t see = G[num].at(i);
            if ( seen[see] == 0 ) {
                q.push(see);
                seen[see] = 1;
                do_look[see] = 0;
                ans++;
            }
        }
    }
    return ans;
}

void func( Graph G ) {
    int64_t ans = 0, num;
    int64_t n = G.size();
    std::vector<int64_t> seen(n, 0);
    queue<int64_t> q;
    rep(i, n) {
        if (seen[i]) continue;
        seen[i] = 1, num = 0;
        q.push(i);
        while ( !q.empty() ) {
            int64_t see = q.front();
            q.pop();
            ++num;
            rep(j, G[see].size()) {
                int64_t next = G[see].at(j);
                if ( !seen[next] ) {
                    q.push(next);
                    seen[next] = 1;
                }
            }
        }
        chmax(ans, num);
    }
    cout << ans << endl;
}

int main() {
    int64_t n, m;
    cin >> n >> m;
    Graph G(n);
    std::vector<int64_t> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        do_look[a[i]] = 1;
        do_look[b[i]] = 1;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    func(G);
    // std::vector<int64_t> v;
    /*
    int64_t ans = 0;
    rep(i, n) {
        /*
        if ( do_look[i] == 1 ) {
            // int64_t num = bfs(G, i);
            // v.push_back( num );
            chmax(ans, bfs(G, i));
            if ( ans >= n/2 ) break;
        }
        if ( !do_look[i] ) continue;
        chmax(ans, bfs(G, i));
        if ( ans >= n/2 ) break;
    }

    // if (v.empty()) v.push_back(n);
    // cout << *max_element(ALL(v)) << endl;
    cout << ans << endl;
    */
    return 0;
}


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

int main(){
	long long a,b,x;
	cin>>a>>b>>x;
	long long r1 = a%x;
	long long r2 = b%x;
	a-=r1;
	b-=r2;
	if(r1) cout<<(b/x-a/x);
	else cout<<(b/x-a/x)+1;	
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	//a := make([]int, N)
	min := 1001001001
	max := 0
	for i := 0; i < N; i++ {
		a := getInt()
		if a > max {
			max = a
		}
		if a < min {
			min = a
		}
	}

	out(max - min)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll D;
  cin >> D;
  string ans = "Christmas";
  REP(i, 25-D){
    ans += " Eve";
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
N = int(input())
X = []
for i in range(N):
  X.append(list(map(int, input().split())))
  
cnt = 0
for j in range(N,0,-1):
  A = X[j-1][0] + cnt
  B = X[j-1][1]
  if A%B != 0:
    cnt += B - A%B
    
print(cnt)

Measured memory_bytes: 62552
#include<stdio.h>
#include<math.h>

int main(void)
{
  int x;
  scanf("%d",&x);
  if(x==1){
    puts("1");
    return 0;
  }
  int max=0;
  for(double i=1;i<=x;i++){
    for(double j=2;j<=x;j++){
      // printf("%lf\n",pow(i,j));
      if(pow(i,j)>max&&pow(i,j)<=x){
        max=pow(i,j);
      }
    }
  }

  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int n;
  cin>>n;
  vector<int> vec(n-1);
  rep(i,n-1){
    cin>>vec[i];
  }
  int sum=vec[0]+vec[vec.size()-1];
  for(int i=0;i<vec.size()-1;i++){
    int right=vec[i];
    int left=vec[i+1];
    sum+=min(right,left);
  }
  cout<<sum<<endl;
  
  
  
}

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

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

int main() {
    int yen, t = 0;
    while (cin >> yen && yen) {
        if (t) cout << endl;
        else t = 1;
        int c[4], sum = 0, b[] = {10, 50, 100, 500};
        rep(i, 4) {
            cin >> c[i];
            sum += c[i];
        }
        int minc = 20*4+1;
        int a1, a2, a3, a4;
        for (int c1 = 0; c1 <= c[0]; ++c1) {
            for (int c2 = 0; c2 <= c[1]; ++c2) {
                for (int c3 = 0; c3 <= c[2]; ++c3) {
                    for (int c4 = 0; c4 <= c[3]; ++c4) {
                        int en = c1*10+c2*50+c3*100+c4*500;
                        int t = sum-(c1+c2+c3+c4);
                        if (en == yen) {
                            if (minc > t) {
                                minc = t;
                                a1 = c1; a2 = c2; a3 = c3; a4 = c4;
                            }
                        }
                        else if (yen < en) {
                            int md = en-yen;
                            int u = 0;
                            for (int i = 3; i >= 0; --i) {
                                if (md/b[i]) {
                                    u += md/b[i];
                                    md -= (md/b[i])*b[i];
                                }
                            }
                            if (minc > t+u) {
                                minc = t+u;
                                a1 = c1; a2 = c2; a3 = c3; a4 = c4;
                            }
                        }
                    }
                }
            }
        }
        if (a1) cout << "10 " << a1 << endl;
        if (a2) cout << "50 " << a2 << endl;
        if (a3) cout << "100 " << a3 << endl;
        if (a4) cout << "500 " << a4 << endl;
    }
}

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int N;

int main()
{
    cin >> N;
    rrep(h,3500){
        rrep(n,3500){
            ll bunshi = (ll)N*n*h;
            ll bunbo = (ll)(4*h*n) - (ll)(N*n) - (ll)(N*h);
            if(bunbo <= 0) continue;
            if(bunshi % bunbo == 0){
                cout << h << " " << n << " " << bunshi/bunbo << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
if b - a + 1 <= 2 * k:
    result = ([i for i in range(a, b + 1)])
else:
    result = ([i for i in range(a, a + k)] + [i for i in range(b - k + 1, b + 1)])
for i in result:
    print(i)

Measured memory_bytes: 3060
'''
Contest 177 - Task B


'''
def count_changed_chars(a, b):
    ans = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            ans += 1
    return ans

if __name__ == "__main__":
    haystack = input()
    needle = input()

    dists = []
    for i in range(len(haystack) - len(needle) + 1):
        sub = haystack[i : i+len(needle)]
        dists.append(count_changed_chars(sub, needle))
    print(min(dists))




Measured memory_bytes: 9084
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
 
int main(){
    
    int n,z,w,a[3333];
    int ke[3333]={0};
    cin>>n>>z>>w;
    for(int i=0;i<n;i++)cin>>a[i];
   if(abs(a[n-1]-a[n-2])>abs(a[n-1]-w))cout<<abs(a[n-1]-a[n-2])<<endl;
   else cout<<abs(a[n-1]-w)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

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

    vector<int> sums(n +1, 0);
    for (int i = 1; i < n +1; i++) {
        sums[i] = sums[i - 1] + points[i - 1];
    }

    for (int i = 0; i < n; i++) {
        int l = sums[i];
        int r = sums[n] - sums[i + 1];

        if (k - l - r <= 0) {
            cout <<"No" << endl;
        } else {
            cout <<"Yes" <<endl;
        }
    }
}


Measured memory_bytes: 1408