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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


const int NUM_=400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
ll mo=1000000007;

int N,X,Y;
pair<int,int> mi[202020];
int C[202020],W[202020];
pair<int,int> L[202020],R[202020];

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<202020> uf;
vector<pair<int,int>> CC[202020];
map<int,int> M[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	for(i=0;i<=202000;i++) mi[i]={1<<30,0};
	
	cin>>N>>X>>Y;
	FOR(i,N) {
		cin>>C[i]>>W[i];
		CC[C[i]].push_back({W[i],i});
		mi[C[i]]=min(mi[C[i]],{W[i],i});
	}
	
	L[0]=R[202000]={1<<30,-1};
	FOR(i,202000) L[i+1]=min(L[i],mi[i+1]);
	for(i=202000;i>=1;i--) R[i-1]=min(R[i],mi[i-1]);
	
	for(i=1;i<=200000;i++) if(CC[i].size()) {
		sort(ALL(CC[i]));
		auto a=CC[i][0];
		pair<int,int> p=min(L[i-1],R[i+1]);
		FORR(r,CC[i]) if(a.first+r.first<=X) uf(a.second,r.second);
		FORR(r,CC[i]) if(p.first+r.first<=Y) uf(p.second,r.second);
	}
	FOR(i,N) M[uf[i]][C[i]]++;
	
	ll ret=1;
	FOR(i,N) if(M[i].size()) {
		x=0;
		FORR(r,M[i]) x+=r.second;
		(ret *= fact[x])%=mo;
		FORR(r,M[i]) (ret *= factr[r.second])%=mo;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 46464
// 2020-06-30 19:27:19
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct mint {
  ll divisor = 998244353;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
};

void answer() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<mint> dp(s+1, 0), p(s+1, 0);
  mint ans = 0;
  rep(i, n) {
    swap(p, dp);
    p[0] += 1;
    repc(j, s) {
      dp[j] = p[j];
      if(j - a[i] >= 0) dp[j] += p[j - a[i]];
    }
    ans += dp[s];
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3736
def mygets():
    return [int(v) for v in input().strip().split(' ')]

n, x = mygets()
a = mygets()

b1 = a

ans = sum(a)

for i in range(1, n):
    b2 = [u if u < b1[k - 1] else b1[k - 1] for k, u in enumerate(a)]
    ans = min(ans, sum(b2) + i * x)
    b1 = b2

print(ans)

Measured memory_bytes: 3316
#include<cstdio>

using namespace std;

int n,s,memo[1024][500];

int search(int stat,int sum,int dep){
	if(dep==n)	return memo[stat][sum]=(s==sum);
	if(~memo[stat][sum])	return memo[stat][sum];
	if(sum>s)	return 0;

	int cnt=0;
	for(int i=0;i<10;i++){
		if((stat&(1<<i))==0){
			stat|=1<<i;
			cnt+=search(stat,sum+i*(n-dep),dep+1);
			stat&=~(1<<i);
		}
	}
	return memo[stat][sum]=cnt;
}

int main(){
	for(;~scanf("%d%d",&n,&s);){
		for(int i=0;i<1024;i++)for(int j=0;j<500;j++)	memo[i][j]=-1;
		if(n>10 || s>=500){ puts("0"); continue; }
		printf("%d\n",search(0,0,0));
	}
	return 0;
}

Measured memory_bytes: 2764
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
  INF = 1 << 30
  H, W = wall.shape
  S, T = Sx * W + Sy, Tx * W + Ty
  dist = np.full(H * W, INF, np.int64)
  deq = np.empty(2*H*W+100, np.int64)
  dist[S] = 0
  deq[H * W] = S
  l, r = H*W, H*W+1
  while l<r:
    v = deq[l]
    l += 1
    vx,vy = divmod(v,W)
    for dx,dy in ((1,0),(0,1),(-1,0),(0,-1)):
      wx,wy = vx+dx,vy+dy
      if wall[wx,wy]:
        continue
      w = wx * W + wy
      if dist[w] <= dist[v]:
        continue
      dist[w] = dist[v]
      deq[l-1] = w
      l -= 1
    for dx in range(-2,3):
      for dy in range(-2,3):
        wx, wy = vx+dx, vy+dy
        if wall[wx,wy]:
          continue
        w = wx*W+wy
        if dist[w]<=dist[v]+1:
          continue
        dist[w] = dist[v]+1
        deq[r] = w
        r += 1
  ans = dist[T]
  if ans == INF:
    ans = -1
  return ans

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)+1, input().split())
gh, gw = map(lambda x:int(x)+1, input().split())

wall = [0]*(H+4)
wall[0] = [True]*(W+4)
wall[1] = [True]*(W+4)
wall[H+2] = [True]*(W+4)
wall[H+3] = [True]*(W+4)
for h in range(2,H+2):
  wall[h] = [True]*2 + [s=='#' for s in input()] + [True]*2
wall = np.array(wall)
print(main(wall, sh, sw, gh, gw))

Measured memory_bytes: 121424
#include <bits/stdc++.h>
using namespace std;
#define loop(i,n) for (int i =0;i<(n);++i)
typedef long long ll;
 
 
int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);

//    freopen("a.txt", "r", stdin);
 
    int patka = 0;
    int N; cin >> N;
    loop(i, N) {
        int current; cin >> current;
        if (current != i+1) patka++;
    }
    string ans = (patka <= 2) ? "YES" : "NO";
    cout << ans << endl;

    //cout <<N;
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int d;
    scanf("%d",&d);
    switch(d){
        case 25:
            printf("Christmas\n");
            break;
        case 24:
            printf("Christmas Eve\n");
            break;
        case 23:
            printf("Christmas Eve Eve\n");
            break;
        case 22:
            printf("Christmas Eve Eve Eve\n");
            break;
    }
    return 0;
}

Measured memory_bytes: 128
C = [list(map(int, input().split())) for i in range(3)]

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (C[0][0]-a1) == (C[1][0]-a2) == (C[2][0]-a3):
                if (C[0][1]-a1) == (C[1][1]-a2) == (C[2][1]-a3):
                    if (C[0][2] - a1) == (C[1][2] - a2) == (C[2][2] - a3):
                        print("Yes")
                        exit()
print("No")

Measured memory_bytes: 3064
N = int(input())
S = input()

s=[]
for i in range(len(S)):
  if ord(S[i])+N >= 91:
    j = (ord(S[i])+N -65)%26+65
    s.append(chr(j))
  else:
    s.append(chr(ord(S[i])+N))
print(''.join(s))

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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define int long long 
#define str string
#define elif else if

int i,j,k,h,w;
int a,b,c,x,y,n,m,cnt=0,ans=0;
str s,t;

signed main(){ 
  cin>>n>>h>>w;  

  rep(i,n){
    cin>>x>>y;
    if(x>=h&&y>=w)cnt++;
  }
  debg(cnt);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

vector<long long> NBase(long long X,long long N) {
    assert(abs(N)>1);
    vector<long long> res;
    while(1) {
        long long b = (X%abs(N)+abs(N)) % abs(N);
        res.push_back(b);
        (X -= b) /= N;
        if(X==0) break;
    }
    return res;
}

int main() {
	ll N,K; cin >> N >> K;
	auto E = NBase(N,K);
	cout << E.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A, B, C;
    cin >> A >> B >> C;
    int lenA = A.length();
    int lenB = B.length();
    lenA--; lenB--;
    if (A[lenA] == B[0] && B[lenB] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

void solve(int n, const std::string& s, const std::string& t)
{
  for (int i = 0; i < n; ++i) {
    std::cout << s[i] << t[i];
  }
}

int main()
{
  int n;
  std::cin >> n;
  std::string s, t;
  std::cin >> s >> t;

  solve(n, s, t);
  std::cout << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=200005;
int n,K,L;
struct Union_Find
{
	int fa[MAX_N];
	void init()
	{
		for(int i=1;i<=n;i++)
		{
			fa[i]=i;
		}
	}
	int find(int x)
	{
		return x==fa[x]?x:fa[x]=find(fa[x]);
	}
	void unite(int a,int b)
	{
		fa[find(a)]=find(b);
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	void update()
	{
		for(int i=1;i<=n;i++)
		{
			find(i);
		}
	}
}rail,road;
map <pair<int,int>,int> connect;
int main()
{
	cin>>n>>K>>L;
	rail.init();
	road.init();
	while(K--)
	{
		int p,q;
		cin>>p>>q;
		road.unite(p,q);
	}
	while(L--)
	{
		int r,s;
		cin>>r>>s;
		rail.unite(r,s);
	}
	road.update();
	rail.update();
	for(int i=1;i<=n;i++)
	{
		connect[make_pair(road.fa[i],rail.fa[i])]++;
	//	cout<<"("<<road.fa[i]<<","<<rail.fa[i]<<")"<<endl;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<connect[make_pair(road.fa[i],rail.fa[i])]<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 13568
let s = Int(readLine()!)!

var dp: [Int] = .init(repeating: -1, count: s + 1)
let mod = 1000000007
func backtrack(from value: Int, target: Int) -> Int {
  if value == target {
    return 1
  }
  if value > target {
    return 0
  }
  if dp[value] != -1 {
    return dp[value]
  }
  
  var sum = 0
  for i in 3..<2001 {
    if i + value > target {
      break
    }
    sum += backtrack(from: value + i, target: target)
    sum %= mod
  }
  dp[value] = sum
  return dp[value]
}

print(backtrack(from: 0, target: s))

Measured memory_bytes: 7820
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define print(x) cout<<x<<endl  //xを改行付きで出力
#define scan(x) cin>>x //xを入力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
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; }
int main(){
  int n;cin>>n;
  ll temp = 0;
  ll mn = INF;
  ll mx = -1000000000;
  ll ans = 0;
  rep0(i,n){
    cin>>temp;
    mn = min(mn,temp);
    mx = max(mx,temp);
    ans += temp;
  }
  cout<<mn<<" "<<mx<<" "<<ans<<endl;
  return 0;
}


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

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

    rep(i, s.size()) cout << 'x';
    cout << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int A, B;
	cin >> A >> B;
	cout << max(max(A + B, A - B), A * B) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int [][]_2Cum_sum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int k2 = k*2;
		long[][] Hope = new long [n][3];
		int[][] map = new int [k2][k2];
		//二次元累積和
		_2Cum_sum = new int[k2+1][k2+1];

		//W=-1,B=1としてHope[i][2]にいれる
		for(int i=0;i<n;i++) {
			Hope[i][0] = Long.parseLong(sc.next());
			Hope[i][1] = Long.parseLong(sc.next());
			Hope[i][2] = sc.next().equals("W")?-1:1;
		}
		sc.close();

		for(int i=0;i<n;i++) {
			//y: -1("W")ならば+kして黒と同じ扱いに
			long x = Hope[i][0];
			long y = Hope[i][2]==-1?Hope[i][1]+k:Hope[i][1];
			//(0,0)=(0+k*2,0+k*2)のため(x%(k*2),y%(k*2))
			map[(int)y%k2][(int)x%k2]++;
		}

		//二次元累積和
		for (int i = 1; i <= k*2; i++) {
		    for (int j = 1; j <= k*2; j++) {
		        _2Cum_sum[i][j] = _2Cum_sum[i-1][j] + _2Cum_sum[i][j-1]  + map[i - 1][j - 1] -_2Cum_sum[i - 1][j - 1];
		    }
		}

        int max = 0;
        for (int i = 0; i < k2; i++) {
            for (int j = 0; j < k2; j++) {
                int y0 = k2, x0 = k2;
                int y1 = Math.min(i + k, k2), x1 = Math.min(j + k, k2);
                int y2 = i, x2 = j;
                int y3 = Math.max(i - k, 0), x3 = Math.max(j - k, 0);
                int y4 = 0, x4 = 0;

                int sum = _2Cum_sum_sum(y1, y0, x1, x0)+ _2Cum_sum_sum(y1, y0, x3, x2)+ _2Cum_sum_sum(y2, y1, x2, x1)
                          + _2Cum_sum_sum(y2, y1, x4, x3)+ _2Cum_sum_sum(y3, y2, x3, x2)+ _2Cum_sum_sum(y3, y2, x1, x0)
                          + _2Cum_sum_sum(y4, y3, x4, x3)+ _2Cum_sum_sum(y4, y3, x2, x1);

                max = Math.max(sum, max);
            }
        }
        System.out.println(max);

	}
    private static int _2Cum_sum_sum(int ya, int yb, int xa, int xb) {
        return _2Cum_sum[ya][xa] + _2Cum_sum[yb][xb] - _2Cum_sum[yb][xa] - _2Cum_sum[ya][xb];
    }

}

Measured memory_bytes: 111836
#include <stdio.h>

int main(void)
{
	float a, b, i;
	
	
	while (scanf("%f %f",&a ,&b) != EOF){
		if (35.50 > a && 71.00 > b){
			printf("AAA\n");
		}
		else if (37.50 > a && 77.00 > b){
			printf("AA\n");
		}
		else if (40.00 > a && 83.00 > b){
			printf("A\n");
		}
		else if (43.00 > a && 89.00 > b){
			printf("B\n");
		}
		else if (50.00 > a && 105.0 > b){
			printf("C\n");
		}
		else if (55.00 > a && 116.0 > b){
			printf("D\n");
		}
		else if (70.00 > a && 148.0 > b){
			printf("E\n");
		}
		else {
			printf("NA\n");
	}
	}
	
	return (0);
}

Measured memory_bytes: 604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        String answer = "";
        if (B <= A) {
            answer = "delicious";
        } else if (B - A <= X) {
            answer = "safe";
        } else {
            answer = "dangerous";
        }
        System.out.println(answer);
    }
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    p.resize(n, -1);
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return ;
    if (r[a] > r[b]) {
      p[a] += p[b];
      p[b] = a;
    } else {
      p[b] += p[a];
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (p[a] < 0) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return -p[find(n)];
  }
private:
  vector<int> r, p;
};

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

  lli n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> v(m);
    cin >> v;
    reverse(v.begin(), v.end());

    UnionFind uf(n + 1);

    vector<lli> u;
    lli x = (n - 1) * n / 2;
    each (e, v) {
      u.push_back(x);
      if (uf.same(e.first, e.second)) {
        continue;
      }

      x += (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
      x += (uf.size(e.second) - 1LL) * uf.size(e.second) / 2;

      uf.unite(e.first, e.second);

      x -= (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
    }
    reverse(u.begin(), u.end());
    each (i, u) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int n;
inline void CountingSort(vi a, vi &b, int k) {
	vi c(k + 1, 0);
	rep(i, 0, n) {
		++c[a[i]];
	}
	rep(i, 1, k + 1) {
		c[i] += c[i - 1];
	}
	rrep(i, n - 1, -1) {
		b[c[a[i]] - 1] = a[i];
		--c[a[i]];
	}
}
int main() {
	cin >> n;
	vi a(n); rep(i, 0, n) cin >> a[i];
	vi b(n);
	CountingSort(a, b, *max_element(all(a)));
	rep(i, 0, n) {
		cout << b[i] << (i + 1 == n ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 26344
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <stdio.h>
#include <assert.h>
#include <queue>

using namespace std;
using namespace std::chrono;

void solve()
{
	char x;
	cin >> x;
	if ('a' <= x && x <= 'z')
	{
		cout << 'a';
	}
	else
	{
		cout << 'A';
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();
	
	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    sum = sum+a.at(i);
  }
  int c=0;
  if((sum%10)==0){
    sort(a.begin(), a.end());
    for(int i=0;i<n;i++){
      if((sum-a.at(i))%10!=0){
        sum=sum-a.at(i);
        break;
      }
      else if(i==n-1)
        sum=0;
    }
  }
    cout << sum << endl;
  
}



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

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        int length = inputs.Length;
        var dic = new Dictionary<long, long>();

        // 値と個数を連想配列にする
        for(int i = 0; i < length; i++)
        {
            if (dic.ContainsKey(inputs[i])) dic[inputs[i]]++;
            else dic[inputs[i]] = 1;
        }

        long all = 0;
        foreach (var item in dic)
        {
            var count = item.Value;                     //個数
            all += nCk(count, 2);
        }
        
        for (int k = 0; k < length; k++)
        {
            var result = all - (dic[inputs[k]] - 1);    // 取り除くk番目とのありえた組み合わせを除く
            Console.WriteLine(result);
        }
    }

    public static long nCk(long n, long k)
    {
        if (n < k) return 0;
        if (n == k) return 1;

        long x = 1;
        for (long i = 0; i < k; i++)
        {
            x = x * (n - i) / (i + 1);
        }

        return x;
    }
}

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


    long long i;string a;long long account=0;long long wacount=0;
    long long tlecount=0;long long racount=0;long long n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        if (a=="AC")
        {
            account=account+1;
        }
        else if (a=="WA")
        {
            wacount=wacount+1;
        }
        else if (a=="TLE")
        {
            tlecount=tlecount+1;
        }
        else
        {
            racount=racount+1;
        }
    }
    cout<<"AC x "<<account<<endl;
    cout<<"WA x "<<wacount<<endl;
    cout<<"TLE x "<<tlecount<<endl;
    cout<<"RE x "<<racount<<endl;



}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));
  int x;
  for (int i = 0; i < h; i++) {
    x = 1;
    for (int j = 0; j < w; j++) {
      cin >> grid.at(i).at(j);
      if (grid.at(i).at(j) == '#') x = 0;
    }
    if (x == 1) {
      grid.pop_back();
      i--;
      h--;
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (grid.at(j).at(i) == '#') break;
      if (j == h - 1) {
        for (int k = 0; k < h; k++)
          grid.at(k).erase(grid.at(k).begin() + i);
        w--;
        i--;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cout << grid.at(i).at(j);
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
	int i;
	long long ans = 0;

	scanf("%d", &n);

	for(i=1; i<=n; i++){
		if(i % 3 != 0 && i % 5 != 0){
			ans += (long long)i;
		}
	}

	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

typedef vector<int> vi;
typedef pair<int,int> P;
const int MN=100000;
vector<int> G[MN];
int ord[MN];
bool inS[MN];
stack<int> roots,S;
vector<vi> cc;
vector<P> bs;
int cnt;
/*
int cmp[MN];
vector<int> cG[MN];
*/
void vis(int v,int p){
	ord[v]=++cnt;
	S.push(v);
	inS[v]=true;
	roots.push(v);
	for(int u:G[v]){
		if(ord[u]==0){
			vis(u,v);
		}else if(u!=p&&inS[u]){
			while(ord[roots.top()]>ord[u]) roots.pop();
		}
	}
	if(v==roots.top()){
		bs.pb(P(p,v));
		vector<int> vc;
		while(true){
			int w=S.top();S.pop();
			inS[w]=false;
			vc.pb(w);
//			cmp[w]=cc.size();
			if(v==w) break;
		}
		roots.pop();
		cc.pb(vc);
	}
}
void bridge(int N){
	rep(i,N) if(ord[i]==0){
		vis(i,-1);
		bs.pop_back();	//P(-1,hoge)
	}
/*	for(P p:bs){
		int x=cmp[p.fs],y=cmp[p.sc];
		cG[x].pb(y),cG[y].pb(x);
	}*/
}

int main(){
	int N,M;
	cin>>N>>M;
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	bridge(N);
	cout<<bs.size()<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

const int pm = 100000;
bool prime[pm];

int main() {
	fill(prime, prime + pm, true);
	prime[0] = prime[1] = false;
	for(int i = 2; i * i <= pm; i++)
		if(prime[i])
			for(int j = 2 * i; j <= pm; j += i)
				prime[j] = false;
	for(int n; cin >> n;) {
		int more, less;
		for(int i = n - 1; i >= 0; i--) {
			if(prime[i]) {
				less = i;
				break;
			}
		}
		for(int i = n + 1; i <= pm; i++) {
			if(prime[i]) {
				more = i;
				break;
			}
		}
		cout << less << " " << more << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
int main(){
	int n;
	scanf("%d",&n);
	bool a[60000]={};
	for(int i=0;i<60000;i++){
		a[i]=true;
	}
	a[0]=false;
	a[1]=false;
	for(int i=2;i<60000;i++){
		if(a[i]){
			for(int j=2*i;j<60000;j+=i){
				a[j]=false;
			}
		}
	}
	int u=0;
	for(int i=6;i<60000;i+=5){
		if((u==n-1) && a[i]){
			printf("%d\n",i);
			break;
		}
		if((u<n-1) && a[i]){
			printf("%d ",i);
			u++;
		}
	}
	n=0;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 4e6 + 7;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const int mod = 1e9 + 7;

const int nx[4] = {1, -1, 0, 0};
const int ny[4] = {0, 0, 1, -1};

int n;
int a[N];

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    cin >> n;
    n += n;
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    }
    sort(a, a + n);
    vector<int> v;
    int ans = 0;
    for (int i = 0, j; i < n; ) {
    	for (j = i; j < n && a[i] == a[j]; j++);
    	if ((j - i) % 2) v.pb(a[i]);
    	ans += ((j - i) / 2) * a[i];
    	i = j;
    }
    for (int i = 0; i < sz(v); i += 2) {
    	ans += v[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main() {
    char inp[4];
    cin >> inp;
    int a,b,c,d;
    a = inp[0] - '0';
    b = inp[1] - '0';
    c = inp[2] - '0';
    d = inp[3] - '0';
    for(int i = 0; i < 2; i++ ) {
        for(int j = 0; j < 2; j++) {
            for(int k = 0; k < 2; k++) {
                int sum = a;
                char ans[3];
                if(i == 0) {
                    sum += b;
                    ans[0] = '+';
                } else {
                    sum -= b;
                    ans[0] = '-';
                }
                if(j == 0) {
                    sum += c;
                    ans[1] = '+';
                } else {
                    sum -= c;
                    ans[1] = '-';
                }
                if(k == 0) {
                    sum += d;
                    ans[2] = '+';
                } else {
                    sum -= d;
                    ans[2] = '-';
                }
                if(sum == 7) {
                    cout << a << ans[0] << b << ans[1] << c << ans[2] << d << "=7";
                    i = 100;
                    j = 100;
                    k = 100;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>

int main()
{
	int n,a;
	scanf("%d%d",&n,&a);
	int k = n % 500;
	if(k <= a) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

bool func(pair< string, int > a, pair< string, int > b){
	return a.second > b.second;
}

int main(){
	
	int n, w, l, d, c = 0;
	string country;
	vector< pair< string, int > > v;
	
	while(cin >> n, n){
		v.clear();
		
		for(int i = 0; i < n; ++i){
			cin >> country >> w >> l >> d;
			v.push_back(pair< string, int >(country, w * 3 + d));
		}
		
		sort(v.begin(), v.end(), func);
		
		
		if(c != 0) cout << endl;
		++c;
		
		for(vector< pair< string, int > >::iterator it = v.begin(); it != v.end(); ++it){
			cout << (it->first) << "," << (it->second) << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1220
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    rep(i, s.length()-1) {
        if(s[i] != s[i+1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int p[100000];
int root(int x){
	if(p[x] < 0) return x;
	return p[x] = root(p[x]);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m, l; cin >> n >> m >> l;
	rep(i, n) p[i] = -1;
	vi cnt(n);
	vector<pi> f;
	rep(i, m){
		int a, b; cin >> a >> b;
		f.emplace_back(--a, --b);
		a = root(a);
		b = root(b);
		if(a != b){
			p[a] += p[b];
			p[b] = a;
		}
	}
	for(pi i : f){
		if(root(i.first) == root(i.second)){
			cnt[i.first]++;
			cnt[i.second]++;
		}
	}
	rep(i, l){
		int a, b; cin >> a >> b;
		if(root(--a) == root(--b)){
			cnt[a]++;
			cnt[b]++;
		}
	}
	
	rep(i, n) cout << -p[root(i)] - cnt[i] - 1 << (i == n - 1 ? "\n" : " ");
	
	return 0;
}

Measured memory_bytes: 3188
#pragma GCC target("popcnt")
#include <x86intrin.h>

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int f(int n) {
  if (n == 0) {
    return 1;
  }
  return f(n % _popcnt64(n)) + 1;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c = count(begin(s), end(s), '1');
  vector<int> mods{c + 1, c - 1};
  vector a(2, vector(n, 1));
  for (int t : {0, 1}) {
    for (int i = n - 1; i--; ) {
      a[t][i] = 2 * a[t][i + 1];
      if (a[t][i] >= mods[t]) {
        a[t][i] -= mods[t];
      }
    }
  }
  vector<int> base(2);
  for (int t : {0, 1}) {
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') continue;
      base[t] += a[t][i];
      if (base[t] >= mods[t]) {
        base[t] -= mods[t];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      int cur = base[0] + a[0][i];
      if (cur >= mods[0]) {
        cur -= mods[0];
      }
      cout << f(cur) << '\n';
    } else if (c == 1) {
      cout << "0\n";
    } else {
      int cur = base[1] - a[1][i];
      if (cur < 0) {
        cur += mods[1];
      }
      cout << f(cur) << '\n';
    }
  }
}


Measured memory_bytes: 5924
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  vector<int> h(n);
  for (int i = 0; i < n; ++i) scanf("%d", &h[i]);

  int dp[n];
  fill(dp, dp + n, INF);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i >= j) {
	dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
      }
    }
  }

  printf("%d\n", dp[n - 1]);
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>d(N);
  for(int i=0;i<N;i++)cin>>d[i];
  sort(rng(d));
  int f=d[N/2-1],s=d[N/2];
  cout<<s-f<<endl;
  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int w,h;
    cin >> w >> h;
    vector<string> c(h);
    int sy,sx,gy,gx;
    rep(i,0,h){
        cin >> c[i];
        rep(j,0,w){
            if(c[i][j]=='s'){
                sy=i;
                sx=j;
            }
            if(c[i][j]=='g'){
                gy=i;
                gx=j;
            }
        }
    }


    int dy[]={0,1,0,-1},dx[]={1,0,-1,0};
    vector<vector<int64_t>> a(h,vector<int64_t>(w,inf64)),b(h,vector<int64_t>(w,inf64));
    auto ok=[&](int y,int x){
        return 0<=y and y<h and 0<=x and x<w and (c[y][x]=='.' or c[y][x]=='s');
    };
    auto bfs=[&](int y0,int x0,int c){
        queue<tuple<int,int,int64_t>> que;
        que.push(make_tuple(y0,x0,0));
        while(!que.empty()){
            tuple<int,int,int> t=que.front();
            que.pop();
            int y=get<0>(t),x=get<1>(t);
            int64_t d=get<2>(t);
            if(c==0){
                if(a[y][x]<=d) continue;
                a[y][x]=d;
            }
            if(c==1){
                if(b[y][x]<=d) continue;
                b[y][x]=d;
            }
            rep(i,0,4){
                int ny=y+dy[i],nx=x+dx[i];
                if(!ok(ny,nx)) continue;
                que.push(make_tuple(ny,nx,d+1));
            }
        }
    };
    rep(i,0,h){
        rep(j,0,w){
            if(c[i][j]=='*') bfs(i,j,0);
            if(c[i][j]=='g') bfs(i,j,1);
        }
    }

    auto g=[&](long double e){
        long double sum=0;
        int count=0;
        rep(y,0,h){
            rep(x,0,w){
                if(c[y][x]=='#' or c[y][x]=='*' or c[y][x]=='g') continue;
                sum+=min(a[y][x]+e,(long double)b[y][x]);
                ++count;
            }
        }
        return sum/count;
    };

    long double lb=0,ub=inf64;
    rep(i,0,128){
        long double mid=(lb+ub)/2;
        if(mid<g(mid)) lb=mid;
        else ub=mid;
    }

    cout << min(a[sy][sx]+lb,(long double)b[sy][sx]) << endl;
 }

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
    return 0;
}

Measured memory_bytes: 7192
n = int(input())
li_a = list(map(int, input().split()))
dic_a = {}

for a in li_a:
    dic_a[a] = dic_a.get(a, 0) + 1

q = int(input())
li_bc = list()

for i in range(q):
    li_bc.append(tuple(map(int, input().split())))


answer = sum(li_a)
for l in li_bc:
    b = l[0]
    c = l[1]

    diff = (c - b) * dic_a.get(b, 0)
    if b in dic_a.keys():
        dic_a[c] = dic_a.get(c, 0) + dic_a.get(b, 0)
        dic_a[b] = 0
        answer += diff
    else:
        pass
    print(answer)


Measured memory_bytes: 30772
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n+1],i,h[n+1];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        h[a[i]]=i;
    }
    for(i=1;i<=n;i++)
        printf("%d ",h[i]);
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
int a,b,c,d;
int x,y,z;
int main()
{
	cin>>a>>b>>c>>d;
	x=abs(a-c);
	y=abs(a-b);
	z=abs(b-c);
	if (x<=d)
		cout<<"Yes";
	else
	{
		if (y<=d && z<=d)
			cout<<"Yes";
		else
			cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,K = map(int,input().split())
A = list(map(int,input().split()))

x = max(A)

mn = 0
mx = max(A)

while mx-mn > 1:
    suc = True
    cnt = 0
    for a in A:
        cnt += -((-a)//x) - 1
        if cnt > K:
            suc = False
            break
    if suc:
        mx = x
        x = (mn+mx)//2
    else:
        mn = x
        x = (mn+mx)//2

print(mx)




Measured memory_bytes: 91988
fun main(arr:Array<String>) {
    val (n,m,x) = readLine()!!.split(" ").map { it.toInt() }
    val ryokinsyo = readLine()!!.split(" ").map { it.toInt() }

    val to0 = ryokinsyo.filter { it < x }.size
    val toN = ryokinsyo.size - to0
    println(Math.min(to0, toN))
}

Measured memory_bytes: 37916
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, y, h, sum = 0;cin >> n;
	rep(i, n) {
		cin >> y >> h;
		sum += h - y + 1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

ll l[200001] = {};
ll r[200001] = {};
int main() {
	ll n; cin >> n;
	string s; cin >> s;

	ll b = 0;
	rep(i, 0, s.size()) {
		l[i] = b;
		if (s[i] == '#') b++;
	}

	l[s.size()] = b;

	ll w = 0;
	r[s.size()] = 0;
	rep_re(i, 0, s.size()) {
		if (s[i] == '.') w++;
		r[i] = w;
	}
	ll ans = INF;
	repe(i, 0, n) {
		ans = min(ans, l[i] + r[i]);
	}
	cout << ans << endl;

	return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
using namespace std;
int n;
int calc(int k)
{
	int sum=0;
	while(k>0)
	{
		sum+=k%10;
		k/=10;
	}
	return sum;
}
int main()
{
	scanf("%d",&n);
	if(n%calc(n)==0)printf("Yes");
	else printf("No");
}

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

int main()
{
    int N,M,r=0,B=0;
    cin>>N>>M;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        B+=A.at(i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    for(int i=0;i<N;i++){
        if(A.at(i)<(double)B/(4*M)){
            break;
        }
        r++;
    }
    if(r>=M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256