akhauriyash/Code-Regression huggingface dataset:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest053-B
#  https://beta.atcoder.jp/contests/abc053/tasks/abc053_b

def atozString(dataStr) :

	rangeFirstToEnd = range(0,len(dataStr),1)
	rangeEndToFirst = range(len(dataStr)-1,-1,-1)
	firstA = 0
	lastZ = len(dataStr)
	for i in rangeFirstToEnd:
		if dataStr[i] == 'A':
			firstA = i
			break

	for i in rangeEndToFirst:
		if dataStr[i] == 'Z':
			lastZ = i
			break

	answerInt = lastZ-firstA+1
	return answerInt


if __name__ == '__main__':
	inputLine = input()
	inputStr = inputLine
	ans=atozString(inputStr)
	print(ans)

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
 
//int nm[10001][10001] = {0};
 
map<pair<int,int>,int> nm;
 
int b[10000];
 
int main() {
    int n,m;
 
    cin >> n >> m;
 
    while(1){
        int s,t,e;
        scanf(" %d %d %d",&s,&t,&e);
        if( (s+t+e) == 0) break;
        //nm[s][t] = e;
        nm[make_pair(s,t)] = e;
    }
 
    int l;
 
    cin >> l;
 
    pair<int,int> tmp;
 
    while(l--) {
 
        int c[10001] = {0};
 
        for(int i=1;i<=m;i++){
            scanf(" %d",&b[i]);
        }
 
        int i, j;
        for (i = 1; i <= n; i++) {
            /*for (j = 0; j < m; j++) {
                c[i] = c[i] + nm[i][j+1] * b[j];
            }*/
        }
        for(map<pair<int,int>,int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) {
            tmp = itr->first;
            c[tmp.first] += b[tmp.second] * itr->second;
            //cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << tmp.second << endl;
        }
 
 
        for(int i=1;i<=n;i++){
            //cout << c[i];
            printf("%d",c[i]);
            if(i!=n) printf(" ");//cout <<  ' ';
        }
        printf("\n");
 
    }
    return 0;
}

Measured memory_bytes: 6400
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int ret[2100];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);b--;c--;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			int d=j-i;
			d=min(d,ABS(i-b)+1+ABS(j-c));
			ret[d]++;
		}
	}
	for(int i=1;i<a;i++){
		printf("%d\n",ret[i]);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, g;
    cin >> d >> g;
    V<> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];
    int ans = INF;
    rep(bit, 1 << d) {
        int score = 0;
        int num = 0;
        rep(i, d) if(1 & bit >> i) score += c[i] + (i+1) * 100 * p[i], num += p[i];
        int rest = g - score;
        if(rest > 0) {
            drep(i, d) if(!(1 & bit >> i)) {
                int now_score = (i+1) * 100;
                if(now_score * (p[i] - 1) < rest) rest -= now_score*(p[i]-1), num += (p[i]-1);
                else {
                    num += (rest+now_score-100)/now_score;
                    score += (rest+now_score-100)/now_score * now_score;
                    break;
                }
            }
        }
        if(score < g) continue;
        else chmin(ans, num);
    }
    cout << ans << endl;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++){
        if(S[i] == T[i]){
            ans ++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int m;
  cin >> m;
  P(48 - m);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;
double condition = 0.0;
void func()
{
	string S;
	cin >> S;
	if(S.find('A') != std::string::npos
		&& S.find('B') != std::string::npos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
//	while(1)
	func();
	return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) cin >> D[i];
  int M;
  cin >> M;
  vector<int> T(M);
  for (int i = 0; i < M; i++) cin >> T[i];
  map<int,int> P;
  for (int i = 0; i < N; i++){
    if (P.count(D[i])){
      P[D[i]]++;
    } else {
      P[D[i]] = 1;
    }
  }
  bool res = true;
  for (int i = 0; i < M; i++){
    if (P.count(T[i])){
      if (P[T[i]] == 0){
        res = false;
      } else {
        P[T[i]]--;
      }
    } else {
      res = false;
    }
  }
  cout << (res ? "YES" : "NO");
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
#define nl cout<<"\n";
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


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



int main() {
    
   
    fastio;
    int n;cin>>n;
    int tot  = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                tot = tot + gcd(i,gcd(j,k));
            }
        }
    }
    cout<<tot; 
}


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

#define int long long
#define X first
#define Y second
#define mp make_pair
#define pr pair
#define vc vector
#define sz(v) (int) v.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 305;
const ll INF = 1e18;

int n, m, l;
vc<pr<int, int>> g[N];
pair<int, int> dist[N][N];
bool used[N];

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> l;
    for (int i = 0; i < m; ++i) {
        int v, u, w;
        cin >> v >> u >> w;
        --v, --u;
        if (w <= l) {
            g[v].push_back(mp(u, w));
            g[u].push_back(mp(v, w));
        }
    }
    for (int i = 0; i < n; ++i) {
        fill(used, used + n, false);
        fill(dist[i], dist[i] + n, mp(INF, 0));
        dist[i][i] = mp(0, -l);
        for (int j = 0; j < n; ++j) {
            int v = -1;
            for (int u = 0; u < n; ++u) {
                if (!used[u] && (v == -1 || dist[i][u] < dist[i][v]) && dist[i][u].X < INF) {
                    v = u;
                }
            }
            if (v == -1) break;
            used[v] = true;
            for (auto &to : g[v]) {
                int u = to.X, w = to.Y;
                pair<int, int> curr = mp(dist[i][v].X, -dist[i][v].Y);
                if (curr.Y < w) {
                    curr.X += 1;
                    curr.Y = l - w;
                } else {
                    curr.Y -= w;
                }
                curr.Y = -curr.Y;
                dist[i][u] = min(dist[i][u], curr);
            }
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int s, t;
        cin >> s >> t;
        --s, --t;
        if (dist[s][t].X == INF) cout << "-1\n";
        else cout << dist[s][t].X << "\n";
    }

    return 0;
}


Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var X, Y int
	ans := "No"

	fmt.Scan(&X, &Y)

	for i := 0; i <= X; i++ {
		if (2 * i + 4 * (X-i) == Y) {
			ans = "Yes"
		}
	}

	fmt.Println(ans)
}

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

int main() {
  string S;cin>>S;
  if(S[0]=='S' && S[1]=='S' && S[2]=='S') cout << 0 << endl;
  if(S[0]=='R' && S[1]=='S' && S[2]=='S') cout << 1 << endl;
  if(S[0]=='S' && S[1]=='R' && S[2]=='S') cout << 1 << endl;
  if(S[0]=='S' && S[1]=='S' && S[2]=='R') cout << 1 << endl;
  if(S[0]=='R' && S[1]=='R' && S[2]=='S') cout << 2 << endl;
  if(S[0]=='R' && S[1]=='S' && S[2]=='R') cout << 1 << endl;
  if(S[0]=='S' && S[1]=='R' && S[2]=='R') cout << 2 << endl;
  if(S[0]=='R' && S[1]=='R' && S[2]=='R') cout << 3 << endl;
}


Measured memory_bytes: 3608
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ai.Sum() >= 22 ? "bust" : "win");
        }
    }
}


Measured memory_bytes: 13396
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const int INF = 2e9 ;
int n, m, u, v;

int main(){
    cin >> n >> m ;
    int mat[n+4][m+4] = {0};
    char ch ;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) {
            cin >> ch;
            if(ch == '#') mat[i][j] = -1;
        }
    }
    ll dp[n+3][m+4] = {0} ;
    dp[1][1] = 1;
    for(int i=2;i<=n;i++) {
        if(mat[i][1] != -1) dp[i][1] = dp[i-1][1] ;
    }
    for(int i=2;i<=m;i++) {
        if(mat[1][i] != -1) dp[1][i] = dp[1][i-1] ;
    }
    for(int i=2;i<=n;i++) {
        for(int j=2;j<=m;j++) {
            if(mat[i][j] != -1) {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod ;
            }
        }
    }
    cout << dp[n][m] << '\n';
    return 0;
}
 

// https://atcoder.jp/contests/dp/tasks






// // // // https://codeforces.com/problemset/problem/474/E
// // // // https://www.hackerrank.com/contests/codeagon/challenges/number-of-ways-1/problem
// // // // https://codeforces.com/contest/475/problem/D


// // https://www.spoj.com/problems/INS17M/
// // https://www.codechef.com/SEPT18B/problems/ANDSQR
// // 


// int d[] = {1, 2, 2, 4, 5, 10, 15, 28, 45, 79, 129, 218, 356, 589, 959, 1569, 2548, 4145, 6720, 10901, 17656, 28602, 46302, 74959};

// ll C[100][100];

// void pre(){
//   for(int i=0;i<=99;i++) C[i][0] = 1;
//   for(int i=1;i<=99;i++) {
//     for(int j=0;j<=min(99,i);j++){
//       C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod ;
//     }
//   }
// }

// int main() {
//     pre();
//   int x =0, y = 1,z ;
//   for(int i=0;i<=23;i++) {
//     z = x + y ;
//     int p = i;
//     cout << z << ' ' ;
//     x = y ;
//     y = z ;
//   }
//   cout << "\n\n";
//     for(int i=2;i<=24;i++){
//       ll res = 0;
//       for(int j=0;j<=i;j++)
//       {
//         res += C[i][j]*C[i][j];
//         res %= mod;
//         if(j < i) {
//           res += C[i-j-1][j];
//           res %= mod;
//         }
//         res -= C[i+j-1][j];
//         res += mod;
//         res %= mod;
//         if(j < i-1) {
//           res += C[i-j-2][i];
//           res %= mod;
//         }
//       }
//       cout << res<< ' ' ;
//     }
//     cout << '\n';
//   return 0 ;
// }

Measured memory_bytes: 12032
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
int A[20];
int n;
int q;
int m;

bool solve(int i, int m){
    if(m == 0)
        return true;
    if(i >= n)
        return false;
    bool res = solve(i + 1, m) or solve(i + 1, m - A[i]);
    return res;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> A[i];
    cin >> q;
    for(int i = 0; i < q; ++i){
        cin >> m;
        if(solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

    



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

int main() {
  int A, B, C ,D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  deque<char> d;
  for(int i=0; i<s.size(); i++){
    d.push_back(s[i]);
  }
  for(int i=0; i<s.size(); i++){
    d.push_front(d.back());
    d.pop_back();
    int cnt = 0;
    for(int j=0; j<s.size(); j++){
      if(d.at(j) == t[j]){
        cnt++;
      }
    }
    if(cnt == s.size()){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int n;
int *A;

int solve(int,int);

int main()
{
  int q,i,result;
  int *m;

  /* 入力一列目 */
  scanf("%d",&n);

  /* 入力二列目 */
  A = (int *)malloc(sizeof(int) * n);
  if(A == NULL) exit(0);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }

  /* 入力三列目 */
  scanf("%d",&q);

  /* 入力四列目 */
  m = (int *)malloc(sizeof(int) * q);
  if(m == NULL) exit(0);
  for(i = 0;i < q;i++){
    scanf("%d",&m[i]);
  }

  /* 判定 */
  for(i = 0;i < q;i++){
    result = solve(0,m[i]);
    if(result == 0) printf("no\n");
    else printf("yes\n");
  }

  return 0;
}

int solve(int i,int m)
{
  int res1,res2;

  if(m == 0) return 1;
  if(i >= n) return 0;

  res1 = solve(i + 1, m);
  res2 = solve(i + 1, m - A[i]);

  if(res1 == 1 || res2 == 1) return 1;
  else return 0;
}

Measured memory_bytes: 580
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef pair<int, int> P;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> x(N), y(N);
  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }

  int ans = N;
  rep(i, N) {
    rep(j, N) {
      if(i == j) continue;
      long long p = x[i] - x[j];
      long long q = y[i] - y[j];

      int cnt = 0;

      rep(k, N) {
        rep(l, N) {
          if(k == l) continue;
          long long xdiff = x[k] - x[l];
          long long ydiff = y[k] - y[l];
          if(p == xdiff && q == ydiff) cnt++;
        }
      }
      ans = min(ans, N-cnt);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, v int
	Fscan(in, &n)
	mp := map[int]int{}
	for i := 0; i < n; i++ {
		Fscan(in, &v)
		mp[v]++
	}
	Fprintln(out, map[bool]string{true: "YES", false: "NO"} [len(mp) == n])
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 12672
#include <iostream>
#include <vector>

using namespace std;

int n,m;
#define MAX 7368792
#define NUM 5

int main() {
	while(true) {
		cin >> m >> n;
		if(n<=0) break;
		int arr[MAX]{};
		int count = 0;
		vector<int> prms;
		for(int i = m; i < MAX; i++) {
			m = i;
			bool flag = arr[i]==0;
			if(flag) {
				for(int prm : prms) flag &= m%prm!=0;
				if(flag) {
					if(count>=n) break;
					count++;
					if(prms.size()<=NUM) {
						prms.push_back(m);
					}else {
						for(int j = 1; j*m<MAX; j++) {
							arr[j*m] = 1;
						}
					}
					m++;
				}
			}
		}
		cout << m << endl;
	}
}



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

int main(){
    int N;cin>>N;
    vector<int> a(N),b(N),c(N-1);
    for(int i=0;i<N;i++)cin>>a.at(i);
    for(int i=0;i<N;i++)cin>>b.at(i);
    for(int i=0;i<N-1;i++)cin>>c.at(i);

    int ans=0;
    for(int i=0;i<N;i++){
        ans+=b.at(a.at(i)-1);
        if(i){
            if(a.at(i)-1==a.at(i-1)){
                ans+=c.at(a.at(i)-2);
            }
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

int main() {
    ll n,k;
    cin >> n >> k;
    ll h[n];
    ll dp[n];
    for(ll i=0;i<n;i++){
        cin >> h[i];
        dp[i] = INT_MAX;
    }    
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(ll i=2;i<n;i++){
        for(ll j=1;j<=k;j++){
            if(i-j < 0)
                break;
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j])); 
        }
    }
    cout << dp[n-1];
	return 0;
}

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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 100

int f(int k){
	if( k%2 )
		return 3*k+1;
	else
		return k/2;
}

int main(int argc, char const *argv[])
{
	#ifdef DBG
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
	#endif	
	
	int num,check,ans;
	map <int,int> table;

	while( ~scanf("%d",&num) ){

		ans = 1;
		check = -1;
		table.clear();
		while( table.size() != check ){
			check = table.size();
			table[num] = 1;
			num = f(num);
			ans++;
		}

		printf("%d\n",ans-1 );

	}

	return 0;
}

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

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

    sort(v.begin(), v.end());
    int maxv = v[N - 1], pre = v[N - 2];
    
    if (maxv == pre) {
        for (int i = 0; i < N; i++) {
            cout << maxv << endl;
        }
        return 0;
    }

    for (int i = 0; i < N; i++) {
        if (A[i] == maxv) cout << pre << endl;
        else cout << maxv << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
import math

A,B,X = [int(i) for i in input().split()]

ans1 = math.ceil(X/1000) * A
ans2 = math.ceil(X/500) * B
ans3 = math.floor(X/1000) * A + math.ceil((X % 1000)/500) * B

print(min(ans1,ans2,ans3))


Measured memory_bytes: 5672
data = input().split()
stack = []
for i in data:
    try:
        stack.append(int(i))
    except:
        b = stack.pop()
        a = stack.pop()
        if i == "+":
            stack.append(a+b)
        if i == "-":
            stack.append(a-b)
        if i == "*":
            stack.append(a*b)
print(stack[0])
            

Measured memory_bytes: 7680
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    P = list(map(int, readline().split()))
    cur = N + 1
    ans = 0
    for x in P:
        if cur > x:
            ans += 1
            cur = x

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 100020
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int k;
  cin>>k;
  map<int,int>mp;
  while(k--)
  {
  	int d;
  	cin>>d;
  	for(int i=0;i<d;i++)
  	{
  		int a;
  		cin>>a;
  		mp[a]++;
	  }
  }
  int count=0;
  for(int i=1;i<=n;i++)
  if(mp[i]==0)
  count++;
  cout<<count;
  
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef long long ll;
ll p,a,ans[2999],c[3000][3000];
ll f(ll n,ll k){
    if(n==0)return 0;
    if(k==0)return 1;
    if(k%2==1)return n*f(n,k-1)%p;
    return f(n,k/2)*f(n,k/2)%p;
}
int main(void){
    cin>>p;
    for(int i=0;i<=p;i++)c[i][0]=1;
    for(int i=1;i<=p;i++){
        for(int j=1;j<=i;j++){
            c[i][j]=c[i-1][j]+c[i-1][j-1];
            c[i][j]%=p;
        }
    }
    for(int i=0;i<p;i++){
        cin>>a;
        if(a==1){
          	ans[p-1]++;
          	ans[p-1]%=p;
          	ll tm=1LL;
            for(int j=0;j<p;j++){
              	if(j==0){
                  ans[0]--;
                  continue;
                }
              	//cout<<c[p-1][j]<<" "<<f(-i,j)<<" "<<i<<" "<<j<<endl;
              	if(i==0){
                  ans[j]+=(c[p-1][j]*-1*f(-i,j))%p;
                  ans[j]%=p;
                }
              	else{
                  tm*=-i;
                  tm%=p;
                  ans[j]+=(c[p-1][j]*-1*tm)%p;
                  //cout<<tm<<" "<<f(-1,j)<<" "<<j<<endl;
                  ans[j]%=p;
                }
            }
        }
    }
    for(int i=p-1;i>=0;i--){
        cout<<(p+ans[i])%p<<" ";
    }
    cout<<endl;
  	//cout<<f(3,0)<<endl;
}


Measured memory_bytes: 68992
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
s = input()[:-1]
ans = [1]*(N+2)


def print_ans(l: list):
    ret = ""
    for a in l[1:-1]:
        ret += "S" if a else "W"
    print(ret)


def next(ind: int, isSame: bool, isSheep: bool)->bool:
    if isSame:
        if isSheep:
            return ans[ind-1]
        else:
            return not ans[ind-1]
    else:
        if isSheep:
            return not ans[ind-1]
        else:
            return ans[ind-1]

    return isSame ^ isSheep ^ ans[ind-1]


def check(first: bool, last: bool)->list:
    ans[0] = last
    ans[1] = first
    for i in range(1, N+1):
        ans[i+1] = next(i, s[i-1] == "o", ans[i])

    return ans[0] == ans[N] and ans[1] == ans[N+1]


for first in [True, False]:
    for last in [True, False]:
        if check(first, last):
            print_ans(ans)
            exit()
print("-1")


Measured memory_bytes: 4852
l, n = gets.chomp.split.map(&:to_i)
hsh, arr, arr2 = Hash.new{|h, k| h[k] = []}, [0, l], {}
n.times{
    p, d, t = gets.chomp.split.map(&:to_i)
    hsh[p] << [p + d, t]
    arr << p
    arr << p + d    
}
arr.sort!.uniq!
arr.each_with_index{|p, i| arr2[p] = i}

dp = [0]
hsh[0].each{|d, t| dp[arr2[d]] = t if dp[arr2[d]].nil? || dp[arr2[d]] > t}
1.upto(arr.length - 1){|i|
    temp = dp[i - 1] + arr[i] - arr[i - 1]
    dp[i] = temp if dp[i].nil? || dp[i] > temp
    hsh[arr[i]].each{|d, t| dp[arr2[d]] = dp[i] + t if dp[arr2[d]].nil? || dp[arr2[d]] > dp[i] + t}
}
puts dp.last


Measured memory_bytes: 8896
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

P a[1010];
signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n){
		int x, y;
		scanf("%lld%lld", &x, &y);
		a[i] = P(x, y);
	}
	int x = a[0].fi, y = a[0].se;
	rrep(i,n-1){
		int m = max((x+a[i].fi-1)/a[i].fi, (y+a[i].se-1)/a[i].se);
		x = a[i].fi*m;
		y = a[i].se*m;
	}
	printf("%lld\n", x+y);
	return 0;
}




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

int D;
const int M = 26;
vector<int> C;
vector<vector<int>> S;
vector<int> T;

const int INF = 1<<30;

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

std::mt19937 mt{ std::random_device{}() };

int randint(int lower, int upper)
{
    std::uniform_int_distribution<int> dist(lower, upper);
    return dist(mt);
}

int calc_score(int N=D)
{
    assert(N <= D);
    int ans = 0;
    vector<int> last(M, -1);
    for(int i=0; i<N; i++)
    {
        if(T[i] != -1)
        {
            ans += S[i][T[i]];
            last[T[i]] = i;
        }
        for(int j=0; j<M; j++)
        {
            ans -= C[j] * (i - last[j]);
        }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> D;
    C.resize(M);
    for(int i=0; i<M; i++) cin >> C[i];
    S.resize(D);
    for(int i=0; i<D; i++)
    {
        S[i].resize(M);
        for(int j=0; j<M; j++)
        {
            cin >> S[i][j];
        }
    }

    int fscore = -INF;
    vector<int> ans;
    for(int k=0; k<=26; k++)
    {
        T.assign(D, -1);
        for(int i=0; i<D; i++)
        {
            int score = -INF;
            int idx = -1;
            for(int j=0; j<M; j++)
            {
                T[i] = j;
                int nscore = calc_score(min(i+1 + k, D));
                if(chmax(score, nscore)) idx = j;
            }
            T[i] = idx;
        }
        int score = calc_score();
        if(chmax(fscore, score)) ans = T;
    }
    for(int i=0; i<D; i++)
    {
        cout << ans[i] + 1 << '\n';
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> color(N+1, N+2);
    vector<int> ans(N);
    int num = 1;
    
    vector<vector<pair<int, int>>> edge(N+1, vector<pair<int, int>>());
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back({b, i});
        edge[b].push_back({a, i});
    }
    
    queue<pair<int, int>> q;
    q.push({1, N+1});
    color[1] = 0;
    while (!q.empty()) {
        int now = q.front().first;
        int c = q.front().second;
        q.pop();
        int t = 1;
        for (int i = 0; i < (int)edge[now].size(); i++) {
            int nxt = edge[now][i].first;
            if (color[nxt] < N) continue;
            if (t == c) t++;
            ans[edge[now][i].second] = t;
            q.push({nxt, t});
            color[nxt] = t;
            num = max(num, t);
            t++;
        }
    }
    cout << num << endl;
    for (int i = 0; i < N-1; i++) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	string s,t;
	cin>>s>>t;
	int k=t.length();
	int ans=1e9;
	for(int i=k-1;i<s.length();i++){
	    int st=i-(k-1),cnt=0;
	    for(int j=0;j<k;j++){
	        if(t[j]!=s[st+j]) cnt++;
	    }
	    ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cctype>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    string str;
    cin >> str;
    if(str[str.size()-1] == 's') {
        str += "es";
    } else {
        str += 's';
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int ab(int);

int main(){
  int N,i,x,res = 0;
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d",&x);
    if(ab(x)){
      ++res;
    }
  }
  printf("%d\n",res);
  return 0;
}

int ab(int x){
  int i;
  if(x < 2){ return 0; }
  for(i = 2 ; i*i <= x ; i++){
    if(x % i == 0){ return 0; }
  }
  return 1;
}



Measured memory_bytes: 2004
# https://atcoder.jp/contests/abc106/tasks/abc106_b

N = int(input())

import math
primes = []
p = [ x for x in range(2, math.floor(math.sqrt(N))+1) ]
while len(p) > 0:
    pi = p.pop(0)
    primes.append(pi)
    for pj in p:
        if pj % pi == 0:
            p.remove(pj)

primes.remove(2)

count = 0
# n = a^7
for a in primes:
    n = pow(a, 7)
    if n <= N:
        count += 1
# n = a^3 * b^1
for a in primes:
    for b in primes:
        if a == b:
            continue
        n = pow(a, 3) * pow(b, 1)
        if n <= N:
            count += 1
# n = a^1 * b^1 * c^1
for a in primes:
    for b in primes:
        for c in primes:
            if a >= b or b >= c:
                continue
            n = a * b * c
            if n <= N:
                count += 1

print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
    int x;
    ind(x);
    printf("%d\n", x + x * x + x * x * x);
    return 0;
}


Measured memory_bytes: 3784
N, K = map(int, input().split())
tree = list(map(int, input().split()))
left = 0
right = 2*(10**9)
treeLen = len(tree)

while right - left > 1:
    cnt = 0
    mid = (right + left) // 2
    for i in range(treeLen):
        cnt += tree[i] // mid
        if tree[i] % mid == 0:
            cnt -= 1  # ちょうどに切れるときは切り口が1減る
    if K >= cnt:
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 30880
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;

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

	int maxv = - 2000000000;
	int minv = R[0];

	for (int i=1; i<n; i++){
		maxv = max(maxv, R[i]-minv);
		minv = min(R[i], minv);
	}

	cout << maxv <<endl;

	return 0;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
int64 f[1005][20005];
int n;
pair<int,pii> a[1005];
void Input()
{
    cin >> n;
    FOR(i,1,n)
        cin >> a[i].se.fi >> a[i].fi >> a[i].se.se;
}
bool cmp(const pair<int,pii> &a, const pair<int,pii> &b)
{
//    if (a.se.fi<=b.fi) {
//        if (b.se.fi>a.fi) return true;
//        return a.fi<b.fi;
//    }
//    if (b.se.fi<=a.fi) return false;
//    return a.fi<b.fi;
    return a.fi+a.se.fi<b.fi+b.se.fi;
}
void Solve()
{
    sort(a+1,a+1+n,cmp);
    FOR(i,1,n)
        FOR(j,0,a[i].fi+a[i].se.fi) {
            f[i][j]=f[i-1][j];
            if (j>=a[i].se.fi)
                f[i][j]=max(f[i][j],f[i-1][j-a[i].se.fi]+a[i].se.se);
        }
    cout << *max_element(f[n],f[n]+1+a[n].fi+a[n].se.fi);
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 156544
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        long ret = k-a;
        a = Math.max(0,a-k);
        b -= Math.max(0,ret);
        b = Math.max(b,0);
        System.out.println(a + " " + b);
    }
}
 

Measured memory_bytes: 25172
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    L = str(input().strip())
    N = len(L)

    dp0 = 0  # Less than L
    dp1 = 1  # Can be greater than L
    for b in L:
        if b == '0':
            # dp1 = dp1 * 1
            dp0 = dp0 * 3 % MOD
        if b == '1':
            dp0 = (dp0 * 3 + dp1) % MOD
            dp1 = dp1 * 2 % MOD
    return (dp0 + dp1) % MOD


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3188
n, m = gets.chomp.split(' ').map(&:to_i)
arr = Array.new(n)
m.times do
  arr[gets.chomp.to_i] = 0
end
arr[0] = 1
arr[1] ||= 1

(2..n).each do |num|
  arr[num] ||= (arr[num-2] + arr[num-1]) % 1_000_000_007
end
puts arr[n]


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

using namespace std ;
#define   ll long long
#define   null NULL
#define   double dll
#define   endl "\n"
#define   mp make_pair
#define   pb push_back
#define   ff first
#define   ss second

ll mod = (ll)(1e9 + 7);
ll inf = (ll)(1e17 + 17);

int main () {
	int x , n ;
	cin >> x >> n ;
	if (n == 0) {
		cout << x ;
		return 0 ;
	}
	int a ;
	vector <int> v(105, 0) ;
	for (int i = 0; i < n; i++) {
		cin >> a ;
		v[a] = 1 ;
	}
	int s = x  , e = x  ;
	if (v[x] == 0) {
		cout << x ;
		return 0 ;
	}
	while (1) {
		if (v[s] == 0 && v[e] == 0) {
			cout << s ;
			return 0 ;
		}
		if (v[s] == 1)s-- ;
		if (v[e] == 1)e++ ;

		if (v[s] == 0 && v[e] == 0) {
			cout << s ;
			return 0 ;
		}

		if (v[s] == 0) {
			cout << s ;
			return 0 ;
		}
		else if (v[e] == 0) {
			cout << e ;
			return 0 ;
		}
	}
	return 0 ;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        func();
        pw.flush();
        return;
    }

    static void func() throws IOException {
        int[] input = arrayOfInt();
        int n = input[0];
        int m = input[1];

//        for(int i = 2;i <= Math.sqrt(m);i++){
//            if (m%i != 0) continue;
//            if(i <= MAX) ans = Math.max(ans,i);
//            if(m/i <= MAX) ans = Math.max(ans,m/i);
//        }
        int MAX = (int)Math.floor(m/n);
        long ans = 1;
        for (int i = 1; i*i <= m; i++) {
            if (m % i != 0) continue;
            if(i <= MAX) ans = Math.max(ans,i);
            if (m / i <= MAX) ans = Math.max(ans,m/i);
        }
        println(ans);
    }
    // 入力受け取り
    static String next() throws IOException {return br.readLine();}
    static int nextInt() throws IOException{return getInt(br.readLine());}
    static long nextLong() throws IOException{return getLong(br.readLine());}
    static String[] arrayOfString() throws IOException{return br.readLine().split(" ");}
    static int[] arrayOfInt() throws IOException{return toIntArray(arrayOfString());}
    // 変換
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {return Integer.parseInt(val);}
    static int[] toIntArray(String[] array) {return Stream.of(array.clone()).mapToInt(Integer::parseInt).toArray();}
    static String joinToString(String[] array) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < array.length;i++) sb.append(array[i]);
        return sb.toString();
    }

    // 出力
    static void println(Object val){pw.println(val);}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b;
	cin >>a >>b;
	int mx = a*b;
	mx = max(a+b, mx);
	mx = max(a-b, mx);
	
	cout << mx <<"\n";
	return 0;
}


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

typedef long long ll;
const int mod = 1000*1000*1000+7;
const int MN = 100010;

int N;
ll A, B;
vector<ll> S;

struct BIT {
    ll tree[4*MN];
    void init() {
        memset(tree, 0, sizeof(tree));
    }
    void build(int l, int r, int n) {
        if(l == r) {
            tree[n] = (l == 0? S[l] : S[l] - S[l - 1]);
            return;
        }
        int m = (l + r)>>1;
        build(l, m, 2*n);
        build(m + 1, r, 2*n + 1);
        tree[n] = min(tree[2*n], tree[2*n + 1]);
    }
    ll quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return 1e18;
        if(a <= l && r <= b) return tree[n];
        int m = (l + r)>>1;
        ll L = quer(a, b, l, m, 2*n);
        ll R = quer(a, b, m + 1, r, 2*n + 1);
        return min(L, R);
    }
} bit;

int cc[100010];
int dp(int idx) {
    int &ret = cc[idx];
    if(ret != -1) return ret;

    if(idx == N) return ret = 1;

    ret = 0;
    if(idx == 0 || S[idx] - S[idx - 1] >= B) {
        ret += dp(idx + 1);
        ret %= mod;
    }

    int s = idx + 1, e = N - 1;
    int x = N;
    while(s <= e) {
        int m = (s + e)>>1;

        if(S[m] - S[idx] >= A) {
            x = m;
            e = m - 1;
        }
        else s = m + 1;
    }

    if(((idx != N - 1 && idx >= 1)? S[idx + 1] - S[idx - 1] >= B : 1) && bit.quer(idx + 2, x - 1, 0, N - 1, 1) >= B) {
        ret += dp(x);
        ret %= mod;
    }

    return ret;
}

int main() {
    scanf("%d %lld %lld", &N, &A, &B);
    S.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%lld", &S[i]);
    }

    if(A < B) swap(A, B);

    bit.init();
    bit.build(0, N - 1, 1);
    memset(cc, -1, sizeof(cc));

    printf("%d", dp(0));
}


Measured memory_bytes: 15488
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	ll N, H, W;
	ll A, B;
	cin >> N >> H >> W;
	int an = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A >> B;
		if (A >= H && B >= W) an++;
	}
	cout << an << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x,y;
while(cin >> a >> b >> c >> d >> e >> f){
  x = (double)((e*c-b*f) / (a*e-b*d));
  y = (double)((-(d*c)+a*f) / (a*e-b*d));
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
  printf("%.3f %.3f\n",x,y);
 }
}

Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    long n,res=0,i,*a;
    cin >> n;
    a = new long[n];
    for(i=0;i<n;i++) cin >> a[i];
    for(i=1;i<n;i++){
        if(a[i] - a[i-1] < 0){
            res += -(a[i] - a[i-1]);
            a[i] = a[i-1];
        }
    } 
    cout << res;
}


Measured memory_bytes: 5180
#include <stdio.h>

int main(void)
{
	int n, i, c;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		if (i % 3 == 0) printf(" %d", i);
		else {
			c = i;

			while (c % 10 != 3 && c) {
				c /= 10;
				}
			
			if (c) printf(" %d", i);
		}
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;
const double PI=3.14159265358979323846;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    double a,b,x;
    double res=0;
    cin >> a >> b >> x;
    int vol = a*a*b;
    if(x < vol/2.){
        res = atanl(a*b*b/(2*x));
    }else{
        //res = atanl(a/(2*x));
        res = atanl((2*b-2*x/(a*a))/(a));
    }
    //COUT(res);
    cout << setprecision(10) << res*180/PI << endl;
    
}

Measured memory_bytes: 256
//https://qiita.com/Cassin01/items/2f90aedded2b8fb017a1
//引用
// O(n)
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n+1];
    let mut is_prime = vec![true; n+1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n+1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {

            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}

//引用終了

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    
    let x: usize = buf.trim().parse().unwrap();
    let primes = sieve_of_eratosthenes(100003);

    for i in primes {
        if i >= x {
            println!("{}", i);
            return ();
        }
    }
}

Measured memory_bytes: 6524
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var x = ReadLong();
            if (x == 1)
            {
                return "Hello World";
            }
            var A = ReadLong();
            var B = ReadLong();
            return A + B;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27400