akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main(){
    int N;
    cin >> N;
    if (N < 10) {
        cout << N << endl;
        return 0;
    }
    int keta = log10(N)+1;
    if (keta % 2 == 1){
        string hiku;
        for(int i = 0; i < keta-2; i+=2){
            hiku += "90";
        }
        cout << N - stoi(hiku) << endl;
    }
    else {
        string ans = "9";
        for (int i = 0; i < keta-2; i+=2){
            ans = "90" + ans;
        }
        cout << stoi(ans) << endl;
    }
}


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

//temmplate------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
#define ZERO(a) memset(a, 0, sizeof(a))
typedef long long lint;
//------template

int main(){
    string S;
    cin >> S;
    string Xs = "";
    REP(i,S.length()){
        Xs += "x";
    }
    cout << Xs << '\n';
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		char[][] a = new char[h + 2][w + 2];
		for (int i = 1; i <= h; i++) {
			String s = br.readLine();
			for (int j = 1; j <= w; j++) {
				a[i][j] = s.charAt(j - 1);
			}
		}
		br.close();
		a[1][0] = '#';
		a[h][w + 1] = '#';

		boolean ans = true;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (a[i][j] == '#') {
					if (a[i + 1][j] == '#' && a[i][j + 1] != '#'
							|| a[i + 1][j] != '#' && a[i][j + 1] == '#') {
					} else {
						ans = false;
						break;
					}
					if (a[i - 1][j] == '#' && a[i][j - 1] != '#'
							|| a[i - 1][j] != '#' && a[i][j - 1] == '#') {
					} else {
						ans = false;
						break;
					}
				}
			}
		}
		if (ans) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
  int i;
  
  while(1){
    char x[1001];
    int sum = 0;
    int re; //??°?????????????????´  
    
    scanf("%s",x);

    if((x[0] == '0') && (x[1] == '\0')) //??????0????????????
      break;
    
    for(i=0; (!(x[i])) == '\0'; i++){ //??????????????????????????§?????????
      re = x[i] - '0'; //??°?????¨?????????????????????
      sum = sum + re; //????¨?????????????
    }
    
    printf("%d\n",sum);
  }

  return(0);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }else if(S == "Cloudy") {
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
    time = [x for x in t]
    time[p[i][0] - 1] = p[i][1]
    print(sum(time))


Measured memory_bytes: 9116
#include <iostream>
#include <array>
#include <map>

using int64 = long long;

template <typename Int, Int MOD, int N>
struct comb_util {
    std::array<Int, N + 1> fc, ifc;

    comb_util() {
        fc[0] = 1;
        for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
        ifc[N] = inv(fc[N]);
        for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
    }

    Int fact(Int n) { return fc[n]; }

    Int inv_fact(Int n) { return ifc[n]; }

    Int inv(Int n) { return pow(n, MOD - 2); }

    Int pow(Int n, Int a) {
        Int res = 1, exp = n;
        for (; a; a /= 2) {
            if (a & 1) res = res * exp % MOD;
            exp = exp * exp % MOD;
        }
        return res;
    }

    Int perm(Int n, Int r) {
        if (r < 0 || n < r)
            return 0;
        else
            return fc[n] * ifc[n - r] % MOD;
    }

    Int binom(Int n, Int r) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
    }

    Int homo(Int n, Int r) {
        if (n < 0 || r < 0) return 0;
        return r == 0 ? 1 : binom(n + r - 1, r);
    }
};

using comb = comb_util<long long, 1000000007, 3000000>;

std::map<int, int> factorize(int N) {
    std::map<int, int> res;

    for (int n = 2; n * n <= N; n++) {
        while (N % n == 0) {
            res[n]++;
            N /= n;
        }
    }
    if (N != 1) res[N]++;
    return res;
}

constexpr int64 mod = 1e9 + 7;

int main() {
    int N, M;
    std::cin >> N >> M;

    auto f = factorize(M);
    int64 ans = 1;

    static comb co;
    for (auto& mp : f) {
        (ans *= co.homo(N, mp.second)) %= mod;
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 47104
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

q = [0] * N
start = -1
end = 0
for i in range(N):
    q[i] = A[i] * F[i]
    end = max(end, q[i])

def check(now, K):
    cnt = 0
    for i in range(N):
        if q[i] - now > 0:
            cnt += (q[i] - now + F[i] - 1) // F[i]
            if cnt > K:
                return False
    return True

now = end // 2
while end > start + 1:
    if check(now, K):
        end = now
    else:
        start = now
    now = (start + end) // 2

print(end)


Measured memory_bytes: 119756
#include <stdio.h>

int main(void)
{
	int x;
	int i = 0;
	for( i=0; i<10000; i++ )
	{
		scanf("%d", &x);
		if( x<1 || x>10000)
		{
			return 1;
		}
		if( x == 0 )
		{
			break;
		}

		printf("Case %d: %d\n", i+1, x);
	}
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct SegmentTree {
  vint data;
  vint lazy;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz *= 2;
    resz(data, 2*sz-1);
    rep(i, sz) data[i+sz-1] = i+1;
    for(int i = sz-2; i >= 0; --i) {
      data[i] = max(data[2*i+1], data[2*i+2]);
    }
    resz(lazy, 2*sz-1, -1);
  }
  void push(int k, int l, int r) {
    if(~lazy[k]) {
      chmax(data[k], lazy[k]);
      if(r-l > 1) {
	chmax(lazy[2*k+1], lazy[k]);
	chmax(lazy[2*k+2], lazy[k]);
      }
      lazy[k] = -1;
    }
  }
  void update(int a, int b, int x, int k, int l, int r) {
    push(k, l, r);
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      chmax(lazy[k], x);
      push(k, l, r);
      return;
    }
    update(a, b, x, 2*k+1, l, (l+r)/2);
    update(a, b, x, 2*k+2, (l+r)/2, r);
    data[k] = max(data[2*k+1], data[2*k+2]);
  }
  void update(int a, int b, int x) {
    update(a, b, x, 0, 0, sz);
  }
  int query(int a, int b, int k, int l, int r) {
    push(k, l, r);
    if(r <= a || b <= l) return -1;
    if(a <= l && r <= b) return data[k];
    int vl = query(a, b, 2*k+1, l, (l+r)/2);
    int vr = query(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
  int query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m, q;
  cin >> n >> m >> q;
  vint d(m), a(m), b(m);
  rep(i, m) cin >> d[i] >> a[i] >> b[i], --a[i];
  vint e(q), s(q), t(q);
  rep(i, q) cin >> e[i] >> s[i] >> t[i], --s[i];
  vector<Tapris> vec;
  rep(i, m) vec.emplace_back(d[i], 1, a[i], b[i], i);
  rep(i, q) vec.emplace_back(e[i], 0, s[i], t[i], i);
  sort(all(vec));
  SegmentTree seg(n);
  vector<string> ans(q);
  rep(i, vec.size()) {
    int v, w, x, y, z;
    tie(v, w, x, y, z) = vec[i];
    if(w == 0) {
      if(x+1 >= y) {
	ans[z] = "Yes";
	continue;
      }
      int mr = seg.query(x, x+1);
      int tmp = seg.query(x, mr);
      while(mr != tmp) {
	mr = tmp;
	tmp = seg.query(x, mr);
      }
      ans[z] = (mr >= y ? "Yes" : "No");
      seg.update(x, mr, mr);
    } else {
      seg.update(x, y, y);
    }
  }
  rep(i, ans.size()) cout << ans[i] << endl;

  return 0;
}



Measured memory_bytes: 24956
x1,y1,x2,y2=map(int,input().split())
dx=(x2-x1)
dy=(y1-y2)
x3=x2+dy
y3=y2+dx
x4=x1+dy
y4=y1+dx
print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 8848
n = gets.chomp.to_i
pn = gets.chomp.split(" ").map(&:to_i)
num = 0
minimum = n
for i in 0..n-1 do
  num += 1 if pn[i] <= minimum
  minimum = pn[i] if pn[i] < minimum
  break if minimum == 1
end
print num

Measured memory_bytes: 16516
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  int flag=0;
 for(int i=1;i<10;i++){
  if(N/i<10&&N%i==0){
     flag=1;
  }
 }
   if(flag){
     cout<<"Yes"<<endl;
   }else{
     cout<<"No"<<endl;
   }
 return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
    fasterthanlight;
    int n;
    cin >> n;
    int arr[n][2];
    for (int i = 0; i < n; i++)
        cin >> arr[i][0];
    for (int i = 0; i < n; i++)
        cin >> arr[i][1];
    int c[n - 1];
    for (int i = 1; i < n; i++)
    {
        cin >> c[i - 1];
    }
    int sum = 0; int prev = -2;
    for (int i = 0; i < n; i++)
    {
        //cout << arr[i][0]

        if (arr[i][0] == prev + 1)
            sum += (arr[arr[i][0] - 1][1]) + c[prev - 1];
        else
            sum += (arr[arr[i][0] - 1][1]);
        prev = arr[i][0];
        //  cout << prev<<" " << endl;
    }
    cout << sum << endl;
    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ull X, Y;
    int ans = 0;
    cin >> X >> Y;
    for(ll i = X; i <= Y; i *= 2)
        ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#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;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
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;
}

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

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

    int h, w, k, sx, sy, tx, ty;
    cin >> h >> w >> k >> sx >> sy >> tx >> ty;
    --sx, --sy, --tx, --ty;
    // cerr << sx << ' ' << sy << ' ' << tx << ' ' << ty << endl;
    vector<string> s(h);
    for(int i = 0; i < h; ++i)  cin >> s[i];

    vector<vector<int>> dist(h, vector<int>(w, INF));
    dist[sx][sy] = 0;
    using T = tuple<int, int, int>;
    priority_queue<T, vector<T>, greater<T>> que;
    que.push(T(0, sx, sy));
    while(!que.empty()){
        T tup = que.top();
        que.pop();
        int d, x, y;
        tie(d, x, y) = tup;
        if(d > dist[x][y])  continue;
        for(int i = 0; i < 4; ++i){
            int nx = x, ny = y;
            for(int j = 0; j < k; ++j){
                nx += dx[i], ny += dy[i];
                if(nx < 0 || nx >= h || ny < 0 || ny >= w)  break;
                if(s[nx][ny] == '@')    break;
                if(dist[nx][ny] < dist[x][y] + 1)   break;
                if(chmin(dist[nx][ny], dist[x][y] + 1)){
                    que.push(T(dist[nx][ny], nx, ny));
                }
            }
        }
    }
    // for(int i = 0; i < h; ++i){
    //     for(int j = 0; j < w; ++j){
    //         if(dist[i][j] == INF)   cerr << -1 << ' ';
    //         else    cerr << dist[i][j] << ' ';
    //     }
    //     cerr  << endl;
    // }
    int ans = dist[tx][ty];
    if(ans == INF)  ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 12180
'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const nums = input[0].split(' ').map(v => parseInt(v, 10));
  const N = nums[0];
  const K = nums[1];
  const S = input[1];

  let ans;
  
  console.log(S.slice(0, K - 1) + S[K - 1].toLowerCase() + S.slice(K));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    const ll INIT = -1L * (1L<<60);
    const ll INF = 1L<<60;

    ll n,m,p;
    cin >> n >> m >> p;
    vector<vector<pair<ll,ll>>> edge(n+1,vector<pair<ll,ll>>()); // [from] first=to second=cost

    REP(i,m) {
        ll a,b,c;
        cin >> a >> b >> c;
        edge[a].emplace_back(make_pair(b,c-p));
    }

    vector<ll> score(n+1,INIT);
    vector<bool> visit(n+1,false);
    visit[1] = true;
    score[1] = 0;
    
    REP(i,n*2) {
        FOR(j,1,n+1) {
            if (visit[j]) {
                for (auto x:edge[j]) {
                    if (!visit[x.first]) {
                        visit[x.first] = true;
                        score[x.first] = score[j] + x.second;
                    } else {
                        if (score[x.first] < score[j] + x.second) {
                            if (i > n-1) {  // Bellman-Ford negative loop
                                score[x.first] = INF;
                            } else {
                                score[x.first] = score[j] + x.second;
                            }
                        }
                    }
                }
            }
        }
    }

    if (score[n] == INF) {
        cout << -1 << endl;
    } else {
        cout << (score[n] < 0 ? 0 : score[n]) << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
const LL mod = 1e9 + 7;
int H, W, K;
LL dp[110][9];
LL fac[10] = {1, 1};
int main(){
	cin >> H >> W >> K;
	dp[1][1] = 1;
	fac[1] = 1;
	for(int i = 2; i <= W; i++){
		fac[i] = fac[i - 1] + fac[i - 2];
	}
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			dp[i + 1][j] += dp[i][j] * fac[j - 1] * fac[W - j];
			dp[i + 1][j + 1] += dp[i][j] * fac[j - 1] * fac[max(0, W - j - 1)];
			dp[i + 1][j - 1] += dp[i][j]* fac[max(0, j - 2)] * fac[W - j];
			dp[i + 1][j] %= mod;
			dp[i + 1][j + 1] %= mod;
			dp[i + 1][j - 1] %= mod;
		}
	}
	cout << dp[H + 1][K] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=100005;
int n,a[N],ans,inv[N],sum,tmp,pre[N],jc;
void up(int &x,int y){x=x-mod+y;x=(x<0)?x+mod:x;}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	inv[0]=inv[1]=pre[1]=1;jc=1;
	for (int i=2;i<=n;i++) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jc=(ll)jc*i%mod,pre[i]=((ll)pre[i-1]+inv[i])%mod;
	for (int i=1;i<=n;i++)
	{
		int tmp=0;up(tmp,pre[i]);up(tmp,pre[n-i+1]);
		up(ans,(ll)(tmp-1)*a[i]%mod);
	}
	printf("%d\n",(ll)ans*jc%mod);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;

    pair<long long, long long> a[55], b[55];
    rep(i,n){
        long long x, y;
        cin >> x >> y;
        a[i] = make_pair(x,y);
    }
    rep(i,m){
        long long x, y;
        cin >> x >> y;
        b[i] = make_pair(x,y);
    }

    rep(i,n){
        long long mini = INF, ans;
        rep(j,m){
            long long dis = abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
            if(mini > dis){
                mini = dis;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	vector< pair<int, int> > v;
	stack< pair<int, int> > s;
	while (M--) {
		int x, y;
		cin >> x >> y;
		v.push_back(make_pair(x, y));
	}
	sort(v.begin(), v.end());

	stack<int> deletes;
	stack<int> mins;

	for (auto p : v) {
		if (s.empty()) {
			s.push(p);
			mins.push(p.second);
		} else if (p.first >= mins.top()) {
			int t = s.top().first;
			deletes.push(t);
			if (s.top().second == mins.top()) mins.pop();
			s.pop();
			while (!s.empty() && t >= s.top().first) {
				if (s.top().second == mins.top()) mins.pop();
				s.pop();
			}
			s.push(p);
			if (mins.empty() || p.second <= mins.top()) mins.push(p.second);
		} else {
			s.push(p);
			if (mins.empty() || p.second <= mins.top()) mins.push(p.second);
		}
	}
	while (!s.empty()) {
		int t = s.top().first;
		deletes.push(t);
		s.pop();
		while (!s.empty() && t >= s.top().first && t < s.top().second) {
			s.pop();
		}
	}
	cout << deletes.size() << "\n";
}

Measured memory_bytes: 1400
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul

mod = 10 ** 9 + 7
sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

n = I()
A = LI()
max_ret = 0
min_ret = 0
max_arr = [0] * (n + 1)
min_arr = [0] * (n + 1)
for i in range(n, -1, -1):
    max_ret = max_ret + A[i]
    min_ret = (min_ret + 1) // 2 + A[i]
    max_arr[i] = max_ret
    min_arr[i] = min_ret

if max_ret >= 1 >= min_ret:
    ans = 1
    ret = 1 - A[0]
    for j in range(1, n + 1):
        ret = min(ret * 2, max_arr[j])
        ans += ret
        ret -= A[j]
    print(ans)
else:
    print(-1)








Measured memory_bytes: 95880
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

int sq(int n){
  return n*n;
}

int32_t main(){
    
  fast;
  int n,d; cin >> n >> d;
  int cnt = 0;
  for(int i=1;i<=n;i++){
    int x,y; cin >> x >> y;
    int dis = sq(x)+sq(y);
    if(dis<=sq(d)) cnt++;
  }

  cout << cnt << '\n';

  

  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(13<=a){
      System.out.println(b);
    }else if(6<=a && a<=12){
      System.out.println(b/2);
    }else {
      System.out.println(0);
    }
    sc.close();
  }
}
    

Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
 
const int MAXN = 2004; //1e5+3;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a;
    cin>>b;
    int n1=a.length();
    int n2=b.length();
    vector<vector<int>> dp(n1+1,vector<int> (n2+1,0));
    for(int i=1;i<=n1;i++){
        for(int j=1;j<=n2;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int len=dp[n1][n2];
    int i=n1;
    int j=n2;
    string ans="";
    while(i>0 and j>0){
        if(a[i-1]==b[j-1]){
            ans+=a[i-1];
            i--;
            j--;
            
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    if(ans!="")reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>

int main()
{
	int i, a[6];
	for (i = 0; i <= 5; i++) scanf("%d", &(a[i]));
	if (a[4] - a[0] <= a[5]) printf("Yay!\n");
	else printf(":(\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1652
def culc(x):
    a = x % 10
    b = x
    while x:
        b = x
        x //= 10
    return a, b

n = int(input())
l = [[0 for i in range(9)] for j in range(9)]
ans = 0

for i in range(1,n+1):
    a,b = culc(i)
    if a != 0 and b != 0:
        l[a-1][b-1] += 1

for i in range(1,n+1):
    a,b = culc(i)
    if a != 0 and b != 0:
        ans += l[b-1][a-1]
print(ans)

Measured memory_bytes: 40924
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    ans = False
    p = 0
    for i in range(N):
        D = list(map(int, input().split()))
        if D[0] == D[1]:
            p += 1
        else:
            p = 0
        if p == 3:
            ans = True
            break
    if ans:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61792
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        multimap<int,bool> m;
        int ret=0,hh,mm,ss,tmp;

        for(int i=0;i<n;i++){
            for(int j=0;j<2;j++){
                cin >> hh;
                cin.ignore();
                cin >> mm;
                cin.ignore();
                cin >> ss;
                tmp = hh * 3600 + mm * 60 + ss;
                if(j == 0){
                    m.insert(make_pair(tmp, true));
                }else{
                    m.insert(make_pair(tmp, false));
                }
            }
        }
        multimap<int,bool>::iterator it = m.begin(),jt;
        tmp = 0;
        while(it != m.end()){
            if((*it).second){
                tmp++;
            }else{
                tmp--;
            }
            jt = it;
            ++jt;
            if(jt == m.end() || (*jt).first != (*it).first){
                ret = max(ret, tmp);
            }
            ++it;
        }
        cout << ret << endl;
    }
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int index=0;
    for(int i = 0; i < n; i++) {
        if(a[i]==index+1) index++; 
    }
    cout << ( index == 0 ? -1 : n-index ) << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        double ans = 0;
        for (int i = 0; i < N; i++) {
            double a = scanner.nextDouble();
            String s = scanner.next();
            if (s.startsWith("J")) {
                ans += a;
            } else {
                ans += a * 380000;
            }
        }
        System.out.println(ans);
    }

}



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

string s ;
char t[] = {'y','u','i','o','p','h','j','k','l','n','m'} ;

int main(){
	
	while( cin >> s ){
		if( s[0] == '#' ) break ;
		
		int ans = 0 ;
		int x,j ;
		for( int i=0 ; i<s.size() ; i++ ){
			for( j=0 ; j<12 ; j++ ){
				if( s[i] == t[j] ) break ;
			}
			if( i==0 ){
				if( j==12 ) x = -1 ;
				else x = 1 ;
			}else{
				if( j==12 && x==1 ){
					ans++ ;
					x = -1 ;
				}
				else if( j!=12 && x==-1  ){
					ans++ ;
					x = 1 ;
				}
			}
		}
		cout << ans << endl ;
	}
	
return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int SIZE = 181 + 1;
const int MAX = 1000000;

int T[SIZE];
int cost1[MAX], cost2[MAX];

int main( void )
{	
	for(int i=0; i < SIZE; ++i) T[i] = i * (i + 1) * (i + 2) / 6;

	for(int i=0; i < MAX; ++i) cost1[i] = cost2[i] = MAX << 1;
	cost1[0] = cost2[0] = 0;
	for(int i=0; i < MAX; ++i) {
			for(int j=0; j < SIZE; ++j) {
				if(i + T[j] < MAX && cost1[i] < 5)
					cost1[i + T[j]] = min(cost1[i + T[j]], cost1[i] + 1);
				if(T[j] & 1) {
					if(i + T[j] < MAX)
						cost2[i + T[j]] = min(cost2[i + T[j]], cost2[i] + 1);
				}
			}
	}
	int n;
	while(cin >> n, n) {
		cout << cost1[n] << ' ' << cost2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

template <typename Operator>
struct SegmentTree {
    Operator OP;
    using TypeNode = decltype(OP.NodeE);
    int length, num;
    vector<TypeNode> node;
    SegmentTree (int N) {
        num = N;
        length = 1;
        while (length < N) length <<= 1;
        node.assign(length << 1, OP.NodeE);
    }
    SegmentTree (vector<TypeNode> &vec) {
        num = SZ(vec);
        length = 1;
        while (length < vec.size()) length <<= 1;
        node.assign(2 * length, OP.NodeE);
        for (int i = 0; i < vec.size(); ++i) node[i + length] = vec[i];
        for (int i = length - 1; i > 0; --i) node[i] = OP.func(node[(i << 1) + 0], node[(i << 1) + 1]);
    }
    void update(int idx, TypeNode val) {
        idx += length;
        node[idx] = OP.change(node[idx], val);
        while (idx >>= 1) node[idx] = OP.func(node[(idx << 1) + 0], node[(idx << 1) + 1]);
    }
    TypeNode get(int l, int r) {
        if (l < 0 || r < 0 || l > num || r > num) return OP.NodeE;
        l += length;
        r += length;
        TypeNode vl = OP.NodeE, vr = OP.NodeE;
        while (r > l) {
            if (l & 1) vl = OP.func(vl, node[l++]);
            if (r & 1) vr = OP.func(node[--r], vr);
            l >>= 1;
            r >>= 1;
        }
        return OP.func(vl, vr);
    }
};

template <typename NodeType = int>
struct hoge {
    NodeType NodeE = 0;
    NodeType func(NodeType x, NodeType y) {return max(x, y);}
    NodeType change(NodeType x, NodeType y) {return y;}
};


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n) {
        cin >> p[i];
        --p[i];
    }
    
    SegmentTree<hoge<>> ST(p);
    ll ans = 0;
    REP(i, n) {
        int a = 0, b = 0, c = 0, d = 0, l = 0, r = 0;
        l = -1; r = i;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (ST.get(m, i) > p[i]) l = m;
            else r = m;
        }
        b = l;
        l = -1; r = b;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (ST.get(m, b) > p[i]) l = m;
            else r = m;
        }
        a = l;
        l = i; r = n + 1;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (ST.get(i, m) > p[i]) r = m;
            else l = m;
        }
        c = l;
        l = c; r = n + 1;
        while (r - l > 1) {
            int m = (r + l) / 2;
            if (ST.get(c + 1, m) > p[i]) r = m;
            else l = m;
        }
        d = l;
        ans += ((ll)(i - b) * (d - c) + (ll)(c - i) * (b - a)) * p[i];
    }
    
    ans += (ll)n * (n - 1) / 2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin>>s[i];
    }
    int cnt=1;
    sort(s.begin(),s.end());
    for (int i = 0; i < n-1; i++)
    {
        if(s[i]!=s[i+1]) cnt++;
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 9536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define INF 1e9

using vb=vector<bool>;
using vvb=vector<vb>;

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvb z(n,vb(n,false));
		auto e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=true;
		}

		vector<vvb> d(3);
		auto f=e;
		rep(l,*max_element(a,a+3)){
			rep(p,3) if(l==a[p]-1) d[p]=f;
			auto next=z;
			rep(k,n)rep(i,n)rep(j,n){
				next[i][j] = next[i][j] or (f[i][k] and e[k][j]);
			}
			f=next;
		}

		unordered_set<int> g;
		g.insert(n-1);
		rep(t,100000){
			unordered_set<int> ng;
			rep(i,n) if(!g.count(i)){
				bool ok=true;
				rep(p,3) ok&=[=]{bool r=false; rep(j,n) r|=(g.count(j) and d[p][i][j]); return r;}();
				if(ok) ng.insert(i);
			}
			if(ng.size()==0){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng.count(0)){
				cout<<t+1<<endl;
				break;
			}
			g.insert(all(ng));
		}
	}
	return 0;
}



Measured memory_bytes: 3152
s=input()
front=[]
back=[]
ans="Yes"
for i in range((len(s)-1)//2):
  front.append(s[i])
for i in range((len(s)+3)//2-1,len(s)):
  back.append(s[i])
back.reverse()
if front!=back:
  ans="No"

fro=[]
bac=[]
if len(front)%2!=0 and len(front)!=1:
  for i in range((len(front)-1)//2):
    fro.append(front[i])
  for i in range((len(front)+3)//2-1,len(front)):
    bac.append(front[i])
  bac.reverse()
  if fro!=bac:
    ans="No"
elif len(front)%2==0:
  for i in range(len(front)//2):
    fro.append(front[i])
  for i in range(len(front)//2,len(front)):
    bac.append(front[i])
  bac.reverse()
  if fro!=bac:
    ans="No"

print(ans)

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

using namespace std;

int main()
{
    string s;
    int c=0;
    cin>>s;
    int l=s.size();
    for(int i=0;i<l/2;i++)
    {
        if(s[i]!=s[l-1-i])
           c++;
    }
   cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define sz size
#define ll long long
#define ull unsigned long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=2e5+10;
int a,b,k,cnt;
int main(){
sc(a);sc(b);sc(k);
a=__gcd(a,b);
for(int i=a;i>=1;i--){
if(a%i==0){cnt++;}
if(cnt==k){printf("%d\n",i);return 0;}

}
return 0;
}

/**
**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  long long int n,s=0,i;
  cin>>n;
  for(i=1;i<=n;i++)
  {
      if((i%3==0)||(i%5==0))
      {
          continue;
      }
      else
      {
          s+=i;
      }
  }
  cout<<s;
}

Measured memory_bytes: 3652
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input())

c = collections.Counter(S)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] == max]
ans.sort()

for s in ans:
    print(s)


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	// freopen("in.txt", "r", stdin);
	int n;
	string s;
	cin >> n;
	cin >> s;
	int mod = 'A';
	for(int i=0; i<s.length(); i++){
		if(s[i] + n > 'Z') cout << (char)(s[i] + n - 'Z' + 'A' - 1);
		else cout << (char)(s[i] + n);
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	vi V;
	REP(i, SZ(S)-1) {
		if (S[i] == 'R' &&  S[i + 1] == 'L')V.push_back(i);
	}
	vi Ans(SZ(S));
	REP(i, SZ(S)) {
		if (S[i] == 'R') {
			//一番近い右の無限ループへ
			int ind = *lower_bound(ALL(V), i);
			int step = ind - i;//indにつくまでのターン
			Ans[ind + (step % 2)]++;
		}
		else {
			//一番近い左の無限ループへ
			int ind = *(lower_bound(ALL(V), i) - 1);
			int step = i - ind;
			Ans[ind + (step % 2)]++;
		}
	}
	REP(i, SZ(S)) {
		if (i != 0)cout << " ";
		cout << Ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1232
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    int N;
    string tarou, hanako;
    int tarouPoint = 0, hanakoPoint = 0;
    
    cin >> N;
    
    
    for(int i = N; i > 0; i--){
        cin >> tarou >> hanako;
        if(tarou < hanako) hanakoPoint += 3;
        else if(tarou > hanako) tarouPoint += 3;
        else tarouPoint++, hanakoPoint++; 
    }
    
    cout << tarouPoint << " " << hanakoPoint << endl;

}



Measured memory_bytes: 3216
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Integer.*;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Pref extends ArrayList<Integer>{}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int M = sc.nextInt();
    int P[] = new int[M];
    int Y[] = new int[M];
    List<Pref> A = new ArrayList<Pref>(N);
    for(int i=0; i<N; i++){
      Pref B = new Pref();
      A.add(B);
    }      
    for(int i=0; i<M; i++){
      P[i] = sc.nextInt();
      Y[i] = sc.nextInt();
      A.get(P[i]-1).add(Y[i]);
    }
    for(int i=0; i<N; i++){
      Collections.sort(A.get(i));
    }
    for(int i=0; i<M; i++){
      int x = Collections.binarySearch(A.get(P[i]-1), Y[i]) + 1;
      out.printf("%06d%06d\n",P[i],x);
    }
    
  }
}

Measured memory_bytes: 125964
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++)
    cin >> p[i];
  
  int m = *max_element(p.begin(),p.end());
  cout << (accumulate(p.begin(),p.end(),0) - m + (m/2)) << endl;
  
  return 0;
}

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

vector<pair<int,int> > v,u;

int N,M;
int main () {
    cin >> N >> M;
    for(int i=0; i<N; i++) {
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    for(int i=0; i<M; i++) {
        int c,d;
        cin >> c >> d;
        u.push_back(make_pair(c,d));
    }
    for(int i=0; i<N; i++) {
        int ans = 0;
        int min = 1000000009;
        pair<int,int> P = v[i];
        int a = P.first;
        int b = P.second;
        for(int j=0; j<M; j++) {
            pair<int ,int> Q = u[j];
            int c = Q.first;
            int d = Q.second;
            int dist = abs( a - c ) + abs( b - d );
            if( dist < min ) {
                ans = j+1;
                min = dist;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#ABC064-C
n = int(input())
a = list(map(int,input().split()))
ma = 0
mi = 0
color = [False for _ in range(8)]

red = 0
for i in range(n):
    if 1<=a[i]<= 399:
        color[0] = True
        
    elif 400<=a[i]<=799:
        color[1] = True
        
    elif 800<=a[i]<=1199:
        color[2] = True
        
    elif 1200<=a[i]<=1599:
        color[3] = True
        
    elif 1600<=a[i]<=1999:
        color[4] = True
        
    elif 2000<=a[i]<=2399:
        color[5] = True
        
    elif 2400<=a[i]<=2799:
        color[6] = True
        
    elif 2800<=a[i]<=3199:
        color[7] = True
        
    elif a[i]>=3200:
        red += 1    
        
        
c = color.count(True)

ma = red + c
        
if c == 0:
    mi = 1
else:
    mi = c
    

print(mi,ma)
        
        
    

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

int main() {
  int N, i, j, p = 0;
  cin >> N;
  for(i=0;i<=25;i++) {
    for(j=0;j<=25;j++) {
      if(4 * i + 7 * j == N){
        p = 1;
      }
    }
  }
  if(p == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    ll l = 0;
    ll t = 0;
    ll max = 0;
    REP(i, N) {
        if (S[i] - '0' == 0) {
            if (i == 0 || S[i - 1] == '1') {
                t++;
            }
        }
        if (t > K) {
            for (ll j = l + 1; j <= i; ++j) {
                if (S[j] == '1' && S[j - 1] == '0') {
                    t--;
                    l = j;
                    break;
                }
            }
        }
        max = std::max(max, i - l + 1);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005],x=0,y=0,b;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            if(x<y)
                x=a[i];
            else
                y=a[i];
            i++;
        }
        if(x!=0 and y!=0)
            break;
    }
    cout<<(long long)(x)*y;
    return 0;
}

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

const int N = 2e5+15;

vector<int> adj[N];

int ret[N];
int maxi[N];

int sz[2];

map<pair<int,int>,int > dp;

int par[N];

int getMaxi(int node){
	if(node==0){
		return 0;
	}
	return maxi[node];
}
map<pair<int,int>,int> dp2;

int f(int node,int v){
	if(node>v){
		return 0;
	}
	if(dp.count(make_pair(node,v))){
		return dp[make_pair(node,v)];
	}
	int ret = 1;
	for(int i=0;i<adj[node].size();++i){
		int ch = adj[node][i];
		if(ch == par[node]){
			continue;
		}
		ret += f(ch,v);
	}
	dp[make_pair(node,v)] = ret;
	return ret;
}

int query(int node,int v){
	if(dp2.count(make_pair(node,v))){
		return dp2[make_pair(node,v)];
	} else {
		int ret = 0;
		for(int i=0;i<adj[node].size();++i){
			int ch = adj[node][i];
			if(ch == par[node]){
				continue;
			}
			ret += f(ch,v);
		}
		dp2[make_pair(node,v)] = ret;
		return ret;
	}
}


void dfs(int node,int p,int bit){
	par[node] = p;
	maxi[node] = max(node,maxi[p]);
	if(bit) {
		if(node != 1) {
			int pp = getMaxi(p);
			int gp = getMaxi(par[p]);
			if(node>gp){
				ret[node] = ret[p] + query(node,pp) + 1;
			} else {
				ret[node] = ret[p] + query(node,pp) - query(node,gp);
			}
		}
	}
	for(int i=0;i<adj[node].size();++i){
		int ch = adj[node][i];
		if(ch == p) {
			continue;
		}
		dfs(ch,node,bit);
	}
}


void solve(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;++i){
		int a,b;
		scanf("%d%d",&a,&b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1,0,0);
	dfs(1,0,1);


	for(int i=2;i<=n;++i){
		printf("%d ",ret[i]);
	}

	putchar('\n');
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}


Measured memory_bytes: 64896