akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var nabc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var (n, a, b, c) = (nabc[0], nabc[1], nabc[2], nabc[3]);
        ImmutableStack<char>[] dp = new ImmutableStack<char>[5 * 5 * 5];
        static int Encode(int a, int b, int c) => (Min(a, 4) * 5 + Min(b, 4)) * 5 + Min(c, 4);
        dp[Encode(a, b, c)] = ImmutableStack<char>.Empty;
        for (int _ = 0; _ < n; _++)
        {
            var s = Console.ReadLine();
            ImmutableStack<char>[] newdp = new ImmutableStack<char>[5 * 5 * 5];
            int da = 0, db = 0, dc = 0;
            switch (s)
            {
                case "AB":
                    da = 1; db = -1;
                    break;
                case "BC":
                    db = 1; dc = -1;
                    break;
                case "AC":
                    da = 1; dc = -1;
                    break;
            }
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    for (int k = 0; k < 5; k++)
                    {
                        var obj = dp[Encode(i, j, k)];
                        if (obj is null) continue;
                        if (i + da >= 0 && j + db >= 0 && k + dc >= 0) 
                            newdp[Encode(i + da, j + db, k + dc)] = obj.Push(s[0]);
                        if (i - da >= 0 && j - db >= 0 && k - dc >= 0) 
                            newdp[Encode(i - da, j - db, k - dc)] = obj.Push(s[1]);
                    }
                }
            }
            dp = newdp;
        }
        var res = dp.FirstOrDefault(x => x != null);
        if (res == null)
        {
            Console.WriteLine("No");
            return;
        }
        Console.WriteLine("Yes");
        foreach (var item in res.Reverse())
        {
            Console.WriteLine(item);
        }
    }
}



Measured memory_bytes: 55576
import collections as cl
N = int(input())
water = cl.deque(map(int,input().split()))
sum = sum(water)
ans = []
sum_odd = 0
sum_even = 0
for i in range(N):
  if i == 0:
    for k in range((N+1)//2):
      if i == 0:
        sum_odd += water[2*k]
        sum_even = sum - sum_odd
  else:
    xxx = sum_even
    yyy = sum_odd
    sum_odd = xxx + water[-1]
    sum_even = yyy - water[-1]
  ans.append((sum_odd - sum_even))
  water.rotate(-1)
  
print(*ans)

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

int main()
{
   long long n,a,sum=0,mx=0;
   cin>>n;
   vector<long long>v;

   for(int i=0;i<n;i++)
   {
       cin>>a;
       v.push_back(a);
   }
   mx=v[0];

   for(int i=0;i<n;i++)
   {
       if(v[i]>mx)
       {
           mx=v[i];
       }
       else
       {
           sum+=mx-v[i];
       }
   }

   cout<<sum<<endl;


     return 0;

}



Measured memory_bytes: 5360
fun main(args: Array<String>) {
    val n = readInt()
    var s = mutableListOf<String>()
    for (i in 0 until n ) {
        s.add(read())
    }

    val ac = s.count { it == "AC" }
    val wa = s.count { it == "WA" }
    val tle = s.count { it == "TLE" }
    val re = s.count { it == "RE" }

    println("AC x $ac")
    println("WA x $wa")
    println("TLE x $tle")
    println("RE x $re")



}


private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readStringList() = read().split(" ")

private fun readIntList() = readStringList().map { it.toInt() }

private fun readLongList() = readStringList().map { it.toLong() }

private fun readDoubleList() = readStringList().map { it.toDouble() }

private fun readStringMatrix(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readStringList()
        matrix.add(list)
    }
    return matrix
}

private fun readIntMatrix(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readIntList()
        matrix.add(list)
    }
    return matrix
}

private fun readDoubleMatrix(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readDoubleList()
        matrix.add(list)
    }
    return matrix
}

private fun readLongMatrix(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readLongList()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 59868
#include <iostream>
#include <string>
using namespace std;
int main() {
    int i,j,n,b,c,x;
    int flag=0;
    int count=0;
    int sum=0;
    int souwa=0;
    int max=0;
    int temp;
    cin>>n;
   int a[n];
   for(i=0; i<n; ++i){
       cin>>a[i];
   }
   for(i=0; i<n; ++i){
       for(j=0; j<n; ++j){
           if(max<=a[j]){max=a[j];temp=j;}
       }
       if(flag==0){sum=sum+max;a[temp]=-1;flag=1;}
       else{souwa=souwa+max;a[temp]=-1;flag=0;}
       max=0;
   }
cout<<sum-souwa;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author mix
 */
 public class Main {

   
    
   
    
    public static void main(String[] args) {
        // TODO code application logic here
        
        
        Scanner s1 = new Scanner(System.in);
        
        int N = s1.nextInt();
        int L = s1.nextInt();
        
        String[] stringArray=new String[N];
        
          for(int i=0;i<N;i++){
            stringArray[i]=s1.next();
            }
          
         
          Arrays.sort(stringArray);
          
          for(String s : stringArray){
          System.out.print(s);
          }
        
          
          System.out.println("");
    }
    
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 A, B;
    cin >> A >> B;
    Vec<i32> res;
    res.push_back(A + B);
    res.push_back(A - B);
    res.push_back(A * B);
    sort(ALL(res));
    cout << res[2] << endl;
}


Measured memory_bytes: 3572
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashMap<Integer, Long> map = new HashMap<>();
		int base = 0;
		map.put(0, 1L);
		for (int i = 0; i < n; i++) {
		    base += sc.nextInt();
		    base %= m;
		    if (map.containsKey(base)) {
		        map.put(base, map.get(base) + 1);
		    } else {
		        map.put(base, 1L);
		    }
		}
		long total = 0;
		for (long x : map.values()) {
		    total += x * (x - 1) / 2;
		}
		System.out.println(total);
    }
}



Measured memory_bytes: 62464
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N, K;
	cin >> N >> K;
	vecll as(N);

	rep(N, i)
	{
		cin >> as[i];
	}

	ll ans = INFL;

	rep((1<<N), bit)
	{
		if (bitcnt(bit) < K)
		{
			continue;
		}

		ll tmp = 0, cost = 0;

		rep(N, i)
		{
			if (bit >> i & 1)
			{
				if (tmp < as[i])
				{
					tmp = as[i];
				}
				else
				{
					tmp++;
					cost += tmp - as[i];
				}
			}
			else
			{
				tmp = max(tmp, as[i]);
			}
		}

		ans = min(ans, cost);
	}

	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int threshold = 1023;

int N, Q;
int V[303030], W[303030];

int eager[threshold + 1][101010];

int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) {
		scanf("%d%d", V + i, W + i);
	}
	for (int i = 0; i <= 100000; ++i) eager[1][i] = (i < W[1] ? 0 : V[1]);
	for (int i = 2; i <= min(N, threshold); ++i) {
		for (int j = 0; j <= 100000; ++j) {
			eager[i][j] = max(eager[i / 2][j], j >= W[i] ? (eager[i / 2][j - W[i]] + V[i]) : 0);
			if (j > 0) eager[i][j] = max(eager[i][j], eager[i][j - 1]);
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; ++i) {
		int v, lim;
		scanf("%d%d", &v, &lim);

		vector<int> vs, ws;
		while (v > threshold) {
			vs.push_back(V[v]);
			ws.push_back(W[v]);
			v /= 2;
		}

		int ret = 0;
		for (int b = 0; b < (1 << vs.size()); ++b) {
			int vc = 0, wc = 0;
			for (int i = 0; i < vs.size(); ++i) if ((b >> i) & 1) {
				vc += vs[i];
				wc += ws[i];
			}
			if (wc <= lim) {
				ret = max(ret, vc + eager[v][lim - wc]);
			}
		}

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


Measured memory_bytes: 408892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ;i++)

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x ==0){
    cout << (n/x)*t << endl;
  }
  else {
    cout << (n/x+1)*t << endl;
  }
  
  return 0;

}

Measured memory_bytes: 3592
N, M = map(int, input().split())
dict={}
ans=[0, 0]
for i in range(M):
	P, S = input().split()
	if P not in dict:
		if S=="AC":
			ans[0]+=1
			dict[P]=S
		else:
			dict[P]=[S, 1]
	else:
		if dict[P][0]=="WA":
			if S=="WA":
				dict[P][1]+=1
			else:
				ans[0]+=1
				ans[1]+=dict[P][1]
				dict[P]=S
		else:
			continue

print(ans[0], ans[1])

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
    int h, w, n; cin >> h >> w >> n;
    int d = max(h, w);
    cout << (n + d - 1) / d << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		LinkedList<String> list = new LinkedList<>();
		while(true){
			list.add(sc.nextLine());
			if(list.getLast().equals("0 0")){
				break;
			}
		}
		list.removeLast();
		for(String data: list){
			int H = Integer.parseInt(data.split(" ")[0]);
			int W = Integer.parseInt(data.split(" ")[1]);
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");
				}
				System.out.printf("\n");
			}
			System.out.println();
		}
	}
}




Measured memory_bytes: 34352
#include <bits/stdc++.h>
    
#define INF 0x3F3F3F3F
#define DINF 1e+12
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define pb push_back
#define pi 3.1415926535897932384626433832795028841971
#define debug(x) if(1) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " " << y << "\n";
#define all(S) (S).begin(), (S).end()
#define MAXV 1005
#define F first
#define S second
#define EPS 1e-9
#define mp make_pair
    
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
    
using namespace std;
    
typedef long long ll;
typedef pair < int, int >  ii;

int main(){

	ll n, a, b;
	
	while(cin >> n >> a >> b){
		int ma = 0, me = 0, mid = 0;
		rep(i, 0, n){
			ll x;
			cin >> x;
			if(x <= a) me++;
			else if(x > b) ma++;
			else mid++;
		}
		cout << min(ma, min(me, mid)) << endl;
	}
	
	return 0;
}

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

int main() {
 int N;
 cin>>N;
 vector<int>a(N);
 for(int i=0;i<N;i++){
     cin>>a[i];
 }
 cout<<*max_element(a.begin(),a.end())-*min_element(a.begin(),a.end())<<endl;
 return 0;}

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

int main(){
  int n;
  int q, k, sum = 0;

  cin >> n;
  vector<int> vec(n);

  for(int i=0;i<n;++i){
    cin >> vec.at(i);
  }

  cin >> q;
  for(int i=0;i<q;++i){
    cin >> k;
    if (*lower_bound(vec.begin(),vec.end(),k) == k){
      sum++;
    }
  }

  cout << sum << endl;
  return 0;

}



Measured memory_bytes: 3112
#include <stdio.h>

#define N 100000

void swap(int *a, int *b) {
	int tmp;

	tmp = *a;
	*a = *b;
	*b = tmp;
}

int partition(int* A, int p, int r) {
	int x, i, j;

	x = A[r];
	i = p - 1;

	for (j = p; j < r; ++j) {
		if (A[j] <= x) {
			i++;
			swap(&A[i], &A[j]);
		}
	}
	swap(&A[i + 1], &A[r]);

	return i + 1;
}

int main() {
	int i, n, pivot, A[N];

	scanf("%d", &n);

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

	pivot = partition(A, 0, n - 1);

	for (i = 0; i < pivot; ++i) {
		printf("%d ", A[i]);
	}

	printf("[%d]", A[pivot]);

	for (i = pivot + 1; i < n; i++) {
		printf(" ");
		if (A[i] > A[pivot]) printf("%d", A[i]);
	}

	printf("\n");

	return 0;
}

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

using namespace std;

int main()
{
    uint64_t N;
    cin >> N;
    vector<uint64_t> vec(N);
    for (uint64_t i = 0; i < N; ++i)
    {
        cin >> vec.at(i);
    }

    uint64_t max = 0;
    uint64_t ans = 0;
    for (const auto &x : vec)
    {
        if (x <= max)
        {
            ans += max - x;
        }
        if (x > max)
        {
            max = x;
        }
    }
    cout << ans << endl;
}

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

M = [[1] * n for i in range(n)]

if n % 2 == 0:
    for i in range(n):
        for j in range(i+1, n):
            if i + j == n-1:
                M[i][j] = 0
else:
    for i in range(n-1):
        for j in range(i+1, n-1):
            if i + j == n-2:
                M[i][j] = 0

A = []
for i in range(n):
    for j in range(i+1, n):
        if M[i][j] == 1:
            A.append([i, j])

print(len(A))
for i in range(len(A)):
    print(A[i][0]+1, A[i][1]+1)

Measured memory_bytes: 43632
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int x;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a==1){
            x=i+1;
            break;
        }
    }
    int y=x;
    int c;
    while(x<n){
        x=x+k-1;
        c++;
    }
    y=y-x+n;
    while(1<y){
        y=y-k+1;
        c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
int a;
int b;
int i;
char op;

for(i=1;i>0;i++){
  scanf("%d %c %d",&a,&op,&b);
if(op == '+'){
  printf("%d\n",a+b);}
else if(op == '-'){
  printf("%d\n",a-b);}
else if(op == '*'){
  printf("%d\n",a*b);}
else if(op == '/'){
  printf("%d\n",a/b);}
else{
break;}
}
return 0;}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll pow_mod(ll a, ll n, ll p)
{
    ll res = 1ll;
    while(n > 0){
        if(n & 1) res = res*a%p;
        a = a*a%p;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll zero = 0;
    ll zero1 = 0;
    ll zero2 = 0;
    map<pair<ll,ll>,ll> mp;
    map<pair<ll,ll>,ll> seen;
    for(i = 0;i < n;++i){
        ll a,b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            ++zero;
            continue;
        }else if(a == 0){
            ++zero1;
            continue;
        }else if(b == 0){
            ++zero2;
            continue;
        }
        ll tmp = gcd(abs(a), abs(b));
        if(a < 0){
            a /= -1;
            b /= -1;
        }
        a /= tmp;
        b /= tmp;
        ++mp[make_pair(a, b)];
        seen[make_pair(a, b)] = 0;
    }
    const ll MOD = 1e9+7;
    ll spare = n;
    vector<pair<ll,ll>> dame;
    for(auto x:mp){
        if(seen[x.first] == 1) continue;
        seen[x.first] = 1;
        ll c = x.first.first;
        ll d = x.first.second;
        ll n1 = x.second;
        ll n2 = 0;
        if(seen.count(make_pair(d,-c))){
            n2 = mp[make_pair(d,-c)];
            seen[make_pair(d,-c)] = 1;
            dame.emplace_back(n1,n2);
            spare -= n1+n2;
        }
    }
    spare -= zero;
    if(zero1 != 0 && zero2 != 0){
        dame.emplace_back(zero1,zero2);
        spare -= zero1 + zero2;
    }
    ll ans = 1;
    for(auto x:dame){
        ll tmp = pow_mod(2ll, x.first, MOD) + pow_mod(2ll, x.second, MOD) -1;
        tmp %= MOD;
        ans *= tmp;
        ans %= MOD;
    }
    ans *= pow_mod(2ll, spare, MOD);
    cout << (ans + MOD - 1)%MOD + zero << endl;

    return 0;
}


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

int main() {
	string a, b;	cin>>a>>b;
	int len = b.length();
	
	for (int i = 0; i < len; ++i) {
		cout<<a[i]<<b[i];
	}
	if (a.length() > b.length())
		cout<<a[a.length()-1];
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N,K= list(map(int,input().split()))
hc=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
  li=[abs(hc[i]-hc[j])+dp[j] for j in range( max(i-K,0),i) ]
  dp[i]=min(li)
print(dp[-1])

Measured memory_bytes: 20672
# selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
#   for i が 0 から N-1 まで
#     minj = i
#    for j が i から N-1 まで
#       if A[j] < A[minj]
#         minj = j
#     A[i] と A[minj] を交換

n = int(input())
nums = list(map(int, input().split()))
count = 0
for i in range(0, n-1):
    minj = i
    for j in range(i, n):
        if nums[j] < nums[minj]:
            minj = j
            
    nums[i], nums[minj] = nums[minj], nums[i]
    if i != minj:
        count += 1
    
        


print(*nums)
print(count)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	str s,st;
	cin >> n;
	if(n<600)
		m=8;
	else if(n<800)
		m=7;
	else if(n<1000)
		m=6;
	else if(n<1200)
		m=5;
	else if(n<1400)
		m=4;
	else if(n<1600)
		m=3;
	else if(n<1800)
		m=2;
	else 
		m=1;
	cout << m << "\n";
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector <long long>st(n);
  vector <long long> pst(n+1);
  for(int i =0;i<n;i++)
  {
    cin>>st[i];
  }
  pst[1] = st[0];
  pst[0] = 0;
  for(int i =2;i<n+1;i++)
  {
    pst[i] += pst[i-1] + st[i-1];
  }
  long long ans = 0;
  for(int i =0;i<n;i++)
  {
    long long p,q;
    p = st[i] % 1000000007;
    q = pst[n] - pst[i+1];
    q = q % 1000000007;
    ans += (p*q)%1000000007;
    ans = ans%1000000007;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> vec(n);
  rep(i, n) cin >> vec[i];
  ll ans = 0;
  rep(i, n-1){
    ll sum = vec[i]+vec[i+1];
    if(sum > x){
      if(sum-x <= vec[i+1]){
        vec[i+1] -= sum-x;
        ans += sum-x;
      }else{
        vec[i] -= sum-x-vec[i+1];
        vec[i+1] = 0;
        ans += sum-x;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int numbering[100001];
vector <int> friendship[100001];
vector <int> blockship[100001];
int n,m,k,a,b;
int cnt[100001];


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    cin >> n >> m >> k;

    for(int i=0;i<m;i++)
    {
    	cin >> a >> b;
    	friendship[a].push_back(b);
    	friendship[b].push_back(a);
    }

    for(int i=0;i<k;i++)
    {
    	cin >> a >> b;
    	//blockship.push_back(make_pair(a,b));
    	blockship[a].push_back(b);
    	blockship[b].push_back(a);
    }

    memset(numbering,-1,sizeof(numbering));
    memset(cnt,0,sizeof(cnt));
    int num = 0;

    for(int i=1;i<=n;i++)
    {
    	if(numbering[i]==-1)
    	{
    		queue <int> que;
    		que.push(i);
    		numbering[i] = num;
    		while(!que.empty())
    		{
    			int now = que.front();
    			que.pop();
    			cnt[num]++;
    			for(auto next : friendship[now])
    			{
    				if(numbering[next]==-1)
    				{
    					numbering[next] = num;
    					que.push(next);
    				}
    			}
    		}
    		num++;
    	}
    }

    for(int i=1;i<=n;i++)
    {
    	int res = cnt[numbering[i]];
    	res-=friendship[i].size();
    	for(int j=0;j<blockship[i].size();j++)
    	{
    		if(numbering[i]==numbering[blockship[i][j]])
    		{
    			res--;
    		}
    	}
    	cout << res-1 << ' ';
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 13048
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  int q;
  cin >> q;
  deque<char> d(all(s));
  bool rev = false;
  rep (i, q) {
    int t;
    cin >> t;
    if (t == 1) {
      rev = !rev;
    } else {
      int  f;
      char c;
      cin >> f >> c;
      --f;
      if (rev) f = !f;
      if (f) d.push_back(c);
      else d.push_front(c);
    }
  }
  string ans(all(d));
  if (rev) reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int N, M, ans = INT_MAX;
	cin >> N >> M;
	vector<string> a(N);
	for (string& i : a) cin >> i;
	for (int i = 1; i < N - 1; ++i) {
		for (int j = 1 + i; j < N; ++j) {
			int b = 0;
			for (int k = 0; k < i; ++k) {
				for (char& l : a[k]) {
					if ('W' != l) ++b;
				}
			}
			for (int k = i; k < j; ++k) {
				for (char& l : a[k]) {
					if ('B' != l) ++b;
				}
			}
			for (int k = j; k < N; ++k) {
				for (char& l : a[k]) {
					if ('R' != l) ++b;
				}
			}
			ans = min(ans, b);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3156
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

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


func main(){
	var N,K,Q int
	var p []int
	fmt.Scan(&N)
	fmt.Scan(&K)
	fmt.Scan(&Q)
	for i:=0; i < N; i++{
		p=append(p,K)
	}

	for i:=0; i < Q; i++{
		q:=nextInt()
		p[q-1]=p[q-1]+1
	}
	for j:=0; j < N; j++{
		p[j]=p[j]-Q
	}
	for i:=0; i < N; i++{
		if (p[i] > 0){
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 9068
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc069.contest.atcoder.jp/tasks/arc069_b>
問題文============================================================
 すぬけくんは動物が好きなので動物園を作りました。
 
 この動物園では 1,2,3,…,N の番号を割り振られた N 匹の動物が円環状に並べられています。
 i(2≦i≦N−1) 番の動物は i−1 番の動物と i+1 番の動物と隣り合っています。
 また、1 番の動物は N 番の動物と 2 番の動物と隣り合っており、
 N 番の動物は N−1 番の動物と 1 番の動物と隣り合っています。
 
 動物園には本当のことしか言わない正直者の羊と、嘘しか言わない嘘つきの狼の 2 種類の動物がいます。
 
 すぬけくんには羊と狼の区別がつかないので、それぞれの動物に両隣の動物が同じ種類かどうかを訪ねたところ、
 i 番目の動物は si と答えました。si が o ならば両隣の動物が同じ種類であると、
 x ならば異なる種類であると i 番の動物が言ったことを示します。
 
 より形式的には、羊は両隣の動物がどちらも羊あるいはどちらも狼のとき o と答え、そうでないとき x と答えます。
 狼は両隣の動物がどちらも羊あるいはどちらも狼のとき x と答え、そうでないとき o と答えます。
 
 これらの回答結果と矛盾しないような各動物の種別の割り当てが存在するか、すぬけくんは気になっています。
 存在するならば一例を示し、存在しないならば -1 を出力しなさい。
 
=================================================================

解説=============================================================

================================================================
*/

string check(string SW,const string& s,const ll &N){
    for(int i = 1; i < N;i++){
        if(s[i] == 'o'){
            if(SW[i] == 'S'){
                SW.push_back(SW[i-1]);
            }else{
                if(SW[i-1] == 'S') SW.push_back('W');
                else SW.push_back('S');
            }
        }else{
            if(SW[i] == 'S'){
                if(SW[i-1] == 'S') SW.push_back('W');
                else SW.push_back('S');
            }else{
                SW.push_back(SW[i-1]);
            }
        }
    }
    if(SW[0] != SW[N]) return "";
    
    if(s[0] == 'o'){
        if(SW[0] == 'S'){
            if(SW[1] != SW[N-1]) return "";
        }else{
            if(SW[1] == SW[N-1]) return "";
        }
    }else{
        if(SW[0] == 'S'){
            if(SW[1] == SW[N-1]) return "";
        }else{
            if(SW[1] != SW[N-1]) return "";
        }
    }
    return SW;
}
void solve(){
    ll N; cin >> N;
    string s; cin >> s;
    
    string ss[4] = {"SS","SW","WS","WW"};
    string ret;
    for(int i = 0; i < 4;i++){
        ret = check(ss[i],s,N);
        if(ret.length() != 0){
            cout << ret.substr(0,N) << endl;
            return;
        }
    }
    cout << -1 << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


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

int main(void) {
  int n;
  
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
      cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
   if(a.at(i) == a.at(i+1)){
       puts("NO");
       return 0;
   }
  }
  puts("YES");
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	
	for (int i = 0; i < s.length(); i++)
	{
		if (i == 4) {
			cout << " ";
			cout << s[i];
		}
		else {
			cout << s[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout << "Yes\n";
    else  cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  double a;
  cin >> a;
  cout << 3*a*a << '\n';
}


Measured memory_bytes: 256
N = int(input())
S = [int(a) for a in input().split()]
ma = 0
for C in range(1, N-1):
    s = 0
    for k in range((N-2) // C):
        A = N-1-k*C
        if A % C == 0 and A//C <= k: continue
        s += S[k*C] + S[-1-k*C]
        ma = max(ma, s)

print(ma)

Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 100000
vector<int> G[MAX];
int id[MAX],pa[MAX],dp[MAX],used[MAX];
void dfs(int v,int d){
  dp[v]=d;
  for(int i=0;i<(int)G[v].size();i++){
    dfs(G[v][i],d+1);
    pa[G[v][i]]=v;
  }
}
signed main(){
  int n;
  cin>>n;
  for(int i=0,k;i<n;i++){
    cin>>id[i]>>k;
    G[id[i]].resize(k);
    for(int j=0;j<k;j++){
      cin>>G[id[i]][j];
      used[G[id[i]][j]]=1;
    }
  }
  memset(pa,-1,sizeof(pa));
  for(int i=0;i<n;i++){
    if(!used[i]) dfs(i,0);
  }
  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": parent = "<<pa[i]<<", depth = "<<dp[i];
    if(pa[i]<0) cout<<", root, [";
    else if(!G[i].size()) cout<<", leaf, [";
    else cout<<", internal node, [";
    for(int j=0;j<(int)G[i].size();j++){
      if(j) cout<<", ";
      cout<<G[i][j];
    }
    cout<<"]"<<endl;
  }
  return 0;
}

Measured memory_bytes: 9464
def resolve():
    N = int(input())
    a = list(map(int,input().split()))
    DP = [[2 ** 63 -1  for _ in range(N+1)] for _ in range(N)]
    SUM = [[0 for _ in range(N+1)] for _ in range(N+1)]

    SUM[0][0] = 0
    for i in range(N):
        for j in range(i,N):
            SUM[i][j+1] = SUM[i][j] + a[j]
            if i < j:
                SUM[i+1][j] = SUM[i][j] - a[i]

    for i in range(N):
        j = i+1
        DP[i][j] = 0

    for w in range(2,N+1):
        for i in range(N+1-w):
            j = i + w
            for k in range(i,j):
                DP[i][j] = min(DP[i][k]+DP[k][j]+SUM[i][j],DP[i][j])
    print(DP[0][N])
resolve()

Measured memory_bytes: 48016
fun main(args : Array<String>) {
    val (n, d) = readLine()!!.split(" ").map { it.toLong() }
    val pp = Array(n.toInt()) { readLine()!!.split(" ").map { it.toLong() } }

    var cnt = 0

    pp.forEach { p ->
        if ((p[0] * p[0]) + (p[1] * p[1]) <= d*d) cnt++
    }

    println(cnt)
}

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

int main(){
    string n; cin >> n;
    int s[4];
    for(int i = 0; i < n.length(); i++) s[i] = n[i] - '0'; 

    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 2; k++){
                int sum = s[0];
                string t = to_string(s[0]);

                if(i == 0){
                    sum += s[1];
                    t += "+" + to_string(s[1]);
                }else {
                    sum -= s[1];
                    t += "-" + to_string(s[1]);
                }if(j == 0){
                    sum += s[2];
                    t += "+" + to_string(s[2]);
                }else{ 
                    sum -= s[2];
                    t += "-" + to_string(s[2]);
                }if(k == 0){
                    sum += s[3];
                    t += "+" + to_string(s[3]);
                }else{
                    sum -= s[3];
                    t += "-" + to_string(s[3]);
                }     
                if(sum == 7){
                    t += "=7";
                    cout << t << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double n,m,d;
  cin >> n >> m >> d;
  double ans = 0.0;
  REP(i,m-1){
    if(d==0) ans += 1.0 / n;
    else ans += 2.0 * (n-d) / (n*n);
  }
  printf("%.9f\n", ans);
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a,b,c;
		Scanner in=new Scanner(System.in);
		a=in.nextInt();
		b=in.nextInt();
		c=in.nextInt();
		if(a<b&&b<c)
		{
		    System.out.println("Yes");
		}else
		System.out.println("No");

	}

}



Measured memory_bytes: 26176
# Author: cr4zjh0bp
# Created: Tue Feb 25 22:04:14 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

x, y = na()

if x == 0 or y == 0:
    if x > y:
        print(abs(x - y) + 1)
    else:
        print(abs(x - y))
elif (x < 0 and y > 0) or (x > 0 and y < 0):
    print(abs(-x - y) + 1)
elif x > y:
    print(abs(-x - -y) + 2)
else:
    print(abs(x - y))

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k) = get!(usize, usize);
    if k == 1 {
        println!("0");
        return;
    }
    println!("{}", n-k);
}


Measured memory_bytes: 8572
# coding: utf-8
# Here your code !

def func():
    result = ""
    
    while (True):
        try:
            line = input().rstrip()
            numbers = line.split(" ")
            for i,item in enumerate(numbers):
                numbers[i]=int(item)
                
        except:
            print("input error")
            return -1
        
        numbers.sort()
        
        bool=True
        resultsub = ""
        for item in numbers:
            bool = bool and (item == 0)
            resultsub += str(item)+" "

        if(bool):
            break

        result += resultsub.rstrip(" ")+"\n"

    print(result.rstrip())

func()

Measured memory_bytes: 7616
#include <iostream>
#include <algorithm>
using namespace std;
long long v[100001],ans[100001];
struct struct2
{
    long long x;
    long long sortp;
    long long nr;
};
struct2 abc[100001];

bool cmp(struct2 a, struct2 b) {
    if(a.sortp<b.sortp)
        return 1;
    else return 0;
}

int main()
{
    int n,m,i,j;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>abc[i].x>>abc[i].sortp;
        abc[i].nr=i;
    }
    sort(abc+1,abc+m+1,cmp);
    for(i=1;i<=m;i++)
    {
        ans[abc[i].nr]=abc[i].x*1000000+v[abc[i].x]+1;
        v[abc[i].x]++;
    }
    for(i=1;i<=m;i++)
    {
        printf("%012lld\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 5376
#N, K = [int(i) for i in input().split()]
S = input()

a = int(S[:2])
b = int(S[2:])

if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=b<=12:
  print("YYMM")
elif 1<=a<=12:
  print("MMYY")
else:
  print("NA")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
const int nmax = 1e6 + 3;
long long d[nmax][5], n;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;

    if(n == 1)
    {
        cout << 0;
        return 0;
    }

    if(n == 2)
    {
        cout << 2;
        return 0;
    }

    d[0][0] = 1;

    for(int i = 1; i <= n; ++i)
    {
        d[i][0] = d[i - 1][0] * 8 % mod;
        d[i][1] = (d[i - 1][0] + d[i - 1][1] * 9) % mod;
        d[i][2] = (d[i - 1][0] + d[i - 1][2] * 9) % mod;
        d[i][3] = (d[i - 1][3] * 10 + d[i - 1][1] + d[i - 1][2]) % mod;
    }

    cout << d[n][3];
    return 0;
}


Measured memory_bytes: 42584
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n){
	if(n == 2 || n == 3) return true; 
	if(n % 6 != 1 && n % 6 != 5) return false; 
	for(int i = 2; i * i <= n; i++){
		if(n % i == 0) return false; 
	}
	return true; 
}
int main(){
	vector<int> P;
	for(int i = 3; i < 10000; i+=2){
		if(is_prime(i)) P.push_back(i); 
	}
	long long A[1010][1010] = {}; 
	for(int i = 0; i <= 500; i++){
		for(int j = 0; j <= 500; j++){
			A[i*2][j*2] = P[i] * P[501+j]; 
		}
	}
	for(int i = 0; i <= 499; i++){
		for(int j = 0; j <= 499; j++){
			A[i*2+1][j*2+1] = A[i*2][j*2] * A[i*2+2][j*2+2] + 1; 
		}
	}
	long long ans[510][510] = {}; 
	for(int i = 0; i < 500; i++){
		for(int j = 0; j < 500; j++){
			ans[i][j] = A[500-i+j][i+j]; 
		}
	}
	int N; cin >> N; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cout << ans[i][j] << " "; 
		}
		cout << endl; 
	}
}

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

int main()
{
  string s;
  int a;
  cin >> s;

  if(s=="SUN"){
    a = 7;
  }else if(s=="MON"){
    a = 6;
  }else if(s=="TUE"){
    a = 5;
  }else if(s=="WED"){
    a = 4;
  }else if(s=="THU"){
    a = 3;
  }else if(s=="FRI"){
    a = 2;
  }else{
    a = 1;
  }

  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace Tenka1_2018_D___Crossing
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solve());
        }
        static string solve()
        {
            var N = int.Parse(Console.ReadLine());
            var len = 1;
            while (true)
            {
                if (2 * N == len * (len + 1)) break;
                if (2 * N < len * (len + 1)) return "No";
                len++;
            }

            var sets = new List<int>[len + 1];
            for (int i = 0; i < len + 1; i++)
            {
                sets[i] = new List<int>();
                sets[i].Add(len);
            }
            var n = 1;
            for (int i = 0; i < len + 1; i++)
            {
                for (int j = i + 1; j < len + 1; j++)
                {
                    sets[i].Add(n);
                    sets[j].Add(n);
                    n++;
                }
            }

            var result = new StringBuilder();
            result.AppendLine("Yes");
            result.AppendLine((len + 1).ToString());
            foreach (List<int> s in sets)
            {
                result.AppendLine(string.Join(" ", s));
            }
            return result.ToString();
        }
    }
}

Measured memory_bytes: 24276
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int min_cost = 2 * 5000 * 100000;
    for (int num_C = 0; num_C / 2 <= 100000; num_C++) {
        int num_A = 0, num_B = 0;
        if (num_C / 2 < X) {
            num_A = X - num_C / 2;
        }
        if (num_C / 2 < Y) {
            num_B = Y - num_C / 2;
        }
        int sum = A * num_A + B * num_B + C * num_C;
        min_cost = fmin(min_cost, sum);
    }
    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  char a, b;
  cin >> a >> b;
  if (a == 'H' && b == 'H') {
    cout << 'H' << endl;
  } else if (a == 'H' && b == 'D') {
    cout << 'D' << endl;
  } else if (a == 'D' && b == 'H') {
    cout << 'D' << endl;
  } else {
    cout << 'H' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<regex>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>

#pragma warning(disable:4996)
using namespace std;

int K;
int S;

int getAns() {
	int tempAns = 0;
	for (int i = 0; i <= min(K, S); ++i) {
		if (S - i <= 2 * K) {
			int h = min(K, S - i);
			int l = max(S - i - K, 0);
			if (h >= l) {
				tempAns += h - l + 1;
			}
		}
	}
	return tempAns;
}

int main() {
	scanf("%d%d", &K, &S);
	printf("%d\n", getAns());
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int t=0,ma=0;
  for(char c:S){
    if(c=='T')
      t++;
    else
      t--;
    ma=max(t,ma);
  }
  cout<<ma*2<<endl;
}

Measured memory_bytes: 3648
// JOI11-quest3.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

void sort(int a[], int n) {
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] < v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
}

int main(void)
{
	int ntopping, dough_dollar, topping_dollar, dough_calorie;
	int topping_calorie[100], dollar, calorie, piza;

	scanf("%d", &ntopping);
	scanf("%d %d", &dough_dollar, &topping_dollar);
	scanf("%d", &dough_calorie);
	for (int i = 0; i < ntopping; i++) {
		scanf("%d", &topping_calorie[i]);
	}

	dollar = dough_dollar;
	calorie = dough_calorie;
	piza = dough_calorie / dough_dollar;
	sort(topping_calorie, ntopping);

	for (int i = 0; i < ntopping; i++) {
		dollar += topping_dollar;
		calorie += topping_calorie[i];

		if (piza < calorie / dollar) {
			piza = calorie / dollar;
		}
	}

	printf("%d\n", piza);

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>



int main(void)
{
	double a ,pi=3.14159265359;
	
	scanf("%lf", &a);
	
	printf("%f %f",a*a*pi ,2*a*pi);
	
	
	
	
	
	
	
	
	
	
	
	
	
 } 


Measured memory_bytes: 2588