akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val r = sc.nextLong()
  val s = sc.nextLong()
  val p = sc.nextLong()
  val t = sc.next()


  val array = CharArray(n)
  val score = LongArray(n)
  for ((i, ti) in t.withIndex()) {
    if (ti == 'r') {
      array[i] = 'p'
      score[i] = p
    }
    if (ti == 's') {
      array[i] = 'r'
      score[i] = r
    }
    if (ti == 'p') {
      array[i] = 's'
      score[i] = s
    }
  }

  // println(array.joinToString(""))
  // println(score.joinToString(""))

  for (i in k until n) {
    val pre = array[i-k]
    val now = array[i]


    if (pre == now) {
      var next = 'x'
      if (i+k < n) {
        next = array[i+k]
      }
      var tmp = 'x'
      if (now == 'r') {
        if (next == 'r') tmp = 'x'
        if (next == 's') tmp = 'p'
        if (next == 'p') tmp = 's'
      } else if (now == 's') {
        if (next == 'r') tmp = 'p'
        if (next == 's') tmp = 'x'
        if (next == 'p') tmp = 'r'
      } else if (now == 'p') {
        if (next == 'r') tmp = 's'
        if (next == 's') tmp = 'r'
        if (next == 'p') tmp = 'x'
      }
      
      array[i] = tmp
      score[i] = 0
    }
  }

  // println(array.joinToString(""))
  // println(score.joinToString(""))
  println(score.sum())


}


Measured memory_bytes: 44740
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int a, b, c; cin >> a >> b >> c;
	int maxx = max({ a,b,c });
	if ((maxx*3-a - b - c) % 2==1) maxx++;
	cout << (maxx*3 - a - b - c) / 2<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
X=input()

def popcnt(x):
    n=x
    res=0
    while n>0:
        res+=n%2
        n//=2
    return res

table=[0,1]+[-1 for i in range(219998)]
for i in range(2,220000):
    table[i]=table[i%popcnt(i)]+1

moto=0
for i in range(N):
    if X[i]=='1':
        moto+=1

plus=0  #もとの数字に1のときのmodをしたやつ
minus=0

for i in range(N):
    plus+=int(X[i])*pow(2,N-1-i,max(1,moto-1))
    minus+=int(X[i])*pow(2,N-1-i,moto+1)
    plus%=(max(1,moto-1))
    minus%=(moto+1)

for i in range(N):
    ans=0
    if X[i]=='1':
        ans=plus
        ans-=pow(2,N-1-i,max(1,moto-1))
        ans%=(max(1,moto-1))
        if moto==1:
            ans=-1
    else:
        ans=minus
        ans+=pow(2,N-1-i,moto+1)
        ans%=(moto+1)
    if ans==-1:
        print(0)
    else:
        print(table[ans]+1)

Measured memory_bytes: 12952
#!/usr/bin/env pypy3

import itertools
# import sys


def count_triplets(n, s):
    rs = [i for i in range(n) if s[i] == "R"]
    gs = [i for i in range(n) if s[i] == "G"]
    bs = [i for i in range(n) if s[i] == "B"]
    rgbs = [rs, gs, bs]
    gt_rs = [sum(r >= i for r in rs) for i in range(n + 2)]
    gt_gs = [sum(r >= i for r in gs) for i in range(n + 2)]
    gt_bs = [sum(r >= i for r in bs) for i in range(n + 2)]
    gts = [gt_rs, gt_gs, gt_bs]
    m = 3
    res = 0
    for col1, col2 in itertools.combinations(range(m), r=2):
        col3 = m - col1 - col2
        for r, g in itertools.product(rgbs[col1], rgbs[col2]):
            if r >= g:
                r, g = g, r
            res += gts[col3][g + 1]
            if 0 <= 2 * g - r < n:
                res -= gts[col3][2 * g - r]
                res += gts[col3][2 * g - r + 1]
    return res


def main():
    n = int(input())
    s = input()
    res = count_triplets(n, s)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71496
#include<stdio.h>
#define mc 999999999
#define pc -1000000000

int main(){
  long long i,j,h,w,sh,sw,v,t=0,p,q;
  long long arr[512][512]={0};
  scanf("%lld%lld%lld%lld",&h,&w,&sh,&sw);
  if(h==sh && w==sw){
    printf("No\n");return 0;
  }
  if(sh==1 && sw==1){
    printf("No\n");return 0;
  }
  v=-(sh*sw);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      p=i%sh;
      if(p==0){p=sh;}
      q=j%sw;
      if(q==0){q=sw;}
      if(p==1 && q==1){
        arr[i][j]=mc;
        t+=mc;
      }
      else if(p==sh && q==sw){
        arr[i][j]=pc;
        t+=pc;
      }
      else{arr[i][j]=0;}
    }
  }
  if(t<=0){printf("No\n");return 0;}
  printf("Yes\n");
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(j!=1){printf(" ");}
      printf("%lld",arr[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve()
{
	int n, k;
	cin >> n >> k;
	s32 bst;
	for (int i = 1; i < n + 1; i++)
		bst.insert(i);
	for (int i = 0; i < k; i++)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int item;
			cin >> item;
			auto itr = bst.find(item);
			if (itr != bst.end())
				bst.erase(itr);
		}
	}
	cout << sz(bst) << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll long long
#define P pair<int ,int>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>>edge(n ,vector<int> (n,1));
    for(int i=0;i<n;i++) edge[i][i] = 0;
    int sum = (n * (n-1))/ 2;
    if(n % 2 == 1){
        for(int i=0;i< n/2 ;i++){
            edge[i][n-i-2] = 0;
            sum--;
        }
    }
    if(n % 2 == 0){
        for(int i=0;i<n/2;i++){
            edge[i][n-i-1] = 0;
            sum--;
        }
    }

    cout << sum << endl;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(edge[i][j]) cout << i+1 << " " <<  j+1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int kazu[100]={0},n;
	int a,b;

	scanf("%d",&n);

	for(a=0;a<n;a++)
	{
		scanf("%d",&kazu[a]);
	}

	for(b=0;b<n;b++)
	{
		if(b)printf(" ");
		printf("%d",kazu[n-b-1]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 600
# 問題：https://atcoder.jp/contests/abc137/tasks/abc137_a

a, b = map(int, input().strip().split())

if a + b < a - b:
    if a - b < a * b:
        print(a * b)
    else:
        print(a - b)
else:
    if a + b < a * b:
        print(a * b)
    else:
        print(a + b)



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

// https://atcoder.jp/contests/abc105/tasks/abc105_b

string solver(int total){
    string result;
    bool totalF=false; // トータルへ行きついたかどうか
    for(int fourD=0;fourD < 100;fourD++){
        for(int sevenD=0;sevenD < 100;sevenD++){
            int sum = 0;
            sum = fourD * 4 + sevenD * 7;
  //          cout << sum << endl;
            if(sum == total){
                totalF = true;
  //              cout << "End" << endl;
                break;
            }
        }
    } 
    if(totalF){
        result = "Yes";
    }
    else{
    result="No";
    }
    return result;
}

int main(void){
    int N;
    string answer;
    cin >> N;
    answer = solver(N);
    cout << answer << endl;
}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;
char c[100007];
int n, k;
void init() {

}

void solve() {
	scanf("%d %d %s", &n, &k, c);
	if (k >= n) {
		printf("%d\n", n);
		return;
	}
	int MEM[100007];
	MEM[0] = 0;
	int comp = 0;
	for (int i = 0; i < n; i++) {
		if (c[i] == '0' && MEM[comp] <= 0)
			MEM[comp]--;
		else if (c[i] == '1' && MEM[comp] >= 0)
			MEM[comp]++;
		else if (c[i] == '0' && MEM[comp] > 0) {
			comp++;
			MEM[comp] = -1;
		}
		else if (c[i] == '1' && MEM[comp] < 0) {
			comp++;
			MEM[comp] = 1;
		}
	}
	int sum = 0;
	int q = 0;
	if (k >= comp) {
		printf("%d\n", n);
		return;
	}
	int i = 0;
	for (; i <= comp && q < k; i++) {
		if (MEM[i] < 0) {
			q++;
			sum += -MEM[i];
		}
		else sum += MEM[i];
	}
	if (i <= comp && MEM[i] > 0) {
		sum += MEM[i];
		i++;
	}
	int ans = sum;
	int tail = 0;
	for (; i <= comp;) {
		for (;;) {
			if (MEM[tail] < 0) {
				sum -= -MEM[tail++];
				break;
			}
			else sum -= MEM[tail++];
		}
		for (;i <= comp;) {
			if (MEM[i] < 0) {
				sum += -MEM[i++];
				if (i <= comp && MEM[i] > 0)
					sum += MEM[i++];
				break;
			}
			else sum += +MEM[i++];
		}
		ans = max(ans, sum);
	}
	printf("%d\n", ans);
}

const bool mtc = false;

int main() {
	int t;
	if (mtc) {
		scanf("%d", &t);
		while (t--) solve();
	}
	else solve();
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll a, b, k;   cin >> a >> b >> k;
    if(a <= k){
        k -= a;
        a = 0;
        if(b <= k){
            b = 0;
        }else{
            b -= k;
        }
    }else{
        a -= k;
    }
    printf("%lld %lld\n", a, b);
}


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for_each(H.begin(), H.end(), [](int& e) { cin >> e; });
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (all_of(H.begin(), H.begin() + i, [&](int x) { return x <= H[i]; })) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

using namespace std;

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


Measured memory_bytes: 764
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a,b;
    a = Integer.parseInt(sc.next()); b = Integer.parseInt(sc.next());
    if(a==2 || b==2){System.out.println("No");}
    else{System.out.println("Yes");}
  }
}

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

int main() {
	long long int a[11111], sum=0, n;
	
	while(cin>>n&&n){
	sum=0;
	
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	sort(a, a+n);
	
	for(int i=0;i<n-1;i++){
		for(int j=0;j<=i;j++){
			sum+=a[j];
		}
	}
	
	cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;
        
        class Main {
         
            public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                sc.nextLine();
                String S = sc.nextLine();
                sc.close();
                String[] we = S.split("");
                int count = 0;
                
                for(int i = 1; i < N; i++) {
                	if(we[i].equals("E")) {
                		count ++;
                	}
                }
                int min = count;
                for(int j = 1; j < N; j++) {
            		if( we[j-1].equals("W")) {
                		count++;
                	}
            		if( we[j].equals("E")) {
                		count--;
                	}
            		min = Math.min(min, count);	
                }
            	
               System.out.println(min);
            }
        }

Measured memory_bytes: 52948
solve :: Int -> [Int] -> [Int] -> [Int] -> Int
solve n lst_a lst_b lst_c =
  sum [lst_b !! (x - 1) | x <- lst_a] +
  sum [lst_c !! (x - 1) | (x, y) <- zip lst_a (tail lst_a), x + 1 == y]

main :: IO()
main = do
  cont <- getContents
  let [line1, line2, line3, line4] = lines cont
      [s_n] = words line1
      n = read s_n
      s_lst_a = words line2
      s_lst_b = words line3
      s_lst_c = words line4
      lst_a = map read s_lst_a
      lst_b = map read s_lst_b
      lst_c = map read s_lst_c
      answer = solve n lst_a lst_b lst_c
  putStrLn (show answer)


Measured memory_bytes: 764
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 魔力配列のサイズ */
	private static final int N = 10;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			int[][] c = new int[N][N];
			IntStream.range(0, N).forEach(i -> IntStream.range(0, N).forEach(j -> c[i][j] = scanner.nextInt()));
			int[][] a = new int[h][w];
			IntStream.range(0, h).forEach(i -> IntStream.range(0, w).forEach(j -> a[i][j] = scanner.nextInt()));
			// 魔力の最短ルートの再計算
			warshallFloyd(c, N);
			System.out.println(IntStream.range(0, h)
					.map(i -> IntStream.range(0, w).filter(j -> a[i][j] != -1).map(j -> c[a[i][j]][1]).sum()).sum());
		}
	}

	/**
	 * ノード関の移動コストを計算する
	 * 
	 * @param costs ノード関の移動コストの配列
	 * @param n     ノードの総数
	 */
	private static void warshallFloyd(int[][] costs, int n) {
		IntStream.range(0, n).forEach(k -> IntStream.range(0, n).forEach(j -> IntStream.range(0, n)
				.forEach(i -> costs[i][j] = Math.min(costs[i][j], costs[i][k] + costs[k][j]))));
	}
}


Measured memory_bytes: 58660
import java.util.*;


class Main{
  
     
  
  
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      
      int cnt5 = 0;
      int cnt7 = 0;
      for(int i=0;i<3;i++){
      	int n = sc.nextInt();
        if(n==5){
        	cnt5++;
        } else if(n==7){
        	cnt7++;
        }
      }
      
      if(cnt5==2 && cnt7==1){
      	System.out.println("YES");
      } else System.out.println("NO");
      
	}
}

Measured memory_bytes: 35648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    string S;
    cin >> S;
    rep(i, S.size() - 1)
    {
        if (S[i] == S[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<vector>
#include<queue>
#include <cstring>
#include<algorithm>
#include<set>
#define MAX_V 100001
#define INF 1000000000000000000
typedef long long ll;
struct edge{int from, to;ll cost;};
using namespace std;

int visit[MAX_V];

set<int> se;

edge es[5001];

ll d[2501];

int V,E;

bool shortest_path(int s){
    for(int i=0;i<=V;i++){
        d[i]=INF;
    }
    d[s]=0;
    ll res;
    for(int j=0;j<2*V;j++){
        bool update = false;
        if(j==V) res=d[V];
        for(int i=0;i<E;i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from]+e.cost){
                d[e.to] = d[e.from]+e.cost;
                update=true;
            }
        }
        if(!update){
            return false;
        }
    }
    if(res==d[V]){
        return false;
    }
    else{
        return true;
    }
}

int main(){
    ll p;
    scanf("%d %d %lld",&V,&E,&p);
    for(int i=0;i<E;i++){
        scanf("%d %d %lld",&es[i].from,&es[i].to,&es[i].cost);
        es[i].cost-=p;
        es[i].cost*=-1;
    }
    if(shortest_path(1)){
        printf("-1\n");
    }
    else{
        printf("%lld\n",max(0LL,-d[V]));
    }
}

Measured memory_bytes: 384
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=2750
etemp=100
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.95:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(1)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)


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

#define INF (1000000000+1)

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	vector<int> dp( N, INF );
	for( int i = N - 1; i >= 0; i-- ) {
		*lower_bound( dp.begin(), dp.end(), A[i], []( int a, int b ) { return a <= b; } ) = A[i];
	}
	int ans = lower_bound( dp.begin(), dp.end(), INF ) - dp.begin();

	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		String S = next();
		String T = next();
		int result = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) != T.charAt(i))result++;
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 30780
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string A,B,C; cin >> A >> B >> C;
    if(A[A.size()-1] == B[0] && B[B.size()-1]==C[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
int main(){
    int n,m;
    cin >> n >> m;
    int k,s;
    int mod[10];
    vector<vector<int>> light(10);
    rep(i,m){
        cin >> k;
        rep(j,k){
            cin >> s;
            light[i].push_back(s-1);
        }
    }
    rep(i,m) cin >> mod[i];
    int ans = 0;
    int c,cnt;
    rep(i,1<<n){
        c = 0;
        rep(j,m){
            cnt = 0;
            for(int l:light[j]){
                if (i&(1<<l)) cnt++;
            }
            if (cnt%2 == mod[j]) c++;
        }
        if (c == m) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char a[3];
    
    scanf("%s", a);
    
    rep(i, 3){
        if (a[i]=='1') {
            a[i]='9';
        } else if (a[i]=='9') {
            a[i]='1';
        }
    }
    
    printf("%s", a);
    
    return 0;
}



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

using namespace std;

int main() {
    map<string,int>mp;
    string st;
    int n, res, tmp = 0 , sm = 0;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>st>>tmp;
        sm += tmp;
        mp[st] = sm;
    }
    cin>>st;
    cout<<sm - mp[st]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		String line[] = sc.nextLine().split("");
		sc.close();
		boolean isFifty = true;

		String char1 = null,char2 = null;
		int charCnt1 = 0,charCnt2 = 0;

		for(String s : line) {
			if(char1 == null || char1.equals(s)) {
				char1 = s;
				charCnt1++;
			}else if(char2 == null || char2.equals(s)) {
				char2 = s;
				charCnt2++;
			}else {
				isFifty = false;
				break;
			}

			if(charCnt1 > 2 || charCnt2> 2) {
				isFifty = false;
				break;
			}
		}

		System.out.println(isFifty ? "Yes" : "No");
	}
}


Measured memory_bytes: 23124
h, w, k = map(int, input().split())
c_ij = [list(map(str, input().split())) for i in range(h)]
ans = 0
for x in range(2 ** h):
    for y in range(2 ** w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if x >> i & 1 == 0 or y >> j & 1 == 0 : continue
                if c_ij[i][0][j] == "#": cnt += 1
        if cnt == k: ans += 1
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int mod=1e9+7,maxn=1e5+10;
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
int sum[maxn],a[maxn];
int main(){
	int n=read();
	int ans=0,fac=1;
	REP(i,1,n) sum[i]=(sum[i-1]+ksm(i,mod-2))%mod,fac=(ll)i*fac%mod;
	REP(i,1,n){
		int x=read();
		ans=(ans+(ll)(sum[i]+sum[n-i+1]-1)*x)%mod;
	}
	printf("%lld\n",(ll)ans*fac%mod);
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	int n,i,min,k,j,count=0,s_len,t_len,max=0;
  char s[10000],t[10050];
scanf("%s",s);
scanf("%s",t);
  
  s_len=W_Length(s);
  t_len=W_Length(t);
  
  if(s_len==t_len){
    
     for(j=0;j<t_len;j++){
    //printf("%d %d\n",i+j, j);
    //printf("%c %c\n",s[i],t[0]);
    if(s[j+i]==t[j]){
      count++;
    }
  }
  //printf("%d\n",count);
  if(count>=max){
      max=count;
    }
    
    printf("%d",t_len-max);
    return 0;
  }
 
for(i=0;i<s_len-t_len;i++){
  count=0;
  for(j=0;j<t_len;j++){
    //printf("%d %d\n",i+j, j);
    //printf("%c %c\n",s[i],t[0]);
    if(s[j+i]==t[j]){
      count++;
    }
  }
  //printf("%d\n",count);
  if(count>=max){
      max=count;
    }
}
  
  printf("%d",t_len-max);
return 0;
}


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

using namespace std;

int main()
{
   int n;
   cin >> n;
   int w[n];
   for(int i=0;i<n;i++){
    cin >> w[i];
   }
   int ans=100000;
   for(int i=1;i<=n;i++){
        int l=0,r=0;
        for(int j=1;j<=n;j++){
            if(j<=i){
                l+=w[j-1];
            }
            else r+=w[j-1];
        }
        ans=min(ans,abs(l-r));
   }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = {Integer.parseInt(scan.next()), Integer.parseInt(scan.next()), Integer.parseInt(scan.next())};
		Arrays.sort(array);
		System.out.println(array[0] + " " + array[1] + " " + array[2]);
		scan.close();
	}
}


Measured memory_bytes: 26196
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int a,b;
  int c=1;
  int d;
  int i;
  int count=2;
  
  scanf("%d %d", &a, &b);
  if (b/10!=0){
    c=2+b/100;
  }
  if (c==1){
    d=a*10+b;
  } else if (c==2){
    d=a*100+b;
  } else {
    d=a*1000+b;
  }

  for (i=2; i<d; ++i){
    if (d%i==0){
      ++count;
    }
  }

  if (count%2==1){
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}


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

    char ch;
    cin>>ch;
    if(ch=='A'){
        cout<<"T"<<endl;
    }

    else if(ch=='T'){
        cout<<"A"<<endl;
    }

    else if(ch=='C'){
        cout<<"G"<<endl;
    }

    else if(ch=='G'){
        cout<<"C"<<endl;
    }

}


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

#define   ll    long long int

int main( )
{
    ll n, k, d;
    cin >> n >> k;
    d = (n / k);
    n = n - k * d;
    cout << min(abs(n - k), abs(abs(n - k) - k)) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;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;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=15;
char ch[MAXN];
int main()
{
	scanf("%s",ch+1);
	if(ch[1]=='S')puts("Cloudy");
	else if(ch[1]=='C')puts("Rainy");
	else puts("Sunny");
	return 0;
}


Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var ab=arr.shift().split(" ").map(Number);
var a=ab[0];
var b=ab[1];
if(b== undefined)b=arr.shift()-0;
var A=arr.shift().split(" ").map(Number);
var B=arr.shift().split(" ").map(Number);
var max=0;
for(var i=0;i<b;i++){
   var j=0;
   var k=i;
   var cnt=0;
   while(true){
      if(a<=j || b<=k)break;
      if(B[k]==A[j]){k++;cnt++;}
      j++;
   }
   max=Math.max(max,cnt);
}
console.log(max);

Measured memory_bytes: 17916
import java.util.Scanner;
 class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
 
        if (a < b){
        	if(b<c){
        		System.out.printf("%d %d %d\n",a,b,c);

        	}
        	else if(c<a){
        		System.out.printf("%d %d %d\n",c,a,b);

        	}
        	else{
        		System.out.printf("%d %d %d\n",a,c,b);

        	}
        	    
        }
        else{
        	        	if(c<b){
        		System.out.printf("%d %d %d\n",c,b,a);

        	}
        	else if(c>a){
        		System.out.printf("%d %d %d\n",b,a,c);

        	}
        	else{
        		System.out.printf("%d %d %d\n",b,c,a);

        	}

        }
        }
    }

Measured memory_bytes: 26152
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int n;
long long int a[100001];
long long int sum[100001];
long long int sum_alternate[100001];

bool ok(int x, int range)
{
	int i1 = lower_bound(a, a + n, x - range) - a;
	int i2 = upper_bound(a, a + n, x + range) - a;
	// [i1, i2)の範囲を青木くんが全てとることができるか？
	// [i1, n)の範囲の個数から、高橋くんと青木くんの取るべき個数がわかる
	// [i1, n)にある数の個数は偶数 -> それぞれ半分ずつ取るべき
	// 奇数 -> 高橋くんが1枚多く取るべき
	if(i2 == i1) return true;
	// cout << range << " " << i1 << " " << i2 << endl;
	int takahashinum = n - i2;
	int aokinum = i2 - i1;
	if(takahashinum >= aokinum) return true;
	if(x - a[i1] == a[i2 - 1] - x){
		// 青木くんの取る範囲を[i1, i2 - 1)にすることができる
		takahashinum++;
		aokinum--;
		if(takahashinum >= aokinum) return true;
	}
	return false;
}

long long int solve(int x)
{
	int l = 0, r = mod;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(ok(x, mid)) l = mid;
		else r = mid;
	}
	int i1 = lower_bound(a, a + n, x - l) - a;
	int i2 = upper_bound(a, a + n, x + l) - a;
	if(i1 == i2) i2++;
	int takahashinum = n - i2;
	int aokinum = i2 - i1;
	// cout << takahashinum << " " << aokinum << endl;
	if(takahashinum < aokinum){
		// 青木くんの取る範囲を[i1, i2 - 1)にする
		i2--;
	}
	// cout << l << " " << i1 << " " << i2 << endl;
	// 答えは[i2, n)の範囲全てとi1 - 1から青木くんと交互にとった結果の値の和になる
	long long int ans = sum[n - 1] - sum[i2 - 1];
	if(i1 % 2 == n % 2) ans += sum_alternate[i1 - 1];
	else ans += sum_alternate[i1 - 2];
	return ans;
}

int main()
{
	int q;
	cin >> n >> q;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i == 0) sum[i] = a[i];
		else sum[i] = sum[i - 1] + a[i];
		if(i < 2) sum_alternate[i] = a[i];
		else sum_alternate[i] = sum_alternate[i - 2] + a[i];
	}
	for(int i = 0; i < q; i++){
		int x;
		cin >> x;
		cout << solve(x) << endl;
	}
}

Measured memory_bytes: 4096
a=input()
b=input()
c=input()
d=input()
e=input()
k=input()

a=int(a)
b=int(b)
c=int(c)
d=int(d)
e=int(e)
k=int(k)

l=e-a

if l<=k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
package main

// ABC079D - Wall (400)
// https://atcoder.jp/contests/abc079/tasks/abc079_d

import "fmt"

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	c := make([][]int, 10)
	for i := 0; i < 10; i++ {
		c[i] = make([]int, 10)
		for j := range c[i] {
			fmt.Scan(&c[i][j])
		}
	}
	A := make([][]int, H)
	for i := range A {
		A[i] = make([]int, W)
		for j := range A[i] {
			fmt.Scan(&A[i][j])
		}
	}
    // ワーシャルフロイド法で i -> jの最小コストを求める
	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j])
			}
		}
	}
	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if A[i][j] >= 0 {
				ans += c[A[i][j]][1] // A[i][j]を1に変更するコストを加算
			}
		}
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2944
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N];
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, n + n) cin >> a[i];
	sort (a + 1, a + 1 + n + n);
	int ans = 0;
	for (int i = 1; i <= n + n; i += 2) ans += a[i];
	cout << ans;
	ioi
}


Measured memory_bytes: 256
//
// Created by Naman Bhalla on 2019-05-26.
//

#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <cstring>
#include <climits>

using namespace std;

long long int dp[101][100005];
int dat[101][2];

int main(){
    int n, w;
    cin >> n >> w;
    memset(dp, 0, sizeof dp);
    int val_s{};
    for(int i = 1; i <= n; ++i){
        cin >> dat[i][0];
        cin >> dat[i][1];
        val_s += dat[i][1];
    }

    for(int i = 0; i <= n; ++i){
        dp[i][0] = 0;
        for(int j = 1; j <= val_s; ++j){
            dp[i][j] = INT_MAX;
        }
    }

    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= val_s; ++j){
            if(dat[i][1] > j){
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - dat[i][1]] + dat[i][0] );
            }
//            cout << dp[i][j] << " ";
        }
//        cout << endl;
    }

    int ans = 0;

    for(int i = 0; i <= val_s; ++i){
        if(dp[n][i] <= w){
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9*1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel
int ans;
void primeFactors(int n)
{
	// Print the number of 2s that divide n
	int x = 0;
	while (n % 2 == 0)
	{
		//cout << 2 << " ";
		//v.pb(2);
		n = n / 2;
		x++;
	}
	ans = -1 + (sqrt(1 + (8 * x)));
	ans = ans / 2;
	x = 0;

	// n must be odd at this point. So we can skip
	// one element (Note i = i +2)
	for (int i = 3; i <= sqrt(n); i = i + 2)
	{	x = 0;
		// While i divides n, print i and divide n
		while (n % i == 0)
		{
			x++;
			//cout << i << " ";
			//v.pb(i);
			n = n / i;
		}
		int tmp = -1 + (sqrt(1 + (8 * x)));
		tmp = tmp / 2;
		ans = ans + tmp;
	}

	// This condition is to handle the case when n
	// is a prime number greater than 2
	if (n > 2)
		ans++;//v.pb(n);//cout << n << " ";
}

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	primeFactors(n);
	cout << ans << endl;



	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;

signed main(){
	
	cin>>n>>k;
	if(500*n>=k)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


Measured memory_bytes: 256
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: String,
    }

    println!("{}", if n.contains('7') {"Yes"} else {"No"});


}


Measured memory_bytes: 2116
#include<stdio.h>

#define G_MAX 100

int main()
{
  int i,j;
  int n;
  int G[G_MAX+1][G_MAX+1];
  int color[G_MAX+1],d[G_MAX+1],pi[G_MAX+1];
  int min,ii;
  int G_weight;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  for(i=0;i<n;i++){
    color[i]=0;
    pi[i]=-1;
    d[i]=2001;
  }
  d[0]=0;

  while(1){
    min=2001;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<min){
        min=d[i];
        ii=i;
      }
    }
    if(min==2001)break;
    color[ii]=2;
    for(i=0;i<n;i++){
      if(G[ii][i]!=-1 && color[i]!=2 && G[ii][i]<d[i]){
	pi[i]=ii;
	d[i]=G[ii][i];
	color[i]=1;
      }
    }
  }
  G_weight=0;
  for(i=0;i<n;i++){
    if(pi[i]!=-1)G_weight+=G[i][pi[i]];
    }
  printf("%d",G_weight);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  int max = 0;
  max = A + B;
  if (max < A - B)
  {
    max = A - B;
  }
  if (max < A * B)
  {
    max = A * B;
  }
  cout << max << endl;
}

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

vector<int> days[31];
bool watched[200];

int main(){
	int n;
	cin>>n;
	int a[n];
	int b[n];
	rep(i,n){
		cin>>a[i]>>b[i];
		for(int d = 0; d < 31; d++)
			if(a[i] <= d + 1 && b[i] >= d + 1)
				days[d].push_back(i);
	}
	int ans = 0;
	for(int i = 0; i < 31; i++)
	{
		int target = -1;
		for(int j = 0; j < days[i].size(); j++)
		{
			if(watched[days[i][j]])
				continue;
			if(target == -1 || b[target] > b[days[i][j]])
				target = days[i][j];
		}
		ans += (target == -1 || watched[target]) ? 50 : 100;
		watched[target] = true;
	}
	cout << ans << endl;
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(b[j-1] > b[j]){
				int alt=b[j-1];
				b[j-1]=b[j];
				b[j]=alt;
				alt=a[j-1];
				a[j-1]=a[j];
				a[j]=alt;
			}
		}
	}
	
	/*bool dt[n][32];
	int movie[32];
	rep(i,32)movie[i]=-1;
	rep(i,n)rep(j,32)dt[i][j]=false;
	int a,b;
	int ans=0;
	rep(i,n){
		cin>>a>>b;
		loop(j,a,b+1)dt[i][j]=true;
	}
	loop(i,1,32){
		int cnt=0;
		int mv=-1;
		rep(j,n){
			if(dt[j][i]){
				cnt++;
				mv=j;
			}
		}
		if(cnt==1){
			movie[i]=mv;
		}
	}
	loop(i,1,32){
		rep(j,n){
			if(dt[j][i] && movie[i]==-1){
				movie[i]=j;
			}
		}
	}
	loop(i,1,32)cout<<movie[i]<<" ";
	cout<<endl;
	bool used[n];
	rep(i,n)used[i]=true;
	loop(i,1,32){
		if(movie[i]!=-1){
			if(used[movie[i]])ans+=100;
			else ans+=50;
			used[movie[i]]=false;
		}
		cout<<ans<<endl;
	}
	cout<<ans<<endl;*/
	return 0;
}

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

#define INF (1 << 29)
#define rep2(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define EPS 1e-10

using namespace std;

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

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

int main()
{
    string tar = "CODEFESTIVAL2016";
    string str;
    cin >> str;
    int ans = 0;
    rep(i,tar.size()) if(tar[i]!=str[i]){
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){

	int a, b, c, x, remain, count=0;

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;

	for(int i=0; i<=a; i++){
		remain = x - (500*i);
		if(remain<0) break;
		for(int j=0; j<=b; j++){
			remain = x - (500*i) - (100*j);
			if(remain<0) break;
			if(remain <= 50*c){
				count++;
			}
		}
	}

	cout << count << endl;
	return 0;
}

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

int main(){
	string str[100];
	int v[100][100];
	int h, w;
	while(cin >> h >> w, h){
		fill((int*)v, (int*)(v+100), false);
		for(int i = 0;i < h;i++)cin >> str[i];
		int x = 0, y = 0;
		while(1){
			if(str[y][x] == '.'){cout << x << " " << y << endl;break;}
			if(v[y][x]){cout << "LOOP" << endl;break;}
			v[y][x] = true;
			if(str[y][x] == '>')x++;
			if(str[y][x] == '<')x--;
			if(str[y][x] == '^')y--;
			if(str[y][x] == 'v')y++;
		}
	}
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	string work[n];

	cin>>work[0];
	bool ans=true;
	rep(i,n-1){
		string tmp;
		cin>>tmp;
		rep(j,i+1){
			if(work[j] == tmp){
				ans=false;
				break;
			}
		}
		if(work[i][work[i].length()-1]!=tmp[0])ans=false;
		if(ans)work[i+1]=tmp;
		else break;

	}

	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
if n > 1:
    s = map(int, raw_input().split())
else:
    s = int(raw_input())
    
q = int(raw_input())
if q > 1:
    t = map(int, raw_input().split())
else:
    t = [int(raw_input())]

# f = open('ALDS1_4_B-in8.txt', 'r')
# data = f.readlines()
# n = int(data[0])
# s = map(int, data[1].split())
# q = int(data[2])
# t = map(int, data[3].split())

def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = int((left + right)/2)
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return False

count = 0
for i in range(q):
    if binarySearch(s, t[i]):
        count += 1
print count

Measured memory_bytes: 14888
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

long long int solve(long long int N) {
    string s = to_string(N);
    int len = s.length();
    
    long long int dp[15][2] = {};
    dp[0][0] = 1;
    for(int i=0; i<len; i++) {
        for(int j=0; j<2; j++) {
            int lim = j ? 9 : s[i] - '0';
            for(int x=0; x<lim+1; x++) {
                if(x == 4 || x == 6) continue;
                dp[i+1][j || x < lim] += dp[i][j];
            }
        }
    }
    
    long long int ret =  dp[len][0] + dp[len][1] - 1;
    return ret;
}


int main(void){
    // Your code here!
    int N;

    while(cin >> N, N) {
        long long int ub = 1LL << 40, lb = 0;
        while(ub - lb > 1) {
            long long int mid = (ub + lb) / 2;
            long long int val = solve(mid);
            
            if(val >= N) ub = mid;
            else lb = mid;
        }
        cout << ub << endl;
    }
    return 0;
}



Measured memory_bytes: 3196