akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

string cipher(const string& input, int alpha, int beta){
    size_t len = input.size();
    string output = input;

    for (int i = 0; i < len; i++) {
        if (input[i] == ' ') {
            output[i] = input[i];
        } else {
            output[i] = (alpha * (input[i] - 'a') + beta) % 26 + 'a';
        }
    }

    return output;
}

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    cin.ignore();

    for (int i = 0; i < n; i++) {
        string input;
        getline(cin, input);

        for (int alpha = 0; alpha < 26; alpha++) {
            for (int beta = 0; beta < 26; beta++) {
                string output = cipher(input, alpha, beta);
                if (output.find("this") != string::npos || output.find("that") != string::npos) {
                    cout << output << endl;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll x,y;
  cin >> x >> y;
  cout << (abs(x-y)>1?"Alice":"Brown") << endl;
}

Measured memory_bytes: 256
N=int(input())
if N%2==1:
    print("No")
    exit()
S=input()
T1=""
T2=""
for i in range(N):
    if i<N//2:
        T1+=S[i]
    else:
        T2+=S[i]
if T1==T2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<assert.h>
#include<sstream>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e18 + 7;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
const int MOD = 21092013;
const double EPS = 1e-8;
//-------------head-------------
bool vis[2155];
vector<int> pri;
void prime() {
	memset(vis, false, sizeof(vis));
	for (int x = 2; x < 2155; ++x)
		if (!vis[x]) {
			pri.push_back(x);
			for (ll y = x * x; y < 2155; y += x)
				vis[y] = true;
		}
//	printf("sz = %d\n", sz(pri));
}
int n;
ll s[N];
map<ll, ll> F;
map<ll, int> S;
int main() {
	prime();
	scanf("%d", &n);
	int ans = 0;
	rep(i, 0, n)
	{
		scanf("%lld", &s[i]);
		ll x = 1, y = 1;
		for (int j = 0; j < sz(pri) && pri[j] <= s[i]; ++j) {
			int c = 0;
			while (s[i] % pri[j] == 0)
				++c, s[i] /= pri[j];
			c %= 3;
			if (c == 1) {
				x *= pri[j], y *= pri[j] * pri[j];
			} else if (c == 2) {
				x *= pri[j] * pri[j], y *= pri[j];
			}
		}
		x *= s[i];
		if (x == 1) {
			ans = 1;
			continue;
		}
		++S[x];
		ll ss = sqrt(s[i]);
		if (ss * ss == s[i]) {
			y *= ss;
		} else if (s[i] <= (ll) (1e11) / s[i]) {
			y *= s[i] * s[i];
		} else {
			y = -1;
		}
		F[x] = y;
	}
	for (auto it : S)
		if (S.find(F[it.first]) == S.end()) {
			ans += it.second;
		} else if (F[it.first] > it.first) {
			ans += max(it.second, S[F[it.first]]);
		}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 13568
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

int n, q;
const int N = 100000;
ll t[N];
double a[N], acc[N];
ll l[N], r[N];

double f(ll x) {
  int idx = lower_bound(t, t + n, x) - t;
  return acc[idx];
}

double perf(ll l, ll r) {
  double x = f(r) - f(l);
  return 1e9 * exp(x);
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  REP(i, 0, n) {
    cin >> t[i] >> a[i];
    a[i] = log(1 - a[i] / 10);
    acc[i + 1] = acc[i] + a[i];
  }
  cin >> q;
  REP(i, 0, q) cin >> l[i] >> r[i];
  REP(i, 0, q) {
    cout << fixed << setprecision(15) << perf(l[i], r[i]) << "\n";
  }
}



Measured memory_bytes: 7688
#include<stdio.h>
int main()
{
  int A, B ;
  scanf("%d %d",&A,&B) ;

  int c = A - 2 * B ;

  if(c > 0){
    printf("%d\n",c) ;
  }else if(c <= 0){
    printf("0\n") ;
  }

  return 0 ;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll H1,H2,M1,M2,K; cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll A = H1*60+M1;
    ll B = H2*60+M2;

    cout << B-K-A << endl;
    return 0;

}

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

int main()
{
    int i,j,c,ans=INT_MAX;
    string s,t;

    cin>>s>>t;

    for(i=0;i<=s.size()-t.size();i++){
        for(j=0,c=0;j<t.size();j++){
            if(s[i+j]!=t[j]){
                c++;
            }
        }
        ans=min(ans,c);
    }
    cout<<ans<<"\n";

    return 0;
}




Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  if(A >= K)
    cout << K << endl;
  else if(A + B >= K)
    cout << A << endl;
  else
    cout << A - (K - A - B) << endl;
  
  return 0;
}


Measured memory_bytes: 3636
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-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 (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout <<lcs<<"\n"; 
} 

/* Driver program to test above function */
int main() 
{ 
char X[] = "AGGTAB"; 
char Y[] = "GXTXAYB"; 
int m = strlen(X); 
int n = strlen(Y); 
string s, t;
  cin>>s>>t;
  m = s.length();
  n = t.length();
lcs(s, t, m, n); 
return 0; 
} 


Measured memory_bytes: 35456
import java.io.*;
 class Main{
    public static void main(String[] args) throws Exception {
        BufferedReader line = new BufferedReader(new InputStreamReader(System.in));
        String str = null;
        while ((str = line.readLine()) != null) {
            String[] arr = str.split(" ");
            if ("0".equals(arr[0]) && "0".equals(arr[1]))
                break;
            int x = Integer.parseInt(arr[0]);
            int y = Integer.parseInt(arr[1]);
 
            if (x > y)
                System.out.println(y + " " + x);
            else
                System.out.println(x + " " + y);
        }
    }
}

Measured memory_bytes: 24596
def max_heapify(i):
    l = i*2
    r = i*2+1
    if l <= H and A[l-1] > A[i-1]:
        largest = l
    else:
        largest = i
    if r <= H and A[r-1] > A[largest-1]:
        largest = r
    if largest != i:
        A[i-1], A[largest-1] = A[largest-1], A[i-1]
        max_heapify(largest)

def build_max_heap():
    for i in range(H//2, 0, -1):
        max_heapify(i)

if __name__ == "__main__":
    H = int(input())
    A = list(map(int, input().split()))
    build_max_heap()
    print(" ", end="")
    print(*A)


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

vector<int> g[200005], parent(200005, -1);
vector<bool> vis(200005, false);

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

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    parent[1] = 0;
    vis[1] = true;

    queue<int> q;
    q.push(1);

    while (!q.empty()) {
        int p = q.front(); q.pop();

        for (auto adj : g[p]) {
            if (vis[adj]) {
                continue;
            }
            q.push(adj);
            vis[adj] = true;
            parent[adj] = p;
        }
    }

    bool possible = true;
    for (int i = 1; i <= n; i++)
        if (!vis[i])
            possible = false;

    if (!possible) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;  
        for (int i = 2; i <= n; i++) {
            cout << parent[i] << endl;
        }
    }

}


Measured memory_bytes: 13040
#include <iostream>

using namespace std;

int main(void){
  int n,y;
  
  cin >> n >> y;
  
  for(int i = 0 ; i <= n ; i++){
    for(int j = 0 ; j <= n ; j++){
      int k = n-(i+j);
      if(k < 0) break;
      else if(y - (10000*i + 5000*j + 1000*k) == 0){
        cout << i << " " << j << " " << k;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
std::vector<int> v(x);
rep(i,x){
  std::cin >> n;
  if(n==y+1){
    y++;
  }else{
    z++;
  }
}
if(y==0)std::cout << -1 << '\n';
else std::cout << z << '\n';
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(){
  double x1,x2,y1,y2,a;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  a=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
  printf("%lf\n",sqrt(a));
  return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi 3.1415926535897932384626433

struct compare
{
	int val;
	compare(int const &i): val{i} {}

	bool operator()(const int& i) const
	{
		return (i == val);
	}
};

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

    int a[n-1]; int count[n] = {0};
    REP(i,0,n-1) {
        cin >> a[i];
        count[a[i]-1]++;
    }

    REP(i,0,n) {
        p1(count[i]);
    }

    return 0;
}

Measured memory_bytes: 5216
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <cctype>
using namespace std;
const int MAX_M = 7;
const int INF = 1<<29;
struct min_max{
  int x_min,x_max,y_min,y_max;
public:
  min_max(){
    x_min = INF,x_max = -1,y_min = INF,y_max = -1;
  }
  void cal(int x,int y){
    x_min = min(x,x_min);
    y_min = min(y,y_min);
    x_max = max(x,x_max);
    y_max = max(y,y_max);
    //    cout << "x " << x_min << " y " << y_min << endl;
  }
  bool check(){
    if(x_min == INF)return false;
    return true;
  }
};
void dfs(const vector<vector<int> > relate,vector<pair<int,int> > &used,int c,int &cnt){
  if(used[c].second == 1)return;
  used[c].second = 1;
  for(int i = 0;i < relate[c].size();i++){
    if(used[relate[c][i]].second == 0){
      dfs(relate,used,relate[c][i],cnt);
    }
  }
  cnt++;
  used[c].first = cnt;
}
int main(){
  int n;
  cin >> n;
  for(int cnt = 0;cnt < n;cnt++){
    int h,w;
    cin >> h >> w;
    map<char,int> che;
    vector<vector<int> > image(h,vector<int>(w,0));
    vector<min_max> keep(MAX_M,min_max());
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	char tmp;
	cin >> tmp;
	if(isupper(tmp)){
	  if(che.count(tmp) == 0){
	    che.insert(make_pair(tmp,che.size()));
	  }
	  keep[che[tmp]].cal(j,i);
	  //cout << keep[che[tmp]].x_min << "ddd" << endl;
	  image[i][j] = che[tmp];
	}else{
	  image[i][j] = -1;
	}
      }
    }
    /*    for(int i = 0;i < keep.size();i++){
      cout << keep[i].x_min << " " << keep[i].x_max << " " << keep[i].y_min << " " << keep[i].y_max << endl;
      }
    */
    
    int flag = 0;
    int size = che.size();
    vector<vector<int> > relate(size);
    map<char,int>::iterator it = che.begin();
    while(it != che.end()){
      int i = (*it).second;
      for(int x = keep[i].x_min;x <= keep[i].x_max;x++){
	for(int y = keep[i].y_min;y <= keep[i].y_max;y++){
	  if(image[y][x] != i && image[y][x] >= 0 && image[y][x] < size ){
	    relate[i].push_back(image[y][x]);
	  }else{
	    if(image[y][x] == -1)flag = 1;
	  }
	}
      }
      it++;
    }
    if(flag){cout << "SUSPICIOUS" << endl;continue;}
    vector<pair<int,int> > used(size,pair<int,int>(0,0));
    int a = 0;
    for(int i = 0;i < used.size();i++){
      dfs(relate,used,i,a);
    }/*
    for(int i = 0;i < size;i++){
      cout << used[i].first <<"kkkk"<< endl;
      }*/
    for(int i = 0;i < relate.size();i++){
      for(int j = 0;j < relate[i].size();j++){
	//cout << relate[i][j] << "ddddddd " <<i<<" fff"<<cnt<< endl;
	if(used[i].first < used[relate[i][j]].first){
	  flag = 1;
	}
      }
    }
    if(flag)cout << "SUSPICIOUS" << endl;
    else cout << "SAFE" << endl;
  }
  return 0;
}
    

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {
	// freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

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

	int ans = 0;
	for (int i = 0; i < a.size(); ++i)
		ans += (a[i] == b[i]);

	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int vals[N];
vector<int> v[N];

void dfs(int s, int p, int op){
   vals[s] += op;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s, vals[s]);
      }
   }
}

int32_t main(){_

   int q;
   cin>>n>>q;

   for (int i = 0; i+1 < n; ++i)
   {
      int a, b;
      cin >> a >> b;
      v[a].pb(b);
      v[b].pb(a);      
   }

   while(q--){
      int p, x;
      cin >> p >> x;
      vals[p] += x;
   }

   dfs(1, -1, 0);

   for (int i = 1; i <= n; ++i)
   {
      cout<<vals[i]<<' ';
   }

   return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

ll n;
string ans;

string solve(ll x)
{
    string ret;
    while (x > 0ll)
    {
        ret = char(x%26+'a'-1) + ret;
        x /= 26;
    }
    return ret;
}

bool correct(string &s)
{
    bool ret = 0;
    // cout << s << " -> ";
    for (int i = 1; i < (int)s.length(); i++)
    {
        if (s[i] != 'a'-1)
            continue;
        ret = 1;
        s[i-1]--;
        s[i] = 'z';
    }
    // cout << s << '\n';
    return ret;
}

void output(string s)
{
    for (int i = 0; i < (int)s.length(); i++)
    {
        if ('a' <= s[i] && s[i] <= 'z')
            cout << s[i];
    }
}

int main()
{
    // cout << 'a'-1 << ' ' << int('`') << " -> " << ('a'-1 == '`') << '\n';
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    // for (ll i = 1; i <= 1000; i++)
    // {
    //     cout << i << " -> ";
    //     solve(i);
    // }
    string ans = solve(n);
    while (correct(ans));
    output(ans);
    return 0;
}

Measured memory_bytes: 3656
package main

import (
  "fmt"
  _ "sort"
  "math"
)

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

  a := make([][]int, n)

  for i:=0; i<n; i++ {
    a[i] = make([]int, d)
    for j:=0; j<d; j++ {
      fmt.Scan(&a[i][j])
    }
  }

  r := 0

  for i:=0; i<n; i++ {
    for j:=i+1; j<n; j++ {
      s := 0
      for k:=0; k<d; k++ {
        s += int(math.Pow(float64(a[i][k] - a[j][k]), 2.0))
      }
      t := int(math.Pow(float64(s), 0.5))
      for u:=t-1; u<t+2; u++ {
        if u*u == s {
          r += 1
        }
      }
    }
  }

  fmt.Printf("%d\n", r)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int X,Y,A,B,C;
	cin >> X >> Y >> A >> B >> C;
	multiset<int>a,b,c;
	REP(i,A){
		int t;
		cin >> t;
		a.insert(t);
	};
	REP(i,B){
		int t;
		cin >> t;
		b.insert(t);
	}
	REP(i,C){
		int t;
		cin >> t;
		c.insert(t);
	}
	REP(i,A - X)a.erase(a.begin());
	REP(i,B - Y)b.erase(b.begin());
	REP(i,C){
		int aa = *a.begin();
		int bb = *b.begin();
		auto itr = prev(c.end());
		if(aa < bb){
			if(aa < *itr){
				a.erase(a.begin());
				a.insert(*itr);
				c.erase(itr);
			}
		}else{
			if(bb < *itr){
				b.erase(b.begin());
				b.insert(*itr);
				c.erase(itr);
			}
		}
	}
	int As = 0,Bs = 0;
	while(a.size()){
		As += *a.begin();
		a.erase(a.begin());
	}
	while(b.size()){
		Bs += *b.begin();
		b.erase(b.begin());
	}
	out(As + Bs);
}

Measured memory_bytes: 15360
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn one_move(ss: &mut Vec<usize>, gs: &Vec<usize>, field: &Vec<char>, i: usize) -> bool {
    for d in 1..3 {
        let npos = ss[i] + d;
        if npos <= gs[i] && field[npos] == '.' && npos != ss[i ^ 1] {
            ss[i] = npos;
            return true;
        }
    }
    return false;
}

fn main() {
    let _n = read::<i64>();
    let mut ss = vec![0; 2];
    let mut gs = vec![0; 2];
    for i in 0..2 {
        ss[i] = read::<usize>() - 1;
    }
    for i in 0..2 {
        gs[i] = read::<usize>() - 1;
    }
    let field = read::<String>().chars().collect::<Vec<char>>();
    if gs[0] < gs[1] {
        ss.swap(0, 1);
        gs.swap(0, 1);
    }
    for i in 0..2 {
        while ss[i] < gs[i] {
            if !one_move(&mut ss, &gs, &field, i) {
                if !one_move(&mut ss, &gs, &field, i ^ 1) {
                    println!("No");
                    return;
                }
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4476
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int K; cin >> K;
    string S; cin >> S;
    if(SZ(S)>K) {
        S=S.substr(0,K);
        S+="...";
    }
    cout << S << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3][3],b[10];
    for(int i=0;i<3;++i)
        for(int j=0;j<3;++j)
        cin>>a[i][j];
    map<int,int>m;
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>b[i];
        m[b[i]]=1;
    }
    int k=0;
    for(int i=0;i<3;++i){
        if(m[a[i][0]]&&m[a[i][1]]&&m[a[i][2]])
            k++;
    }
    for(int j=0;j<3;++j){
        if(m[a[0][j]]&&m[a[1][j]]&&m[a[2][j]])
            k++;
    }
    if(m[a[0][0]]&&m[a[1][1]]&&m[a[2][2]])
        k++;
    else if(m[a[0][2]]&&m[a[1][1]]&&m[a[2][0]])
        k++;

    if(k!=0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m >> k;
    vector<int> v = {n, m, k};
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0] * 10 + v[1] + v[2] << endl;
    return 0;
}


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

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

    int a, p;
    cin >> a >> p;
    int total = (a * 3) + p;
    int result = 0;
    while (total >= 2) {
        total = total - 2;
        result++;
    }
    cout << result;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e18;

ll dp[3010][3010], a[3010], v[3010][3010];
ll n;

ll f(int l, int r) {
  if (l > r) return 0;
  if (v[l][r]) return dp[l][r];
  v[l][r] = 1;

  ll res;
  ll turn = n - 1 - (r - l);
  if (turn % 2 == 0) {
    res = -INF;
    res = max(res, f(l + 1, r) + a[l]);
    res = max(res, f(l, r - 1) + a[r]);
  } else {
    res = INF;
    res = min(res, f(l + 1, r) - a[l]);
    res = min(res, f(l, r - 1) - a[r]);
  }
  return dp[l][r] = res;
}

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];

  cout << f(0, n - 1) << endl;
   return 0;
}

Measured memory_bytes: 96144
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[2][20];  /* dp[id][i+1] : 先頭からi桁目までの各桁の和の最大値。
                                ただし、id = 0 のとき現時点でsと等しい
                                id = 1 のとき現時点でs未満が確定 */

int main() {
    string s;
    cin >> s;
    ll m = s.size();  // sはm桁とする
    
    dp[1][0] = -INF;
    rep(id, 2) {
        rep(i, m) {
            ll lim = s[i] - '0';  //  先頭からi桁目にはlim以下の数を置ける
            if(id) {  // s未満が確定していたら
                lim = 9;
            }
            exrep(x, 0, lim) {  // 先頭からi桁目にxを置くとする
                chmax(dp[id || x < lim][i+1], dp[id][i] + x);
            }
        }
    }
    
    out(max(dp[0][m], dp[1][m]));
    re0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

/*#define int ll*/
signed main(){
    int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < A.size(); i++)
	{
		cin >> A[i];
	}
	
	map<int, int> m;
	vector<int> SUM(N + 1);
	SUM[0] = 0;
	for (int i = 0; i < N; i++)
	{
		SUM[i + 1] = (SUM[i] + A[i]) % M;
	}
 
	long long ans = 0;
	for (int i = 0; i < SUM.size(); i++)
	{
		ans += m[SUM[i]];
		m[SUM[i]]++;
	}
 
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
let () =
  try
    while true do
      let c1, c2, c3 = Scanf.scanf "%d %d %d\n" (fun a b c -> (a, b, c)) in
      let lst = [1;2;3;4;5;6;7;8;9;10] in
      let sum2 = c1 + c2 in
      let n = 20 - sum2 in
      let lst' = List.filter (fun x -> x <> c1 && x <> c2 && x <> c3 && x <= n) lst in
      Printf.printf "%s\n" (if (List.length lst') >= 4 then "YES" else "NO")
    done
  with
  | End_of_file -> ()


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std; 
int N; 
vector<int> E[200010]; 
vector<int> A[200010]; 
int S[200010]; // iを根とする部分木のサイズ
void dfs(int now, int parent){
	for(int i = 0; i < E[now].size(); i++){
		if(E[now].at(i) == parent) continue; 
		dfs(E[now].at(i), now); 
		S[now] += S[E[now].at(i)]; 
	}
}
void dfs2(int now, int parent){
	int tmp = N-1; 
	for(int i = 0; i < E[now].size(); i++){
		if(E[now].at(i) == parent) continue; 
		A[now].push_back(S[E[now].at(i)]); 
		tmp -= S[E[now].at(i)]; 
	}
	A[now].push_back(tmp); 
	for(int i = 0; i < E[now].size(); i++){
		if(E[now].at(i) == parent) continue; 
		dfs2(E[now].at(i), now); 
	}
}
long long int Pow(long long int a, int n, long long int m) {
	long long tmp = a; 
	long long pow = n;
	long long Q = 1;  
  	while(pow > 0){
		if(pow & 1){
			Q *= tmp; Q %= m; 
		}
		tmp = tmp * tmp % m; 
     		pow >>= 1; 
  	}
	return Q;
}
int main(){
	cin >> N; 
	for(int i = 0; i < N-1; i++){
		int a, b; cin >> a >> b;  
		a--; b--; 
		E[a].push_back(b); 
		E[b].push_back(a); 
	}
	for(int i = 0; i < N; i++) S[i] = 1; 
	dfs(0, -1); 
	dfs2(0, -1); 
	long long ans = (long long) N; 
	long long P = 1000000007; 
	for(int i = 0; i < N; i++){
		long long tmp = 1000000 * P; 
		for(int j = 0; j < A[i].size(); j++){
			tmp -= Pow(500000004, N - 1 - A[i].at(j), P); 
		}
		tmp += (((long long) A[i].size() - 1) * Pow(500000004, N - 1, P)) % P; 
		tmp %= P; 
		ans += tmp; ans %= P; 
	}
	ans *= 500000004; ans %= P; 
	cout << ans << endl; 
}

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

main() {
    int N,K,X,Y; cin >> N >> K >> X >> Y;
    if(N>K) cout << K*X+(N-K)*Y << endl;
    else cout << N*X << endl;

    return 0;
}

Measured memory_bytes: 384
# editorial参照
# 格子まで詰め込もうとしたのが困難
# 十分大きい黒白の塊一つに孤立した白黒の点を取る

#最初のに出力h,w追加
a,b = map(int, input().split( ))
k=50
W = [["."]*(k*2) for i in range(k)] 
B = [["#"]*(k*2) for i in range(k)]

for i in range(b-1):
    w = (i//k)*2
    h = (i%k)*2
    W[w][h]="#"


for i in range(a-1):
    w = (i//k)*2+1
    h = (i%k)*2+1
    B[-w][-h]="."
ans = [''.join(W[i]) for i in range(k)]+ [''.join(B[i]) for i in range(k)]
print(100,100)
print('\n'.join(ans))


    


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count = 0;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
  cin >> a.at(i);
  }
  int store = 0;
 for(int i=0;i<N;i++){
   int max = 0;
   int j   =0;
   for(int k=0;k<N;k++){
     if(max<a.at(k)){
       max=a.at(k);
       j = k;
     }
   }
   a.at(j) = 0;
   if(max != store){
     count++;
     store = max;
   }
  }  
  cout << count << endl;
  return 0; 
}

Measured memory_bytes: 256
n, m = map(int, input().split())
min_num = 0
max_num = 10**5
           
for i in range(m):
  min_temp, max_temp = map(int, input().split())
  if min_temp > min_num:
    min_num = min_temp
  if max_temp < max_num:
    max_num = max_temp
print(max(max_num - min_num + 1, 0))
  


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

vector<int> odd, even;
int n, a[18], b[18];
int dfs(int x) {
  int res = 1000000000;
  if (x == n) {
    vector<pair<int, int> > oddp, evenp;
    for (int i = 0; i < odd.size(); i++) {
      if (odd[i] % 2) {
        oddp.push_back({b[odd[i]], odd[i]});
      } else {
        oddp.push_back({a[odd[i]], odd[i]});
      }
    }
    for (int i = 0; i < even.size(); i++) {
      if (even[i] % 2 == 0) {
        evenp.push_back({b[even[i]], even[i]});
      } else {
        evenp.push_back({a[even[i]], even[i]});
      }
    }
    sort(oddp.begin(), oddp.end());
    sort(evenp.begin(), evenp.end());

    for (int i = 0; i < oddp.size(); i++) {
      if (n % 2 == 0 || i != oddp.size() - 1) {
        if (oddp[i].first > evenp[i].first) {
          return res;
        }
      }
      if (i != 0) {
        if (oddp[i].first < evenp[i - 1].first) {
          return res;
        }
      }
    }
    res = 0;
    for (int i = 0; i < oddp.size(); i++) {
      for (int j = i + 1; j < oddp.size(); j++) {
        if (oddp[i].second > oddp[j].second) {
          res++;
        }
      }
      for (int j = i; j < even.size(); j++) {
        if (oddp[i].second > evenp[j].second) {
          res++;
        }
      }
    }
    for (int i = 0; i < evenp.size(); i++) {
      for (int j = i + 1; j < oddp.size(); j++) {
        if (evenp[i].second > oddp[j].second) {
          res++;
        }
      }
      for (int j = i + 1; j < evenp.size(); j++) {
        if (evenp[i].second > evenp[j].second) {
          res++;
        }
      }
    }
    return res;
  }
  if (odd.size() < (n + 1) / 2) {
    odd.push_back(x);
    res = min(res, dfs(x + 1));
    odd.pop_back();
  }
  if (even.size() < (n) / 2) {
    even.push_back(x);
    res = min(res, dfs(x + 1));
    even.pop_back();
  }
  return res;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  int ans = dfs(0);
  if (ans == 1000000000) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

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

int main() {
  int a, b, ans;
  cin >> a >> b;
  
  if(abs(a-b) >= 1)
    ans = max(a, b) * 2 - 1;
  else
    ans = 2*a;
  
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  int B;
  cin >> N >> A >> B ;
  int plan1 = A*N;
  int plan2 = B;
  if (plan1 < plan2 ){
   cout << plan1 ;
  }
  else{
    cout << plan2;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,x,i,a[500],d[500],acm;
    while(~scanf("%d%d",&n,&x))
    {
        d[1]=0;
        acm=1;
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(i=2;i<=n+1;i++)
        {
            d[i]=d[i-1]+a[i-1];
            if(d[i]<=x)
                acm++;
        }
        printf("%d\n",acm);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/
ll tree[1000000];
void build(ll node, ll l ,ll r){
    if(r-l<2){
        tree[node] = 0;
        return;
    }
    ll mid = (l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid,r);
    tree[node]=0;
}
void update(ll node, ll l, ll r, ll x, ll val){
    if(x>=r or x < l) return ;
    if(r-l<2){
        tree[node]+=val;
        return;
    }
    ll mid = (l+r)/2;
    if(x<mid){
        update(2*node,l,mid,x,val);
    }else{
        update(2*node+1,mid,r,x,val);
    }
    tree[node] = max(tree[2*node] , tree[2*node+1]);
}

ll query(ll node, ll l, ll r, ll x, ll y){
    if(x>=r or y<=l) return 0;
    if(x<=l and y>=r) return tree[node];
    ll mid = (l+r)/2;
    return max(query(2*node,l,mid,x,y) , query(2*node+1,mid,r,x,y));
}

int main(){
    _cin;
    // cout << setprecision(22);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n;
    vector<pair<ll,pair<ll,ll>>> a(n);
    fo(i,n){
        cin >> a[i].first;
        a[i].second.second=i;
    }
    fo(i,n) cin >> a[i].second.first;
    sort(all(a));
    mx=0;
    build(1,0,n);
    fo(i,n){
        x = query(1,0,n,0,a[i].second.second);
        mx = max(mx , x + a[i].second.first);
        update(1,0,n,a[i].second.second, x + a[i].second.first);
    }
    cout << mx;
}
 return 0;      
}

Measured memory_bytes: 11136
n, m =map(int,input().split())
c = list(map(int,input().split()))

INF = 10**100
dp = [INF]*500000
dp[0] = 0

for i in range (n+1):
    for j in c:
        dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])


Measured memory_bytes: 10772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
    ll n,m,x,y;
    cin>>n>>m;

    ll a[n+1] = {0};
    bool check[n+1] = {0};
    for(int i=1;i<=n;i++)
        cin>>a[i];

    while(m--)
    {
        cin>>x>>y;
        if(a[x] == a[y])
            check[x] = check[y] = 1;
        else if(a[x] > a[y])
            check[y] = 1;
        else
            check[x] = 1;
    }

    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(!check[i])
            ans++;
    }

    cout<<ans<<"\n";

}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 4484
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int N = 5;

    //届くのにかかる時間
    vector<int> Time = {a,b,c,d,e};

    //次に注文できるまでの時間
    vector<int> nextTime(N);
    for(int i = 0; i < N; i++)
    {
        if (Time[i] % 10 == 0) {
            nextTime[i] = Time[i];
        } else
        {
            nextTime[i] = Time[i] - (Time[i] % 10) + 10;
            //example 123
            //130 == 123 - 3 + 10
        }
    }
    
    int BestTime = 9999999;

    //最後に注文すべきものを全探索
    //入力によって組み合わせ数が変化しないことに気づけるとよかった
    
    //最後の注文→i
    //注文の順番→j
    for(int i = 0; i < N; i++)
    {
        int SumTime = 0;
        for(int j = 0; j < N; j++)
        {
            if (i == j) { //最後の注文
                SumTime += Time[j];
            } else //最後以外の注文
            {
                SumTime += nextTime[j];
            }
        }
        BestTime = min(BestTime, SumTime); 
    }
    cout << BestTime;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
s=""
if n==1:
  s=l[0]
elif n%2==1:
  s+=str(l[n-1])
  for i in range(1,(n//2)+1):
    s+=" "+str(l[n-i*2-1])
  for i in range(1,n//2+1):
    s+=" "+str(l[i*2-1])
else:
  s+=str(l[n-1])
  for i in range(1,n//2):
    s+=" "+str(l[n-i*2-1])
  for i in range(1,(n//2)+1):
    s+=" "+str(l[i*2-2])
print(s)

Measured memory_bytes: 26020
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

s=input()
ans=s+'s' if s[-1]!='s' else s+'es' 

print(ans)

Measured memory_bytes: 9324
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int d;
	cin >> d;
	cout << "Christmas";
	
	while (d < 25) {
		d++;
		cout << " Eve";
	}

	cout << endl;

	return 0;
}

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

using namespace std;
int main(){
/*int n;
string s,t;
long dp[100009]={};
int wp[26][100009]={};//ワープの個数、ワープ先の星(t)
int alpha[100009];//所属アルファベット(s)

int solve(int now){
	if(now==n-1) return dp[n-1]=1;//目的地
	if(dp[now]!=0) return dp[now];
	for(int i=1; i<wp[alpha[now]][0]+1; i++){//ワープの個数ループ
		if(wp[alpha[now]][i] > now){//条件を満たす
			dp[now] += solve(wp[alpha[now]][i]);
		}
	}
	return dp[now];
}

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

	string alph="abcdefghijklmnopqrstuvwxyz";
	for(int i=0; i<t.size(); i++){
		alpha[i] = s[i] - 'a';
		wp[t[i]-'a'][0]++;
		wp[t[i]-'a'][wp[t[i]-'a'][0]] = i;
	}

	solve(0);

	cout << dp[0]%1000000007 << endl;

	return 0;


}*/
/*
	int a,n,m;
	cin >> a >> n >> m;
	int ans=0;

	for(int i=1; i<=m; i++){
		int x=1;
		int y=(i/100)+((i%100)/10)+(i%10);
		for(int j=0; j<n; j++){
			x*=(y+a);
		}
		if(x==i)ans++;
	}

	cout << ans << endl;

	
	*/

int a, b, c;

cin >> a >> b >> c;

	if (a < b && b < c){
		cout << "Yes" << endl;
	}

	else{
		cout << "No" << endl;
	}

	return 0;
}



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

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

int main(){
    int h, n; cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<vector<ll>> dp(n+1,vector<ll>(h+1,INF));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= h; j++){
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i]);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 78592
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	x := sc.NextInt()
	l := 0
	ans := 1
	for i := 0; i < n; i++ {
		l += sc.NextInt()
		if l <= x {
			ans++
		}
	}
	fmt.Printf("%+v\n", ans) // output for debug
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}



Measured memory_bytes: 640
//Lucky PIN

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18


signed main (){
    int n;
    string s;
    cin>>n>>s;
    int ans{};
    bool flag=false;
    rep(i,0,10)rep(j,0,10)rep(k,0,10){
        flag=false;
        for(int q=0;q<n;q++){
            if(flag)break;
            if(s[q]-'0'==i){
                for(q++;q<n;q++){
                    if(flag)break;
                    if(s[q]-'0'==j){
                        for(q++;q<n;q++){
                            if(flag)break;
                            if(s[q]-'0'==k){
                                ans++;flag=true;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3680
N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

cum_A = [0] * (N + 1)
for i in range(1, N + 1):
    cum_A[i] = cum_A[i - 1] + A[i - 1]
cum_B = [0] * (M + 1)
for i in range(1, M + 1):
    cum_B[i] = cum_B[i - 1] + B[i - 1]

ans = 0
b_ub = M + 1
for i in range(N + 1):
    rest = K - cum_A[i]
    for j in range(b_ub)[::-1]:
        if cum_B[j] <= rest:
            ans = max(i + j, ans)
            b_ub = j + 1
            break

print(ans)


Measured memory_bytes: 117788
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch PowerSocket | diff PowerSocket.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address PowerSocket.cpp && ./a.out

/*
 
 9/1/2019
 
 5:02-
 
 */

int A,B;

void solve() {
  int res=0;
  if(B==1) res=0;
  else if(B<=A) res=1;
  else {
    res=2; int x=2*A-1;
    while(B>x) {
      ++res;
      x+=A-1;
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
# 2 次元平面上に辺の長さがそれぞれ L1,L2,...,LN の
# N 角形(凸多角形でなくてもよい)が描けるかを判定してください。
# ここで、次の定理を利用しても構いません。
# 定理 : 一番長い辺が他の N−1 辺の長さの合計よりも真に短い場合に限り、条件を満たす N 角形が描ける。

n = gets.to_i
l = gets.chomp.split
n.times do |i|
    l[i] = l[i].to_i
end

max = l.max
sum = 0
n.times do |i|
    sum += l[i]
end
sum -= max

if max < sum
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788