akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  struct Edge {
    int to, c;
  };
  int n; cin >> n;
  vector<vector<Edge>> G(n);
  REP (i, n - 1) {
    int s, t, w; cin >> s >> t >> w;
    G[s].push_back({t, w});
    G[t].push_back({s, w});
  }
  int ans = 0;
  function<int(int, int)> dfs = [&](int v, int p) {
    int ma = 0;
    for (Edge e: G[v]) if (e.to != p) {
      int tmp = dfs(e.to, v) + e.c;
      ans = max(ans, ma + tmp);
      ma = max(ma, tmp);
    }
    return ma;
  };
  dfs(0, -1);
  cout << ans << endl;
}



Measured memory_bytes: 19108
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    map<ll,pair<ll,ll>> m;

    forn(i,3){
        forn(j,3){
            ll a;
            cin>>a;
            m.insert(mp(a,mp(i,j)));
        }
    }
    ll n,f=0;
    cin>>n;
    ll b[n];
    ll a[3][3];
    forn(i,3)
    forn(j,3) a[i][j]=0;

    forn(i,n){
        cin>>b[i];
        auto it=m.find(b[i]);
        if(it==m.end()) continue;
        a[it->se.fi][it->se.se]=1;
    }
    forn(i,3){
        if((a[i][0]==1)&&(a[i][1]==1)&&(a[i][2]==1)) f=1;
        if((a[0][i]==1)&&(a[1][i]==1)&&(a[2][i]==1)) f=1;
    }
    if((a[0][0]==1)&&(a[1][1]==1)&&(a[2][2]==1)) f=1;
    if((a[2][0]==1)&&(a[1][1]==1)&&(a[0][2]==1)) f=1;
    if(f==1) cout<<"Yes";
    else cout<<"No";
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;

  CIN(N);

  int A[N], B[N], C[N];
  for (int i = 0; i < N; i++) {
    CIN(A[i]);
  }
  for (int i = 0; i < N; i++) {
    CIN(B[i]);
  }
  for (int i = 0; i < N - 1; i++) {
    CIN(C[i]);
  }
  C[N - 1] = 0;

  int count = 0;
  int last = 0;
  for (int i = 0; i < N; i++) {
    count += B[A[i] - 1];

    if (0 < i) {
      if (last + 1 == A[i]) {
        count += C[last - 1];
      }
    }

    last = A[i];
  }

  COUT(count);

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
a = [0 for _ in range (5)]
for i in range (N):
    if S[i][0] == "M":
        a[0] += 1
    elif S[i][0] == "A":
        a[1] += 1
    elif S[i][0] == "R":
        a[2] += 1
    elif S[i][0] == "C":
        a[3] += 1
    elif S[i][0] == "H":
        a[4] += 1
print (a[0]*a[1]*a[2]+a[1]*a[2]*a[3]+a[2]*a[3]*a[4]+a[0]*a[1]*a[3]+a[0]*a[1]*a[4]+a[0]*a[2]*a[3]+a[0]*a[2]*a[4]+a[1]*a[2]*a[4]+a[1]*a[3]*a[4]+a[0]*a[3]*a[4])

Measured memory_bytes: 9776
while True:
    a, op, b = input().split()
    a, b = int(a),int(b)
    
    if op == "+":
        print("%d"%(a + b))
    elif op == "/":
        print("%d"%(a / b))
    elif op == "*":
        print("%d"%(a * b))
    elif op == "-":
        print("%d"%(a - b))
    elif op == "?":
        break


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    set<int> st{A, B, C};
    if (st.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int x[3000]={0},y[3000]={0};
    int i_in=0,i_out=0;

    //input data set
    while(1){
        scanf("%d %d", &x[i_in], &y[i_in]);

        if(x[i_in]==0 && y[i_in]==0){
            break;
        }
        else{
            i_in++;
        }

    }

    //output swapped data set
    for(i_out=0; i_out<i_in; i_out++){
        if(x[i_out] < y[i_out]){
            printf("%d %d\n", x[i_out], y[i_out]);
        }
        else{
            printf("%d %d\n", y[i_out], x[i_out]);
        }
    }

    return 0;
}

Measured memory_bytes: 632
#include<stdio.h>
#include<stack>
#include<queue>
using namespace std;
int main()
{
	deque<long long> q;
    int n;
    scanf("%d",&n);
 
    for(int i=1;i<=n;i++)
    {
        long long a;
        scanf("%lld",&a);
        if(i%2==0)
            q.push_front(a);
        else
            q.push_back(a);
    }
    if(n%2==0)
    {
        printf("%lld",q.front());
        q.pop_front();
        while(!q.empty())
        {
            printf(" %lld",q.front());
            q.pop_front();
        }
        printf("\n");
    }
    else
    {
        printf("%lld",q.back());
        q.pop_back();
        while(!q.empty())
        {
            printf(" %lld",q.back());
            q.pop_back();
        }
        printf("\n");
    }
    return 0;
} 

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int d[100] ={};
    for(int i=0; i<N; i++)
    {
       int a;
       cin >> a;
       d[a-1] = max(d[a-1], 1);
    }
    int sum = 0;
    for(int i=0; i<100; i++)
    {
    	sum += d[i];
    }
    cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
function puzzle(){
   var obj={};
   obj["123456780"]=0;
   var dy=[-1,0,0,1];
   var dx=[0,-1,1,0];
   var V=[1,2,3,4,5,6,7,8,0];
   var P=[[V,0]];
   while(P.length>0){
      var A=P.shift();
      var arr=A[0];
      var cnt=A[1];
      var index=arr.indexOf(0);
      var y=Math.floor(index/3);
      var x=index%3;
      var yx=[arr.slice(0,3),arr.slice(3,6),arr.slice(6,9)];
      for(var i=0;i<4;i++){
         var yy=y+dy[i];
         var xx=x+dx[i];
         if(yy<0 || xx<0 || yy>=3 || xx>=3)continue;
         yx[y][x]=yx[yy][xx];
         var card=yx[yy][xx];
         yx[yy][xx]=0;
         var YX=yx[0].concat(yx[1],yx[2]);
         var str=YX.join("");
         if(obj.hasOwnProperty(str)==false){
               obj[str]=cnt+1;
               P.push([YX,cnt+1]);
         }
         yx[yy][xx]=card;
         yx[y][x]=0;
      }
   }
   return obj;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var str=(input.trim()).replace(/\n|\s/g,"");
var PUZZLE=puzzle();
console.log(PUZZLE[str]);

Measured memory_bytes: 74596
<?php

$base = [
    'A',
    'T',
    'C',
    'G',
];

// 入力
fscanf(STDIN, "%s", $input);

$result = 0;
$max = 0;

foreach (str_split($input) as $c) {
    if (in_array($c, $base)) {
        $max++;
        if ($max > $result) {
            $result = $max;
        }
    } else {
        $max = 0;
    }
}

# 出力
echo $result . "\n";


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vp vector<pii>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define INF 1e9
#define LLINF 1e18
#define PI (acos(-1))
#define MOD 1e9+7

int main(){
	int n;
	cin >> n;
	vi v(n);
	rep(i, n){
		cin >> v.at(i);
	}
	sort(all(v));
	
	double ans = (double)(v.at(0) + v.at(1)) / 2;
	FOR(i, 1, n - 1){
		ans = (ans + v.at(i + 1)) / 2;
	}
	cout << ans << endl;
	
	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll h; std::cin >> h;
  ll tmp = h, cnt = 0;
  while (tmp != 1) tmp /= 2, cnt++;
  ll ans = 1, node = 1;
  rep(i, cnt) node *= 2, ans += node;
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int n ,x=0 ,hoge[1000000]={} ,ans=0;
  while( cin >> n ){
    for( int i=2 ; i<=sqrt(n) ; i++ ){
      for( int j=i*2 ; j<=n ; j+=i ){
	hoge[j] = 1;
      }
    }
    
    for( int i=2 ; i<=n ; i++ ){
      if( hoge[i] == 0 ) ans++;
    }
    cout << ans << endl;
    ans = 0;
  }
}
  

Measured memory_bytes: 5072
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

//const int MAX = 1000007;

LL n, a, b;
LL x[250000];
LL dp[250000][2];
set< pair<LL, int> > f;
const int X = 2*131072;

struct Tree
{
    LL e[2*X];
    
    void init()
    {
        e[X] = 0;
        FOR (i,1,n) e[X+i] = x[i]-x[i-1];
        FOR (i,n,X) e[X+i] = 0;
        RFOR (i,X,0) e[i] = min(e[2*i],e[2*i+1]);
    }
    
    LL mx(int l, int r)
    {
        l += X; r+= X;
        LL W = 2e18;
        while (l <= r)
        {
            if (l%2 == 1)
            {
                W = min(W,e[l]);
                l++;
            }
            if (r%2 == 0)
            {
                W = min(W,e[r]);
                r--;
            }
            l/=2; r/=2;
        }
        return W;
    }
} T;

bool ok(int l, int r, LL dist)
{
    if (l == r) return true;
    
    //FOR (i,l+1,r+1) if (x[i]-x[i-1] < dist) return false;
    //return true;
    if (T.mx(l+1,r) >= dist) return true;
    return false;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    //freopen("/Users/Taras/Downloads/big_top.txt", "r", stdin);
    //freopen("/Users/Taras/Downloads/mout.txt", "w", stdout);
    
    cin >> n >> a >> b;
    //n = 100000; a = b = 100000;
    if (n > 100000) throw -1;
    FOR (i,0,n)
    {
        cin >> x[i];
        //if (!i) x[0] = 0;
        //else x[i] = x[i-1] + 50001;
        f.insert(MP(x[i],i));
    }
    T.init();
    dp[0][0] = dp[0][1] = 1;
    FOR (i,1,n)
    {
        // set 0;
        set< pair<LL, int> > :: iterator to = f.upper_bound(MP(x[i]-a,INF));
        if (to->second == i)
        {
            dp[i][0] = (dp[i-1][0]+dp[i-1][1])%MOD;
        }
        else
        {
            if (ok(to->second,i-1,b))
                dp[i][0] = dp[to->second][1];
        }
        // set 1;
        to = f.upper_bound(MP(x[i]-b,INF));
        if (to->second == i)
        {
            dp[i][1] = (dp[i-1][0]+dp[i-1][1])%MOD;
        }
        else
        {
            if (ok(to->second,i-1,a))
                dp[i][1] = dp[to->second][0];
        }
        if (dp[i][0] < 0 || dp[i][1] < 0) throw -1;
    }
    cout << (dp[n-1][0]+dp[n-1][1])%MOD << endl;
}

Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const LL LINF = 1LL << 60;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ LL to, cost; edge(int t, LL c) :to(t), cost(c){} };

int dxk[] = { 1, 1, 1, 0, -1, 0 };
int dxg[] = { 0, 1, 0, -1, -1, -1 };
int dy[] = { -1, 0, 1, 1, 0, -1 };

int main()
{
	int w, h;
	while (cin >> w >> h && w)
	{
		vector<vector<int>> stage(h + 2, vector<int>(w + 2));
		rep(i, h)rep(j, w) cin >> stage[i + 1][j + 1];

		vector<vector<bool>> used(h + 2, vector<bool>(w + 2));
		queue<P> que;
		que.emplace(0, 0);
		used[0][0] = true;
		int ans = 0;
		while (!que.empty())
		{
			P p = que.front(); que.pop();
			int y = p.first, x = p.second;

			rep(i, 6)
			{
				int nx, ny;
				if (y % 2 == 0) nx = x + dxg[i];
				else nx = x + dxk[i];
				ny = y + dy[i];

				if (ny < 0 || nx < 0 || nx >= w + 2 || ny >= h + 2) continue;
				if (used[ny][nx]) continue;
				if (stage[ny][nx] == 1)
				{
					ans++;
				}
				else
				{
					used[ny][nx] = true;
					que.emplace(ny, nx);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
import java.util.Scanner;
 
public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		for(int i=0;i<n+1;i++){
			int count =0;
			int cj = i;
			for(int j=1;j<=i;j *= 6){
				count += cj%6;
				cj = cj/6;
			}
			int ck = n-i;
			for(int k=1;k+i<=n;k *= 9){
				count += ck%9;
				ck = ck/9;
			}

			min = Math.min(min,count);

		}

		System.out.println(min);
	}
 
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >>N;
  int a=0;;
  int saishou=INT_MAX;
  int saidai=-1*INT_MAX;
  long long sum=0;
  for(int i=0;i<N;i++){
    cin>>a;
    saishou=min(saishou,a);
    saidai=max(saidai,a);
    sum+=a;
  }
  cout <<saishou<<" "<<saidai<<" "<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#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;

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

    vl c(n);
    rep(i, n) {
        cin >> c[i];
    }
    sort(rall(c));

    ll ans = 0;
    rep(i, n) {
        ans += c[i]*(i+2);
        ans %= mod;
    }

    rep(i, n-1) {
        ans *= 4;
        ans %= mod;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1792
package main

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


func main() {
     stdin := bufio.NewScanner(os.Stdin)     

     var inputs []string
     for stdin.Scan() {
         inputs = append(inputs, stdin.Text())
     }
     num := inputs[0]
     intNum, _ := strconv.Atoi(num)
     textArr := inputs[1]
     var arrA []string
     for _ , a := range textArr {
         total := int(a) + intNum
         var tmpInt int
         switch {
         case total > 90:
              diff := total - 90
              if diff > 26 {
                 surplus := diff % 26
                 tmpInt = 64 + surplus
              } else {
                 tmpInt = 64 + diff
              }
         default:
              tmpInt = total
         }
         arrA = append(arrA, string(tmpInt))
     }
     output := strings.Join(arrA, "")
     fmt.Println(output)
}

Measured memory_bytes: 1536
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

int main(void) {
    string a, b, c, ans = "";

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    ans += toupper(a[0]);
    ans += toupper(b[0]);
    ans += toupper(c[0]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

a_even, a_odd = a.partition.with_index { |_, idx| idx.even? }
x = [a_even.sum - a_odd.sum]

(n - 1).times do |i|
  x << 2 * a[i] - x[i]
end

puts x.join(' ')

Measured memory_bytes: 24280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int im[100010]={};
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    im[a]++;
    im[b+1]--;
  }
  int ans=0;
  for(int i=0;i<n+2;i++){
    im[i+1]+=im[i];
    if(im[i]+1>=i)ans=max(ans,i-1);
  }
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pr pair<long long,long long>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fow(i,a,b,c) for(long long i=a;i<=b;i+=c)
#define bck(i,a,b,c) for(long long i=a;i>=b;i-=c)
#define F first
#define S second
#define loop int tests;cin>>tests;while(tests--)
#define full(x) (x).begin(),(x).end()
#define ubd(x,y) (upper_bound(full(x),y)-x.begin())
#define N (200006)
#define inf ((long long)1e18)

vector<pr> shop;
vector<long long> zero;
long long n,t;
long long dp[N][31],tmp[31];

int main()
{
	fastio;
	cin>>n>>t;
	shop.resize(n);
	fow(i,0,n-1,1)
		cin>>shop[i].F>>shop[i].S;
	sort(full(shop),[](pr x,pr y){return x.F*(y.S+1)>y.F*(x.S+1);});
	while(shop.size()!=0&&shop.back().F==0)
	{
		zero.eb(shop.back().S);
		shop.pop_back();
	}
	sort(full(zero));
	fow(i,1,(long long)(zero.size())-1,1)
		zero[i]+=zero[i-1]+1;
	fow(i,1,30,1)
		tmp[i]=inf;
	fow(i,0,(long long)(shop.size())-1,1)
	{
		bck(j,30,1,1)
		{
			if(tmp[j-1]<=t)
				dp[i][j]=tmp[j-1]+1+shop[i].F*(tmp[j-1]+1)+shop[i].S;
			else dp[i][j]=inf;
			tmp[j]=min(tmp[j],dp[i][j]);
		}
	}
	long long output=0;
	fow(i,0,30,1)
		if(tmp[i]<=t)
		{
			output=max(output,i+ubd(zero,t-tmp[i]-1));
		}
	cout<<output<<"\n";
}



Measured memory_bytes: 51840
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
  int N,D,X;
  cin>>N;
  cin>>D>>X;

  vector<int> A(N);
  rep(i,N) cin>>A[i];

  rep(i,N) X+=(D-1)/A[i]+1;

  cout<<X<<endl;

}

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





int main()
{
	
	ll n,m;
	cin>>n>>m;
	ll s[m],c[m];
	for (int i = 1; i <= m; ++i)
	{
		cin>>s[i]>>c[i];
	}
	map <ll,ll> mp;
	for (int i = 1; i <= n; ++i)
	{
		mp[i]=-1;
	}
	
	for (int i = 1; i <= m; ++i)
	{
		if(c[i]==0 && s[i]==1 && n!=1)
		{
			cout<<-1;
			return 0;
		}
		if(mp[s[i]]!=c[i] && mp[s[i]]!=-1)
		{
			//cout<<c[i];
			cout<<-1;
			return 0;
		}
		mp[s[i]]=c[i];
	}
	for (int i = 1; i <= n; ++i)
	{
		if(i==1 && mp[i]==-1 && n!=1)
		{
			mp[i]=1;
		}
		else if(mp[i]==-1)
		{
			mp[i]=0;
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		cout<<mp[i];
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> mp;
  ll sum = 0;
  REP(i, n){
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }
  ll q;
  cin >> q;
  vector<ll> ans(q);
  REP(i, q){
    ll b, c;
    cin >> b >> c;
    ll m = mp[b];
    sum += (c-b)*m;
    mp[b] = 0;
    mp[c] += m;
    ans[i] = sum;
  }
  REP(i, q){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 10552
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

typedef std::pair<int, int> IntPair;

template <class _Ty> inline _Ty tp_abs(const _Ty& a)
{
	//	usage:  tp_abs<type name>(a);

	return ((a < 0) ? (a * -1) : a);

}

template <class _Ty> inline void tp_swap(_Ty & right, _Ty & left) 
{
	//	usage:  tp_swap<type name>(a, b);

	_Ty tmp = right;
	right = left;
	left = tmp;
}


//static void ABC120D_DecayedBridges();
static void ABC116C_GrandGarden();


#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC116C_GrandGarden();

	fflush(stdout);
	return 0;
}
#endif

static void ABC116C_GrandGarden()
{
	int N;

	scanf(" %d", &N);

	auto height = new int[N + 1];
	int maxHeight = 0;
	for (int i = 0; i < N; i++) {
		scanf(" %d", &height[i]);
		if (maxHeight < height[i]) {
			maxHeight = height[i];
		}
	}
	height[N] = 0;

	int ope = 0;
	bool operating = false;
	for(int ht = 0; ht < maxHeight; ht++) {
		operating = false;
		for (int i = 0; i < N; i++) {
			if (height[i] <= 0) {
				operating = false;
			}
			else if ((height[i] > 0) && (!operating)) {
				ope++;
				operating = true;
			}
			height[i]--;
		}
	}
	printf("%d\n", ope);

	delete[] height;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<n; i++)
 
 
int main() {
    int N;
    cin >> N;
 
    vector<int>moti(101,0);
    rep(i, N) {
        int d;
        cin >> d;
        moti[d] = 1;
    }
 
    int ans = 0;{
        repr(i, 1, 101) {
            ans += moti[i];
        }
 
    }
 
    cout << ans << endl;
 
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

int H, W;
bool is_safe(int x, int y){
    return (0 <= x && x < W)&&(0 <= y && y < H);
}

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

signed main(){
    cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    
    bool ans = true;
    
    rep(y,H)rep(x,W){
        if(field[y][x]!='#') continue;
        bool can = false;
        rep(i,4){
            if(!is_safe(x+dx[i], y+dy[i])) continue;
            if(field[y+dy[i]][x+dx[i]]=='#'){
                can = true;
                break;
            }
        }
        if(!can) ans = false;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
}


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

int main()
{
	
		int n,k,j,x;
		cin>>n>>k;

		int arr[n+1],dp[n+1];
		for(int i=1;i<n+1;i++)
			cin>>arr[i];

		dp[1]=0;
		dp[2]=abs(arr[2]-arr[1]);

		for(int i=3;i<n+1;i++)
		{
			j=1;
			dp[i]=INT_MAX;
			while(i-j>0&&j<=k)
			{	
				dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
					j++;
			}
		}
		cout<<dp[n]<<endl;
	return 0;
}

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

using namespace std;

const int maxi=1e6+6;
int n;
int a[maxi];

int main()
{
   cin>>n;

   int one=0;
   int two=0;

   for (int i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
       if (a[i]%4==0) two++; else
        if (a[i]%2==0) one++;
   }

   int x=(n-one);

   if (one==0)
   {
       if (n/2<=two) printf("Yes\n"); else printf("No\n");
       return 0;
   }

   if ((x+1)/2<=two) printf("Yes\n"); else printf("No\n");



   return 0;
}

//RINGISPIL SE PLACA


Measured memory_bytes: 640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define ALL(v) v.begin(), v.end()

int N, K;
double ans;

void resolve()
{
    cin >> N >> K;
    vector<int> p(N);
    RPT0(i, N) cin >> p[i];

    vector<int> q(N - K + 1);

    q[0] = 0;
    RPT(i, 0, K - 1) q[0] += p[i];

    RPT(i, 1, N - K) { q[i] = q[i - 1] - p[i - 1] + p[i + K - 1]; }

    sort(ALL(q), greater<int>());

    ans = ((double)q[0] + K) / 2;

    cout << fixed << setprecision(12);
    cout << ans << endl;
}

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


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E') {
      a[i + 1] = a[i] + 1;
    } else {
      a[i + 1] = a[i];
    }
  }

  int mi = n;
  for (int i = 0; i <= n; i++) {
    mi = min(mi, i - (a[i] - a[0]) + a[n] - a[i]);
  }
  cout << mi << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define For(i, l, r) for (int i = l; i <= r; ++ i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c;
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("e.in", "r", stdin);
	freopen("e.out", "w", stdout);
}

const int N = 1e5 + 10; char s[N];
int n;

int main() {
	//File();

	scanf("%s", s + 1), n = strlen(s + 1);
	if(s[n]=='1' || s[n-1]=='0' || s[1]=='0') return printf("-1\n"),0;
	
	int flag = 1;
	For(i, 1, n - 1) flag &= s[i] == s[n - i];
	
	if (!flag) return puts("-1"), 0;

	int lst=1,num=1,lstnum=1;
	For(i,2,n-1) if(s[i]=='1'){
		printf("%d %d\n",lstnum,num+1);
		++num;
		lstnum=num;
		For(j,1,i-lst-1){
			++num;
			printf("%d %d\n",lstnum,num);
		}
		lst=i;
	}
	if(num<n) printf("%d %d\n",lstnum,num+1);

	return 0;
}



Measured memory_bytes: 1536
import java.io.*;
import java.util.*;
import java.text.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        DecimalFormat df = new DecimalFormat("0.000000000");
        int n = in.nextInt();
        int a[] = new int[n];a[0]=0;
        for(int i=1;i<n;i++) a[in.nextInt()-1]++;
        for(int i:a) out.println(i);
        
        in.close();out.flush();out.close();
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 1000000000000000000;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  vector<intll> v(n) ;
  intll total = 0 ;
  
  rep(i,n){
    cin >> v.at(i) ;
    total += v.at(i) ;
  }
  
  intll ans = INF;
  intll now = 0 ;
  rep(i,n-1){
    now += v.at(i) ;
    intll x = abs((total - now) - now) ; 
    ans = min (ans,x);
  }
 
  
  cout << ans ;


}


Measured memory_bytes: 4776
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
    int n, tmp, maxv, minv;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (i == 0) minv = tmp;
        else {
            if (i == 1) maxv = tmp - minv;
            else maxv = max( maxv, tmp - minv );
            minv = min( minv, tmp );
        }
    }
    cout << maxv << endl;

    return 0; 
}


Measured memory_bytes: 3116
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
MAXN = 10**7+1
dp = [1] * (MAXN+1)
for i in range(2,MAXN+1):
    for j in range(i, MAXN+1,i):
        dp[j] += 1
n = I()
ans = 0
for i in range(1,n+1):
    ans += i * dp[i]
print(ans)


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

int main(){
    string S;
    cin>>S;
    string now; 
    long long ans=0;
    for(int s=0;s<(1<<S.size()-1);s++){
        now="";
        now+=S[0];
        for(int i=0;i<S.size()-1;i++){
            if(s&(1<<i)) now+="+";
            now+=S[i+1];
        }
        long long sum=0;
        int pos=0;
        while(now.find("+",pos)!=string::npos){
            int nextpos=now.find("+",pos);
            sum+=stoll(now.substr(pos,nextpos-pos));
            pos=nextpos+1;
        }
        sum+=stoll(now.substr(pos));
        ans+=sum;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 1; i < 4; i++) {
        if (s[i-1] == s[i]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    
    
    return 0;
}

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


int N, K;
VI X(210), Y(210);

double f(double x, double y) {//答えのカウント

	vector<double>dis(N);
	REP(i, N) {
		double a = X[i], b = Y[i];
		
		dis[i] = pow((a - x)*(a - x) + (b - y)*(b - y), 0.5);
	}

	rSORT(dis);
	double res = 0;
	REP(i, K)res += dis[i];
	return res;

}

double g(double x) {//fの最適化

	double L = -1000, R = 1000;
	REP(i, 100) {
		double m1 = (L * 2 + R) / 3;
		double m2 = (L + R * 2) / 3;

		if (f(x, m1) > f(x, m2))L = m1;
		else R = m2;
	}
	return f(x, L);
}


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


	cin >> N >> K;
	REP(i, N)cin >> X[i] >> Y[i];

	double L = -1000, R = 1000;
	REP(i, 100) {
		double m1 = (L * 2 + R) / 3;
		double m2 = (L + R * 2) / 3;

		if (g(m1) > g(m2))L = m1;
		else R = m2;
	}
	
	printf("%.9f\n", g(L));

	return 0;
}




Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] resultArray = line.split(" ");
		int a = Integer.parseInt(resultArray[0]);
		int b = Integer.parseInt(resultArray[1]);
		System.out.print(a * b +" ");
		System.out.println(a * 2 + b * 2);
	}

}

Measured memory_bytes: 25968
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
    int N,A,B;
    cin >> N;
    cin >> A >> B;
    int P[N];
    for(int i=0;i<N;i++) cin >> P[i];

    int ans[3] = {0,0,0};
    for(int i=0;i<N;i++){
        if(P[i] <= A) ans[0]++;
        else if(P[i] <= B) ans[1]++;
        else ans[2]++;
    }
    cout << min({ans[0],ans[1],ans[2]});
    return 0;
}

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


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000)

n = int(input())
e = [[] for _ in range(n)]
weights = {}
for i in range(n-1):
    s, t, w = map(int, input().split())
    e[s].append(t)
    e[t].append(s)
    weights[(s, t)] = w
    weights[(t, s)] = w


def dfs(v, d, visited):
    r = [d, v]
    visited[v] = True
    for tv in e[v]:
        if not visited[tv]:
            r = max([dfs(tv, d+weights[(v, tv)], visited), r])
    return r


def fartheast(v):
    visited = [False]*n
    return dfs(v, 0, visited)


def diameter(a, b, d, visited):
    visited[a] = True
    for tv in e[a]:
        if not visited[tv]:
            td = diameter(tv, b, d+weights[(a, tv)], visited)
            if td > 0:
                return td
    return d if a == b else 0


xd, x = fartheast(0)
yd, y = fartheast(x)
print(yd)



Measured memory_bytes: 170492
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, M;
  std::cin >> N >> M;
  std::vector<ll> S(N), T(M);
  vvl dp= vv(N+1, M+1, 0, ll), dpsum = vv(N+1, M+1, 0, ll);
  for(int i=0;i<N;i++) std::cin >> S[i];
  for(int i=0;i<M;i++) std::cin >> T[i];
  for(int i=1;i<N+1;i++){
    for(int j=1;j<M+1;j++){
      if(S[i-1]==T[j-1]){
        dp[i][j]=dpsum[i-1][j-1]+1;
      }else{
        dp[i][j]=0;
      }
      dpsum[i][j]=(((dpsum[i-1][j]+dpsum[i][j-1])%1000000007)+dp[i][j])%1000000007;
      dpsum[i][j]= (dpsum[i][j]- dpsum[i-1][j-1])%1000000007;
      if(dpsum[i][j]<0) dpsum[i][j]+= 1000000007;
    }
  }
  std::cout << dpsum[N][M]+1<< '\n';
  return 0;
}


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


def cal(n):
    c = ord("a")
    l = ""
    b = n
    while b > 26:
        a = (b-1) % 26
        b = (b-a)//26
        l = l+chr(c+a)
    l = l+chr(c+b-1)
    print(l[::-1])


cal(n)


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

long gcd(long a, long b) {
  if (a < b) return gcd(b,a);
  long r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  long A; cin>>A;
  long B; cin>>B;

  long J = gcd(A,B);

  long len = 0;
    for (long i = 2; i*i <= J; i++) {
      if (J % i == 0) {
        len++;
        J /= i;
        while (J % i == 0) {
          J /= i;
        }
      }
    }
    if (J > 1) len++;

  cout << len+1 << endl;

  return 0;
}


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

int main() {  
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<vector<int> > a(n, vector<int> (3));
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	vector<vector<int> > dp(n, vector<int> (3,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			if(i){
				for(int k=0;k<3;k++){
					if(k!=j){
						dp[i][j] = max(dp[i-1][k], dp[i][j]);
					}
				}
			}
			dp[i][j] += a[i][j];
		}
	}
	cout<<*max_element(dp[n-1].begin(),dp[n-1].end());
	return 0;  
}


Measured memory_bytes: 11264
import sys
readline = sys.stdin.readline

S = readline().rstrip()
gx,gy = map(int,readline().split())

C = []

import itertools
for key,g in itertools.groupby(S):
  C.append([key,len(list(g))])
  
x,y = 0,0
ind = 0
if C[0][0] == "F":
  x += C[0][1]
  ind = 1

# Xの方向を向いている
dirX = True
now_x = {x}
now_y = {y}
for i in range(ind,len(C)):
  if C[i][0] == "F":
    step = C[i][1]
    if dirX:
      nex_x = set()
      for n in now_x:
        nex_x.add(n + step)
        nex_x.add(n - step)
      now_x = nex_x
    else:
      nex_y = set()
      for n in now_y:
        nex_y.add(n + step)
        nex_y.add(n - step)
      now_y = nex_y
  else:
    if C[i][1] % 2 == 1:
      dirX ^= True
    
if gx in now_x and gy in now_y:
  print("Yes")
else:
  print("No")


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {
    int N;
    string S;
    cin >> N >> S;

    int W=0;

    vi white(N+1,0); //wの累積和

    //黒に出会うまでに白が多いか黒が多いか？
    REP(i,N){
        if(S[i]=='.')W++; //ここまでの白の数
        white[i+1]=W;
    }

    int ans=2*100000+1;

    REP(i,N+1){ //切り分け作業 //i以降が黒くなるとすると
        int change_black = white[N]-white[i]; 
        int change_white = i-white[i];
        ans = min(ans,change_black+change_white); //i番目まで白くすると
    }



    cout << ans << endl;
    
}



Measured memory_bytes: 1412
import java.util.*;
import javax.lang.model.util.ElementScanner6;

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

        // 入力
        String s = sc.next();

        int out = 0;
        int h = 0;
        int t = s.length() - 1;
        while (h < t) {
            if (s.charAt(h) != s.charAt(t)) {
                out += 1;
            }
            h += 1;
            t -= 1;
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 22996
## subroutines

def gcd(x, y)
  if x < y
    tmp = x; x = y; y = tmp
  end

  step = 0

  while true
    r = x % y
    x = y
    y = r
    step += 1
    break if y == 0
  end

  [x, step]
end

### main

while true
  m, n = gets.strip.split(' ').map{|s| s.to_i}
  break if m == 0 && n == 0

  g, step = gcd(m, n)

  puts [g, step].join(' ')
end

Measured memory_bytes: 6100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

bool is_2(int n) {
  int cnt = 1;
  for (int i = 1; i <= 10; i++) {
    if (cnt == n) return true;
    cnt *= 2;
  }
  return false;
}

int main() {
  int n, ans;
  cin >> n;
  for (int i = n; i > 0; i--) {
    if (is_2(i)) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;
#define int ll

const int N = 3e6;
const int M = 1e9 + 7;

int fp(int a, int p) {
	int x = 1;
	for (; p > 0; p >>= 1) {
		if (p & 1) {
			(x *= a) %= M;
		}
		(a *= a) %= M;
	}
	return x;
}

int fac[N], inv[N];

int cnk(int n, int k) {
	assert(0 <= k && k <= n && n < N);
	int up = fac[n], dn = inv[k] * inv[n - k] % M;
	return up * dn % M;
}
int f(int r, int c) {
	return cnk(r + c, r);
}

int solve(int r, int c) {
	int ans = 0, s = 1;
	for (int d = 0; d <= r + c; ++d) {
		// (0, d) ... (d, 0)
		//cerr << d << " " << s << endl;
		ans += s;
		(s *= 2) %= M;
		if (d >= r) {
			int i = r, j = d - r;
			(s += M - f(i, j)) %= M;
		}
		if (d >= c) {
			int i = d - c, j = c;
			(s += M - f(i, j)) %= M;
		}
	}
	return ans;
}

int r1, c1, r2, c2;

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);
	
	fac[0] = 1;
	for (int i = 1; i < N; ++i) {
		(fac[i] = fac[i - 1] * i) %= M;
	}
	inv[N - 1] = fp(fac[N - 1], M - 2);
	for (int i = N - 2; i >= 0; --i) {
		(inv[i] = inv[i + 1] * (i + 1)) %= M;
	}

	cin >> r1 >> c1 >> r2 >> c2;
	--r1;
	--c1;
	int res = solve(r2, c2) - solve(r2, c1) - solve(r1, c2) + solve(r1, c1);
	res %= M;
	res += M;
	res %= M;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 47104
while True:
  N, M, C = input(), [], 0
  if not N:
    break
  for i in range(N):
    M.append(input())
  for p in range(N)[::-1]:
    for i in range(p):
      if M[i] > M[i + 1]:
        M[i], M[i + 1] = M[i + 1], M[i]
        C += 1
  print(C)

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



int main() {
  int n,k;
  cin >>n >>k;
  int count=0;
  while(n>0){
    if(count==0){n-=k;count++;continue;}
    n-=k-1;
    count++;
  }
  cout << count << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int l = n % 10;
	string ans = "bon";
	if (l == 2 || l == 4 || l == 5 || l == 7 || l == 9) {
		ans = "hon";
	} else if (l == 0 || l == 1 || l == 6 || l == 8) {
		ans = "pon";
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    double T, X; cin >> T >> X;
    printf("%.10f", T / X);
    return 0;
}

Measured memory_bytes: 256