akhauriyash/Code-Regression huggingface dataset:
/* written by : vipin kumar */
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<cmath>
#include<algorithm>
using namespace std;
#include<vector>
#define int long long int
#define mod 1000000007
int power(int a,int b,int m)
{
	if(b==0)
	{
		return 1%m;
	}
	else
	{
		int r=power(a,b/2,m);
		if(b%2==0)
		{
			return (r*r)%m;
		}
		else
		{
			int x=(r*r)%m;
			return (a*x)%m;
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int total=0;
	string str;
	cin>>str;
	int j;
	for(j=0;j<n;j++)
	{
		if(str[j]=='1')
		   total++;
	}
	if(total==0)
	{
		for(j=0;j<n;j++)
		   cout<<1<<endl;
		exit(0);
	}
	int value[n+1]={0};
	int value2[n+1]={0};
	int sum1=0,sum2=0;
	for(j=0;j<n;j++)
	{
		if(str[j]=='1')
		{
			int val=power(2,n-1-j,total+1);
			value[j]=val;
			sum1+=val;
			sum1%=(total+1);
		}
	}
	if(total-1!=0)
	{
		for(j=0;j<n;j++)
		{
			if(str[j]=='1')
			{
				int val=power(2,n-1-j,total-1);
				value2[j]=val;
				sum2+=val;
				sum2%=(total-1);
			}
		}
	}
	for(j=0;j<n;j++)
	{
		if(str[j]=='0')
		{
			int here1=sum1;
			here1+=power(2,n-1-j,total+1);
			here1%=(total+1);
			int op=1;
			while(here1!=0)
			{
				int x=__builtin_popcount(here1);
				here1%=x;
				op++;
			}
			cout<<op<<endl;
		}
		else
		{
			if(total==1)
			{
				cout<<0<<endl;
			}
			else
			{
				int here2=sum2;
				here2-=power(2,n-1-j,total-1);
				here2%=(total-1);
				if(here2<0)
				{
					here2+=(total-1);
				}
				int op=1;
				while(here2!=0)
				{
					int x=__builtin_popcount(here2);
					here2%=x;
					op++;
				}
				cout<<op<<endl;
			}
		}
	}
}



Measured memory_bytes: 6900
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int min = Integer.MAX_VALUE;

		for (int i = -100; i <= 100; i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				sum += (a[j] - i) * (a[j] - i);
			}
			min = Math.min(min, sum);
		}

		pr.println(min);

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9680
import java.io.*;
import java.util.*;

class Main {
  
  	public static int minCost(int h[], int N) {
      	int dp[] = new int[N];
      	dp[0] = 0;
      	dp[1] = Math.abs(h[1] - h[0]);
      	for (int i = 2 ; i < N ; ++i) {
         	 dp[i] = Math.min(dp[i-1] + Math.abs(h[i] - h[i-1]), dp[i-2] + Math.abs(h[i] - h[i-2]));
        }
      	return dp[N-1];
    }
      
	public static void main(String args[]) throws IOException {
     	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	int N = Integer.parseInt(br.readLine());
      	String in[] = br.readLine().split(" ");
      	int h[] = new int[N];
      	int i = 0;
      	for (String s: in) {
        	h[i++] = Integer.parseInt(s);
        }
      
      	int cost = minCost(h, N);
      	System.out.println(cost);
    }
}

Measured memory_bytes: 35048
#include <iostream>
#include <string>
#define rp(i,n) for(long long i=0;i<n;i++)

using namespace std;
using ll = long long;

int main(void)
{
    string s,a;
    cin>>s;
    int l=s.length();
    rp(i,l)
    {
        if(s[i]!=s[l-i-1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    a=s.substr(0,(l-1)/2);
    rp(i,(l-1)/2)
    {
        if(a[i]!=a[-i+(l-3)/2])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
        return 0;
}


Measured memory_bytes: 256
flag=True
n=int(input())
A=list(map(int,input().split()))
cnt=0
while flag:
  ls=[]
  tmp=False
  for a in A:
    if a%2==0:
      tmp=True
      cnt+=1
      ls.append(a//2)
  A=ls
  if tmp==False:
    flag=False
print(cnt)

Measured memory_bytes: 4148
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 2e5 + 5;
vector<int> G[maxn];
int add[maxn];
int sum[maxn];
int n,q;
void ad(int rot,int val)
{
	add[rot] += val;
}
void pushdown(int rot)
{
	if(add[rot])
	{
		sum[rot] += add[rot];
		for(int i = 0;i < G[rot].size(); ++i)
		{
			int u = G[rot][i];
			add[u] += add[rot];
			pushdown(u);
		}
		add[rot] = 0;
	}
}
void print()
{
	for(int i = 1;i <= n; ++i)
	{
		pushdown(i);
	}
	for(int i = 1; i <= n; ++i)
	{
		printf("%d%c",sum[i],i == n ? '\n' : ' ');
	}
}
int main(int argc, char const *argv[])
{
	cin>>n>>q;
	for(int i = 1;i < n; ++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
	}
	for(int i = 1;i <= q; ++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		ad(x,y);
	}
	print();
	return 0;
}

Measured memory_bytes: 24320
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s, t = input().split()
ans = ''
for i in range(n):
    ans += s[i] + t[i]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>

using namespace std;


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 1 << 3; i++) {
		int sum = s[0] - '0';
		for (int j = 0; j < 3; j++) {
			int a = s[j+1] - '0';
			
			if (i & 1 << j) {
				sum += a;
			}
			else {
				sum -= a;
			}
		}
		
		if (sum == 7) {
			cout << s[0];
			for (int p = 0; p < 3; p++) {
				if (i & 1 << p)cout << '+';
				else cout << '-';
				cout << s[p + 1];
			}
			cout << "=7";
			return 0;
		}
		
	}
}

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

using namespace std;

typedef long long ll;

int main(){
    ll N;
    string S, T, ans;

    cin >> N;
    cin >> S >> T;

    ans = "";

    for (ll i = 0; i < N; i++){
        ans = ans + S[i] + T[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, m, a, i, d;
  
  scanf("%d%d", &n, &m);
  
  for (i = 0; i < m; i++) {
      scanf("%d", &a);
        
      n -= a;
  }
	if (n < 0)
		printf("-1");
      
    else 
  		printf("%d", n);

    return 0;
}


Measured memory_bytes: 1732
N, P = map(int,input().split())
A = [int(i) for i in input().split()]
p_num = [0,0]
for a in A:
    p_num[a%2] += 1

p = [0,0]

if p_num[1] == 0:
    if P == 0:
        print(2**p_num[0])
    else:
        print(0)
    exit()

print(2**(N-1))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int X, A, B; cin >> X >> A >> B;
    int n = -(A - B);
    if (n <= 0) printf("%s\n", "delicious");
    else {
        if (n <= X) printf("%s\n", "safe");
        else printf("%s\n", "dangerous");
    }
}

Measured memory_bytes: 3612
N, K, S = map(int, input().split())

l = [S]*K + [(S+1)%10**9]*(N-K) #長さKで要素が全てSの列（条件満たすK通り）と長さNーKの適当な列で長さN列を生成

print(*l) #*lは標準出力時にはいれつの[]を出力しないため


Measured memory_bytes: 6500
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

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

    int Hmax=H[0], ans=1;
    for(int i=1; i<N; i++){
        if(H[i] >= Hmax){
            ans += 1;
            Hmax = H[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int64_t h, w;
    cin >> h >> w;

    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }

    if(w%2 == 0){
        cout << w/2*h << endl;
    } else{
        int64_t firstLine = (w+1)/2;
        if(h%2 == 0){
            cout << (firstLine*2-1) * h/2 << endl;
        }else{
            cout << firstLine + (firstLine*2-1) * (h-1)/2 << endl;
        }
    }
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string A, B, C;
	
	cin >> A >> B >> C;

	char tmp_a = A[0] - 32;
	char tmp_b = B[0] - 32;
	char tmp_c = C[0] - 32;
	
	cout << tmp_a << tmp_b << tmp_c << endl;	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
c=0
while h:
  while h:
    if h[-1]==0:
      _=h.pop(-1)
    else:
      break
  if h:
    l=len(h)
    for i in range(l):
      if h[l-i-1]:
        h[l-i-1]-=1
      else:
        break
    c+=1
print(c)
    

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define MAX 100005
#define INF (1LL<<60)

vector<int> G[MAX];
int n,m,k,s,p,q,x,y,a[MAX];
ll d[MAX];

void dijkstra(ll si,ll costA,ll costB){
  priority_queue< P , vector<P> , greater<P> > Q;
  for(int i=0;i<=n;i++)d[i]=INF;
  d[si]=0;
  Q.push(P(0,si));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    ll cost=p.first,pos=p.second;
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i];
      ll ncost=cost;
      if(a[to]==2)continue;
      if(a[to]==1)ncost+=costA;
      if(a[to]==0)ncost+=costB;
      if(to==n-1)ncost=cost;
      if(ncost<d[to]){
        d[to]=ncost;
        Q.push(P(ncost,to));
      }
    }
  }
}

int main(){
  cin>>n>>m>>k>>s>>p>>q;
  for(int i=0;i<k;i++){
    scanf("%d",&x);
    x--;
    G[n].push_back(x);
  }
  for(int i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dijkstra(n,1,1);
  for(int i=0;i<n;i++){
    if(d[i]<=s+1)a[i]=1;
    if(d[i]==1)a[i]=2;
  }
  dijkstra(0,q,p);
  cout<<d[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 9116
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll H, W, N;
map<P, ll> cnt;
vector<ll> ans;

int main()
{
  cin >> H >> W >> N;
  for(int i = 0; i < N; i++) {
    ll a, b; cin >> a >> b;
    for(ll y = max(2LL, a-1); y <= min(H-1, a+1); y++) {
      for(ll x = max(2LL, b-1); x <= min(W-1, b+1); x++) {
	cnt[P(y, x)]++;
      }
    }
  }
  ans.resize(10);
  for(map<P, ll>::iterator it = cnt.begin(); it != cnt.end(); it++) {
    ans[it->second]++;
  }
  ans[0] = (H-2)*(W-2);
  for(int i = 1; i < ans.size(); i++) ans[0] -= ans[i];
  for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 56448
A, B = map(int, input().split())

# 偶奇のそれぞれのパターンで4通りある

if A % 2 == 0 and B % 2 == 0:  # 1のビットが偶数個並ぶわけではないわ
    if (B-1 - A + 1) % 4 == 0:  # 1が偶数個できて結果0
        print(0^B)
    else:
        print(1^B)
if A % 2 == 0 and B % 2 == 1:  # Aが偶数でBのみ奇数
    if (B - A + 1) % 4 == 0:  # 1が偶数個できて結果0
        print(0)
    else:
        print(1)
if A % 2 == 1 and B % 2 == 0:
    if ((B-1) - (A+1) + 1) % 4 == 0:
        print(0^A^B)
    else:
        print(1^A^B)
if A % 2 == 1 and B % 2 == 1:
    if (B - (A+1) + 1) % 4 == 0:
        print(A^0)
    else:
        print(A^1)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, n;
  cin >> h >> w >> n;
  if (h > w) {
    swap(h, w);
  }
  cout << (n + w - 1) / w << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[3003];
ll dp[3003][3003];
ll sm[3003];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; 
	cin>>n; 
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)sm[i] = sm[i-1]+a[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j] = 2e18+123;
		}
	}
	for(int i=1;i<=n;i++)dp[i][i] = 0;
	for(int l=n;l>=1;l--){
		for(int r=l+1;r<=n;r++){
			for(int k=l;k<=r;k++){
				dp[l][r] = min(dp[l][r],dp[l][k]+dp[k+1][r]+sm[r]-sm[l-1]);
			}
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}


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

int main()
{
	ll n,s[100100];
	cin>>n;
	ll res=0,ans=0;
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&s[i]);
		if(i)		
		{
			if(s[i]<=s[i-1]) res++;
			else res=0;
			ans=max(ans,res);
		}
//		if(s[i]<=s[i-1]) res++;
//		else res=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1000000007

func main() {
	sc.Buffer(make([]byte, 500000), 500000)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	h := make([]int, n)
	for i := range h {
		h[i] = nextInt()
	}

	max := 0
	count := 0
	for i := 1; i < n; i++ {
		if h[i-1] >= h[i] {
			count++
		} else {
			if max < count {
				max = count
			}
			count = 0
		}
	}
	if max < count {
		max = count
	}
	fmt.Println(max)
}

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;
const int N=2e3+3;
int S[N][N],rd[N][N],cd[N][N],rb[N][N],cb[N][N];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m,q; cin>>n>>m>>q;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char ch; cin>>ch;
            if(ch=='1') S[i][j]=1;
            else S[i][j]=0;
        }
    }
    // rd
    for(int i=1;i<=n;i++){
        for(int j=2;j<=m;j++){
            if(S[i][j] and S[i][j-1]) rd[i][j]=1;
        }
        for(int j=2;j<=m;j++) rd[i][j]+=rd[i][j-1];
    }
    // cd
    for(int i=2;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(S[i][j] and S[i-1][j]) cd[i][j]=1;
        }
        for(int j=1;j<=m;j++) cd[i][j]+=cd[i-1][j];
    }
    // rb
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(S[i][j]) rb[i][j]=1;
        }
        for(int j=2;j<=m;j++) rb[i][j]+=rb[i][j-1];
    }
    // cb
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(S[i][j]) cb[i][j]=1;
        }
        for(int j=1;j<=m;j++) cb[i][j]+=cb[i-1][j];
    }
    
    while(q--){
        int r1,c1,r2,c2; cin>>r1>>c1>>r2>>c2;
        int rblue=0,rdoubles=0,cdoubles=0;
        for(int r=r1;r<=r2;r++){
            rblue+=(rb[r][c2]-rb[r][c1-1]);
            rdoubles+=(rd[r][c2]-rd[r][c1]);
        }
        for(int c=c1;c<=c2;c++){
            cdoubles+=(cd[r2][c]-cd[r1][c]);
        }
        cout<<rblue-rdoubles-cdoubles<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 80128
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

ll mod = 0;

int main() {
	int n;
	cin >> n >> mod;
	ll sum(0);
	map<int, int> vs;
	int s = 0;
	vs[0] = 1;
	rep(i, 0, n) {
		int a;
		cin >> a;
		s += a;
		s %= mod;
		sum += vs[s];
		++vs[s];
	}
	cout << sum << endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;

	long long dist = abs(b - a);
	bool ok = false;
	if (v >= w) {
		ok = dist <= t * (v - w);
	}

	cout << (ok ? "YES": "NO") << endl;
	return 0;
}


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

int main(){
	int n, a, b, c, ma, sum, rst;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> a >> b >> c;
		a*=a; b*=b; c*=c;
		sum=a+b+c;
		ma=max(a,max(b,c));
		rst=sum-ma;
		if(rst==ma) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {
    
    int n,m;
    int p[100000],y[100000];
    vector<int> po[100001];
    
    cin >> n>>m;
    
    rep(i,0,m){
        cin >> p[i]>>y[i];
        po[p[i]].push_back(y[i]);
    }
    
    rep(i,1,n+1){
        sort(po[i].begin(),po[i].end());
    }
    
    rep(i,0,m){
        
        cout << setfill('0') << right << setw(6) << p[i];
        cout << setfill('0') << right << setw(6) << lower_bound(all(po[p[i]]),y[i])-po[p[i]].begin()+1<< endl;
        
    }
    
    return 0;
}



Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]){
		No();
		return 0;
	}
	if((s[0] == s[1] && s[2] == s[3])
	|| (s[0] == s[2] && s[1] == s[3])
	|| (s[0] == s[3] && s[1] == s[2])) Yes();
	else No();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int n;
vector<double> X, Y;

double dist(double x, double y) {
    double res = 0;
    rep(i, n) chmax(res, hypot(x - X[i], y - Y[i]));
    return res;
}

double opt_y(double x) {
    double dy = 0, uy = 1000;
    rep(_, 100) {
        double y1 = (2 * dy + uy) / 3;
        double y2 = (dy + 2 * uy) / 3;
        if (dist(x, y1) < dist(x, y2)) {
            uy = y2;
        } else {
            dy = y1;
        }
    }
    return dist(x, uy);
}

void solve() {
    cin >> n;
    rep(i, n){
        double x, y;
        cin >> x >> y;
        X.emplace_back(x);
        Y.emplace_back(y);
    }
    double lx = 0, rx = 1000;
    rep(_, 100) {
        double x1 = (2 * lx + rx) / 3;
        double x2 = (lx + 2 * rx) / 3;
        if (opt_y(x1) < opt_y(x2)) {
            rx = x2;
        } else {
            lx = x1;
        }
    }
    cout << fixed << setprecision(10) << opt_y(rx) << endl;
}

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


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

int main(){
  int n;
  int shop[n]={};
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      int x;
      cin >> x;
      shop[i]+=(x<<j);
    }
  }
  int value[n][11];
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin >> value[i][j];
    }
  }
  int ret = -1e9-7;
  for(int i=1;i<1<<10;i++){
    int cnt[n]={};
    int sum = 0;
    for(int j=0;j<n;j++){
      for(int k=0;k<10;k++){
        if((i>>k)%2 & (shop[j]>>k)%2)cnt[j]++;
      }
    }
    for(int j=0;j<n;j++){
      sum += value[j][cnt[j]];
    }
    ret = max(ret,sum);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 24832
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <string>
using namespace std;

const int MAXN = 1000;
int equ,var;
int a[MAXN][MAXN];
int x[MAXN];

int Gauss()
{
	int max_r,col,k;
	for(k = 0,col = 0;k < equ && col < var;k++,col++)
	{
		max_r = k;
		for(int i = k+1;i < equ;i++)
		{
			if(abs(a[i][col]) > abs(a[max_r][k]))
				max_r = i;
		}
		if(a[max_r][col] == 0)
		{
			k--;
			continue;
		}
		if(max_r != k)
		{
			for(int j = col;j < var+1;j++)
				swap(a[k][j],a[max_r][j]);
		}
		for(int i = k+1;i < equ;i++)
		{
			if(a[i][col] != 0)
			{
				for(int j = col;j < var+1;j++)
					a[i][j] ^= a[k][j];
			}
		}
	}
	for(int i = k;i < equ;i++)
		if(a[i][col] != 0)
			return -1;
	if(k < var)return var-k;
	return 0;
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n,m,d;
	while(scanf("%d%d%d",&m,&n,&d) == 3)
	{
		if(n == 0 && m == 0 && d == 0)break;
		equ = var = n*m;
		memset(a,0,sizeof(a));
		for(int i = 0;i < n*m;i++)
			scanf("%d",&a[i][n*m]);
		for(int j = 0;j < n*m;j++)
		{
			a[j][j] = 1;
			int x = j/m;
			int y = j%m;
			for(int i= -d;i <= d;i++)
			{
				int xx = x+i;
				int yy = y - (d-abs(i));
				if(xx < 0 || xx >= n || yy < 0 || yy >= m)continue;
				a[xx*m + yy][j] = 1;
			}
			for(int i= -d;i <= d;i++)
			{
				int xx = x+i;
				int yy = y + (d-abs(i));
				if(xx < 0 || xx >= n || yy < 0 || yy >= m)continue;
				a[xx*m + yy][j] = 1;
			}
		}
		if(Gauss() >= 0)printf("1\n");
		else printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 5084
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

int a[3][70];
int cnt[3];
ll ans[70],anscnt;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		if(t==2)a[0][cnt[0]++]=i+1;
		if(t==-2)a[1][cnt[1]++]=i+1;
		if(t==-1)a[2][cnt[2]++]=i+1;
	}
	for(int i=0;i<cnt[0];i++)ans[anscnt++]=a[0][i];
	for(int i=0;i<cnt[1]/2;i++){
		ans[anscnt++]=a[1][2*i];
		ans[anscnt++]=a[1][2*i+1];
	}
	if(cnt[2]&&cnt[1]%2){
		ans[anscnt++]=a[1][cnt[1]-1];
		ans[anscnt++]=a[2][0];
	}
	sortup(ans,anscnt);
	printf("%lld\n",anscnt);
	for(int i=0;i<anscnt;i++)printf("%lld\n",ans[i]);
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <vector>

struct DFS
{
  int c;
  int N,A;
  std::vector<int> &a;
  std::vector<std::vector<bool>> seen;
  std::vector<std::vector<std::vector<std::vector<int>>>> graph;

  DFS(std::vector<int> &w,int over):
    N(w.size()),
    A(over),
    a(w)
  {
    c=0;
    seen.assign(N+1,std::vector<bool>(A+1,false));
    graph.assign(N+1,std::vector<std::vector<std::vector<int>>>(A+1));

    graph[0][0].push_back(std::vector<int>{0});
  }

  const std::vector<std::vector<int>> &find(int row,int clm)
  {
    auto f=[&,this](int i)->bool
    {
      int nextRow=row-1;
      if(nextRow<0)
        return false;

      int nextClm=i==0?clm:clm-a[nextRow];
      if(nextClm<0)
        return false;

      std::vector<std::vector<int>> v;
      if(seen[nextRow][nextClm])
      {
        v=graph[nextRow][nextClm];
      }
      else
      {
        v=find(nextRow,nextClm);
      }
      graph[row][clm].reserve(graph[row][clm].size()+v.size());
      if(i==0)
      {
        for(auto &e:v)
          graph[row][clm].push_back(std::move(e));
      }
      else
      {
        for(auto &e:v)
        {
          e.push_back(a[nextRow]);
          graph[row][clm].push_back(std::move(e));
        }
      }

      return true;
    };

    seen[row][clm]=true;
    for(int i=0;i<=1;i++)
    {
      c++;
      if(f(i)==false)
        continue;
    }

    return graph[row][clm];
  }
};

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

  int h,w,k;
  std::cin>>h>>w>>k;

  std::vector<std::vector<char>> g(h,std::vector<char>(w,0));
  std::vector<int> HValue(h,0);
  std::vector<int> WValue(w,0);
  for(int i=0;i!=h;i++)
  {
    for(int j=0;j!=w;j++)
    {
      std::cin>>g[i][j];

      if(g[i][j]=='#')
      {
        HValue[i]++;
        WValue[j]++;
      }
    }
  }

  int result=0;
  for(int bit=0;bit!=(1<<h);bit++)
  {
    std::vector<int> hvalue=HValue;
    std::vector<int> wvalue=WValue;

    int sum=0;
    for(int i=0;i!=h;i++)
    {
      if(bit&(1<<i))
      {
        for(int j=0;j!=w;j++)
        {
          if(g[i][j]=='#')
          {
            hvalue[i]=0;
            wvalue[j]--;
          }
        }
      }
      sum+=hvalue[i];
    }

    int over=sum-k;

    if(over<0)
      continue;

    DFS f(wvalue,over);
    const auto &r=f.find(f.N,f.A);
    result+=r.size();
  }

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

Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d", &a);
	if(a==1)
	printf("Hello World\n");
	else
	{
		scanf("%d %d", &a, &b);
		printf("%d\n", a+b);
	}
	
	return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BThin {
    string grid[N];
public:
	void solve(std::istream& in, std::ostream& out) {
	    int h, w; in >> h >> w;
	    for (int i = 0; i < h; ++i) in >> grid[i];
	    for (int i = 0; i < h; ++i) {
	        out << grid[i] << el << grid[i] << el;
	    }
	}
};


int main() {
	BThin solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	int w;
	cin >> s >> w;
	for (int i = 0; i < s.size(); i += w) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int M1, D1;
    int M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    cout << ((M1 == M2) ? 0 : 1) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#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++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    ll ma = a.at(0), ans = 0;
    rep(i, n){
        if(a.at(i) > ma){
            ma = a.at(i);
        }
        else if(a.at(i) < ma){
            ans += (ma - a.at(i));
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, m;
    map<int, int> mp1, mp2;
    cin >> n;
    rep(i, n) {
        int x;
        cin >> x;
        mp1[x]++;
    }
    cin >> m;
    rep(i, m) {
        int x;
        cin >> x;
        mp2[x]++;
    }

    for (auto p : mp2) {
        int x, c;
        tie(x, c) = p;
        if (c > mp1[x]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 19072
#include <iostream>

using namespace std;

int main() {
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	S %= 3600;
	m = S / 60;
	S %= 60;
	s = S;

	cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
using LL = long long;

int n, m;
char s[3010];
int sum[3010];

int dp[3010][3010];
int a[3010];

const int mod = 1000000007;
int f(int l, int r, int c) {
  if (l > r && c) return 0;
  if (l > n) return c == 0;
  if (a[l] >= r) {
    c += sum[a[l]] - sum[r];
    r = a[l];
  }
  int &ret = dp[l][c];
  if (ret >= 0) return ret;
  ret = 0;
  if (r - l + 1 - c > 0) ret += f(l + 1, r, c);
  if (c > 0) ret += f(l + 1, r, c - 1);
  if (ret >= mod) ret -= mod;
  return ret;
}

int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  for (int i = 1; i <= n; ++i)
    sum[i] = sum[i - 1] + (s[i] == '1');
  for (int i = 1; i <= n; ++i)
    a[i] = i;
  for (int i = 0; i < m; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    a[l] = max(a[l], r);
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", f(1, 0, 0));
  return 0;
}



Measured memory_bytes: 35968
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a; cin >>a ;
	cout << a/3600 <<":"<<(a%3600)/60 << ":"<<(a%3600)%60 <<endl;


}


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

int main() {
	long long a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	if (a + b >= c) {
		printf("%lld\n", b + c);
	} else {
		printf("%lld\n", (a + b + 1) + b);
	}
}

Measured memory_bytes: 256
import Control.Monad
import Prelude

data Query = One | Two Int Char deriving (Show, Eq)


type Queue a = ([a], [a])
type MyStr = Queue Char


empty :: Queue a
empty = ([], [])

check :: [a] -> [a] -> Queue a
check [] r = (reverse r, [])
check f  r = (f, r)

snoc :: Queue a -> a -> Queue a
snoc (f, r) x = check f (x : r)


toList :: Queue a -> [a]
toList (a,b)= a ++ reverse b


sousa :: Query -> MyStr -> MyStr
sousa One (s, t) = (t, s)
sousa (Two 1 c) (s, t) = (c:s, t)
sousa (Two 2 c) str@(s, t) = snoc str c

main = do
  str <- getLine
  q <- read <$> getLine
  qs <- forM [1..q] $ \n -> do
    query <- getLine
    return $ if head query == '1'
       then One
       else let [f, c] = tail (words query) in Two (read f) (head c)
  putStrLn $ toList $ foldl (flip sousa) (str, []) qs

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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0; i<n; i++) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i + 1; j < n-1; j++) {
            for (int k = j + 1; k < n; k++) {
                if ((l[i]<l[k]+l[j]) && !(l[i]==l[j]) && !(l[j]==l[k])) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl; 
    return 0;
}

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

#define josh 0
#define ll long long
#define llu long long unsigned
#define ii pair<int ,int>
#define iii pair<int, ii>
#define all(v) (v).begin(), (v).end()
#define vout(v) for(auto i:v)cout<<i<<" "; cout<<endl;
#define loop(x, n, p) for(int i=x; p>0 ? i<n : i>=n; i+=p)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file(x) if(x=="in")freopen("input.txt", "r", stdin); \
                else{freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}



template <typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template <typename T>
T get(T& a){
    read(a);
    return a;
}



struct Converter{
template<typename T>
    T toNum(string s, T& n){
        stringstream ss; ss<<s;
        ss>>n;
        return n;
    }
template <typename T>
    string toString(T& n){
        stringstream ss; ss<<n;
        string s; ss>>s;
        return s;
    }

}convert;

struct Prime{

    bool isPrime[10000007]={0};
    std::vector<int> primeContain;

    void sieve(int n){

        memset(isPrime, true, sizeof(isPrime));

        for (int p=2; p*p<=n; p++){
            if (isPrime[p] == true){
                for (int i=p*p; i<=n; i += p)
                    isPrime[i] = false;
            }
        }
        isPrime[0]=0, isPrime[1]=0;
        loop(2, n+7, 1)
            if(isPrime[i])
                primeContain.push_back(i);

    }


    bool primeDigit(int n){
        while(n){
            int t=n%10;
            if(t!=2 && t!=3 && t!=5 && t!=7)
                return false;
            n/=10;
        }
        return true;
    }


}prime;


struct Algo{

    int josephusDP[100005];

    int josephus(int n, int k){ //O(N)
        if(josephusDP[n]!=-1)return josephusDP[n];
        if(n==1)return 1;  ///return 0;  //for 0 based
        return josephusDP[n] = (josephus(n-1, k)+k-1)%n+1;   ///return (josephus(n-1, k)+k)%n;  //for 0 based
    }

}algo;


void cppCheck(){
    if( __cplusplus == 201103L ) std::cout << "C++11\n" ;
    else if( __cplusplus == 199711L ) std::cout << "C++98\n" ;
    else std::cout << "pre-standard C++\n" ;
}


/*................................let's do it bitch............................................*/








int main(){

    ll n; cin>>n;
    ll x; cin>>x;
    ll currentMax=x, ans=0;
    loop(0, n-1, 1){
        cin>>x;
        if(x<currentMax){
            ans+=(currentMax-x);
        }
        currentMax=max(currentMax, x);
    }
    cout<<ans<<endl;


return josh;
}















Measured memory_bytes: 13340
#include<stdio.h>
int main()
{
    while(1){
       int a,b,i,j,ans=0,c=0;
    scanf("%d%d",&a,&b);
    if(a==0 &&b==0){
        break;
    }
    for(i=1; i<=a+1; i++){
        for(j=1; j<=a+1; j++){
            if(j<=i){
                continue;
            }
            c=b-(i+j);
            if (c > j && c <= a){
                ans += 1;
            }

        }
    }

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



Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int n; cin >> n;
    vector<int> num(26), ans(26, INF);
    REP(i, n){
        string s; cin >> s;
        REP(j, s.size()) num[s[j] - 'a']++;
        REP(j, 26) ans[j] = min(ans[j], num[j]);
        REP(j, 26) num[j] = 0;
    }

    REP(i, 26){
        REP(j, ans[i]) cout << char(i + 'a');
    }
    cout << endl;
}

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

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

	dsu d(n);
	int cnt=0;
	rep(i, m){
		int a, b;
		cin>>a>>b; a--; b--;
		if(!d.same(a, b)) cnt++;
		d.merge(a, b);
	}

	int ans=n-1-cnt;
	cout<<ans<<endl;
	return 0;
}


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

int main(void){
	int T;
	cin>>T;
	vector<int> N(T);
	vector<int> D(T);
	vector<int> result(T);
	for(int i=0; i<T; ++i){
		cin>>N[i]>>D[i];
	}
	for(int i=0; i<T; ++i){
		multiset<int> s;
		s.insert(D[i]);
		for(int j=0; j<N[i]-1; ++j){
			int a = *(s.begin())^127;
			s.erase(s.begin());
			s.insert(a);
			s.insert(127);
		}
		for(auto itr = s.begin(); itr != s.end(); ++itr) {
			result[i]+=*itr;
	}
	}
	for(int i=0; i<T; ++i){
		cout<<result[i]<<endl;
	}
	return 0;
}

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

const int maxn=200005;
const int maxm=1000005;
const int mdn=998244353;
const int inv2=(mdn+1)>>1;
int n;
int a[maxn];
int c[maxm];
long long f[maxm];
int mu[maxm];
bool ntp[maxm];
int prm[maxm],prc;
int fac[maxm];
int cnt;
map<int,int> h;
int ex[maxn],px[maxn];
void seive(){
    mu[1]=ntp[1]=1;
    for(int i=2;i<maxm;i++){
        if(!ntp[i]){prm[++prc]=i;mu[i]=-1;fac[i]=i;}
        for(int j=1;prm[j]*i<maxm;j++){
            ntp[i*prm[j]]=1;
            fac[i*prm[j]]=prm[j];
            if(i%prm[j]){
                mu[i*prm[j]]=-mu[i];
            }else{
                mu[i*prm[j]]=0;
                break;
            }
        }
    }
}

long long tv=0;
void dfs(int u,int x){
    if(u==cnt+1){
        tv+=mu[x]*x;
        tv%=mdn;
        return;
    }
    int g=1;
    for(int i=0;i<=ex[u];i++){
        dfs(u+1,x*g);
        g*=px[u];
    }
}
inline long long calc(int n){
    tv=0;
    cnt=0;
    int c=n;
    h.clear();
    while(c!=1){
        h[fac[c]]++;
        c/=fac[c];
    }
    for(map<int,int>::iterator it=h.begin();it!=h.end();it++){
        ++cnt;
        px[cnt]=(*it).first;
        ex[cnt]=(*it).second;
    }
    dfs(1,1);
    return (tv+mdn)%mdn;
}
int main(){
    ios::sync_with_stdio(0);
    seive();
    cin>>n;
    long long ans=0,sm=0;
    for(int i=1;i<=n;i++){cin>>a[i];sm+=a[i];sm%=mdn;}
    for(int i=1;i<=n;i++){c[a[i]]++;}
    for(int i=1;i<maxm;i++){
        long long t=0;
        for(int j=1;j<=(maxm-1)/i;j++){
            t+=(long long)(j)*c[j*i];t%=mdn;
        }
        f[i]=(t*t)%mdn;
    }
    for(int i=1;i<maxm;i++){
        long long sum=calc(i);//sum{d|n}mu[d]*d
        ans+=f[i]*i%mdn*sum%mdn;
        ans%=mdn;
    }
    cout<<((ans-sm+mdn)*inv2)%mdn;
    return 0;
}

Measured memory_bytes: 23424
#include<stdio.h>

int main(){
  int n,q,i,j,count=0,l,m,r;

  scanf("%d",&n);
  int S[n];
  for(i=0 ; i<n ; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  int T[q];
  for(j=0 ; j<q ; j++){
    scanf("%d",&T[j]);
  }

for(i=0 ; i<q ; i++){
  l=0;
  r=n;

  while(l<r){
    m=(l+r)/2;
if(T[i] == S[m]){
  count++;
  break;
}
if(T[i]>S[m]){
  l = m + 1;
}
if(T[i]<S[m]){
  r = m;
}
}
}
printf("%d",count);
printf("\n");

return 0;
}



Measured memory_bytes: 2304
s = input()
s1 = s[:len(s)//2]
s2 = s[len(s)//2+1:]

#print(s,s1,s2)
if s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print("Yes")
else:
    print("No")


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

int main() {
    int d, g, p[10], c[10];
    cin >> d >> g;
    for (int i = 0; i < d; i++) cin >> p[i] >> c[i];

    int solve_num = 10 * 100;

    for (int combination = 0b0; combination < (1 << d); combination++) {
        int const_score = 0, const_num = 0, not_used_max = -1;
        for (int i = 0; i < d; i++) {
            if ((combination >> i) & 1) {
                const_score += (i + 1) * 100 * p[i] + c[i];
                const_num += p[i];
            } else {
                not_used_max = i;
            }
        }

        int adjust = 0, adjust_num = 0;
        if (const_score < g) {
            adjust = (not_used_max + 1) * 100;
            adjust_num = ((g - const_score) / adjust) + ((g - const_score) % adjust ? 1 : 0);
            if (adjust_num >= p[not_used_max]) continue;
        }

        solve_num = min(solve_num, const_num + adjust_num);
    }

    cout << solve_num << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner dataScanner = new Scanner(System.in);
    String data = dataScanner.nextLine();
    String[] dataList = data.split(" ");
    int a = Integer.parseInt(dataList[0]);
    int b = Integer.parseInt(dataList[1]);
    if (a*b % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  } 
}


Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int H = sc.nextInt();
		final int W = sc.nextInt();
		
		final char[][] input = new char[H][];
		for(int i = 0; i < H; i++){
			input[i] = sc.next().toCharArray();
		}
		
		int curr_x = 0, curr_y = 0;
		LOOP:
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(input[i][j] == '#'){
					curr_x = j;
					curr_y = i;
					break LOOP;
				}
			}
		}
		
		while(input[curr_y][curr_x] == '#'){
			input[curr_y][curr_x] = '.';
			
			if(curr_x < W - 1 && input[curr_y][curr_x + 1] == '#'){
				curr_x += 1;
			}else if(curr_y < H - 1){
				curr_y += 1;
			}else{
				break;
			}
		}
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(input[i][j] == '#'){
					System.out.println("Impossible");
					return;
				}
			}
		}
		System.out.println("Possible");
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8148
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = list()
for i in range(N):
  b.append(int(input()))
A = A1 + A2 + A3

l = list()

for i in range(9):
  cnt = b.count(A[i])
  l.append(cnt)

if l[0] == l[1] == l[2] == 1 or l[3] == l[4] == l[5] == 1 or l[6] == l[7] == l[8] == 1 or l[0] == l[3] == l[6] == 1 or l[1] == l[4] == l[7] == 1 or l[2] == l[5] == l[8] == 1 or l[0] == l[4] == l[8] == 1 or l[2] == l[4] == l[6] == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064