akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int k = int.Parse(Console.ReadLine());
        int x = k;
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        while(k <= 1000)
        {
            if(arr[0] <= k && k <= arr[1])
            {
                Console.WriteLine("OK");
                return;
            }
            k += x;
        }
        Console.WriteLine("NG");
    }





}



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

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define mp make_pair

using namespace std;

typedef pair<int, int> P;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int h, w, n;
int ans = 0;
int sx, sy, gx, gy;
char field[1010][1010];
int went[1010][1010];

/*struct state{
	int x;
	int y;
	int count;
};*/

int bfs(P start, int tmp) {
	rep(i, h) {
		rep(j, w) {
			went[i][j] = INF;
			if(field[i][j] == tmp + '0') {
				gy = i;
				gx = j;
			}
		}
	}
	went[start.first][start.second] = 0;

	queue<P> q;
	q.push(start);

	while(!q.empty()) {
		P p = q.front();
		q.pop();
		//cout << p.first << " " << p.second.first << " " << p.second.second << endl;
		if(p.first == gy && p.second == gx) return went[p.first][p.second];
		rep(i, 4) {
			int nx = p.second + dx[i];
			int ny = p.first + dy[i];
			if(nx >= 0 && ny >= 0 && nx < w && ny < h && went[ny][nx] == INF && field[ny][nx] != 'X') {
				q.push(P(ny, nx));
				went[ny][nx] = went[p.first][p.second] + 1;
			}
		}
	}
}

int main() {
	cin >> h >> w >> n;
	rep(i, h) rep(j, w) {
		cin >> field[i][j];
		if(field[i][j] == 'S'){
			sx = j, sy = i;
			gx = j, gy = i;
		}
	}
	/*rep(i, h) {
		rep(j, w) cout << field[i][j];
		cout << endl;
	}*/
	for(int i = 1; i <= n; ++i) {
		ans += bfs(P(gy, gx), i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8036
package main

import (
	"fmt"
	"math"
)

var (
	n, k  int
	h, dp []int
)

func main() {
	fmt.Scan(&n, &k)

	h = make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	dp = make([]int, n)
	for i := range dp {
		dp[i] = -1
	}

	fmt.Println(recDp(n - 1))
}

func recDp(i int) int {
	if i == 0 {
		return 0
	}
	if dp[i] != -1 {
		return dp[i]
	}
	res := math.MaxInt64
	for j := range make([]struct{}, k) {
		if i-j-1 >= 0 {
			res = min(res, recDp(i-j-1)+abs(h[i]-h[i-j-1]))
		}
	}
	dp[i] = res
	return res
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

typedef long long ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    string a,b;
    cin >> a >> b;

    if(a.size() > b.size())
    {
        cout << "GREATER" << endl;
    }

    else if(a.size() < b.size())
    {
        cout << "LESS" << endl;
    }

    else
    {
        if(b[0] < a[0])
        {
            cout << "GREATER" << endl;
        }
        else if(a[0] < b[0])
        {
            cout << "LESS" << endl;
        }
        else
        {
            cout << "EQUAL" << endl;
        }
    }
}

Measured memory_bytes: 3604
import static java.util.Arrays.binarySearch;

import java.io.IOException;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		int n = nextInt();
		int m = nextInt();
		int[] xs = new int[n];
		int[] ys = new int[n];
		for (int i = 0; i < n; i++) {
			xs[i] = nextInt();
			ys[i] = nextInt();
		}

		TreeSet<Integer> xSet = new TreeSet<Integer>();
		TreeSet<Integer> ySet = new TreeSet<Integer>();

		for (int i = 0; i < n; i++) {
			xSet.add(xs[i]);
			ySet.add(ys[i]);
		}
		xSet.add((int) Integer.MAX_VALUE);
		xSet.add((int) Integer.MIN_VALUE);
		ySet.add((int) Integer.MAX_VALUE);
		ySet.add((int) Integer.MIN_VALUE);

		Integer[] xss = xSet.toArray(new Integer[0]);
		Integer[] yss = ySet.toArray(new Integer[0]);

		int w = xss.length;
		int h = yss.length;

		int[][] a = new int[h + 1][w + 1];
		for (int i = 0; i < n; i++) {
			int x = binarySearch(xss, xs[i]);
			int y = binarySearch(yss, ys[i]);
			a[y + 1][x + 1]++;
		}

		for (int j = 0; j < h; j++) {
			for (int i = 0; i < w; i++) {
				a[j + 1][i + 1] += a[j + 1][i] + a[j][i + 1] - a[j][i];
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
			int x1 = binarySearch(xss, xSet.ceiling(nextInt()));
			int y1 = binarySearch(yss, ySet.ceiling(nextInt()));
			int x2 = binarySearch(xss, xSet.floor(nextInt())) + 1;
			int y2 = binarySearch(yss, ySet.floor(nextInt())) + 1;
			sb.append(a[y2][x2] - a[y1][x2] - a[y2][x1] + a[y1][x1]);
			sb.append('\n');
		}
		System.out.print(sb.toString());
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 211420
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

double p[3000];
double dp[3000];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	for (int i = 0; i < N; i++) cin >> p[i];
    
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		for (int front = N; front >= 0; front--) {
			dp[front] = dp[front] * (1 - p[i]);
			if (front != 0) dp[front] += dp[front - 1] * p[i];
		}
		DMP(dp);
	}

	cout << fixed << setprecision(10);
	cout << accumulate(dp + (N + 1) / 2, dp + 3000, 0.0) << "\n";

	return 0;
}


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

using namespace std;

#define int long long

const int N = (int)3e5, MOD = (int)1e9 + 7, INF = (int)3e18;

vector <int> g[N];
int d[N];
int used[N];

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int n;
    int x, y;
    cin >> n >> x >> y;
    for (int i = 1; i <= n - 1; ++i) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    map <int, int> cnt;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) d[j] = 0;
        queue <int> q;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (auto to : g[v]) {
                if (!used[to]) {
                    used[to] = 1;
                    q.push(to);
                    d[to] = d[v] + 1;
                }
            }
        }
        for (int j = i + 1; j <= n; ++j) ++cnt[d[j]];
        for (int j = 1; j <= n; ++j) used[j] = 0;
    }
    for (int i = 1; i <= n - 1; ++i) {
        cout << cnt[i] << '\n';
    }
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>>graph(n + 1, vector<int>());
  for (int i = 0; i < m; i++) {
    int u,v; cin >> u >> v;
    graph[u].push_back(v);
  }
  vector<int>memo(n + 1, -1);
  function<int(int)>f = [&](int r) -> int {
    if (memo[r] != -1) return memo[r];
    int ans = 0;
    for (const auto& x: graph[r]) {
      ans = max(ans, 1 + f(x));
    }
    return memo[r] = ans;
  };
  int ans = 0;
  for (int i = 1; i <= n; i++)
    ans = max(ans, f(i));
  cout << ans << endl;
  // vector<int>dp(n + 1, 0);
  // for (int i = 1; i <= n; i++) {
  //   for (int j = 1; j <= n; j++) {
  //     for (const auto& adj: graph[j]) {
  //       dp[j] = max(dp[j], dp[adj] + 1);
  //     }
  //   }
  // }
  // // cout << dp[3] << endl;
  // cout << *max_element(dp.begin(), dp.end()) << endl;
  return 0;
}

Measured memory_bytes: 8832
def myAnswer(A:int,B:int)-> int:
   total = 0
   for i in range(A,B+1):
      tmp =str(i)
      if(tmp[:2]==tmp[:2:-1]):
         total+=1
   return total

def modelAnswer():
   tmp=1
def main():
   A, B = map(int,input().split())
   print(myAnswer(A,B))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;

int t[6];

int main(){
	for(int i = 0 ; i < 6; i++){
		scanf("%d",&t[i]);
	}
	sort(t,t+4);
	sort(t+4,t+6);
	printf("%d\n",t[1]+t[2]+t[3]+t[5]);
	
	return 0;
}

Measured memory_bytes: 2780
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,q=0,r=0,jk,jc;
    cin>>n;
vector<int> c(n),v(n);

jk=n;
jc=n;
for(;n>0;){
    cin>>c[q];
    q++;
    n--;
    
}
q=0;
for(;jk>0;){
    cin>>v[q];
    q++;
    jk--;
}
q=0;
while(jc){
    
    if(c[q]>v[q]){
r=r+c[q]-v[q];
    }
    jc--;
q++;
}
cout<<r<<endl;
return(0);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#----------
N = int(input().strip())
A_list = [int(input().strip()) for _ in range(N)]
#----------
# ボタン番号と、リストのIndex番号を合わせるために、要素[0]にダミー値を挿入
A_list.insert(0,0)

pressed_button={}
end_flag=False
index_button=1
count=0
while end_flag == False:
    count += 1
    pressed_button[str(index_button)] = True
    
    # 次のボタンを指定・チェック
    index_button = A_list[index_button]
    if ( str(index_button) in pressed_button ) or (index_button == 2):
        end_flag = True

if index_button == 2:
    print(count)
else:
    print("-1")


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

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        left.append(a[i])
    else:
        right.append(a[i])
if n % 2 == 0:
    right.reverse()
    arr = right + left
    ans = " ".join(map(str, arr))
    print(ans)
else:
    left.reverse()
    arr = left + right
    ans = " ".join(map(str, arr))
    print(ans)

Measured memory_bytes: 37168
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;
int main() {
  int N ,K;
  std::cin >> N >> K;
  set<int> S;
  for (int i = 0; i < N; i++) {
    S.insert(i+1);
  }
  for (size_t i = 0; i < K; i++) {
    int X,D;
    std::cin >> D;
    for (size_t j = 0; j < D; j++) {
      std::cin >> X;
      S.erase(X);
    }
  }
  std::cout << S.size() << '\n';
}


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

	if (a == "H") {

	}
	else {
		if (b == "H") {
			b = "D";
		}
		else {
			b = "H";
		}
	}

	cout  << b << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=505*505;
int ans,n,p[N],dis[N],L[N],R[N],U[N],D[N];
bool v[N];

void dfs(int x){
	for(int y:{U[x],D[x],L[x],R[x]}) if(dis[x]+v[y]<dis[y]) dis[y]=dis[x]+v[y],dfs(y);
}

signed main(){
	read(n);
	for(int i=1;i<=n*n;i++) read(p[i]),v[i]=1;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dis[(i-1)*n+j]=min({i-1,j-1,n-i,n-j});
	for(int i=1;i<=n;i++) for(int j=2;j<=n;j++) L[(i-1)*n+j]=(i-1)*n+j-1;
	for(int i=1;i<=n;i++) for(int j=1;j<n;j++) R[(i-1)*n+j]=(i-1)*n+j+1;
	for(int i=2;i<=n;i++) for(int j=1;j<=n;j++) U[(i-1)*n+j]=(i-2)*n+j;
	for(int i=1;i<n;i++) for(int j=1;j<=n;j++) D[(i-1)*n+j]=i*n+j;
	for(int i=1;i<=n*n;i++){
		ans+=dis[p[i]]--;
		v[p[i]]=0;
		for(int x:{L[p[i]],R[p[i]],U[p[i]],D[p[i]]}) dis[p[i]]=min(dis[p[i]],dis[x]);
		dfs(p[i]);
	}
	write(ans);
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;


const int MAX = 3010000;
const int MOD = 998244353;

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

// 二項係数計算
ll 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;
}






int N, M;

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

  // 前処理
  COMinit();

  cin >> N >> M;

  ll ans = 0;
  for (int n=M%2; n<=M; n += 2) {
    int D = (M * 3 - n) / 2;
    ll a1 = COM(N, n) * COM(N+D-1, N-1) % MOD;
    ll b1 = N * (COM(N-1, n-1) * COM(N+D-M-1, N-1) % MOD) % MOD;
    ll b2 = N * (COM(N-1, n) * COM(N+D-M-2, N-1) % MOD) % MOD;
    ans = (ans + a1 - b1 - b2 + MOD*2) % MOD;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

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

int main(void){
  while(true){
    int N;
    cin >> N;
    if(N == 0){ break; }

    int n, d, maxx, minx, maxy, miny;
    vector<pair<int, int> > pablo;
    pablo.push_back(make_pair(0, 0));
    maxx = minx = maxy = miny = 0;
    for(int i = 1; i < N; i++){
      cin >> n >> d;
      int newx = pablo[n].first + dx[d];
      int newy = pablo[n].second + dy[d];
      maxx = max(maxx, newx);
      minx = min(minx, newx);
      maxy = max(maxy, newy);
      miny = min(miny, newy);
      pablo.push_back(make_pair(newx, newy));
    }

    cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2988
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if((a*n)>b){
      System.out.println(b);
    }else{
      System.out.println(a*n);
    }  
  } 
}

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

using namespace std;

int main() {

	int A;
	int B;
	cin >> A >> B;

	double b = static_cast<double>(B-1);
	double a = static_cast<double>(A-1);
	double buf = b/a;
	int res = ceil(buf);
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())

v = list(map(int, input().split()))
c = list(map(int, input().split()))

diff = []

for i, x in enumerate(v):
  if x - c[i] > 0:
    diff.append(x- c[i])

    
ans = 0

for x in diff:
  ans += x
  
print(ans)

Measured memory_bytes: 3060
#coding:UTF-8
while True:
    h,w = map(int,raw_input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i%2 == 1:
            if w % 2 == 0:
                print ".#" * (w / 2)
            else:
                print ".#" * (w / 2) + "."
        else:
            if w % 2 == 0:
                print "#." * (w/2)
            else:
                print "#." * (w/2) + "#"
    print ""

Measured memory_bytes: 4212
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    vector<tuple<int, int, char, ll, string>> goods(n);
    REP(i, n){
        int v, w; char t; ll d; string s;
        cin >> v >> w >> t >> d >> s;
        goods[i] = MT(v, w, t, d, s);
    }
    SORT(goods);
    REP(i, n){
        cout << get<0>(goods[i]) << " " << get<1>(goods[i]) 
             << " " << get<2>(goods[i]) << " " << get<3>(goods[i])
             << " " << get<4>(goods[i])<< "\n";
    }
    return 0;
}



Measured memory_bytes: 12196
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int dp[50][4];
int p[100];
int t[100];

int main(){
	int n;
	while(cin >> n && n){
		rep(i, n) cin >> p[i] >> t[i];
		fill(&dp[0][0], &dp[0][0] + 50 * 4, INF);
		dp[0][0] = 0;
		rep(i, n){
			rep(j, 4){
				// i: next pos, j: current weight;
				int pos = (i == 0) ? 0 : p[i-1];
				int tim = (i == 0) ? 0 : t[i-1];

				if(j != 3){
					int need = abs(p[i] - pos) * (j + 1);
					if(need <= t[i] - tim){
						dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + abs(p[i] - pos));
					}
				}
				int need = p[i] + pos * (j + 1);
				if(need <= t[i] - tim){
					dp[i+1][1] = min(dp[i+1][1], dp[i][j] + p[i] + pos);
				}
			}
		}
		
		int id = 0;
		rep(i, n + 1){
			rep(j, 4){
				if(dp[i][j] != INF){
					id = i;
				}
			}
		}
	
		if(id == n){
			int res = INF;
			rep(i, 4) res = min(res, dp[n][i]);
			cout << "OK " << res + p[n-1] << endl;
		}else{
			cout << "NG " << id + 1<< endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
# coding: utf-8
import copy

def bfs(n, ls, mat):
    tmat = copy.deepcopy(mat)
    cnt = 0
    for a, b in ls:
        tmat[a][b] = tmat[b][a] = 0
        visited = [0 for i in range(n+2)]
        que = [a]
        
        while que:
            st = que.pop(0)
            visited[st] = 1
            for i in range(1, n + 1):
                if tmat[st][i] == 1 and visited[i] != 1:
                    que.append(i)
                    
        tmat = copy.deepcopy(mat)
        if sum(visited) != n:
            cnt += 1
    return cnt

n, m = list(map(int, input().split()))
ls = []
for i in range(m):
    a, b = list(map(int, input().split()))
    ls.append((a, b))
    
mat = [[0 for i in range(m + 2)] for j in range(m + 2)]
for a, b in ls:
    mat[a][b] = mat[b][a] = 1
    
cnt = bfs(n, ls, mat)
print(cnt)

Measured memory_bytes: 3568
# solution 3
import heapq
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Q = []
s = []
heapq.heappush(Q, (-A[0]-B[0]-C[0], 0, 0, 0))
for n in range(K):
    q, i, j, k = heapq.heappop(Q)
    print(-q)
    if i < X-1:
        if [i+1, j, k] not in s:
            heapq.heappush(Q, (- A[i+1] - B[j] - C[k], i+1, j, k))
            s.append([i + 1, j, k])
    if j < Y-1:
        if [i, j+1, k] not in s:
            heapq.heappush(Q, (- A[i] - B[j+1] - C[k], i, j+1, k))
            s.append([i, j + 1, k])
    if k < Z-1:
        if [i, j, k+1] not in s:
            heapq.heappush(Q, (- A[i] - B[j] - C[k+1], i, j, k+1))
            s.append([i, j, k + 1])

Measured memory_bytes: 4592
#include<stdio.h>

int main() {
  int n;
  int i;
  char s[110] = {};
  char ans[210] = {};
  int numleft[110] = {};
  int numright[110] = {};
  int lmax = 0;
  int rmax = 0;
  scanf("%d\n", &n);
  for (i = 1; i < n+1; i++) {
    scanf("%c", &s[i]);
    if (s[i] == ')') {
      numleft[i] = numleft[i-1] + 1;
    } else if (s[i] == '(') {
      numleft[i] = numleft[i-1] - 1;
    }
    if (lmax <= numleft[i]) {
      lmax = numleft[i];
    }
    /*printf("%d\n", numleft[i]);*/
  }
  for (i = n; i > 0; i--) {
    if (s[i] == ')') {
      numright[i] = numright[i+1] - 1;
    } else if (s[i] == '(') {
      numright[i] = numright[i+1] + 1;
    }
    if (rmax <= numright[i]) {
      rmax = numright[i];
    }
  }
  /*printf("%d %d\n", lmax, rmax);*/
  for (i = 1; i < lmax+1; i++) {
    ans[i] = '(';
  }
  for (i = lmax+1; i < lmax + n+1; i++) {
    ans[i] = s[i-lmax];
  }
  for (i = lmax + n+1; i < lmax + n + rmax + 1; i++) {
    ans[i] = ')';
  }
  for (i = 1; i < n+lmax+rmax+1; i++) {
    printf("%c", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 10;
int cnt[maxn];
ll ans;
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		for(int j = i; j <= n; j += i)
			++cnt[j]; 
	for(int i = 1; i<= n; ++i)
		ans += 1ll * i * cnt[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 42764
#include <iostream>
#include <cmath>
#include <algorithm>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define INF 1000000000

using namespace std;

int N, A, B, C;
int l[10];

int dfs(int cur, int a, int b, int c) {
	if ( cur == N ) {
		if ( a == 0 || b == 0|| c == 0 ) return INF;
		else return abs(A - a) + abs(B - b) + abs(C - c) - 30;
	}
	int ret0 = dfs(cur + 1, a, b, c);
	int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
	return min(ret0, min(ret1, min(ret2, ret3)));
}

int main(void) {
    scanf("%d %d %d %d", &N, &A, &B, &C);
    REP(i, 0, N) scanf("%d", &l[i]);
    
    printf("%d\n", dfs(0, 0, 0, 0));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<tuple<int,int,int>> l;
  for(int i=0;i<m;i++){
    int l1,r1;      
    cin>>l1>>r1;
    l.push_back(make_tuple(r1-l1,l1,r1));
  }
  int min_l=0;
  int max_l=n;
  sort(l.begin(),l.end());
  min_l = get<1>(l[0]);
  max_l = get<2>(l[0]);

  for(int i=1;i<m;i++){
    int l1 = get<1>(l[i]);
    int r1 = get<2>(l[i]);
    // unit
    if(min_l<=l1){
      min_l = l1;
    }
    if(max_l >= r1){
      max_l = r1;
    }
    
    // exclude
    if(min_l>r1 || max_l< l1){
      cout<<0;
      return 0;
    } 
    
  }
  cout<<max_l-min_l+1; 
}


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

typedef long long ll;

using namespace std;


const ll MOD=1000000007ll;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }

	void print(){
		for(int i=0;i<par.size();i++ ){
			cout<<par[i]<<" ";
		}
		cout<<endl;
	}
};


typedef vector<vector<int> > Graph;







int main(){
	

	int N,M;
	cin>>N>>M;


	vector<pair<int,int> > vecp(M);

	for(int i=0;i<M;i++){
		cin>>vecp[i].first>>vecp[i].second;	
		--vecp[i].first;
		--vecp[i].second;	
	}
    /*
	for(int i=0;i<M;i++){
		cout<<vecp[i].first<<":"<<vecp[i].second<<endl;
	}
	*/

	int count=0;

	for(int i=0;i<M;i++){
		UnionFind uf(N);
		for(int j=0;j<M;j++){
			if(i==j)continue;
			uf.merge(vecp[j].first,vecp[j].second);
		}
		//uf.print();
		if(!uf.issame(vecp[i].first,vecp[i].second)){
			++count;
		}
	}

     cout<<count<<endl;

}



Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int a[214514];
double b[214514];
signed main(){
	ic(n)
	rep(0,i,n){
		cin>>b[i];
	}
	sort(b,b+n);
	double sum=(b[0]+b[1])/2;
	rep(2,i,n){
		sum=(sum+b[i])/2;
	}
	c(sum)
}				

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

d = dict()

for i in range(N):
    s = input()
    try:
        d[s] += 1
    except KeyError:
        d[s] = 1

max_value = max(d.values())


res_ls = []

for k, v in d.items():
    if v == max_value:
        res_ls.append(k)
        
for r in sorted(res_ls):
    print(r)

Measured memory_bytes: 93784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> net(n);
    REP(i, m){
        ll ui, vi, si;
        cin >> ui >> vi >> si;
        ui--; vi--;
        net.at(ui).emplace_back(vi, si);
        net.at(vi).emplace_back(ui, si);
    }

    vector<bool> vis(n, false);
    vector<ll> depth(n, -1);
    vector<ll> bias(n, 0);
    vis.at(0) = true;
    depth.at(0) = 0;
    queue<ll> que;
    que.push(0);

    ll lb = 1, ub = numeric_limits<ll>::max();
    while(!que.empty()){
        const ll u = que.front(); que.pop();
        for(const auto& p : net.at(u)){
            const ll v = p.first;
            const ll s = p.second;
            if(!vis.at(v)){
                vis.at(v) = true;
                depth.at(v) = depth.at(u) + 1;
                bias.at(v) = s - bias.at(u);
                if(depth.at(v) % 2 == 0){
                    // bv + x >= 1 <=> x >= 1 - bv
                    lb = max(lb, 1 - bias.at(v));
                }else{
                    // bv - x >= 1 <=> bv - 1 >= x
                    ub = min(ub, bias.at(v) - 1);
                }
                que.push(v);
            }else{
                if(depth.at(u) % 2 == 0 && depth.at(v) % 2 == 0){
                    // bu + x + bv + x = s <=> 2x = s - bu - bv
                    const ll twox = s - bias.at(u) - bias.at(v);
                    if(twox <= 0 || twox % 2 != 0){
                        cout << 0 << endl;
                        return 0;
                    }else{
                        lb = max(lb, twox / 2);
                        ub = min(ub, twox / 2);
                    }
                }else if(depth.at(u) % 2 == 1 && depth.at(v) % 2 == 1){
                    // bu - x + bv - x = s <=> bu + bv - s = 2x
                    const ll twox = bias.at(u) + bias.at(v) - s;
                    if(twox <= 0 || twox % 2 != 0){
                        cout << 0 << endl;
                        return 0;
                    }else{
                        lb = max(lb, twox / 2);
                        ub = min(ub, twox / 2);
                    }
                }else{
                    // bu + x + bv - x = s or bu - x + bv + x = s
                    if(bias.at(u) + bias.at(v) != s){
                        cout << 0 << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout << max(ub - lb + 1, 0LL) << endl;

    return 0;
}


Measured memory_bytes: 9728
#Created on 2017-05-13
ans =[]
n,m = gets.chop.split(" ").map(&:to_i)
m.times do |a,b|
  a,b =gets.chop.split(" ").map(&:to_i)
  ans<<a<< b 
end

n.times do |i|
  puts ans.sort.count(i+1)
end

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A,B,C;
char dp[100005][3][3][3];
string s[100005];
signed main(){
	cin>>N>>A>>B>>C;
	if(A+B+C<=2){
		rep(i,N+1)rep(j,3)rep(k,3)rep(l,3)dp[i][j][k][l]='Z';
		dp[0][A][B][C]='A';
		rep(i,N){
			cin>>s[i];
			rep(j,3)rep(k,3)rep(l,3){
				if(dp[i][j][k][l]=='Z')continue;
				if(s[i]=="AB"){
					if(k)dp[i+1][j+1][k-1][l]='A';
					if(j)dp[i+1][j-1][k+1][l]='B';
				}else if(s[i]=="AC"){
					if(l)dp[i+1][j+1][k][l-1]='A';
					if(j)dp[i+1][j-1][k][l+1]='C';
				}else {
					if(k)dp[i+1][j][k-1][l+1]='C';
					if(l)dp[i+1][j][k+1][l-1]='B';
				}
			}
		}
		rep(i,3)rep(j,3)rep(k,3){
			if(dp[N][i][j][k]!='Z'){
				int nowi=i,nowj=j,nowk=k;
				vector<char>ans;
				for(int l=N;l>0;l--){
					char c=dp[l][nowi][nowj][nowk];
					if(c=='A'){
						ans.pb('A');
						nowi--;
						if(s[l-1]=="AB")nowj++;
						else nowk++;
					}else if(c=='B'){
						ans.pb('B');
						nowj--;
						if(s[l-1]=="AB")nowi++;
						else nowk++;
					}else {
						ans.pb('C');
						nowk--;
						if(s[l-1]=="BC")nowj++;
						else nowi++;
					}
				}
				cout<<"Yes\n";
				reverse(all(ans));
				for(char c:ans)cout<<c<<endl;
				return 0;
			}
		}
		cout<<"No\n";return 0;
	}
	vector<char>ans;
	rep(i,N){
		cin>>s[i];
		if(s[i]=="AB"){
			if((A|B)==0){
				cout<<"No\n";return 0;
			}
			if(A<B){
				ans.pb('A');
				A++;B--;
			}else {
				ans.pb('B');
				A--;B++;
			}
		}else if(s[i]=="AC"){
			if((A|C)==0){
				cout<<"No\n";return 0;
			}
			if(A<C){
				ans.pb('A');
				A++;C--;
			}else {
				ans.pb('C');
				A--;C++;
			}
		}else {
			if((B|C)==0){
				cout<<"No\n";return 0;
			}
			if(B<C){
				ans.pb('B');
				B++;C--;
			}else {
				ans.pb('C');
				B--;C++;
			}
		}
	}
	cout<<"Yes\n";
	for(char c:ans)cout<<c<<endl;
}


Measured memory_bytes: 9496
import java.util.Scanner;

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

		String s = sc.next();

		if(s.equals("A")) {
			System.out.println("T");
		}else{
			if(s.equals("T")) {
				System.out.println("A");
			}
			else{
				if(s.equals("G")) {
					System.out.println("C");
				}else {
					if(s.equals("C")) {
						System.out.println("G");
					}
				}
			}
		}
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int area=a*b;
	int length=2*a+2*b;
	System.out.println(area + " " + length);
    }
}

Measured memory_bytes: 26000
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>
#include <deque>

using namespace std;

int main(){

    int H,W,K;
    char a;
    cin >> H >> W >> K;
    int C[12][1010];
    int acc[12][1010];
    
    for(int i=0;i<H;++i){
        acc[i][0] = 0; 
        for(int j=0;j<W;++j){
            cin >> a;
            C[i][j] = a-48;
            acc[i][j+1] = acc[i][j] + C[i][j];
        }
    }

    int ans(10000);
    int tmp(0), d(0);
    int count(0), pj(0);
    bool bk(false);
    
    int divH = 1 << (H-1);
    for(int div=0;div<divH;++div){
        tmp = 0;
        d = div;
        bk = false;
        while(d!=0){
            tmp += d%2;
            d /= 2;
        }
        if(ans < tmp) continue;

        for(int j=0;j<W;++j){
            d = div;
            count = 0;
            for(int i=0;i<H;++i){
                count += C[i][j];
                if(count > K){
                    bk=true;
                    break;
                }
                if(d%2==1) count = 0;
                d /= 2;
            }
            if(bk) break;
        }
        if(bk) continue;
        
        pj = 0;
        for(int j=1;j<W;++j){
            d = div;
            // printf("div:%d j:%d pj:%d\n", div, j, pj);
            count = 0;
            for(int i=0;i<H;++i){
                count += acc[i][j+1] - acc[i][pj];
                if(count > K){
                    // printf("div:%d j:%d pj:%d i:%d count:%d\n", div, j, pj, i, count);
                    ++tmp;
                    pj = j;
                    break;
                }
                if(d%2==1) count = 0;
                d /= 2;
            }
        }
        // printf("%d %d\n", div, tmp);
        ans = min(ans,tmp);
    }

    cout << ans << endl;

    // for(int i=0;i<H;++i){
    //     for(int j=0;j<=W;++j){
    //         cout  << acc[i][j] << " " ;
    //     }
    //     cout << endl;
    // }
                                     
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main(void){
  int N;
  cin>>N;
  long x[N],y[N],h[N];
  for(int i=0;i<N;i++){
      cin>>x[i]>>y[i]>>h[i];
  }
  for(int i=0;i<=100;i++){
      for(int j=0;j<=100;j++){
          long H=-1;
          for(int k=0;k<N;k++){
              if(h[k]!=0){
                H=h[k]+abs(x[k]-i)+abs(y[k]-j);
              }
          }
          bool check=true;
          for(int k=0;k<N;k++){
              int hight=H-abs(x[k]-i)-abs(y[k]-j);
              if(max(hight,0)!=h[k]){check=false;}
          }
          if(check){cout<<i<<' '<<j<<' '<<H; return 0;}
      }
  }
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

const int MAX_N = 200020;

int par[MAX_N];
int Rank[MAX_N];
int size;

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
	size = n;
}

int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	size--;
	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y]) {
			Rank[x]++;
		}
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	init(200020);
	rep(i, N) {
		int K; cin >> K;
		rep(j, K) {
			int L; cin >> L;
			unite(i, L + 100010);
			///cout << i << " " << L + 100010 << endl;
		}
	}
	
	rep(i, N - 1) {
		//cout << par[i] << " " << par[i + 1] << endl;
		if (!same(i, i + 1)) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
    {
     ll int n,k;
     cin>>n>>k;
     if(n*500>=k)
     cout<<"Yes"<<endl;
     else
     cout<<"No"<<endl;
  
  
  
  
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







Measured memory_bytes: 10644
#include <bits/stdc++.h>
using namespace std;
int solve() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int dp[n];
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (i == 1) {
			dp[i] = abs(arr[i] - arr[i - 1]) + dp[i - 1];

		}
		else {
			int op1 = abs(arr[i] - arr[i - 1]) + dp[i - 1];
			int op2 = abs(arr[i] - arr[i - 2]) + dp[i - 2];
			dp[i] = min(op1, op2);
		}
	}
	return dp[n - 1];

}
int main()
{

	cout << solve();
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i;
	cin>>n;
	string s;
	cin>>s;
	int r=0,w=0;
	REP(i,0,n-1){
		if(s[i]=='R') r++;
		else w++; 
	}
	int num=0;
	REP(i,0,r-1){
		if(s[i]=='W') num++;
	}
	cout<<num;
	return 0;
}

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

const int N = 20;
int n,m,x;
int c[N];
int a[N][N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	
	bool hano = false;
	int ans = (int)2e9;
	
	for(int i=0;i<(1<<n);i++){
		int cnt = 0;
		vector<int> v(m);
		for(int j=0;j<n;j++){
			if( i & (1<<j)){
				cnt += c[j];
				for(int k=0;k<m;k++){
					v[k] += a[j][k];
				}
			}
		}
		bool hnhn = true;
		for(int j=0;j<m;j++){
			if(v[j] < x) hnhn = false;
		}
		if(hnhn){
			hano = true;
			ans = min(ans,cnt);
		}
	}
	
	if(hano){
		cout<<ans;
	}
	else{
		cout<<-1;
	}
	
	return 0;
}


Measured memory_bytes: 3656
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_1-D: Maximum Profit

#include <algorithm>
#include <iostream>

static int max_profit(int const rs[], const unsigned int n)
{
  auto r0 = rs[0], r1 = rs[1];

  auto cur_p = r1 - r0;
  auto max_p = cur_p;
  auto min_r = std::min(r0, r1);

  for (auto i = 2u; i < n; ++i) {
    const auto r = rs[i];
    cur_p = r - min_r;
    max_p = std::max(max_p, cur_p);
    min_r = std::min(min_r, r);
  }

  return max_p;
}

int main()
{
  unsigned int n;
  std::cin >> n;
  int rs[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> rs[i];
  }

  const int max_p = max_profit(rs, n);
  std::cout << max_p << std::endl;
}

// eof

Measured memory_bytes: 3864
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(u==s) a--;
    else if(u==t) b--;
    cout<<a<<" "<<b<<endl;

    return 0;
}

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

int main()
{
    int a, b, x;
    std::cin >> a >> b >> x;

    if (a <= x && b >= x - a) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,i,ans;
int main(){
	cin>>n;
	for(i=sqrt(n);i>=1;i--)
	{
		if(n%i==0)
			break;
	}
	b=n/i;
	while(b!=0)
	{
		b=b/10;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans =[]

for _ in range(N):
  ans.append(-1)

for i in range(1, N + 1)[::-1]:
  C = i*2
  BALL = A[i-1]
  while C <= N:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

print(ans.count(1))
ans2 = []
for i in range(N):
  if ans[i] == 1:
    ans2.append(i+1)

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)


Measured memory_bytes: 20536
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	max_n, max_cnt := 1, 0
	for i := n; i > 0; i-- {
		num := i
		cnt := 0
		for num % 2 == 0 {
			cnt++
			num /= 2
		}
		if cnt > max_cnt {
			max_cnt = cnt
			max_n = i
		}
	}

	fmt.Println(max_n)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i,j;
    while(cin>>n,n){
        vector<string> table(n);
        for(i=0;i<n;i++){
            cin>>table[i];
            for(j=0;j<table[i].length();j++){
                if(table[i][j]=='.'){
                    table[i][j]=' ';
                }
                else{
                    if(j!=0){
                        table[i][j-1]='+';
                        for(int k=i-1;k>=0&&((j-1)<table[k].length());k--){
                            if(table[k][j-1]==' ') table[k][j-1]='|';
                            else break;
                        }
                    }
                    break;
                }
            }
        }
        for(auto s:table) cout<<s<<endl;
    }
}


Measured memory_bytes: 3816