akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll max1(ll a, ll b, ll c, ll d) { return max(a, max(b, max(c, d))); }

ll min1(ll a, ll b, ll c, ll d) { return min(a, min(b, min(c, d))); }
ld min1(ld a, ld b, ld c, ld d) { return min(a, min(b, min(c, d))); }

ll arr2[N][3];

ll mp(char d) {
  if (d == 'R')
    return 0;
  if (d == 'L')
    return 1;
  if (d == 'U')
    return 2;
  if (d == 'D')
    return 3;
}

ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
ll n;
ld eval(ld t) {

  t = max((ld)0, t);

  ld xmax, xmin, ymax, ymin;
  xmax = ymax = -inf;
  xmin = ymin = inf;

  for (ll i = 1; i <= n; i++) {
    xmax = max(xmax, arr2[i][0] + t * dir[arr2[i][2]][0]);
    xmin = min(xmin, arr2[i][0] + t * dir[arr2[i][2]][0]);
    // cout << arr2[i][0] + t * dir[arr2[i][2]][0] << endl;
    ymax = max(ymax, arr2[i][1] + t * dir[arr2[i][2]][1]);
    ymin = min(ymin, arr2[i][1] + t * dir[arr2[i][2]][1]);
  }

  // cout << xmax << " " << xmin << " " << ymax << " " << ymin << endl;
  return (xmax - xmin) * (ymax - ymin);
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;

  ll R[2][2], U[2][2], D[2][2], L[2][2];

  for (ll i = 0; i < 2; i++) {
    for (ll j = 0; j < 2; j++) {
      if (j == 0) {
        R[i][j] = U[i][j] = L[i][j] = D[i][j] = inf;
      } else
        R[i][j] = U[i][j] = L[i][j] = D[i][j] = -inf;
    }
  }
  for (ll i = 1; i <= n; i++) {

    ll arr[3];
    char d;
    cin >> arr[0] >> arr[1] >> d;

    arr2[i][0] = arr[0];
    arr2[i][1] = arr[1];
    arr2[i][2] = mp(d);
    if (d == 'R') {
      for (ll j = 0; j < 2; j++) {
        R[j][0] = min(R[j][0], arr[j]);
        R[j][1] = max(R[j][1], arr[j]);
      }
    }
    if (d == 'L') {

      for (ll j = 0; j < 2; j++) {
        L[j][0] = min(L[j][0], arr[j]);
        L[j][1] = max(L[j][1], arr[j]);
      }
    }

    if (d == 'U') {
      for (ll j = 0; j < 2; j++) {
        U[j][0] = min(U[j][0], arr[j]);
        U[j][1] = max(U[j][1], arr[j]);
      }
    }

    if (d == 'D') {
      for (ll j = 0; j < 2; j++) {
        D[j][0] = min(D[j][0], arr[j]);
        D[j][1] = max(D[j][1], arr[j]);
      }
    }
  }

  ld t1 = L[0][1] - R[0][1];
  ld t2 = L[0][0] - R[0][0];
  ld t3 = D[1][1] - U[1][1];
  ld t4 = D[1][0] - U[1][0];

  t1 /= 2;
  t2 /= 2;
  t3 /= 2;
  t4 /= 2;

  ld res = min1(eval(t1), eval(t2), eval(t3), eval(t4));

  ld low = 0, high = 1e9;
  ll cnt = 1000;
  while (low <= high && cnt--) {
    ld left1 = (low * 2 + high) / 3.0;
    ld right1 = (low + 2 * high) / 3.0;

    if (eval(left1) > eval(right1))
      low = left1;
    else
      high = right1;
  }

  res = min(res, eval(low));

  cout << fixed << setprecision(10) << res << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int a;
    int x=0;
    int y=1;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> a;
        
        if(a%4==0){
            
            x += 1;
            
        } else if(a%2==1){
            
            x -= 1;
            
        } else {
            
            y = 0;
            
        }
        
    }
    
    x += y;
    
    if(x>=0){
        
        cout << "Yes" << endl;
        
    } else {
        
        cout << "No" << endl;
        
    }
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;

const int INF=1e18+5;

int32_t main()
{
    fast

   int test=1;
   //cin>>test;


  while(test--)
  {
  string s,t;
  cin>>s>>t;
  int m=s.size(),n=t.size();
  int L[m+1][n+1];
  for(int i=0;i<=m;i++)
  {
    for(int j=0;j<=n;j++)
    {
      if(i==0||j==0)L[i][j]=0;
      else if(s[i-1]==t[j-1])L[i][j]=L[i-1][j-1]+1;
      else L[i][j]=max(L[i-1][j],L[i][j-1]);
    }
  }

  // int index=L[m][n];
  string ans="";
  // ans[index]='\0';
  int i=m,j=n;
  while(i>0&&j>0)
  {
    if(s[i-1]==t[j-1])
    {
      // ans[index-1]=s[i-1];
      ans+=s[i-1];
      i--;
      j--;
      // index--;
    }
    else if(L[i-1][j]>L[i][j-1])i--;
  else j--;
  }

reverse(all(ans));
  cout<<ans;

  //while loop ending 
  }



return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;

	if (N <= 2) {
		cout << -1 << endl;
		return 0;
	}

	vector<VI> dp(1010);
	char ans[1010][1010];

	char a3[3][3] = {
		{'a','.','.'},
		{'a','.','.'},
		{'.','b','b'}
	};

	if (N == 3) {
		REP(i, 3) {
			REP(j, 3)cout << a3[i][j];
			cout << endl;
		}
		return 0;
	}
	char a4[4][4] = {
		{'a','a','b','c'},
		{'d','d','b','c'},
		{'e','f','g','g'},
		{'e','f','h','h'}
	};
	char a5[5][5] = {
		{'a','a','b','b','c'},
		{'h','.','.','j','c'},
		{'h','.','.','j','d'},
		{'g','i','i','.','d'},
		{'g','f','f','e','e'}

	};

	char a6[6][6] = {
		{'a','.','.','b','b','a'},
		{'a','c','c','.','.','a'},
		{'b','.','.','d','d','b'},
		{'b','a','a','.','.','b'},
		{'c','.','.','e','e','c'},
		{'c','a','a','.','.','c'}

	};
	char a7[7][7] = {
		{'a','.','.','a','.','.','a'},
		{'a','.','.','a','.','.','a'},
		{'.','b','b','.','b','b','d'},
		{'a','.','.','a','.','.','d'},
		{'a','.','.','a','.','.','e'},
		{'.','b','b','.','b','b','e'},
		{'a','a','c','c','e','e','.'}

	};
	dp[6].push_back(6);
	dp[4].push_back(4);
	dp[5].push_back(5);
	dp[7].push_back(7);
	eFOR(i, 8, N) {
		eFOR(j, 4, 8) {
			if (i - j >= 4) {
				dp[i] = dp[i - j];
				dp[i].push_back(j);
				break;
			}
		}
	}
	/*for (int i : dp[N]) {
		cout << i << " ";
	}
	cout << endl;*/
	REP(i, N) {
		REP(j, N)ans[i][j] = '.';
	}

	int k = 0;
	int key = 0;
	while (k < dp[N].size()) {


		int a = dp[N][k];

		if (a == 4) {
			REP(b, 4) {
				REP(c, 4)ans[key + b][key + c] = a4[b][c];
			}
			key += 4;
		}
		if (a == 5) {
			REP(b, 5) {
				REP(c, 5)ans[key + b][key + c] = a5[b][c];
			}
			key += 5;
		}
		if (a == 6) {
			REP(b, 6) {
				REP(c, 6)ans[key + b][key + c] = a6[b][c];
			}
			key += 6;
		}
		if (a == 7) {
			REP(b, 7) {
				REP(c, 7)ans[key + b][key + c] = a7[b][c];
			}
			key += 7;
		}
		k++;
	}

	REP(i, N) {
		REP(j, N)cout << ans[i][j];
		cout << endl;
	}

	
	return 0;
}



Measured memory_bytes: 4352
n,m = map(int,input().split())
l = len(format(m,"b"))

sa = m-n
ans = 0
if sa % 2 ==  1:
    if sa % 4 != 3:
        ans += 1
else:
    if n % 2 == 0:
        if sa % 4 != 0:
            ans += 1
    else:
        if sa % 4 == 0:
            ans += 1
for i in range(1,l):
    count = 0
    x = m % 2**(i+1)
    y = n % 2**(i+1)
    if x < 2**i:
        count += 0
    else:
        count += x-2**i+1
    if y < 2**i:
        count += 2**i
    else:
        count += 2**(i+1)-y
    

    if count % 2 == 1:
        ans += 2**i
        
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int field, p;
    int[] players;
    char[] yama;

    void run(){
	while(sc.hasNext()){
	    p = sc.nextInt();
	    if(p!=0){
		players = new int[p];
		field = 0;
		yama = sc.next().toCharArray();
		solve();
	    }
	}
    }

    void solve(){
	int turn = 0;
	for(int i=0; i<yama.length; i++){
	    if(yama[i]=='M'){
		players[turn]++;
	    }
	    else if(yama[i]=='S'){
		field += players[turn]+1;
		players[turn] = 0;
	    }
	    else if(yama[i]=='L'){
		players[turn] += field+1;
		field = 0;
	    }
	    turn = (turn+1)%p;
	}
	Arrays.sort(players);

	for(int i=0; i<players.length; i++)
	    System.out.print(players[i]+" ");
	System.out.println(field);
    }
}

Measured memory_bytes: 22120
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
typedef long long LL;
const int MaxN = 2e5;
using namespace std;
char s[MaxN + 5];
int succ[MaxN + 5], a[MaxN + 5];
int nxt[MaxN + 5][30];
int cnt[30], now[30];
void Init(){
	int len = strlen(s + 1);
	for(int i = 1;i <= len;i++) a[i] = s[i] - 'a' + 1; 
	memset(succ, 0, sizeof(succ));
	memset(cnt, 0, sizeof(cnt));
	int sum = 0;
	for (int i = len; i >= 1; i--){
		cnt[a[i]]++, sum = 0;
		for (int j = 1; j <= 26; j++){
			sum += (cnt[j] > 0 ? 1 : 0);
		}
		if(sum == 26){
			succ[i] = succ[i + 1] + 1;
			memset(cnt, 0, sizeof(cnt));
		}
		else succ[i] = succ[i + 1];
	}
	memset(nxt, -1 ,sizeof(nxt));
	memset(now, -1, sizeof(now));
	a[0] = 28;
	for (int i = len; i >= 0; i--){
		for (int j = 1; j <= 26; j++){
			nxt[i][j] = now[j];
		}
		now[a[i]] = i;
	}
}
void Solve(){
	string res = "";
	int len = succ[1] + 1;
	int pre = 0;
	for (int i = 1; i <= len; i++){
		int pos;
		for (int j = 1; j <= 26; j++){
			pos = nxt[pre][j];
			if(pos == -1 || succ[pos + 1] < len - i){
				res += (j + 'a' - 1);
				break;
			}
		}
		pre = pos;
	}
	cout << res << endl;
}
int main()
{
	while(~scanf("%s", s + 1)){
		Init();
		Solve();
	}
}

Measured memory_bytes: 25600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String ans = "";
        if (400 <= N && N < 600) {
        	ans = "8";
        } else if (600 <= N && N < 800) {
        	ans = "7";
        } else if (800 <= N && N < 1000) {
        	ans = "6";
        } else if (1000 <= N && N < 1200) {
        	ans = "5";
        } else if (1200 <= N && N < 1400) {
        	ans = "4";
        } else if (1400 <= N && N < 1600) {
        	ans = "3";
        } else if (1600 <= N && N < 1800) {
        	ans = "2";
        } else if (1800 <= N && N < 2000) {
        	ans = "1";
        }
        System.out.println(ans); 
    }
}

Measured memory_bytes: 35692
#include <stdio.h>

int main()
{
	int i, N, A, flag[1000001] = {};
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &A);
		flag[A]++;
	}
	
	int j, ans = 0;
	for (i = 1; i <= 1000000; i++) {
		if (flag[i] == 0) continue;
		else if (flag[i] == 1) ans++;
		for (j = i; j <= 1000000; j += i) flag[j] = 0;
	}
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 5608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

//int min(int a, int b) {
//    if (a > b)
//        return b;
//    else
//        return a;
//}

int main()
{
  int a ,b, c, d, e, X, Y;
  //long long  a, b, c, d, e, X, Y;
  //  double  c;
  int  A[200003]={};
//  long long  A[100003]={};
//  long long  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long ans=1;
  int max=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d%d", &a, &b, &c);
//  cnt = strlen(t);
// printf("%d\n",a);
  

  if(a*b >c)printf("%d\n",c);
  else printf("%d\n",a*b);
  

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   
//  ans=a*3;
//  ans=(ans+b)/2;
//  printf("%d\n", ans);

  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define MAX_M 300000
using Graph = vector<vector<int> >;
int N, M;
bool flag = false;

vector<bool> seen;
void dfs(const Graph &G, int v, int cnt) {
  if (cnt >= 2) return;
  seen[v] = true;
  for (auto next_v : G[v]) {
    if (next_v == N) flag = true;
    if (seen[next_v]) continue;
    dfs(G, next_v, cnt + 1);
  }
}

int main() {
  cin >> N >> M;
  Graph G(MAX_M);

  REP(i, M) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
  }

  seen.assign(M, false);
  dfs(G, 1, 0);
  if (flag)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include <string>

int solve_A() {
  int a;
  std::cin >> a;

  if (a >= 3200) {
    std::string s;
    std::cin >> s;
    std::cout << s;
  } else {
    std::cout << "red";
  }

  return 0;
}

int main() {
  return solve_A();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll a,b,x;
    cin >> a >> b >> x;
    ll out = b/x - a/x;
    if(a%x==0) out++;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(){
	char day[3];
 	int i, max_len = 0, len = 0;
 	for(i = 0; i < 3; i++){
		scanf("%c", &day[i]);
	}
	for(i = 0; i < 3; i++){
		if(day[i] == 'R'){
			len++;
          	if(max_len < len){
				max_len = len;
			}
		}else if(day[i] == 'S'){
			if(max_len < len){
				max_len = len;
			}
			len = 0;
		}
	}
	printf("%d\n", max_len);
	return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   ll a[4]; 
   rep(i,0,4) cin >> a[i];

   ll ans = -1e18;
   ans = max(ans, a[0]*a[2]);
   ans = max(ans, a[0]*a[3]);
   ans = max(ans, a[1]*a[2]);
   ans = max(ans, a[1]*a[3]);
   cout << ans << "\n";
}

Measured memory_bytes: 3572
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int count = 700;
		for(int i=0; i<3; i++) {
			if(s.charAt(i) == 'o') {
				count+=100;
			}
		}
		System.out.println(count);
	}

}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    string s;
    cin >> n >> s;

    outYes(s.substr(0,n/2) + s.substr(0, n/2) == s);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

char g[100007];
int res[100007];
int main()
{
    scanf("%s",g);
    int len=strlen(g);

    g[len]='R';
    int now=0, p=0;
    while(now<=len)
    {
        int count=0;
        while(g[now]=='R'){ count++; now++; }
        p=now;
        res[p-1]+=(count+1)/2;
        res[p]+=count/2;
        count=0;
        while(g[now]=='L'){ count++; now++; }
        res[p-1]+=count/2;
        res[p]+=(count+1)/2;
    }

    for(int i=0; i<len; i++){ printf("%d ",res[i]); }
    printf("\n");
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout<<#a<<"="<<a<<endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define vl vector<ll>
#define pll pair<ll, ll>
#define ii pair<ll,ll>
#define vi vector<ll>
#define MX 600000
#define MXX 1000000000
using namespace std;

void solve(){
    ll n, d;
    cin>>n>>d;
    d=d*d;
    ll ct=0;
    for(int i=0;i<n;i++)
    {
        ll x, y;
        cin>>x>>y;
        if(x*x+y*y<=d) ct++;
    }
    cout<<ct<<endl;
}

int main()
{
    fast;
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
void dfs(vector<vector<int>>& vec, int index, int& res, int cost,vector<int>& val,int x) {
	if (cost >= res) return;
	if (index == vec.size()) {
		int num = 0;
		for (int v : val) {
			if (v >= x) num++;
		}
		if (num == vec[0].size() - 1) res = cost;
		return;
	}
	dfs(vec, index + 1, res, cost, val, x);
	for (int i = 1; i < vec[index].size();i++) {
		val[i - 1] += vec[index][i];
	}
	dfs(vec, index + 1, res, cost + vec[index][0], val, x);
	for (int i = 1; i < vec[index].size(); i++) {
		val[i - 1] -= vec[index][i];
	}
}
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>>vec(n, vector<int>(m + 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= m; j++) cin >> vec[i][j];
	}
	int res = INT_MAX,cost=0;
	vector<int>val(m,0);
	dfs(vec, 0, res, cost, val,x);
	if (res == INT_MAX) cout << -1 << endl;
	else cout << res << endl;
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    ll N;
    cin >> N;
    for (ll A=1; A<=1000000; A++) {
        ans += (N+A-1)/A-1;
    }

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





Measured memory_bytes: 3632
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 1000005;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    vector<int> vec(n);
                    vector<int> cnt(MAX, 0);
                    for(int i = 0; i < n; i++)
                        cin>>vec[i];
                    sort(vec.begin(), vec.end());
                    ll ans = 0;
                    for(int i = 0; i < n; i++){
                        if(cnt[vec[i]] != 0){
                            cnt[vec[i]] = 2;
                            continue;
                        }
                        cnt[vec[i]] = 1;
                        for(int j = vec[i]*2; j < MAX; j += vec[i])
                            cnt[j] = 2;
                    }
                    for(int i : vec)
                        ans += cnt[i] == 1;
                    cout<<ans;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}

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

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

    int N;
    long long x;
    cin >> N >> x;
    long long a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    sort(a, a + N);
    int count = 0;
    while (x >= a[count] && count <= N) {
        x -= a[count++];
    }

    if (x > 0 && count == N) --count;

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main() {
	int K, S;
	int cnt = 0;
	scanf("%d%d", &K, &S);
	for (int x = 0; x <= K; x++){
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (0 <= z&&z <= K) cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

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

int pcnt(int x){
  return __builtin_popcount(x);
}

int f(int x){
  if(x == 0) return 0;
  else return f(x%pcnt(x))+1;
}

int main() {
  int n,pc = 0;
  string s;
  cin >> n >> s;
  vector<int>x(n);
  vector<int>ans(n);
  rep(i,0,n){
    x[i] = s[i]-'0';
    if(s[i] == '1') pc++;
  }
  rep(b,0,2){
    int npc = pc,r0 = 0;
    if(b == 0) npc++;
    else npc--;
    if(npc <= 0) continue;
    rep(i,0,n){
      r0 = (2*r0)%npc;
      r0 += x[i];
    }
    int k = 1;
    for(int i = n-1;i >= 0;i--){
      int r = r0;
      if(x[i] == b){
        if(b == 0) r = (r+k)%npc;
        else r = (r-k+npc)%npc;
        ans[i] = f(r)+1;
      }
      k = (2*k)%npc;
    }
  }
  rep(i,0,n) cout << ans[i] << endl;
}

Measured memory_bytes: 5220
import java.util.*;

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

        if (a >= 3200) {
            System.out.println(s);
        }
        else {
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	
	boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = 1000000007;
	
	
	
	/* solve */
	void solve(){
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int max = Math.min(A, B);
		int min = Math.max(0, A+B-N);
		System.out.println(max + " " + min);
	} 
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws IOException {
		new Main().m();
	}
	void m() throws IOException {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%7d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

int rec(int t,int k){
  int res=0;
  while(t>0){
    res+=t%k;
    t/=k;
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  int ans=n;
  for(int i=0;i<=n;i++){
    int a=i,b=n-i;
    ans=min(ans,rec(a,6)+rec(b,9));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
  int t;
  cin>>t;
  while(t--){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b){
      cout<<"No\n";
    }
    else if(b>d){
      cout<<"No\n";
    }
    else if(c+1>=b){
      cout<<"Yes\n";
    }
    else {
      ll g=gcd(b,d);
      if(b-g+a%g>c){
        cout<<"No\n";
      }
      else{
        cout<<"Yes\n";
      }
    }
  }
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = int(input())
dp = [0]*(s+1)
dp[0] = 1
M = 10**9+7
for i in range(3, s+1):
    val = 0
    for j in range(3, i+1):
        val += dp[i-j]
        val %= M
    dp[i] = val
ans = dp[s]%M
print(ans)

Measured memory_bytes: 64800
/*******************************************************************************
 * Copyright (c) 2016-2017, xehoth
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name xehoth, nor the names of its contributors may be used
 *       to endorse or promote products derived from this software without 
 *       specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY XEHOTH AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL XEHOTH AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ******************************************************************************/
#include <bits/stdc++.h>
/**
 * 「AtCoder Beginner Contest 061」 10-05-2017
 * @author xehoth 
 */
namespace IO {

inline char read() {
    static const int IN_LEN = 1000000;
    static char buf[IN_LEN], *s, *t;
    s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin) : 0;
    return s == t ? -1 : *s++;
}

template<class T>
inline void read(T &x) {
    static char c;
    static bool iosig;
    for (c = read(), iosig = false; !isdigit(c); c = read()) {
        if (c == -1) return;
        c == '-' ? iosig = true : 0;
    }
    for (x = 0; isdigit(c); c = read())
        x = (x + (x << 2) << 1) + (c ^ '0');
    iosig ? x = -x : 0;
}

const int OUT_LEN = 1000000;

char obuf[OUT_LEN], *oh = obuf;

inline void print(char c) {
    oh == obuf + OUT_LEN ? (fwrite(obuf, 1, OUT_LEN, stdout), oh = obuf) : 0;
    *oh++ = c;
}

template<class T>
inline void print(T x) {
    static int buf[30], cnt;
    if (x == 0) {
        print('0');
    } else {
        for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
        while (cnt) print((char)buf[cnt--]);
    }
}

inline void flush() {
    fwrite(obuf, 1, oh - obuf, stdout);
}
}

namespace Task {

inline void solve() {
    using namespace IO;
    register int a, b, c;
    read(a), read(b), read(c);
    std::cout << ((c >= a && c <= b) ? "Yes\n" : "No\n");
}
}

int main() {
#ifdef DBG
    freopen("in.in", "r", stdin);
#endif
    Task::solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		long a=1;
		
		for(int i=n; i>=1; i--){
			a*=i;
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 17172
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  n <- readLn :: IO Int
  s <- getLine :: IO String
  print $ solve s
 
solve s = (Map.foldr (\a acc -> (a `modadd` 1) `modmul` acc) 1 cs) - 1
  where
    cs = toCountMap s

toCountMap :: (Ord k) => [k] -> Map.Map k Integer
toCountMap = Map.fromListWith (+) . flip zip (repeat 1)

divConst = 10^9 + 7 :: Integer
modadd x y = (x + y) `mod` divConst
modsub x y = (x - y) `mod` divConst
modmul x y = ((x `mod` divConst) * (y `mod` divConst)) `mod` divConst


Measured memory_bytes: 4476
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    cin >> s;

    Int ans = 0, ways = (1 << (s.size() - 1)) - 1;
    for (Int i = ways; i >= 0; i--) {
        Int tem = i, integ = s[0] - '0';
        for (Int k = 1; k <= s.size() - 1; k++) {
            if (tem & 1) {
                ans += integ;
                if (k != s.size() - 1) {
                    integ = s[k] - '0';
                } else {
                    ans += s[s.size() - 1] - '0';
                }
            } else {
                integ *= 10;
                integ += s[k] - '0';
                if (k == s.size() - 1) {
                    ans += integ;
                }
            }

            tem /= 2;
        }
    }

    if (s.size() == 1) {
        ans = s[0] - '0';
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<string> ss(N);
  map<char, ll> dic;
  for(int i = 0; i < N; ++i) {
    cin >> ss[i];
    dic[ss[i][0]]++;
  }

  vector<char> march = {'M', 'A', 'R', 'C', 'H'};
  ll ans = 0;
  for(int i = 0; i < march.size() - 2; ++i) {
    for(int j = i + 1; j < march.size() - 1; ++j) {
      for(int k = j + 1; k < march.size(); ++k) {
        ans += dic[march[i]] * dic[march[j]] * dic[march[k]];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

void solve(int, int, string, string);
string getsex(int);

int main(){
  cin.tie(0);
	ios::sync_with_stdio(false);
  int n, ans; cin >> n; //人数

  string s=getsex(0), e=getsex(n-1); //両サイドの性別チェック

  solve(0, n-1, s, e);

  return 0;
}

void solve(int s, int e, string ssex, string esex){
  int start=s, end=e, m, n=0;
  string startsex=ssex, endsex=esex, msex;

  while(true){
    m=(s+e)/2;
    msex = getsex(m);

    if(((m-s)%2==0 && ssex==msex) || ((m-s)%2==1 && ssex!=msex))s=m, ssex=msex;
    else  e=m, esex=msex;
  }
}

string getsex(int num){
  string res;
  cout << num << endl;
  cin >> res;

  if(res=="Vacant") exit(0);
  return res;
}


Measured memory_bytes: 852
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;

int main()
{
	ll s,w;

	cin >> s >> w;

	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int moveCount = Integer.parseInt(sc.nextLine());
    	
    	boolean okFlag = true;
    	int prePosX = 0;
    	int prePosY = 0;
    	int preTime = 0;
    	//check the route avaible
    	for(int i = 1;i<=moveCount;i++) {
    		String[] line = sc.nextLine().split(" ");
    		int time = Integer.parseInt(line[0]);
    		int posX = Integer.parseInt(line[1]);
    		int posY = Integer.parseInt(line[2]);
    		int disX = Math.abs(posX - prePosX);
    		int disY = Math.abs(posY - prePosY);
    		int disTime = Math.abs(time - preTime);
    		//check the distance
    		if(disTime < (disX + disY)) {
    			okFlag = false;
    			break;
    		}
    		
    		//check the avaible position
    		if(disTime%2 != (disX + disY)%2) {
    			okFlag = false;
    			break;
    		}
    		
    		prePosX = posX;
    		prePosY = posY;
    		preTime = time;
    		
    	}
    	if(okFlag) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    	
    	
    }
}

Measured memory_bytes: 91352
import math
n,d,a=map(int,input().split())
XH=[]
for _ in range(n):
    x,h=map(int,input().split())
    h=math.ceil(h/a)
    XH.append([x,h])
XH.sort()
if n==1:
    print(XH[0][1])
    exit()
l=0
r=0
ans=XH[0][1]
c=XH[0][1]
L=[c]
while l<=n-1:
    left=XH[l][0]
    right=left+2*d
    if XH[r+1][0]<=right:
        cc=max(0,XH[r+1][1]-c)
        L.append(cc)
        c+=cc
        ans+=cc
        r+=1
        if r>=n-1:
            r-=1
            l+=1
    else:
        c-=L[l]
        l+=1
print(ans)

Measured memory_bytes: 117948
#include <stdio.h>

#define A 100

int main() {
	static char used[A + 1];
	int n, cnt;

	scanf("%d", &n);
	cnt = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		if (!used[a])
			cnt++, used[a] = 1;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#include<fstream>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> ans;
	if(n==3) {
		cout<<2<<" "<<5<<" "<<63<<endl;
		return 0;
	}
	ans.pb(2);
	ans.pb(4);
	ans.pb(3);
	ans.pb(9);
	n-=4;
	ll c=8;
	while(n>1&&c<=29996) {
		ans.pb(c);
		ans.pb(c+2);
		c+=6;
		n-=2;
	}
	c=15;
	while(n>1&&c<=29991) {
		ans.pb(c);
		ans.pb(c+6);
		c+=12;
		n-=2;
	}
	c=6;
	while(n>0) {
		ans.pb(c);
		c+=6;
		n--;
	}
	sort(ALL(ans));
	DUMP(ans);
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> count(10);
	for(int i=0;i<k;++i){
		int x;
		cin>>x;
		count[x]=1;
	}
	set<int> q;
	for(int i=0;i<10;++i){
		if(count[i]==0) q.insert(i);
	}
	int flag=0;
	for(int i=n;;++i){
		int a=i;
		int flag=0;
		while(a){
			if(q.find(a%10)==q.end()) {
				flag=1;break;
			}
			a/=10;
		}
		if(!flag){
			cout<<i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
D, G=list(map(int, input().split()))
#L[i][0]:i番目の問題数、L[i][0]:i番目のボーナス得点
L=[0]+[list(map(int, input().split())) for i in range(D)]
 
#f:i番目まで考えるときの最小問題数  
def f(G, i):
    if i==0:
	    return 10000
    #n:i番目を絶対に解くときの問題数  
    n=min(G//(i*100), L[i][0])
    #s:i番目を絶対に解くときのスコア  
    s=n*i*100
    #全部解くとき、ボーナスもスコアに加える
    if n==L[i][0]:
        s+=L[i][1]
	#スコアに届かない時、届かない分はG-s点をi-1番目までで埋める
    if s<G:
        n+=f(G-s, i-1)
    #i-1番目までの方が少ない時はそっちを返す
    return min(n, f(G,i-1))
print(f(G, D))

Measured memory_bytes: 3064
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 1000001
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */



void solve(){
	ll n;
	cin >> n;
	vv(ll) a(n), b(n), c(n);
	fr(i,n){
		cin >> a[i] >> b[i] >> c[i];
	}
	vv(vv(ll)) dp(n,vv(ll)(3,0));
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(ll i = 1; i < n; i++){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}
	ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout << ans << endl;
}

int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
}

Measured memory_bytes: 11104
fun main(args: Array<String>) {
    val (n, m, x) = readIntList()
    val a = readIntList()
    val d = a.filter { it < x }.count()
    val e = a.filter { it > x }.count()
    println(min(d, e))
}

fun min(a: Int, b: Int): Int = Math.min(a, b)

fun printYesOrNo(flag: Boolean) {
    println(if (flag) "YES" else "NO")
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}

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

#define ll long long
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    
    if (n == 1){
        if (a==b){
            cout << "1" << endl;
            return 0;
        }
        else{
            cout << "0" << endl;
            return 0;
        }
    }
    
    if (b < a){
        cout << "0" << endl;
        return 0;
    }
    
    ll c = a*(n-1) + b;
    ll d = b*(n-1) + a;
    
    cout << d - c + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;

typedef pair<int, int> P;
int di[] = {1, -1, 0, 0};
int dj[] = {0, 0, 1, -1};

const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector <string> g(h);
  rep(i, h) cin >> g[i];

  // init graph
  vector<vi> dist(h*w, vi(h*w, INF));
  rep(i, h * w) dist[i][i] = 0;

  rep(i, h) rep(j, w){
    if (g[i][j] == '#') continue;
    rep(k, 4){
      int dy = i + di[k];
      int dx = j + dj[k];
      if (dy < 0 or dy >= h or dx < 0 or dx >= w) continue;
      if (g[dy][dx] == '#') continue;
      dist[(i * w)+j][(dy * w)+dx] = 1;
    }
  }

  rep(k, h*w){
    rep(i, h*w){
      rep(j, h*w){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = 0;
  rep(i, h*w){
    rep(j, h*w){
      if (dist[i][j] != INF) ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
  fast;
  int n,l,i;
  string s;
  vector<string> st;
  cin>>n>>l;
  for (i=0;i<n;i++)
  {
    cin>>s;
    st.pb(s);
  }
  sort(st.begin(),st.end());
  for (i=0;i<n;i++)
    cout<<st[i];
}

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

struct Rest{
  int idx;
  string name;
  int value;
};

bool operator<(const Rest& l, const Rest& r)
{
  if(l.name != r.name) return l.name < r.name;
  else if(l.value != r.value) return l.value > r.value;
  return true;
}

vector<Rest> r;

int main(){
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string n;
    int v;
    cin >> n >> v;
    Rest re;
    re.idx=i+1; re.name=n; re.value=v;
    r.push_back(re);
  }
  sort(r.begin(), r.end());
  for(int i=0; i<N; i++){
    cout << r[i].idx << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

int cnt;

int gcd(int a, int b){
	if(b == 0) return a;
	cnt++;
	return gcd(b, a%b);
}

int main(){
	int X, Y;
	while(cin >> X >> Y, X || Y){
		if(X < Y) swap(X, Y);
		cnt = 0;
		int ans = gcd(X, Y);
		printf("%d %d\n", ans, cnt);
	}
	return 0;
}

Measured memory_bytes: 1144
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 num = 1;
		int ans = 0;

		while (true) {
			num += a-1;
			ans += 1;
			if (num >= b) {
				break;
			}

		}

		if (b==1) {
			System.out.println(0);
		} else {
		System.out.println(ans);
		}
}}

Measured memory_bytes: 23764