akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int num = N % 10;
        String a = null;
        
        if(num == 3){
            a = "bon";
        } else if(num == 0||num==1||num==6||num==8){
            a = "pon";
        } else {
            a ="hon";
        }
        
        System.out.println(a);
    }
}


Measured memory_bytes: 35724
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())
n = 0
m = 0

if N >= 2:
    n = combinations_count(N, 2)
if M >= 2:
    m = combinations_count(M, 2)

print(n + m)


Measured memory_bytes: 3060
import fractions as frac
a,b,c,d = map(int,input().split())


lcm = (c * d) // frac.gcd(c,d)
if a % lcm != 0:
    s = lcm - a % lcm
else:
    s = 0
e = b % lcm
m = ((b - e) - (a + s)) // lcm
modgcd = (b - a + 1) - (s + (lcm - 1) * m + e)

if a % c != 0:
    s = c - a % c
else:
    s = 0
e = b % c
m = ((b - e) - (a + s)) // c
modc = (b - a + 1)- (s + (c - 1) * m + e)

if a % d != 0:
    s = d - a % d
else:
    s = 0
e = b % d
m = ((b - e) - (a + s)) // d
modd = (b - a + 1) - (s + (d - 1) * m + e)

print((b - a + 1)-(modc + modd - modgcd))


Measured memory_bytes: 5048
a=''
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=f'\n{len(z)}'
print(a[1:])


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

res = 0
buf = -2
for i in A:
	res += B[i-1]
	if buf == i-2:
		res += C[i-2]
	buf = i-1

print(res)

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

multiset < int > arr; int N , cnt;

int main(){
	cin >> N;
	for(int i = 1 , x ; i <= N ; ++i){cin >> x; arr.insert(x);}
	while(!arr.empty()){
		int t = *--arr.end(); arr.erase(arr.find(t)); int x = 1 << (int)(log2(t + 0.1) + 1);
		if(arr.find(x - t) != arr.end()){arr.erase(arr.find(x - t)); ++cnt;}
	}
	cout << cnt; return 0;
}

Measured memory_bytes: 9728
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed int main() {
	string s;
	cin >> s;
	int n = s.size();

	string substr1 = s.substr(0, (n - 1) / 2);
	int n1 = substr1.size();
	string substr2 = s.substr((n + 3) / 2 - 1, (n - 1) / 2);
	int n2 = substr2.size();


	rep(i, n/2+1) {
		if (s[i] != s[n - 1-i]) {
			print("No");
				return 0;

		}
	}
	//print(substr1);
	rep(i, n1 / 2 + 1) {
		if (substr1[i] != substr1[n1 - 1 - i]) {
			print("No");
			return 0;

		}
	}
	//print(substr2);
	rep(i, n2 / 2 + 1) {
		if (substr2[i] != substr2[n2 - 1 - i]) {
			print("No");
			return 0;

		}
	}

	print("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

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

	if (a >= 3200) {
		cout << s;
		return 0;
	}
	cout << "red";
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    string s;
    cin>>s;
    if (s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";




}

Measured memory_bytes: 256
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;

string s;
map<char, bool> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  FOR(i, 0, sz(s)) m[s[i]] = true;
  cout << ((m['N']^m['S']||m['E']^m['W']) ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
ls = []
for i in range(N):
    ls.append(int(input()))
i = 0
cnt = 1
while(cnt <= N):
    k = ls[i]
    if (k == 2):
        print(cnt)
        sys.exit()
    cnt += 1
    i = k-1
print(-1)

Measured memory_bytes: 7084
#include <cstdio>
#include <algorithm>
using namespace std;
int n, s=1, M=1e9+7, a[100005];

bool f() {
	int i;
	if(n%2) {
		if(a[0] != 0) return 0;
		for(i=1; i<n; i+=2) {
			if(a[i]-a[i-1] != 2) return 0;
			if(a[i+1]-a[i] != 0) return 0;
		}
	} else {
		if(a[0]!=1 || a[1]!=1) return 0;
		for(i=2; i<n; i+=2) {
			if(a[i]-a[i-1] != 2) return 0;
			if(a[i+1]-a[i] != 0) return 0;
		}
	}
	return 1;
}

int main() {
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	if(!f()) {puts("0"); return 0;}
	for(i=0; i<n/2; i++) s = s*2 % M;
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 512
a,b,k = list(map(int, input().split()))

c = [a,b]
c.sort()
a= c[0]
b= c[1]
n = []
for i in range(1, a+1):
    if a%i == 0 and b%i == 0:
        n.append(i)

print(n[-k])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long  int h1,m1,h2,m2,k,i,j;
  cin>>h1>>m1>>h2>>m2>>k;
  j=h2*60+m2;
  i=h1*60+m1;
  cout<<abs(j-i-k);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0; i != N; ++i)
#define co(o) cout << o << endl;
using namespace std;
typedef long int li;
typedef long long ll;

int N;

void dfs(string str, char used){
    if(str.length()==N){
        cout << str << endl;
    }else{
        for(char c='a'; c<=used+1; ++c){
            dfs(str+c, max(used,c));
        }
    }
}

int main(void){
    cin >> N;   
    string s;    
    s.reserve(N);
    s="a";
    dfs(s,'a');
}


Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const ll MAX = 10000000000000;

int main() {
	ll n; // 32 10^9.6
	cin >> n;
  ll min = MAX;
  for (int i = 1; i <= 1000000; ++i) {
    if (n % i == 0 && min > (n/i + i)) {
      //cout << n/i << " " << i << endl;
      min = n/i + i;
    }
  }
	cout << min - 2<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    set<ll> prime;
    vec similar(0);
    reps(i,2,100010){
        bool p = true;
        for(ll pri : prime){
            if(i%pri == 0) p = false;
            if(pri * pri > i) break;
        }
        if(p) prime.insert(i);
    }

    /*for(ll p : prime){
        cout<<p<<endl;
        if(p > 100) break;
    }
    cout<<endl;*/

    reps(i,1,50005){
        ll temp = i*2 + 1;
        if((prime.find(temp) != prime.end()) && (prime.find(temp/2 + 1) != prime.end())){
            similar.push_back(temp);
        }
    }

    /*rep(i,10) cout<<similar[i]<<' ';
    cout<<endl;*/

    cin>>Q;
    rep(i,Q){
        cin>>L>>R;
        cout<<upper_bound(similar.begin(), similar.end(), R) - lower_bound(similar.begin(), similar.end(), L)<<endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

vector<int> T[200005];
vector<int> ans;

void dfs(int a, int p){
	for(int x : T[a]) {
		if(x != p){
			ans[x] += ans[a];
			dfs(x, a);
		}
	}
}

int main(void){
	int n, q;
	scanf("%d %d", &n, &q);
	rep(i, n - 1){
		int a, b;
		scanf("%d %d", &a, &b);
		T[a].push_back(b);
		T[b].push_back(a);
	}
	ans.resize(n + 1);
	rep(i, q){
		int p, x;
		scanf("%d %d", &p, &x);
		ans[p] += x;
	}
	dfs(1, 0);
	for(int i = 1; i <= n; i++) printf("%d\n", ans[i]);

	return 0;
}


Measured memory_bytes: 23424
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        
        UnionFind uf = new UnionFind(n);
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < q; i++){
            if(Integer.parseInt(sc.next()) == 0){
                uf.unite(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
            }else{
                if(uf.same(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()))){
                    sb.append(1).append(System.lineSeparator());
                }else{
                    sb.append(0).append(System.lineSeparator());
                }
            }
        }
        
        System.out.print(sb);
    }
    
    static class UnionFind {
        int[] parent;
        int[] rank;
        
        public UnionFind(int n) {
            parent = new int[n];
            rank = new int[n];
            for(int i = 0; i < n; i++){
                parent[i] = i;
            }
        }
        int root(int x){
            if(parent[x] == x){
                return x;
            }else{
                return parent[x] = root(parent[x]);
            }
        }
        void unite(int x, int y){
            x = root(x);
            y = root(y);
            if(x == y) return;

            if(rank[x] < rank[y]){
                parent[x] = y;
            }else{
                parent[y] = x;
                if(rank[x] == rank[y]){
                    rank[x]++;
                }
            }
        }
        boolean same(int x, int y){
            return root(x) == root(y);
        }
    }
}


Measured memory_bytes: 71400
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x=N;
  int pow;
  for(int i=0;i<=5;i++){
    if(x/10>0)x/=10;
    else {pow=i; break;}
  }
  if(pow==0) cout << N << endl;
  if(pow==1) cout << 9 << endl;
  if(pow==2) cout << 9+N-99 << endl;
  if(pow==3) cout << 9+900 << endl;
  if(pow==4)cout << 9+900+N-9999 << endl;
  if(pow==5) cout << 9+900+90000 << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

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

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

    if(a < b){
      System.out.println("a < b");
    } else if(a > b){
      System.out.println("a > b");
    } else {
      System.out.println("a == b");
    }
  }
}



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

int main () {
  int n;
  cin >> n;
  vector<int> a (n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (is_sorted(a.begin(), a.end())) {
    cout << "YES" << '\n';
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      swap (a[i], a[j]);
      if (is_sorted(a.begin(), a.end())) {
        cout << "YES" << '\n';
        return 0;
      }
      swap (a[i], a[j]);
    }
  }
  cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main() {
	std::string g;
	int a=0;
	std::cin >> g;
	
	for (int i = 0; i < 4; i++) {
		if (g[i] == '+') {
			a++;
		}
		else {
			a--;
		}
	}

	std::cout << a << std::endl;
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
NN=N//2
l=list(map(int,input().split()))
l1=[l[2*i] for i in range(NN)]
l2=[l[2*i+1] for i in range(NN)]
l1c=Counter(l1)
l2c=Counter(l2)
r1=l1c.most_common()
r2=l2c.most_common()
if r1[0][0]==r2[0][0]:
  if r1[0][1]==NN and r2[0][1]==NN:
    ans=NN
  elif r1[0][1]>r2[0][1]:
    ans=N-r1[0][1]-r2[1][1]
  elif r1[0][1]<r2[0][1]:
    ans=N-r1[1][1]-r2[0][1]
  else:
    if r1[1][1]>r2[1][1]:
      ans=N-r1[1][1]-r2[0][1]
    else:
      ans=N-r1[0][1]-r2[1][1]
else:
  ans=N-r1[0][1]-r2[0][1]
print(ans)

Measured memory_bytes: 21952
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
            if(n%2==0)
            {
                printf("%d\n",n);
            }
            if(n%2!=0)
            {
                printf("%d\n",n*2);
            }
        }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
void solve()
{
    int n;
    vector<pll> v;
    cin >> n;
    v.resize(n);
 
    for (int i = 0; i < n; i++)
    {
        cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end());
    ll curr = 0;
    bool good = true;
    for (pll out : v)
    {
        curr += out.second;
        good &= curr <= out.first;
    }
    if (good)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
 
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1<<29;

const double PI = acos(-1);
const double EPS = 1e-8;

vector<int> sub(vector<int> &v, int pos) {
  vector<int> res;
  if (v.size() <= pos) return res;
  for (int i=pos; i<v.size(); ++i) {
    res.push_back(v[i]);
  }
  v.erase(v.begin()+pos, v.end());
  reverse(ALL(res));
  return res;
}
int main() {
  int m;
  while(cin>>m,m) {
    vector<vector<int> > pile;
    REP(i, m) {
      pile.push_back(vector<int>(1, i));
    }
    
    int a,b;
    while(cin>>a>>b,a||b) {
      a--; b--;
      if (a == b) continue;
      int p1, p2, h1, h2;
      REP(i,pile.size()) {
        REP(j,pile[i].size()) {
          if (pile[i][j] == a) p1 = i, h1 = j;
          if (pile[i][j] == b) p2 = i, h2 = j;
        }
      }
      if (b < 0) {
        if (h1 == 0) continue;
        pile.push_back(vector<int>());
        p2 = pile.size()-1;
        h2 = 0;
      }
      if (p1 == p2) {
        if (h1 > h2) {
          continue;
        } else {
          for (int i=h1+1; i<pile[p1].size(); ++i) {
            pile.push_back(vector<int>(1, pile[p1][i]));
            if(i == h2) pile[pile.size()-1].push_back(a);
          }
          pile[p1].erase(pile[p1].begin()+h1, pile[p1].end());
        }
      } else {
        for (int i=h1+1; i<pile[p1].size(); ++i)
          pile.push_back(vector<int>(1, pile[p1][i]));
        pile[p2].push_back(a);
        pile[p1].erase(pile[p1].begin()+h1, pile[p1].end());
      }
      for (int i=pile.size()-1; i>=0; --i) {
        if (pile[i].size() == 0) pile.erase(pile.begin() + i);
      }
      // FOR(it, pile) {
      //   FOR(jt, *it) {
      //     cout << *jt << " ";
      //   }
      //   cout << endl;
      // }
      // cout << "===========" << endl;
    }
    vector<int> ans;
    FOR(it, pile) {
      ans.push_back(it->size());
    }
    sort(ALL(ans));
    FOR(it, ans) cout << *it << endl;
    cout << "end" << endl;
  }
}

Measured memory_bytes: 0
A,B,C = map(str,input().split())
haiku = A+B+C
flag = 0
if haiku == "755":
  flag = 1
elif haiku == "575":
  flag = 1
elif haiku == "557":
  flag = 1
else:
  print("NO")
if flag == 1:
  print("YES")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  int x,y;
  cin>>x>>y;
  if(y%2!=0)
  {
    cout<<"No";
    return;
  }
  int low=2*x,high=4*x;
  if(y>=low && y<=high)
  cout<<"Yes";
  else
  cout<<"No";
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
long long int gcd(long long int x,long long int y){
	if(max(x,y)%min(x,y)==0){
		return min(x,y);
	}else{
		return gcd(max(x,y)%min(x,y),min(x,y));
	}
}
int main()
{
	long long int a,b;
	cin>>a>>b;
	vector<long long int> n;
	long long int g=gcd(a,b);
	n.push_back(1);
	long long int gcd=g;
	
	for(long long int i=2;i<=sqrt(gcd);i++){
		if(g==1){
			break;
		}else if(g%i==0){
			n.push_back(i);
			while(g%i==0){
				g=g/i;
			}
		}
	}
	if(g!=1)n.push_back(g);
	
	cout<<n.size()<<endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int _h;
  cin >> _h;
  bool flg = true;
  for (int i = 1; i < N; ++i) {
    int h;
    cin >> h;
    if (_h < h) {
      _h = --h;
    } else if (_h > h) {
      flg = false;
    }
  }
  if (flg) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3120
int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  int ans;
  if (a != 1 && b != 1)
    ans = 1;
  else if (a != 2 && b != 2)
    ans = 2;
  else
    ans = 3;
  printf("%d", ans);
}

Measured memory_bytes: 128
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

ll dp[200100];
int main(){
   int n;
   cin >> n;
   vector<ll> a(n);
   rep(i, n)cin >> a[i];

   ll sum = 0;
   rep(i, n){
       dp[i + 1] = (dp[i] + sum * a[i] % MOD) % MOD;
       (sum += a[i]) %= MOD;
   }
   dp[n] %= MOD;
   cout << dp[n] << endl;
}


Measured memory_bytes: 6052
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<modint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    modint operator()(int n, int k) {
        if (n < k || k < 0) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    modint h(int n, int k) {
        n += k - 1;
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2002002);
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    modint x = 1;
    rep(i, a) x *= (n - i);
    rep(i, a) x /= (i + 1);
    modint y = 1;
    rep(i, b) y *= (n - i);
    rep(i, b) y /= (i + 1);
    cout << (modint(2).pow(n) - 1 - x - y).value() << endl;
}

Measured memory_bytes: 31488
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let rec f n =
    if n < 2L then
        1L
    else
        n * f (n - 2L)

[<EntryPoint>]
let main _ =
    let N = read int64

    let fs =
        Seq.scan (fun s _ -> s * 5L) 1L (Seq.initInfinite id)
        |> Seq.tail
        |> Seq.takeWhile (fun x -> x <= N)

    // eprintfn "%A" (Seq.toArray fs)

    if N % 2L = 1L then
        printfn "0"
    else
        let mutable ans = 0L
        for d, i in Seq.zip fs (Seq.initInfinite id |> Seq.tail) do
            let a = N / d
            let b =
                if a % 2L = 0L then
                    a / 2L
                else
                    (a - 1L) / 2L
            let c = b / 5L
            ans <- ans + (int64 i * (b - c))
        printfn "%i" ans

    0

Measured memory_bytes: 14416
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	var a, b, k = scanInt(), scanInt(), scanInt()

	if a < 1 || b < 1 {
		panic("a and b must be > 1")
	}

	if k > 100 {
		panic("k must be <= 100")
	}

	sideA := true
	for {
		if sideA && a%2 != 0 {
			a--
		}
		if !sideA && b%2 != 0 {
			b--
		}
		if sideA {
			a /= 2
			b += a
		} else {
			b /= 2
			a += b
		}

		k--
		sideA = !sideA

		if k <= 0 {
			break
		}
	}

	fmt.Printf("%+v %+v", a, b)
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	int N;
	cin >> N;

	priority_queue<double, vector<double>, greater<double> > queue;

	FOR(i, 0, N){
		int in;
		cin >> in;
		queue.push(in);
	}

	while(queue.size() > 1){
		double d1 = queue.top();
		queue.pop();
		double d2 = queue.top();
		queue.pop();

		queue.push((d1+d2)/2);
	}

	cout << setprecision(16) << queue.top() << '\n';

}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: i64 = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut x = 0;
    for i in (0..41).rev() {
        if x | (1 << i) > k {
            continue;
        }
        let mut zero = 0;
        let mut one = 0;

        for &a_i in a.iter() {
            if ((a_i >> i) & 1) == 1 {
                one += 1;
            } else {
                zero += 1;
            }
        }

        if zero > one {
            x += 1 << i;
        }
    }

    let mut ans = 0;
    for &a_i in a.iter() {
        ans += a_i ^ x;
    }

    println!("{}", ans);
}

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


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
int b[26];

int main() {
	cin >> s;
	
	inc(i, s.size()) {
		b[s[i] - 'a']++;
	}
	
	inc(c, 26) {
		if(b[c] == 0) {
			char cc = 'a' + c;
			cout << cc << endl;
			return 0;
		}
	}
	
	cout << "None" << endl;
	
	return 0;
}


Measured memory_bytes: 512
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X = ir()
answer = 0
num = 100
while num < X:
    answer += 1
    num *= 1.01
    num = int(num)

print(answer)


Measured memory_bytes: 9168
#include<stdio.h>
int main(void){
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}

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

#define MAXN 100005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int N, M;
vector<int> g[MAXN];
vector<int> l[MAXN];
vector<int> r[MAXN];
vector<int> ch[MAXN];
int par[MAXN];
int dp[MAXN];
int dp2[MAXN];

int dfs(int u, int p) {
    par[u] = p;
    for (int v: g[u]) {
        if (v == p) continue;
        ch[u].push_back(v);
        dfs(v, u);
    }
    l[u].push_back(1);
    for (int i = 0; i < ch[u].size(); i++) {
        l[u].push_back(l[u].back() * ((dp[ch[u][i]] + 1) % M) % M);
    }
    r[u].push_back(1);
    for (int i = ch[u].size()-1; i >= 0; i--) {
        r[u].push_back(r[u].back() * ((dp[ch[u][i]] + 1) % M) % M);
    }
    dp[u] = l[u].back();
    return dp[u];
}

void dfs2(int u) {
    for (int i = 0; i < ch[u].size(); i++) {
        int v = ch[u][i];
        dp2[v] = (dp2[u]+1) % M * l[u][i] % M * r[u][ch[u].size()-i-1] % M;
        dfs2(v);
    }
}

signed main() {
    fastio;
    cin >> N >> M;
    for (int i = 1; i <= N-1; i++) {
        int u, v;
        cin >> u >> v ;
        g[u].push_back(v), g[v].push_back(u);
    }
    dp2[1] = 0 % M;
    dfs(1, 0);
    dfs2(1);
    for (int i = 1; i <= N; i++) {
        //cout << dp[i] << " " << dp2[i] << endl;
        cout << (dp2[i]+1) % M * dp[i] % M << endl;
    }
    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

vector<int> hsplit(int hstate, int h) {
  vector<int> a;
  a.push_back(0);

  rep(i, h) {
    if ((hstate >> i) & 1 == 1) {
      a.push_back(i + 1);
    }
  }
  a.push_back(h);

  return a;
}

bool wsplit(int wi, const vector<int>& hs, const vector<int>& ws, const vector<string>& s, int k) {
  int left = ws[ws.size() - 1];
  int right = wi;

  bool f = true;
  rep(i, hs.size() - 1) {
    int top = hs[i];
    int bottom = hs[i+1];

    int cnt = 0;
    for(int y = top; y < bottom; y++) {
      for(int x = left; x < right; x++) {
        if (s[y][x] == '1') {
          cnt += 1;
        }
      }
    }

    if (cnt > k) {
      f = false;
      break;
    }
  }

  return f;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 1<<30;

  rep(hstate, 1<<(h-1)) {
    vector<int> hs = hsplit(hstate, h);
    vector<int> ws;
    ws.push_back(0);

    bool f = true;
    for(int wi = 1; wi <= w; wi++) {
      bool ok = wsplit(wi, hs, ws, s, k);
      if (ok == false) {
        if (wi == 1) {
          f = false;
          break;
        }

        ws.push_back(wi - 1);
        ok = wsplit(wi, hs, ws, s, k);
        if (ok == false) {
          f = false;
          break;
        }
      }
    }
    if (f) {
      int t = hs.size() - 2 + ws.size() - 1;
      ans = min(ans, t);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int k = read.to!int;
	int x = read.to!int;
	
	int[] ans;
	foreach(i; x - k + 1 .. x + k) ans ~= i;
	
	ans.map!(to!string).join(" ").writeln;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%lld\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 2010
#define inf (1ll<<60)
#include<set>
set<ll>s1,s2;
int main(){
	int n,m,q;
	in(n);in(m);in(q);
	s1.insert(-inf);s1.insert(inf); 
	FOR(i,1,n)s1.insert(read()); 
	s2.insert(-inf);s2.insert(inf);
	FOR(i,1,m)s2.insert(read());
	while(q--){
		ll x=read();
		ll l1=*--s1.lower_bound(x),l2=*s1.lower_bound(x);
		ll r1=*--s2.lower_bound(x),r2=*s2.lower_bound(x);
		out(min(min(min(max(x-r1,x-l1),max(r2-x,l2-x)),x-l1+r2-x+min(x-l1,r2-x)),l2-x+x-r1+min(l2-x,x-r1)));
	}
}

Measured memory_bytes: 10752
/*

https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_f

人Xが優勝する可能性があるかをO(N)で求めればいい
人0を優勝させるためには、まず0が勝てない人を全員排除する必要がある
→stackとかで解けないかな…？

勝ち方向をグラフで表したとき、そこからすべて到達可能ならば優勝可能…？
→違いそうだし計算量的に不可能

右端から、この区間で勝つ可能性がある人のリストを構築していく
ある人が勝つ可能性がある条件は、それより右にいる優勝者候補の中に勝てる人がいること？
十分条件ではあるけど…
→逆に優勝者候補全てに勝てないとする
→優勝者候補以外ですべての優勝者を倒せる

今までの優勝者候補が優勝者であり続ける or 新たなる優勝者候補が生まれる条件は？
新規追加の人に誰も勝てなければ全員優勝者候補ではなくなる

優勝者候補の人は、直接勝てれば候補のまま
直接勝てない場合・・・面倒くさい
優勝候補じゃない場合、
→この考え方は無理がありそう

=====解説を見た=====
bitsetかぁ…
つまりO(N^3)解を見つければいい

さっき考えてたのがO(N^3)か
dpL[j][i] = i…jを考えたとき、iが優勝する可能性がある
dpR[i][j] = i…jを考えたとき、jが優勝する可能性がある

答えは ΣdpL[N-1][i]&dpR[0][i]
dpL[j][i] = Σ(or)A[i][x] & dpR[i+1][x] & dpL[j][x]
dpR[i][j] = Σ(or)A[j][x] & dpR[i][x] & dpL[j-1][x]

かぶらないためには、j-iが小さいほうから計算していく

*/

#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <bitset>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = int;
const ll mod = 998244353;


int main(){

    int N;
    int tmp;
    char tmpc = '\n';
    bitset<2000> tmpset;

    scanf ("%d",&N);
    vector<bitset<2000>> A(N);
    rep(i,2,N+1){
        rep(j,1,i){
            while (tmpc == '\n'){
                scanf ("%c",&tmpc);
            }
            tmp = tmpc-'0';
            tmpc = '\n';

            A[i-1][j-1] = (bool)tmp;
            A[j-1][i-1] = (bool)(tmp^1);
        }
    }

    //cout << A[0] << endl;
    vector<bitset<2000>> dpL(N);
    vector<bitset<2000>> dpR(N);

    rep(j_i,0,N){
        rep(i,0,N-j_i){
            int j = i+j_i;

            if (i == j){
                dpL[j][i] = true;
                dpR[i][j] = true;
            }else{
                tmpset = A[i] & dpR[i+1] & dpL[j];
                bool lans = tmpset.any();
                tmpset = A[j] & dpR[i] & dpL[j-1];
                bool rans = tmpset.any();
                dpL[j][i] = lans;
                dpR[i][j] = rans;
            }
        }
    }

    tmpset = dpL[N-1]&dpR[0];
    cout << tmpset.count() << endl;

}

Measured memory_bytes: 4816
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a: Vec<i64> = (0..n).map(|_| input()).collect();
    a.sort();
    a.reverse();

    let mut sa = 0;
    let mut sb = 0;
    for i in 0..n {
        if i % 2 == 0 {
            sa += a[i];
        } else {
            sb += a[i];
        }
    }
    println!("{}", sa - sb);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char ch[107];
int ans=107;
int main()
{
	scanf("%s",ch);
	ans=strlen(ch)-1;
	int l=strlen(ch);
	for (int i=1;i<=26;i++)
	{
		int last=-1,now=0;
		for (int r=0;r<l;r++)
			if (ch[r]=='a'+i-1)
			{
				now=max(r-last-1,now);
				last=r;
			}
		now=max(l-last-1,now);
		ans=min(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
const int qsz=1e5;int qLen,qHead,Q[100000];
static inline void PUSH(int n){Q[(qHead+qLen)%qsz]=n;qLen++;}
static inline int POP(void){int q=Q[qHead];qLen--;qHead=(qHead+1)%qsz;return q;}
int H,W,grid[1000][1000];
const int dx[24]={0,1,0,-1,0,0,1,1,1,1,-1,-1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2};
const int dy[24]={1,0,-1,0,2,-2,1,2,-1,-2,1,2,-1,-2,0,1,2,-1,-2,0,1,2,-1,-2};
static inline int f(int x,int y){return W*x+y;}
static inline void DFS(int x,int y)
{
  if(x>=0&&x<H&&y>=0&&y<W&&!grid[x][y])
  {
    grid[x][y]=1;PUSH(f(x,y));rep(i,4){DFS(x+dx[i],y+dy[i]);}
  }
}
int main(void)
{
  int C[2],D[2],step=0;H=IN(),W=IN(),C[0]=IN()-1,C[1]=IN()-1,D[0]=IN()-1,D[1]=IN()-1;
  rep(i,H){char str[1001];if(!scanf("%s",str)){return -1;}rep(j,W){grid[i][j]=(str[j]=='#');}}
  PUSH(f(C[0],C[1]));
  while(qLen)
  {
    int size=qLen;
    while(size--){int x=POP();DFS(x/W,x%W);}
    size=qLen;
    while(size--)
    {
      int z=POP(),x=z/W,y=z%W;
      if(x==D[0]&&y==D[1]){return OUT(step),0;}
      rep(i,20)
      {
        int nx=x+dx[4+i],ny=y+dy[4+i];
        if(nx>=0&&nx<H&&ny>=0&&ny<W&&!grid[nx][ny]){PUSH(f(nx,ny));}
      }
    }
    step++;
  }
  return puts("-1"),0;
}

Measured memory_bytes: 5888
#include <iostream>

int solve(int n, int k) {
  int ans = 1;
  while (n >= k) {
    ++ans;
    n /= k;
  }
  return ans;
}

int main() {
  int n, k;
  std::cin >> n >> k;
  std::cout << solve(n, k) << std::endl;
  return 0;
}


Measured memory_bytes: 256
for r in range(input()):
	if r > 0: print
	A  = [raw_input().split() for i in range(9)]
	RA = [[A[h][w] for h in range(9)] for w in range(9)] 
	A9 = [[A[h][w:w+3]+A[h+1][w:w+3]+A[h+2][w:w+3] for w in range(0,9,3)] for h in range(0,9,3)]
	P = [[" "]*9 for i in range(9)]
	for h in range(9):
		for w in range(9):
			if P[h][w] != "*":
				if A[h].count(A[h][w]) > 1:
					P[h][w] = "*"
				elif RA[w].count(A[h][w]) > 1:
					P[h][w] = "*"
				elif A9[h/3][w/3].count(A[h][w]) > 1:
					P[h][w] = "*"
	for h in range(9):
		print "".join([P[h][w]+A[h][w] for w in range(9)])

Measured memory_bytes: 4296
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
vector<int> x(10), y(10);
double dist(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return sqrt(dx * dx + dy * dy);
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    s[i] = i;
  }
  double sum = 0;
  int cnt = 0;
  do {
    for (int i = 0; i < n - 1; i++) {
      sum += dist(s[i], s[i + 1]);
    }
    cnt++;
  } while (next_permutation(s.begin(), s.end()));
  double ans = sum / cnt;
  printf("%0.6f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
#define inf 0x3f3f3f3f
#define ll long long
int a[N];
int main() 
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=0;
	int i=1;
	map<int,int> mp;
	int flag=0;
	while(1)
	{
		i=a[i];
		ans++;
		if(i==2)
			break;
		if(mp[i])
		{
			flag=1;
			break;
		}
		mp[i]=1;
	}
	if(flag)
		cout<<-1<<endl;
	else 
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5376
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    for i in 0..s.len() {
        print!("{}", s[i]);
    }
    if s[s.len() - 1] == 's' {
        println!("es");
    } else {
        println!("s");
    }
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }


int n;
vector<int> g[100005];
int dfs(int pos) {
    if (g[pos].empty()) return 1;
    vector<int> childDepth(g[pos].size());
    rep(i, g[pos].size()) childDepth[i] = dfs(g[pos][i]);
    all(sort, childDepth, greater<>());
    rep(i, g[pos].size()) childDepth[i] += i + 1;
    return *all(max_element, childDepth);
}

void solve() {
    cin >> n;

    reps(i, n - 1) {
        int a; cin >> a;
        g[a - 1].push_back(i);
    }

    cout << dfs(0) - 1 << endn;
}

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



Measured memory_bytes: 16640
#include <stdio.h>

int main(int argc, char* argv[]){
    int a, b;
    scanf("%d %d", &a, &b);
    if(!(a%3) || !(b%3) || !((a+b)%3)){
        printf("Possible");
    }else{
        printf("Impossible");
    }
    return 0;
}

Measured memory_bytes: 128
def resolve():
    n = int(input())
    ds = map(int, input().split())

    sorted_ds = sorted(ds)
    mid_diff = sorted_ds[n // 2] - sorted_ds[n // 2 - 1]
    if mid_diff == 0:
        print(0)
    else:
        print(mid_diff)

resolve()

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int s,w;
  cin >> s >> w;
  cout << (w>=s ? "unsafe" : "safe") << endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

string s;

vector<char> c;

int main() {
    cin >> s; int n = s.size();

    c.PB(s[0]); int m = 0;

    for (int i = 1; i < n; i++) {
        while (c.size() >= 2 && c[c.size()-2] != s[i]) {
            m = 1 - m;
            c.pop_back();
        }

        c.PB(s[i]);
    }

    if (m == 0) {
        printf("Second\n");
    }
    else {
        printf("First\n");
    }

    return 0;
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    data = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    print(data[int(input())-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060