akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define NUM 100000

struct node{
  struct node *parent;
  struct node *left_child;
  struct node *right_sibling;
  int p_number;
  int c_number;
  int number;
};

int main(){
  struct node n[NUM],null_node;
  int n1,i,j,k,num,depth[NUM],child,child1;


  for(i=0;i<NUM;i++){
    n[i].parent=&null_node;
    n[i].left_child=&null_node;
    n[i].right_sibling=&null_node;
    n[i].p_number=-1;
    n[i].c_number=-1;
    depth[i]=0;
  }
  scanf("%d",&n1);
  
  for(i=0;i<n1;i++){ 
    scanf("%d%d",&num,&k);
    if(k>0){
      scanf("%d",&child);
      n[num].left_child=&n[child];
      n[num].c_number=child;
      n[child].parent=&n[num];
      n[child].p_number=num;
      for(j=0;j<k-1;j++){
	scanf("%d",&child1);
	n[child].right_sibling=&n[child1];
	n[child1].parent=&n[num];
	n[child1].p_number=num;
	n[child1].number=child1;
	child=child1;
      }
    }
    n[num].number=num;
  }

  for(i=0;i<n1;i++){
    j=i;
    while(n[j].parent!=&null_node){
      j=n[j].p_number;
      depth[i]++;
    }
  }

  for(i=0;i<n1;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",n[i].p_number);
    printf("depth = %d, ",depth[i]);
    if(n[i].p_number==-1){
      printf("root, [");
    }else if(n[i].p_number!=-1 && n[i].left_child==&null_node){
      printf("leaf, [");
    }else{
      printf("internal node, [");
    }
    if(n[i].left_child!=&null_node){
      printf("%d",n[i].c_number);
      j=n[i].c_number;
      while(n[j].right_sibling!=&null_node){
	printf(", %d",n[j].right_sibling->number);
	j=n[j].right_sibling->number;
      }
    }
    printf("]\n");
  }
  
  return 0;
}
  
  



Measured memory_bytes: 6064
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int n, m, x, y, mx, mn;

signed main()
{
    cin >> n >> m >> x >> y;
    mx = x;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mx = max(a, mx);
    }
    mn = y;
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        mn = min(a, mn);
    }
    if(mx < mn){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }



    return 0;
}
/*


*/


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  char ans;
  char a, b;
  cin >> a >> b;

  if (a == 'H') {
    ans = b;
  } else {
    if (b == 'H') {
      ans = 'D';
    } else {
      ans = 'H';
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
int ans;
char s[600011];
struct bignum{
	int s[500021],len;
	friend bignum operator*(bignum &x,int y){
		bignum ret;
		memset(&ret,0,sizeof(ret));
		ret.len=x.len;
		for(int i=1;i<=x.len;i++){
			ret.s[i]+=x.s[i]*y;
			ret.s[i+1]+=ret.s[i]/10;
			if(i==x.len && ret.s[i]>=10) ret.len++;
			ret.s[i]%=10;
		}
		for(int i=1;i<=ret.len;i++) ans+=ret.s[i];
		return ret;
	}
}n;
void Add(bignum &x,int y){
	ans-=x.s[1];
	x.s[1]+=y;
	for(int i=1;i<=x.len;i++){
		ans+=x.s[i]%10;
		if(x.s[i]>=10){
			if(i==x.len) x.len++;
			ans-=x.s[i+1];
			x.s[i+1]+=x.s[i]/10;
			x.s[i]%=10;
		}
		else break;
	}
}
bignum Read(){
	bignum ret;
	memset(&ret,0,sizeof(ret));
	scanf("%s",s+1);
	ret.len=strlen(s+1);
	for(int i=1;i<=ret.len;i++){
		ret.s[ret.len-i+1]=s[i]-'0';
	}
	return ret;
}
int main(){
	n=Read();
	n=n*9;
	for(int i=1;i<=n.len;i++){
		Add(n,9);
		if(ans<=9*i){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

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

namespace AtCoderABC086
{
    class Program
    {
        public static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(a);
            Console.WriteLine(a[2] * 10 + a[1] + a[0]);
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#define MAXN  100055	
using namespace std;
int n,m;
bool flag[MAXN]={false};
int  ball[MAXN]; 
int main()
{	
	scanf("%d%d",&n,&m);
	for(int i =1;i<=n;i++)
	{
		ball[i]=1;
	}
	flag[1]=true;
	int f,t;
	while(m--)
	{
		scanf("%d%d",&f,&t);
		if(ball[f]>1&&flag[f]==true)
		{
			ball[f]--;
			flag[t]=true;
			ball[t]++;
		}
		else if(flag[f]==true&&ball[f]==1)
		{
			flag[f]=false;
			flag[t]=true;
			ball[t]++;
			ball[f]--;
		}
		else
		{
			ball[t]++;
			ball[f]--;
		}
	}
	int cnt=0;
	for(int i =1;i<=n;i++)
	{
		if(flag[i]==true)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
string s;

int main(){
	cin>>n>>s;
	int q[n];
	if(s[0]=='W')
		q[0]=0;
	else q[0]=1;
	for(int i=1;i<n;i++){
		q[i]=q[i-1];
		if(s[i]=='E')
			q[i]++;
	}
	int ans=q[n-1]-q[0];
	for(int i=1;i<n;i++){
		int tans=(q[n-1]-q[i])+(i-q[i-1]);
		ans=min(ans,tans);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    ll n,k;
    cin >> n >> k;
    n = n%k;
    while (n > abs(n-k))
    {
        n = abs(n-k);
    }
    cout << n << endl;
}
int main()
{
    //ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


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

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int s = max( A, C );
	int t = min( B, D );
	int ans = 0;
	if( s < t ) {
		ans = t - s;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import math
from bisect import bisect_right
from copy import copy
n = int(input())
li = set([357,375,537,573,735,753])
li2 = set()
for i in li:
    li2.add(str(i))
li4 = copy(li2)
for k in range(6):
    li3 = set()
    for i in li4:
        for j in range(len(i)):
            i1 = i[:j]+'3' +i[j:]
            i2 = i[:j]+'5' +i[j:]
            i3 = i[:j]+'7' +i[j:]
            li3.add(i1)
            li3.add(i2)
            li3.add(i3)
    li4 = copy(li3)
    for j in li4:
        li2.add(j)
li5 = []
for i in li2:
    li5.append(int(i))
li5.sort()
k = bisect_right(li5, n)
print(k)

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

using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    vector<pair<string,int>> d;
    for (int i = 0; i < n; ++i) {
        string s;
        int t;
        cin>>s>>t;
        d.emplace_back(s,t);
    }
    string x;
    cin>>x;
    bool b=false;
    int ans=0;
    for (int i = 0; i < n; ++i) {
        if(b)ans+=d[i].second;
        if(d[i].first==x)b=true;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std; 
#define MAXO 50
#define MAXE 50
int main(int argc,char const* argv[])
{
  string o,e,tmpo,tmpe,correct(MAXO+MAXE,0);
  int i,sizeo,sizee,sizecorrect;
  cin >> o >> e;
  sizeo=o.size();
  sizee=e.size();
  sizecorrect=sizeo+sizee;
  for(i=0;i<sizeo;i++)
    {
      correct[2*i]=o[i];
    }
  for(i=0;i<sizee;i++)
    {
      correct[2*i+1]=e[i];
    }
  for(i=0;i<sizecorrect;i++)
    {
      cout << correct[i];
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())

ans = [0] * (N - 1)

for i in range(1, N + 1, 1):
    for j in range(i + 1, N + 1, 1):
        tmp = min(
            abs(j - i),
            abs(X - i) + 1 + abs(j - Y)
        )
        ans[tmp - 1] += 1

for a in ans:
    print(a)

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

using namespace std;

void solve(int x, vector<vector<int>> &graph, vector<int> &dp) {
    for (int child : graph[x]) {
        if (dp[child] == -1) {
            solve(child, graph, dp);
        }
        dp[x] = max(dp[x], dp[child] + 1);
    }
}

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

    int n, m;
    cin >> n >> m;

    int x, y;
    vector<vector<int>> graph(n);

    for (int i = 0; i < m; ++i) {
        cin >> x >> y;
        graph[x - 1].push_back(y - 1);
    }

    vector<int> dp(n, -1);
    for (int i = 0; i < n; ++i) {
        if (graph[i].empty()) {
            dp[i] = 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (dp[i] == -1) {
            solve(i, graph, dp);
        }
    }

    cout << *max_element(begin(dp), end(dp));

    return 0;
}


Measured memory_bytes: 8832
#include<stdio.h>

int main(){
    int k,n;
    scanf("%d %d",&k,&n);
    int a[n];
    int max=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<n+1;i++){
        if(i==n){
            if(max<k-a[n-1]+a[0]){
                max=k-a[n-1]+a[0];
            }
        }else{
            if(max<a[i]-a[i-1]){
                max=a[i]-a[i-1];
            }
        }
    }
    printf("%d",k-max);
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[200005];

ll comb(ll a, ll b) {
  ll ue=frac[a], sh1=1, sh2=1;
  ll tmp1, tmp2;
  ll h=mod-2;
  ll two;
  while(h>0) {
    two = 1;
    tmp1 = frac[a-b];
    tmp2 = frac[b];
    while(2*two<h) {
      two *= 2;
      tmp1 *= tmp1;
      tmp1 %= mod;
      tmp2 *= tmp2;
      tmp2 %= mod;
    }
    h -= two;
    sh1 *= tmp1;
    sh1 %= mod;
    sh2 *= tmp2;
    sh2 %= mod;
  }
  return ue*sh1%mod*sh2%mod;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<200005;++i) frac[i] = frac[i-1]*i%mod;
  ll N, M, K;
  cin>>N>>M>>K;
  ll ans = 0;
  for(ll i=0;i<N;++i) {
    ans += i*(i+1)/2%mod*M%mod*M%mod;
    ans %= mod;
    ans += (N-(i+1))*(N-(i+1)+1)/2%mod*M%mod*M%mod;
    ans %= mod;
  }
  for(ll i=0;i<M;++i) {
    ans += i*(i+1)/2%mod*N%mod*N%mod;
    ans %= mod;
    ans += (M-(i+1))*(M-(i+1)+1)/2%mod*N%mod*N%mod;
    ans %= mod;
  }
  ll two, h=mod-2;
  ll tmp;
  while(h>0) {
    two = 1;
    tmp = 2;
    while(2*two<h) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod;
    }
    h -= two;
    ans *= tmp;
    ans %= mod;
  }
  cout<<ans*comb(N*M-2, K-2)%mod<<endl;
}



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

#define	mp	make_pair
#define	X	first
#define	SL	second

using namespace std;

typedef	pair<int,int>	pii;

const int inf=1000000000;
pii river[150][11];
int memo[150][10][76];

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n;){
		for(int i=0;i<n;i++){
			int k;	scanf("%d",&k);
			for(int j=0;j<k;j++){
				int x,slip;	scanf("%d%d",&x,&slip);
				river[i][j]=mp(x,slip);
			}
			river[i][k]=mp(-1,-1);
		}

		for(int i=0;i<n;i++)for(int j=0;~river[i][j].X;j++)for(int k=0;k<=m;k++)
			memo[i][j][k]=inf;

		for(int j=0;~river[0][j].X;j++)	memo[0][j][0]=0;
		for(int j=0;~river[1][j].X;j++)	memo[1][j][1]=0;

		for(int i=1;i<n;i++){
			for(int j=0;~river[i][j].X;j++){
				int cost;
				for(int k=0;k<=m;k++){
					for(int b=0;~river[i-1][b].X;b++){
						cost=(river[i][j].SL+river[i-1][b].SL)*abs(river[i][j].X-river[i-1][b].X);
						memo[i][j][k]=min(memo[i][j][k],cost+memo[i-1][b][k]);
					}
				}
				for(int k=1;k<=m;k++){
					if(i-2<0)	continue;
					for(int b=0;~river[i-2][b].X;b++){
						cost=(river[i][j].SL+river[i-2][b].SL)*abs(river[i][j].X-river[i-2][b].X);
						memo[i][j][k]=min(memo[i][j][k],cost+memo[i-2][b][k-1]);
					}
				}
			}
		}

		int mincost=inf;
		for(int j=0;~river[n-1][j].X;j++)for(int k=0;k<=m;k++)	mincost=min(mincost,memo[n-1][j][k]);
		for(int j=0;~river[n-2][j].X;j++)for(int k=0;k<m;k++)	mincost=min(mincost,memo[n-2][j][k]);
		printf("%d\n",mincost);
	}

	return 0;
}

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

ab.sort()

ans=0
for i in range(n):
    if ab[i][1]>=m:
        ans+=ab[i][0]*m
        break
    else:
        ans+=ab[i][0]*ab[i][1]
        m-=ab[i][1]
print(ans)

Measured memory_bytes: 27504
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> s(3);
  cin >> s[0] >> s[1] >> s[2];
  std::sort(s.begin(), s.end());
  cout << s[0]+s[1] << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
$a = fgets(STDIN);
$b = explode(' ', fgets(STDIN));
$c = 100;
for ($i=0; $i<$a; $i++){
	for ($j=0; $b[$i]%2==0; $j++){
    $b[$i]/=2;
	}
    $c=min($j,$c);
}
echo $c;
?>

Measured memory_bytes: 3576
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    sort(s.begin(),s.end());
    cout<<(s[0]==s[2]?"No":"Yes")<<endl;
}


Measured memory_bytes: 256
def f(n):
    n = int(n)
    if n%4 == 0:
        return 2
    elif n%2 == 0:
        return 1
    else:
        return 0

n = int(input())
a = list(map(f,input().split()))
c1 = a.count(0)
c2 = a.count(1)
c4 = n-c1-c2
if c1<=c4:
    print("Yes")
elif c1 == c4 + 1 and c2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62832
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    D = int(sys.stdin.readline())
    if D == 25:
        print("Christmas")
    elif D == 24:
        print("Christmas Eve")
    elif D == 23:
        print("Christmas Eve Eve")
    elif D == 22:
        print("Christmas Eve Eve Eve")



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, K; cin >> n >> K;
  vector<pair<ll, ll>> P(n);
  rep(i, n) cin >> P[i].first >> P[i].second;
  ll ans = LONG_LONG_MAX;
  rep(i, n) rep(j, n) rep(k, n) rep(l, n) {
    ll xl = min({P[i].first, P[j].first, P[k].first, P[l].first});
    ll xr = max({P[i].first, P[j].first, P[k].first, P[l].first});
    ll yl = min({P[i].second, P[j].second, P[k].second, P[l].second});
    ll yr = max({P[i].second, P[j].second, P[k].second, P[l].second});
    int cnt = 0;
    rep(m, n) {
      if(xl <= P[m].first && P[m].first <= xr &&
         yl <= P[m].second && P[m].second <= yr) cnt++;
    }
    if(cnt >= K) ans = min((xr-xl)*(yr-yl), ans);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;
template<class Value>
using dict = map<string, Value>;

int main(){
  int n;
  cin >> n;
  vector<ll> sum(n + 1, 0);
  map<ll, ll> s_map;
  for(int i = 0; i < n; ++i){
    ll a;
    cin >> a;
    sum[i + 1] = sum[i] + a; 
    if(s_map.count(sum[i + 1]) == 0){
      s_map[sum[i + 1]] = 1;
    }
    else ++s_map[sum[i + 1]];
  }

  ll cnt = 0;
  for(auto const& s : s_map){
    ll k = s.first;
    ll v = s.second;
    cnt += v * (v - 1) / 2; 
    if(k == 0)cnt += v;
  }

  cout << cnt << endl;

  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  REP(i, W + 2) cout << '#';
  cout << endl;
  for(int i = 0; i < H; i++) {
    cout << '#';
    for(int j = 0; j < W; j++) {
      char a;
      cin >> a;
      cout << a;
    }
    cout << '#' << endl;
  }
  REP(i, W + 2) cout << '#';
  cout << endl;

  return 0;
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int A, B, C;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> A >> B >> C;
  cout << (A == B && B == C ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define M 1000
using namespace std;  
#define PI 3.141592653589793238462643383279502884197169
int main()
{
   
 int n;
  cin>>n;
  int a=n%10;
  if(a==2||a==4||a==5||a==7||a==9)
    cout<<"hon";
  if(a==0||a==1||a==6||a==8)
    cout<<"pon";
  if(a==3)
    cout<<"bon";

    return 0;
}

Measured memory_bytes: 3676
from bisect import bisect_left
 
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += idx - 1 - j
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i=0; i<N; ++i) cin >> X[i];

    ll mn = INT_MAX;
    for (int P=1; P<=100; ++P) {
        ll cost = 0;
        for (int i=0; i<N; ++i) {
            cost += (X[i] - P) * (X[i] - P);
        }
        mn = min(mn, cost);
    }
    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-9;
const int N = 1e5 + 50, M = 1e5 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }

int main() {
	fast_in_out();
//	cout << fixed << setprecision(6);
	int n, m, c;
	cin >> n >> m >> c;
	int op = 0;
	while (c > 0) {
		c -= max(n, m);
		op++;
	}
	cout << op << endl;
	return 0;
}

Measured memory_bytes: 256
n,d = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(n)]

def dist_squere(x, y):
    d = 0
    for i,j in zip(x,y):
        d += (i-j)**2
    return d**.5

from itertools import combinations

ans = 0
for x,y in combinations(X, 2):
    if dist_squere(x, y).is_integer():
        ans += 1

print(ans)

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;

int32_t main()
{
	fio;
	int r;
	cin>>r;
	cout<<2*(22.0/7.0)*r<<endl;
	return 0;
}

Measured memory_bytes: 3820
#include <cstdio>

typedef long long LL;
const int Mod = 998244353;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

const int MN = 500005;

int Fac[MN], iFac[MN];

inline void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}
inline int Binom(int N, int M) {
	if (M < 0 || M > N) return 0;
	return (LL)Fac[N] * iFac[M] % Mod * iFac[N - M] % Mod;
}

int N, K, Ans;

int main() {
	scanf("%d%d", &N, &K);
	Init(K);
	for (int i = N; i <= K; ++i) Ans = (Ans + Binom(K - 1, i - 1)) % Mod;
	printf("%d\n", Ans); 
	return 0;
}

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

int main(void) {
    int a,b;
    cin>>a;
    cin>>b;

    if(a>b){
        cout<<"a > b";
    }
    else if(a<b){
        cout<<"a < b";
    }
    else if(a==b){
        cout<<"a == b";
    }
 

    cout<<endl;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int charCount = sc.nextInt();
		String word = sc.next();
		int answer = 0;
		int index = 0;
		while(true) {
			index = word.indexOf("ABC");
			if(index == -1){
				break;
			}else {
				word = word.substring(index +3);
				answer++;
			}
		}
		System.out.println(answer);

	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
LL facctorialMethod(int k);
int main(){
    LL x,x_cnt,kin,ans;
    cin >> x;
    kin = 100;
    x_cnt = 0;

    while(kin < x){
//        kin = floor(kin * 1.01);
        kin += kin / 100;
        x_cnt++;
//        cout << "kin :" << kin << endl;
//        cout << "x_xnt :" << x_cnt << endl;
    }

    ans = x_cnt;
    cout << ans << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3600
n=int(input())
l=list(map(int,input().split()))
if l[0]>0:
	ans=0
	now=l[0]
else:
	ans=1-l[0]
	now=1
for i in range(1,n):
	if i%2==0:
		if now + l[i]>0:
			now+=l[i]
		else:
			ans+=(1-now)-l[i]
			now=1
	else:
		if now + l[i]<0:
			now+=l[i]
		else:
			ans+=(1+now)+l[i]
			now=-1
if l[0]<0:
	tmp=0
	now=l[0]
else:
	tmp=1+l[0]
	now=-1
for i in range(1,n):
	if i%2==1:
		if now + l[i]>0:
			now+=l[i]
		else:
			tmp+=(1-now)-l[i]
			now=1
	else:
		if now + l[i]<0:
			now+=l[i]
		else:
			tmp+=(1+now)+l[i]
			now=-1
print(min(tmp,ans))



Measured memory_bytes: 14468
#include<iostream>

using namespace std;

#define SIZE 200001

const long long P = 1000000007;

long long fac[SIZE + 1];
long long ifac[SIZE + 1];

long long mod_pow(long long a, long long p) {
	long long ans = 1;

	while (p != 0) {
		if (p & 1) {
			ans = ans * a % P;
		}
		a = a * a % P;
		p = p >> 1;
	}
	return ans;
}

void init_fac_table(void) {
	fac[0] = 1;
	ifac[0] = 1;
	for (int i = 0; i < SIZE; i++) {
		fac[i + 1] = fac[i] * (i + 1) % P;
		ifac[i + 1] = ifac[i] * mod_pow(i + 1, P - 2) % P;
	}
}

long long nCr(long long n, long long r) {
	if (n == 0 && r == 0) {
		return 1;
	}
	if (n < r || n < 0) {
		return 0;
	}
	long long t = ifac[n - r] * ifac[r] % P;
	return t * fac[n] % P;
}

int main(int argc, char *argv[])
{
	long long N, M, K;

	cin >> N >> M >> K;
	init_fac_table();
	long long ans = 0;
	for (long long i = 0; i < M; i++) {
		ans += nCr(M * N - 2, K - 2) * i * (M - i) * N * N % P;
	}

	for (long long i = 0; i < N; i++) {
		ans += nCr(M * N - 2, K - 2) * i * (N - i) * M * M % P;
	}
	cout << ans % P << "\n";
	return 0;
}


Measured memory_bytes: 3328
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    if(e-a>f)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
return 0;
}


Measured memory_bytes: 4992
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};



int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int k;
    vector<int> a(5);
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    string ans = "Yay!";
    for (int i=0; i<5; ++i){
        for (int j=i+1; j<5; ++j){
            if(abs(a[i] - a[j]) > k){
                ans = ":(";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans1 = a*b;
        int ans2 = a*2+b*2;
        System.out.println(ans1 + " " + ans2);
    }
}



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

int main(){
  string A,B; cin >> A >> B;
  if(A.size()>B.size()){
    cout << "GREATER" << endl;
  }else if(A.size()<B.size()){
    cout << "LESS" << endl;
  }else{
    if(A>B){
      cout << "GREATER" << endl;
    }else if(A<B){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }
  }
}

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

class Main{

    public static int n, i, j, m = 0;
    public static int[] A;
    public static int[] B;
    public static int[] C;

    public static void main(String[] args){
        try{
	    int i;
	    //int j=0;
	    BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
	    String s;
	    s = buffer.readLine();
	    n = Integer.parseInt(s);
	    A = new int[n+1];
	    B = new int[n+1];
	    

	    StringTokenizer S = new StringTokenizer(buffer.readLine());
	    j=0;
	    for(i=1 ; i<=n ; i++){
		A[i] = Integer.parseInt(S.nextToken());	
		j++;
		if(m < A[i]){m = A[i];}
	    }
	    buffer.close();
	}
	catch(IOException e){
	    System.out.println(e);
	}
       StringBuffer sb = new StringBuffer();
       
	C = new int[m+1];
	CountingSort(A, B, m);
	for(i=1 ; i<n ; i++){
	   sb.append(B[i]+" ");
	}
	sb.append(B[i]);
	System.out.println(sb);
    }
    public static void CountingSort(int A[], int B[], int k){
        for(int i=0 ; i<k ; i++){
            C[i] = 0;
        }
        for(int j=1 ; j<=n ; j++){
            C[A[j]]++;
        }
        for(int i=1 ; i<=k ; i++){
            C[i] = C[i] + C[i-1];
        }
        for(int j=n ; j>0 ; j--){
            B[C[A[j]]] = A[j];
            C[A[j]]--;
        }
    }
}



Measured memory_bytes: 228424
#include<iostream>
#include<cmath>
#include<algorithm>
#include <iomanip> 
#include<vector>
#define fo(i,n) for(int i=0;i<n;i++)
#define f(i,n) for(int i=2;i<=n;i++)
#define ll long long
/*Elegizip, elegizip otken sol bir shaktar-ai
 Elendeter zamanymnyn otip bara zhatkanny-ai
Umytylmas-Umytylmas Kairan esil shaktar-ai
Zamanymnyn kolyn bulgap otip bara jatkany-ai
 kairan esil , kairan esil shaktar-ai
kolyn bulgap zamanymnyn otip bara jatkany-ai;*/
using namespace std;

int main()
{ios::sync_with_stdio(0);
ll k,n, r=0;
cin>>k>>n;
ll a[n];
fo(i,n){
cin>>a[i];
if(i>0){
    if(a[i]-a[i-1]>r) r=a[i]-a[i-1];

}

}
if(k-a[n-1]+a[0]>r) r=k-a[n-1]+a[0];


cout<<k-r;





}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    S = input().strip()
    print("ABC" if S == "ARC" else "ARC")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
#include<stdio.h>

int main(void)
{
	int n,x,i,j,k,num=0;
	scanf("%d %d",&n,&x);
	while(1)
	{
		for(i = 1;i <= n;i++)
		{
			for(j = i + 1;j <= n;j++)
			{
				for(k = j + 1;k <= n;k++)
				{
					if(i + j + k == x)
					{
						num = num + 1;
					}
				}
			}
		}
		printf("%d\n",num);
		num = 0;
		scanf("%d %d",&n,&x);
		if(n == 0 || x == 0)
		{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 1e5 + 10;

int n;
int p[maxn], pos[maxn];
multiset <int> s;
multiset<int>::iterator a1,a2,x,y,b1,b2;

int main()
{   
	cin>>n;
	for(int i=1;i<=n;i++) {
		read(p[i]);
		pos[p[i]] = i;
	}
	s.insert(0); s.insert(0);
	s.insert(n+1); s.insert(n+1);
	ll res = 0;
	for (int i=n;i>=1;i--){
		x = y = s.upper_bound(pos[i]);  //第一个大于等于pos[i]
		a2 = --x; a1 = --x;
		b1 = y ; b2 = ++y;
		res += 1ll*(*a2-*a1)*(*b1-pos[i])*i;
		res += 1ll*(pos[i]-*a2)*(*b2-*b1)*i;
		s.insert(pos[i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 5760
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e9,M=1e9+7;
const int N=1;

void solve()
{
    int n,k,s;
    cin>>n>>k>>s;

    for(int i=1;i<=k;++i)
        cout<<s<<" ";

    for(int i=k+1;i<=n;++i)
    {
        if(s==inf)
            cout<<inf-1;
        else
            cout<<inf;
        cout<<" ";
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	int ans = 0;

	ans += n * (n - 1) / 2;
	ans += m * (m - 1) / 2;

	dunk(ans);
	return 0;
}


Measured memory_bytes: 256
// Aizu Vol-2 0281: Formation
// 2017.8.6

#include <stdio.h>

int main()
{
	int c, a, n, ans, cn;

	scanf("%d", &cn);
	while (cn--) {
		scanf("%d%d%d", &c, &a, &n);
		if (n <= c && n <= a) {
			ans = n, c -= n, a -= n;
			if (a <= c) {
				if (2 * a >= c) ans += c / 2;
				else {
					ans += a, c -= 2 * a;
					ans += c / 3;
				}
			} else ans += c / 2;
		}
		else if (a <= c && a <= n) ans = a + (c - a) / 3;
		else ans = c;    // c <= a && c <= n
		printf("%d\n", ans);
	}
	return 0;
}

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

int table[1010];
int p[10], c[10];

int main() {
    int D, G;
    cin >> D >> G;

    G /= 100;
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }

    for (int i = 0; i < D; i++) {
        for (int num = 1000; num >= 0; num--) {
            for (int j = 0; j <= min(num, p[i]); j++) {
                int score = (i + 1) * j;
                if (j == p[i]) score += c[i];

                table[num] = max(table[num], table[num - j] + score);
            }
        }
    }

    for (int num = 0; num <= 1000; num++) {
        if (table[num] >= G) {
            cout << num << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    int d[100000] = {};
    int D[100000] = {};
    for(int i=0;i<N;i++){
        cin >> d[i];
        D[i] = d[i];
    }
    
    sort(d,d+N);
    sort(D,D+N,greater<int>());
    
    int ans[2] = {};
    ans[0] = d[N/2];
    ans[1] = D[N/2];
    sort(ans,ans+2);
    
    int cnt = 0;
    for(int i=ans[0];i<ans[1];i++){
        cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int r, D, x;
	cin >> r >> D >> x;

	for (int i = 0; i < 10; i++)
	{
		int next = r * x - D;
		cout << next << "\n";
		x = next;
	}

	return 0;
}

Measured memory_bytes: 3608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter
from collections import defaultdict
from collections import deque 
def main():
    N, X, Y = map(int, readline().split())
    to = [[] for _ in range(N)] 

    for i in range(N-1):
        to[i].append(i+1)
        to[i+1].append(i)
    to[X-1].append(Y-1)
    to[Y-1].append(X-1)
    INF = int(1e9)
    ans = defaultdict(int)
    for si in range(N):
        dq = deque()
        dq.append(si)
        dist = [INF for _ in range(N)]
        dist[si] = 0
        while len(dq)>0:
            v = dq.popleft()
            for nx in to[v]:
                if dist[nx] != INF:
                    continue
                dq.append(nx)
                dist[nx] = dist[v]+1
        for i in dist:
            ans[i] += 1
    
    for i in range(1, N):
        print(ans[i]//2)
if __name__ == '__main__':
    main()


Measured memory_bytes: 53084
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N = int(input())
A = list(map(int,(input().split())))
A.sort()
A.append(-1)
ans = 0
ok = [True]*(10**6+1)
for i in range(N):
    now = A[i]
    if now != A[i+1]:
        if ok[now]:
            if i == 0 or now != A[i-1]:
                ans += 1
            c = 1
            while now*c < 10**6+1:
                ok[now*c] = False
                c += 1
print(ans)

Measured memory_bytes: 97084
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(0,A+1):
	for b in range(0,B+1):
		for c in range(0,C+1):
			if a * 500 + b * 100 + c * 50 == X: 
				ans = ans + 1
print(ans)


Measured memory_bytes: 3060
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(1e5)+5;
int cnt[maxn],now[2];

int main() {
    int n;
    read(n);
    REP(i,1,n) {
        int x;
        read(x);
        cnt[x]++;
    }
    int mx=(int)(1e5);
    REP(i,1,mx) if(cnt[i]) {
        if(cnt[i]&1) now[1]++;
        else now[0]++;
    }
    if(now[0]&1) now[1]--;
    printf("%d\n",now[1]+now[0]);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int sum = 0;
        sc.close();
        if(a>=k){
            System.out.println(k);
            return;
        }
        if(a+b>=k){
            System.out.println(a);
            return;
        }
        sum = k - a - b;
        System.out.println(a-sum); 
    }
}

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

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> list(105,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>list.at(i).at(j);
        }
    }
    vector<vector<char>> ans(220,vector<char>(w));
    for(int i=0;i<h;i++){
        ans.at(2*i)=list.at(i);
        ans.at(2*i+1)=list.at(i);
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout<<ans.at(i).at(j);
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[0 for i in range(w)] for i in range(h)]
c2 = [[0 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == 0:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n +=1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == 0:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n +=1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

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

using namespace std;

int main(){

    int v[3];
    cin>> v[0]>> v[1]>> v[2];
    sort(v, v+3);

    if(v[0]==5&&v[1]==5&&v[2]==7){
        cout<< "YES";
    }else{
        cout<< "NO";
    }
    cout<< endl;

    return 0;
}


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

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

int main(void){
    int a, b;
	while(cin >> a >> b) {
	    cout << gcd(a,b) << " " << (a / gcd(a,b) * b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n), b(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  for (i64 i = 0; i < n; i++)
    cin >> b[i];
  i64 ans = 1e9;
  //0:red 1:blue
  for (i64 bit = 0; bit < (1LL << n); bit++)
  {
    vector<pair<i64, i64>> even, odd;
    for (i64 i = 0; i < n; i++)
      if (i % 2 == 0)
      {
        if (bit & (1LL << i))
          odd.push_back({b[i], i});
        else
          even.push_back({a[i], i});
      }
      else
      {
        if (bit & (1LL << i))
          even.push_back({b[i], i});
        else
          odd.push_back({a[i], i});
      }
    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());
    bool ok = true;
    vector<pair<i64, i64>> t(n);
    i64 esize = even.size(), osize = odd.size();
    for (i64 i = 0; i < n; i++)
      if (i % 2 == 0 && i / 2 < esize)
        t[i] = even[i / 2];
      else if (i % 2 == 1 && i / 2 < osize)
        t[i] = odd[i / 2];
      else
        ok = false;
    for (i64 i = 1; i < n; i++)
      if (t[i].first < t[i - 1].first)
        ok = false;
    if (ok)
    {
      i64 tmp = 0;
      vector<i64> g(n);
      for (i64 i = 0; i < n; i++)
        g[t[i].second] = i;
      for (i64 i = 0; i < n; i++)
        for (i64 j = i + 1; j < n; j++)
          if (g[j] < g[i])
            tmp++;
      ans = min(ans, tmp);
    }
  }
  if (ans == 1e9)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int64_t> a(N);
  vector<int64_t> S(N+1,0);
  for(int i=0;i<N;++i) cin>>a[i];
  for(int i=1;i<=N;++i) S[i]=S[i-1]+a[i-1];
  sort(S.begin(),S.end());
  int64_t sum=0;
  for(int i=0;i<=N;++i){
    int j=i;
    int64_t cnt=0;
    while(j<=N && S[j]==S[i]){
      ++j;
      ++cnt;
    }
    sum += cnt*(cnt-1)/2;
    i=j-1;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include<vector>
using namespace std;
int main() {
	string z;
	cin >> z;
	for (int i = 0; i < 3; i++) {
		if (z[i] == '7') {
			cout << "Yes" << endl;

			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#define INF 2000000000
typedef struct{
  char c;
  int n;
}data;
int partition(data*, int, int);
void quickSort(data*, int, int);
void merge(int*, int, int, int);
void mergeSort(data*, int, int);
int main(){
  int n;
  std::cin >> n;
  data A[n], B[n];
  for(int i=0; i<n; i++){
    std::cin >> A[i].c >> A[i].n;
    B[i] = A[i];
  }
  quickSort(A, 0, n-1);
  mergeSort(B, 0, n);
  bool stable=true;
  for(int i=0; i<n; i++){
    if(A[i].c != B[i].c){
      stable = false;
      break;
    }
  }
  std::cout << (stable ? "Stable\n" : "Not stable\n");
  for(int i=0; i<n; i++) std::cout << A[i].c << " " << A[i].n << "\n";
  return 0;
}
int partition(data *A, int p, int r){
  int i=p-1;
  data tmp, x=A[r];
  for(int j=p; j<=r-1; j++){
    if(A[j].n <= x.n){
      i++;
      tmp=A[i], A[i]=A[j], A[j]=tmp;
    }
  }
  tmp=A[i+1], A[i+1]=A[r], A[r]=tmp;
  return i+1;
}
void quickSort(data *A, int p, int r){
  int q;
  if(p < r){
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}
void merge(data *A, int l, int m, int r){
  int n1=m-l, n2=r-m, i, j;
  data L[n1+1], R[n2+1];
  for(i=0; i<n1; i++) L[i] = A[l+i];
  for(i=0; i<n2; i++) R[i] = A[m+i];
  L[n1].n = R[n2].n = INF;
  i = j = 0;
  for(int k=l; k<r; k++){
    if(L[i].n <= R[j].n){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}
void mergeSort(data *A, int l, int r){
  int m;
  if(l+1 < r){
    m =(l + r) / 2;
    mergeSort(A, l, m);
    mergeSort(A, m, r);
    merge(A, l, m, r);
  }
}

Measured memory_bytes: 5364
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0;
    } else {
        cout << 10; 
    }   
}


Measured memory_bytes: 256