akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ITP1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] strs = Console.ReadLine().Split(' ');
            Console.Write(strs[n-1]);
            for (int i = n - 2; i >= 0; i--) Console.Write(" " + strs[i]);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8848
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
const int KTINF = 1e9+7;

int main(int argc, char **argv)
{
	int n, *a, i;
	char *sp = "";
	scanf("%d", &n);
	if (n == 0) return 0;
	a = malloc(sizeof(int) * n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	for (i = 0; i < n; i++) {
		printf("%s%d", sp, a[n - i - 1]);
		sp = " ";
	}
	putchar('\n');

	return 0;
}

Measured memory_bytes: 600
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools


a = int(stdin.readline().rstrip())
b = int(a/500)
a -= b*500
c = int(a/5)
print(b*1000+c*5)


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

int main(void){
  int A, B;
  cin >> A >> B;
  int num = A;
  int count = 1;
  if (B!=1){
    while(num < B){
      num += A - 1;
      count++;
    }
  }else{
    count = 0;
  }

  cout << count << endl;
}

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

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

  int a,b;cin>>a>>b;
  for(int i=1;i<=3;i++){
    if(i!=a&&i!=b){
      cout<<i<<endl;
    }
  }
  
  return 0;
}


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

long long int gcd(long long int a,long long int b){
  if(!b)return a;
  return gcd(b,a%b);
}

long long int lcm(long long int a,long long int b){
  return a*b/gcd(a,b);
}

int main(){
  int a1,m1,a2,m2,a3,m3;

  while(1){
    cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
    if(!a1 && !m1 && !a2 && !m2 && !a3 && !m3)break;

    int x = 1,y = 1,z = 1;
    long long int ans1 = 0,ans2 = 0,ans3 = 0;
    do{
      ans1++;
      x = (a1*x)%m1;
    }while(x!=1);
    do{
      ans2++;
      y = (a2*y)%m2;
    }while(y!=1);
    do{
      ans3++;
      z = (a3*z)%m3;
    }while(z!=1);


    cout << lcm(ans1,lcm(ans2,ans3)) << endl;
  }
}

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


#define INF 1000000000000


signed main()
 {
int n,m;
cin>>n>>m;
vector<int>h(n);
vector<int>good(n);
rep(i,n){cin>>h[i]; good[i]=1;}
rep(i,m){
  int a,b;
  cin>>a>>b;
  if(h[a-1]>h[b-1]){good[b-1]=0;}
  if(h[b-1]>h[a-1]){good[a-1]=0;}
  if(h[b-1]==h[a-1]){good[a-1]=0;good[b-1]=0;}
}
int ans=0;
rep(i,n){
  ans+=good[i];
}
cout<<ans;
}


Measured memory_bytes: 4844
#include<iostream>
using namespace std;
int w,h;
char tail[21][21];
int a[]={-1,0,1,0};
int b[]={0,1,0,-1};
int cnt=0;
void func(int x,int y);
main(){
  int sx,sy;
  while(1){
    cin>> w>> h;
      if(w==0&&h==0) break;
    cnt=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>> tail[i][j];
	if(tail[i][j]=='@'){
	  sx=j;
	  sy=i;
	}
      }
    }
    func(sx,sy);
    cout<< cnt<< endl;
  }
}

void func(int x,int y){
  tail[y][x]='#';
  cnt++;
  for(int i=0;i<4;i++){
    int nx=x+a[i];
    int ny=y+b[i];
    if(nx>=0 && nx<w && ny>=0 && ny<h && tail[ny][nx]!='#'){
      func(nx,ny);
    }
  }
}

Measured memory_bytes: 1168
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7

ans = 0
for i in range(60):
    p = 0
    q = 0
    for a in A:
        if a & (1<<i):
            p += 1
        else:
            q += 1
    ans = (ans + ((1<<i) %mod * p * q) % mod) % mod
print(ans)

Measured memory_bytes: 123356
#include<cstdio>
#include<algorithm>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();
	while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();
	while(c>='0'&&c<='9');
}

int L=1,first[131073],head[131073],_L,n;
struct ac{ int to,nx; }e[1000000];
inline void addedge(int u,int v)
{
	u=u<<1,v=v<<1|1;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	u^=1,v^=1,u^=v^=u^=v;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
}
inline void addedge2(int u,int v)
{
	u=u<<1|1,v=v<<1|1;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	u^=1,v^=1,u^=v^=u^=v;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
}
inline void addedge3(int u,int v)
{
	u=u<<1,v=v<<1|1;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	e[L].to=u,e[L].nx=first[v],first[v]=L++;
	u^=1,v^=1;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	e[L].to=u,e[L].nx=first[v],first[v]=L++;
}


int st[131073],top;
int b[131073],timer;
bool dfs(int u)
{
	if(b[u^1]==timer)
		return false;

	b[u]=timer;
	st[top++]=u;

	for(int j=first[u];j;j=e[j].nx)
		if(!(b[e[j].to]==timer||dfs(e[j].to)))
			return false;
	return true;
}


bool check(int u)
{
	top=0;
	if(dfs(u<<1))return true;
	while(top)b[st[--top]]=0;
	return dfs(u<<1|1);
}


#define x first
#define y second
#define lc now<<1
#define rc (now<<1|1)
std::pair<int,int>a[20000],s[131073];
int pos[10000];

void init(int now=1,int l=0,int r=n-1)
{
	if(l==r)
	{
		if(~pos[a[l].y])
		{
			int u=pos[a[l].y];
			addedge3(u,now);
			head[u<<1]=first[u<<1];
			head[u<<1|1]=first[u<<1|1];
			head[now<<1]=first[now<<1];
			head[now<<1|1]=first[now<<1|1];
			a[l].y=now;
		}
		else
			a[l].y=pos[a[l].y]=now;
		s[now].x=s[now].y=a[l].x;
		s[rc].x=2e9;
		return;
	}
	int m=(l+r)>>1;
	init(lc,l,m);
	init(rc,m+1,r);
	s[now].x=s[lc].x;
	s[now].y=s[rc].y;
	addedge2(now,lc);
	addedge2(now,rc);
	head[now<<1]=first[now<<1];
	head[now<<1|1]=first[now<<1|1];
	head[lc<<1]=first[lc<<1];
	head[lc<<1|1]=first[lc<<1|1];
	head[rc<<1]=first[rc<<1];
	head[rc<<1|1]=first[rc<<1|1];
}

void link(int u,int L,int R,int now=1,int l=0,int r=n-1)
{
	if(L<=l&&s[now].y<=R)return addedge(u,now);
	int m=(l+r)>>1;
	if(L<=m)link(u,L,R,lc,l,m);
	if(s[rc].x<=R)link(u,L,R,rc,m+1,r);
}

void paste(int now=1,int l=0,int r=n-1)
{
	first[now<<1]=head[now<<1];
	first[now<<1|1]=head[now<<1|1];
	if(l<r)
	{
		int m=(l+r)>>1;
		paste(lc,l,m);
		paste(rc,m+1,r);
	}
}

bool twosat(int now=1,int l=0,int r=n-1)
{
	if(!check(now))return false;
	if(l<r)
	{
		int m=(l+r)>>1;
		if(!twosat(lc,l,m))return false;
		if(!twosat(rc,m+1,r))return false;
	}
	return true;
}



bool work(int d)
{
	L=_L,paste();
	for(int i=0;i<n;i++)
		link(a[i].y,i+1,a[i].x+d-1);

	return ++timer,twosat();
}


int main()
{
	int i,l=1e9,m,r=1;read(n);
	for(i=0;i<n;i++)pos[i]=-1;n<<=1;
	for(i=0;i<n;i++)
	{
		read(a[i].x);
		a[i].y=i>>1;
		a[i].x<l&&(l=a[i].x);
		a[i].x>r&&(r=a[i].x);
	}
	std::sort(a,a+n);

	init(),_L=L;
	work(14);

	r-=l,l=0;
	while(l<r)
	{
		m=(l+r+1)>>1;
		if(work(m))l=m;
		else r=m-1;
	}
	printf("%d\n",l);
}

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

int main()
{
    int n;

    cin >> n;

    int a[n];

    int max = -1;
    for( int i = 0; i < n; i++ )
    {
        cin >> a[i];
        if( a[i] > max )
            max = a[i];
    }

    int m = 1;
    while( true )
    {
        bool judge = true;
        for( int i = 0; i < n; i++ )
        {
            if( ( max * m ) % a[i] != 0 )
                judge = false;
        }
        if( judge == true )
        {
            cout << max * m << endl;
            break;
        }
        m++;
    }

    return 0;
}


Measured memory_bytes: 3076
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<iterator>
#include<string>
#include<sstream>
#include <unordered_map>
#include<cmath>
using namespace std;
#define ll long long


int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; t=1;
    while(t--){
       int x,y; cin>>x>>y;
       if((y-2*x)%2==0&&y>=2*x&&y<=4*x) cout<<"Yes\n";
       else cout<<"No\n";
    }    
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
const double pi = 3.1415926;

int main(){
  double a,b,C;
  cin>>a>>b>>C;
  double S = 0.5*a*b*sin(C*pi/180);
  double L = a+b+sqrt(a*a+b*b-2*a*b*cos(C*pi/180));
  double h = 2*S/a;
  cout<<setiosflags(ios::fixed)<<setprecision(6)<<S<<" "<<L<<" "<<h<<endl;
  return 0;
}


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


int main(){
    int n; cin >> n;
    if(n%2){
        cout << ((n-1)/2.0 + 1.0)/n << endl;
    }else{
        cout << 1/2.0 << endl;
    }
}

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

int main() {
    int n;
    long long s = 0;
    vector<int> a;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        int h;
        cin >> h;
        a.push_back(h);
    }
    int prev = 0;
    for(int i=0; i<n; i++)
    {
        if(prev > a[i])
        {
            s += (prev - a[i]);
        }
        else
        {
            prev = a[i];
        }
    }

    cout << s << endl;

    return 0;
}



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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    long A, B, K;
    cin >> A >> B >> K;
    cout << A - min (A, K) << " " << B - min (B, K - min (A, K)) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define mp make_pair
#define pb push_back
 
 
typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}
const int MAXN = 120000;
 
int was[MAXN];
int sz[MAXN];
ll gans;
vector<pair<int, ll> > eds[MAXN];
int n;
 
void dfs1(int v) {
    was[v] = 1;
    sz[v] = 1;
    for (pair<int, ll> e: eds[v]) {
        int u = e.first;
        if (was[u])
            continue;
        dfs1(u);
        sz[v] += sz[u];
    }
}
 
void dfs2(int v) {
    was[v] = 1;
    sz[v] = 1;
    for (pair<int, ll> e: eds[v]) {
        int u = e.first;
        if (was[u])
            continue;
        dfs2(u);
        sz[v] += sz[u];
        gans += e.second * 2 * sz[u];
    }
}
 
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        ll c;
        scanf("%d%d%lld", &a, &b, &c);
        --a, --b;
        eds[a].push_back(make_pair(b, c));
        eds[b].push_back(make_pair(a, c));
    }
    dfs1(0);
    int bst = -1;
    for (int i = 0; i < n; ++i)
        if (sz[i] * 2 >= n && (bst == -1 || sz[i] < sz[bst]))
            bst = i;
    memset(was, 0, sizeof(was));
    dfs2(bst);
    memset(was, 0, sizeof(was));
    ll me = 1e9 + 1000;
    int fl = 0;
    for (pair<int, ll> e: eds[bst]) {
        int u = e.first;
        if (sz[u] * 2 == n) {
            fl = 1;
            me = e.second;
        }
        else if (!fl) {
            me = min(me, e.second);
        }
    }
    cout << gans - me << "\n";
    return 0;
}

Measured memory_bytes: 13184
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    pS = defaultdict(list)
    for i in range(M):
        p, S = input().split()
        pS[p].append(S)

    ac = 0
    wa = 0
    for pp in pS:
        tmp = pS[pp]
        wa_tmp = 0
        for t in tmp:
            if t == 'WA':
                wa_tmp += 1
            else:
                ac += 1
                wa += wa_tmp
                break
    print(ac, wa)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >>x>>y;
  bool can=false;
  for(int i=0;i<x+1;i++){
    if(2*i+4*(x-i)==y){
      can=true;
      break;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }
  else{
    cout <<"No"<<endl;
  }

    
  
}
      

Measured memory_bytes: 3624
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	N = readline() |> parseInt
	G=[Array{Pair{Int,Int}}(0) for _=1:N]
	for i in 1:N-1
		u,v,w=readline() |> split |> parseMap
		push!(G[u],v=>w)
		push!(G[v],u=>w)
	end
	d=zeros(Int,N)
	used=[false for _=1:N]
	function dfs(u,di)
		d[u]=di%2
		used[u]=true
		for (v,x)=G[u]
			if !used[v]
				dfs(v,di+x)
			end
		end
	end
	dfs(1,0)
	for d=d
		println(d)
	end
end
main()


Measured memory_bytes: 184344
#!/usr/bin/env python3
from collections import deque

n = int(input())
g = [list() for _ in range(n)]
visited = [True] * n
coler = [0] * n
for _ in range(1, n):
    v1, v2, w = map(int, input().split())
    v1 -= 1
    v2 -= 1
    w %= 2
    g[v1].append((v2, w))
    g[v2].append((v1, w))

q = deque([0])
visited[0] = False
while q:
    a = q.pop()
    for v, w in g[a]:
        if visited[v]:
            visited[v] = False
            coler[v] = (coler[a] + w) % 2
            q.append(v)

print(*coler, sep="\n")


Measured memory_bytes: 42048
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007

using namespace std;
int main(){
    FAST
    int k,a,b; cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    

    return 0;
}


Measured memory_bytes: 3636
fun main() {

    val N = readLine()!!.toInt()

    val r = (1..N).map { readLine()!! }

    val l = mutableMapOf("AC" to 0, "WA" to 0, "TLE" to 0, "RE" to 0)

    r.forEach {
        val v = l[it]!!
        l[it] = v + 1
    }

    l.forEach {
        println("${it.key} x ${it.value}")
    }
}

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

int main(){
    long long N;
    cin >> N;
    long long ans = 0;
    for(long long i = 1; i <= N; i++){
        long long l = N/i;
        ans += i*(l+1)*l/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

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

#define dump(o) { cerr << #o << " " << o << endl; }
#define dumpc(o) { cerr << #o; for (auto &e : (o)) cerr << " " << e; cerr << endl; }
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX_M 101
#define MAX_N 100

signed main() {
	cout << fixed << setprecision(2);
	double a[MAX_N][MAX_N];
	double dp[MAX_M][MAX_N];
	for (int n, m; cin >> n >> m&&n;) {
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> a[i][j];
			}
		}

		for (int i = 0; i < n; i++) {
			dp[0][i] = 1.0;
		}

		for (int i = 1; i < m; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					dp[i][j] = max(
						dp[i][j],
						dp[i - 1][k] * a[k][j]
					);
				}
			}
		}
		double ans = 0;
		for (int j = 0; j < n; j++) {
			ans = max(ans, dp[m - 1][j]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

int main(){
  int n; cin >> n;
  long a[n*3], asum[n*3+1];
  asum[0] = 0;
  rep(i, n*3) cin >> a[i], asum[i+1] = asum[i] + a[i];
  long sumin[n+1], sumax[n+1]; sumin[0] = sumax[n] = 0;
  priority_queue<long, vector<long>, greater<long>> qmin;
  priority_queue<long> qmax;
  rep(i, n) qmin.push(a[i]), qmax.push(a[3*n-1-i]);
  rep(i, n){
    qmin.push(a[i+n]); sumin[i+1] = sumin[i] + qmin.top(); qmin.pop();
    qmax.push(a[2*n-1-i]); sumax[n-1-i] = sumax[n-i] + qmax.top(); qmax.pop();
  }
  long ans = -LONG_MAX;
  rep(i, n+1) ans = max(ans, asum[n+i]-sumin[i]-(asum[n*3]-asum[n+i]-sumax[i]));
  cout << ans << endl;
}

Measured memory_bytes: 8300
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}


int main() {
	int a, b;
	vector<int>vec(4);
	rep(i, 3) {
		cin >> a >> b;
		vec[a - 1]++;
		vec[b - 1]++;
	}
	if (vec[0] == 3 || vec[0] == 0 || vec[1] == 0 || vec[1] == 3 || vec[2] == 0 || vec[2] == 3 || vec[3] == 0 || vec[3] == 3) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}




Measured memory_bytes: 256
_n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count1 = count2 = 0

a.zip(b).each do |x, y|
  x > y ? count1 += x - y : count2 += (y - x) / 2
end

puts count1 <= count2 ? :Yes : :No

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

bool m[30][30];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c; cin >> c;
            if (c == '.') m[i+1][j+1] = 1;
        }
    }
    int ans = 0;
    auto s = [&](int x, int y) {
        queue<int> xq, yq; xq.push(x); yq.push(y);
        vector<vector<int>> d(h+1, vector<int>(w+1, 1e9));
        d[x][y] = 0;
        while (!xq.empty()) {
            int i = xq.front(), j = yq.front();
            xq.pop(), yq.pop();
            for (int t = 0; t < 4; t++) {
                if (m[i+dx[t]][j+dy[t]] && d[i+dx[t]][j+dy[t]] > d[i][j] + 1) {
                    ans = max(ans, d[i][j]+1);
                    d[i+dx[t]][j+dy[t]] = d[i][j] + 1;
                    xq.push(i+dx[t]), yq.push(j+dy[t]);
                }  
            }
        }
    };
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (m[i+1][j+1]) s(i+1, j+1);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
(* O(|s|) *)
let s = read_line ()
let b = Bytes.make 10 ' '
let i = ref 0
let f c =
  match c with
  | 'B' -> if !i > 0 then decr i
  | _ -> Bytes.set b !i c; incr i
let _ =
  String.iter f s;
  Bytes.sub_string b 0 !i |> print_endline

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1e9,INF=~0u>>2;
ll n,ans,i,len,l,r,mid;
string rep;
int main(){
//	freopen("ex.in","r",stdin);
	cout<<"? 10000000000"<<endl;
	cin>>rep;
	if(rep=="Y"){
		ans=2;
		while(1){
			cout<<"? "<<ans<<endl;
			cin>>rep;
			if(rep=="Y"){
				cout<<"! "<<ans/2<<endl;
				return 0;
			}
			ans*=10;
		}
	}
	r=10;
	while(1){
		cout<<"? "<<r<<endl;
		cin>>rep;
		if(rep=="N") break;
		r*=10;
	}
	l=r/10;
	r--;
	while(r>l){
		mid=(l+r)>>1;
		cout<<"? "<<mid<<"0"<<endl;
		cin>>rep;
		if(rep=="Y") r=mid;
		else l=mid+1;
	}
	cout<<"! "<<r<<endl;
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
  	int tot = 0;
    for(int j = 1; j <= i; j++) tot += (i%j) == 0;
  	ans += tot == 8 && (i%2) == 1;
  }
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int px[81],py[81];ll pk[81];
char qc[323];int qa[321],qb[321];
int Lx[81],Rx[81],Ly[81],Ry[81];
int fir[410],dis[10000010],nxt[10000010],w[10000010],id=1;ll cost[10000010];
void link(int a,int b,int c,ll d){
	nxt[++id]=fir[a],fir[a]=id,dis[id]=b,w[id]=c,cost[id]=d;
	nxt[++id]=fir[b],fir[b]=id,dis[id]=a,w[id]=0,cost[id]=-d;
}
int S,T,lst[410],que[100000],hd,tl,inq[410];
ll dist[410],Cost,Flow;
bool Mincost(){
	hd=tl=0;memset(dist,63,sizeof dist);
	dist[S]=0;inq[S]=1;que[tl++]=S;lst[S]=0;
	while(hd^tl){
		int x=que[hd++];
		for(int i=fir[x];i;i=nxt[i])
			if(w[i]&&dist[dis[i]]>dist[x]+cost[i]){
				dist[dis[i]]=dist[x]+cost[i];lst[dis[i]]=i;
				if(!inq[dis[i]])inq[dis[i]]=1,que[tl++]=dis[i];
			}
		inq[x]=0;
	}
	if(dist[T]>1e18)return 0;
	for(int i=lst[T];i;i=lst[dis[i^1]])--w[i],++w[i^1],Cost+=cost[i];
	++Flow;
	return 1;
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<=n;++i)px[i]=gi(),py[i]=gi(),pk[i]=gi();
	int q=gi();
	for(int i=1;i<=q;++i)scanf("%s",qc+i),qa[i]=gi(),qb[i]=gi();
	ll ans=0;
	for(int N=1;N<=n;++N){
		for(int i=1;i<=N;++i)Lx[i]=1,Rx[i]=100,Ly[i]=1,Ry[i]=100;
		for(int i=1;i<=q;++i){
			switch(qc[i]){
			case'L':for(int j=qb[i]+1;j<=N;++j)cxk(Lx[j],qa[i]+1);break;
			case'R':for(int j=1;j<=N-qb[i];++j)cnk(Rx[j],qa[i]-1);break;
			case'D':for(int j=qb[i]+1;j<=N;++j)cxk(Ly[j],qa[i]+1);break;
			case'U':for(int j=1;j<=N-qb[i];++j)cnk(Ry[j],qa[i]-1);break;
			}
		}
		memset(fir,0,sizeof fir);id=1;
		S=N+N+200+1,T=S+1;
		for(int i=1;i<=N;++i)link(S,i,1,0),link(i+N,T,1,0);
		for(int i=1;i<=N;++i)
			for(int j=1;j<=100;++j){
				if(Lx[i]<=j&&j<=Rx[i])link(i,j+N+N,1,0);
				if(Ly[i]<=j&&j<=Ry[i])link(j+N+N+100,i+N,1,0);
			}
		for(int i=1;i<=n;++i)link(px[i]+N+N,py[i]+N+N+100,1,-pk[i]);
		Flow=Cost=0;while(Mincost());
		if(Flow==N&&-Cost>ans)ans=-Cost;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int n;
    int x;
    cin >> n;
    for(int i = 1; i <= n; i++){
        x = i;
        if(x % 3 == 0){
            cout << " " << i;
        } else {
            while(x > 1){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }else {
                    x /= 10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n), f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  ll l = -1, r = 1e12;
  while (l + 1 < r) {
    ll c = (l + r) / 2;
    bool ok = [&] {
      ll s = 0;
      rep(i, n) { s += max(0ll, a[i] - c / f[i]); }
      return s <= k;
    }();
    if (ok)
      r = c;
    else
      l = c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
const int MAXN = 1E5 + 10;
int pre[MAXN];
int find(int x)                                                                                                         //查找根节
{
  int r=x;
  while ( pre[r ] != r )                                                                                              //返回根节点 r
    r=pre[r ];

  int i=x , j ;
  while( i != r )                                                                                                        //路径压缩
  {
    j = pre[ i ]; // 在改变上级之前用临时变量  j 记录下他的值 
    pre[ i ]= r ; //把上级改为根节点
    i=j;
  }
  return r ;
}


void join(int x,int y) {
  int fx=find(x),fy=find(y);
  if(fx!=fy)
    pre[fx ]=fy;
}

int a[MAXN];
int main() {
  int n, m, x, y;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pre[i] = i;
    }

    while (m--) {
      cin >> x >> y;
      join(x, y);
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      if (find(i) == find(a[i])) ++cnt;
    }
    cout << cnt << endl;

  }
}


Measured memory_bytes: 1024
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H, W, A, B = ZZ()
    ans = [[0] * W for _ in range(H)]
    for i in range(B):
        for j in range(A): ans[i][j] = 1
    for i in range(B, H):
        for j in range(A, W): ans[i][j] = 1
    for i in range(H): print(*ans[i], sep='')

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 13300
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define endl "\n"
#define tt ll tc;cin >> tc;while(tc--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool cm(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}
#define int long long

int par[100005],n,m;

int find(int a) {
    if(par[a] < 0) {
        return a;
    }
    else return par[a] = find((par[a]));
}

void xunion(int a, int b) {

    par[a] = min(par[a],par[b]);
    par[b] = a;
}
int32_t main() {
    int2(n,m)
    int a[m];
    int sum= 0;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n) {
        cout << -1 << endl;
    }
    else {
        cout << n - sum << endl;
    }
        return 0;
}




Measured memory_bytes: 3716
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main()
{
    int a[1000010][3];
    int n,i,j,flag,x,y;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        for(j=0;j<3;j++)
    {
        scanf("%d",&a[i][j]);
    }
    for(i=0,flag=1;i<n;i++)
    {
         if(i==0)
        {
            if(a[i][1]+a[i][2]==a[i][0])
            {
                flag=1;
                continue;
            }
            if(a[i][1]+a[i][2]<a[i][0]&&(a[i][0]-a[i][1]-a[i][2])%2==0)
            {
                flag=1;
                continue;
            }
            else
            {
                flag=0;
                break;
            }
        }
         if(i==n-1)
        {
            if(n!=1)
            {
               x=abs(a[i][1]-a[i-1][1]);
               y=abs(a[i][2]-a[i-1][2]);
            }
            if(n==1)
            {
                x=a[i][1];
                y=a[i][2];
            }
            if(x+y==a[i][0])
            {
                flag=1;
                continue;
            }
            if(x+y<a[i][0]&&(a[i][0]-a[i-1][0]-x-y)%2==0)
            {
                flag=1;
                continue;
            }
            else
            {
                flag=0;
                break;
            }
        }
        if(i!=0&&i!=n-1)
        {
            x=abs(a[i][1]-a[i-1][1]);
            y=abs(a[i][2]-a[i-1][2]);
            if(x+y==a[i][0])
            {
                flag=1;
                continue;
            }
             if(x+y<a[i][0]&&(a[i][0]-a[i-1][0]-x-y)%2==0)
            {
                flag=1;
                continue;
            }
            else
            {
                flag=0;
                break;
            }
        }
    }
    if(flag==1)
        printf("Yes\n");
    if(flag==0)
        printf("No\n");
    return 0;
}


Measured memory_bytes: 2944
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var ret = int.Parse(s[0].ToString()) + 9 * (s.Length - 1);
        if (s.Substring(1).Replace("9", "").Length != 0) ret -= 1;
        Console.WriteLine(ret);
    }
}


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

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  int mx=-1,mn=1e9;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mx = max(mx,a[i]);
    mn = min(mn,a[i]);
  }
  cout << mx - mn << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;
long long a,b,C,D;
int main(){
	cin>>n>>a>>b>>C>>D;
	b-=a;n--;
	bool ok=false;
	for(int i=0;i<=n;i++){
		long long k=i*D-(n-i)*C;
		long long r=i*D-(n-i)*D;
		if(r<=b&&b<=k)ok=true;
		if(r<=-b&&-b<=k)ok=true;
		//cout<<r<<" "<<k<<endl;
	}
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll power(ll a, ll b)    //a is base, b is exponent
    {
        if(b==0)
            return 1;
        if(b==1)
            return a;
        if(b%2 == 1)
            return (power(a,b-1)*a)%mod;
        ll q = power(a,b/2);
        return (q*q)%mod;
    }

    ll ncr(ll n,ll r)
    {
        ll ans=1,i,j;
        for(i=n-r+1;i<=n;++i)
        {
            ans=(ans*i)%mod;
        }
        for(i=1;i<=r;++i)
        {
            ans=(ans*power(i,mod-2))%mod;
        }
        return ans;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,a,b;
            cin>>n>>a>>b;
            ll ans=(power(2,n)-1+mod)%mod;
            ans=(ans-ncr(n,a)+mod)%mod;
            if(a!=b)
                ans=(ans-ncr(n,b)+mod)%mod;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    new Main();
  }
  public Main(){
    Scanner sc = new Scanner(System.in);
    int dataset = 0;
    while(true){
      ++dataset;
      int w = sc.nextInt();
      if(w==0)break;
      int n = sc.nextInt();
      int[] dp = new int[w+1];
      for(int i=0;i<=w;i++){
        dp[i] = -830252521;
      }
      dp[0] = 0;
      for(int i=0;i<n;i++){
        String[] s = (sc.next()).split(",");
        int val = Integer.parseInt(s[0]);
        int wei = Integer.parseInt(s[1]);
        for(int j=w;j>=0;j--){
          if(j+wei>w)continue;
          dp[j+wei] = Math.max(dp[j+wei],dp[j]+val);
        }
      }
      int answei = 0;
      for(int i=1;i<=w;i++){
        if(dp[i]>dp[answei]){
          answei = i;
        }
      }
      System.out.println("Case "+dataset+":");
      System.out.println(dp[answei]);
      System.out.println(answei);
    }
  }
}

Measured memory_bytes: 30420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int n;
	cin>>n;
	vector<Pii> v;
	int a,b;
	rep(i,n){
		cin>>a>>b;
		v.push_back(Pii(b,a));
	}
	sort(v.begin(),v.end());
	string flg="Yes";
	int total=0;
	rep(i,n){
		total+=v[i].second;
		if(total>v[i].first)flg="No";
	}
	cout<<flg<<endl;

	return 0;
}


Measured memory_bytes: 2420
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n, m;
long h[100005];
std::vector<long> edge[100005];

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 1; i <= n; i++){
        scanf("%ld", h+i);
    }
    for(int i = 0; i < m; i++){
        long a,b;
        scanf("%ld%ld", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    long ans = 0;
    for(int i = 1; i <= n; i++){
        bool good = true;
        for(int j = 0; j < edge[i].size(); j++){
            long nx = edge[i][j];
            if(h[i] <= h[nx]){
                good = false;
            }
        }
        if(good){
            ans++;
        }
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 10456
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const  int MAX=1e4;
long long int prime[MAX]={1};
long long int pwr(int n ,int m){
	long long int res=1;
	while(n){
		if(n%2)
			res=res*m;
		m=m*m;
		n/=2;
	}
	return  res;
}
int main(){
	 long long int a  ,b ,c ,n ,i ,j ,arr[10] ,cnt[MAX]={0} ,lcm[11][MAX];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<MAX;j++)
			lcm[i][j]=0;
	}
	for(i=0;i<n;i++){
		for(j=2;j*j<=arr[i];j++){
		while(arr[i]%j==0){
		//	cout<<arr[i]<<"\n";
			lcm[i][j]++;
			arr[i]=arr[i]/j;
		}
		//lcm[i][arr[i]]++;
	}
	lcm[i][arr[i]]++;
	}
	long long int res=1 ,p;
	for(j=2;j<MAX;j++){
		p=0;
		for(i=0;i<n;i++){
			if(lcm[i][j]){
				//cout<<j<<"\n";
			p=max(lcm[i][j] ,p);
			//cout<<p;
		}
		}
		if(p!=0){
			//	cout<<p<<j<<"\n";
		res*=pwr(p ,j);}
	}
	cout<<res<<"\n";
}


Measured memory_bytes: 3940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  k--;
  rep(i, n) {
    if (s[i] != s[k])
      s[i] = '*';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int score[101];
	int exist[31];
	int i;
	for(i=0;i<31;i++) exist[i]=0;
	int p,s;
	while(scanf("%d,%d",&p,&s)!=EOF){
		if(p==0&&s==0) break;
		score[p]=s;
		exist[s]=1;
	}
	int q,r=1;
	int rank[31];
	for(i=0;i<31;i++) rank[i]=0;
	for(i=30;i>=0;i--){
		rank[i]=r;
		r+=exist[i];
	}
	while(scanf("%d",&q)!=EOF){
		printf("%d\n",rank[score[q]]);
	}
	
	return 0;
}

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

const ll mod = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 1ll;
    for (ll i = k; i <= n; i++) {
        ll lb = i * (i - 1) / 2;
        ll rb = i * n - lb;
        if (lb > rb) break;
        ans += rb - lb + 1ll;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include<vector>
const int INF = 10e9 + 7;
using namespace std;

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	vector<int> h(n), dp(n,INF);
	for(int i = 0; i<n; i++){
		cin>>h[i];
	}
	dp[0]=0;
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<=i+k; j++){
			if(j<n)
				dp[j] = min(dp[j], dp[i]+abs(h[j]-h[i]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

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

int main(){
  ll k,a,b;
  cin >> k >> a >> b;

  ll ans=1;
  if(a+1>=b) ans+=k;
  else if(a+1>k) ans+=k;
  else{
    ll rest = k-(a+1);
    ans = b + (b-a)*(rest/2) + rest%2;
  }

  cout << ans;
}

Measured memory_bytes: 3616
n = int(input())
s = [input() for _ in range(2)]
mod = 10 ** 9 + 7


def is_vertical(i):
    return s[0][i] == s[1][i]


i = 0
if is_vertical(i):
    ans = 3
    prev_is_vertical = True
    i += 1
else:
    ans = 3 * 2
    prev_is_vertical = False
    i += 2

while i < n:
    if is_vertical(i):
        if prev_is_vertical:
            ans *= 2
        else:
            ans *= 1
        prev_is_vertical = True
        i += 1

    else:
        if prev_is_vertical:
            ans *= 2
        else:
            ans *= 3
        prev_is_vertical = False
        i += 2

    ans %= mod

print(ans)


Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int n;
    bool f=false;
    while(cin>>n,n){
        vint v(4);
        if(f) cout<<endl;
        f=true;
        rep(i,4) cin>>v[i];
        vint w={10,50,100,500};
        int tmp=0;
        rep(i,4) tmp+=v[i]*w[i];
        tmp-=n;
        vint x(4);
        // cout<<tmp<<endl;
        for(int i=3;i>=0;i--){
            while(tmp>=w[i]){
                tmp-=w[i];
                x[i]++;
            }
        }
        rep(i,4){
            if(v[i]>x[i]) cout<<w[i]<<" "<<v[i]-x[i]<<endl;
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main() {
  int A, B;
  char op;
  
  cin >> A;
  cin >> op;
  cin >> B;
  
  if (op == '+'){
    cout << A + B << endl;
  } else if(op == '-'){
    cout << A - B << endl;
  }
}

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


int main(){
    ll Q, H, S, D, N;  cin >> Q >> H >> S >> D >> N;
    Q *= 4;  H *= 4;  S *= 4;  D *= 4;
    N *= 4;

    ll ans = 0;
    if(N >= 8){
        ans += N/8 * min({8*Q, 4*H, 2*S, D});
        N %= 8;
    }
    if(N >= 4){
        ans += N/4 * min({4*Q, 2*H, S});
        N %= 4;
    }
    if(N >= 2){
        ans += N/2 * min({2*Q, H});
        N %= 2;
    }
    ans += N*Q;
    cout << ans/4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 21
#define ll long long int
using namespace std;

int field[MAX][MAX];
int w, h;
int coun = 1;
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int temp;

void search(int n, int x, int y)
{
	int jx, jy; //???????????´???

	if (n >= temp) {
		return;
	}

	for (int i = 0; i < 4; i++) {
		jx = x; 
		jy = y;

	

		jx = jx + dx[i];
		jy = jy + dy[i];

		

		if (jx < 0 || jx >= w) {
			continue;
		}

		if (jy < 0 || jy >= h) {
			continue;
		}
		if (field[jx][jy] == 1) {
			continue;
		}


		while (1) { //????????????


			
			if (field[jx][jy] == 3) {
				temp = n;
				return;
			}

			jx = jx + dx[i];
			jy = jy + dy[i];



			if (jx < 0 || jx >= w) { //??´???
				break;
			}
			if (jy < 0 || jy >= h) { //??´???
				break;
			}

			if (field[jx][jy] == 1) { //?£??????¶????????£?????¨???
				field[jx][jy] = 0;


				search(n + 1, jx - dx[i], jy - dy[i]);
				field[jx][jy] = 1;
				break;
			}

		}

	}

}



int main(void)
{

	int i, j;
	int sx, sy;
	vector <int> ans;

	while (1) {

		cin >> w >> h;
		if (w == 0 && h == 0) {
			break;
		}

		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				cin >> field[j][i];
				if (field[j][i] == 2) {
					field[j][i] = 0;
					sx = j;
					sy = i;
				}

			}
		}
		temp = 11;



		search(1, sx, sy);

		if (temp >= 11) {
			ans.push_back(-1);
		}
		else {
			ans.push_back(temp);
		}
		




		for (i = 0; i < 20; i++) { //field ????????????
			for (j = 0; j < 20; j++) {
				field[j][i] = -19;
			}
		}


	}

	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}


	return (0);
}

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

int main(){
  // input
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  // compute
  int ans = 0;
  int MaxHeight = -1;
  
  for(int i = 0; i < N; i++){
    if(MaxHeight <= H[i]){
      ans++;
      MaxHeight = H[i];
    }
  }
  
  // output
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s,t;
    cin >> s;
    cin >> t;

    if(t.size()==s.size()+1)
    {
        t.pop_back();
        if(t==s)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

const int bm = 105;
int n, x;
int a[bm];

signed main()
{
    sll(n, x);
    sal(a, n);
    sort(a, a+n);
    int rep = 0;
    int s = 0;
    fin(i, n) {
        s += a[i];
        if (s > x) break;
        ++rep;
    }
    if (rep == n && s != x) --rep;
    pl(rep);
}

Measured memory_bytes: 256