akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
from numba import njit


def input(): return sys.stdin.readline().rstrip()


@njit
def solve(N, P):
    W = N + 2
    dp = np.zeros((W, W), np.int32)
    for _ in range(4):
        dp = dp.T[::-1]
        for n in range(1, (N + 1) // 2 + 1):
            dp[n, n:-n] = n
    filled = np.zeros_like(dp)
    filled[1:-1, 1:-1] = 1
    dp = dp.ravel()
    filled = filled.ravel()
    stack = np.empty_like(dp)
    ans = 0
    for n in P:
        n -= 1
        h, w = divmod(n, N)
        v = (h + 1) * W + (w + 1)
        ans += dp[v] - 1
        filled[v] = 0
        k = min(dp[v - 1], dp[v + 1], dp[v - W], dp[v + W])
        if dp[v] == k:
            return ans
        p = 0
        stack[0] = v
        dp[v] = k
        while p >= 0:
            v = stack[p]
            p -= 1
            for dx in (-1, 1, -W, W):
                w = v + dx
                k = dp[v] + filled[w]
                if dp[w] > k:
                    dp[w] = k
                    p += 1
                    stack[p] = w
    return ans


N = int(input())
P = np.array(input().split(), np.int32)

print(solve(N, P))


Measured memory_bytes: 124572
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a;
    cin >> a;
    int ans = 0;
    for(int i = 1; i <= a; i++){
        int keta = 0;
        int tmp = i;
        while(tmp > 0){
            keta ++;
            tmp /= 10;
        }
        if(keta%2 == 1){
            ans ++;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if ((0 < A && A < 10) && (0 < B && B < 10)){
        printf("%d\n", A * B);
    } else{
        printf("%d\n", -1);
    }
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
l = list(map(int,input().split()))
m = 10**9
for i in range(n-k+1):
  a = l[i]
  b = l[i+k-1]
  m = min(m,b-a+min(abs(a),abs(b)))
print(m)

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

int main() { 
    int x,y;
  cin >> x >> y;

for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= x; j++) {
    if (i * 2 + j * 4 == y && i + j == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  }
cout << "No" << endl;
  }

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int k, n, a[200000], fans = 0;
	vector<int>ans;
	cin >> k >> n;
	rep(i, n)cin >> a[i];
	rep(i, n-1) {
		int x = a[i + 1] - a[i];
		ans.push_back(x);
	}
	ans.push_back(k - a[n-1] + a[0]);
	sort(ans.begin(), ans.end());
	
	rep(i, n - 1)fans = fans + ans[i];
	cout << fans << endl;
}

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

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

    int n;
    cin >> n;

    int ten_sum = 0;
    int other_sum = 0;
    int other_min = 101;

    rep(i, n){
        int s;
        cin >> s;
        if(s%10) {
            other_sum += s;
            other_min = min(other_min, s);
        }
        else {
            ten_sum += s;
        }
    }

    if((ten_sum + other_sum)%10) cout << ten_sum + other_sum << endl;
    else{
        if(other_sum){
            cout << ten_sum + other_sum - other_min << endl;
        }
        else{
            cout << 0 << endl;
        }
    }



}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let d: Vec<u32> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            ans += d[i] * d[j];
        }
    }

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


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        long X = scanner.nextLong();
        long Y = scanner.nextLong();
        
        long x = X;
        long y = Y;
        long M = 0;
        
        if(X>Y){
            while(y != 0){
                M = x%y;
                x = y;
                y = M;
            }
            System.out.println(X*Y/x);
        }
        
        if(Y>X){
            while(x != 0){
                M = y%x;
                y = x;
                x = M;
            }
            System.out.println(X*Y/y);
        }
        
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC166F
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            string[] sa;
            line = Console.ReadLine();
            sa = line.Split(' ');
            int n = int.Parse(sa[0]);
            int m = int.Parse(sa[1]);

            int[] ha = new int[n];
            line = Console.ReadLine();
            sa = line.Split(' ');

            for (int i = 0; i < n; ++i)
            {
                ha[i] = int.Parse(sa[i]);
            }

            int[,] link = new int[m, 2];
            for (int i = 0; i < m; ++i)
            {
                line = Console.ReadLine();
                sa = line.Split(' ');

                link[i, 0] = int.Parse(sa[0]) - 1;
                link[i, 1] = int.Parse(sa[1]) - 1;
            }

            bool[] res = new bool[n];   // false: 条件にあうもの
            for (int i = 0; i < m; ++i)
            {
                int hl = ha[link[i, 0]];
                int hr = ha[link[i, 1]];

                if (hl == hr)
                {
                    res[link[i, 0]] = true;
                    res[link[i, 1]] = true;
                }
                else if (hl > hr)
                {
                    res[link[i, 1]] = true;
                }
                else
                {
                    res[link[i, 0]] = true;
                }
            }

            int result = 0;
            for (int i = 0; i < n; ++i)
            {
                if (res[i] == false)
                {
                    result += 1;
                }
            }
            Console.WriteLine(result);
#if DEBUG
            Console.WriteLine();
#endif
        }

        private static bool check(int n, int[,] link, int m, int[] ha)
        {
            for (int i = 0; i < m; ++i)
            {
                int h = ha[n];
                if (link[i, 0] == n)
                {
                    int other = ha[link[i, 1]];
                    if (other >= h)
                    {
                        return false;
                    }
                }
                else if (link[i, 1] == n)
                {
                    int other = ha[link[i, 0]];
                    if (other >= h)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 46840
#!/usr/bin/env python3
import math

def binsearch_float(l, r, pred): # [l, r)
    assert l < r
    for _ in range(100):
        m = (l + r) / 2
        if pred(m):
            r = m
        else:
            l = m
    return r

def f(a, b, theta):
    area = 0
    w1 = a * math.cos(theta)
    h1 = a * math.sin(theta)
    w2 = b * math.sin(theta)
    h2 = b * math.cos(theta)
    if h1 < h2:
        r = (h2 - h1) / math.cos(theta)
        w3 = r * math.sin(theta)
        area += h1 * w1 / 2
        area += h2 * w2 / 2
        area += (h2 - h1) * w3 / 2
        area += (h2 - h1) * (w1 - w3)
    else:
        area += h1 * w1 / 2 * (h2 / h1) ** 2
        area += h2 * w2 / 2
    return a * area

def solve(a, b, x):
    radian = binsearch_float(0, math.pi / 2, lambda theta: f(a, b, theta) < x)
    return radian / (2 * math.pi) * 360

print('%.12f' % solve(*map(int, input().split())))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll x;
  cin>>x;
  cout<<(x/500)*1000+((x%500)/5)*5;                       
}

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

int main()
{
    while(1) {
        int R0=0, W0=0, C=0, R=0;
        std::cin >> R0 >> W0 >> C >> R;
        if(R0==0 && W0==0 && C==0 && R==0) break;
        int output = 0;
        while(R0+output*R<C*W0) {
            output += 1;
        }

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

Measured memory_bytes: 3072
#include <stdio.h>
int main(void){
  int n,i,a[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int j,k=0;
  for(i=0;i<=n;i++){
    j=a[k];
    if(j==2) {printf("%d\n",i + 1);return 0;}
    k=j-1;
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N = 105;
char s[N];

int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	int l, r, p;
	l = r = p = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '(')	p++;
		else	p--;
		if(p < 0)	{l++; p++;}
	}
	p = 0;
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == ')')	p++;
		else	p--;
		if(p < 0)	{r++; p++;}
	}
	for(int i = 0; i < l ; i++)
		putchar('(');
	printf("%s", s);
	for(int i = 0; i < r ; i++)
		putchar(')');
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,min=0,max=0,k,cnt=0;
  scanf("%d%d",&a,&b);
  if(a>b){
    max=a;
    min=b;
  }
  else{
    max=b;
    min=a;
  }
  for(k=min; k<=max; k++){
    if(k-min==max-k){
      cnt++;
      printf("%d\n",k);
      break;
    }
  }
  if(cnt==0){
    printf("IMPOSSIBLE\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

template<typename T>
class BIT{
public:
    vector<T> bit;
    int size;
    BIT(int size):
        bit(vector<T>(size+1,0)),size(size){}
    
    T sum(int i){
        if(!i) return 0;
        return bit[i]+sum(i-(i&(-i)));
    }

    void add(int i,T x){
        if(i>size)return;
        bit[i]+=x;
        add(i+(i&(-i)),x); 
    }   
};

int main(){

    string S; cin >> S;

    int N = S.size();

    int ub = N+1;
    int lb = N/2;
    int K;

    while (ub-lb>1) {
        K = (ub+lb) / 2;
        BIT<int> bit(N+1);
        FOR(i,1,N+1){
            bit.add(i,(int)(S[i-1]-'0'));
            bit.add(i+1,(int)(S[i-1]-'0'));
        }
        FOR(i,1,N-K+1){
            if(bit.sum(i)%2) {
                bit.add(i,1);
                bit.add(N+1,1);
            }
        }
        FOR(i,K+1,N+1) {
            if(bit.sum(i)%2) {
                bit.add(1,1);
                bit.add(i+1,1);
            }
        }
        if(bit.sum(1)%2){
            bit.add(1,1);
            bit.add(K+1,1);
        }
        bool flag = true;
        FOR(i,N-K+1,K) {
            if (bit.sum(i)%2!=bit.sum(i+1)%2) flag = false;
        }
        if (flag) lb = K;
        else ub = K;
    }
    cout << lb << endl;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int k, x;
	cin >> k >> x;

	for (int i = x - k + 1; i <= x + k - 1; i++) cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    n: usize,
    k: usize,
    mut pa: [usize; n]
  };

  let mut pa : Vec<usize> = pa;
  pa.sort();
  let ans : usize = pa.iter().take(k).sum();
  echo!(ans);
}


Measured memory_bytes: 2128
import java.util.Scanner;



public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        }
        else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        }
        else if(s.equals("Rainy")){
            System.out.println("Sunny");
        }
    }
    
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	int n; cin >> n;
	map<int, int> m;
	for(int i=0;i<n;i++){
		int a; cin >> a;
		m[a]++;
	}
	int ans = 0;
	for(auto kv:m){
		if(kv.second%2==1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n,x = map(int, input().split())
    xs = list(map(int, input().split()))
    xs.append(x)
    xs.sort(reverse=True)
    dif = [0]*n
    front = xs[0]
    for i,num in enumerate(xs[1:]):
        dif[i] = front - num
        front = num
    min_dif = min(dif)
    div_min = [min_dif]
    for i in range(int(min_dif**0.5),1,-1):
        if min_dif%i == 0:
            div_min.append(i)
            div_min.append(min_dif//i)
    div_min.sort(reverse=True)
    for i in div_min:
        for j in dif[1:]:
            if j % i != 0:
                break
        else:
            print(i)
            exit()
    print(1)


Measured memory_bytes: 14168
S = input()
S= str(S)
dic = {}
dic["SUN"] = 7
dic["MON"] = 6
dic["TUE"] = 5
dic["WED"] = 4
dic["THU"] = 3
dic["FRI"] = 2
dic["SAT"] = 1

out = dic[S]
print(out)

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

int main()
{
  int N;
  cin >> N;
  
  int A;
  
  int C = 0;//CはAを2で割れる回数の最小値
  int D = 0;//DはAを2で割れる回数
  bool zero = false;//Aがそもそも2で割れないときtrueにして0を出力
  for(int i = 0; i < N; i++)
  {
    cin >> A;
    if(A % 2 != 0)
    {
      zero = true;
      break;
    }
    else
    {
      while(A % 2 == 0)
      {
        if(i == 0){C++;}
        else{D++;}
        A /= 2;
      }
      if(i > 0)
      {
        if(C > D){C = D;}
      }
    }
    D = 0;
  }
  
  if(zero){cout << "0" << endl;}
  else{cout << C << endl;}
}

Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;


int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; 
    if(key > A[mid]) left = mid + 1; 
    else if(key < A[mid]) right = mid; 
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}




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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  string s[4];
  REP(i, 3) cin >> s[i];
  ll p[4];
  REP(i, 3) p[i] = 0;
  ll t = 0;
  while(1) {
    /*
    REP(i, 3) {
      cout << p[i] << endl;
    }
    
    cout << t << " -------" << endl;
    */
    if(s[t].size() == p[t]) {
      break;
    }
    ll c = s[t][p[t]];
    p[t]++;
    t = c - 'a';
  }
  cout << (char)(t + 'A') << endl;

}


Measured memory_bytes: 256
# coding: utf-8

import collections
import copy

# 標準入力 <int>
N = int(input())

# 標準入力 <str> list[]
A = list(map(str, input().split()))

c = collections.Counter(A)
nodel = 0

for cv in c.values():
  if cv >= 2:
    nodel += int((cv * (cv-1))/2)

for a in A:
  ans = copy.copy(nodel)
  if c.get(a) >= 3:
    ans = ans - int((c.get(a)*(c.get(a)-1))/2) + int(((c.get(a)-1)*(c.get(a)-2))/2)
  elif c.get(a) == 2:
    ans -= 1
  print(ans)

Measured memory_bytes: 28896
using System;

namespace CircleinaRectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input = Console.ReadLine();

			char[] CharSeparators = new char[] {' '};
			string[] array = input.Split(CharSeparators);

			int w = int.Parse(array[0].ToString());
			int h = int.Parse(array[1].ToString());
			int x = int.Parse(array[2].ToString());
			int y = int.Parse(array[3].ToString());
			int r = int.Parse(array[4].ToString());

			int inputhightforcircle = (y + r);
			int inputwideforcircle = (x + r);

			if(inputhightforcircle <= h &&
				inputwideforcircle <= w &&
				inputhightforcircle > 0 &&
				inputwideforcircle > 0 && 
				h > 0 && h <= 100 &&
				w > 0 && w <= 100 &&
				r > 0 && r <= 100){

				Console.WriteLine ("Yes");
			}else{
				Console.WriteLine ("No");
			}
		}
	}
}

Measured memory_bytes: 5312
N = int(input())

if N == 1:
    print(0)
    exit()
if N == 2:
    print(2)
    exit()

mod = int(10**9+7)

zeronai = 1
for i in range(N):
    zeronai = zeronai * 9
    zeronai = zeronai % mod

dottimonai = 1
for i in range(N):
    dottimonai = dottimonai * 8
    dottimonai = dottimonai % mod

aru = 1
for i in range(N):
    aru = aru * 10
    aru %= mod


# print(aru, zeronai, dottimonai)
print((aru - 2*zeronai + dottimonai) % mod)


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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::cin >> a;

	double n = 100000;
	for (int i = 0; i < a; i++) {
		n = n*1.05;
		n = static_cast<int>(ceil(n / 1000));
		n = n * 1000;
	}

	std::cout << std::setprecision(20) << n << std::endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  deque<ll> a(n);
  rep(i,n) cin >> a[i];
  a.push_front(0);
  a.push_back(0);
  n = (int)a.size();
  ll sum = 0;
  rep(i,n-1) sum += llabs(a[i]-a[i+1]);
  REP(i,1,n-1) {
    ll pre = a[i-1];
    ll cur = a[i];
    ll nex = a[i+1];
    //cout << i << "-th :" << pre << " " << cur << " " << nex << endl;
    if( ( min(pre,nex) <= cur && cur <= max(pre,nex) ) ) {
      cout << sum << endl;
    } else if( min(nex,cur) <= pre && pre <= max(nex,cur) ) {
      cout << sum - llabs(cur-pre)*2LL << endl;
    } else {
      cout << sum - llabs(cur-nex)*2LL << endl;
    }
    
  }
  compute();
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cmath>
int main() {
	int n = 0, m = 0, d[50] = {}, ans = 99999999;
	int box = 99999999999;
	int people[50][2] = {};
	int check[50][2] = {};
	
	std::cin >> n >> m;
	for (int i = 0; i < n; i++) {
		std::cin >> people[i][0];
		std::cin >> people[i][1];
	}
	for (int j = 0; j < m; j++) {
		std::cin >> check[j][0];
		std::cin >> check[j][1];
	}
	for (int a = 0; a < n; a++) {
		for (int b = 0; b < m; b++) {
			d[b] = std::abs(people[a][0] - check[b][0]) + std::abs(people[a][1] - check[b][1]);
			if (d[b] < box) {
				box = d[b];
				ans = b + 1;
			}
		}
		std::cout << ans << std::endl;
		box = 99999999999;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define EPS 1e-6
 
int main()
{
    fast;
    lli n, m;
    cin>>n>>m;
    lli sum=0;
    for(int i=0; i<m; i++){
        lli x;
        cin>>x;
        sum+=x;
    }
    if(n-sum>=0) cout<<(n-sum);
    else cout<<(-1);
    return 0;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N,K;
string S;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K>>S;
	S[K-1]+=(ll)'a'-'A';
	cout<<S<<endl;
}

Measured memory_bytes: 256
t = gets.to_i
t.times {
    n, k = gets.split.map &:to_i
    break if n == 0
    xs = gets.split.map &:to_i
    lengths = (0..n-2).map{|i| xs[i+1] - xs[i]}
    if n - k > 0
        p lengths.sort[0..n-k-1].inject(0, :+)
    else
        p 0
    end
}

Measured memory_bytes: 14784
#include <stdio.h>
#define N 100

int main(){
  int n, i, j, a, k, l;
  int Adj[N][N];

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

  for (i = 0; i < n; i++){
    scanf("%d%d", &a, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &l);
      Adj[i][l-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j != n-1) printf("%d ", Adj[i][j]);
      else printf("%d", Adj[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

#define int long long
const int MN = 101234, S = 30000;
int a[MN], n;

bool val(int x, int y) {
//	cout << x << ' ' << y << ' ' << (x < n) << (a[x] > y) << endl;
	return x < n && a[x] > y;
}

bool get(int x, int y) {
//	cerr << x << '|' << y << endl;
	if (val(x + S, y + S))
		return get(x + S, y + S);
	if (val(x + 1, y + 1))
		return get(x + 1, y + 1);
	if (val(x + 1, y) && !val(x, y + 1))
		return !get(x + 1, y);
	if (val(x, y + S) && !val(x + 1, y))
		return get(x, y + S);
	if (val(x, y + 1) && !val(x + 1, y))
		return !get(x, y + 1);
	if (val(x, y + 1)) {
		bool xx = !get(x, y + 1);
		bool yy = !get(x + 1, y);
//		cout << xx << '&' << yy << endl;
		return !get(x, y + 1) | !get(x + 1, y);
	}
//	cerr << "Hora" << endl;
	return false;
}	

int32_t main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	int gd = 0;
	cout << (get(0, 0)? "First": "Second");
}


Measured memory_bytes: 5760
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    long s, m = 1e9;
    cin >> s;
    if (s == 1e18)
    {
        cout << "0 0 " << m << " 0 0 " << m << endl;
        return;
    }
    cout << "0 0 " << m << ' ' << (m - s % m) << ' ' << 1 << ' ' << (s / m + 1) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;

const int INF=1e18+5;

int32_t main()
{
    fast

   int test=1;
   //cin>>test;


  while(test--)
  {
  int n,W;
  cin>>n>>W;
  vi w(n),v(n);
  int sum=0;
  for(int i=0;i<n;i++)
    {
      cin>>w[i]>>v[i];
      sum+=v[i];
    }
    vi dp(sum+1,INF);
    dp[0]=0;
  for(int i=0;i<n;i++)
  {
    for(int value=sum-v[i];value>=0;value--)
    {
      dp[value+v[i]]=min(dp[value+v[i]],w[i]+dp[value]);
    }
  }
int ans=0;
  for(int i=0;i<=sum;i++)
    if(dp[i]<=W)ans=i;

  cout<<ans;

  //while loop ending 
  }



return 0;
}

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

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

}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Arrays;
/* static int java.util.Arrays.binarySearch(int[] a, int key); */
import java.math.BigDecimal;
/* static int java.util.Arrays.binarySearch(int[] a, int key); */


public class Main {
    Scanner sc = new Scanner(System.in);
    int n;
    public void run(){
        n = sc.nextInt();
        solve();
    }
    public void solve(){
        long min = Long.MAX_VALUE;
        long max = Long.MIN_VALUE;
        for(int i = 0; i < n; i++){
            long a = sc.nextLong();
            if(a < min){
                min = a;
            }
            if(a > max){
                max = a;
            }
        }
        System.out.println(max - min);
    }

    public static void main(String[] args){
        new Main().run();
    }

    static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }
    static class Edge{
        int to, cost;
        public Edge(int a, int b){
            this.to = a;
            this.cost = b;
        }
    }
    class MyComparator implements Comparator {
        @Override
        public int compare (Object arg0, Object arg1) {
            int x = ((Pair)arg0).first;
            int y = ((Pair)arg1).first;

            if (x < y) {
                return 1;
            } else if (x > y) {
                return -1;
            } else{
                return 0;
            }
        }
    }
    static class UnionFind{
        int par[];
        int rank[];

        //n要素で初期化
        public UnionFind(int maxn){
            par = new int[maxn];
            rank = new int[maxn];

            for(int i = 0; i < maxn; i++){
                par[i] = i;
                rank[i] = 0;
            }
        }

        //木の根を求める
        int find(int x){
            if(par[x] == x){
                return x;
            }
            else {
                return par[x] = find(par[x]);
            }
        }

        // xとyの属する集合を併合
        void unite (int x, int y){
            x = find(x);
            y = find(y);
            if(x == y){
                return;
            }

            if(rank[x] < rank[y]){
                par[x] = y;
            }
            else{
                par[y] = x;
                if(rank[x] == rank[y]) rank[x]++;
            }
        }

        // xとyが同じ集合に属するか否か
        boolean same(int x, int y){
            return find(x) == find(y);
        }
    }

}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

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

P p[200000];

int main() {
	
	int N;
	cin >> N;
	
	long long int xmin = 100000000000LL;
	long long int ymin = 100000000000LL;
	long long int xmax = 0;
	long long int ymax = 0;
	
	for(int i = 0; i < N; i++){
		cin >> p[i].first >> p[i].second;
		if(p[i].first > p[i].second){
			swap(p[i].first, p[i].second);
		}
		xmax = max(xmax, p[i].first);
		ymax = max(ymax, p[i].second);
		xmin = min(xmin, p[i].first);
		ymin = min(ymin, p[i].second);
	}
	
	long long int ans = (ymax - ymin) * (xmax - xmin);
	
	sort(p, p + N);
	long long int diff = ymax - xmin;
	
	long long int pmin = p[0].first;
	long long int dmin = 10000000000LL;
	long long int pmax = 0;
	
	for(int i = 0; i < N; i++){
		pmax = max(pmax, p[i].first);
	}
	
	ans = min(ans, diff * (pmax - pmin));
	
	for(int i = 0; i < N - 1; i++){
		dmin = min(dmin, p[i].second);
		pmin = min(p[i + 1].first, dmin);
		pmax = max(pmax, p[i].second);
		ans = min(ans, diff * (pmax - pmin));
	}
	dmin = min(dmin, p[N - 1].second);
	pmin = dmin;
	pmax = max(pmax, p[N - 1].second);
	ans = min(ans, diff * (pmax - pmin));
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3456
package main
import (
  "fmt"
  "strings"
)
func main() {
  var s string
  fmt.Scan(&s)
  s = reverse(s)
  for ;len(s)>0; {
    if len(s) < 5 { break }
    if s[0:5] == "maerd" {
      s = s[5:]
      continue
    }
    if s[0:5] == "esare" {
      s = s[5:]
      continue
    }
    if len(s) < 6 { break }
    if s[0:6] == "resare" {
      s = s[6:]
      continue
    }
    if len(s) < 7 { break }
    if s[0:7] == "remaerd" {
      s = s[7:]
      continue
    }
    break
  }
  if len(s) > 0 {
    fmt.Println("NO")
  } else {
    fmt.Println("YES")
  }
}
func reverse(s string) string {
  var n int = len(s)
  var t []string = make([]string,n)
  for i:=0;i<n;i++ {
    t[i] = s[n-1-i:n-i]
  }
  return strings.Join(t,"")
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[110];

int main()
{
	scanf("%s",a+1);int n=strlen(a+1);
	int ans=n;
	for (int c='a';c<='z';c++)
	{
		int x=0,t=0;
		for (int i=1;i<=n+1;i++)
		{
			t=max(t,i-x);
			if (i<=n&&a[i]==c) x=i;
		}
		ans=min(ans,t);
	}
	printf("%d\n",ans-1);
	return 0;
}


Measured memory_bytes: 128
l = []

for i in range(3):
    a,b = map(int,input().split())
    l.append([a,b])

d = {}
for aa,bb in l:
    if aa not in d.keys():
        d[aa] = 0
    if bb not in d.keys():
        d[bb] = 0
    d[aa] += 1
    d[bb] += 1

for i in d.values():
    if i >= 3:
        print("NO")
        exit()
print("YES")


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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n,a,b;
  bool able[10000000];
  while(cin>>n>>a>>b){
    memset(able,0,sizeof(able));
    if(n==0) break;
    if(a>b) swap(a,b);
    able[0] = true;
    for(int i=0;i+a<=n;i++){
      if(able[i]) able[i+a] = true;
    }
    for(int i=0;i+b<=n;i++){
      if(able[i]) able[i+b] = true;
    }
    int count = n;
    for(int i=1; i<=n; i++){
      if(able[i])count--;
    }
    cout<<count<<endl;
  }

  return 0;
}

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

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
#define INF 999999999
typedef long long ll;
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<ll> h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }
    rep(i, 101) {
        rep(j, 101) {
            ll height = -2;

            rep(k, n) {
                if(h[k] > 0) {
                    ll tmp = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    if(height == -2){
                        height = tmp;
                    }
                    else {
                        if(height != tmp) {
                            height = -1;
                            break;
                        }
                    }
                }
            }

            if(height == -1) continue;

            rep(k,n){
                if(h[k] == 0){
                    if(height > abs(i - x[k]) + abs(j - y[k])){
                        height = -1;
                        break;
                    }
                }
            }
            if(height == -1) continue;
            cout << i << " " << j << " " << height << endl;
            return 0;
        }
    }
}

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

ll a[10101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    for(int i=1; i<=n; i++){
        for(int t=1; i*t<=n; t++){
            a[i*t]++;
        }
    }
    ll ans = 0;
    for(int i=1; i<=n; i++){
        ans += i*a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 81720
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<typename T>
struct Edge{
    int u, v;
    T cost;
    
    Edge() = default;
    Edge(int u, int v, T cost) : u(u), v(v), cost(cost) {}

    bool operator<(const Edge& other) const{
        return cost < other.cost;
    }
};

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

// クラスカル法を適用してグラフの最小全域木を求める
template<typename T>
T Kruskal(vector<Edge<T>> &es, int VertexNumber){
    T res = 0;    
    sort(es.begin(), es.end());
    int sz = es.size();
    UnionFind tree(VertexNumber);
    for(int i = 0; i < sz; ++i){
        if(!tree.same(es[i].u, es[i].v)){
            tree.unite(es[i].u, es[i].v);
            res += es[i].cost;
        }
    }
    return res;
}

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

    using ld = long double;
    constexpr ld eps = 1e-9;
    for(;;){
        int n;
        cin >> n;
        if(n == 0)  return 0;
        vector<ld> x(n), y(n), z(n), r(n);
        for(int i = 0; i < n; ++i)  cin >> x[i] >> y[i] >> z[i] >> r[i];
        auto get_dist = [&](int i, int j){
            ld X = x[i] - x[j], Y = y[i] - y[j], Z = z[i] - z[j];
            ld d = sqrt(X * X + Y * Y + Z * Z) - r[i] - r[j];
            return d < eps ? 0.0 : d;
        };
        vector<Edge<ld>> es;
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < i; ++j){
                es.emplace_back(j, i, get_dist(i, j));
            }
        }
        cout << fixed << setprecision(3);
        cout << Kruskal(es, n) << endl;
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int n;
  cin >> n;
  printf("%.10f\n",2.0*n*M_PI);
  
  return 0;
}


Measured memory_bytes: 3764
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    ans = 10 ** 10
    dist = 10 ** 10
    for i in range(m):
        c, d = cd[i]
        temp = abs(a - c) + abs(b - d)
        if dist > temp:
            dist = temp
            ans = i + 1
    print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        int minAbs = Integer.MAX_VALUE;
        long sum = 0L;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int abs = Math.abs(a);
            sum += (long)abs;
            if(a < 0) cnt++;
            if(abs < minAbs){
                minAbs = abs;
            }
        }
        if(0 < minAbs && cnt % 2 != 0){
            sum -= 2 * minAbs;
        }
        System.out.println(sum);
        sc.close();

    }

}


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

using namespace std;

using vb = vector<bool>;
using vvb = vector<vb>;

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

    int h, w, k;
    cin >> h >> w >> k;
    vvb s(h, vb(w));
    for (int i = 0; i < h; i++) {
        string t;
        cin >> t;
        for (int j = 0; j < w; j++) {
            s.at(i).at(j) = t.at(j) == '#';
        }
    }

    int ans = 0;
    for (int i = 0; i < 1 << h; i++) {
        for (int j = 0; j < 1 << w; j++) {
            int cur = 0;
            for (int x = 0; x < h; x++) {
                for (int y = 0; y < w; y++) {
                    cur += !(i >> x & 1) && !(j >> y & 1) && s.at(x).at(y);
                }
            }

            if (cur == k) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

for i in range(1, n+1):
    if i%3 == 0 or i%10 == 3:
        print(" %d" % i, end="")
        continue

    x = i
    while x > 0:
        x = int(x / 10)
        if x % 10 == 3:
            print(" %d" % i, end="")
            break

print()



Measured memory_bytes: 5872
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int a[200100];
int b[200100];
int numa[200100];
int numb[200100];
int n;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n;
	rep(i,n)cin>>a[i],numa[a[i]]++;
	rep(i,n)cin>>b[i],numb[b[i]]++;
	sort(a,a+n);
	sort(b,b+n);
	rep(i,200001)if(numa[i]+numb[i]>n)
	{
		cout<<"No\n";
		return 0;
	}
	reverse(b,b+n);
	int now=-1;
	rep(i,n)
	{
		if(a[i]==b[i])
		{
			for(int j=now+1;j<n;j++)
			{
				if(b[j]!=a[i]&&b[i]!=a[j])
				{
					swap(b[j],b[i]);
					now=j;
					break;
				}
			}
		}
	}
	cout<<"Yes\n";
	rep(i,n)cout<<b[i]<<" ";
	cout<<endl;
	return 0;
}



Measured memory_bytes: 6704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

ll dp[100];
int main() {
    int n; cin >> n;
    dp[0] = 2;
    dp[1] = 1;
    for(int i = 2; i <= n+1; i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;

    return 0;
}

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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e16;
const double EPS = 1e-9;
const ll MOD = (ll)(1e9 + 7);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

int n;

int A[1005][1005];
int curr[1005];
bool mark[1005][1005];

int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	cin >> n;

	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n - 1;j ++){
			cin >> A[i][j];
			A[i][j] --;
		}

	int h = 0;
	vector<pair<int, int>> cand[2];

	for(int i = 0;i < n;i ++){
		mark[i][A[i][curr[i]]] = true;
		if(mark[A[i][curr[i]]][i] == true){
			cand[h].push_back(make_pair(i, A[i][curr[i]]));

			curr[A[i][curr[i]]] ++;
			curr[i] ++;
		}
	}
	int days = 0;
	int cnt = 0;


	int kk = 0;
	while(1){
		if(cnt == n * (n - 1) / 2){
			cout << days << "\n";
			return 0;
		}
		if(cand[h].size() == 0 || cnt > n * (n - 1) / 2){
			cout << "-1\n";
			return 0;
		}


		for(int i = 0;i < cand[h].size();i ++){
			cnt ++;
			int a = cand[h][i].first;
			int b = cand[h][i].second;

			//cout << a << " " << b << "\n";

			mark[a][A[a][curr[a]]] = true;
			if(curr[a] < n - 1 && mark[A[a][curr[a]]][a] == true){
				cand[!h].push_back(make_pair(a, A[a][curr[a]]));

				curr[A[a][curr[a]]] ++;
				curr[a] ++;
			}

			mark[b][A[b][curr[b]]] = true;
			if(curr[b] < n - 1 && mark[A[b][curr[b]]][b] == true){
				cand[!h].push_back(make_pair(b, A[b][curr[b]]));

				curr[A[b][curr[b]]] ++;
				curr[b] ++;
			}
		}

		//cout << "\n";

		cand[h].clear();
		h = !h;
		days ++;
	}

	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;

    int ans = 0;
    REP(i, N) {
        if (T[i] == 'r') { // p
            ans += P;
        } else if (T[i] == 's') { // r
            ans += R;
        } else if (T[i] == 'p') { // s
            ans += S;
        }
    }
    // cout << ans << endl;

    REP(i, K) {
        int cur = 1;
        int j = i;
        for (; j < N - K; j += K) {
            // cout << " i:" << i << " j:" << j << " ans:" << ans << " cur:" << cur << " T[j]:" << T[j] << endl;
            if (T[j] == T[j + K]) {
                cur++;
            } else {
                if (T[j] == 'r') { // p
                    ans -= cur / 2 * P;
                } else if (T[j] == 's') { // r
                    ans -= cur / 2 * R;
                } else if (T[j] == 'p') { // s
                    ans -= cur / 2 * S;
                }
                cur = 1;
            }
        }
        if (T[j] == 'r') { // p
            ans -= cur / 2 * P;
        } else if (T[j] == 's') { // r
            ans -= cur / 2 * R;
        } else if (T[j] == 'p') { // s
            ans -= cur / 2 * S;
        }
        cur = 1;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 512