akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct Card {char suit, value;};

void trace(struct Card A[], int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

void bubble(struct Card A[], int N) {
  for (int i = 0; i < N; i++) {
    for (int j = N-1; j >= i; j--) {
      if (A[j].value < A[j-1].value) {
        Card t = A[j];
        A[j] = A[j-1];
        A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (A[j].value < A[minj].value) {
        minj = j;
      }
    }
    Card t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for (int i = 0; i < N; i++) {
    if (C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main() {
  int N;
  Card C1[100], C2[100];
  char ch;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> C1[i].suit >> C1[i].value;

  for (int i = 0; i < N; i++) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  trace(C1, N);
  cout << "Stable" << endl;
  
  trace(C2, N);
  if (isStable(C1, C2, N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  ll a, b, x;
  cin >> a >> b >> x;

  cout << b / x - (a + x - 1) / x + 1 << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {

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

        int n = sc.nextInt();
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int flag = 1;
        int count = 0;
        while(flag == 1) {
            flag = 0;
            for (int j = n - 1; 0 < j; j--) {
                if (a[j] < a[j - 1]) {
                    int tmp = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = tmp;
                    flag = 1;
                    count++;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i != n - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
        System.out.println(count);
    }
}



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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

str s[5];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	s[0] = "hi";
	for(int i = 1; i < 5; i++) s[i] = s[i - 1] + "hi";
		str t;
	cin >> t;
	for(int i = 0; i < 5; i++) if(t == s[i]) return cout << "Yes\n", 0;
		cout << "No\n";
	
	return 0;
}


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

int main(){
  int n, i, a, mi, ma;
  long long sum;
  cin >> n;
  sum = 0;
  ma = -1000000;
  mi = 1000000;
  for (i = 0; i < n; i++){
    cin >> a;
    sum += a;
    if (mi > a)
      mi = a;
    if (ma < a)
      ma = a;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}



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

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


using namespace std;
using lint = long long;

int main(void)
{
    int N;
    cin >> N;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    lint min = 10000000;
    for(int k = 1; k <= 100; k++){
        lint sum = 0;
        for(int i = 0; i < N; i++){
            sum += (x[i] - k)*(x[i] - k);
        }
        if(min > sum){
            min = sum;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  A=int(input())
  B=int(input())
  C=int(input())
  D=int(input())
  E=int(input())

  Amod=A%10
  if Amod==0:
    Amod=10
  Bmod=B%10
  if Bmod==0:
    Bmod=10
  Cmod=C%10
  if Cmod==0:
    Cmod=10
  Dmod=D%10
  if Dmod==0:
    Dmod=10
  Emod=E%10
  if Emod==0:
    Emod=10
  last=min(Amod,Bmod,Cmod,Dmod,Emod)
  
  A_round=((A+9)//10)*10
  B_round=((B+9)//10)*10
  C_round=((C+9)//10)*10
  D_round=((D+9)//10)*10
  E_round=((E+9)//10)*10
  
  time=A_round+B_round+C_round+D_round+E_round
  time=time-10+last

  print(time)

main()
  

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

typedef long long ll;
int main() {
	ll n;
	cin >> n;
	
	vector<ll> a(n);
	unordered_map<ll,ll> map;
	
	ll sum = 0;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
		map[a[i]]++;
	}
	
	ll q;
	cin >> q;
	
	while(q--){
		ll b,c;
		cin >> b >> c;
	
		ll times = map[b];
	
		map[b] = 0;
		map[c] += times;
		
		sum -= b * times;
		sum += c * times;
		
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 7768
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import sqrt

points = [tuple(li()) for _ in range(3)]

# 3つの辺を求める
sides = []
angles = []
for i in range(3):
    p1,p2 = points[i], points[(i+1)%3]
    sides.append(sqrt((p2[0]-p1[0])**2 + (p2[1]-p1[1])**2))

# 内接円の半径
s = (sum(sides)) / 2
a,b,c = sides
area = sqrt(s* (s-a) * (s-b) * (s-c))
r = 2*area / sum(sides)

print(max(sides)*r / (2*r + max(sides)))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int l = 0;
    int r = 0;
    for (int i = 0; i < m; i++) {
      int a = sc.nextInt();
      if (x >= a) {
        l += 1;
      } else {
        r += 1;
      }
    }
    System.out.println(Math.min(l, r));
  }
}


Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

class unko10 {
public:
	char C[1275725], C9[211470];
	constexpr unko10() : C(), C9() {
		char c[11] = {};
		int d = 0;
		int k[11] = {};
		int saidai[11] = {};
		int ma = 10;

		auto ci = C;
		while (d >= 0) {
			c[d] = k[d]++ + 'a';
			saidai[d + 1] = max(saidai[d], k[d]);
			d++;
			if (d == ma) {
				rep(i, ma)* ci++ = c[i];
				*ci++ = '\n';
				d--;
			}

			while (d >= 0 && (c[d] - 'a') == saidai[d]) {
				k[d] = 0;
				c[d] = 'z';
				d--;

			}
		}
		d = 0;
		ma = 9;
		ci = C9;
		while (d >= 0) {
			c[d] = k[d]++ + 'a';
			saidai[d + 1] = max(saidai[d], k[d]);
			d++;
			if (d == ma) {
				rep(i, ma)* ci++ = c[i];
				*ci++ = '\n';
				d--;
			}

			while (d >= 0 && (c[d] - 'a') == saidai[d]) {
				k[d] = 0;
				c[d] = 'z';
				d--;
			}
		}
	}
} f;


char dn[37260], *di = dn;
int N, k;
char c[10];
void keisan(int n, int saidai) {
	if (n == N) {
		rep(i, N) *di++ = c[i];
		*di++ = '\n';
	}
	else {
		rep1(i, saidai + 1) {
			c[k++] = 'a' + i - 1;
			keisan(n + 1, max(saidai, i));
			k--;
		}
	}
}

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


	scanf("%d", &N);

	if (N < 9) {
		keisan(0, 0);
		fwrite(dn, 1, di - dn, stdout);
	}
	else if (N == 9){
		fwrite(f.C9, 1, 211470, stdout);
	}
	else {
		fwrite(f.C, 1, 1275725, stdout);
	}

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

int N;
ll x;
vector<ll> v;
vector<ll> cost;

int main(){
	scanf("%d%lld", &N, &x);
	for(int i=0; i<N; i++){
		ll tmp; scanf("%lld", &tmp); v.push_back(tmp);
		cost.push_back(tmp);
	}
	ll sum = 0;
	ll ans = 1000000000000000000LL;
	for(int i=0; i<=N; i++){
		sum = 0;
		for(int j=0; j<N; j++){
			sum+=cost[j];
		}
		ans = min(ans, sum+x*(ll)i);
		if(i!=N){
			for(int j=0; j<N; j++){
				int idx = (j+i+1)%N;
				cost[j] = min(cost[j], v[idx]);
			}
		}		
	}
	printf("%lld", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int s = S.size();
  int t = T.size();
  int ans = s;
  for(int i=0; i<s-t+1; i++){
    int cnt = 0;
    for(int j=0; j<t; j++){
      if(S[i+j] != T[j]){
        cnt++;
      }
    }
    ans = min(cnt,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))

s = input()
n = len(s)

count=0
if(n%2==0):
    
    for i in range(n//2):
        if(s[n-1-i]!=s[i]):
            count+=1
    print(count)
else:
    for i in range((n-1)//2):
        if(s[i]!=s[n-1-i]):
            count+=1
    print(count)



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[222222],p,q,ans[222222];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) 
	scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
	{
		p=n-i+1;
		if (p%2) q=1+p/2;
		else q=i+p/2;
		ans[q]=a[i];
	}
	for (int i=1;i<=n;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

int main(){
	fastio;
	string s;
	cin >> s;
	int sum = 0;
	for(char c:s){
		sum += (c-'0');
	}
	cout << (sum%9==0?"Yes":"No") << "\n";
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;
#define loop(i, n) for (int i = 0; i < (int)n; i++)
int main() {
    string s; cin >> s;
    loop(i, s.size()) {
        if (s[i] == '7') { cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int c=0;
  int a;

  for (int i = 0; i < N; i++) {
    cin >> a;
    for(;a%2!=1;a/=2){
      c++;
    }  
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int S[1000];
int top;
int isEmpty(){
        if(top==0) {
                return 1;
        }
        else return 0;
}
void  push(int x){
        S[++top]=x;
}
int pop(){
        if(isEmpty()) {
                fprintf(stderr,"Underflow\n");
        }
        else{

                top--;
        }
        return S[top+1];
}

int main (){
        int i,j;

        char s[100];
        top=0;
        while(scanf("%s",s)!=EOF) {
                if(s[0]=='+') {
                        i=pop();
                        j=pop();
                        push(i+j);
                }
                else if(s[0]=='-') {
                        j=pop();
                        i=pop();
                        push(i-j);
                }
                else if(s[0]=='*') {
                        i=pop();
                        j=pop();
                        push(i*j);
                }
                else {
                        push(atoi(s));

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



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


int main(){

  int n;
  cin >> n;

  vector <int> array(3,0);

  while(n>0){

    cin >> array[0] >> array[1] >> array[2];

    sort(array.begin(),array.end());

    if(array[0]*array[0] + array[1]*array[1] == array[2]*array[2]){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
    n--;
  }


  return 0;
}

Measured memory_bytes: 3136
#include <cstdio>
#include <algorithm>
using namespace std;

int N, T, t[200005];
int time = 0;


int main() {
	scanf("%d%d", &N, &T);
	for (int i = 0; i != N; ++i)
		scanf("%d", t + i);
	sort(t, t + N);
	t[N] = ~0u >> 1;
	for (int i = 0; i != N; ++i)
		if (t[i + 1] - t[i] <= T)
			time += t[i + 1] - t[i];
		else time += T;
	printf("%d\n", time);
	return 0;
}


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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i,n) cin >> w[i];
    int sum=0;
    rep(i,n) sum+=w[i];
    int ans=100100100;
    int s1=0,s2=sum;
    for(int i=0;i<n;i++){
        s1+=w[i];
        s2-=w[i];
        ans=min(ans,abs(s1-s2));
    }
    cout << ans << endl;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

void test_case() {

}

const int mxN = 1e5 + 1;

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

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int n, a[3005], b[3005], mat[6005];
char dp[6005][6005], s[6005];
int main() {
    scanf("%d%s", &n, s);
    for (int i = 0, ai = 0, bi = 0; i < 2 * n; i++)
        if (s[i] == 'a')
            a[ai++] = i;
        else
            b[bi++] = i;
    for (int i = 0; i < n; i++)
        mat[a[i]] = b[i], mat[b[i]] = a[i];
    n *= 2;
    for (int i = n - 1; i >= 0; i--) {
        if (mat[i] < i) {
            strcpy(dp[i], dp[i + 1]);
        } else {
            if (s[i] == 'a') {
                dp[i][0] = 'a';
                dp[i][1] = 'b';
                strcpy(dp[i] + 2, dp[mat[i] + 1]);
            } else {
                int si = 0, ed = mat[i];
                for (int j = i; j <= ed; j++)
                    if (i <= mat[j]) {
                        dp[i][si++] = s[j];
                        ed = max(ed, mat[j]);
                    }
                strcpy(dp[i] + si, dp[ed + 1]);
            }
            if (strcmp(dp[i], dp[i + 1]) < 0)
                strcpy(dp[i], dp[i + 1]);
        }
    }
    puts(dp[0]);
    return 0;
}

Measured memory_bytes: 35328
#include <iostream>
#define LEN 10000
#define NIL -1
using namespace std;

struct Node {int p,l,r;};
Node T[LEN];
int n;

void preParse(int u)
{
    if(u==NIL) return;
    cout<<" "<<u;
    preParse( T[u].l );
    preParse( T[u].r );
}

void inParse(int u)
{
    if(u==NIL) return;
    inParse( T[u].l );
    cout<<" "<<u;
    inParse( T[u].r );
}

void postParse(int u)
{
    if(u==NIL) return;
    postParse( T[u].l );
    postParse( T[u].r );
    cout<<" "<<u;
}
int main()
{
    int v,l,r,root;
    cin>>n;
    for(int i=0;i<n;i++) T[i].p=NIL;
    for(int i=0;i<n;i++){
        cin>>v>>l>>r;
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL) T[l].p=v;
        if(r!=NIL) T[r].p=v;
    }
    for(int i=0;i<n;i++) if( T[i].p ==NIL ) root=i;
    cout<< "Preorder" <<endl;
    preParse(root); cout<<endl;
    cout<< "Inorder" <<endl;
    inParse(root); cout<<endl;
    cout<< "Postorder" <<endl;
    postParse(root); cout<<endl;
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    const int LIMIT = 1000000256;
    const int tenfive = 100000;
}

using namespace atcoder;

int main(void){
    string s;
    cin >> s;
    cout << 700+count(s.begin(),s.end(),'o')*100 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int>arr;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	int td=0;
	for(int i=0;i<n-1;i++)
	{
		td += abs(arr[i]-arr[i+1]);
	}
	td+=abs(0-arr[0])+abs(arr[arr.size()-1]-0);
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			int tp=td;
			tp -= (abs(0-arr[i])+abs(arr[i]-arr[i+1]));
			tp += abs(0-arr[i+1]);
			cout<<tp<<"\n";
		}
		else if(i==n-1)
		{
			int tp=td;
			tp -= (abs(arr[i]-0)+abs(arr[i]-arr[i-1]));
			tp += abs(arr[i-1]-0);
			cout<<tp<<"\n";
		}
		else
		{
			int tp=td;
			tp -= (abs(arr[i]-arr[i-1])+abs(arr[i]-arr[i+1]));
			tp += (abs(arr[i-1]-arr[i+1]));
			cout<<tp<<"\n";
		}
	}
}

Measured memory_bytes: 1784
a = input().rstrip().split()
count5=0
count7=0
for i in range(len(a)):

    if int(a[i]) == 5:
        count5+=1
    elif int(a[i])== 7:
        count7+=1

if count5==2 and count7==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    cout << *min_element(all(a)) << " " << *max_element(all(a)) << endl;
}



Measured memory_bytes: 3172
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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;
}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class BBounding {
public:
    int N, X;
    int L[20000];

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> X;
        int hop = 0;
        int d = 0;
        REP(i, N) {
            int tmp; in >> tmp;
            d += tmp;
            hop++;
            if (d > X) {
                OUT(hop);
                return;
            }
        }
        OUT(N+1);
    }
};


int main() {
    BBounding solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;

    vector<ll> odd(100010, 0), even(100010, 0);
    rep(i, n){
        ll a;
        cin >> a;
        if(i&1)odd[a]++;
        else even[a]++;
    }

    vector<ll> ord_1(100010), ord_2(100010);
    iota(ALL(ord_1), 0);
    iota(ALL(ord_2), 0);

    sort(ALL(ord_1), [&](ll x, ll y){
        return odd[x] > odd[y];
    });
    sort(ALL(ord_2), [&](ll x, ll y){
        return even[x] > even[y];
    });

    ll odd_cnt = n/2;
    ll even_cnt = n/2;
    if(n&1)even_cnt++;

    ll ans = n;
    if(ord_1[0] != ord_2[0]){
        ans = odd_cnt - odd[ord_1[0]] + even_cnt - even[ord_2[0]];
    }
    else {
        ans = odd_cnt - odd[ord_1[0]] + even_cnt - even[ord_2[1]];
        ans = min(ans, odd_cnt - odd[ord_1[1]] + even_cnt - even[ord_2[0]]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6412
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a string
	fmt.Scan(&a)
	b := ""
	arr := strings.Split(a, b)
	// fmt.Println(arr[0], arr[1])
	i := 0
	for i < 3 {
		if arr[i] == arr[i+1] {
			fmt.Println("Bad")
			break
		}
		if (i == 2) && (arr[i] != arr[i+1]) {
			fmt.Println("Good")
		}
		i++
	}
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),ans=0;
    ans+=n/500*1000;n%=500;
    ans+=n/5*5;
    pr2(ans);
    return 0;
}

Measured memory_bytes: 128
def main():
    S = input()
    N = len(S)
    S1 = S[0:(N - 1) // 2]
    S2 = S[(N + 3) // 2 - 1:]
    
    if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9008
N = int(input())
nums = list(map(int, input().split()))
#list =[]
count=0
for i in range(1,N-1):
    if (nums[i-1] < nums[i] and nums[i] < nums[i+1]) or (nums[i-1] > nums[i] and nums[i] > nums[i+1]):
        count += 1
print(count)

Measured memory_bytes: 3064
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a,b,c,d = map(int,input().split())

lcm_cd = lcm(c,d)

min_a_c = (a-1)//c
min_a_d = (a-1)//d
min_a_lcm = (a-1)//lcm_cd
max_b_c = b//c
max_b_d = b//d
max_b_lcm = b//lcm_cd

ans=(b-a+1)-((max_b_c-min_a_c)+(max_b_d-min_a_d)-(max_b_lcm-min_a_lcm))


print(ans)



Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d,x1,x2,x3,y1,y2,y3;
    cin>>a>>b>>c>>d;
    if(a<0 && b>0){
    	x1=a;
    	x2=0;
    	x3=b;
    }
    else{
    	x1=a;
    	x2=a;
    	x3=b;
    }
    if(c<0 && d>0){
    	y1=c;
    	y2=0;
    	y3=d;
    }
    else{
    	y1=c;
    	y2=c;
    	y3=d;
    }
    int mx = std::numeric_limits<int>::min();
    mx= max(mx,x1*y1);
    mx= max(mx,x1*y2);
    mx= max(mx,x1*y3);
    mx= max(mx,x2*y1);
    mx= max(mx,x2*y2);
    mx= max(mx,x2*y3);
    mx= max(mx,x3*y1);
    mx= max(mx,x3*y2);
    mx= max(mx,x3*y3);
    cout<<mx<<endl;
    return 0;
}

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

using namespace std;

#define INF 0x7FFFFFFF


int main() {
  vector<int> h;
  int N;
  int ans = 0;
  
  cin >> N;
  
  h.resize(N);
  
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  
  while (true) {
    int left = -1, right = -1;
    
    for (int i = 0; i < N; i++) {
      if (left == -1 && h[i] > 0) {
        left = i;
      }
      
      if (left != -1 && (i == N - 1 || h[i + 1] == 0)) {
        right = i;
      }
      
      if (left != -1 && right >= left) {
        break;
      }
    }
    
    if (left == -1) {
      break;
    }
    
    int _min = INF;
    
    for (int i = left; i <= right; i++) {
      _min = min(_min, h[i]);
    }
    
    ans += _min;
    
    for (int i = left; i <= right; i++) {
      h[i] -= _min;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    string ss;
    cin >> ss;
    string a = "AKIHABARA";
    set<string>s;
    s.insert("AKIHABARA");
    s.insert("AKIHABAR");
    s.insert("AKIHABRA");
    s.insert("AKIHBARA");
    s.insert("KIHABARA");
    
    s.insert("KIHABAR");
    s.insert("KIHABRA");
    s.insert("KIHBARA");
    s.insert("AKIHBAR");
    
    s.insert("AKIHBAR");
    s.insert("AKIHBRA");
    s.insert("AKIHABR");
    s.insert("KIHABRA");
    
    s.insert("KIHABR");
    s.insert("AKIHBR");
    s.insert("KIHBRA");
    s.insert("KIHBAR");
    s.insert("KIHBR");
    if(s.count(ss)){
        cout <<"YES" << endl;
    }else{
        cout <<"NO" << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h> 

int main(void)
{
	int n, x;
	int b, i, j, k, a;

	while (1) {
		scanf("%d %d", &n, &x);
		b = 0;
		if (n == 0 && x == 0){
			break;
		}
		for (k = 1; k <= n; k++) {


			for (j = 1; j <= n; j++) {

				for (i = 1; i <= n; i++) {

					if (i == j || j == k || i == k) {

					}
					else{
						a = i + j + k;
						if (a == x) {

							b += 1;

						}
					}

				}

			}

		}
		printf("%d\n", b / 6);
	}


	return 0;
}



Measured memory_bytes: 2112
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> ls = new ArrayList<Integer>(n);
    for (int i = 0; i < n; i++) {
      ls.add(0);
    }
    for (int i = 0; i < n - 1; i++) {
      int boss = sc.nextInt();
      ls.set(boss - 1, ls.get(boss - 1) + 1);
    }
    sc.close();
    for (int i = 0; i < n; i++) {
      System.out.println(ls.get(i));
    }
  }
}

Measured memory_bytes: 57080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int S = sc.nextInt();
		int W = sc.nextInt();
		
		// 結果の出力
		System.out.println(S <= W? "unsafe" : "safe");

		sc.close();
	}
}


Measured memory_bytes: 27084
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        sum=sum^a[i];
    }
    for (int i = 0; i < n; i++)
    {
        a[i]=sum^a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
     
return 0;
}

Measured memory_bytes: 3632
object Main{
  def main(args:Array[String]) = {
    val list = scala.io.StdIn.readLine.split(" ").map(_.toInt).toList
    println((list(0) + 1) * (list(1) + 1) - list(0) + 1 - list(1) - list(1) - list(0) - 1)
  }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a >= 13){
    cout << b << endl;
  }else if(a <= 12 && a >= 6){
    cout << b / 2 << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
program main
	implicit none
	character i*3,j*3
	read(*,*)i
	read(*,*)j
	if(i(1:1)==j(3:3).and.i(2:2)==j(2:2).and.j(1:1)==i(3:3))then
		write(*,"(a3)")"YES"
	else
		write(*,"(a2)")"NO"
	endif
end program main


Measured memory_bytes: 512
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
#print(a)
H=[]
W=[]
for i in range(h):
    count=0
    for j in range(w):
        if a[i][j]==".":
            count+=1
    if count==w:
        H.append(i)
for i in range(w):
    count=0
    for j in range(h):
        if a[j][i]==".":
            count+=1
    if count==h:
        W.append(i)
for i in range(1,len(H)+1):
    for j in range(w):
        a[H[-1*i]][j]=""
for i in range(1,len(W)+1):
    for j in range(h):
        a[j][W[-1*i]]=""

for i in range(h):
    if not ("." in a[i] or "#" in a[i]):
        continue
    print("".join(a[i]))


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    double sum = 0.0;
    int x;
    f1(i,n){
        cin >> x;
        sum+= (1.0/x);
    }
    cout << (1.0/sum) << endl;

    return 0;
}



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

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))

int main(){
  INT(n); INT(k);
  if ((n - 1) * (n - 2) / 2 < k){
    printf("-1\n");
  } else {
    vector<pair<int, int>> gr;
    REP(u, 2, n + 1){
      gr.EB(1, u);
    }
    int cnt = (n - 1) * (n - 2) / 2;
    REP(u, 2, n){
      if (cnt == k){break;}
      REP(v, u + 1, n + 1){
        if (cnt == k){break;}
        gr.EB(u, v); cnt--;
      }
    }
    printf("%d\n", SZ(gr));
    for (auto p: gr){
      printf("%d %d\n", p.first, p.second);
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    ll h;
    cin >> h;
    ll now = 1;
    ll ans = 0;
    while(h){
        h/=2;
        now *= 2;
        ans += now/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int main(){
    string s;cin >> s;
    int n=s.size();
    int up,down;
    if(n%2==0){
        up=n/2;
        down=up-1;
    }
    else{
        up=n/2;
        down=n/2;
    }
    int chara=s[up];
    while(s[up]==chara&&s[down]==chara){
        up++;
        down--;
        if(down<0) break;
    }
    cout << up << endl;
    return 0;
}

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

long long int a[101][2];
long long int dp[101][100001];


int main() {
	long long int n, w;
	memset(dp, 1, sizeof(dp));
	scanf("%lld%lld", &n, &w);
	for (long long int i = 0; i < n; i += 1) {
		scanf("%lld%lld", &a[i][0], &a[i][1]);
	}
	for (long long int i = 0; i <= n; i += 1) {
		dp[i][0] = 0;
	}
	for (long long int i = 1; i <= n; i += 1) {
		for (long long int j = 1; j <= 100000; j += 1) {
			if (j - a[i - 1][1] > -1) {
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - a[i - 1][1]] + a[i - 1][0]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	long long int ans = 0;
	for (long long int i = 1; i <= 100000; i += 1) {
		if (dp[n][i] <= w) {
			ans = max(ans, i);
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 79104
n, q = map(int, input().split())
elapse = 0
processes = []
result = []

for _ in range(n):
    name, time = input().split()
    time = int(time)
    processes.append([name, time])

while processes:
    process = processes.pop(0)
    if process[1] <= q:
        elapse += process[1]
        result.append([process[0], elapse])
    else:
        elapse += q
        processes.append([process[0], process[1]-q])

for process in result:
    print("{} {}".format(process[0], str(process[1])))



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    ll h;
    cin >> h;
    ll num = 0;
    ll res = 0;
    while (h > 0){
        h /= 2;
        res += pow(2, num);
        num++;
    }
    cout << res << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const int INF=1e9;
int dp[2525][2525], x[2525], y[2525], xx[2525][2525], xy[2525][2525], yx[2525][2525], yy[2525][2525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a[4334];
	char c[4334];
	cin>>n;
	REP(i, n<<1){
		cin>>c[i]>>a[i];
		--a[i];
		if(c[i]=='W'){
			x[a[i]]=i;
		}
		else{
			y[a[i]]=i;
		}
	}
	REP(i, n){
		REP(j, n){
			xx[i][j+1]=xx[i][j]+(x[i]<x[j]);
			xy[i][j+1]=xy[i][j]+(x[i]<y[j]);
			yx[i][j+1]=yx[i][j]+(y[i]<x[j]);
			yy[i][j+1]=yy[i][j]+(y[i]<y[j]);
		}
	}
	REP(i, n+1){
		REP(j, n+1){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	REP(i, n+1){
		REP(j, n+1){
			if(i<n){
				dp[i+1][j]=min(dp[i+1][j], dp[i][j]+xx[i][i]+xy[i][j]);
			}
			if(j<n){
				dp[i][j+1]=min(dp[i][j+1], dp[i][j]+yy[j][j]+yx[j][i]);
			}
		}
	}
	cout<<dp[n][n]<<'\n';
	return 0;
}


Measured memory_bytes: 106752
n, m, x, y = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))


xs = xs + [x]
ys = ys + [y]

max_x = sorted(xs)[-1]
min_y = sorted(ys)[0]



if max_x < min_y and x < min_y and max_x < y:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e3+5;

const int mod = 1e9+7;

int n;
double a[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    sort(a + 1 , a + n + 1);
    for(int i = 2; i <= n; i++){
        a[i] = (a[i] + a[i - 1])/ 2;
    }
    cout << a[n];
}

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

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<(abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) ? "Yes" : "No")<<endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n, w, h;
    cin >> n >> w >> h;
    int width[w + 1] = {}, height[h + 1] = {};

    rep(i, n) {
        int x, y, d;
        cin >> x >> y >> d;
        width[max(0, x - d)]++, width[min(w, x + d)]--;
        height[max(0, y - d)]++, height[min(h, y + d)]--;
    }

    bool ok_w = true, ok_h = true;
    if (width[0] == 0) ok_w = false;
    repl(i, 1, w) {
        width[i] += width[i - 1];
        if(width[i] == 0) ok_w = false;
    }
    if (height[0] == 0) ok_h = false;
    repl(i, 1, h) {
        height[i] += height[i - 1];
        if(height[i] == 0) ok_h = false;
    }

    if(ok_w || ok_h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3940
#include <iostream>
#include <queue>
#include <stdlib.h>

using namespace std;
#define N_MAX 50
int N;
int A[N_MAX];

int main(){
	cin >> N;
	int max_abs = 0;
	int max_abs_index = 0;
	for (int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		A[i] = tmp;
		if (max_abs < abs(tmp)){
			max_abs = abs(tmp);
			max_abs_index = i;
		}
	}

	if (A[max_abs_index] >= 0){
		cout << 2*N<<endl;
		cout << max_abs_index+1 << " " << 1 << endl;
		cout << max_abs_index+1 << " " << 1 << endl;
		for (int i = 2; i <= N; i++){
			cout << i-1 << " " << i << endl;
			cout << i-1 << " " << i << endl;
		}
	}
	else {
		cout << 2*N << endl;
		cout << max_abs_index+1 << " " << N << endl;
		cout << max_abs_index+1 << " " << N << endl;
		for (int i = N; i >1 ; i--){
			cout << i << " " << i-1 << endl;
			cout << i << " " << i-1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    int ans = 0;
    
    while (b > 0 && c > 0){
        c--;
        ans++;
        b--;
        ans++;
    }
    
    if (b > 0){
        ans += b;
        b = 0;
    }
    
    while (a > 0 && c > 0){
        c--;
        ans++;
        a--;
    }
    
    if (c > 0) ans++;
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int,input().split()))
b = [0] * (n + 1)
for i in range(n):
    b[a[i]] += 1
ans = 0
for i in range(len(b)):
    ans += b[i] * (b[i]-1) // 2
for i in range(n):
    print(ans - (b[a[i]] - 1))

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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var maxret = 0;
        for (int i = 0; i < n; i++)
        {
            var count = 0;
            var s1 = s.Substring(0, i);
            var s2 = s.Substring(i);
            var used = new List<char>();
            for (int j = 0; j < s1.Length; j++)
            {
                if (!used.Contains(s1[j]) && s2.Contains(s1[j])) count++;
                used.Add(s1[j]);
            }
            maxret = Math.Max(maxret, count);
        }
        Console.WriteLine(maxret);
    }
}


Measured memory_bytes: 13152
import math

a, b, C = map(int, input().split())

rC = math.radians(C)
a2 = a ** 2
b2 = b ** 2
ab = a * b

c = math.sqrt(a2 + b2 - 2 * ab * math.cos(rC))

S = ab * math.sin(rC) / 2
L = a + b + c
h = b * math.sin(rC)

print(f"{S:.5f} {L:.5f} {h:.5f}")


Measured memory_bytes: 5724
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    string s;
    cin >> s;
    if (s.size()%2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (size_t i = 0; i < s.size(); i += 2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define o(x)		  cout << x << endl;
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll bS(ll l, ll r, ll x, vll arr) {
	while (l <= r) {
		ll m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;
}

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

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;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll n, x , y;
		cin >> n >> x >> y;
		vll vec(n, 0);

		forn(i, 1, n + 1) {
			for (ll j = 1; i + j <= n; j++) {
				//cout << i << " " << i + j <<  endl;
				ll mini = min((abs(x - i) + abs(y - (i + j)) + 1), j);
				vec[mini]++;

			}




		}
		vec.erase(vec.begin());
		out(vec)



	}
	CLOCK
	return 0;
}



Measured memory_bytes: 3820