akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;


//int dp[105][4][2];

int main(void){
	string N;
	int K;
	cin >> N;
	cin >> K;
	int L = N.size();
	int dp[105][4][2];
	//dp[0][0][0] = 1;
	for(int i = 0; i < 105; ++i){
		for(int j = 0; j < 4; ++j){
			for(int k = 0; k < 2; ++k){
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	for(int i = 0; i < L; ++i){
		for(int j = 0;j < 4;++j){
			for(int k = 0;k < 2; ++k){
				int now = N[i] - '0';
				for(int l = 0; l < 10; ++l){
					int ni = i +1, nj = j, nk = k;
					if(l != 0){
						nj++;
					}
					if(nj > K){
						continue;
					}
					if(k == 0){
						if(l > now){
							continue;
						}
						if(l < now){
							nk = 1;
						}
					}
						dp[ni][nj][nk] += dp[i][j][k];
				}
			}
		}
	}
	int ans = dp[L][K][0] + dp[L][K][1];
	//cout << dp[L][K][0] << ' ' << dp[L][K][1] << endl;
	cout << ans << endl;
	return 0;
}



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

using namespace std;

int main()
{
   string s ;
   cin>>s;
   int i=0;
   int j,c=0;
   j= s.length()-1;
   while(j>i){
    if(s[i++]!= s[j--]){
        c++;
    }
   }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
c = [[0]*10 for _ in range(10)]

for i in range(1,N+1):
    a,b = str(i)[0], str(i)[-1]
    c[int(a)][int(b)] += 1

print(sum([c[i][j]*c[j][i] for i in range(10) for j in range(10)]))

Measured memory_bytes: 3064
Table = [1150, 125, 140, 160]

def getFee amount
  case amount
  when 0..10
    Table[0]
  when 11..20
    Table[0] + Table[1] * (amount - 10)
  when 21..30
    Table[0] + Table[1] * 10 + Table[2] * (amount - 20)
  else
    Table[0] + Table[1] * 10 + Table[2] * 10 + Table[3] * (amount - 30)
  end
end

while (n = $stdin.gets.to_i) != -1 do
  puts 4280 - getFee(n)
end

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

////////////////////////////////////////
// ポテンシャル付きUnion-Find木(未検証) //
////////////////////////////////////////

// 0-indexed
class UnionFindWithPotential {
private:
	std::vector<int> parent_, size_;
	std::vector<int64_t> potential_delta_;

	// indexの含まれる木の根のノード番号を返す
	int calcRoot(const int index)
	{
		int &parent{parent_[index]};
		if (parent == index) return index;

		const int root{calcRoot(parent)};
		potential_delta_[index] += potential_delta_[parent];
		parent = root;
		return parent;
	}
public:
	UnionFindWithPotential(const int size)
		:parent_(size), size_(size, 1), potential_delta_(size)
	{
		for (int i{}; i < size; i++) parent_[i] = i;
	}

	// index1とindex2の連結判定
	bool areConnected(const int index1, const int index2)
	{
		return calcRoot(index1) == calcRoot(index2);
	}

	// potential(index1) = potential(index2) + weightとなるよう結合
	bool unite(const int index1, const int index2, const int64_t weight)
	{
		const int root1{calcRoot(index1)}, root2{calcRoot(index2)};
		if (root1 == root2)
			return potential_delta_[index1] == potential_delta_[index2] + weight;
		if (size_[root1] <= size_[root2])
		{
			size_[root2] += size_[root1];
			potential_delta_[root1] = (potential_delta_[index2] + weight) - potential_delta_[index1];
			parent_[root1] = root2;
		}
		else
		{
			size_[root1] += size_[root2];
			potential_delta_[root2] = potential_delta_[index1] - (weight + potential_delta_[index2]);
			parent_[root2] = root1;
		}
		return true;
	}

	// indexが含まれる木の要素数を返す
	int calcSize(const int index)
	{
		return size_[calcRoot(index)];
	}

	// potential(index1) - potential(index2)を返す
	// 根が異なる場合はLLONG_MAXを返す
	int64_t calcDiff(const int index1, const int index2)
	{
		if (calcRoot(index1) != calcRoot(index2))
			return LLONG_MAX;
		return potential_delta_[index1] - potential_delta_[index2];
	}
};

bool solve()
{
	int N, M;
	scanf("%d%d", &N, &M);
	UnionFindWithPotential ufp(N);
	for (int i{}; i < M; i++)
	{
		int L, R;
		long long D;
		scanf("%d%d%lld", &L, &R, &D);
		L--; R--;
		if (!ufp.unite(R, L, D)) return false;
	}
	return true;
}

int main()
{
	if (solve()) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 1792
//ツ嘉ーツ法
//ツづつづィツ仰エツづ個妥渉嘉猟重ツつェツ渉ャツつウツつ「ツ督つゥツづァツ渉づゥ
main(){
	int n,m[25],w[25],i,j,W,ng;
	for(;scanf("%d",&n),n;){
		for(i=0;i<n;i++)
			scanf("%d%d",m+i,w+i);
		W=0;
		ng=0;
		for(i=0;i<999;i++){
			for(j=0;j<n;j++){
				if(w[j]==i){
					W+=m[j];
					if(W>i)
						ng=1;
				}
			}
		}
		puts(ng?"No":"Yes");
	}
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  vector<int> vec(A);
  
  for(int i=0;i<A;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int sum = 0;
  for(int i=0;i<A-1;i++){
    sum += vec.at(i);
  }
  if(vec.at(A-1)<sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
K = int(input())
A, B = map(int, input().split())

A_bai = int(A/K)
B_bai = int(B/K)

if A_bai != B_bai:
  print("OK")
elif (A%K == 0) or (B%K == 0):
  print("OK")
else:
  print("NG")


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  for (int i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++)
    {
      int buf;
      cin >> buf;
      a[i].push_back(buf);
    }
  }

  vector<int> tmp(m, 0);
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < a[i].size(); j++)
    {
      tmp[a[i][j] - 1]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < m; i++)
  {
    if (tmp[i] == n)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

//alias
using LL  = long long;
using VI  = std::vector<int>;
using VII = std::vector< std::vector<int> >;
using VL  = std::vector<long>;
using VL2 = std::vector<long long>;
using VL2L2 = std::vector< VL2 >;
using PII = std::pair<int,int>;

bool debug = true;

int N, A;
VI x;

int main(void){
    OPT;
    std::cin >> N >> A;
    x.resize(N);
    REP(i,N){
        std::cin >> x[i];
    }

    std::vector< VL2L2 > dp(N+1, VL2L2(N+1, VL2(N*A + 10, 0)));
    dp[0][0][0] = 1;
    REP(i,N){
        REP(j,N){
            REP(k, N*A){
                if( k+x[i] <= N*A ){
                    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                }
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }

    LL ans = 0;
    FOR(i, 1, N+1){
        ans += dp[N][i][i*A];
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 52352
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

vector<VB> a(12, VB(12));
vector<VB> visited(12, VB(12));
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

void dfs(int x, int y) {
	if (x < 0 || y < 0 || x >= 12 || y >= 12 || !a[y][x] || visited[y][x])return;
	visited[y][x] = true;
	rep(i, 4)dfs(x + dx[i], y + dy[i]);
}

int main() {
	string t;
	while (cin >> t) {
		rep(i, 12)rep(j, 12)a[i][j] = false;
		rep(i, 12)rep(j, 12)visited[i][j] = false;
		VS s(12); s[0] = t;
		rep(i, 11)cin >> s[i + 1];
		rep(i, 12)rep(j, 12) {
			if (s[i][j] == '1')a[i][j] = true;
			else a[i][j] = false;
		}

		int ans = 0;
		rep(i, 12) {
			rep(j, 12) {
				if (a[i][j] && !visited[i][j]) { ans++; dfs(j, i); }
			}
		}
		Cout(ans);
	}
}


Measured memory_bytes: 3148
#include <iostream>
using namespace std;
int main(){
  int h, w, i, j;
  cin >> h >> w;
  char a[h][w];
  for(i=0;i<h; i++)
    for(j=0; j<w; j++)
      cin >> a[i][j];
  
  for(i=0; i<h; i++){
    int flag=0;
    for(j=0; j<w; j++){
      if(a[i][j]=='.') flag++;
    }
    if(flag==w){
       for(j=0; j<w; j++){
	 a[i][j]=0;
       }}
  }

  for(j=0; j<w;j++){
    int flag=0;
    for(i=0; i<h; i++){
      if(a[i][j]=='.'||a[i][j]==0) flag++;
    }
    if(flag==h){
      for(i=0;i<h; i++){
	a[i][j]=0;
      }}
  }
  

  for(i=0; i<h; i++){int flag=0;
    for(j=0;j<w;j++){
      if(a[i][j]!=0){cout << a[i][j];
	flag++;
      }
    }if(flag!=0)cout << endl;
  }
      
  return 0;
}

Measured memory_bytes: 256
Q=int(input())
A=[0]
S=[0]*(10**5+1)
import math

def is_prime(n):
  if n == 1: return False

  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False

  return True

def id2017(n):
  if is_prime(n) and is_prime((n+1)/2):
    return True
  else:
    False
count=0    
for i in range(1,10**5+1):
  if id2017(i) and i%2==1:
    count+=1
  S[i]=count
for i in range(Q):
  l,r=map(int, input().split())
  print(S[r]-S[l-1])

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    q *= 4;
    h *= 2;
    cout << n / 2 * min(min(q * 2,h * 2),min(s * 2,d)) + n % 2 * min({q,h,s}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    string s;
    s = "NG";
    for (int i=a; i <= b ;i++){
        if(i % k == 0){
            s = "OK";
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long int
#define hell (int)(1e9+7)
#define inf 1000000000000

using namespace std;

void solve(){
    int h,n;
    cin>>h>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=accumulate(begin(a),end(a),(int)0);
    if(ans>=h)
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll n,l,ans=0;
struct node
{
	node *child[2];
	bool isend;
	int depth;
};
node *getnode(int d)
{
	node *temp=new node;
	temp->depth=d;
	temp->isend=false;
	temp->child[0]=NULL;
	temp->child[1]=NULL;
	return temp;
}
void insert(string &s,int idx,node *curr)
{
	if(idx==(int)s.length())
	{
		curr->isend=true;
		return ;	
	} 
	if(!curr->child[0]) curr->child[0]=getnode(curr->depth+1);
	if(!curr->child[1]) curr->child[1]=getnode(curr->depth+1);
	int ch=s[idx]-'0';
	insert(s,idx+1,curr->child[ch]);
} 
void dfs(node *curr)
{
	int h=l-curr->depth + 1;
	if(!curr->child[0] && !curr->child[1]) 
	{
		if(curr->isend) return;
		ll div=1;
		for(ll i=1;i<(1e18+5);i<<=1)
		{
			if((h%i)==0) div=i;
		}
		ans^=div;
		return;
	}
	dfs(curr->child[0]);
	dfs(curr->child[1]);
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	cin>>n>>l;
	node *root=getnode(0);
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin>>s;
		insert(s,0,root);
	}
	dfs(root);
	if(ans) cout<<"Alice\n";
	else cout<<"Bob\n";
	return 0;
}

Measured memory_bytes: 7276
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	string s;
	cin >> s;
	int ans = 0;
	bool flag = true;
	for (int i = 1; i < s.length(); i++) {
		if (s[i] - '0' != 9)flag = false;
		ans += 9;
	}
	
	if (flag) pr(ans + (s[0] - '0'));
	else pr(ans + (s[0] - '1'));

	//system("pause");
	return 0;
}

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

int main()
{
  int r,g,b;
  cin >> r>>g>>b;

  int num = r*100+g*10+b;

  if(num%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int N, M, K;
  cin >> N >> M >> K;

  vector<int> A(N), B(M);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < M; i++)
    cin >> B[i];

  int b_books = 0;
  ll sum = 0;
  for (int i = 0; i < M; i++) {
    if (sum + B[i] > K)
      break;
    sum += B[i];
    b_books = i + 1;
  }

  int res = b_books;
  int a_books = 0;
  for (int i = 0; i < N; i++) {
    if (sum + A[i] <= K)
      sum += A[i];
    else {
      while (b_books && sum + A[i] > K) {
        sum -= B[b_books - 1];
        b_books--;
        if (b_books == 0)
          break;
      }
      if (sum + A[i] > K)
        break;
      sum += A[i];
    }
    a_books = i + 1;
    res = max(res, a_books + b_books);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  if(min(n,m)>=2){
    cout << (n-2)*(m-2) << endl;
  }
  else if(n*m==1){
    cout << 1 << endl;
  }
  else{
    cout << max(n,m)-2 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String s = br.readLine();

			int num = Integer.parseInt(s);

			long ans = (long)num * num * num ;

			System.out.println(ans);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
}

Measured memory_bytes: 24232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

const ll MOD = 1000000007;

int main(){

    ll N, K;
    cin >> N >> K;
    set<ll>S;
    for(ll i = 1; i * i <= N; i++){
        S.insert(i);
        S.insert(N / i);
    }
    vector<ll>v;
    for(set<ll>::iterator it = S.begin(); it != S.end(); it++)v.push_back(*it);
    ll V = v.size();
    for(ll i = V - 1; i > 0; i--)v[i] -= v[i - 1];
    for(ll i = 0; i < V; i++)v[i] %= MOD;
    vector<vector<ll> >dp(K + 2, vector<ll>(V, 0));
    dp[0][0] = 1;
    for(ll i = 1; i <= K + 1; i++){
        for(ll j = V - 1; j >= 0; j--){
            ll k = V - j - 1;
            dp[i][j] = (dp[i][j] + dp[i - 1][k]) % MOD;
        }
        for(ll j = V - 1 - 1; j >= 0; j--){
            dp[i][j] = (dp[i][j] + dp[i][j + 1]) % MOD;
        }
        for(ll j = 0; j < V; j++){
            dp[i][j] = (dp[i][j] * v[j]) % MOD;
        }
    }
    cout << dp[K + 1][0] << endl;
    return 0;
}

Measured memory_bytes: 54908
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CABlandYard solver = new CABlandYard();
        solver.solve(1, in, out);
        out.close();
    }

    static class CABlandYard {
        List<Integer>[] graph;
        char[] s;

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            s = in.next().toCharArray();
            graph = Utils.listArray(n);

            int[][] count = new int[n][2];
            for (int i = 0; i < m; i++) {
                int from = in.nextInt() - 1, to = in.nextInt() - 1;
                graph[from].add(to);
                graph[to].add(from);
                count[from][s[to] - 'A']++;
                count[to][s[from] - 'A']++;
            }

            int[] q = new int[n];
            int head = 0, tail = 0;
            boolean[] bad = new boolean[n];
            for (int i = 0; i < n; i++) {
                if (count[i][0] == 0 || count[i][1] == 0) {
                    bad[i] = true;
                    q[tail++] = i;
                }
            }
            while (head < tail) {
                int cur = q[head++];
                for (int j : graph[cur]) {
                    count[j][s[cur] - 'A']--;
                    if (count[j][s[cur] - 'A'] == 0 && !bad[j]) {
                        bad[j] = true;
                        q[tail++] = j;
                    }
                }
            }


            out.println(head < n ? "Yes" : "No");
        }

    }

    static class Utils {
        public static <T> List<T>[] listArray(int size) {
            List<T>[] result = new List[size];
            for (int i = 0; i < size; i++) {
                result[i] = new ArrayList<>();
            }
            return result;
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



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

int main(){
  int N; cin >> N;
  bool even=true;
  int a;
  for(int i=0; i<N; i++){
    cin >> a;
    if(a%2==1){
      even=false;
      break;
    }
  }
  cout << ((even)?"second":"first") << endl;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

   ll sum=0;
   for(int k=1; k<=n;){
      int a=n/k;
      int nxtk=n/a+1;
      int m=nxtk-k;
      sum+=(ll)a*(a+1)*m*((ll)2*k+m-1)/4;

      k=nxtk;
   }

   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll X;
	cin >> X;
	ll num = 100;
	int cnt = 0;
	while (num < X) {
		num = num + num * 0.01;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int ans = 0;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    F0R(i,n) {
        int x; cin >> x;
        if (x&1) ans ^= 1;
    }
    if (ans == 0) cout << "YES";
    else cout << "NO";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define MOD                 1000000007LL
#define EPS                 1e-9
#define io                  ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAXN = 1e5+5;

int main(){
	io;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int sum1 = a+b, sum2 = c+d;
	if(sum1 > sum2)
		cout << "Left" << endl;
	else if(sum1 == sum2)
		cout << "Balanced" << endl;
	else
		cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
h = readl()
h.sort()
left = h[n // 2 - 1]
right = h[n // 2]
print(right - left)

Measured memory_bytes: 16412
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define erep(i, n) for (ll i = 1; i <= (n); i++)
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  int ans = 1e9;
  for (int bit = 0; bit < (1 << n); bit++) {
    int monny = 0;
    vector<int> rikaido(m);
    rep(i, n) {
      if (bit & (1 << i)) {
        monny += c[i];
        rep(j, m) rikaido[j] += a[i][j];
      }
    }
    bool yoshi = true;
    rep(i, m) if (rikaido[i] < x) yoshi = false;
    if (yoshi) mins(ans, monny);
  }
  if (ans != 1e9)
    cout << ans << '\n';
  else
    cout << -1 << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

int N;

vector<long long int>T;

int main()
{
	cin >> N;
	T = vector<long long int>(N);
	for (int i = 0; i < N; i++) cin >> T[i];
	
	long long int ans;
	
	ans = T[0];
	for (long long int n : T){
		long long int buf1, buf2;
		
		buf1 = (ans > n) ? ans : n;
		buf2 = (ans < n) ? ans : n;
		
		while (buf1 % buf2 != 0){
			long long int buf3;
			
			buf3 = buf1 % buf2;
			buf1 = buf2;
			buf2 = buf3;
		}
		buf1 = n;
		
		ans *= (buf1 / buf2);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    com_init();
    ll N,M,K; cin >> N >> M >> K;
    mint ans = 0;
    FOR(i,1,N+1){
        ans += M*M*((i-1)*i/2 + (N-i)*(N-i+1)/2);
    }
    FOR(i,1,M+1){
        ans += N*N*((i-1)*i/2 + (M-i)*(M-i+1)/2);
    }
    ans *= com(N*M-2,K-2);
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
class Graph{

public:
  vector<vector<int>> graphs;
  vector<bool> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS
  vector<ll> ct;

  Graph(int n){
    graphs.resize(n);
    init(n);
  }
  ~Graph(){}

  void addedge(int u, int v){
    u--; v--;
    graphs[u].push_back(v);
    graphs[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.resize(n, false);
    dist.resize(n, -1);
    ct.resize(n, 0);
  }

  void reset(){
    rep(i,check.size()){
      check[i]=false;
      dist[i]=-1;
    }
  }

  void dfs(int v)
  {
    check[v] = true;

    for(auto next_v : graphs[v]){
      if(check[next_v]) continue;
      ct[next_v] += ct[v];
      dfs(next_v);
    }
  }

  void bfs(int v)//----------------------
  {
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graphs[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }//-----------------------
};

int main(void) {
  int n, q;
  cin >> n >> q;
  Graph g(n);
  g.addedge_cin(n-1);

  rep(i,q){
    int p, x;
    cin >> p >> x;
    p--;
    g.ct[p] += x;
  }

  g.dfs(0);

  prtall(g.ct);
}


Measured memory_bytes: 22016
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();
		
		int A12 = Math.abs(A1 - A2);
		int A13 = Math.abs(A1 - A3);
		int A23 = Math.abs(A2 - A3);
		int cost = Math.min(Math.min(A12 + A23, A13 + A23), A12 + A13);
		System.out.println(cost);
	}
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main(void){
    int a, b, k, count, i;

    cin >> a >> b >> k;

    count = 0;
    i = 101;
    while(count != k){
        i--;
        if(a%i == 0 && b%i == 0){  
            count++;
        }
    }

    cout << i << endl;

    return 0;
}

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

  for (int i = 0; i < N; i++) {
    cin >> a;
    S.insert(a);
  }
  cout << S.size() << endl;

  
}

Measured memory_bytes: 19252
// Membership Management
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1305

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<set>
#include<sstream>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct Group {
    string name;
    bool checked;
    vector<string> members;
    Group(): name(""), checked(false) {}
    Group(string _name): name(_name), checked(false) {}
    
    void join(string member) { members.push_back(member); }
    bool is_member() { return members.size() == 0; }

    bool operator<(const Group &g) const {
        return name < g.name;
    }
};

map<string, Group> groups;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            elems.push_back(item);
        } 
    }
    return elems;
}

int dfs(string name) {
    if (groups[name].checked) return 0;
    groups[name].checked = true;

    if (groups[name].is_member()) return 1; 
    
    int visit_total = 0;
    for (string member : groups[name].members) {
        visit_total += dfs(member);
    }
    return visit_total;
}

int main() {
    int N;    
    while (cin >> N) {
        if (N == 0) break;
       
        string first_group = "";
        groups.clear();
        for (int nth = 0; nth < N; ++nth) {
            string line;
            cin >> line;
            vector<string> devide = split(line, ':');
            Group group = Group(devide[0]);
            if (nth == 0) first_group = devide[0];

            devide[1].erase(--devide[1].end());
            vector<string> members = split(devide[1], ',');
            for (string member : members) {
                group.join(member);
            }

            groups[group.name] = group;
        }

        cout << dfs(first_group) << endl;
    }
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N;
    int count = 0;
    cin >> N;
    vector<pair<int, int>> range;
    range.resize(N);
    for (int i = 0; i < N; i++){
        int x, l;
        cin >> x >> l;
        range[i] = make_pair(x - l, x + l);
    }
    sort(range.begin(), range.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
        return a.second < b.second;
    });

    int end = range[0].second;
    count++;
    for (int i = 1; i < range.size(); i++){
        if(range[i].first >= end){
            count++;
            end = range[i].second;
        }
    }
    cout << count << endl;
    return 0;
}       

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
vector<int> A;
int cnt1;
map<int, int> mp;

bool can_div[1010101];
bool used[1010101];

void check_can_div() {
  rep(i, 0, 1010100) { can_div[i] = false; }

  for (auto e : A) {
    if (!can_div[e] && !used[e]) {
      used[e] = true;
      for (int i = 2 * e; i <= 1010000; i += e) {
        can_div[i] = true;
      }
    }
  }
}

int main() {
  //
  cin >> N;
  rep(i, 0, N) {
    int a;
    cin >> a;
    A.push_back(a);
    mp[a]++;
    if (a == 1) {
      cnt1++;
    }
  }

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

  check_can_div();

  int ans = 0;
  for (auto e : A) {
    if (!can_div[e]) {
      if (mp[e] == 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 14540
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    init();
    int n = sc.nextInt();
    String x = sc.next();
    char[] xc = x.toCharArray();
    int baseCount = 0;
    for (int j = 0, len = x.length(); j < len; j++) {
      if (xc[j] == '1') {
        baseCount++;
      }
    }
    BigInteger xB = new BigInteger(x, 2);
    BigInteger count1 = BigInteger.valueOf(baseCount - 1);
    BigInteger count2 = BigInteger.valueOf(baseCount + 1);
    BigInteger rem1 = count1.compareTo(BigInteger.ZERO) == 0 ? BigInteger.ZERO : xB.remainder(count1);
    BigInteger rem2 = xB.remainder(count2);
    initMod(n, count1, count2);
    for (int i = 1; i <= n; i++) {
      char tmp = xc[i - 1];
      BigInteger count = tmp == '1' ? count1 : count2;
      BigInteger r = tmp == '1' ? rem1 : rem2;
      if (count.compareTo(BigInteger.ZERO) == 0) {
        System.out.println(0);
        continue;
      }
      BigInteger rem;
      if (tmp == '1') {
        rem = modMap1.get(n - i).negate().add(count1);
      } else {
        rem = modMap2.get(n - i);
      }
      System.out.println(map.get(
          rem.add(r).remainder(count).intValue()
      ) + 1);
    }
  }

  private static Map<Integer, Integer> map = new HashMap<>();
  private static void init() {
    int limit = 200000;
    map.put(0, 0);
    map.put(1, 1);
    for (int i = 2; i <= limit; i++) {
      String b = Integer.toString(i, 2);
      int count = 0;
      for (int j = 0, len = b.length(); j < len; j++) {
        if (b.charAt(j) == '1') {
          count++;
        }
      }
      int t = map.get(i % count);
      map.put(i, t + 1);
    }
  }

  private static final BigInteger TWO = BigInteger.ONE.add(BigInteger.ONE);
  private static Map<Integer, BigInteger> modMap1 = new HashMap<>();
  private static Map<Integer, BigInteger> modMap2 = new HashMap<>();
  private static void initMod(int n, BigInteger count1, BigInteger count2) {
    BigInteger i1 = BigInteger.ONE;
    BigInteger i2 = BigInteger.ONE;
    for (int i = 0; i <= n; i++) {
      modMap1.put(i, i1);
      modMap2.put(i, i2);
      i1 = count1.compareTo(BigInteger.ZERO) == 0 ? BigInteger.ZERO : i1.multiply(TWO).remainder(count1);
      i2 = i2.multiply(TWO).remainder(count2);
    }
  }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());

	int thre = n / 2;
	cout << d[thre] - d[thre - 1] << endl;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> p;
const Int INF = 1e18;

struct edge{Int to, t;};

Int N, M, S;

// 頂点vで銀貨c枚持っている状態を頂点 v*2501+c とする 
vector<vector<edge>> G(51*2501);
vector<Int> dist(51*2501, INF);

void dijkstra(int s){
    // first:最短距離 second:頂点番号
    priority_queue<p, vector<p>, greater<p>> q;
    dist[s] = 0;
    q.push(p(0, s));

    while (!q.empty()){
        int cur_d = q.top().first;
        int cur_v = q.top().second;
        q.pop();

        if (cur_d > dist[cur_v]) continue;

        for (int i = 0; i < G[cur_v].size(); i++){
            edge e = G[cur_v][i];
            if (dist[cur_v] + e.t < dist[e.to]){
                dist[e.to] = dist[cur_v] + e.t;
                q.push(p(dist[e.to], e.to));
            }
        }
    }
}


int main(){
    cin >> N >> M >> S;
    if(S > 2500) S = 2500;

    rep(i,M){
        int u, v; Int a, b;
        cin >> u >> v >> a >> b;
        u--; v--;

        for(int j=a; j<=2500; j++){
            G[u*2501+j].push_back(edge{v*2501+(j-a),b});
            G[v*2501+j].push_back(edge{u*2501+(j-a),b});
        }
    }

    
    rep(i,N){
        Int c, d; cin >> c >> d;
        rep(j,2500){
            G[i*2501+j].push_back(edge{i*2501 + min(j+c, (Int)2500),d});
        }
    }

    dijkstra(S);

    rep1(i,N-1){
        Int ans = INF;
        rep(j,2501){
            ans = min(ans, dist[i*2501+j]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 23792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int n, t, x, y;
int main() {
	cin >> n;
	while(n--)
	{
		cin >> t >> x >> y;
		if(t < x + y)
		{
			puts("No");
			return 0;
		}
		if((x + y) % 2 == 0 && t % 2 == 1)
		{
			puts("No");
			return 0;
		}
		if((x + y) % 2 == 1 && t % 2 == 0)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<Pii> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i].first;
        a[i].second = i+1;
    }

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

    for(int i=0;i<n;++i) {
        cout << a[i].second << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    println!(
        "{}",
        s.char_indices()
            .filter(|&(i, _)| i % 2 == 0)
            .map(|(_, c)| c)
            .collect::<String>()
    );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
long ncr(int n,int r){
    long ans = 1;
    int rr = 2;
    for(int i=n-r+1;i<=n;i++){
        ans *= i;
        while(rr <= r && ans % rr == 0){
            ans /= rr;
            rr++;
        }
    }
    return ans;
}



int main(){
    int n,p;
    cin >> n >> p;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    int odd = 0;
    int even = 0;
    for(int i=0;i<n;i++){
        if(a[i] %2 == 0)even++;
        else odd++;
    }
    long oddSum = 0;
    long evenSum = 0;
    if(p==0){
        for(int i=0;i<=even;i++){
            evenSum += ncr(even,i);
        }
        for(int i=0;i<=odd;i+=2){
            oddSum += ncr(odd,i);
        }
    }else{
        for(int i=0;i<=even;i++){
            evenSum += ncr(even,i);
        }
        for(int i=1;i<=odd;i+=2){
            oddSum += ncr(odd,i);
        }
    }
    cout << oddSum * evenSum << endl;
}


Measured memory_bytes: 256
a,b,c,d = map(int, input().split())


maxa=a*c
ans2=a*d
if maxa<ans2:
    maxa=ans2
ans3=b*c
if maxa<ans3:
    maxa=ans3
ans4=b*d
if maxa<ans4:
    maxa=ans4
print(maxa)


Measured memory_bytes: 61636
/*input
10 1000000000000000000
0 0 1 1 0 0 0 1 1 0
0 0 0 0 0 1 1 1 0 0
0 1 0 0 0 1 0 1 0 1
1 1 1 0 1 1 0 1 1 0
0 1 1 1 0 1 0 1 1 1
0 0 0 1 0 0 1 0 1 0
0 0 0 1 1 0 0 1 0 1
1 0 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
1 0 1 1 1 0 1 1 1 0
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define endl "\n"
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define inf 1000000000000000001
#define F first
#define S second
#define dbg(x) cout << #x << " = " << x << '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n;
ll add(ll a,ll b)
{
    return (a%mod+b%mod)%mod;
}

ll mul(ll a,ll b)
{
    return (a%mod*b%mod)%mod;
}

struct M{
    vector<vector<ll>> t;
    M()
    {
        t.resize(n,vector<ll>(n));
    }

    M operator*(M &b){
        M c=M();
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<n;j++)
            {
                for(ll k=0;k<n;k++)
                    c.t[i][j]=add(c.t[i][j],mul(t[i][k],b.t[k][j]));
            }
        }
        return c;
    }
};


void solve()
{
    ll k;
    cin>>n>>k;
    M ans,base;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
            cin>>base.t[i][j];
        ans.t[i][i]=1;
    }
    while(k)
    {
        if(k%2)
            ans=ans*base;
        base=base*base;
        k>>=1;
    }
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
            sum=add(sum,ans.t[i][j]);
    }
    cout<<sum;
}

int main() 
{
    off;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
import sys

input = sys.stdin.readline


def solve(N, K, L):
    dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(L + 1)]
    dp[0][0][0] = 1
    for i in range(L):
        D = N[i]
        for j in range(2):
            d_max = 9 if j == 1 else D
            for k in range(K + 1):
                if k < K:
                    for d in range(d_max + 1):
                        dp[i + 1][int(j or (d < D))][k + int(d > 0)] += dp[i][j][k]
                else:
                    dp[i + 1][j][k] += dp[i][j][k]

    return dp[L][0][K] + dp[L][1][K]


def main():
    N = list(map(int, input().rstrip()))
    K = int(input())

    L = len(N)
    ans = solve(N, K, L)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		s.insert(str);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 19228