akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

int rec(vector<vector<int>>& edge, vector<int>& memo, int st) {
  if (memo[st] != -1) return memo[st];   // 更新済み
  int res = 0;
  for (auto& nv : edge[st]) {
    chmax(res, rec(edge, memo, nv) + 1);  // 自分の子からの最長パスを求めて 1 足す
  }
  memo[st] = res;
  return res;
}

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

  ll n, m;
  cin >> n >> m;
  vector<int> memo(n, -1);
  vector<vector<int>> edge(n, vector<int>());
  rep(i, m) {
    int x, y; cin >> x >> y; x--; y--;
    edge[y].push_back(x);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {     // 全てのノードを始点にして試す
    chmax(ans, rec(edge, memo, i));
  }

  cout << ans << endl;

  return 0;
}


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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=2e6+10, mod=998244353;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<ll> v1(n+1),v2(n+1);
	
	map<int,int> mp;
	for(int i=0;i<m;i++){
		int x; string ver;
		cin>>x>>ver;
		if( v1[x] ) continue;
		if( ver[0]=='A' ){
			v2[x]=mp[x];
			v1[x]=1;
		}else{
			mp[x]++;
		}
			
	}
	int r1=0,r2=0;
	for(int i=0;i<=n;i++){
		if( v1[i] ){
			r1++;
			r2+=v2[i];
		}
	}
	cout<<r1<<" "<<r2;
	
    yogeshk972();
}


Measured memory_bytes: 6528
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    
    int n,m;
    
    int w,x,y,z;
    
    int q = 1000000000;
    
    cin >> n >> m;
    
    int a[n],b[n],c[m],d[m];
    
    int result[n];
        
    for(int i = 0; i<n; i++){
        cin >> a[i] >> b[i];
    }
    
    for(int i = 0; i<m; i++){
        cin >> c[i] >> d[i];
    }
    
    for(int i = 0; i<n; i++){
        q = 1000000000;
        
        for(int j = 0; j<m; j++){
            
            x = a[i] - c[j];
            y = b[i] - d[j];
            
            if(x < 0){
                x = -x;
            }
            
            if(y < 0){
                y = -y;
            }
            
            z = x + y;
            
            if(z < q){
                q = z;
                w = j + 1;
            }
        }
        
        result[i] = w;
    }
    
    for(int i = 0; i<n; i++){
        cout << result[i] << endl;
    }
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == 5 && b == 5 && c == 7) {
    cout << "YES\n";
  } else if (a == 5 && b == 7 && c == 5) {
    cout << "YES\n";
  } else if (a == 7 && b == 5 && c == 5) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
#include<string.h>
using namespace std;

int main(){
	string S;
	string T;
	cin >> S;
	cin >> T;
	int n = S.size();
	int m = 0;

	for (int i = 0;i<n; i++){
		if (S[i]==T[i]);
		else{
			T[i] = S[i];
			m++;
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    int q;

    deque<char> deq;
    int toggle = 0;

    cin >> s;
    cin >> q;

    for(const auto& c : s)
    {
        deq.push_back(c);
    }

    for(int i = 0; i < q; ++i)
    {
        int t, f;
        char c;

        cin >> t;

        if(t == 1)
        {
            toggle = (toggle + 1) % 2;
        }
        else
        {
            cin >> f >> c;

            if((!toggle && f == 1) || (toggle && f == 2))
            {
                deq.push_front(c);
            }
            else
            {
                deq.push_back(c);
            }
        }
    }

    if(toggle)
    {
        reverse(deq.begin(), deq.end());
    }

    for(auto const& c : deq)
    {
        cout << c;
    }

    cout << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>

int main() {
    int N;
    scanf("%d",&N);
    int t[2]={0},x[2]={0},y[2]={0};
    for (int i=0; i<N; i++) {
        t[0] = t[1]; x[0] = x[1]; y[0] = y[1];
        scanf("%d %d %d",&t[1],&x[1],&y[1]);
        if ((t[1] + x[1] + y[1]) % 2 || abs(x[1]-x[0]) + abs(y[1]-y[0]) > t[1] - t[0]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

using namespace std;

int n, m, gcd;
int ln, lm;
long long lcm;
string S, T;

int main()
{
    cin >> n >> m;
    cin >> S >> T;
    gcd = __gcd(n, m);
    lcm = 1ll*n/gcd*m;
    ln = m/gcd; lm = n/gcd;
    for(int i = 0; i < gcd; ++i)
    {
        if(S[i*lm] != T[i*ln])
            return puts("-1")&0;
    }
    cout << lcm << endl;
    return 0;
}


Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()

ab = [LIST() for _ in range(M)]
ab.sort(key = lambda x: (x[1], x[0]))

ans = 0
tmp = -INF
for l, r in ab:
    if tmp <= l:
        ans += 1
        tmp = r

print(ans)



Measured memory_bytes: 36224
n,q=map(int,input().split())
s=[0]*-~n
w=m=0
for _ in[0]*q:
 a,v=map(int,input().split())
 s[a]+=v
 if v<0 and a==w:m=max(s);w=s.index(m)
 elif s[a]>m:w,m=a,s[a]
 elif s[a]==m:w=min(w,a)
 print(w,m)


Measured memory_bytes: 13960
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;


int main() {
	int N, C, s[100000], t[100000], c[100000];
	int x[200002] = { 0 }, y[200002] = { 0 };

	cin >> N >> C;
	REP(i, N) {
		cin >> s[i] >> t[i] >> c[i];
	}

	FOR(i, 1, C + 1) {
		REP(j, 200002) {
			x[j] = 0;
		}
		REP(j, N) {
			if (c[j] == i) {
				x[s[j] * 2 - 1]++;
				x[t[j] * 2]--;
			}
		}
		REP(j, 200001) {
			x[j + 1] += x[j];
		}
		REP(j, 200002) {
			if (x[j] > 0) {
				y[j]++;
			}
		}
	}

	int ans = 0;
	REP(j, 200002) {
		ans = max(ans, y[j]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2944
from heapq import heappop,heappush
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
Heap = []
memo = [[0,0,0]]
heappush(Heap,[-1 * (A[0] + B[0] + C[0]),0,0,0])
for _ in range(K):
    S,k,l,m = heappop(Heap)
    print(-1 * S)
    if k < X - 1 and not [k + 1,l,m] in memo:
        heappush(Heap,[-1 * (A[k + 1] + B[l] + C[m]),k + 1,l,m])
        memo.append([k + 1,l,m])
    if l < X - 1 and not [k,l + 1,m] in memo:
        heappush(Heap,[-1 * (A[k] + B[l + 1] + C[m]),k,l + 1,m])
        memo.append([k,l + 1,m])
    if m < X - 1 and not [k,l,m + 1] in memo:
        heappush(Heap,[-1 * (A[k] + B[l] + C[m + 1]),k,l,m + 1])
        memo.append([k,l,m + 1])

Measured memory_bytes: 4724
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main(){
  string s,out;
  cin >>s;

  for(int i=0;i<s.length();i++){
    if(s[i]=='B'){
      if(out.length()>0)
      out=out.substr(0,out.length()-1);
    }
    else out += s[i];


  }
  cout<<out<<endl;

  }


Measured memory_bytes: 256
H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for i in range(H)]
ans=H+W-2
for bit in range(2**(H-1)):
    divH=[0]
    for j in range(H-1):
        if(bit>>j&1):
            divH.append(j+1)
    divH.append(H)
    glen=len(divH)-1
    group=[0]*(glen)
    res=glen-1
    go=True
    w=0
    while w<W:
        ok=True
        c=[0]*(glen)
        for g in range(glen):
            cum=0
            for h in range(divH[g],divH[g+1]):
                cum+=S[h][w]
            c[g]+=cum
            if cum>K:
                go=False
                break
            if c[g]+group[g]>K:
                ok=False
        if not go:
            break
        if not ok:
            res+=1
            group=[0]*glen
        else:
            for i in range(glen):
                group[i]+=c[i]
            w+=1
    if not go:
        continue
    ans=min(ans,res)
print(ans)

Measured memory_bytes: 46300
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
  int N;
  map<ll, int> ans;

  cin >> N;
  rep (i, N) {
    ll a;
    cin >> a;
    ans[a]++;
  }

  ll result = 0;
  for(auto itr: ans) {
    if (itr.second % 2 == 1) result++;
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 9844
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int a[] = new int[m];
    long sum = 0;
    for (int i = 0; i < m; i++) {
      a[i] = Integer.parseInt(sc.next());
      sum += a[i];
    }
    pw.println(
      Math.max(n - sum, -1)
    );
  }
}


Measured memory_bytes: 41716
#include <queue>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

#define INF (1 << 26)

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

int main()
{
	int H, W, N;

	cin >> H >> W >> N;

	vector<string> D(H);

	for (int i = 0; i < H; i++)
		cin >> D[i];

	int route = 0;

	for (int i = 1; i <= N; i++)
	{
		queue<pair<int, int> > que;

		vector<vector<int> > memo(H, vector<int>(W, INF));

		char start;

		if (i == 1)
		{
			start = 'S';
		}
		else
		{
			start = i + 47;
		}

		pair<int, int> start_;

		for (int j = 0; j < H; j++)
		{
			for (int k = 0; k < W; k++)
			{
				if (D[j][k] == start)
				{
					start_.first = k;
					start_.second = j;
				}
			}
		}

		que.push(start_);

		memo[start_.second][start_.first] = route;

		while (que.size())
		{
			pair<int, int> place = que.front(); que.pop();

			int x, y;

			x = place.first;
			y = place.second;

			for (int dir = 0; dir < 4; dir++)
			{
				if (0 <= x + dx[dir] && x + dx[dir] < W && 0 <= y + dy[dir] && y + dy[dir] < H)
				{
					if (D[y + dy[dir]][x + dx[dir]] != 'X' && memo[y + dy[dir]][x + dx[dir]] == INF)
					{
						place.first = x + dx[dir];
						place.second = y + dy[dir];

						que.push(place);

						memo[y + dy[dir]][x + dx[dir]] = memo[y][x] + 1;

						if (D[y + dy[dir]][x + dx[dir]] - 48 == i)
						{
							route = memo[y][x] + 1;

							goto Exit;
						}
					}
				}
			}
		}

	Exit:;
	}

	cout << route << endl;

	return 0;
}

Measured memory_bytes: 6060
#include <iostream>

using namespace std;
long long a[300010],mod = 1000000007,sum = 0;
int main(){
	long long i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<60;i++){
		long long x = (1LL<<i);
		long long cnt = 0;
		for(j=0;j<n;j++){
			if(a[j] & x) cnt++;
		}
		(sum += x%mod*cnt%mod*(n - cnt)%mod) %= mod;
	}
	cout << sum << endl;
}

Measured memory_bytes: 2560
// 2019/07/08
// AtCoder Beginner Contest 050 - A

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // Input
        int a = sc.nextInt();
        String o = sc.next();
        int b = sc.nextInt();
        int ans;

        // Check
       if(o.equals("+")){
           ans = a + b;
       } else {
           ans = a - b;
       }
       
       // Output
       System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int used[100000];
int main(void)
{
	int n,k,i;
	scanf("%d",&n);
	for(k=1;k*(k+1)/2<n;k++);
	used[k*(k+1)/2-n]=1;
	FOR(i,1,k+1){
		if(!used[i]) printf("%d\n",i);
	}
	return 0;
}


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

int main() {
    int n; cin >> n;
    int prea; cin >> prea;
    int ans = 0;
    for (int i=1; i<n; ++i) {
        int a; cin >> a;
        if (prea == a) {
            ans++;
            prea = a;
            cin >> a;
            i++;
        }
        prea = a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long x,y,w,h,i;
  double s,w2,h2;
  scanf("%ld %ld %ld %ld",&w,&h,&x,&y);
  w2 = (double)w;
  h2 = (double)h;
  if((x==w2/2)&&(y==h2/2))
    i=1;
  else
    i=0;
  printf("%.6f %d",(w2 * h2) / 2.000000,i);
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const ll MOD = 1e9 + 7;

ll modpow(ll a, ll n) {
    ll ret = 1;
    while(n > 0) {
        if(n % 2 == 1) ret = (ret * a) % MOD;
        a = (a * a) % MOD;
        n /= 2;
    }
    return ret;
}

ll inv(ll a) {
    return modpow(a, MOD - 2);
}

int main() {
    FAST_IO();
    ll X, Y; cin >> X >> Y;
    if((2 * X - Y) >= 0 && (2*Y - X) >= 0 && (2 * X - Y) % 3 == 0 && (2 * Y - X) % 3 == 0) {
        ll a = (2 * X - Y) / 3, b = (2 * Y - X) / 3;
        // (a + b)! / a!b!
        ll ans = 1;
        ll ab_ = 1, a_ = 1, b_ = 1;
        repp(i, 1, a) a_ = (a_ * i) % MOD;
        repp(i, 1, b) b_ = (b_ * i) % MOD;
        repp(i, 1, a + b) ab_ = (ab_ * i) % MOD;
        ans = ab_ * inv(a_) % MOD * inv(b_) % MOD;
        cout << ans << "\n";
    } else {
        cout << "0\n";
    }
}


Measured memory_bytes: 256
def main():
    a, b = map(int, input().split())
    kuchi = 1
    ans = 0

    while kuchi < b:
        kuchi = kuchi - 1 + a
        #print(kuchi, a, b)
        ans += 1
    print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 79544
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef tuple<ll, ll, ll> T;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  ll N,M,p,y;cin>>N>>M;
  T t;
  vector<T> vec_t(M);
  REP(i,0,M){
    cin>>p>>y;
    t=make_tuple(i,--p,y);
    vec_t[i]=t;
  }
  sort(all(vec_t),[](const T &a,const T &b){
    if(get<1>(a)!=get<1>(b))return get<1>(a) < get<1>(b);
    else return get<2>(a) <= get<2>(b);
  });

  ll before_p=0,now_p=0,idx=0;
  REP(i,0,M){
    now_p=get<1>(vec_t[i]);
    if(now_p==before_p){
      idx++;
    }
    else{
      idx=1;
      before_p=now_p;
    }
    get<2>(vec_t[i])=idx;
  }
  sort(all(vec_t));

  REP(i,0,M){
    printf("%06lld",get<1>(vec_t[i])+1);
    printf("%06lld",get<2>(vec_t[i]));
    printf("\n");
  }
  return 0;


}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vll a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];

  sort(all(a));
  sort(all(b));
  sort(all(c));

  vll s(n);
  rep(i, n) {
    ll idx = upper_bound(all(c), b[i]) - c.begin();
    s[i] = n - idx;
  }

  for (int i = n - 2; i >= 0; i--) {
    s[i] += s[i + 1];
  }

  ll ans = 0;
  rep(i, n) {
    ll idx = upper_bound(all(b), a[i]) - b.begin();
    ans += s[idx];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H;
  rep(i, N) {
    ll h;
    cin >> h;
    H.pb(h);
  }

  ll dp[1000010];
  rep(i, 1000010) {
    dp[i] = INF;
  }
  dp[0] = 0;
  rep(i, N) {
    rep2(j, 1, K + 1) {
      chmin(dp[i + j], dp[i] + abs(H[i] - H[i + j]));
    }
  }
  COUT(dp[N - 1]);
  return 0;
}

Measured memory_bytes: 8948
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int a=sc.nextInt();
	int b=sc.nextInt();
	if(a<b)System.out.println("a < b");
	else if(a>b)System.out.println("a > b");
	else System.out.println("a == b");
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 26152
//AtCoder Beginner Contest 075
//B - Minesweeper
//Hiia
#include <stdio.h>
#include <stdlib.h>

int main(){

  char a[100][100], b[100][100];
  int h, w, i, j; //height,width

  scanf("%d %d", &h, &w);
  for(i = 1; i <= h; i++) {
    for(j = 1; j <= w; j++) {
      scanf("%c", &a[i][j]);
      if(a[i][j] == '\n') {//Kore ga naito kaigyou mo hairetu toshite yomikomareru yurusann
        j--;//a[i][j] = '\0';
      }
    }
  }

  //printf("\n");

  for(i = 1; i <= h; i++) {
      a[i][0]='x';
      a[i][w+1]='x';
  }
  for(j = 0; j <= w+1; j++) {
    a[0][j]='x';
    a[h+1][j]='x';
  }

/*
  for(i = 0; i <= h+1; ++i) {
    for(j = 0; j <= w+1; ++j) {
      printf("%c", a[i][j]);
      if(j==w+1){
        printf("\n");
      }
    }
  }
*/

  for(i = 1; i <= h; i++) {
    for(j = 1; j <= w; j++) {
      if(a[i][j]=='.'){
            b[i][j]='0';
            if(a[i-1][j-1]=='#') b[i][j]++;
            if(a[i-1][j]=='#') b[i][j]++;
            if(a[i-1][j+1]=='#') b[i][j]++;
            if(a[i][j-1]=='#') b[i][j]++;
            if(a[i][j+1]=='#') b[i][j]++;
            if(a[i+1][j-1]=='#') b[i][j]++;
            if(a[i+1][j]=='#') b[i][j]++;
            if(a[i+1][j+1]=='#') b[i][j]++;
          }
      else{
            b[i][j]=a[i][j];
      }
    }
  }

  for(i = 1; i <= h; ++i) {
    for(j = 1; j <= w; ++j) {
      printf("%c", b[i][j]);
      if(j==w){
        printf("\n");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1612
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const int maxn=100005;
vector<int>E[maxn];
int n,deg[maxn],dp[maxn],lim,rt;
bool dfs(int u,int fa){
	bool res=1;
	REP(i,0,E[u].size()-1){
		int v=E[u][i];
		if(v!=fa)res&=dfs(v,u);
	}
	static int c[maxn],tot;
	tot=0;
	REP(i,0,E[u].size()-1){
		int v=E[u][i];
		if(v!=fa)c[++tot]=dp[v];
	}
	if(deg[u]&1)c[++tot]=0;
	sort(c+1,c+1+tot);
	int l=1,h=tot;
	while(l<=h){
		int mid=(l+h)>>1,curl=1,curr=tot,Max=0;
		REP(i,1,tot>>1){
			if(curl==mid)curl++;
			if(curr==mid)curr--;
			chkmax(Max,c[curl]+c[curr]);
			curl++,curr--;
		}
		if(Max<=lim)h=mid-1;
		else l=mid+1;
	}
	res&=(l<=tot);
	dp[u]=c[l]+1;
	return res;
}
bool check(int x){
	lim=x;
	return dfs(rt,0)&(dp[rt]-1<=lim);
}
int main(){
	int u,v;
	n=read();
	REP(i,1,n-1){
		u=read(),v=read();
		E[u].pb(v),deg[u]++;
		E[v].pb(u),deg[v]++;
	}
	int ans=0;
	REP(i,1,n)
		if(deg[i]&1)rt=i,ans++;
	write(ans>>1,' ');
	int l=1,h=n-1;
	while(l<=h){
		int mid=(l+h)>>1;
		if(check(mid))h=mid-1;
		else l=mid+1;
	}write(l,'\n');
	return 0;
}

Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < 10 && b < 10) {
			System.out.println(a * b);
		} else {
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 22612
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    lst = [0, 0]

    a_lst.sort()
    a_lst.reverse()

    length = a_lst[0]
    count = 0
    for i in range(n):
        if a_lst[i] == length:
            count += 1

            if count == 2:
                lst.append(a_lst[i])
                count = 0

            if len(lst) == 4:
                break

        else:
            count = 1
            length = a_lst[i]

    area = lst[-1] * lst[-2]
    print(area)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
#define inf 1e18
#define ll long long
ll dp[405][405];
ll a[405];
ll sum(ll i,ll j)
{
	ll ans=0;
	for(int p=i;p<=j;p++)
	{
		ans+=a[p];
	}
	//cout<<ans<<"\n";
	return ans;
}
ll calculate(int i,int j)
{
	if(i>=j)
	return 0;
	if(dp[i][j]!=-1)
	return dp[i][j];
	dp[i][j]=inf;
	ll p,q,r;
	for(int k=i;k<=j;k++)
	{
	    p=calculate(i,k);
	    q=calculate(k+1,j);
	    r=sum(i,k)+sum(k+1,j);
		dp[i][j]=min(dp[i][j],p+q+r);
	}
	return dp[i][j];
}
int main() {
	// your code goes here
	    int n;
		cin>>n;
		for(int i=0;i<n;i++)
     	cin>>a[i];
	    for(int i=0;i<=n;i++)
	    {
		   for(int j=0;j<=n;j++)
		   {
		     	dp[i][j]=-1;
		    }
    	}
    	cout<<calculate(0,n-1)<<"\n";
	return 0;
} 

Measured memory_bytes: 1536
n = int(input())

cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt4 = 0

for i in range(n):
    a = input()
    if a == "AC":
        cnt1 += 1
    elif a == "WA":
        cnt2 += 1
    elif a == "TLE":
        cnt3 += 1
    elif a == "RE":
        cnt4 += 1

print("AC x %d" %(cnt1))
print("WA x %d" %(cnt2))
print("TLE x %d" %(cnt3))
print("RE x %d" %(cnt4))

Measured memory_bytes: 9236
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int N = 101000;
int a[N];
int seg[N << 2];

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

void build(int root, int l, int r) {
	if(l == r) {
		seg[root] = a[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(root << 1, l, mid);
	build(root << 1 | 1, mid + 1, r);
	seg[root] = gcd(seg[root << 1], seg[root << 1 | 1]);
}

int query(int root, int a, int b, int l, int r) {
	if(a > r || b < l) return 0;
	if(l <= a && b <= r) {
		return seg[root];
	}
	int mid = (a + b) >> 1;
	return gcd(
			query(root << 1, a, mid, l, r),
			query(root << 1 | 1, mid + 1, b, l, r)
  );
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	build(1, 0, n - 1);
	
	int best = 0;
	if(n > 1) best = query(1, 0, n - 1, 1, n - 1);
	if(n > 1) best = max(query(1, 0, n - 1, 0, n - 2), best);
	for(int i = 1; i < n - 1; ++i) {
		int l = max(0, i - 1);
		int r = min(n - 1, i + 1);
		int cur = gcd(
				query(1, 0, n - 1, 0, l),
				query(1, 0, n - 1, r, n - 1)
		);
		best = max(cur, best);
	}
	
	cout << best << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lcm(a,b) (a / __gcd(a,b) ) * b
#define lll long 
#define pfd(x,k) cout<<fixed<<setprecision(k)<<x<<endl;
ll arr[10000000];

int main(){
    ll i,j,k,l,n,m=1;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    for(i=0;i<n;i++){
        m=lcm(m,arr[i]);
    }
    cout<<m<<endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,H,W;
    cin >> N >> H >> W;
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        ll A,B;
        cin >> A >> B;
        if(H<=A && W<=B){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    static int mod=1000000007;
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        long n=sc.nextLong();
        long p=sc.nextLong();
        long t=p;
        HashMap<Long,Long> map=new HashMap<>();
        long ans=1;
        long g=(long)sqrt(p);
        for (long i = 2; i <= g+1l;i++) {
            while(p%i==0){
                p/=i;
                map.put(i,map.getOrDefault(i,0l)+1);
            }
        }
        if(p!=1)map.put(p,1l);
        for(Long i:map.keySet()){
            long j=map.get(i)/n;
            for (long k = 0; k < j; k++) {
                ans *= i;
            }
        }
        out.println(ans);
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a,int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

Measured memory_bytes: 22868
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int h = parseInt(sc.next());
		int w = parseInt(sc.next());
		String[] s = new String[h];
		for(i = 0; i <h; i++) {
			s[i] = sc.next();
		}
		sc.close();
		int[][] hc = new int[h][w];
		int[][] wc = new int[h][w];
		for(i = 0; i < h; i++) {
			int ws = 0;
			while(ws<w) {
				int wp = s[i].indexOf("#", ws);
				if(wp == -1) wp = w;
				for(j = ws; j < wp; j++) {
					wc[i][j] = wp - ws;
				}
				if(wp>=w)break;
				wc[i][wp] = 0;
				ws = wp+1;
			}
//			System.out.println(Arrays.toString(wc[i]));
		}
		for(i = 0; i < w; i++) {
			int hs = 0;
			while(hs<h) {
				int hp = h;
				for(j = hs; j < h; j++) {
					if(s[j].charAt(i) == '#') {
						hp = j;
						break;
					}
				}
				for(j = hs; j < hp; j++) {
					hc[j][i] = hp - hs;
				}
				if(hp>=h)break;
				wc[hp][i] = 0;
				hs = hp+1;
			}
//			System.out.println(Arrays.toString(hc[i]));
		}
		int max = 0;
		for(i = 0; i < h; i++) {
			for(j = 0; j < w; j++) {
				int nn = wc[i][j] + hc[i][j] -1;
				if(nn > max)max = nn;
			}
		}
		System.out.println(max);
	}
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int x;
	cin >> x;
	vi tbl;
	for(int i = 1; i < 1000; i++)
	{
		for(int j = 2; j < 1000; j++)
		{
			int beki = pow(i, j);
			if(beki > 1000) break;
			tbl.push_back(beki);
		}
	}
	sort(all(tbl));
	auto i = upper_bound(all(tbl), x);
	cout << *(i - 1) << endl;
	return 0;
}

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

int solve(vector<int> &vect){
  	int n = vect.size();
	if(n<=1) return 0;
  	vector<int> dp(n,INT_MAX);
  	dp[0] = 0;
  	for(int i=1;i<n;i++){
      	int left = INT_MAX, right = INT_MAX;
    	if(i>=1){
            left = dp[i-1] + abs(vect[i] - vect[i-1]);
        }
      	if(i>=2){
        	right = dp[i-2] + abs(vect[i]-vect[i-2]);
        }
      	dp[i] = min(left,right);
    }
  	return dp[n-1];
}

int main(){
	int n;
    cin>>n;
    vector<int> vect(n);
    for(int i=0;i<n;i++) cin>>vect[i];
    cout<<solve(vect);
    return 0;
}

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

int main(void) {
  char buf[8];
  int num1, num2;

  while (scanf("%d %d", &num1, &num2) != EOF) {
    printf("%d\n", (int)log10((double)(num1 + num2)) + 1);
  }

  return 0;
}

Measured memory_bytes: 644
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, T;
    while(cin >> N >> T) {
        vi A(N);
        rep(i, N)cin >> A[i];
        vi ma(N+1);
        for(int i = N - 1; i >= 0; --i) {
            ma[i] = max(ma[i + 1], A[i]);
        }

        int best = 0;
        rep(i, N) {
            smax(best, ma[i + 1] - A[i]);
        }
        int ans = 0;
        rep(i, N) {
            if(ma[i + 1] - A[i] == best)ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1152
N,T,E=map(int,input().split())
x=list(map(int,input().split()))
a=[i for i in range(T-E,T+E+1)]
ans=-1
for i in range(N):
    for j in range(len(a)):
        if a[j]%x[i]==0:
            ans=(i+1)
            break
        else:
            pass
    if ans==-1:
        pass
    else:
        break
print(ans)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}

int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  if(b-a+1<2*k){Rep(i,a,b+1)cout<<i<<endl;}
  else{rep(i,k)cout<<i+a<<endl;
    rep(i,k)cout<<b-k+i+1<<endl;
  }
    
    
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f;
ll a,b,c,d,e,f;
int main()
{
	cin>>a>>b>>c>>d>>e;
	f=c-a;
	if (f<0) f=0-f;
	if ((b-d)*e>=f) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 3628
N, Q = map(int, input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
	ta,tb = map(int, input().split())
	E[ta].append(tb)
	E[tb].append(ta)

cnt = [0 for _ in range(N+1)]

for _ in range(Q):
	tp, tx = map(int, input().split())
	cnt[tp] += tx

q = [[1,0]]
flg = [0 for _ in range(N+1)]
flg[0] = 1

while q:
	cp, cost = q.pop()
	cnt[cp] += cost
	flg[cp] = 1
	for np in E[cp]:
		if flg[np] == 1:
			continue
		q.append([np, cnt[cp]])

print(*cnt[1:])

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

signed compare(const void *a, const void *b){
	return *(int *)a - *(int *)b;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, K, i, ans = (int)(1e9);
	scanf("%d%d", &N, &K);
	int *h = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &h[i]);
	}
	qsort(h, N, sizeof(int), compare);
	for(i = 0; i + K - 1 < N; i++){
		ans = min(ans, h[i + K - 1] - h[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int op(int a,int b){
  return max(a,b);
}
int e(){
  return 0;
}
int main(){
  int n,k;
  cin>>n>>k;
  int b=300001;
  segtree<int,op,e> st(b);
  vector<int> l(n);
  int m=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    l.at(i)=st.prod(max(a-k,0),min(a+k+1,b))+1;
    m=max(l.at(i),m);
    st.set(a,l.at(i));
  }
  cout<<m<<endl;
}

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

int main()
{
  long long int n;
    string ans;
    cin>>n;
    while(n){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
def solve():
  a,aa=map(int,input().split())
  b=list(map(int,input().split()))
  c=[0]*a
  c[0]=0
  for i in range(1,a):
    c[i] = min(c[j] + abs(b[i] - b[j]) for j in range(max(0,i-aa),i))
  print(c[-1])
  
solve()



Measured memory_bytes: 13980
from bisect import bisect
import random


def binary_search(L, n, i, j):
    # print(L, n, i, j)
    low = i
    high = j

    while low <= high:
        mid = (low + high) //2
        guess = L[mid]
        # if guess == n:
            # return mid
        if guess > n:
            high = mid -1
        else:
            low = mid + 1
    # print(low)
    return low

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# N = 10 ** 5
# A = [random.randint(1, 10**9) for _ in range(N)]
# B = [random.randint(1, 10**9) for _ in range(N)]
# C = [random.randint(1, 10**9) for _ in range(N)]

A.sort()
B.sort()
C.sort()

ans = 0
i, j = 0, 0

A_ind = []
B_cum = [0]

for a in A:
    # i = binary_search(B, a, i, N-1)
    i = bisect(B, a)
    A_ind.append(i)

s = 0
for b in B:
    # j = binary_search(C, b, j, N-1)
    j = i = bisect(C, b)
    s += N-j
    B_cum.append(s)

for a in A_ind:
    ans += B_cum[-1] - B_cum[a]
print(ans)



Measured memory_bytes: 31892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 9;
const int INF = 1 << 29;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  float sum = 0;
  rep(i, N) {
    cin >> a[i];
    sum += a[i];
  }
  sum /= (4 * M);
  int ans = 0;
  rep(i, N) {
    if (a[i] >= sum) {
      ans += 1;
    }
  }
  if (ans >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int count[999];
    // for(int i = 0; i < 1201; i++){
    //     count[i] = 0;
 	// }
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


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

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

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

int main() {
  long X, K, D;
  cin >> X >> K >> D;
  
  long abs_min;
  abs_min = abs(X);
  
  if(abs(X)/D > K){
    abs_min -= D*K;
  }
  else{
    for(int i = 0; i <= K; i++){
      if(((K-i) % 2 == 0) && (abs(X) <= D)){
        abs_min = abs(X);
        break;
      }
      if(X > 0) X -= D;
      else X += D;
    }
  }

  cout << abs_min << endl;

return 0;
}

Measured memory_bytes: 3600
N, M = list(map(int, input().split()))
s = 10**9+7
a = 1

if abs(N-M)>=2:
    print(0)
else:
    if abs(N-M):
        for i in range(1, min(N,M)+1):
            a = (a * i) % s
        b = (a * max(N,M)) % s
        print((a * b) % s)
    else:
        for i in range(1, N+1):
            a = (a * i) % s
        c = (a * a) % s
        print((c * 2) % s)

Measured memory_bytes: 3064
#pragma GCC optimize(3 , "Ofast" , "inline")

#include <bits/stdc++.h>

#define rep(i , a , b) for(register int i=(a);i<=(b);i++)
#define rop(i , a , b) for(register ll i=(a);i<(b);i++)
#define per(i , a , b) for(register ll i=(a);i>=(b);i--)
#define por(i , a , b) for(register ll i=(a);i>(b);i--)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double , double > pi;
template<class T>
inline void read (T &x) {
    x = 0;
    int sign = 1;
    char c = getchar ();
    while (c < '0' || c > '9') {
        if ( c == '-' ) sign = - 1;
        c = getchar ();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar ();
    }
    x = x * sign;
}
const int maxn = 1e5+10;
const int inf = int (1e9);
const ll INF = ll(1e18);
const double PI = acos (-1);
const int mod = 1e9+7;
const double eps = 1e-8;

struct node {
    int a,b;
}e[maxn];

bool cmp(node A,node B) {
    return A.a<B.a;
}
int n,m;
int main(){
    read (n);read (m);
    rep (i,1,n) {
        read (e[i].a);read (e[i].b);
    }
    sort (e+1,e+1+n,cmp);
    ll ans = 0;
    for(int i=1;m>=0&&i<=n;i++) {
        if(m>=e[i].b) {
            m-=e[i].b;
            ans+=1ll*e[i].a*e[i].b;
        }
        else {
            ans+=1ll*m*e[i].a;
            m=0;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = input()
a = list(map(int, input().split()))
ans = []

for i in a:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            ans.append(i)
    else:
        pass

if len(ans) == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
//## MohK
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s ; 
    cin >> s ; 
    int n = (int) s.size() ;
    for(int i = 0; i < n; i += 2){
        if ( s[i] == 'L' ) return cout << "No" << endl , 0;
    }
    for(int i = 1; i < n; i += 2){
        if ( s[i] == 'R' ) return cout << "No" << endl , 0;
    }
    cout << "Yes" << endl;
    return 0 ;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
long long N,A,B,AB,BA,ans;
vector<string> V;
int main(){
  ans=0;
  A=0;B=0;AB=0;BA=0;
  cin >> N;
  for (int i=0;i<N;i++){
    string str; cin >> str;
    V.push_back(str);
  }
  for (int i=0;i<N;i++){
    for (int j=0;j<V[i].length()-1;j++){
      if (V[i][j]=='A' && V[i][j+1]=='B'){
        AB++;
      }
    }
    if (V[i][0]=='B'&&V[i][V[i].length()-1]=='A')BA++;
    if (V[i][0]=='B')B++;
    if (V[i][V[i].length()-1]=='A')A++;
  }
  if (A>B)ans=B; else ans=A;
  if (BA==B && BA==A && ans) ans--;
  if (ans==N) ans--;
  ans+=AB;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 832