akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

signed main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++) {
        const auto &pf = prime_factorize(i);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans += res;
        //cout << res << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

void solve() {
   int n;
   cin >> n;
   vector <int> a(n), b(n);

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

   if(a > b) swap(a, b);
   int ans = 0;
   do {
      if(a == b) break;
      ans++;
   } while(next_permutation(a.begin(), a.end()));
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const vector<int> need = {1, 4, 7, 9};

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	vector<int> v(4);
	for (auto &t : v) {
		cin >> t;
	}
	sort(v.begin(), v.end());
	if (v == need) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define INF 100100100

int N, M;

int g[100][100];
int cost[100][100];

set<pair<int, int> > ans;
vector<pair<int, int> > edge;

int main()
{
    cin >> N >> M;

    for (int i = 0; i < 100;i++)
    {
        for (int j = 0; j < 100;j++)
        {
            if(i == j)
            {
                g[i][j] = 0;
            }
            else
            {
                g[i][j] = INF;
            }
        }
    }

    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a][b] = c;
        g[b][a] = c;
        ans.insert(make_pair(a, b));
        ans.insert(make_pair(b, a));
        edge.push_back(make_pair(a, b));
    }

    for (int i = 0; i < N;i++)
    {
        for (int j = 0; j < N;j++)
        {
            cost[i][j] = g[i][j];
        }
    }

    for (int k = 0; k < N;k++)
    {
        for (int i = 0; i < N;i++)
        {
            for (int j = 0; j < N;j++)
            {
                cost[i][j] = min(cost[i][k] + cost[k][j], cost[i][j]);
            }
        }
    }

    for (int s = 0; s < N;s++)
    {
        for (int m = 0; m < M;m++)
        {
            int i = edge[m].first;
            int j = edge[m].second;

            if ((cost[s][j] + g[j][i] == cost[s][i] || cost[s][i] + g[i][j] == cost[s][j]) && ans.find(edge[m]) != ans.end())
            {
                ans.erase(make_pair(i, j));
                ans.erase(make_pair(j, i));
            }
        }
    }

    cout << ans.size() / 2 << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(void){
	int h, w, n;
	cin >> h >> w >> n;
	int sr, sc;
	cin >> sr >> sc;
	string s, t;
	cin >> s >> t;
	int nowr=sr, nowc=sc;
	for(int i = 0; i < n; ++i){
		if(s[i]=='L'){
			nowc--;
		}
		if(nowc==0) break;
		if(t[i]=='R'&& nowc!=w){
			nowc++;
		}
	}
	if(nowc==0){
		cout << "NO" << endl;
		return 0;
	}
	nowc=sc;
	for(int i = 0; i < n; ++i){
		if(s[i]=='R'){
			nowc++;
		}
		if(nowc==w+1) break;
		if(t[i]=='L'&& nowc!=1){
			nowc--;
		}
	}
	if(nowc==w+1){
		cout << "NO" << endl;
		return 0;
	}

	for(int i = 0; i < n; ++i){
		if(s[i]=='U'){
			nowr--;
		}
		if(nowr==0) break;
		if(t[i]=='D'&& nowr!=h){
			nowr++;
		}
	}
	if(nowr==0){
		cout << "NO" << endl;
		return 0;
	}
	nowr=sr;
	for(int i = 0; i < n; ++i){
		if(s[i]=='D'){
			nowr++;
		}
		if(nowr==h+1) break;
		if(t[i]=='U'&& nowr!=1){
			nowr--;
		}
	}
	if(nowr==h+1){
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

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

struct zahyo{
  ll y,x;
};

ll absll(ll x){
  return (x<0?x*-1:x);
}

void output(vector<vector<ll>> v){
  for(ll i=0;i<v.size();i++){
    for(ll j=0;j<v[i].size();j++){
      if(j){
        cout<<' ';
      }
      cout<<v[i][j];
    }
    cout<<"\n";
  }
  cout<<flush;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll h,w,d;
  cin>>h>>w>>d;
  map<ll,zahyo> m;
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      ll temp;
      zahyo yx;
      cin>>temp;
      yx.y=i;
      yx.x=j;
      m[temp]=yx;
    }
  }
  vector<vector<ll>> v(d+1,vector<ll> (1,0));
  //cout<<"v.size()="<<v.size()<<endl;
  for(ll i=1;i<=d;i++){
    ll vi=0;
    for(ll j=i+d;j<=h*w;j+=d){
      //cout<<"j="<<j<<endl;
      ll cost;
      cost = absll(m[j].y-m[j-d].y)+absll(m[j].x-m[j-d].x);
      v[i].push_back(v[i][vi] + cost);
      vi++;
    }
  }
  //output(v);
  ll q;
  cin>>q;
  ll l,r;
  for(ll i=0;i<q;i++){
    cin>>l>>r;
    ll ori=l%d;
    if(ori==0){
      ori=d;
    }
    ll left,right;
    left=(l-ori)/d;
    right=(r-ori)/d;
    cout<<v[ori][right]-v[ori][left]<<endl;
  }
  return 0;
}

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

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

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

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

using namespace std;

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

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

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int ans = n;
  for(int i = 0; i <= n; ++i) {
    int cc = 0;
    int t =i;
    while(t > 0) cc+=t%6, t/=6;
    t = n - i;
    while(t > 0) cc+=t%9, t/=9;
    if(ans > cc) ans = cc;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int S=cin.nextInt(),time[]=new int[3];
		
		for(int i=0;i<3;i++){
			time[i]=S%60;
			S/=60;
		}
		
		System.out.println(time[2]+":"+time[1]+":"+time[0]);
	}

}



Measured memory_bytes: 26192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll H,N;
    cin >> H >> N;
    vl A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    vvc<ll> dp(N + 1, vl(2 * 10000,INF));
    dp[0][0] = 0;
    rep(i,N){
        rep(j,2*10000){
            if (j >= A[i]) dp[i + 1][j] = min(dp[i + 1][j - A[i]] + B[i], dp[i][j]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    ll ans = INF;
    repe(i,H,2*10000){
        if (dp[N][i] != INF) chmin(ans, dp[N][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 160640
#include <stdio.h>
    #include <cstdio>
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <cmath>
    #include <iomanip>
     
    using namespace std;
     
    int main() {
    	cin.tie(0);
    	ios::sync_with_stdio(false);
     
    	int N;
     
    	cin >> N;
     
    	long long mod = pow(10, 9) + 7;
     
    	vector<long long> A(N);
     
    	for(int i = 0; i < N; i++) {
    		cin >> A[i];
    	}
     
    	long long count = 0;
     
    	for(int i = 0; i < 62; i++) {
    		long long zeros = 0;
    		long long ones = 0;
    		for(int j = 0; j < N; j++) {
    			if(A[j] & (1LL << i)) {
    				ones++;
    			} else {
    				zeros++;
    			}
    		}
     
    		long long c = (((zeros * ones) % mod) * ((1LL << i) % mod)) % mod;
    		count += c % mod;
    		count %= mod;
    	}
     
    	cout << count << endl;
    }

Measured memory_bytes: 2560
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()

if n>=m:
    print(0)
    quit()

ans=[]
for i in range(m-1):
    ans.append(x[i+1]-x[i])
# print(ans)

ans.sort()
# print(ans)
for i in range(n-1):
    ans[-1-i]=0
print(sum(ans))

Measured memory_bytes: 94304
import java.util.Scanner;

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

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();
int b = sc.nextInt();

if(a+b >= a-b && a+b >= a*b){
  System.out.println(a+b);
  
}else if(a-b >= a+b && a-b >= a*b){
  System.out.println(a-b);
}else{
  System.out.println(a*b);
}

    
  }
}


Measured memory_bytes: 25044
#include<stdio.h>

int main(void){

	int N,i,n1,n2,n3;

	scanf("%d",&N);

	for(i=0;i<N;i++){
		scanf("%d %d %d",&n1,&n2,&n3);
		if(n1*n1==(n2*n2+n3*n3)||n3*n3==(n2*n2+n1*n1)||n2*n2==(n1*n1+n3*n3)){
			puts("YES");
		}
		else{
			puts("NO");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
using ll = long long;
using namespace std;

int main()
{
    ll a, b, c, d, ans = 0;
    cin >> a >> b >> c >> d;
    if(b >= 0 && d >= 0){ 
        ans = b * d;
        ans = max(ans, a * c);
    } else if(b >= 0 && d < 0){
        ans = a * d;
        ans = max(ans, a * c);
    } else if(b < 0 && d >= 0){
        ans = b * c;
        ans = max(ans, a * c);
    } else ans = a * c;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3644
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def ncr(n, r, p):
    # initialize numerator
    # and denominator
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den,
            p - 2, p)) % p

s = INT()

zz = s//3

ans = 0

for i in range(1, zz+1):
    N = s-3*i

    ans+= ncr(N+i-1,i-1,mod)
print(ans%mod)

Measured memory_bytes: 68484
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n; i++) {
			arr[i] = scan.nextInt();
		}
		Sort sort = new Sort();
		arr = sort.insertion(arr);
	}
}

class Sort{
	public int[] insertion(int[] A){
                showArray(A);
		for(int i=1; i<A.length; i++){
			int v = A[i];
			int j = i-1;
			while(j >= 0 && A[j] > v){
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			showArray(A);
		}
		return A;
	}
	public void showArray(int[] A){
		for(int i=0; i<A.length; i++){
			System.out.print(A[i]);
			if(i != A.length-1)System.out.print(" ");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 34508
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int num = Integer.parseInt(a + b);
		int tmp =(int)Math.sqrt(num);
		if(tmp * tmp == num){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
 	}
}




Measured memory_bytes: 39452
X, K, D = map(int, input().split())

if abs(X) > K * D:
    print(abs(X) - K * D)
    exit()

y = abs(X) // D
X_ = abs(X) - y * D
z = K - y
if z % 2 == 0:
    ans = X_
else:
    ans = abs(X_ - D)

print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    ll N, M;
    cin >> M >> N;
    ll ans = min(N / 2, M);
    N -= 2 * ans;
    M -= ans;
    ans += N / 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	if (N > M) {
		cout << 0 << endl;
		return 0;
	}
	vector<vector<vector<long long int>>>dp(M + 1, vector<vector<long long int>>(N + 1, vector<long long int>(N + 1)));
	dp[0][0][0] = 1;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k <= j; k++) {
				dp[i + 1][j][k] += dp[i][j][k] * (j - k);
				dp[i + 1][j][k] %= MOD;
				dp[i + 1][j + 1][k] += dp[i][j][k];
				dp[i + 1][j + 1][k] %= MOD;
				dp[i + 1][j][j] += dp[i][j][k] * (k + 1);
				dp[i + 1][j][j] %= MOD;
			}
		}
	}
	//for (int i = 0; i <= M; i++) {
	//	for (int j = 0; j < N; j++) {
	//		for (int k = 0; k < N; k++) {
	//			cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
	//		}
	//	}
	//}
	long long int ans = dp[M][N - 1][N - 1];
	for (int i = 2; i < N; i++) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 216832
# from collections import defaultdict
# N,M = list(map(int,input().split()))
# price_howmany = defaultdict(int)
import sys

stdin = sys.stdin

read_int = lambda : list(map(int,stdin.readline().split()))

N,M = read_int()
price_howmany = {}
# price_list = []

price_set = set()
for _ in range(N):
    tmp = read_int()
    # if tmp[0] not in price_set:
        # price_list.append(tmp[0])
    price_set.add(tmp[0])
    if tmp[0] in price_howmany:
        price_howmany[tmp[0]] += tmp[1]
    else:
        price_howmany[tmp[0]] = tmp[1]
# price_list.sort(reverse=True)
price_list = sorted(list(price_set))

# price_howmany = dict(price_howmany)

def solve():
    price = 0
    global M
    # while M > 0:
        # low_price = min(price_howmany.keys())
        # low_price = price_list.pop()
        # many = min(M,price_howmany.pop(low_price))
        # price += many * low_price
        # M -= many
    for low_price in price_list:
        many = min(M,price_howmany.pop(low_price))
        price += many * low_price
        M -= many
        if M == 0: break
    print(price)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 21924
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> mons(n);
        for(auto &&i : mons) cin >> i;
        int maxhp = *max_element(mons.begin(),mons.end());
        vector<pair<int, int>> v, u;
        int m;
        cin >> m;
        for (int i = 0; i < m; ++i) {
            string s, t; int mp, damage;
            cin >> s >> mp >> t >> damage;
            if(t == "All") v.emplace_back(mp, damage);
            else u.emplace_back(mp, damage);
        }
        vector<ll> dp(maxhp+1, MOD), dq(maxhp+1, MOD);
        dp[0] = 0;
        for (int i = 1; i <= maxhp; ++i) {
            for (const auto & j : v){
                dp[i] = min(dp[i], j.first+dp[max(0, i-j.second)]);
            }
        }
        dq[0] = 0;
        for (int i = 1; i <= maxhp; ++i) {
            for (const auto & j : u){
                dq[i] = min(dq[i], j.first+dq[max(0, i-j.second)]);
            }
        }
        for (int k = maxhp-1; k >= 0; --k) {
            dp[k] = min(dp[k], dp[k+1]);
            dq[k] = min(dq[k], dq[k+1]);
        }
        ll ans = INF<ll>/1000;
        for (int i = 0; i <= maxhp; ++i) { // 単体でiまで減らす
            ll x = dp[i];
            for (int j = 0; j < n; ++j) {
                x += dq[max(0, mons[j]-i)];
            }
            ans = min(ans, x);
        }
        cout << ans << "\n";
    }
    return 0;
}


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

function main()
	h,w = readline() |> split |> parseMap
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	c = zeros(Int,h,w)
	nx = 1
	ny = 1
	for i in 1:n
		for j in 1:a[i]
			c[nx,ny]=i
			if nx%2==1
				ny+=1
				if ny>w
					ny = w
					nx += 1
				end
			else
				ny-=1
				if ny<1
					ny = 1
					nx += 1
				end
			end
		end
	end
	for i in 1:h
		for j in 1:w-1
			print(c[i,j]," ")
		end
		println(c[i,w])
	end
end

main()

Measured memory_bytes: 114820
class Dice
  attr_accessor :face
  Edge = [[0,1,2],[0,2,4],[0,4,3],[0,3,1],[1,5,2],[2,5,4],[4,5,3],[3,5,1]]
  def query(a, b)
    x,y = @face.index(a),@face.index(b)
    Edge.each do |item|
      if i = item.index(y)
        if item[i-1] == x
          return item[i-2]
        end
      end
    end
  end
end

dice = Dice.new
dice.face = gets.chomp.split.map(&:to_i)
gets.chomp.to_i.times do
  a,b = gets.chomp.split.map(&:to_i)
  puts dice.face[dice.query(a, b)]
end

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

int main()
{
 int N,digit;
	scanf("%d",&N);

	digit=N%10;
	if(digit==2)
        printf("hon");
    if(digit== 4)
        printf("hon");
    if(digit==5 )
        printf("hon");
    if(digit==7 )
        printf("hon");
    if(digit==9 )
        printf("hon");
    if(digit==0 )
        printf("pon");
    if(digit==1)
        printf("pon");
    if(digit==6)
        printf("pon");

    if(digit==8)
        printf("pon");
    if(digit==3)
        printf("bon");
    
}


Measured memory_bytes: 1736
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, M, X;
    cin >> N >> M >> X;

    ll l = 0, r = 0;
    ll A;
    rep(i, M){
        cin >> A;
        if(A < X){
            l++;
        }else if(A > X && A < N){
            r++;
        }
    }

    cout << min(l, r) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main() {
  ll H,W,cnt=0,dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
  cin>>H>>W;
  vector<string> v(H);
  rep(i,H) cin>>v[i];
  vector<vector<ll>> w(H,vector<ll>(W,-1));
  rep(i,H) rep(j,W) if(v[i][j]=='#') w[i][j]=-2,cnt++;
  queue<pint> que;
  que.push(pint(0,0));
  w[0][0]=0;
  while(!que.empty()){
    auto c=que.front();que.pop();
    rep(i,4){
      ll ny=c.first+dy[i];
      ll nx=c.second+dx[i];
      if(nx<0 || ny<0 || W<=nx || H<=ny) continue;
      if(w[ny][nx]==-1) w[ny][nx]=w[c.first][c.second]+1,que.push(pint(ny,nx));
    }
  }
  if(w[H-1][W-1]==-1) cout<<-1<<endl;
  else cout<<W*H-cnt-(w[H-1][W-1]+1)<<endl;
}

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

int main(void){
	int n, i,c;
	int ha = 0, ta = 0;
	char card_t[128];
	char card_h[128];

	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%s %s",card_t,card_h);
	c = strcmp(card_t, card_h);
	if(c == 0){ha++; ta++;}
	if(c > 0){ta += 3;}
	if(c < 0){ha += 3;}
}
printf("%d %d\n",ta, ha);
return 0;
}

Measured memory_bytes: 604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func isInclude(s string, c byte) bool {
	for _, v := range s {
		if string(v) == string(c) {
			return true
		}
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)
	s := fmt.Sprintf("%d%d%d%d", nextInt(), nextInt(), nextInt(), nextInt())
	if isInclude(s, '1') && isInclude(s, '9') && isInclude(s, '7') && isInclude(s, '4') {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back

int main()
{
	int n;
	cin>>n;
	vector<int>store;
	store.pb(1);
	int ways[n+1];
	for(int i=0;i<=n;i++)
	{
		ways[i]=100001;
	}
	int x=1,y=1;
	
			while(x*9<=n){
				store.pb(x*9);
				//ways[x*9]=1;
				x*=9;
			}
		while(6*y<=n)
	{
			store.pb(6*y);
			//ways[6*y]=1;
			y*=6;
	}
	sort(store.begin(),store.end());
	ways[0]=0;
	ways[1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<store.size();j++)
		{
			if(store[j]<=i){
			ways[i]=min(ways[i],1+ways[i-store[j]]);}
			else
				break;
		}
	}
	cout<<ways[n]<<"\n";
	}


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

using int_ = int;
#define int int_least64_t

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n; cin >> n;
  string s; cin >> s;
  if (count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B'))
    cout << "Yes\n";
  else
    cout << "No\n";
}



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

int main() {
	// your code goes here
	int n,count=0;
	cin>>n;
    int a[n][2];
    
    for(int i=0;i<n;i++)
    for(int j=0;j<2;j++)
    cin>>a[i][j];
    
    for(int i=0;i<n;i++)
    if(a[i][0]==a[i][1])
    {
        count++;
        if(count==3)
        {
        cout<<"Yes";
        return 0;
        }
    }
    else
    count=0;
    
    
    
    cout<<"No";
	return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
struct edge{
	lnt to,dist,cost;
};
vector<edge> G[10000];
priority_queue<P,vector<P>,greater<P> > q;
lnt n,m;
lnt d[10000];
const lnt INF = 0xffffffffff;
int main()
{
while(1){
	cin>>n>>m;
	if(!n&&!m) return 0;
	lnt x,y,z,w;
	for(int i=0;i<n;i++) G[i].clear();
	for(int i=0;i<m;i++){
		cin>>x>>y>>z>>w;
		x--;
		y--;
		G[x].push_back(edge{y,z,w});
		G[y].push_back(edge{x,z,w});
	}
	fill(d,d+n,INF);
	d[0]=0;
	q.push(P(0,0));
	while(!q.empty()){
		P p = q.top();
		q.pop();
		lnt v = p.second;
		if(d[v]<p.first) continue;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to]>d[v]+e.dist){
				d[e.to]=d[v]+e.dist;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	lnt ans=0;
	for(int i=1;i<n;i++){
		z=INF;
		for(int j=0;j<G[i].size();j++){
			edge e=G[i][j];
			if(d[i]==d[e.to]+e.dist){
				z=min(z,e.cost);
			}
		}
		ans+=z;
	}
	cout<<ans<<endl;
}
}

Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k,cnt=0;
    cin>>n>>k;
    while(n--){
        int a;
        cin>>a;
        if(a>=k)
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<pll> vec(n);
    REP(i, n){
        cin >> vec[i].first >> vec[i].second;
    }

    sort(vec.begin(), vec.end(), [](pll &p1, pll &p2){return atan2(p1.second, p1.first) < atan2(p2.second, p2.first);});

    ll maxx = 0;
    FOR(i, 0, n){
        IFOR(j, 1, n){
            pll now = make_pair(0, 0);
            FOR(k, 0, j){
                int idx = (i + k) % n;
                now.first += vec[idx].first, now.second += vec[idx].second;
            }
            maxx = max(maxx, now.first * now.first + now.second * now.second);
        }
    }

    printf("%.14f\n", sqrt(maxx));

    return 0;
}

Measured memory_bytes: 512
N = int(input())
results = {(str(i), str(j)): 0 for i in range(1, 10) for j in range(1, 10)}


for i in range(N+1):
    s = str(i)
    if (s[0], s[-1]) in results.keys():
        results[(s[0], s[-1])] += 1

cnt = 0
for i in range(1, 10):
    for j in range(1, 10):
        cnt += results[(str(i), str(j))] * results[(str(j), str(i))]

print(cnt)

Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.nextLine();
    sc.close();

    if(n.length() == 4) {
      int bill = Integer.parseInt(n.substring(1, 4));
      if(bill == 0) {
        System.out.println(0);
      }else {
        System.out.println(1000 - bill);
      }

    }else if(n.length() == 5) {
      System.out.println(0);
    }else {
      System.out.println(1000 - Integer.parseInt(n));
    }
  }

}


Measured memory_bytes: 35824
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int ctoi(const char c)
{
    if ('0' <= c && c <= '9')
        return (c - '0');
    return -1;
}

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

    vector<int> a(n);

    int cnt = 0;

    REP(i,n){
        cin >> a[i];
        if(a[i]%2==0)   cnt++;
    }

    if(cnt==n){
        cout << "second" << endl;
    }else{
        cout << "first" << endl;
    }

    return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(ALL(S));
    for (int i = 0; i < N; i++) {
        cout << S[i];
    }
    cout << endl;
}


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

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
// Function to find gcd of array of 
// numbers 
int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    return result; 
} 


int main()
{
  long long int n;
  cin>>n;
  int arr[3];
  int a = sizeof(arr) / sizeof(arr[0]); 
  long long ans=0;
  int i,j,k;
  for ( i=1; i<n+1; i++)
  {
    for ( j=1; j<n+1; j++)
    {
        for ( k=1; k<n+1; k++)
        {
            arr[0]=i, arr[1]=j, arr[2]=k;
            ans += findGCD(arr, a);
            
        }
    }
    
  }
  cout<<ans;
  
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        String[] t = sc.next().split("");
        
        int result = 0;
        for (int i=0; i<3; i++) {
            if (s[i].equals(t[i])) {
                result++;
            }
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35868
n = int(input())
a = list(map(int, input().split()))

b =[0]*(n+1)

ans = 0

for i in range(n):
  j = n-i
  sum = 0
  m = 1
  while j*m <= n:
    sum += b[j*m]
    m += 1
  if sum % 2 != a[j-1]:
    b[j] = 1 
    ans += 1
    


if not 1 in b:
  print(0)
else:
  print(ans)
  for i in range(n+1):
    if b[i] == 1:
      print(i, end =' ')


Measured memory_bytes: 7148
#include "bits/stdc++.h"
using namespace std;

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

    vector<int> dp(100100);
    dp[1] = 0;
    dp[2] = abs(H[1] - H[0]);
    for (int i = 3; i <= N; i++) {
        dp[i] = min(dp[i - 2] + abs(H[i - 1] - H[i - 3]), dp[i - 1] + abs(H[i - 1] - H[i - 2]));
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int m,d,ans;
int main()
{
	scanf("%d%d",&m,&d);
	for(int i=22;i<=d;i++)
	{
		int d10=i/10,d1=i%10;
		if(d10*d1<=m&&d1>=2)ans++;
	}
	printf("%d",ans);
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

#ifdef sarthak
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#else
#define trace(...)
#endif

#ifndef sarthak
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

ll d[100001];
ll pre[100001];

void solve()
{
    ll n;
    cin >> n;

    rep(i,n)
    {
        cin >> d[i];
        pre[d[i]]++;
    }

    fr(i,1,100000)
    {
        pre[i] += pre[i-1];
    }

    ll ans = 0;

    fr(i,1,100000)
    {
        ll num1 = pre[i-1];
        ll num2 = pre[100000]-pre[i-1];
        if(num1==num2)
            ans++;
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

    	Scanner       scan         = new Scanner(System.in);
    	List<Integer> inputNumbers = new ArrayList<Integer>();
    	double        ave          = 0;

    	int count = scan.nextInt();

    	for(int i=0; i<count; i++) {

    		inputNumbers.add(scan.nextInt());

    	}

    	scan.close();

    	Collections.sort(inputNumbers);
    	ave = inputNumbers.get(0);

    	for(int i=1; i<inputNumbers.size(); i++) {

    		ave = (ave + inputNumbers.get(i)) / 2;

    	}

    	System.out.println(ave);

	}

}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y) {
    rep (i, 100) rep (j, 100) {
        if (X == i + j && i * 2 + j * 4 == Y) {
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

int main() {
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(X, Y);
    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

// Tip : ceil ( a/b ) = 1 + floor( (a-1)/b ) !

void solve ( int test_case )
{
    ll n , k ;
    cin >> k >> n ;

    if ( k*500 >= n )
        cout << "Yes" ;
    else
        cout << "No" ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int la=a.length();
	for(int i=0;i<la;i++)
	{
		if(a[i]==',')
		a[i]=' ';
	}
	for(int i=0;i<la;i++)
	cout<<a[i];
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int f[210000000];
int main(void)
{
	int a,s,d[1000],high,low,ba,naka,nokori,kore,g,h,i,j,z,x,c,v;
	while(1){
		kore=0;
		scanf("%d %d",&a,&s);
		if(a==0&&s==0)
			break;
		d[0]=0;
		for(i=1;i<=a;i++){
			scanf("%d",&d[i]);
		}
		g=0;
		for(i=0;i<=a;i++){
			for(j=i;j<=a;j++){
				f[g]=d[i]+d[j];
				g++;
			}
		}
		sort(f,f+g);
		/*for(i=0;i<g;i++)
			printf("%d\n",f[i]);*/
		
		for(i=0;i<g;i++){
			v=0;
			low=0;
			high=g-1;
			nokori=s-f[i];
		//	printf("%d %d\n",i,nokori);
			if(nokori>=0){
				while(1){
					if(low>high)
						break;
					naka=(low+high)/2;
				//	printf("%d = %d %d %d %d %d\n",i,f[high],f[naka],f[low],f[i],nokori);
					if(nokori>f[naka]){
						low=naka+1;
					//	printf("%d %d %d low\n",i,nokori,f[naka]);
					}
					if(nokori<f[naka]){
						high=naka-1;
					//	printf("%d %d %d high\n",i,nokori,f[naka]);
					}
					if(nokori==f[naka]){
						ba=f[naka];
						v=1;
						break;
					}
				}
				if(v==0)
					ba=f[low-1];
				//printf("%d\n",f[i]+ba);
				if(kore<f[i]+ba){
					kore=f[i]+ba;
				//	printf("   %d\n",kore);
				}
			}
		}
		printf("%d\n",kore);
	}
	return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD 998244353
typedef long long int lli;

int bs(vector<int> &len, int f, int s){
    int l = 0, r = s;
    int mid = 0;
    int hit = -1;
    do{
        if(mid < s && len[f] + len[mid] > len[s] && len[mid] + len[s] > len[f] && len[s] + len[f] > len[mid]){
            hit = mid;
            r = mid;
            // cout << "hit!" << endl;
            // cout << "s = " << s << ", hit = " << hit << ", f = " << f << endl;
        }else{
            l = mid;
        }
        // cout << "l = " << l << ", r = " << r << endl;
        mid = r - (r - l) / 2;
    }while(r - l >= 2);

    // cout << "s = " << s << ", hit = " << hit << ", f = " << f << endl << endl;
    return (hit == -1) ? 0 : s - hit;
}

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

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

    lli ans = 0;
    for(int f = n - 1; f >= 2; --f){
        for(int s = f - 1; s >= 1; --s){
            ans += bs(len, f, s);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a;
	while(cin>>a){
		if(a=="#") break;
		int len=a.size();
		int k=0,m=2;
		for(int i=0;i<len;i++){
			if(a[i]=='q'||a[i]=='w'||a[i]=='e'||a[i]=='r'||a[i]=='t'||a[i]=='a'||a[i]=='s'||a[i]=='d'||a[i]=='f'||a[i]=='g'||a[i]=='z'||a[i]=='x'||a[i]=='c'||a[i]=='v'||a[i]=='b'){
				if(m==1){
					k++;
				}
				m=0;
			}
			else{
				if(m==0){
					k++;
				}
				m=1;
			}
		}
		cout<<k<<endl;
	}
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define rrep(i,n,l) for(int i=n-1;i>=l;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a);
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
//typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

vi v;
int n, l;

string changes(int k) {
	stringstream ss;
	string s;
	ss << k;
	ss >> s;
	return s;
}

int changei(string s) {
	stringstream ss;
	int k;
	ss << s;
	ss >> k;
	return k;
}

int main() {
	while (cin >> n >> l) {
		if (n == 0 && l == 0)break;
		int d[100] = {};
		bool f = 0;
		d[0] = n;
		rep(i,1,21) {
			string s = changes(n);
			while (s.size()<l){
				s += "0";
			}
			string t1 = s;
			sort(ALL(t1));
			string t2 = t1;
			reverse(ALL(t2));
			int mi, ma;
			ma = changei(t2);
			mi = changei(t1);
			n = ma - mi;
			d[i] = n;
			REP(j, i) {
				if (d[i] == d[j]) {
					cout << j << " " << d[i] << " " << i - j << endl;
					f = 1;
					break;
				}
			}
			if (f)break;
		}
	}
}

Measured memory_bytes: 1248
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	
	string str1 = "CODEFESTIVAL2016";
	
	string str2;
	
	cin >> str2;
	
	int ans = 0;
	
	for(int i = 0; i < str1.size(); i++){
		if(str1[i] != str2[i]){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r<0||y-r<0||x+r>W||y+r>H){
        printf("No\n");
    }else if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
        printf("Yes\n");
    }
    return 0;
}

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


int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif


	int n;
	cin >> n;
	int a[n];
	for(int i= 0; i < n; i++)
		cin>> a[i];

	int count = 0;
	for(int i = 0; i < n; i++) {
		if (a[i] != i-count+1){
			count++;
		}
	}
	if(count == n)
		cout << -1 << endl;
	else
		cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> edge[108000];
int cnta, cntb;
int a, b, n;
int la, lb;
int cnt[108000];
bool valid[108000];
void ok(){
  cout << "First" << endl;
  exit(0);
}

int main(){
  cin >> n ;
  for(int i = 0;i < n-1;i++){
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
    cnt[a]++;
    cnt[b]++;
  }

  vector<int> ones;
  for(int i = 1;i <= n;i++){
    if(edge[i].size() == 1)
      ones.push_back(i);
    valid[i] = true;
  }
  
  while(!ones.empty()){
    int x = ones.back();ones.pop_back();
    valid[x] = false;
    for(int i = 0;i < edge[x].size();i++){
      int to = edge[x][i];
      if(!valid[to])continue;
      for(int j = 0;j < edge[to].size();j++){
	int tto = edge[to][j];
	if(!valid[tto])continue;
	cnt[tto]--;
	if(cnt[tto] == 0)ok();
	if(cnt[tto] == 1)ones.push_back(tto);
      }
      valid[to] = false;
      
    }
  }
  cout << "Second" << endl;
  return 0;
}

Measured memory_bytes: 6912