akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

n=int(input())
cards=[0]*n
A=[0]*n
inds=[0]*n
d=defaultdict(lambda :[])
di=defaultdict(int)
for i in range(n):
    tmp=input().split()
    cards[i]=tmp[0],int(tmp[1])
    A[i]=int(tmp[1])
    inds[i]=i
    d[int(tmp[1])].append(tmp[0])

def partition(A,inds,p,r):
    x=A[r]
    i=p-1
    for j in range(p,r):
        if A[j] <= x:
            i+=1
            A[i],A[j]=A[j],A[i]
            inds[i],inds[j]=inds[j],inds[i]
    A[i+1],A[r]=A[r],A[i+1]
    inds[i+1],inds[r]=inds[r],inds[i+1]
    return i+1

def quicksort(A,inds,p,r):
    if p < r:
        q=partition(A,inds,p,r)
        quicksort(A,inds,p,q-1)
        quicksort(A,inds,q+1,r)

quicksort(A,inds,0,n-1)

stable_flag=True
for i in range(n):
    num_i=cards[inds[i]][1]
    suit=cards[inds[i]][0]

    if d[num_i][di[num_i]] != suit:
        stable_flag=False
        break
    di[num_i]+=1

if stable_flag:
    print("Stable")
else:
    print("Not stable")

for i in range(n):
    print(*cards[inds[i]])




Measured memory_bytes: 28960
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var a = long.Parse(inputs[1]);
            var b = long.Parse(inputs[2]);
            var result = Math.Min(a * n, b);
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27408
"""

https://atcoder.jp/contests/agc009/tasks/agc009_c

A <= B としてよい
dpだろうなぁ

dpA[i][X] = 1つ前を置いたのがBで、Aに置かれた最大がindexXの時の置き方
dpB[i][X] = 同様

if S[i]-S[i-1] >= B:
    dpA[i][X] = dpA[i-1][X]
    if X == i-1:
        dpA[i][X] = ///


推移は、BITですればおｋ

もし差がB以下ならば→直前にBを置いていた場所に重ねおきはできない
→直前にAに置いていて、なおかつ最後にBに置いたのとの差がB以下の場合だけBにおける
→dpA[i][i-1]以外は0になる

#直前とB以上の差があるとき
if X != i-1:
    dpBに置く[i][最後にAに置いたのがX] = dpB[i-1][X]
else:
    dpB[i][i-1] = ΣdpA[i-1][y] (y<=S-B)
#差がないとき
if X == i-1:
    dpB[i][i-1] = ΣdpA[i-1][y] (y<=S-B)
else:
    dpB[i][X] = 0

"""

import sys
from sys import stdin
from collections import deque

def bitadd(a,w,bit): #aにwを加える(1-origin)
 
    x = a
    while x <= (len(bit)-1):
        bit[x] += w
        x += x & (-1 * x)
 
def bitsum(a,bit): #ind 1～aまでの和を求める
 
    ret = 0
    x = a
    while x > 0:
        ret += bit[x]
        x -= x & (-1 * x)
    return ret

N,A,B = map(int,stdin.readline().split())
mod = 10**9+7

BITA = [0] * (N+3)
BITB = [0] * (N+3)
bitadd(1,1,BITA)
#bitadd(0,1,BITB)

aq = deque([])
bq = deque([])
Slis = [float("-inf")]

for loop in range(N):

    S = int(stdin.readline())
    
    aq.append( (S,loop+2) )
    bq.append( (S,loop+2) )
    while aq[0][0] <= S-A:
        aq.popleft()
    while bq[0][0] <= S-B:
        bq.popleft()

    #dpAへの推移(Bに置く)
    #Bに置けるのは、1つ前との差がB以上の場合全部おk
    #そうでない場合、前にAにおいていて、かつ差がB以上の場合

    """
    #全てokの場合
    if S - Slis[-1] >= B:
        Aans = bitsum(bq[0][1]-1,BITB)
        Aans %= mod
    else: #そうでない場合→直前にAに置いていた場合のみ可能→bitをリセットする必要あり
        Aans = bitsum(bq[0][1]-1,BITB)
        Aans %= mod

    if S - Slis[-1] >= A:
        Bans = bitsum(aq[0][1]-1,BITA)
        Bans %= mod
    else:
        Bans = bitsum(aq[0][1]-1,BITA)
        Bans %= mod
    """
    Aans = bitsum(bq[0][1]-1,BITB)
    Bans = bitsum(aq[0][1]-1,BITA)
    
    if Aans < 0:
        Aans = 0
    if Bans < 0:
        Bans = 0

    Aans %= mod
    Bans %= mod

    #print (Aans,Bans)
    #更新
    if S - Slis[-1] >= B:
        bitadd(loop+1,Aans,BITA)
    else:
        nowsum = bitsum(N+2,BITA)
        bitadd(1,-1*nowsum,BITA)
        bitadd(loop+1,Aans,BITA)

    if S - Slis[-1] >= A:
        bitadd(loop+1,Bans,BITB)
    else:
        nowsum = bitsum(N+2,BITB)
        bitadd(1,-1*nowsum,BITB)
        bitadd(loop+1,Bans,BITB)

    Slis.append(S)
    if len(Slis) >= 3 and Slis[-1] - Slis[-3] < min(A,B):
        print (0)
        sys.exit()

print ((bitsum(N+2,BITA) + bitsum(N+2,BITB))% mod)
    
        
    


Measured memory_bytes: 96580
import numpy as np
C = np.array([list(input()) for i in range(2)])

C_r = np.array([['0']*3 for i in range(2)])
for i in range(2):
    for j in range(3):
        C_r[1-i, 2-j] = C[i, j]

if np.all(C==C_r):
    print('YES')
else:
    print('NO')




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

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int M = scn.nextInt();
		Drink[] A = new Drink[N];
		for (int i = 0; i < N; i++) {
			A[i] = new Drink(scn.nextInt(), scn.nextInt());
		}
		Arrays.sort(A);
		long ans = 0;
		for(int i = 0;i < N;i++) {
			if(M > A[i].getMax()) {
				ans += A[i].getPrice() * A[i].getMax();
				M -= A[i].getMax();
			}else {
				ans += A[i].getPrice() * M;
				break;
			}
		}
		System.out.println(ans);
	}
}

class Drink implements Comparable<Drink>{
	long price, max;

	Drink(long price, int max) {
		this.price = price;
		this.max = max;
	}

	long getPrice() {
		return this.price;
	}

	long getMax() {
		return this.max;
	}

	@Override
	public int compareTo(Drink o) {
		if(this.getPrice() < o.getPrice()) {
			return -1;
		}else {
			if(this.getPrice() > o.getPrice()) {
				return 1;
			}else {
				return 0;
			}
		}
	}
}


Measured memory_bytes: 90116
/*
边权为 -1, 2 的二叉树转多叉树，使得 $(-1) ^ {c_i} 2 ^ {d_i}$ 中的 $d_i$ 只与深度有关

父亲对自己的正负号贡献和儿子对自己的正负号贡献拆开，分别为“树权”和“点权”

分类讨论并转移，$O(n ^ 5)$，什么鬼差分后优化为 $O(n ^ 4)$

方案不同当且仅当存在点 “终权” = 树权 * 点权 在两种方案中不同，或者 深度相同的点的进制 在两种方案中不同

于是本题统计方案时要特别注意，无论是树权的组合，还是点权的组合，对于方案数都是没有贡献的，
于是，第 i 层的方案分为两部分，“终权”和点数，点数是需要在转移到第 i 层的时候计算好的，
但是有树权为 1 的点数对答案是没有贡献的，只有在转移到 i + 1 层的时候，才能确定第 i 层的“终权”，
这时才能算上“终权”的贡献，最后一层终权 = 树权，特殊统计

其实，这题也可以看做是一种有“后效性”的 DP，因为第 i + 1 层的情况会对第 i 层的情况产生影响。
一般有后效性的 DP 使用高斯消元，而这一题利用不变量和类似待定系数的方法，把贡献拆到了下一层计算，
而 i + 2 行以后的情况对 i 行无影响；同时在最后层时 DP 无后效性，解决了这个问题。是一个不错的思路

(j - k, -1, x, - 1) (k, 1, y, -1)
[x + k - y, 1] [y + j - k - x, -1]

ntk - (ntj - ntk) = y - x   ntj = 2 * ntk - (y - x)
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
const int N = 55, Mod = 1e9 + 7;

int n, fans, C[N][N], f[N][N][N];

/* f[i][j][k] ：i 个点，最后一层 j 个点，最后一层有 k 个树权为 1 */
inline void Add(int &x, LL y) { x = ((LL)x + y) % Mod; }

int main()
{
	scanf("%d", &n);
	for (int i = 0; i <= n; ++i) {
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; ++j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
	}
	//f[1][1][1] = 1;
	f[1][1][1] = C[n][1];
	for (int i = 1; i < n; ++i)
	for (int j = 1; j <= i; ++j)
	for (int k = 0; k <= j; ++k) {
		for (int deta = -(j - k); deta <= k; ++deta)
		for (int ntk = 0; i + ntk <= n; ++ntk) {
			int ntj = 2 * ntk - deta;
			if (ntj < 0) continue;
			if (i + ntj > n) break;
			//Add(f[i + ntj][ntj][ntk], (LL)f[i][j][k] * C[n - i][ntj] % Mod * C[ntj][ntk] % Mod * C[j][k - deta]);
			Add(f[i + ntj][ntj][ntk], (LL)f[i][j][k] * C[n - i][ntj] % Mod * C[j][k - deta]);
		}
	}
	fans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = /*1*/ 0; j <= n; ++j) {
			//Add(fans, (LL)f[n][i][j]);
			Add(fans, (LL)f[n][i][j] * C[i][j]);
		}
	printf("%d\n", (fans % Mod + Mod) % Mod);

	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const double pi=3.1415926535;

signed main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h=h+m*1.0/60;
	m=m*1.0/5;
    double num=fabs(h-m);
    if(num>6.0)num=12.0-num;
    double theta=num*pi/6.0;
    double tot=sqrt(a*a+b*b-2*a*b*cos(theta));
    cout<<fixed<<setprecision(9)<<tot<<endl;
    return 0;
}


Measured memory_bytes: 4196
N = gets.to_i
a = 0
for x in 0..(N / 4) + 1
    for y in 0..(N / 7) + 1
        if 4 * x + 7 * y == N 
            a += 1
        end
    end
end
if a >= 1
    puts 'Yes'
else
    puts 'No'
end



Measured memory_bytes: 1788
#include "bits/stdc++.h"

using namespace std;

int main()
{
	int n, k, ans = 0;
	cin >> n >> k;
	auto p = vector<int>(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < k; i++)
	{
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
from heapq import heappop, heappush

def calc(KD, N):
  now = 0
  hq = []
  for i in range(1, N+1):
    while now < N and KD[now][0] <= i:
      heappush(hq, KD[now][1])
      now += 1
    while len(hq) > i:
      heappop(hq)
  res = sum(hq)
  while now < N:
    res += KD[now][1]
    now += 1
  return res

def solve(KLR, N):
  res = 0
  KD_l = []; KD_r = []
  for k, l, r in KLR:
    if l < r:
      if k < N:
        KD_r.append((N-k, r-l))
      res += l
    elif l > r:
      if k < N:
        KD_l.append((k, l-r))
        res += r
      else:
        res += l
    else:
      res += l
  KD_l.sort(); KD_r.sort()
  Nl = len(KD_l); Nr = len(KD_r)
  res += calc(KD_l, Nl)
  res += calc(KD_r, Nr)
  return res


ans = []
T = int(input())
for i in range(T):
  N = int(input())
  KLR = [tuple(map(int, input().split())) for i in range(N)]
  ans.append(solve(KLR, N))

print(*ans, sep='\n')

Measured memory_bytes: 62308
using System;
class aoj{
	static void Main(){
		string []a=Console.ReadLine().Split(' ');
		int []b=new int[3];
		for(int i=0;i<3;i++)
		{
			b[i]=int.Parse(a[i]);
		}
		Array.Sort(b);
		Console.WriteLine("{0} {1} {2}",b[0],b[1],b[2]);
	}
}

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

int main(int argc, char *argv[]){
  int w, h;
  cin >> h >> w;
  string grid[h];
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }
  vector<vector<int> > ans(h, vector<int>(w, -1));
  for (int i = 0; i < h; i++) {
    bool flag = false;
    int seq = 0;
    for (int j = 0; j < w; j++) {
      if(grid[i][j] == 'c')flag = true, seq = 0;
      if(flag == false)continue;
      ans[i][j] = seq;
      seq++;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      std::cout << ans[i][j] << " ";
    }
    std::cout << ans[i][w - 1] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	int n, k;
	cin >> n >> k;
	if (n % 2 == 0) {
		if (k <= n / 2) {
			_Y();
		}
		else {
			_N();
		}
	}
	else {
		if (k <= n / 2 + 1) {
			_Y();
		}
		else {
			_N();
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;
#define inf 100000000/*10^8*/

/////////////////////////////////


int main(){
    int k;cin>>k;
    ll a[k+1];for(int i=1;i<=k;i++)scanf("%lld",&a[i]);
    ll min=2,max=2;
    bool flag=true;
    for(int i=k;i>=1;i--){
        if(min/a[i]==max/a[i]&&min>a[i]*(min/a[i])){
            flag=false;
            break;
        }
        ll small=min/a[i]+1;
        if(min%a[i]==0)small--;
        ll big=max/a[i];
        
        min=small*a[i];
        max=big*a[i]+a[i]-1;
    }
    if(flag==true)cout<<min<<" "<<max<<endl;
    else cout<<"-1"<<endl;
    
    return 0;
}


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

using namespace std;

struct state{
    int x,y,r,c;
};

bool check(int x1,int y1,int r1,int x2,int y2,int r2){
    if((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) >= (r1+r2)*(r1+r2)){
        return 0;
    }
    else return 1;
}

int memo[1<<24];

int dp(vector<state>&v,int now){
    if(memo[now]!=-1)return memo[now];
    vector<int>ue(v.size(),0);
    for(int i=0;i<v.size();++i){
        if(!((now>>i)&1))continue;
        for(int j=0;j<i;++j){
            if(!((now>>j)&1))continue;
            if(check(v[i].x,v[i].y,v[i].r,v[j].x,v[j].y,v[j].r)){
                ue[i]++;
            }
        }
    }
    int ret=0;
    for(int i=0;i<v.size();++i){
        for(int j=i+1;j<v.size();++j){
            if((now>>i)&1 && (now>>j)&1){
                if(ue[i]==0 && ue[j]==0){
                    if(v[i].c != v[j].c)continue;
                    ret=max(ret,dp(v,now-((1<<i)+(1<<j)))+2);
                }
            }
        }
    }
    return memo[now]=ret;
}

int main(){
    int n;
    while(cin>>n,n){
        for(int i=0;i<(1<<24);++i){
            memo[i]=-1;
        }
        vector<state>v(n);
        for(int i=0;i<n;++i){
            int x,y,r,c;
            cin>>x>>y>>r>>c;
            v[i]={x,y,r,c};
        }
        cout<<dp(v,(1 << n)-1)<<endl;
    }
}



Measured memory_bytes: 68640
#include <iostream>

using namespace std;

void solve()
{
	int y, m, d;
	while(cin >> y >> m >> d)
	{
		int date = d + 100 * m + 10000 * y;
		if(date < 18680908)
		{
			cout << "pre-meiji" << endl;
		}
		else if(18680908 <= date && date <= 19120729)
		{
			cout << "meiji ";
			cout << y - 1868 + 1 << " " << m << " " << d << endl;
		}
		else if(19120730 <= date && date <= 19261224)
		{
			cout << "taisho ";
			cout << y - 1912 + 1 << " " << m << " " << d << endl;
		}
		else if(19261225 <= date && date <= 19890107)
		{
			cout << "showa ";
			cout << y - 1926 + 1 << " " << m << " " << d << endl;
		}
		else if(19890108 <= date)
		{
			cout << "heisei ";
			cout << y - 1989 + 1 << " " << m << " " << d << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

int main(){
    int n,num;
    int cont = 1;
    int ladrillos_rotos = 0;
    cin >> n;
    int limit = n-1;
    for (int i=1;i<=n;i++){
        cin >> num;
        if(num==cont){
            cont++;
        }else{
            ladrillos_rotos++;
        }
    }
    if(ladrillos_rotos<=limit){
        cout << ladrillos_rotos << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a,b,sum;
    char op;
    cin>>a>>op>>b;
    if(op=='+'){
        sum=a+b;
        cout<<sum;
    }
    else{
        sum=a-b;
        cout<<sum;
    }
    system("pause");
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<complex>
using namespace std;

#define EACH(v, c) for(auto&v:c)

double EPS=1e-10;

struct P {
    double x,y;
    P() : x(0),y(0) {
        return; 
    }
    P(double x,double y) : x(x),y(y) {
        return; 
    }

    P operator + (const P &a) const {
        return P(x+a.x,y+a.y);
    }
    P operator - (const P &a) const {
        return P(x-a.x,y-a.y);
    }
    P operator * (const double &a) const {
        return P(x*a,y*a);
    }
    P operator / (const double &a) const {
        return P(x/a,y/a);
    }

    bool operator < (const P &a) const {
        return x==a.x?y<a.y:x<a.x;
    }
};

double cross(const P &a, const P &b) {
   return a.x*b.y-a.y*b.x;
}

vector<P> convex_hull(vector<P> ps) {
    const int n=ps.size();
    sort(ps.begin(),ps.end());
    int k=0;

    vector<P> convex(n*2);
    for (int i=0;i<n;++i) {
        while (k>1 && cross(convex[k-1]-convex[k-2], ps[i]-convex[k-1])<=0) k--;
        convex[k++]=ps[i];
    }

    for (int i=n-2,t=k;i>=0;--i) {
        while (k>t && cross(convex[k-1]-convex[k-2],ps[i]-convex[k-1])<=0) k--;
        convex[k++]=ps[i];
    }
    convex.resize(k-1);
    return convex;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (;;) {
        int n;
        cin>>n;
        if (n==0) {
            break;
        }
        vector<P> ps(n);
        int tmp=10;
        EACH(p, ps) {
            char d;
            cin >> p.x >> d >> p.y;
        }
        vector<P> convex=convex_hull(ps);
        printf("%d\n",n-convex.size());
    }
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>

void print_comp(char x, char y) {
  if(x > y) {
    std::cout << ">" << std::endl;
  } else if(x < y) {
    std::cout << "<" << std::endl;
  } else {
    std::cout << "=" << std::endl;
  }
}
int main(void) {
  char X,Y;
  std::cin >> X >> Y;
  print_comp(X,Y);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K){
    cout << K << endl;
  }
  else if(A < K&&A + B >= K){
    cout << A << endl;
  }
  else if(A < K&& A+B < K) {
    cout << A - (K - (A+B))<<endl;
  }
}
  

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

using namespace std;

int main()
{
	int nmax = 0, nmin = 124;
	int n;
	for( int i = 0; i < 5; i++ )
	{
		cin >> n;
		nmax = max( nmax, n );
		nmin = min( nmin, n );
	}

	int k;
	cin >> k;
	if( nmax - nmin <= k )
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
int main(){
    ll n;
    cin>>n;
    vector<pair<ll,ll> > a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n;i++){
        cout<<a[i].second+1<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int x, t;

	cin >> x >> t;

	if (x - t < 0) {
		cout << 0 << endl;
	}
	else {
		cout << x - t << endl;

	}

}

Measured memory_bytes: 256
# 169A

# 1.入力をちゃんと受け取る
# ex:「2 5」＞＝ a=2, b=5みたいにしないといけない
a, b = map(int, input().split())
# print(a)
# print(b)

# 2.目的通りの計算をする
# ex: ２つの整数AとBの掛け算をやる
answer = a * b
# 3.計算の結果を出力する
print(answer)

Measured memory_bytes: 9088
n=int(input())
a_b_list=[]
for i in range(n):
    c, d=map(int, input().split())
    a_b_list.append([c, d])
a_b_list.sort(key=lambda x:x[1])
time=0
flag=0
for i in range(len(a_b_list)):
    time=time+a_b_list[i][0]
    if not time<=a_b_list[i][1]:
        flag=1

if flag:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 86232
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    string S;
    cin>>S;
    int A=0,B=0;
    REP(i,3){
      if(S[i]=='A')A++;
      else B++;
    }
    if(A*B==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;

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

map<int, int> cnt;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  LL sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
    sum += (LL)a;
  }
  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    sum += ((LL)c - b) * (LL)cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << sum << '\n';
  }
}

Measured memory_bytes: 8004
#include <stdio.h>
#include <string.h>
int A[10],B[10],D[10],E[10];
void Sort(int C[10]);
int Search(int num,int ans);
int Answer(void);
int main(void){
	int tmp,i,n,cnt;
	char str[100],*line;

	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); A[1]=n; B[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); A[i]=n; B[i]=n;
	}
	fgets(str,sizeof(str),stdin);
	line = strtok(str," ");
	sscanf(line,"%d",&n); D[1]=n; E[1]=n;
	for(i=2;i<=6;i++){
		line = strtok(NULL," ");
		sscanf(line,"%d",&n); D[i]=n; E[i]=n;
	}
	Sort(A); Sort(D);
	/*for(i=1;i<=5;i++){
		if(A[i]>A[i+1]){
			tmp = A[i+1];
			A[i+1] = A[i];
			A[i] = tmp;
		}
		if(D[i]>D[i+1]){
			tmp = D[i+1];
			D[i+1] = D[i];
			D[i] = tmp;
		}
	}*/
	cnt=0;
	for(i=1;i<=6;i++){
		if(A[i] == D[i])
			cnt++;
	}
	if((cnt==6) && (A[1]==A[2]) && (A[2]==A[3]) && (A[3]==A[4]) && (A[4]==A[5])){
		printf("Yes\n");
		return 0;
	}
	Search(1,2);
	Search(1,3);
	Search(2,3);
	Answer();	
	return 0;
}			
void Sort(int C[10]){
	int tmp,i;
	for(i=1;i<6;i++){
		if(C[i]>C[i+1]){
			tmp = C[i+1];
			C[i+1] = C[i];
			C[i] = tmp;	
		}
	}
}
int Search(int num,int ans){
	int tmp,i;
	for(i=0;i<10;i++){
		if(B[num]==E[num])
			return 0;
		tmp = B[num];
		B[num] = B[ans];
		B[ans] = B[7-num];
		B[7-num] = B[7-ans];
		B[7-ans] = tmp;
	}
	return 0;
}
int Answer(void){
	int i;
	for(i=2;i<=6;i++){
		if(B[i] != E[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 588
/**
 * ?????§??¬?´???°
??????????????¶??° x, y ?????\?????¨???????????????????????§??¬?´???°????±???????????????°????????????????????????????????????

???????????´??° x ??¨ y ???????????????x ?? d ??¨ y ?? d ??????????????¨?????? 0 ??¨?????? d ??????????????§???????????????x ??¨ y ????????§??¬?´???°???Greatest Common Divisor?????¨?¨?????????????????????°???35 ??¨14 ????????§??¬?´???° gcd (35, 14) ??? 7 ??¨???????????????????????????35 ????´???°{1, 5, 7, 35}???14 ????´???° {1, 2, 7, 14} ?????¬?´???° {1, 7} ????????§?????¨???????????????

??\???
x ??¨ y ?????????????????????????????§??????????????????????????????

??????
?????§??¬?´???°???????????????????????????????????????

??¶?´?
1 ??? x, y ??? 10^9
?????????
??´??° x, y ???????????????x ??\ y ????????° x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????????????§ x % y ??? x ??? y ??§?????£???????????§????????????

??\?????? 1
147 105
??\?????? 1 ??????????????????
21
 */

#include <iostream>
#include <sstream>

unsigned int gcd(unsigned int x, unsigned int y) {
  if (y != 0) {
    x = gcd(y, x % y);
  }
  return x;
}

int main(int argc, char const *argv[]) {
  unsigned int x, y;
  std::istringstream iss;
  std::string Param;

  while (true) {
    getline(std::cin, Param);
    iss.str(Param);
    iss >> x >> y;
    if ((x < 1 || x > 1000000000) || (y < 1 || y > 1000000000)) {
      std::cout << "Error: 1 <= x,y <= 1,000,000,000" << std::endl;
    } else {
      break;
    }
  }

  std::cout << gcd(x, y) << std::endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> cnt(4);
  rep(i, n) {
    int x;
    cin >> x;
    cnt[x%4]++;
  }
  
  int x = cnt[1] + cnt[3] + (cnt[2] != 0);
  int y = cnt[0];

  if(y + 1 < x)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    A = input([int, N])

    a = list(zip(A, [x for x in range(1, N + 1)]))
    ans = [str(x[1]) for x in sorted(a)]
    print(" ".join(ans))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 33688
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
    [_, x] <- map read . words <$> getLine
    as <- map read . words <$> getLine
    print $ solve x as

solve :: Int -> [Int] -> Int
solve x as = go 0 0 as
    where
        go !acc !a0 [] 
            | a0 > x      = acc + a0 - x
            | otherwise   = acc
        go !acc !a0 (a1:as)
            | a0 + a1 > x = go (acc + a0 + a1 - x) (x - a0) as
            | otherwise   = go acc a1 as

Measured memory_bytes: 36220
n,y = map( int, input().split() )

is_concerned = False

for i in range(n+1):
  for j in range(n-i+1):
      k = n - i - j
      if k < 0:
        break
      if y == 1000 * i + 5000 * j + 10000 * k:
        print( k,j,i )
        is_concerned = True
        break
  if is_concerned == True:
    break

if is_concerned == False:
  print( "-1 -1 -1" )

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << min(c, b / a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define SQ(a) (a)*(a)

#define M 315
using namespace std;
 

int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        vector<ll> a(n);
        ll totxor = 0;
        for(int i = 0;i<n;i++)
        {
          cin>>a[i];
          totxor = totxor^a[i];
        }
        for(int i = 0;i<n;i++)
        {
          ll temp = totxor^a[i];
          cout<<temp<<" ";
        } 
        

    }   
    
    return 0;
}


Measured memory_bytes: 4788
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

// #define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int k, a , b;
    cin >> k >> a >> b;
    
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) return cout << "OK\n", 0;
    }
    
    cout << "NG\n";
    
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int W, a, b;
	cin >> W >> a >> b;

	if( a < b ) {
		cout << max( b-(a+W), 0 ) << endl;
	}
	else {
		cout << max( a-(b+W), 0 ) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
1.upto(3500) do |x|
  1.upto(3500) do |y|
    nume = n*x*y
    deno = 4*x*y - n*x - n*y
    if deno > 0 && nume % deno == 0
      z = nume / deno
      puts [x, y, z].join(" ")
      exit
    end
  end
end

Measured memory_bytes: 3836
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;


int main(){
  int n,m;
  int total = 0;
  priority_queue<pair<int,int> > p;
  priority_queue<int> q;
  cin >> n >> m;
  int a,b;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    p.push(make_pair(-1*a,b));
  }

  for(int i=1;i<m+1;i++){
    while(-1*p.top().first <= i && !p.empty()){
      q.push(p.top().second);
      p.pop();
    }
    if(!q.empty()){
      total += q.top();
      q.pop();
    }
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 1908
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
#include <iomanip>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
///////////////////////////////
#define int long long

const int mod = 1e9 + 7;

int nc2(int n){
	
	int val = n*(n - 1)/2;
	val%=mod;
	return val;
}

int power(int a , int n){
	
	int res = 1;
	while(n){
		
		if(n&1)
			res*=a , res%=mod;
		a*=a;
		a%=mod;
		n/=2;
	}
	return res;
}

void solve(){
	
	int n;
	cin>>n;
	
	if(n <= 1){
		
		cout<<0<<endl;
		return;
	}
	
	int val = power(10 , n);
	val -= 2*power(9 , n);
	while(val < 0)
		val += mod;
	val += power(8 , n);
	val%=mod;
	cout<<val<<endl;
}

signed main(){
 
	fast;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
}

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

int main(){
    int N;
    while(cin>>N,N){
        vector<int> A(N);
        for(auto &a:A){
            string s;
            cin>>s;
            if(s=="x"){
                a=2000000000;
            }else{
                a=stoi(s);
            }
        }
        int up=1000000100;
        int lo=-1000000100;
        for(int i=0;i<N;i++){
            if(A[i]==2000000000){
                if(i+1<N&&A[i+1]==A[i]){
                        lo=1000000100;
                        up=-1000000100;
                        break;                    
                }
                if(i%2==0){
                    if(i-1>=0) up=min(up,A[i-1]);
                    if(i+1<N) up=min(up,A[i+1]);
                }else{
                    if(i-1>=0) lo=max(lo,A[i-1]);
                    if(i+1<N) lo=max(lo,A[i+1]);
                }
            }else{
                if(i%2==0){
                    if(i-1>=0&&A[i-1]!=2000000000&&A[i]>=A[i-1]){
                        lo=1000000100;
                        up=-1000000100;
                        // cout<<'A'<<endl;
                        break;
                    }
                    if(i+1<N&&A[i+1]!=2000000000&&A[i]>=A[i+1]){
                        lo=1000000100;
                        up=-1000000100;
                        // cout<<'B'<<endl;
                        break;
                    }
                }else{
                    if(i-1>=0&&A[i-1]!=2000000000&&A[i]<=A[i-1]){
                        lo=1000000100;
                        up=-1000000100;
                        // cout<<'C'<<endl;
                        break;
                    }
                    if(i+1<N&&A[i+1]!=2000000000&&A[i]<=A[i+1]){
                        lo=1000000100;
                        up=-1000000100;
                        // cout<<'D'<<endl;
                        break;
                    }
                }
            }
        }
        // cout<<up<<' '<<lo<<endl;
        if(up-lo<2){
            cout<<"none"<<endl;
        }else if(up-lo==2){
            cout<<lo+1<<endl;
        }else{
            cout<<"ambiguous"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3032
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 18:16:23 2020

@author: shinba
"""

s = input()

start = s[0]
cnt1 = 0

for i in range(1,len(s)):
    if s[i] == start:
        continue
    cnt1 += 1
    start = s[i]

start = s[-1]
cnt2 = 0

for i in range(len(s)-1,-1,-1):
    if s[i] == start:
        continue
    cnt2 += 1
    start = s[i]

print(min(cnt1,cnt2))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a)
    cin >> e;
  ll sunu = 0, kuma = 0;
  ll nmin = 1e17;
  ll sum = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += a[i];
  }
  for (int i = 0; i < n - 1; ++i)
  {
    sunu += a[i];
    kuma = sum - sunu;
    nmin = min(nmin, abs(sunu - kuma));
  }
  cout << nmin << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pll pair<LL,LL>

using namespace std;

int main(){

    int N;cin>>N;
    LL xmax=-10000000000LL,xmin=10000000000LL,ymax=-10000000000LL,ymin=10000000000LL;
    priority_queue<pll,vector<pll>,greater<pll> > que;

    REP(i,N){
        LL x,y;cin>>x>>y;
        if(x<y)swap(x,y);
        xmax = max(xmax,x);
        xmin = min(xmin,x);
        ymax = max(ymax,y);
        que.push({y,x});
    }

    LL ans = (xmax - xmin)*(ymax - que.top().first);

    REP(i,N-1){
        pll p = que.top();que.pop();
        xmin = min(xmin, p.first);
        ymax = max(ymax,p.second);
        ymin = min(ymin,p.second);
        ans = min(ans,(xmax-xmin)*(ymax-min(ymin,que.top().first)));
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6512
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> strs = vector<string>(n);
  
  string _str;
  for(int i = 0; i < n; i++){
    cin >> _str;
    strs[i] = _str;
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(strs[i] == strs[j]){
        printf("No\n");
        return 0;
      }
    }
  }
  
  for(int i = 1; i < n; i++){
  	if(strs[i - 1][strs[i - 1].size()-1] != strs[i][0]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 256
// B - Crane and Turtle
import { readFileSync } from 'fs';
const input = readFileSync('/dev/stdin', 'utf8');

const [X, Y] = input.split(' ').map((item) => parseInt(item));

let anser: 'Yes' | 'No' = 'No';

const crane = 2;
const turtle = 4;

const all: number[] = new Array(X).fill(crane);

const rd = (arr: number[]) =>
  arr.reduce((previousValue, currentValue) => previousValue + currentValue);

let thatarr: number[] = all;

all.forEach((value, index) => {
  if (anser === 'Yes') return;
  anser = Y === rd(thatarr) ? 'Yes' : 'No';

  thatarr = thatarr.map((mValue, mIndex) => {
    if (index === mIndex) return turtle;
    else return mValue;
  });

  if (anser === 'Yes') return;
  anser = Y === rd(thatarr) ? 'Yes' : 'No';
});

console.log(anser);


Measured memory_bytes: 29696
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  std::vector<int> v;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());
  int count=0,tmp=1;
  for(int i=0;i<n;i++){
    if(v[i]<v[i+1]){
      tmp++;
    }else if(v[i]==v[i+1]){
      continue;
    }else{
      count=tmp;
      tmp=1;
    }
  }
  if(tmp>count) count=tmp;
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int len[105];
char s[105][12];
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n;
cin >>n;
scanf("%s",s[1]+1);
len[1]=strlen(s[1]+1);
for(int i=2;i<=n;i++)
	{
	scanf("%s",s[i]+1);
	len[i]=strlen(s[i]+1);
	if(s[i][1]!=s[i-1][len[i-1]])
		{
		cout <<"No";
		return 0;
		}
	for(int j=i-1;j>=1;j--)
		{
		if(strcmp(s[i]+1,s[j]+1)==0)
			{
			cout <<"No";
		return 0;
			}
		}
	}
cout <<"Yes";
return 0;
}

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

const static int MAX = 100;
const static int INFTY = (1<<21);
const static int WHITE = 0;
const static int GRAY = 1;
const static int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
  int u, minv;
  int d[MAX], p[MAX], color[MAX];

  for(int i=0; i<n; ++i){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(true){
    minv = INFTY;
    u = -1;
    for(int i=0; i<n; ++i){
      if(minv>d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] =BLACK;
    for(int v = 0; v < n; ++v){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(int i=0; i<n; ++i){
    if(p[i] != -1) sum += M[i][p[i]];
  }



  return sum;
}

int main(){
  cin >> n;

  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      int work;
      cin >> work;
      M[i][j] = (work == -1) ? INFTY : work;
    }
  }

  cout << prim() << endl;


  return 0;
}



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

int main() {
  double n,m;
  cin >> n >> m;
  vector<int> goods(n);
  for (int i = 0; i < n; i++) {
  cin >> goods.at(i);
  };
  double sum = 0;
  for (int i = 0; i < n; i++) {
    sum = sum + goods.at(i);
  };
  sort(goods.begin(),goods.end(),std::greater<int>());
  int a = m - 1;
  double b = sum / (4 * m);
  if ( b > goods.at(a) ) {
    cout << "No";
  } else {
    cout << "Yes";
  };
}


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

int main(){
  
  int D,N;
  
  cin >> D >> N;
  if(D == 0 && N < 100)cout << N*1;
  if(D == 0 && N == 100)cout << 101;
  if(D == 1 && N < 100)cout << N*100;
  if(D == 1 && N == 100)cout << 101*100;
  if(D == 2 && N < 100)cout << N*10000;
  if(D == 2 && N == 100)cout << 101*10000;
  
  return 0;
}
  


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int main(){
    int N,M;
    while(cin >> N >> M){
        if(N==0&&M==0) break;
        vector<LL> s(N),d(M),ac(1<<N);
        for(int i=0;i<N;i++) cin >> s[i];
        for(int i=0;i<M;i++) cin >> d[i];
        for(int i=0;i<(1<<N);i++){
            for(int j=0;j<N;j++){
                if(i&(1<<j)) ac[i]+=s[j];
            }
        }
        sort(All(d));
        LL dp[M+1][1<<N];
        memset(dp,0,sizeof(dp));
        for(int m=0;m<M;m++){
            for(int k=0;k<(1<<N);k++){
                dp[m+1][k]=dp[m][k]+abs(ac[k]-d[m]);
                for(int s=0;s<N;s++){
                    if(k&(1<<s)){
                        int p=k^(1<<s);
                        dp[m+1][k]=min(dp[m+1][k],dp[m+1][p]);
                    }
                }
            }
        }
        cout << dp[M][(1<<N)-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 29204
#include<bits/stdc++.h>
using namespace std;
int father[100500];
int dis[100500];
int seek(int x) {
	if(father[x]==x)return x;
	int a1=father[x];
	int a2=seek(father[x]);
	father[x]=a2;
	dis[x]=dis[x]+dis[a1];
	return a2;
}
int fd(int x) {
	if(father[x]==x)return 0;
	return fd(father[x])+dis[x];
}
int main(void) {
	int num,cas,L,R,D;
	cin>>num>>cas;
	for(int i=0; i<=num; i++) {
		father[i]=i;
		dis[i]=0;
	}
	while(cas--) {
		cin>>L>>R>>D;
		int fl=seek(L);
		int fr=seek(R);
		if(fl==fr) {
			if(dis[L]+D!=dis[R]) {
				cout<<"No"<<endl;
				return 0;
			}
		} else {
			father[fr]=fl;
			dis[fr]=fd(L)-fd(R)+D;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(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);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// typedef struct 
// {
//     ll index;
//     ll a;
// } box;

// int cmp_qwe(const void*a, const void*b){return ((box*)b)->a - ((box*)a)->a;}

ll u[300000];
ll v[300000];

int main(){
  ll n;
  ll s, *t;
  ll i, j, k, l;

  ll check=0;
  
  scanf("%lld", &n);
  for (i = 0; i < n; i++)
  {
      scanf("%lld", &s);
      u[i] = 1 + i + s;
      v[i] = 1 + i - s;
  }
  u[n] = v[n] = 1000000000;

  qsort(u, n, sizeof(u[0]), upll);
  qsort(v, n, sizeof(u[0]), upll);
  
  i = 0; j = 0;
  while(i< n && j < n){
      if(u[i] == v[j]) {
          for (k = i; u[k+1] == u[i]; k++);
          for (l = j; v[l+1] == v[j]; l++);
          check += (1 + k - i)*(1+l-j);
          i = k+1;
          j = l+1;
      }
      else if(u[i] < v[j]) i++;
      else j++;
  }
  

  printf("%lld", check);

  return 0;
}

Measured memory_bytes: 6332
#include <cstdio>
#include <algorithm>

int main(){
    int N, R;
    while(scanf("%d %d", &N, &R), N || R){
        int cards[51], _a[51];
        for(int i=1;i<=N;i++){
            cards[i] = N-i+1;
        }

        while(R--){
            int p, c;
            scanf("%d %d", &p, &c);
            
            for(int i=1;i<p;i++){
                _a[i] = cards[i];
            }
            for(int i=1;i<=c;i++){
                cards[i] = cards[p+i-1];
            }
            for(int i=1;i<p;i++){
                cards[c+i] = _a[i];
            }
        }

        printf("%d\n", cards[1]);
    }

    
}

Measured memory_bytes: 1012
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int n2 = 2 * n;
		int n3 = 3 * n;
		sa = br.readLine().split(" ");
		int[] a = new int[n3];
		for (int i = 0; i < n3; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long[][] sum = new long[2][n + 1];

		PriorityQueue<Integer> que1 = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
			que1.add(a[i]);
			sum[0][0] += a[i];
		}
		for (int i = 0; i < n; i++) {
			que1.add(a[n + i]);
			sum[0][i + 1] = sum[0][i] + a[n + i];
			sum[0][i + 1] -= que1.poll();
		}

		PriorityQueue<Integer> que2 = new PriorityQueue<>(new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return o2 - o1;
			}
		});
		for (int i = n2; i < n3; i++) {
			que2.add(a[i]);
			sum[1][n] += a[i];
		}
		for (int i = 1; i <= n; i++) {
			que2.add(a[n2 - i]);
			sum[1][n - i] = sum[1][n - i + 1] + a[n2 - i];
			sum[1][n - i] -= que2.poll();
		}

		long ans = Long.MIN_VALUE;
		for (int i = 0; i <= n; i++) {
			ans = Math.max(ans, sum[0][i] - sum[1][i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 83340