akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, ans = 0, x = 0, y = 0, z = 0;
  cin >> n;
  rep(i,n) {
    string s;
    cin >> s;
    int siz = s.length();
    rep(i,siz-1) {
      if (s[i] == 'A' && s[i+1] == 'B') ans++;
    }
    if (s[0] == 'B' && s[siz-1] == 'A') z++;
    else if (s[0] == 'B') y++;
    else if (s[siz-1] == 'A') x++;
  }
  if (z - 1 > 0) ans += z-1;
  if (x > 0 && z > 0) {
    ans += 1;
    x--;
  }
  if (y > 0 && z > 0) {
    ans += 1;
    y--;
  }
  ans += min(x, y);
  cout << ans << endl;
  return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if (n % 2 == 1)
    {
        ll l = A[n / 2];
        ll r = B[n / 2];
        cout << r - l + 1 << endl;
    }
    else
    {
        long double l = (A[n / 2 - 1] + A[n / 2]) / 2.0;
        long double r = (B[n / 2 - 1] + B[n / 2]) / 2.0;
        cout << (ll)((r - l) / 0.5) + 1 << endl;
    }
}

Measured memory_bytes: 6380
def main():
    N = int(input())
    numbers = list(map(int, input().split(" ")))
    answer = 0
    odds = 0
    while odds < N:
        odds = 0
        for i in range(N):
            if not numbers[i] % 2:
                numbers[i] //= 2
                answer += 1
            else:
                odds += 1
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, k;
    cin >> n >> k;

    ll part1 = n / k;
    ll part2 = 0;

    if (k % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            if (i % k == k / 2)
            {
                part2++;
            }
        }
    }
    cout << part1 * part1 * part1 + part2 * part2 * part2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x, y) cout <<x<<" "<<y<<endl
#define nl endl
const int N = 1e5+10;

int main()
{
    int a,b;
    scanf("%d", &a);
    int flag = false;
    for(int i = 1; i <= 9; ++i)
    for(int j = 1; j <= 9; ++j) if(i*j == a) {
        flag =true;
        break;
    }
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
arr = list(map(int, input().split(" ")))
stick = defaultdict(int)
for c in arr :
    stick[c] += 1 

s = sorted(list(stick.keys()))

n = len(s)
res = 0
for i in range(n) :
    for j in range(i+1, n) :
        v = stick[s[i]]*stick[s[j]]
        for k in range(j+1, n) :
            if s[i]+s[j] <= s[k] : 
                continue
            res += v*stick[s[k]]
print(res)

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
typedef long long Long;
const int maxN = 50;
int n, a[maxN + 10], b[maxN + 10], use[maxN + 10], cnt;
Long ans;
bool vis[maxN + 10];

void Dfs(int p) {
    if (vis[p]) return;
    vis[p] = 1;
    for (int i = 1; i <= cnt; ++i)
        Dfs(p % use[i]);
}

bool Check(int p) {
    for (int i = 1; i < p; ++i) use[++cnt] = i;
    for (int i = 1; i <= n; ++i) {
        memset(vis, 0, sizeof vis);
        Dfs(a[i]);
        if (!vis[b[i]]) {
            for (int i = 1; i < p; ++i) --cnt;
            return 1;
        }
    }
    for (int i = 1; i < p; ++i) --cnt;
    return 0;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
    for (int i = 50; i >= 1; --i)
        if (Check(i)) {
            use[++cnt] = i;
            ans += 1ll << i;
            if (Check(i)) {
                printf("-1"); return 0;
            }
        }
    printf("%lld", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int A[100000];
int F[100000];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < n + 1; ++i) {
        cin >> A[i];
    }
    F[1] = 0;
    F[2] = (int) abs(A[2] - A[1]);
    for (int i = 3; i < n + 1; ++i) {
        F[i] = (int) min(F[i - 1] + abs(A[i] - A[i - 1]), F[i - 2] + abs(A[i] - A[i - 2]));
    }
    cout << F[n];
    return 0;
}

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



int main()

{	
	int n,s=0,x,a;
	cin>> n;
	a=n;
	while (n>0)
	{	x=n%10;
		s=s+x;
		n=n/10;
		}
	if(a%s==0)
	cout<< "Yes";
	else 
	cout<< "No";
		
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

ans=0

chk=True
cnt=0
while chk:
    cnt+=1
    for i in product([3,5,7],repeat=cnt):
        if 3 in i and 5 in i and 7 in i:
            if n>=int("".join(map(str, i))):
                ans+=1
            else:
                chk=False
print(ans)

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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,3)if(s[i]=='1')ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,k,a[N];
ll ans;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    for(int i=1;i<=n;i++)
        if(i>k) ans+=a[i];
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
N,K = (int(i) for i in input().split())
onon = 2
hoge = 3
if (N-1) * (N-2) // 2 < K:
    print(-1)
else:
    print(N-1 +((N -1) * (N-2) // 2 - K))
    for i in range(N-1):
        print("1" + " " + str(i+2))
    for i in range((N -1) * (N-2) // 2 - K):
        print(str(onon) + " " + str(hoge))
        hoge += 1
        if hoge > N:
            hoge = onon + 2
            onon += 1

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const int mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int n,m;
int a,b;
int q;
int v,d,c;
int dp[100000+5][15]={};
vector<vector<int>> g(100000+5);
int V[100000+5],D[100000+5],C[100000+5];

int func(int v,int d,int c){
    if (dp[v][d]!=0) return c;
    if (d==0) return dp[v][d]=c;
    for(auto i: g[v]){
        func(i,d-1,c);
    }
    return dp[v][d]=c;
}

int main(){
    cin >> n >> m;
    rep(i,n) g[i].pb(i);
    rep(i,m){
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    cin >> q;
    rep(i,q) cin >> V[i] >> D[i] >> C[i];
    rrep(i,q-1){
        func(V[i]-1,D[i],C[i]);
    }
    rep(i,n){
        cout << dp[i][0] << endl;
    }
    return 0;
}

Measured memory_bytes: 13696
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int[] array = new int[3];
		Scanner input = new Scanner(System.in);
		array[0] = input.nextInt();
		array[1] = input.nextInt();
		array[2] = input.nextInt();
		int num = 0;
		num = array[2];
		array[2] = array[1];
		array[1] = array[0];
		array[0] = num;
		
		for(int i =0;i < array.length; i++) {
			System.out.print(array[i] + " ");	
		}
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
	string s; cin >> s;
    ll ss = s.size();
 
    int a_count = 0;
    // int bc_count = 0;
    ll ans = 0;
    ll cnt = 0;
    
    int i = 0;
    while (i < ss-1) {
        if (s[i] == 'A') {
            a_count += 1;
            i += 1;
        } else if (s[i] == 'B' && s[i+1] == 'C') {
            ans += a_count;
            i += 2;
            // bc_count = 0;
        } else {
            a_count = 0;
            i += 1;
        }
    }
    cout << ans << endl;
	
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t =1; 
//	cin>>t; 
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <sstream>
//#include <fstream>

using namespace std;

const int MAX_N = 1000000;
bool hamming[MAX_N + 1];

bool ishamming (int n )
{
	while (n % 2 == 0 ){
		n /= 2;
	} // end while
	while (n % 3 == 0 ){
		n /= 3;
	} // end while
	while (n % 5 == 0 ){
		n /= 5;
	} // end while

	return (n == 1 );
}
	
void make_hamming (void )
{
	memset (hamming, false , sizeof (hamming ) );

	for (int i = 1; i <= MAX_N; ++i){
		if (ishamming(i ) ){
			hamming[i] = true;
		} // end if
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.hamming", "r", stdin );
	string str = "";

	make_hamming();

	while (getline (cin, str ) ){
		int m, n;

		if (str.length() == 1 && str[0] == '0'){
			break;
		} // end if

		stringstream ss (str );
		ss >> m >> n;
		
		int res = 0;

		for (int i = m; i <= n; ++i){
			if (hamming[i] ){
				++res;
			} // end if
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
#define d read()
ll a,b,n;
ll mx,num;
int main(){
//	while(1){
//		mx=num=0;
//		a=d,b=d,n=d;
//	//if(a>b)swap(a,b);
//	f(i,1,n){
//		ll k=floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b);
//		if(k>mx)mx=k;
//	}
//	f(i,1,n)
//		if(floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b)==mx)cout<<i<<" ";
//	cout<<endl;
//	}
	scanf("%lld%lld%lld",&a,&b,&n);
	if(a>=b){
		if(b-1<=n)cout<<a*(b-1)/b-a*((b-1)/b);
		else cout<<a*n/b-a*(n/b);
		return 0;
	}
	if(b-b/a<=n){cout<<a*(b-b/a)/b-a*((b-b/a)/b);return 0;}
	cout<<a*n/b-a*(n/b);
	return 0;
}


Measured memory_bytes: 3684
n,y = [int(e) for e in input().split()]
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int A, B, C; cin >> A >> B >> C;
  string result = "No";
  if (A==B&&A!=C) result = "Yes";
  if (B==C&&B!=A) result = "Yes";
  if (C==A&&C!=B) result = "Yes";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 764
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var weathers = new string[] { "Sunny", "Cloudy", "Rainy" };

        var input = Console.ReadLine();

        foreach( var index in Enumerable.Range(0, weathers.Length) )
        {
            if (index == weathers.Length - 1)
            {
                Console.WriteLine(weathers[0]);
                return;
            }

            if (input.Equals(weathers[index]))
            {
                Console.WriteLine(weathers[index + 1]);
                return;
            }
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 1e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        cout<<(n+1)/2;

    }




   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll N, M;
  cin >> N >> M;
  if (N == 1 && M == 1)
  {
    cout << 1 << endl;
  }
  else if (N == 1 && M != 1)
  {
    cout << M - 2 << endl;
  }
  else if (N >= 2 && M >= 2)
  {
    cout << (N - 2) * (M - 2) << endl;
  }
  else
  {
    cout << N * M - 2 << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <array>

using namespace std;

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

int n;
array<int, 50> d;

int calc(array<bool, 25>& arr, int i) {
    if(i == n) {
        int a = -24, min = 24;
        rep(k, 25) {
            if(arr[k]) {
                if(min > k - a) min = k - a;
                a = k;
            }
        }
        return min;
    } else {
        int x = 0, y = 0;
        if(!arr[d[i]]) {
            arr[d[i]] = true;
            x = calc(arr, i + 1);
            arr[d[i]] = false;
        }

        if(!arr[24-d[i]]) {
            arr[24-d[i]] = true;
            y = calc(arr, i + 1);
            arr[24-d[i]] = false;
        }

        if(x < y) x = y;
        return x;
    }
}

int main() {
    cin >> n;
    rep(i, n) cin >> d[i];
    array<bool, 25> arr;
    fill(arr.begin(), arr.end(), false);
    arr[0] = arr[24] = true;
    cout << calc(arr, 0) << endl;
}

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

int main(){
	
	int a, b, c;
	int tmp;
	cin >> a >> b >> c;
	
	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
		
	}if(b > c){
		tmp = b;
		b = c;
		c = tmp;
	}if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	cout << a <<" "<< b <<" "<< c << endl;
	
	return 0;
}

Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int ans = 0;

int main() {
    cin >> n;
    while (n--) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int time = Convert.ToInt32( Console.ReadLine(),10 );

            int hour = time / 3600;
            time = time % 3600;

            int min = time / 60;
            time = time % 60;

            int sec = time;

            Console.WriteLine(hour + ":" + min + ":" + sec);
        }
    }
}

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

int main(){
    int A,B,x1,x2,y1,y2;
    cin>>A>>B;
    x1 = (25*A+1)/2;
    x2 = x1 + 11;
    y1 = 10*B;
    y2 = y1+9;
    if(x1<=y1&&y1<=x2){
        cout<<y1<<endl;
    }else if(x1<=y2&&y1<=x1){
        cout<<x1<<endl;
    }else{
        cout<<"-1"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    ll N = 0;
    cin >> N;
    vector<ll > a(N);
    map<ll, ll > mp;
    for(ll i = 0; i < N; i++){
        cin >> a[i];
        mp[a[i]]++;
        mp[a[i] + 1]++;
        mp[a[i] - 1]++;
    }
    //一番数が多いのを探す
    ll ans = 0;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        ans = max(ans, iter->second);
    }
    

    cout << ans << endl;

} 

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  
  int A,B;
  char x;
  cin >> A >> x >> B;
  
  if( x == '+' ){
    
  cout << A+B << endl;
  
  }
  
  else{
    
  cout << A-B << endl;
    
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}
template <typename T> void cout_join(vector<T> &v,string d=" "){REP(i,v.size()){if(i>0)cout<<d;cout<<v[i];}cout<<endl;}

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

  int n,m; cin >> n >> m;
  vector<int> p(m), y(m);
  REP(i,m) cin >> p[i] >> y[i];

  vector<vector<pair<int,int>>> c(n);

  REP(i,m){
    c[p[i]-1].push_back(make_pair(y[i],i));
  }
  
  REP(i,n){
    sort(ALL(c[i]));
  }

  REP(i,m){
    int a = lower_bound(ALL(c[p[i]-1]), make_pair(y[i],i)) - c[p[i]-1].begin();
    printf("%06d%06d\n", p[i], a+1);
  }
  
  return 0;
}


Measured memory_bytes: 7808
// URL: https://atcoder.jp/contests/abc173/tasks/abc173_a

import std.algorithm, std.array, std.bitmanip, std.container, std.conv, std.format,
       std.functional, std.math, std.range, std.traits, std.typecons, std.stdio, std.string;

version(unittest) {} else
void main()
{
  int N; io.getV(N);
  io.putB(N%1000 == 0, 0, 1000 - N%1000);
}

auto io = IO!()();
import std.stdio;
struct IO(alias IN = stdin, alias OUT = stdout)
{
  import std.meta : allSatisfy;
  import core.stdc.stdlib : exit;

  void getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }
  void getA(T)(size_t n, ref T v)
    if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }
  void getC(T...)(size_t n, ref T v)
    if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v) w = new typeof(w)(n);
    foreach (i; 0..n) foreach (ref w; v) get(w[i]);
  }
  void getM(T)(size_t r, size_t c, ref T v)
    if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }
  template getS(E...)
  {
    void getS(T)(size_t n, ref T v)
    {
      v = new T(n);
      foreach (ref w; v) foreach (e; E) mixin("get(w."~e~");");
    }
  }

  const struct PutConf
  {
    bool newline = true, flush, exit;
    string floatFormat = "%.10f", delimiter = " ";
  }

  void put(alias conf = "{}", T...)(T v)
  {
    mixin("const PutConf c = "~conf~"; putMain!c(v);");
  }
  void putB(alias conf = "{}", S, T)(bool c, S t, T f)
  {
    if (c) put!conf(t);
    else put!conf(f);
  }
  void putRaw(T...)(T v)
  {
    OUT.write(v);
    OUT.writeln;
  }

  private
  {
    dchar[] buf;
    auto sp = (new dchar[](0)).splitter;

    void nextLine()
    {
      IN.readln(buf);
      sp = buf.splitter;
    }
    void get(T)(ref T v)
    {
      if (sp.empty) nextLine();
      v = sp.front.to!T;
      sp.popFront();
    }

    void putMain(PutConf c, T...)(T v)
    {
      foreach (i, w; v) {
        putOne!c(w);
        if (i+1 < v.length) OUT.write(c.delimiter);
      }
      static if (c.newline) OUT.writeln;
      static if (c.flush) OUT.flush();
      static if (c.exit) exit(0);
    }
    void putOne(PutConf c, T)(T v)
    {
      static if (isInputRange!T && !isSomeString!T) putRange!c(v);
      else static if (isFloatingPoint!T) OUT.write(format(c.floatFormat, v));
      else static if (hasMember!(T, "fprint")) v.fprint(OUT);
      else OUT.write(v);
    }
    void putRange(PutConf c, T)(T v)
    {
      auto w = v;
      while (!w.empty) {
        putOne!c(w.front); w.popFront();
        if (!w.empty) OUT.write(c.delimiter);
      }
    }
  }
}


Measured memory_bytes: 2732
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
fn main() {
    input! {
        n:i64,
        an:[i64;n],
    }
    let mut map = HashMap::new();
    for &a in &an {
        let posi = a + 1;
        let nega = a - 1;
        *map.entry(posi).or_insert(0) += 1;
        *map.entry(nega).or_insert(0) += 1;;
        *map.entry(a).or_insert(0) += 1;
    }
    let ans = map.into_iter().map(|(k, v)| v).max().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 12540
#include <stdio.h>

int main(void){
	
	int i;
	int j;
	int k;
	int n;
	int count;
	int sum;
	static int prime[1000001];
	
	for (i = 1; i <= 1000000; i++){
		if (i == 2){
			prime[i] = 1;
		}
		else if (i != 1){
			k = 0;
			for (j = 2; j * j <= i; j++){
				if (i % j == 0){
					k = 1;
					break;
				}
			}
			if (k == 0){
				prime[i] = 1;
			}
		}
	}
	while (1){
		count = 0;
		sum = 0;
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		i = 0;
		while (count < n){
			if (prime[i] == 1){
				sum += i;
				count++;
			}
			i++;
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 4504
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

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

Measured memory_bytes: 3628
N=int(input())
S=[[] for i in range(N)]
for i in range(N):
    s,p=map(str,input().split())
    S[i]=[s,int(p)*(-1),i]

S.sort(key=lambda x:(x[0],x[1]))

for i in range(N):
    print(S[i][2]+1)

Measured memory_bytes: 8892
import java.util.*;
 
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a,b,c;
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		
		if(a+b>=c)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21588
import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i+1] >= b:
            A_ls[i+1] -=b
            S+=b
        else:
            S+=A_ls[i+1]
            A_ls[i+1] = 0 
    else:
        S += b

print(S)


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

using namespace std;

const int N = (int)1e6 + 5;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; ++i) {
    cout << s[i] << t[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) {
    ll res = 1;    x = x % p;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y = y>>1;    x = (x*x) % p;
    } return res;
}

int main()
{
    Imposter

    ll x,n;
    cin>>x>>n;
    ll a[n];
    input(a,n);ll mini=102,temp;
    map<ll,ll>m;
    f(n)m[a[i]]++;

        for(ll j=0;j<102;j++)
        {

            if(mini>abs(x-j)and m[j]==0)
        {

            mini=abs(x-j);
            temp=j;
        }
}
    cout<<temp<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
		if(i%2==0)
			ans++;
	printf("%.10lf",(double)(n-ans)/(double)n);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int h, w;
    cin >> h >> w;
    string board[h];
    int L[h][w], R[h][w], U[h][w], D[h][w];
    rep(i,h) cin >> board[i];
    rep(i,h) {
        int l = 0, r = 0;
        rep(j,w){
            if(board[i][j] == '#'){
                l = 0;
                L[i][j] = l;
                continue;
            }
            l++;
            L[i][j] = l;
        }
        rep(j,w){
            int k = w-j-1;
            if(board[i][k] == '#'){
                R[i][k] = 0;
                r = 0;
                continue;
            }
            r++;
            R[i][k] = r;
        }
    }
    rep(j,w){
        int u = 0, d = 0;
        rep(i,h){
            if(board[i][j] == '#'){
                U[i][j] = 0;
                u = 0;
                continue;
            }
            u++;
            U[i][j] = u;
        }
        rep(i,h){
            int k = h-i-1;
            if(board[k][j] == '#'){
                D[k][j] = 0;
                d = 0;
                continue;
            }
            d++;
            D[k][j] = d;
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w) {
        if(board[i][j] == '#') continue;
        chmax(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 66816
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,p;cin>>n>>p;
  vll a(n);
  COMinit();
  ll x=0,y=0,ans=0;
  rep(i,0,n){
    cin>>a[i];
    if(a[i]%2){
      x++;
    }
    else y++;
  }
  ans=pow(2,y);
  if(p){
    ll cnt=0;
    for(ll i=1;i<=x;i+=2){
      cnt+=COM(x,i);
    }
    ans*=cnt;
  }
  else{
    ll cnt=0;
    for(ll i=0;i<=x;i+=2){
      cnt+=COM(x,i);
    }
    ans*=cnt;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15984
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int px, py, pt;
	px = py = pt = 0;
	int n;
	cin >> n;
	rep(i, n){
		int t, x, y;
		cin >> t >> x >> y;
		int dx = abs(x-px), dy = abs(y-py), dt = abs(t - pt);
		if(dt % 2 == 0){
			if((dx + dy) % 2 == 1 || dx + dy > dt){
				cout << "No" << endl;
				return 0;
			}
		}else{
			if((dx + dy) % 2 == 0 || dx + dy > dt){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int n,x,m;
int l[10],r[10],s[10];
int ans[10],tmp[10],sum,interval;

void rec(int d){
  if(d==n){
    for(int i=0;i<m;i++){
      interval = 0;
      for(int j=l[i];j<=r[i];j++)interval += tmp[j];
      if(interval != s[i])return;
    }
    interval = 0;
    for(int i=0;i<n;i++)interval += tmp[i];
    if(interval > sum){
      sum = interval;
      for(int i=0;i<n;i++)ans[i] = tmp[i];
    }
    return;
  }

  for(int i=0;i<=x;i++){
    tmp[d] = i;
    rec(d+1);
  }
}

int main(){
  cin >> n >> x >> m;
  for(int i=0;i<m;i++){
    cin >> l[i] >> r[i] >> s[i];
    l[i]--; r[i]--;
  }

  sum = -1;
  rec(0);
  if(sum<0)cout << sum << endl;
  else{
    for(int i=0;i<n;i++){
      cout << ans[i] << ((i==n-1)?"\n":" ");
    }
  }
}

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

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vector<ii> > vvii;
typedef long long ll;

int main(){

	int n, h;
	cin >> n >> h;
	int m[10][10];
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> m[i][j];
		}
	}

	for(int k = 0; k < 10; k++){
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
			}
		}
	}

	int r = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < h; j++){
			int x;
			cin >> x;
			if(x != -1 and x != 1){
				r += m[x][1];
			}
		}
	}
	cout << r << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+7;
bool vis[maxn];
int a[maxn],b[maxn],p[maxn],fa[maxn];
ll c[maxn];
ll dp[maxn],sum[maxn];
struct Edge{
	int nxt,to;
}G[maxn<<1],T[maxn<<1];
int bG=0,hG[maxn],bT=0,hT[maxn<<1];
void addG(int x,int y){
	G[bG].nxt=hG[x];G[bG].to=y;hG[x]=bG++;
	G[bG].nxt=hG[y];G[bG].to=x;hG[y]=bG++;
}
void addT(int x,int y){
	T[bT].nxt=hT[x];T[bT].to=y;hT[x]=bT++;
	T[bT].nxt=hT[y];T[bT].to=x;hT[y]=bT++;
}
bool cmp(int x,int y){
	return c[x]<c[y];
}
void dfs(int v,int p){
	sum[v]=b[v];
	for (int i=hT[v];i!=-1;i=T[i].nxt){
		int u=T[i].to;
		if (u==p) continue;
		dfs(u,v);
		sum[v]+=sum[u];
	}
	dp[v]=sum[v]+c[v];
	for (int i=hT[v];i!=-1;i=T[i].nxt){
		int u=T[i].to;
		if (u==p) continue;
		dp[v]=min(dp[v],sum[v]-sum[u]+max(dp[u],c[v]));
	}
}
int Get(int x){
	if (fa[x]==x) return x;
	fa[x]=Get(fa[x]);return fa[x];
}
int main(){
	memset(hG,-1,sizeof(hG));
	memset(hT,-1,sizeof(hT));
	int n,m;scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++){
		scanf("%d%d",a+i,b+i);
		c[i]=max(a[i]-b[i],0);
		p[i]=i;fa[i]=i;
	}
	for (int i=0;i<m;i++){
		int u,v;scanf("%d%d",&u,&v);u--;v--;addG(u,v);
	}
	sort(p,p+n,cmp);
	for (int i=0;i<n;i++){
		int v=p[i];
		vis[v]=true;
		for (int e=hG[v];e!=-1;e=G[e].nxt){
			int u=G[e].to;
			int fu=Get(u);
			if (vis[u] && v!=fu){
				fa[fu]=v;
				addT(fu,v);
			}
		}
	}
	dfs(p[n-1],-1);
	printf("%lld\n",dp[p[n-1]]);
	return 0;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;

int n;
string s;
int W[MAXN], E[MAXN];
void solve(){
    int i = 0;
    int w = 0, e = 0;
    for(i = 0; i < n; i++){
        if(s[i] == 'W')
            w++;
        else
            e++;
        W[i] = w;
        E[i] = e;
    }
    int mn = MAXN;
    for(i = 0; i < n; i++){
        if(i == 0)
            mn = min(mn, E[n - 1] - E[i]);
        else if(i == n - 1)
            mn = min(mn, W[i - 1]);
        else
            mn = min(mn, E[n - 1] - E[i] + W[i - 1]);
    }
    cout << mn;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int test = 1;
    //cin >> test;
    while(test--) {
        cin >> n >> s;

        solve();
    }
    //4689772647015
    return 0;
}

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a); i >=(b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod1=1000000007;
ll mod2=67280421310721;
ll mod3=998244353;
ll INF=1e18;

ll binpow1(ll a,ll b){
    ll res=1;
    while (b>0){
        if (b&1)
        res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

ll binpow2(ll a,ll b,ll m){
    a%=m;
    ll res=1;
    while (b>0){
        if (b & 1)
        res=res*a%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}

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

map<ll,ll> fact(ll n) {
    map<ll,ll> factorization;ll c=0;
    while (n % 2 == 0) {
        c++;
        n /= 2;
    }
    if(c>0)
    {
        factorization.insert({2,c});
    }c=0;
    for (ll d = 3; d * d <= n; d += 2) {
        while (n % d == 0) {
            c++;
            n /= d;
        }
        if(c>0)
    {
        factorization.insert({d,c});
    }c=0;
    }
    if (n > 1)
       {
           factorization.insert({n,1});
       }
    return factorization;
}

int main()
{ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    ll dp[a.length()+1][b.length()+1];
    FOR(i,0,a.length()+1)
    {
        FOR(j,0,b.length()+1)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else
            {
                if(a[i-1]==b[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else
                {
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
    }
    stack<char> s1;
    queue<pair<ll,ll>> q;
    q.push({a.length(),b.length()});
    while(!q.empty())
    {
        pair<ll,ll> s=q.front();
        q.pop();
        if(s.first>0 && s.second>0)
        {if(a[s.first-1]==b[s.second-1])
        {
            q.push({s.first-1,s.second-1});
            s1.push(a[s.first-1]);
        }
        else if(dp[s.first][s.second-1]>dp[s.first-1][s.second])
        {
            q.push({s.first,s.second-1});
        }
        else
        {
            q.push({s.first-1,s.second});
        }}
    }
    while(!s1.empty())
    {
        cout<<s1.top();
        s1.pop();
    }
    cout<<'\n';




	return 0;
}













Measured memory_bytes: 74000
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>

int main() {
    int n;
    std::cin >> n;

    std::vector< long double > xs(n), ys(n);
    for (auto &x: xs) std::cin >> x;
    for (auto &y: ys) std::cin >> y;

    double m1 = 0, m2 = 0, m3 = 0, minf = 0;
    for (int i = 0; i < n; ++i) {
        double a = std::abs(xs[i] - ys[i]);
        m1 += a;
        m2 += std::pow(a, 2);
        m3 += std::pow(a, 3);
        minf = std::max(minf, a);
    }

    m2 = sqrt(m2);
    m3 = cbrt(m3);

    std::cout << std::fixed << std::setprecision(20);
    std::cout << m1 << std::endl;
    std::cout << m2 << std::endl;
    std::cout << m3 << std::endl;
    std::cout << minf << std::endl;
}


Measured memory_bytes: 3536
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  rep(i, k) { a[i] = 0; }
  rep(i, n) sum += a[i];
  Cout(sum);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int n,m,i,j,x,y,ans=0,a[30]={0};
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> x;
        for(j=0;j<x;j++){
            cin >> y;
            a[y-1]++;
        }
    }
    for(i=0;i<m;i++){
        if(a[i]==n) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
program caddi2018b
  implicit none
  integer n, h, w
  integer, dimension(:,:), allocatable :: a

  read *, n, h, w
  allocate(a(2,n))
  read *, a
  print '(i0)', count(a(1,:) >= h .and. a(2,:) >= w)
end program caddi2018b


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <stack>
#define N 110
using namespace std;
stack<int> s;
int n;
int m[N][N];
int used[N];
int time = 1;
int bb_start[N];
int bb_end[N];
int getnext(int u){
    for(int i = 1; i <= n; i++){
        if(m[u][i] == 1 && used[i] == 0) return i;
    }
    return -1;
}
void dfs(int root){
    used[root] = 1;
    bb_start[root] = time++;

    while(!s.empty()) s.pop();
    s.push(root);
    while(!s.empty()){
        int u = s.top();
        int v = getnext(u);
        if(v != -1 && used[v] == 0){
            used[v] = 1;
            bb_start[v] = time++;
            s.push(v);
        } else{
            bb_end[u] = time++;
            s.pop();
        }
    }
}
int main(){
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) m[i][j] = 0;
    for(int i = 0; i < N; i++) used[i] = 0;
    scanf("%d", &n);
    for(int p = 0; p < n; p++){
        int node, k;
        scanf("%d %d", &node, &k);
        for(int i = 0; i < k; i++){
            int b;
            scanf("%d", &b);
            m[node][b] = 1;
        }
    }
    for(int i = 1; i <= n; i++) if(used[i] == 0) dfs(i);
    for(int i = 1; i <= n; i++){
        printf("%d %d %d\n", i, bb_start[i], bb_end[i]);
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;

  set<int> s;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    if (s.count(n) != 0) s.erase(n);
    else s.insert(n);
  }

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse

if n == 1
  puts 0
  exit
end

cnt = 2
ans = a.first
now_index = 1
while cnt < n do
  ans += a[now_index]
  cnt += 1
  if cnt != n
    ans += a[now_index]
    now_index += 1
    cnt += 1
    next
  end
end

puts ans

Measured memory_bytes: 31200
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int A, B, C;

int main() {
  cin >> A >> B >> C;
  if (A == B) {
    cout << C << endl;
  } else if (A == C) {
    cout << B << endl;
  } else {
    cout << A << endl;
  }

  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

long long choose(long long n) {
	return (n*(n - 1LL)) / 2LL;
}

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	int n; cin >> n;
	vector<long long> a(n), oc(n+1, 0LL);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		oc[a[i]] += 1LL;
	}
	long long sum = 0LL;
	for (int i = 0; i <= n; ++i) {
		sum += choose(oc[i]);
	}
	for (int i = 0; i < n; ++i) {
		cout << sum - choose(oc[a[i]]) + choose(oc[a[i]] - 1) << "\n";
	}
	return 0;
}

Measured memory_bytes: 5760
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

const uint64_t MOD = 1e9 + 7;

struct Number {
    uint64_t n;

    Number(uint64_t n = 0): n(n % MOD) {}

    Number operator * (const Number& m) const {
        return Number(n * m.n);
    }

    Number operator + (const Number& m) const {
        return Number(n + m.n);
    }

    friend istream& operator >> (istream& is, Number& num) {
        return is >> num.n;
    }
};

struct Matrix {
    int n, m;
    vector<vector<Number>> a;

    Matrix(int n, int m): n(n), m(m) {
        a.resize(n);
        for (auto& v : a) {
            v.resize(m);
            v.assign(m, Number(0));
        }
    }

    Matrix operator * (const Matrix& other) const {
        Matrix result(n, other.m);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < other.m; ++j) {
                result.a[i][j] = 0;
                for (int k = 0; k < m; ++k) {
                    result.a[i][j] = result.a[i][j] + a[i][k] * other.a[k][j];
                }
            }
        }
        return result;
    }
};

template<typename M>
M pow(M a, int p) {
    if (p == 1) return a;
    M b = pow(a, p / 2);
    b = b * b;
    if (p % 2 == 0) {
        return b;
    } else {
        return b * a;
    }
}


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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    vector<vector<Number>> x_pow(500, vector<Number>(500, 1));
    x_pow[0][0] = 1;
    for (uint64_t i = 1; i < 500; ++i) {
        x_pow[i][0] = 1;
        for (int p = 1; p < 500; ++p) {
            x_pow[i][p] = x_pow[i][p - 1] * Number(i);
        }
    }
    vector<vector<Number>> sum_pow(500, vector<Number>(500, 0));
    for (int i = 1; i < 500; ++i) {
        for (int p = 0; p < 500; ++p) {
            sum_pow[i][p] = sum_pow[i - 1][p] + x_pow[i - 1][p];
        }
    }

    int n, c;
    cin >> n >> c;
    vector<int> A(n), B(n);
    cin >> A >> B;
    Matrix V(c + 1, 1);
    V.a[0][0] = 1;
    for (int k = 0; k < n; ++k) {
        Matrix M(c + 1, c + 1);
        for (int i = 0; i <= c; ++i) {
            for (int j = 0; j <= i; ++j) {
                M.a[i][j] = Number(MOD + sum_pow[B[k] + 1][i - j].n - sum_pow[A[k]][i - j].n);
            }
        }
        V = M * V;
    }
    cout << V.a[c][0].n << endl;
}


Measured memory_bytes: 8904