akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from collections import defaultdict
MOD = 1000000007  # type: int


class Combination(object):

    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        b = (self.finv[k]*self.finv[n-k] % self.MOD)
        return (self.fac[n] * b) % self.MOD


def make_downward(E, N, s=0):
    # BFSでdownward順を構成する
    front, back = 0, 1
    downward = [s]*N
    parent = [-1]*N
    for _ in range(N-1):
        v = downward[front]
        front += 1
        for u in E[v]:
            if u == parent[v]:
                continue
            parent[u] = v
            downward[back] = u
            back += 1
    # print(downward)
    return downward, parent


def solve(N: int, a: "List[int]", b: "List[int]"):
    # グラフの構築
    E = [[] for _ in range(N)]
    for aa, bb in zip(a, b):
        E[aa-1].append(bb-1)
        E[bb-1].append(aa-1)

    # 組み合わせの初期化
    cmb = Combination(N)

    # BFSでdownward順を構成する
    downward, parent = make_downward(E, N)

    # 節点vを根とした部分木の塗り方dp[v]
    dp = [1]*N
    # 節点vを根とした部分木のサイズsize[v]+1
    size = [0]*N

    # 木DP
    # 葉から根へ向かう探索
    for v in reversed(downward):
        for u in E[v]:
            if u == parent[v]:
                continue
            size[v] += size[u]+1
            dp[v] *= cmb.finv[size[u]+1]
            dp[v] %= MOD
            dp[v] *= dp[u]
            dp[v] %= MOD
        dp[v] *= cmb.fac[size[v]]
        dp[v] %= MOD

    # 全方位木DP
    # 根から葉へ向かう探索
    for v in downward:
        for u in E[v]:
            if u == parent[v]:
                continue
            dp[u] = dp[v]
            dp[u] *= (size[u]+1)*cmb.inv[N-(size[u]+1)]
            dp[u] %= MOD

    for v in dp:
        print(v)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)


if __name__ == '__main__':
    main()


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

value = input().rstrip().split(' ')
cost  = input().rstrip().split(' ')

X = 0
Y = 0

for i in range(N):

    if int(value[i]) > int(cost[i]):
        X += int(value[i])
        Y += int(cost[i])
    else:
        pass


print(X-Y)

Measured memory_bytes: 3064
#!/usr/bin/perl
my ($h) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $c = 1;

my $ac = 0;
while( $h > 1 ){
  $h = int($h/2);
  $ac += $c;
  $c += $c;
}

my $res = $ac + $c;
print "$res\n";


Measured memory_bytes: 512
N = int(input())
S = input()
L = ""
def f(a):
    return chr((ord(a)+N)%90 + 64) 
  
for i in range(len(S)):
    if ord(S[i])+N>90:
        s = f(S[i])
    else:
        s = chr(ord(S[i])+N)
    L += s

print(L)

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

using namespace std;

int main(){

int n,k;
cin >> n >> k;

if(n <= k){
    cout << 0 <<endl;
    return 0;
}

vector<int> h(n);

for(int i = 0;i < n;i++){
    cin >> h[i];
}

sort(h.begin(),h.end());
 long long  ans = 0;
 for(int i = 0;i < n-k;i++){
    ans += h[i];
 }

 cout << ans <<endl;


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,x;
  int y,ans;

  while(cin>>n>>a>>b>>c>>x && (n||a||b||c||x)){
    ans=0;
    for(int i=0;i<n;i++){
      if(i>0) {x=(a*x+b)%c;ans++;}
      cin>>y;
      while(ans<=10000 && x!=y){
	x=(a*x+b)%c;
	ans++;
      }
    }
    if(ans>10000) ans=-1;
    cout<<ans<<endl; 
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void){
  int num[3] = {};
  int i=0,j5=0,j7=0;
  
  scanf("%d %d %d",&num[0],&num[1],&num[2]);
  for(i=0;i<3;i++){
    if(num[i]==5) j5++;
    if(num[i]==7) j7++;
  }
  
  if((j5==2)&&(j7==1)) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  ans = 700;
  rep(i, S.length()) if(S[i] == 'o') ans+=100;

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int N;cin>>N;
	vl plu, dif;
	rep(i,N) {
		ll a; cin >> a;
		plu.pb(i + 1 + a);
		dif.pb(i + 1 - a);
	}
	sort(all(plu)); sort(all(dif));
	ll ans = 0;
	for(int i = 1; i <= N; i++){
		ans += (ll)(lower_bound(all(plu), i) - upper_bound(all(plu), i)) * (lower_bound(all(dif), i) - upper_bound(all(dif), i));
	}
	out(ans);



}

Measured memory_bytes: 6708
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <functional>

using namespace std;

typedef long	DWORD;
typedef short WORD;
typedef bool	BOOL;
typedef pair<DWORD, DWORD> PAIR;

#define MAX_N	(100000)

DWORD N;
BOOL	used[MAX_N + 1] = {};
vector<PAIR> G[MAX_N + 1];
priority_queue<PAIR, vector<PAIR>, greater<PAIR>> cost_que;



void makeEdgeList(priority_queue<PAIR, vector<PAIR>, greater<PAIR>> *que)
{
	
	PAIR pre_posi, cur_posi;
	DWORD posIdx = 1;

	pre_posi = (*que).top();
	(*que).pop();
	while(!(*que).empty()) {
		DWORD len;
		cur_posi = (*que).top();
		(*que).pop();
		
		len = cur_posi.first - pre_posi.first;
		
		G[pre_posi.second].push_back(PAIR(len, cur_posi.second));
		G[cur_posi.second].push_back(PAIR(len, pre_posi.second));
		
		pre_posi = cur_posi;
	}

}

DWORD Prim() 
{
	DWORD ans = 0;
	PAIR top;

	for (int i = 0; i < G[1].size(); i++) {
		cost_que.push(PAIR(G[1][i].first, G[1][i].second));	
	}
	used[1] = true;

	while (!cost_que.empty()) {
		top = cost_que.top();
		cost_que.pop();

		if (!used[top.second]) {
			used[top.second] = true;
			ans += top.first;

			for (int i = 0; i < G[top.second].size(); i++) {
				cost_que.push(PAIR(G[top.second][i].first, G[top.second][i].second));
			}
		}
	}
	return ans;
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif
	DWORD cost_x, cost_y;
	priority_queue<PAIR, vector<PAIR>, greater<PAIR>> x_que;
	priority_queue<PAIR, vector<PAIR>, greater<PAIR>> y_que;
	cin >> N;

	for (int i = 1; i <= N; i++) {
		DWORD x, y;
		cin >> x >> y;

		x_que.push(PAIR(x, i));
		y_que.push(PAIR(y, i));
	}

	//グラフを作成
	makeEdgeList(&x_que);
	makeEdgeList(&y_que);

	cout << Prim() << endl;
	
	return 0;
}

Measured memory_bytes: 20964
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int dp1[1000005], dp2[1000005];
void makeDP(){
  vector<int> v1;
  vector<int> v2;
  int tn = 1;
  while(1){
      int tmp = tn*(tn+1)*(tn+2)/6;
      if(tmp < 1000000){
        v1.push_back(tmp);
        if(tmp % 2 != 0) v2.push_back(tmp);
      }else{
        break;
      }
      tn++;
  }
  REP(i,0,1000005) dp1[i] = i, dp2[i] = i;
  REP(i,1,180){
    REP(j,0,1000005){
      if(j-v1[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v1[i]] + 1);
    }
  }
  REP(i,1,45){
    REP(j,0,1000005){
      if(j-v2[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v2[i]] + 1);
    }
  }
}

int main() {

  makeDP();

  int N;
  while(1){
    cin>>N;
    if(N==0) break;
    cout<<dp1[N]<<" "<<dp2[N]<<endl;
  }

  return 0;
}

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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }

    static int waru2(int x)
    {
        int ret = 0;
        while (x % 2 == 0)
        {
            x /= 2;
            ret++;
        }
        return ret;
    }


    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int N = sc.intarr[0];
        int[] a = sc.intarr;

        int ans = 0;
        foreach(var x in a)
        {
            ans += waru2(x);
        }
        wr.wri(ans);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 14176
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 600000


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

	return 0;
}



Measured memory_bytes: 2720
# abc106 B
class Integer
  def divisor_list
    require 'prime'
    list = []
    d = ([1] + prime_division.flat_map { |x,n| [x] * n })
    [true, false].repeated_permutation(d.size) do |arr|
      r = 1
      arr.each_with_index do |a, i|
        r *= d[i] if a
      end
      list << r
    end
    list.uniq
  end
end

n = gets.to_i
cnt = 0
1.upto(n) do |i|
  next if i.even?

  cnt += 1 if i.divisor_list.size == 8
end
p cnt



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

struct item{
	string name;
	double value;
};

bool operation(const item &right,const item &left){
	if(right.value == left.value)return right.name < left.name;
	else return right.value > left.value;
}

int main(){
	int n;
	double p,a,b,c,d,e,f,s,m,time,x;
	string l;
	vector<item> v;
	item plant;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		v.clear();
		for(int i = 0;i < n;i++){
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			time = a + b + c + (d + e)*m;
			x = f * m;
			plant.name = l;
			plant.value = (double)(((x * s) - p)/time);
			v.push_back(plant);
		}
		sort(v.begin(),v.end(),operation);
		for(int i = 0;i < v.size();i++){
			cout << v[i].name <<endl;
			//printf("%f\n",v[i].value);
		}
		printf("#\n");
	}
	return 0;
}

Measured memory_bytes: 3308
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, M;
	cin >> N >> M;
	if (N == M)cout << "Yes";
	else cout << "No";
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    string N;
    ist >> N;

    /* ------- 計算 ------- */

    long long sum = 0;
    for (auto n : N)
    {
        int num = (int)n - 48;
        sum += num;
    }

    if (sum % 9 == 0)
    {
        ost << "Yes" << endl;
    }
    else
    {
        ost << "No" << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char> >  itbl(h, vector<char>(w));
  vector<bool> outputRows(h, false);
  vector<bool> outputCols(w, false);
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> itbl.at(i).at(j);
      if(itbl.at(i).at(j) == '#') {
	outputRows.at(i) = true;
	outputCols.at(j) = true;
      }
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(outputRows.at(i) && outputCols.at(j)) {
	cout << itbl.at(i).at(j);
      }
    }
    if(outputRows.at(i)) {
      cout << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 2e3 + 10;
const int INF = 2e9 + 10;
using namespace std;

string s[maxn << 1];
int ord[maxn << 1], n, id;
int dp[maxn][maxn], b[maxn], c[maxn];
int rb[maxn], rc[maxn], w_tot, b_tot;
int wi[maxn][maxn], bl[maxn][maxn];
int idw[maxn], idb[maxn];

void update(int *C, int x) { for(; x <= n; x += x & -x) C[x]++; }
int get_sum(int *C, int x) { int ans = 0; for( ; x; x -= x & -x) ans += C[x]; return ans; }

int main() {
	ios::sync_with_stdio(0);
	int ans = 0; cin >> n;
	for(int i = 1; i <= 2 * n; i++) {
		cin >> s[i] >> ord[i];
		if(s[i][0] == 'W') {
			idw[ord[i]] = i;
			rc[ord[i]] = get_sum(c, n - ord[i] + 1);
			update(c, n - ord[i] + 1);
		} else {
			idb[ord[i]] = i;
			rb[ord[i]] = get_sum(b, n - ord[i] + 1);
			update(b, n - ord[i] + 1);
		}
	}
	for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) {
		dp[i][j] = INF; 
		if(!i || !j) continue;
		wi[j][i] = (wi[j][i - 1] + (idb[i] < idw[j]));
		bl[j][i] = (bl[j][i - 1] + (idw[i] < idb[j]));
	}
	dp[0][0] = 0;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			int cost = 0;
			//下一个放白球
			cost += rc[j + 1];
			cost +=	wi[j + 1][n] - wi[j + 1][i];
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cost);
			//下一个放黑球
			cost = 0;
			cost += rb[i + 1];
			cost += bl[i + 1][n] - bl[i + 1][j];
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost);
		}
	}
	cout << dp[n][n] << endl;
	return 0;
}

Measured memory_bytes: 47872
void main() {
	auto N = readAs!ulong;
	auto k = 1;
	ulong a = 0;
	if(N % 2 == 1) {
		writeln(0);
		return;
	}
	for(ulong i = 10; N >= i; i *= 5) a += N / i;
	a.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const ll inf = 1e15;
int n;
ll a[N], dp[N][3];
char s[N][2];
int main() {
    scanf("%d", &n);
    for(int i = 1; i < n; ++i) {
        scanf("%lld%s", &a[i], s[i]);
    }
    scanf("%lld", &a[n]);
    dp[1][0] = a[1];
    dp[1][1] = dp[1][2] = -inf; 
    for(int i = 2; i <= n; ++i) {
        if(s[i - 1][0] == '-') {
            dp[i][0] = -inf;
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - a[i];
            dp[i][2] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        } else {
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
            dp[i][1] = max(dp[i - 1][2], dp[i - 1][1]) - a[i];
            dp[i][2] = dp[i - 1][2] + a[i];
        }
    }
    printf("%lld\n", max(max(dp[n][0], dp[n][1]), dp[n][2]));
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
int main() {
	ll n, m;
	cin >> n >> m;
	if (n == m / 2)cout << n << endl;
	else if (n > m / 2)cout << m / 2 << endl;
	else cout << n + (m - 2 * n) / 4 << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n;
	int l;
	int r;
	int a = 0;
	scanf("%d", &n);
	
	while(n != 0){
		scanf("%d %d", &l, &r);
		a = a + (r - l) + 1;
		
		n--;
		
	}
	
	printf("%d", a);
	
	return(0);
	
}

Measured memory_bytes: 128
import java.util.*;

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

        int N = sc.nextInt();
        int[] As = new int[N];
        
        for (int i=0; i<N; i++) {
            As[i] = sc.nextInt();
        }
        Arrays.sort(As);
        System.out.println(As[N-1] - As[0]);
    }
}



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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,k,a=-1;
    cin>>h>>w>>k;
    string s[h];
    ll num[h];
    ll m[h];
    memset(m,-1,sizeof(m));
    bool maki;
    memset(num,-1,sizeof(num));
    for(int i=0;i<h;i++){
        cin>>s[i];
        maki=false;
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                if(m[i]==-1){
                    m[i]=j;
                }
                maki=true;
            }
        }
        if(maki){
            num[i]=i;
            if(a==-1)a=i;
        }
    }
    for(int i=0;i<h;i++){
        if(num[i]==-1)num[i]=a;
        else a=num[i];
    }
    ll index=0;
    ll niko;
    ll ans[h][w];
    for(int i=0;i<h;i++){
        niko=1;
        if(num[i]==i){
            for(int j=0;j<w;j++){
                if(s[i][j]=='#'){
                    if(niko)niko=0;
                    index++;
                }
                ans[i][j]=index+niko;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(num[i]!=i){
            for(int j=0;j<w;j++){
                ans[i][j]=ans[num[i]][j];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout <<ans[i][j]<<" ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#define max 44

int fibo(int);
int F[max];

int main(){

  int a;

  scanf("%d",&a);

  printf("%d\n",fibo(a));


  return 0;
}

int fibo(int n){

  int i;

  F[0] = 1;
  F[1] = 1;
  for(i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }

  return F[n];

}

Measured memory_bytes: 596
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    string s;
    cin>>s;
    int len=s.length();
    int ten=1;
    int num[200005]={}, count[2025]={};
    for(int i=len-1;i>=0;i--){
      num[i]=((s[i]-'0')*ten+num[i+1])%2019;
      count[num[i]]++;
      ten*=10;
      ten%=2019;
    }
    ll ans=0;
    if(count[0])ans+=(count[0]+1)*count[0]/2;
    for(int i=1;i<=2018;i++){
        if(count[i]>=2)ans+=count[i]*(count[i]-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main(void){
	int a[3];
	rep(i,3) cin >> a[i];
	sort(a,a+3);
	if(a[0]+a[1]==a[2])
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
c = []
a = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci))

INF = 100 ** 18
dp = [INF] * (2**n + 1)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)



Measured memory_bytes: 46424
#include<iostream>
#define fr(i,a,b) for(int i=a;i<=b;i++)
int f[]={0,1,2,4,7,12,20,29,38,52,73},n;
int main()
{
	std::cin>>n;//////////////////////
	long d[11][11]={0},p=1;
	fr(i,2,n){fr(j,1,i-1)d[i][j]=d[j][i]=p*f[j];p+=d[i][i-1]+d[i][i-2]-d[i-1][i-2];}
	fr(i,1,n)fr(j,1,n)std::cout<<d[i][j]<<" \n"[j==n];
	return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  string s;
  cin >> s;
  set<char> st;
  st.insert('A');
  st.insert('C');
  st.insert('G');
  st.insert('T');
  int ans = 0;
  rep (i, s.size()) {
    for (int j = i; j < s.size(); j++) {
      bool flag = true;
      for (int k = i; k <= j; k++) {
        if (!st.count(s[k])) flag = false;
      }
      if (flag) {
        ans = max(ans, j - i + 1);
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
  int n,r,i,j,p,c;
  cin >> n >> r;
  while(n!=0&&r!=0){
    vector <int> cards;
    for(i=0;i<n;i++){
      cards.push_back(i+1);
    }
    for(i=0;i<r;i++){
      cin >> p >> c;
      for(j=0;j<c;j++){
	cards.push_back(cards[n-p-c+1]);
	cards.erase(cards.begin()+n-p-c+1);
      }
      //for(j=0;j<n;j++) cout << j+1 << ":" << cards[j] << endl; 
    }
    
    cout << cards[n-1] << endl;
    
    cin >> n >> r;
  }
  
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array


#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18


ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

ld dist(pii a, pii b) {
	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
	ans = sqrt(ans);
	return ans;
}
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;
}
int *dp;
ll maxCompositeSummands(ll n) {
	if (n == 2 || n == 1 || n == 3) {
		return INT_MIN;
	}
	if (dp[n] != -1) {
		return dp[n];
	}
	ll mexx = INT_MIN;
	for (ll i = 4; i <= n; i++) {
		if (!isPrime[i]) {
			mexx = max(mexx, maxCompositeSummands(n - i));
		}
	}
	return dp[n] = mexx == INT_MIN ? mexx : mexx + 1;
}
int main() {
	fast
	ll r;
	cin >> r;
	long double pi = 3.141592653;
	long double ans = 2 * pi * r;
	cout << ans << endl;

}


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

int main() {
  int x,y;
  cin>>x>>y;
  vector<int>vec={0,2,0,1,0,1,0,0,1,0,1,0};
 
  if(vec.at(x-1)==vec.at(y-1)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 256
N,K = map(int, input().split())
ab = [ [int(j) for j in input().split()] for _ in range(N)]
ab = sorted(ab)

i = 0
ans = 0
while K > 0:
    p = ab[i]
    ans = p[0]
    K -= p[1]
    i+=1
print(ans)
    



Measured memory_bytes: 61700
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n;
	long long a,b,s,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		s=a*b;
		t=(int)sqrt(s);
		if(t*t==s)
		{
			if(a==b)
			{
				printf("%lld",(t-1)*2);
			}
			else
			{
				printf("%lld",(t-1)*2-1);
			}
		}
		else
		{
			if(s<=t*(t+1))
			{
				printf("%lld",t*2-1-1);
			}
			else
			{
				printf("%lld",t*2-1);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

bool the_first_index = true;

void putspace()
{
	if (the_first_index) {
		the_first_index = false;
	} else {
		std::cout << " ";
	}
}

int main()
{
	std::string S;

	std::cin >> S;

	for (int first = 0; first < S.size();) {
		int i = first;
		for (i = first; i< S.size(); ++i) {
			if (S[i] != 'R')
				break;
		}
		int numR = i - first;
		int j = i;
		for (j = i; j < S.size(); ++j) {
			if (S[j] != 'L')
				break;
		}
		int numL = j - i;
		first = j;
		for (int i = 0 ; i < numR - 1; ++i) {
			putspace();
			std::cout << "0";
		}
		putspace();
		std::cout << (((numR+1) / 2) + (numL / 2));
		putspace();
		std::cout << ((numR / 2) + ((numL+1) / 2));
		for (int i = 0 ; i < numL - 1; ++i) {
			putspace();
			std::cout << "0";
		}
	}
	std::cout << "\n";
}


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

using namespace std;

#define LL long long

LL n,ans,a[80],b[80],f[80][80],g[80][80];

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i) scanf("%lld",&a[i]);
	for (LL i=1;i<=n;++i) scanf("%lld",&b[i]);
	for (LL i=1;i<=n;++i)
		g[i][a[i]]=1;
	for (LL i=50;i;--i){
		memcpy(f,g,sizeof f);
		bool fl=1;
		for (LL j=1;j<=n;++j){
			for (LL k=i-1;k;--k)
				for (LL l=0;l<=50;++l)
					f[j][l%k]|=f[j][l];
			fl&=f[j][b[j]];
		}
		if (!fl){
			ans+=1LL<<i;
			for (LL j=1;j<=n;++j)
				for (LL k=0;k<=50;++k)
					g[j][k%i]|=g[j][k];
		}
	}
	for (LL i=1;i<=n;++i) if (!g[i][b[i]]){puts("-1"); return 0;}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 384
#include<cstdio>
using namespace std;
int main()
{
    long long n,t;
    scanf("%lld%lld",&n,&t);
    if(n-t<=0)
    {
        printf("0\n");
        return 0;
    }
    printf("%lld\n",n-t);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define N 105
#define db double
#define ll long long
int n,A,B;
int main()
{
	scanf("%d%d%d",&n,&A,&B);
	if(abs(B-A)%2) puts("Borys");
	else puts("Alice");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		double ans=100000;
		for(int i=0;i<n;i++){
			ans=ans*1.05;
			if(ans%1000!=0){
				ans=ans+1000-ans%1000;
			}
		}
		int a=(int)ans;
		System.out.println(a);
	}
}

Measured memory_bytes: 12000
string = input()
pattern = ["A","C","G","T"]

c = 0
result = []
for i in string:
    if i in pattern:
        c += 1
        if string[len(string)-1] == i:
            result.append(c)
    else:
        result.append(c)
        c = 0

if len(result) == 0:
    print(len(string))
else:
    print(max(result))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,x;
  cin>>a>>b>>x;
  if(a>x) cout<<"NO"<<'\n';
  else if(a+b>=x) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';
  return 0;
}


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

int main(){
    int o, z, m, a;
    cin >> o >> z >> m >> a;
    int sum = 0;

    if(o >= a){
        cout << a << endl;
    }else if(o+z >= a){
        cout << o << endl;
    }else{
        cout << o - (a-o-z) << endl;
    }


}

Measured memory_bytes: 3628
/*ASHWINI SHARMA*/
#include <bits/stdc++.h>

using namespace std;


#define fr(i,a,b) for (long long int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second


#define PI 3.1415926535897932385
#define INF 1000111222
#define EPS 1e-7
#define MAXN 1000001
#define MOD 1000000007
                                           /*ASHWINI SHARMA*/
int main() {
    
    cin.sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    rep(i, m)
    cin >> b[i];
    int a[n][m];
    rep(i, n)
    {
    	rep(j, m)
    	cin >> a[i][j];
    }
    int ans = 0;
    rep(i, n)
    {
    	int sum = c;
    	rep(j, m)
    	{
    		sum += a[i][j] * b[j];
    	}
    	if(sum > 0)
    		ans++;
    }
    cout << ans;
    return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int c; cin >> c;
	if (c >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

//!

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<pll> H(N);//<H,id>
    vector<ll> h(N);
    REP(i, N){
        cin >> h[i];
        H[i].fi = h[i];
        H[i].se = i;
    }
    vector<vector<int>> e(N);
    REP(i, M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        e[a].pb(b);
        e[b].pb(a);
    }

    vector<int> ok(N);
    RSORT(H);
    int ans = 0;
    REP(i, N){
        if(ok[H[i].se]) continue;
        ok[H[i].se] = 1; 
        bool f = true;
        for(auto&& c : e[H[i].se]){
            if(h[c] >= H[i].fi) f = false;
        }
        if(f){
            ans++;
            for(auto&& c : e[H[i].se]) ok[c] = 1;
        }
    }
    pr(ans);
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    int max = 0;
    int min = 1000000001;
    int ans = 0;
    for (int i=0; i<N; i++) {
        if (A.at(i) > max) max = A.at(i);
        if (A.at(i) < min) min = A.at(i);
    }
    ans = max - min;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int main(void){
	int m[10], i;
	for(i = 0;i < 10;i++){
		scanf("%d",&m[i]);
	}
	sort(m,m + 10,greater<int>());
	for(i = 0;i < 3;i++){
		printf("%d\n",m[i]);
	}
	return 0;
}

Measured memory_bytes: 1044
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer n,t;
  n=nil;
  while(1){
    if(n->next==nil)return t;
    if(n->next->key==key)return n->next;
    n=n->next;
  }
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t,n;
  t=listSearch(key);
  if(t==n)return ;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  x->prev=nil;
  nil->next->prev= x;
  nil->next=x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d",&key);
      insert(key);
      np++;
      size++;
    }else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf("%d",&key);
	delete(key);
      }
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32940
#include<bits/stdc++.h>
#define maxn 150005
#define eps 1e-10
#define mp(x,y) make_pair(x,y)
#define se second
#define fi first
#define inf 50000000
using namespace std;
typedef long long int ll;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(abs(a-b)%2==0)cout<<abs(a-b)/2<<endl;
	else
	{
		if(a>b)swap(a,b);
		ll u=a+(b-a-1)/2;
		ll v=n-b+1+(b-a-1)/2;
		cout<<min(u,v)<<endl;
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    int A, B;
    cin >> A >> B;
    A--; B--;

    if (B % A == 0) cout << B / A << endl;
    else cout << B / A + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, q;
    cin >> n >> q;
    vector<queue<int> > vque(n);
    for(int i=0; i<q; i++){
        int k, t, x;
        cin >> k;
        if(k==0){
            cin >> t >> x;
            vque[t].push(x);
        }else{
            cin >> t;
            if(!vque[t].empty()){
                if(k==1)cout << vque[t].front() << endl;
                else if(k == 2){
                    vque[t].pop();
                }
            }
    }

    }}




Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string s;
    cin >> s;
    bool odd = true;
    for (auto c:s) {
        if ((odd && c == 'L') || (!odd && c == 'R')) {
            cout << "No" << '\n';
            return 0;
        }
        odd = !odd;
    }
    cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
x = [int(_) for _ in input().split()]
ans = []
for i in range(N-K+1):
    l = abs(x[i]) + abs(x[i+K-1]-x[i])
    r = abs(x[i+K-1]) + abs(x[i+K-1]-x[i])
    ans.append(min(l,r))
print(min(ans))

Measured memory_bytes: 14384
#include<iostream>
using namespace std;
int d[100];
bool b[100]={0};
int main(){
	int n,k,x,sum=0;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>d[i];
		for(int j=0;j<d[i];j++){
			cin>>x;
			b[x-1]=1;
		}
	}
	for(int i=0;i<n;i++){
		if(b[i]==0)sum++;
	}
	cout<<sum<<'\n';
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,a1,a2,b1;
  
  cin >> a >> b >> c;
  
  a1 = a + b;
  a2 = a + c;
  b1 = b + c;
  
  if(a1 < a2){
    if(a1 < b1){
      cout << a1 << endl;
    }
    else{
      cout << b1 << endl;
    }
  }
  else{
    if(a2 < b1){
      cout << a2 << endl;
    }
    else{
      cout << b1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int nmax=200005;

int n,aib[nmax],a[nmax],b[nmax];

void update(int indx,int val){
    for(int i=indx;i<=n;i+=(i&-i)) aib[i]=max(aib[i],val);
}

int query(int indx){
    int rs=0;
    for(int i=indx;i>=1;i-=(i&-i)){
        rs=max(rs,aib[i]);
    }
    return rs;
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++) cin >> b[i];
    for(int i=1;i<=n;i++){
        auto it=query(a[i]);
        update(a[i],it+b[i]);
    }
    cout << query(n);
}


Measured memory_bytes: 4992
li=[]

for i in range(5):
    li.append(str(input()))

min=10
f=1
for i in li:
    temp=int(i[-1])
    #print('-1',temp)
    if temp!=0:
        f=0
    if min > temp and temp!=0:
        min=temp
    if f:
        min=10


sum=0
for i in li:
    #print(i[-1])
    if i[-1]!='0':
        temp=int(i[0:-1]+"0")+10
    else:
        temp=int(i)
    #print("temp", temp)
    sum+=temp

sum-=(10-min)

print(sum)



Measured memory_bytes: 3064
#include<iostream>
#include "string"

using namespace std;
int N,M,a[200000],b[200000];
int t,f,ans;
bool Fs[200000],Fn[200000],F;
int main(){
	cin >> N>>M;
	for(int i=0;i<M;i++){
		cin>>a[i]>>b[i];
		if(a[i]==1){
			Fs[b[i]]=true;
		}

		if(b[i]==N){
			Fn[a[i]]=true;
		}
	}
	ans=false;
	for(int i=0;i<N;i++){
		if(Fs[i]==true&&Fn[i]==true){
			ans=true;
		}
	}
	if(ans==true){
		cout <<"POSSIBLE"<<endl;
	}else{
		cout<< "IMPOSSIBLE"<<endl;
	}


	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<sstream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int ans=10000;
  for(int i=0;i<N;i++){
    int num=0;
    int A;
    cin>>A;
    while(A%2==0){
      A/=2;
      num++;
    }
    ans=min(num,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
S = str(input())
if len(S) > A+B+1:
        print("No1")
        exit()
if len(S[A+1:]) != B:
        print("No2")
        exit()
if S == S[0:A]+"-"+S[A+1:] and "-" not in S[0:A] and "-" not in S[A+1:] :
        print("Yes")
else:
        print("No")



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
int main(){
long int a[100001],n,m=-1,i;
std::cin>>n;
for(i=0;i<n;i++)std::cin>>a[i];
std::sort(a,a+n);
for(i=0;i<n-1;i++){a[i+1]+=a[i];if(3*a[i]<a[i+1])m=i;}
std::cout<<n-m-1;
}

Measured memory_bytes: 1024