akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mk make_pair
#define fi first
#define nd second
#define pii pair<int,int>
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
inline ll read() {ll x = 0; char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {if(ch == '-') w = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
const int N = 3000000;
int n, fa[N];
set<int>e[N];
map<pii, int>c;
queue<pii>q;
int find(int x){
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}
int main() {
	int tot = 0;
	n = read();
	for(int i = 1; i < n * 2 - 1; ++i){
		int x = read(), y = read();
		e[x].insert(y);
		e[y].insert(x);
		++c[mk(x, y)];++c[mk(y,x)];
		if(c[mk(x,y)] == 2) q.push(mk(x, y)), ++tot;
	}
	for(int i = 1; i <= n; ++i) fa[i] = i;
	while(!q.empty() && tot < n - 1) {
		pii now = q.front();q.pop();
		int x = find(now.fi), y = find(now.nd);
		if(x == y) continue;
		if(e[x].size() > e[y].size()) swap(x, y);
		fa[x] = y;
		for(set<int>::iterator z = e[x].begin(); z != e[x].end(); ++z) {
			if(*z == y) continue;
			c[mk(*z, x)] = c[mk(x, *z)] = 0;
			++c[mk(*z, y)]; ++c[mk(y, *z)];
			e[y].insert(*z);e[*z].insert(y);
			e[*z].erase(x);
			if(c[mk(y, *z)] == 2) q.push(mk(y, *z)), ++tot;
		}
		e[x].clear();e[y].erase(x);
	}
	if(tot < n - 1) {
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 192128
li = [int(input()) for _ in range(5)]

ans = 0
a = 10
for i in li:
    if i%10 < a and i%10 != 0:
        a = i%10

    if i%10 == 0:
        ans += i
    else:
        i = i//10
        i = (i+1)*10
        ans += i

print(ans+a-10)


Measured memory_bytes: 2940
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).group_by{|e| e}.map{|k, v| [k, v.length]}.to_a.sort{ |x, y| x[1] <=> y[1] }
ans = 0
while a.size > K
  ans += a[0][1]
  a.shift
end
puts ans


Measured memory_bytes: 54384
#include <stdio.h>

#define MAX 100
#define BLACK 1
#define WHITE 0
#define inf 100000000
int prim(void);

int A[MAX][MAX],n;

int main(){

  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
    }
  }

printf("%d\n",prim());

return 0;

}

int prim(void){
int i,u,v,min,sum = 0;
int d[MAX],pi[MAX],color[MAX];

for(i=0;i<n;i++){
  d[i] = inf;
  pi[i] = -1;
  color[i] = WHITE;
}
d[0] = 0;

while(1){
  min = inf;
  for(i=0;i<n;i++){
    if(color[i] != BLACK && d[i] < min){
    min = d[i];
    u = i;
  }
  }


  if(min == inf) break;
  color[u] = BLACK;

  for(v=0;v<n;v++){
    if(color[v] != BLACK && A[u][v] < d[v] && A[u][v] != -1){
    pi[v] = u;
    d[v] = A[u][v];
  }
}
}

  for(i = 0;i < n;i++) sum += d[i];
  return sum;
}

Measured memory_bytes: 632
#include <iostream>
using namespace std;
int dp[100001]={},ar[100001]={};
int main()
{
	int n,k;cin>>n>>k;
	for (int i=0;i<n;i++) {cin>>ar[i];}
	for (int i=0;i<=n;i++) {dp[i] = 1000000000;}
	dp[1]=0;
	for (int i=2;i<=n;i++)
	{
		for (int j=1;j<=min(i-1,k);j++)
		{
			dp[i] = min(dp[i],dp[i-j]+abs(ar[i-1]-ar[i-j-1]));
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
import sys

N = int(input())

a = []

ybl = 0
tbl = 0

for i in range(N):

    A = list(input())

    if "." not in A:
        ybl += 1

    a.append(A)


blexist = False
for j in range(N):

    blnum = 0

    for i in range(N):

        if a[i][j] == "#":
            blexist = True
            blnum += 1

    if blnum == N:
        tbl += 1

#print (blexist,tbl,ybl)

if not blexist:
    print (-1)
    sys.exit()

if ybl != 0:
    print (N - tbl)
    sys.exit()


ans = float("inf")

for i in range(N):

    bexi = False
    for j in range(N):
        if a[j][i] == "#":
            bexi = True
            break

    

    chnum = 0
    for j in range(N):
        if a[i][j] == ".":
             chnum += 1

    if bexi:
        ans = min(ans,chnum + (N - tbl))

    else:
        ans = min(ans,chnum + 1 + (N - tbl))

        

print (ans)


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

ll const INF = 1001001001;
vector<int> const dx = {1, -1, 0, 0};
vector<int> const dy = {0, 0, 1, -1};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> cells(H);
  rep(i, H) cin >> cells[i];

  int ans = 0;
  // i, x縦, j, y横
  rep(i, H) {
    rep(j, W) {
      if (cells[i][j] == '#') continue;

      vector<vector<int> > dist(H, vector<int>(W, INF));
      dist[i][j] = 0;

      queue<P> q;
      q.push(make_pair(i, j));
      while (!q.empty()) {
        P Q = q.front(); q.pop();
        int x = Q.first, y = Q.second;
        int d = dist[x][y] + 1;
        rep(k, 4) {
          int nx = x + dx[k], ny = y + dy[k];
          if (nx >= 0 && nx < H && ny >= 0 && ny < W && cells[nx][ny] == '.'&& dist[nx][ny] == INF) {
            ans = max(ans, d);
            dist[nx][ny] = d;
            q.push(make_pair(nx, ny));
          }
        }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::vector;
using std::cin;
using std::map;
using std::multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll n;
	cin >> n;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	vector<bool> flg(n, false);
	set<ll> s;
	REPC(x, v) {
		if (x == 1) {
			s.emplace(0);
		} else if (!flg[x - 2]) {
			s.emplace(x - 1);
		}
		flg[x - 1] = true;
	}

	ll max = 0;
	ll tmp = 0;
	REPC(x, s) {
		max = std::max(max, x - tmp);
		tmp = x;
	}
	cout << ((max == 0) ? 0 : n - max) << endl;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define ll long long
#define MAX 100000000
#define INF 1000000
#define M 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
  fast_io
   ll a;
   cin>>a;
   ll ans = a*(1+(a*a)+a);
   cout<<ans<<endl;
   return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;

	int value = 0;
	int cost = 0;

	vector<int> v(21, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector<int> c(21, 0);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		if (c[i] < v[i]) {
			value += v[i];
			cost += c[i];
		}
	}



	cout << value-cost << endl;
}

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

int main(void)
{
  int N; std::cin >> N;
  std::vector<int> d(N);
  int half = N / 2 - 1;
  
  for (int i = 0; i < d.size(); i++) {
    std::cin >> d[i];
  }
  
  std::sort(d.begin(), d.end());
  
  
  
  std::cout << d[half+1] - d[half] << std::endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long gcd(long a,long b)
{
	if(a%b==0)
	{
		return b;	
	}
	else
	{
		return gcd(b,a%b);	
	}
}
long long lcm(long a,long b)
{
	return (long long)(a*b)/gcd(a,b);
}
int main()
{
	long a,b;
	scanf("%ld %ld",&a,&b);
	printf("%lld",lcm(a,b));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define ld long double


int main(){

int n;
cin>>n;

vector<int> vec(n);
for(int i=0;i<n;i++)
    cin>>vec[i];
    
sort(vec.begin(), vec.end(), greater<int>());

int al=0, bo=0;
for(int i=0;i<n;i++){
    if(i&1)
    bo+=vec[i];
    else
    al+=vec[i];
}
cout<<al-bo;
    
}

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

int main(){
  string s;
  cin >> s;
  string t="";
  int S=s.size();
  long long cnt=0;
  for(int i=0;i<S;i++){
    if(i+1<S && s[i]=='B' && s[i+1]=='C'){t+='D'; i++;}
    else{t+=s[i];}
  }
  int T=t.size();
  for(int i=0;i<T;i++){
    int a=0;
    while(i<T && t[i]!='B' && t[i]!='C'){
      if(t[i]=='A')a++;
      else{cnt+=a;}
      i++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 776
def main():
    x,y,a,b,c=map(int,input().split())
    p=list(map(int,input().split()))
    q=list(map(int,input().split()))
    r=list(map(int,input().split()))
    p.sort(reverse=True)
    q.sort(reverse=True)
    ans=r+p[:x]+q[:y]
    ans.sort(reverse=True)
    print(sum(ans[:x+y]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 23996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll x, y;
    cin >> x >> y;
    if(abs(x-y) > 1)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Brown" << endl;
    }
}


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

using namespace std;

int main(){

	int N;

	cin >> N;

	bool flag = false;

	for(int i = 0;i < N;i++){
		char a;
		cin >> a;
		if(a  == 'Y'){
			flag= true;
		}
	}

	if(flag){
		cout << "Four" << endl;
	}else{
		cout << "Three" << endl;
	}

    return 0;

}


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

  if(b[0] == 'H'){
    if(a[0] == 'H'){
      cout << 'H' << endl;
    }else{
      cout << 'D' << endl;
    }
  }else if(b[0] == 'D'){
    if(a[0] == 'H'){
      cout << 'D' << endl;
    }else{
      cout << 'H' << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  if(K%7==0) {
    K /= 7;
  }
  ll x = 1;
  int ans = 0;
  while(x%K!=0&&ans<K) {
    ans++;
    x = 10*x+1;
    x %= K;
  }
  if(ans==K) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans+1 << endl;
  return 0;
}

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

int main(){
  int N, K, x, sum=0;
  cin >> N >> K;
  for (int i=0; i<N; i++){
    cin >> x;
    if (x <= K-x) sum += 2*x;
    else sum += 2*(K-x);
  }
  cout << sum << endl;
}

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);



void solve1()
{
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    while( n > 0 ){
        ans += 1;
        n /= k;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		if (N == 0) {
			System.out.println(X);
			return;
		}
		for (int i = 0; i < N; i++) {
			int pi = sc.nextInt();
			list.add(pi);
		}
		if (!list.contains(X)) {
			System.out.println(X);
			return;
		}
		Collections.sort(list);
		int Xb = X;
		int Xs = X;
		while (true) {
			int Xbi = Xb+1;
			int Xsm = Xs-1;
			if (!list.contains(Xs)) {
				System.out.println(Xs);
				return;
			}
			if (!list.contains(Xb)) {
				System.out.println(Xb);
				return;
			}
			Xb = Xbi;
			Xs = Xsm;
		}
	}
}

Measured memory_bytes: 36072
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;

int main()
{
	int N; cin >> N;
	vec W(N);

	int total = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> W[i];
		total += W[i];
	}

	int tmp = 0;
	int ans = 1000000;
	for (int i = 0; i < N - 1; ++i)
	{
		tmp += W[i];
		ans = min(abs(2 * tmp - total), ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
L_1 = [l[0]+l[1] for l in L]
L_2 = [(10**9+1-l[0])+l[1] for l in L]
L_3 = [(10**9+1-l[1])+l[0] for l in L]
L_4 = [(10**9+1-l[0])+(10**9+1-l[1]) for l in L]
L_1.sort()
a = L_1[-1]-L_1[0]
L_2.sort()
b = L_2[-1]-L_2[0]
L_3.sort()
c = L_3[-1]-L_3[0]
L_4.sort()
d = L_4[-1]-L_4[0]
print(max(a,b,c,d))

Measured memory_bytes: 77876
program sample
	implicit none
    integer :: x,y
    
    read(*,*) x
    read(*,*) y
    
    if (x==1 .and. y==2) then
    	write(*,*) 3
    else if (x==1 .and. y==3) then
    	write(*,*) 2
    else if (x==2 .and. y==1) then
    	write(*,*) 3        
    else if (x==2 .and. y==3) then
    	write(*,*) 1        
    else if (x==3 .and. y==1) then
    	write(*,*) 2        
    else if (x==3 .and. y==2) then
    	write(*,*) 1        
	end if

    stop
end program sample

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    Graph G(N);
    rep(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> dist(N,INF);
    queue<int> Q;
    Q.push(0);
    dist[0] = 0;
    while(!Q.empty()){
        int v = Q.front();
        Q.pop();
        for(auto nv: G[v]){
            if(dist[nv]>dist[v]+1){
                dist[nv]=dist[v]+1;
                Q.push(nv);
            }
        }
    }

    vector<ll> dist1(N,INF);
    queue<int> Q1;
    Q1.push(N-1);
    dist1[N-1] = 0;
    while(!Q1.empty()){
        int v = Q1.front();
        Q1.pop();
        for(auto nv: G[v]){
            if(dist1[nv]>dist1[v]+1){
                dist1[nv]=dist1[v]+1;
                Q1.push(nv);
            }
        }
    }
    int f = 0, s = 0;
    rep(i,N){
        if(dist[i]<=dist1[i])f++;
        else s++;
    }
    if(f>s)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 10372
def f(x)
  if x==1
    return "-"
  else
    return "+"
  end
end
n = gets.strip.chars.map(&:to_i)
ary = []
[0, 1].repeated_permutation(3) do |bits|
  sum = n[0]
  for i in 0..2
    if bits[i] == 1
      sum -= n[i+1]
    else
      sum += n[i+1]
    end
  end
  if sum == 7
    ary << [n[0],f(bits[0]),n[1],f(bits[1]),n[2],f(bits[2]),n[3],"=",7].to_a
  end
end
print ary[0].join("")

Measured memory_bytes: 14364
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    d = I()
    ans = [" Eve"]*(25-d)
    print("Christmas",end = "")
    for i in ans:
        print(i,end = "")
    print()
    return

#B
def B():
    return

#C
def C():
    n,k = LI()
    h = IR(n)
    h.sort()
    ans = float("inf")
    for i in range(n-k+1):
        ans = min(ans,h[i+k-1]-h[i])
    print(ans)

#D
def D():
    n,x = LI()
    l = [1 for i in range(n+1)]
    for i in range(n):
        l[i+1] = 2*l[i]+3
    p = [1 for i in range(n+1)]
    for i in range(n):
        p[i+1] = 2*p[i]+1
    ans = 0
    for i in range(1,n+1)[::-1]:
        if i == 1:
            if x == 5:ans += 3
            else:ans += max(0,x-1)
        else:
            if x == 0:continue
            if x == l[i]:
                ans += p[i]
                x = 0
            if x > l[i-1]+1:
                ans += p[i-1]+1
                x -= l[i-1]+2
            else:
                x -= 1
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			// ???????????°N
			int N = sc.nextInt();
			if (N == 0)
				break;
			
			// ???????????´??????????´????????????????(x,y)???????´?
			List<Integer> x = new ArrayList<Integer>(N);
			List<Integer> y = new ArrayList<Integer>(N);
			for (int i = 0; i < N; i++) {
				x.add(sc.nextInt());
				y.add(sc.nextInt());
			}
			// ??????????????°M
			int M = sc.nextInt();
			
			// ???????????¢?´¢?????????????????????
			exploler(M, x, y);
		}
	}
	
	//???????????¢?´¢??????????????????
	static public void exploler(int M, List x, List y) {
		// ???????????????????¨????
		Integer xPlace = 10;
		Integer yPlace = 10;
		
		for (int i = 0; i < M; i++) {
			// ????§?/?????¢ d/l
			String d = sc.next();
			int l = sc.nextInt();
			// ????§????1??????????????§???????????????????????????????????????????????¢?????°????????????
			for (int j = 0; j < l; j++) {
				if (d.equals("N")) {yPlace++;}
				if (d.equals("S")) {yPlace--;}
				if (d.equals("E")) {xPlace++;}
				if (d.equals("W")) {xPlace--;}
				// ??????????????????????????????????????????recJuwels
				recJuwels(xPlace, yPlace, x, y);
			}
		}
		//???????°??????????????????????
		if (x.size() == 0) {
			System.out.println("Yes");}
		else {System.out.println("No");
		}
	}
	
	
//?????????????????????????????????????????????recoveryJuwels
	public static void recJuwels(Integer xPlace, Integer yPlace, List x,List y) {
		//???????????´?????¨?????????????????´???????????´?????????????????????????????°??????????????????
		for (int k = 0; k < x.size(); k++) {
			//?????´??????????????°???List??????????????????(????????????????????????????????£???????????°Yes??????)
			if (xPlace == x.get(k) && yPlace == y.get(k)) {
				x.remove(k);
				y.remove(k);
			}
		}
	}
}

Measured memory_bytes: 42912
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cins(int, 2, n);
    Cout((n[0]+n[1]+1)/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    string S;
    cin >> S;

    size_t N = S.size();
    int ans = 0;

    for (size_t i = 0; i < N - 1; ++i) {
        if (S[i] == S[i+1]) {
            S[i+1] = (S[i] == '0') ? '1' : '0';
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  vector<vector<bool>> adj(n,vector<bool>(n,false));
  vector<int> v(n);
  
  for ( int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    adj.at(a).at(b) = adj.at(b).at(a) = true;
  }
  
  for ( int i = 0; i < n; i++){
    v[i] = i;
  }
  
  int ans = 0;
 
  do{
      bool ok = true;
    for(int i = 1; i < n ; i++){
      if (adj.at(v.at(i-1)).at(v.at(i))== false){
        ok = false;
        break;
      }
    }
    if ( ok ) ans++;
  } while ( next_permutation(++v.begin(),v.end()));
  
  cout  << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
X = sorted(list(map(int,input().split())))
ans = 10**9
tmp = 0
for i in range(X[0],X[-1]+1):
  for j in range(n):
    tmp += (X[j]-i)**2
  ans = min(ans,tmp)
  tmp = 0
  
print(ans)

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)-sum(b)
if s<0:
    print(-1)
else:
    c=[0]*n
    po=0
    ze=0
    ne=0
    nc=0
    for i in range(n):
        c[i]=a[i]-b[i]
        if c[i]>0:
            po+=c[i]
        elif c[i]<0:
            ne-=c[i]
            nc+=1
        else:
            ze+=1
    ans=0
    c=sorted(c)
    for i in range(n-1,-1,-1):
        if ne>0:
            ans+=1
        if c[i]>0:
            ne=ne-c[i]
        
    print(nc+ans) 
        


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

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

    int num = 0;

    for(int i = 0; i <= D ; i++){
        if((i/10 >= 2) && (i%10 >= 2) && ((i/10)*(i%10) <= M)){
            num ++;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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 (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll r;
    cin >> r;
    print(3 * r * r);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std; int l[100000]; int k[100000];
int main(){
	int n; cin >> n; int z; cin >> z;
	for (int i=0; i<n; i++){
	 	cin >> l[i];
	}
	int zb=0; k[0]=0; k[1]=abs(l[0]-l[1]); 
	for (int i=2; i<n; i++){
		int d=i-z;
		if (d<0) d=0; 
		int ma=1e4*n;
		for(int j=d; j<i; j++){
			ma=min(ma,k[j]+abs(l[i]-l[j]));
		}
		k[i]=ma;
	}
	cout << k[n-1];
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
ll a[52];

ll calc(){
  ll ans = 0;
  while(true){
    ll add = 0;
    REP(i,n){
      ll sub = a[i]/n;
      a[i] -= sub*(n+1);
      add += sub;
    }
    if(add==0)break;
    ans += add;
    REP(i,n)a[i]+=add;
  }
  return ans;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%lld",a+i);
  ll ans = calc();
  printf("%lld\n",ans);
  return 0;
}


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

/*
最短経路をもとめて、経路上以外の.のマスの数を求めればよい.
グリッド上の'.'の数 - 最短経路で通った'.'の数

ゴールにたどり着けない場合は-1を出力。
*/

const int INF = 1e9;
typedef pair<int, int> P;

vector<int> di = {1, 0, -1, 0};
vector<int> dj = {0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<char>> maze(H, vector<char>(W));
    int num_white = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            char c; cin >> c;
            maze[i][j] = c;

            if (c == '.') {
                num_white++;
            }
        }
    }
    num_white -= 2; // distract for start and goal white

    // init dist
    vector<vector<int>> dist(H, vector<int>(W, INF));

    // init start
    dist[0][0] = 0;
    queue<P> que;
    que.push(P(0, 0));

    // BFS
    while (que.size() > 0)
    {
        P p = que.front(); que.pop();

        // goal break
        if (p.first == H-1 && p.second == W-1) {
            break;
        }

        for (int i = 0; i < 4; i++)
        {
            int ni = p.first + di[i];
            int nj = p.second + dj[i];

            if (0 <= ni && ni < H && 0 <= nj && nj < W) {
                if (maze[ni][nj] != '#' && dist[ni][nj] == INF) {
                    que.push(P(ni, nj));
                    dist[ni][nj] = dist[p.first][p.second] + 1;
                }
            }
        }
    }

    int goal_dist = dist[H - 1][W - 1];
    if (goal_dist == INF) {
        cout << -1 << endl;
    }
    else {
        goal_dist--; // distract for moving to goal
        cout << num_white - goal_dist << endl;
    }
    


}

Measured memory_bytes: 3612
/*
 * 	If I got locked away
 * 		And we lost it all today
 * 			Tell me honestly 
 * 				Would you still love me the same?
*/

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&


void solve(){
    string s; cin >> s;
    for(int i = 0; i < sz(s); ++i){
        if(s[i] == '?')
            cout << "D";
        else 
            cout << s[i];
    }
    cout << '\n';
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        solve();
    }
    return 0;
}

/*
Sample inp
*/

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	int n, W;
	cin >> n >> W;
	VEC v(n, 0), w(n, 0);
	loop(i, n)
	{
		cin >> v[i] >> w[i];
	}
	VEC2 dp(n, VEC(W + 1, -1));
	dp[0][0] = 0;
	dp[0][w[0]] = (w[0] <= W ? v[0] : 0);
	loops(i, 1, n)
	{
		loop(j, W + 1)
		{
			if (dp[i - 1][j] != -1)
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j]);
				if (j + w[i] <= W)
				{
					dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
				}
			}
		}
	}
	/*------------------------------------------------------------------
	loop(i, n)
	{
		loop(j, W + 1)
		{
			cout << "dp[" << i << "][" << j << "]" << ": " << dp[i][j] << " , ";
		}
		cout << endl;
	}
	*/
	int ans = -1;
	loop(i, W+1)
	{
		ans = max(ans, dp[n - 1][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6840
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int a,b;cin>>a>>b;
	int sum=0;
	fo0(i,b){
		int c;cin>>c;
		sum+=c;
	}
	if(sum>=a)
		cout<<"Yes"<<endl;
	else
		cout<<"No";
}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
S=input()
N=len(S)
comp1=""
comp2=""
count1=0
count2=0
for i in range(N):
    if i%2==0:
        comp1+="1"
        comp2+="0"
    else:
        comp1+="0"
        comp2+="1"
for i in range(N):
    if comp1[i]!=S[i]:
        count1+=1
    else:
        count2+=1
print(min(count1,count2))

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


int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(d == 1) cout << 1 << endl;
    else cout << 0 << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

signed main()
{   
    gearup;
    string s; cin >> s;
    cout << (s=="ABC"?"ARC":"ABC") << endl;
}


Measured memory_bytes: 3640
#昔はtleの回答、今は通る？
import sys
input=sys.stdin.readline
n=int(input())
lists=list(map(int,input().split()))
aa=[0 for i in range(n)]
bb=[0 for i in range(n)]
length=61
use=[0 for i in range(61)]
for  j in range(n):
    k=format(lists[j],"0%ib"%length)
    k=k[::-1]
    aa[j]=k[:30]  
    bb[j]=k[30:]
for p in aa:    
    for some in range(30):
        use[some]+=int(p[some])
for q in bb:    
    for some in range(31):
        use[some+30]+=int(q[some])
answer=0

for j in range(61):
    answer+=(2**j)*use[j]*(n-use[j])%(10**9+7)
print(answer%(10**9+7))


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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = (B - 1) / (A - 1); // 初期状態が1個 B-1個増やしたい. 1つ増やすごとにA-1個増える
	if ((B - 1) % (A - 1) != 0) { // (B-1)/(A-1)の切り上げを計算 !=0 いらん.
		ans++;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 596
function Main(input) {
  input = parseInt(input);
  var s =0;
  var s2 = 0;
  for(var i=0; s<input; i++){
    s=s+i;
    s2=i;

  }

  console.log('%s', s2);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int n;
    cin >> n;
    printf("%.20lf\n", (1.0 / n) * (n - (n >> 1)));
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0 ; i < 2 ; i++) {
			if(s.charAt(i) == '9') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);

const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}


int main2() {
  int N = nextInt();
  int K = nextInt();
  ll ans = 0;
  for (int k = 0; k <= K; k++) {
    int sign = k % 2 == 0 ? +1 : -1;
    ans += sign * choose(K, k) * mod_pow(K - k, N, MOD);
    ans = (ans % MOD + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  {
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
  }

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}



Measured memory_bytes: 10588
a, b = map(int, input().split())
result = ""

if a == b:
    for i in range(a):
        result += str(a)

    print(result)
elif a < b:
    for i in range(b):
        result += str(a)

    print(result)
elif a > b:
    for i in range(a):
        result += str(b)

    print(result)



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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

vector<int32> a;
int64 ans = 0;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  a.resize(n);
  REP(i,n)cin >> a[i];
  vector<int32> pos(n,-1);
  REP(i,n)pos[a[i]-1] = i;
  set<int32> used;
  used.insert(-1);
  used.insert(n);
  REP(i,n){
    ans += (i+1) * (pos[i] - *(--used.lower_bound(pos[i]))) * (*used.lower_bound(pos[i]) - pos[i]);
    // ANS((pos[i] - *(--used.lower_bound(pos[i]))) * (*used.lower_bound(pos[i]) - pos[i]));
    used.insert(pos[i]);
  }
  ANS(ans);
  return 0;
}

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

  
int main(){
  int n,m,x,y;
  cin >> n >> m >> x >>y;
  VI xx(n);
  VI yy(m);
  rep(i,n){
    cin >> xx.at(i);
  }
  rep(i,m){
    cin >> yy.at(i);
  }
  bool a=false;
  bool b=false;
  int xmax=-500;
  int ymin=500;
  rep(i,n){
    xmax=max(xmax,xx.at(i));
  }
  rep(i,m){
    ymin=min(ymin,yy.at(i));
  }
  if(xmax < y && xmax < ymin) a=true;
  if(x< y && x<ymin) b=true;
  
  if(a && b) cout << "No" << " " << "War" <<endl;
  else cout << "War" <<endl;
  
}
  

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	a := make([]int, n, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		tmp, _ := strconv.Atoi(sc.Text())
		a[i] = tmp
	}

	sort.Ints(a)

	answer := "YES"
	for i := 1; i < n; i++ {
		if a[i-1] == a[i] {
			answer = "NO"
		}
	}

	fmt.Println(answer)
}


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

using namespace std;

const int maxn=114514;
struct node{
	int to,nxt,id;
}tr[maxn<<1];int tot=0,head[maxn];
inline void addedge(int u,int v,int id){
	tr[++tot].to=v;
	tr[tot].id=id;
	tr[tot].nxt=head[u];
	head[u]=tot;
}

int ans[maxn];
int mxans=0;
inline void dfs(int u,int fa,int col){
	int now=1;
	for(int i=head[u];i;i=tr[i].nxt){
		int to=tr[i].to;
		if(to==fa) continue;
		if(now==col) now++;
		ans[tr[i].id]=now;
		dfs(to,u,now);
		now++;
	}
}

int in[maxn],n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		in[u]++,in[v]++;
		addedge(u,v,i);addedge(v,u,i);
	}
	int mxid;
	for(int i=1;i<=n;i++){
		if(mxans<in[i]){
			mxans=in[i];
			mxid=i;
		}
	}
	printf("%d\n",mxans);
	dfs(mxid,0,0);
	for(int i=1;i<n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3968
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N =5e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
vector<int> g[5];
char s[N];
int main(){
    int n = read();
    scanf("%s",s+1);
    rep(i,1,n){
        if(s[i] == 'R') g[1].push_back(i);
        else if(s[i] == 'G') g[2].push_back(i);
        else g[3].push_back(i);
    }
    ll ans = 0;
    rep(i,1,n-2){
        rep(j,i+1,n-1){
            if(s[i]!=s[j]){
                int d = j - i;
                int l = 0,r ;
                int op = 1;
               // cout<<i<<' '<<j<<endl;
                if(s[i]!='R'&&s[j]!='R') op = 1;
                else if(s[i]!='G'&&s[j]!='G') op = 2;
                else if(s[i]!='B'&&s[j]!='B') op = 3;
                int sz = g[op].size();
                r = sz;
                while(l < r){
                    int mid = l + r >> 1;
                    if(g[op][mid] > j) r = mid;
                    else l = mid + 1;
                }
                if(r != sz) {
					ans += sz - r;
                	if(j+d<=n&&s[j+d]!=s[i]&&s[j+d]!=s[j]) ans --;
            	}
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3696
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int sum=0;
        while(n--){
            int s=0,h;
            for(int i=0;i<3;i++){
                int l;
                scanf("%d",&l);
                s+=l;
            }
            scanf("%d",&h);
            if(s<=60&&h<=2)sum+=600;
            else if(s<=80&&h<=5)sum+=800;
            else if(s<=100&&h<=10)sum+=1000;
            else if(s<=120&&h<=15)sum+=1200;
            else if(s<=140&&h<=20)sum+=1400;
            else if(s<=160&&h<=25)sum+=1600;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1032
var out = function(x) {
  console.log(x);
  return x;
}

var mult = function(a,b) {
  return a * b;
  }

var calc = function(a,b) {
  return a*2 + b*2;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
  var area = input.split(' ').map(Number).reduce(mult);
  var len = input.split(' ').map(Number).reduce(calc);
  out(area + ' ' + len);
});

Measured memory_bytes: 7644
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
T, A = MAP()
H = LIST()

tmp = [T-x*0.006 for x in H]
# print(tmp)
y = 100000000
i_tmp = 0
for i, data in enumerate(tmp):
	if abs(data - A) < y:
		y = abs(data - A)
		i_tmp = i+1

print(i_tmp)


Measured memory_bytes: 4200