akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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 srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A+B << '\n';
  } else {
    cout << B-A << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

// DAME:
int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";
    // 1往復目
    ans += string(tx-sx, 'R');
    ans += string(ty-sy, 'U');

    ans += string(tx-sx, 'L');
    ans += string(ty-sy, 'D');

    // ２往復目
    ans += 'D';
    ans += string(tx-sx+1, 'R');
    ans += string(ty-sy+1, 'U');
    ans += 'L';

    ans += 'U';
    ans += string(tx-sx+1, 'L');
    ans += string(ty-sy+1, 'D');
    ans += 'R';

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

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

int main() {
  string s;
  cin >> s;
  rep(i,2){
    if(s.at(i) != s.at(i+1)){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def get_input() -> int:
    """
    標準入力を取得.

    Returns:\n
        int: 標準入力
    """
    a = int(input())

    return a


def main(a: int) -> None:
    """
    メイン処理.

    Args:\n
        a (int): 整数（1 <= a <= 10）
    """
    # 求解処理
    ans = a + a**2 + a**3

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    a = get_input()

    # メイン処理
    main(a)


Measured memory_bytes: 9028
using System;

class Prog
{
  static void Main()
  {
    var table = new string[]{ "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN" };
    var input = Console.ReadLine();
    
    for( int i=0 ; i<table.Length ; i++ )
    {
      if( table[ i ] == input )
      {
        Console.WriteLine( i + 1 );
      }
    }
  }
}

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

using namespace std;

#define int long long

signed main()
{	
  	int n, k; cin >> n >> k;
  	
  	n %= k;
  	
  	while(2*n > k)
      	n = abs(n-k);
  
  	cout << n << "\n";
	return 0;
}

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

int main()
{
    int P , Q , R;
    scanf("%d %d %d",&P,&Q,&R);
    int max=0;

    if (P>=Q && P>=R)printf("%d",Q+R);
    else if (Q>=P && Q>=R)printf("%d",P+R);
    else if (R>=P && R>=Q)printf("%d",P+Q);

    return 0;
}


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

int main() {
    
    ll a;
    cin >> a;
    ll sum = a + a * a + a * a * a;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,Q;string s;cin>>N>>Q>>s;
	char T[Q],D[Q];
	for(int i=0;i<Q;i++){
		cin>>T[i]>>D[i];
	}int a=0,b=N+1;int k;
	int c,d;
	while(a+1<b){
		k=(a+b)/2;
		for(int j=0;j<Q;j++){
			if(T[j]==s.at(k-1)){
				if(D[j]=='L'){
					k--;
				}else{
					k++;
				}if(k==0||k==N+1){
                    break;
                }
			}
		}if(k==0){
			a=(a+b)/2;
		}else{
			b=(a+b)/2;
		}
	}c=a;
	a=0;b=N+1;
	while(a+1<b){
		k=(a+b+1)/2;
		for(int j=0;j<Q;j++){
			if(T[j]==s.at(k-1)){
				if(D[j]=='L'){
					k--;
				}else{
					k++;
				}if(k==0||k==N+1){
                    break;
                }
			}
		}if(k==N+1){
			b=(a+b+1)/2;
		}else{
			a=(a+b+1)/2;
		}
	}d=b;
	cout<<d-c-1<<endl;
}

Measured memory_bytes: 1028
#include <stdio.h>
 
int main(void)
{
    int n, i;
     
    scanf("%d", &n);
    printf("%d:", n);
     
    i = 2;
    while (1){
        if (n == 1 || i * i > n){
            break;
        }
        else if (n % i == 0){
            printf(" %d", i);
            n /= i;
        }
        else if (i == 2){
            i++;
        }
        else {
            i += 2;
        }
    }
     
    if (n != 1){
        printf(" %d", n);
    }
     
    puts("");
     
    return (0);
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef map<ll, vector<ll>> mll;
typedef unordered_map<ll, vector<ll>> ull;

#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()
#define rep(i, a, b) for(ll i = a; i < b ; i++)
#define repr(i, a, b) for(ll i = a; i >= b ; --i)
#define distinct(v) v.erase(unique(v.begin(), v.end()), v.end());
#define delt(v, x) (v).erase(std::remove((v).begin(), (v).end(), x), (v).end())
#define MAX 200010
#define INF 1000000007
const ll MAXN = 1e5 + 5;

void dfs(int u, int par, vector<bool> &v, unordered_map<int, vector<int>> g) {
    if (!v[u]) {
        v[u] = true;
        for (auto i:g[u]) {
            if (!v[i] && i != par)dfs(i, u, v, g);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vll a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            sum += a[i] * a[j];
        }
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#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 <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const unsigned long long INF = 1LL << 60;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}


int main(){ 
int N,K; cin >> N >> K;
vector<long long> h(N);
rep(i,N) cin >> h[i];
vector<long long> dp(1000005);
rep(i,100005) dp[i] = INF;
dp[0] = 0;
for(int i = 0; i < N; i++){
	for(int j = 1; j <= K; j++)
	chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
}
	cout << dp[N-1] << endl;
}


Measured memory_bytes: 8832
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[21][21]; int n;
ll dp[22][1 << 21];
vector<int> v[22];
void init() {
	rep(i, (1 << n)) {
		int c = 0;
		rep(j, n)if (i&(1 << j))c++;
		v[c].push_back(i);
	}
}
int main() {
	cin >> n; init();
	rep(i, n) {
		rep(j, n)cin >> a[i][j];
	}
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, v[i].size()) {
			int x = v[i][j];
			//cout << i << " " << x << endl;
			rep(k, n) {
				if (x&(1 << k))continue;
				if (!a[i][k])continue;
				int nex = x ^ (1 << k);
				(dp[i + 1][nex] += dp[i][x]) %= mod;
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 318908
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);

        var s = input.ReadLine();

        return Regex.IsMatch(s, "[0-9]{" + a + "}-[0-9]{" + b + "}") ? Yes : No;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 15832
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>
#include <map>
#include <set>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int solve(){
    ll H,W,M;
    cin >> H >> W >> M;
    
    set <pair<ll,ll>> st;

    REP(i,M)
    {
        ll a,b;
        cin >> a >> b;
        st.insert({a,b});
    }

    map <ll,ll> mph,mpw;
    ll hmaxval = 0;
    ll wmaxval = 0;
    vector <ll> hmax,wmax;
    for(auto tmp: st)
    {
        //最も爆弾が設定されている行と列
        hmaxval = max(hmaxval,++mph[tmp.first]);
        wmaxval = max(wmaxval,++mpw[tmp.second]);
    }
    for(auto tmp:mph)
    {
        if(hmaxval == tmp.second)hmax.push_back(tmp.first);
    }
    for(auto tmp:mpw)
    {
        if(wmaxval == tmp.second)wmax.push_back(tmp.first);
    }


    ll res = hmaxval + wmaxval -1;
    for(auto h: hmax)
    {
        for(auto w: wmax)
        {
            if(st.find({h,w}) == st.end())
            {
                ++res;
                cout << res << endl;
                return 0;
            }
        }
    }

    cout << res << endl;
    return 0;
}

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


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

class Bit {
  public:
    ll n;
    vector<ll> bit;

    Bit(ll nn) {
      n = nn;
      vector<ll> b(n+1, 0);
      bit = b;
    }

    ll sum(ll i) {
      ll s= 0;
      while(i > 0) {
	s += bit[i];
	i -= i & -i;
      }
      return s;
    }

    void add(ll i, ll x) {
      while(i <= n) {
	bit[i] += x;
	i += i & -i;
      }
    }
};

ll d(ll n, vector<ll> a) {
  ll lb = -1, ub = n;
  vector<ll> b = vector<ll>(n, 0);

  for(ll i=0;i<n;i++) {
    b[i] = a[i];
  }
  sort(b.begin(), b.end(), greater<ll>());
  ll offset = n + 1;
  //cout << "NUM: " << (n+1)*n/4 << endl;
  while(ub - lb > 1) {
    vector<ll> s = vector<ll>(n, 0);
    ll mid = (lb + ub) / 2;

    Bit bit = Bit(n*2 + 10);
    s[0] = b[mid] <= a[0] ? 1 : -1;
    bit.add(offset + s[0], 1);
    ll num = (s[0] == 1 ? 1 : 0);

    for(ll i=1;i<n;i++) {
      s[i] = s[i-1] + (b[mid] <= a[i] ? 1 : -1);
      ll temp = num;
      num += bit.sum(offset + s[i]);

      bit.add(offset + s[i], 1);
      if(s[i]>=0)
	num++;
     // cout << "i: " << i << " -> " << num - temp << endl; 
    }
    //cout << "num: " << num << " b[mid]: " << b[mid] << " lb: " << lb << " mid: " << mid << " ub: " << ub;


    if(num >= (n+1)*n/4) {
      ub = mid;
      //cout << " answer is left side";
    } else {
      lb = mid;
      //cout << " answer is right side";
    }
    //cout <<endl;
  }
  //cout << b[ub ] << " lb: " << lb << " ub: " << ub << endl;
  return b[ub];
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n) ;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  cout << d(n, a);
}

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

int main() {
    int32_t a, b, c;
    int64_t k;
    cin >> a >> b >> c >> k;
    
    if (k % 2 == 0) {
        cout << a - b << endl;
    } else {
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e3+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

int a[MAX_N*MAX_N],mark[MAX_N][MAX_N];
main(){
    fast();per(0);
    //get_fact();
    int h,w,n; cin>>h>>w>>n ;
	for(int i=1;i<=n;i++)
		cin>>a[i] ;
	int c=1;
	for(int i=1;i<=h;i++){
		if(i%2==1){
			for(int j=1;j<=w;j++){
				mark[i][j]=c;
				a[c]--;
				if(a[c]==0)
					c++;
			}
		}
		else{
			for(int j=w;j>=1;j--){
				mark[i][j]=c;
				a[c]--;
				if(a[c]==0)
					c++;
			}
		}
	}

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)
			cout<<mark[i][j]<<" " ;
		cout<<endl ;
	}
}



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

int coin[]={500,100,50,10,5,1};

int main(){
    int n;
    while(cin>>n,n){
            
        n=1000-n;
        int ans=0;
    
        for(int i=0;i<6;i++){
            ans+=n/coin[i];
            n%=coin[i];
        }
        
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N][3];
int main(){
	int n;
	cin >> n;
	vector<vector<int>> arr(n, vector<int>(3));
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < 3; ++j)
			cin >> arr[i][j];
	for(int j = 0; j < 3; ++j)
		dp[n-1][j] = arr[n-1][j];
	for(int i = n-2; i >= 0; --i){
		for(int j = 0; j < 3; ++j)
			dp[i][j] = max(dp[i+1][(j+1)%3] + arr[i][j], dp[i+1][(j+2)%3] + arr[i][j]);
	}
	for(int j = 1; j < 3; ++j)
		dp[0][0] = max(dp[0][0], dp[0][j]);
	cout << dp[0][0];
	return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
main(){
string s,t;
int N,x;
for(cin>>N;N--;){cin>>t,s+=t;}
char buf[9];
const char *p=s.c_str();
for(x=0;;x++){
sprintf(buf,"%d",x);
if(!strstr(p,buf)){puts(buf);return 0;}
}}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int c,d,w,x;
  while(cin >>c>>d>>w>>x,c||d||w||x){
    int be[15][30],su[15][30];
    for(int i=0; i<c; i++)
      for(int j=0; j<d; j++)
	cin >>be[i][j];
    for(int i=0; i<c; i++)
      for(int j=0; j<d; j++)
	cin >>su[i][j];
    int dp[31][51][6] = {0};
    for(int i=0; i<d; i++){
      for(int j=0; j<=w; j++){
	for(int k=0; k<=x; k++){
	  dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
	  for(int l=0; l<c; l++){
	    if(be[l][i] != 0 &&(j == w || dp[i][j][k]!=0)){
	      if(j>=su[l][i]){
		dp[i+1][j-su[l][i]][k] = max(dp[i+1][j-su[l][i]][k],dp[i][j][k]+be[l][i]);
		if(k>0){
		  int life,ben;
		  life = j-su[l][i];
		  ben = be[l][i];
		  for(int ii=l-1; ii>=0; ii--){
		    life-=su[ii][i];
		    ben+=be[ii][i];
		    if(life<0 || be[ii][i] == 0) break;
		    dp[i+1][life][k-1] = max(dp[i+1][life][k-1],dp[i][j][k]+ben);
		  }
		  life = j-su[l][i];
		  ben = be[l][i];
		  for(int ii=l+1; ii<c; ii++){
		    life-=su[ii][i];
		    ben+=be[ii][i];
		    if(life<0 || be[ii][i] == 0) break;
		    dp[i+1][life][k-1] = max(dp[i+1][life][k-1],dp[i][j][k]+ben);
		  }
		}
	      }
	    }
	  }
	}
      }
    }
    int ans = 0;
    for(int i=0; i<=x; i++)
      for(int j=0; j<=w; j++)
	ans = max(ans,dp[d][j][i]);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
  while(1)
    {
  char buf[120][2];
  char str[128];
  buf['A']['0']='X';
  buf['A']['1']='Y';
  buf['X']['1']='Z';
  //buf['X']['0']='n';
  buf['Y']['0']='X';
  //buf['Y']['1']='n';
  buf['Z']['0']='W';
  buf['Z']['1']='B';
  buf['W']['0']='B';
  buf['W']['1']='Y';
  buf['B']['0']='Y';
  buf['B']['1']='X';
  scanf("%s",str);
  if(str[0]=='#')break;
  int ans=strlen(str);
  
  char now='A';
  for(int i=0;i<ans;i++)
    {
      
      now=buf[now][str[i]];
      //if(now=='n')break;

    }
  if(now=='B')printf("Yes\n");
  else printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
 
ll N, M;
vector<ll> v;
 
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
 
 
int main() {
    cin >> N >> M;
    for (ll i = 0; i < N; ++i) {
        ll a; cin >> a; v.push_back(a>>1);
        if (a&1LL) { cout << "0" << endl; return 0; }
    }
  	
  int cMax = 0, cMin = 100;
	for(long long int num : v){
      	num <<= 1;
		int cnt = 0;
		while(num % 2 == 0){
			num /= 2;
			cnt += 1;
		}
		cMax = max(cnt, cMax);
		cMin = min(cnt, cMin);
	}
	if(cMax != cMin){
		cout << 0 << endl;
		return 0;
	}
  
  
    ll lcm = v[0];
    for (int i = 1; i < N; ++i) {
        lcm = (lcm * v[i]) / gcd(lcm, v[i]);
        if (lcm > M) { cout << "0" << endl; return 0; }
    }
 
    ll ans = 0;
    for (ll i = lcm; i <= M; i += (lcm<<1)) ++ans;
 
    //cout << (M/lcm+1)/2 << endl;
  	cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	vector<int>pf(n+2);
	for(int i=0; i<m; i++){
		int a,b;
		cin>>a>>b;
		pf[a]++;
		pf[b+1]--;
	}
	for(int i=1; i<=n; i++){
		pf[i]+=pf[i-1];
	}
	int cnt=0;
	for(int i=1; i<=n; i++){
		if(pf[i]==m)
		 cnt++;
	}
	cout<<cnt;
	return 0;
	
}

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

void selectionSort(vector<int> &a,int n);

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
  }
  
  selectionSort(a,n);

}

void selectionSort(vector<int> &a,int n){
  int cou=0,minj;
  for(int i=0;i<n;i++){
    minj = i;
    for(int j=i;j<n;j++){
      if (a[j] < a[minj]){
        minj = j;
      }
    }
    if(a[i]!=a[minj]){
       swap(a[i],a[minj]);
       //cout<<i<<a[i]<<a[minj]<<endl;
       cou++;
      }
  }
  rep(i,n-1){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl;
  cout<<cou<<endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
#define FAST_IO {ios::sync_with_stdio(0);cin.tie(0);}
using namespace std;
signed main() {
  int H, W;
  while (cin >> H >> W, H+W != 0) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }  
}




Measured memory_bytes: 3100
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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



int main(){
    int H, W; std::cin >> H >> W;
    std::vector<int> cnt(26, 0);
    {
        std::string a;
        for(int i(0); i < H; ++i){
            std::cin >> a;
            for(int j(0); j < W; ++j){
                ++cnt[a[j]-'a'];
            }
        }
    }
    int cnt1(0), cnt2(0);
    for(int i(0); i < 26; ++i){
        if(cnt[i] % 2){
            ++cnt1; --cnt[i];
        }
        if(!(cnt[i] % 2) && (cnt[i] % 4)) ++cnt2;
    }
    int lim1((H % 2) & (W % 2)), lim2(0);
    if(H % 2) lim2 += W / 2;
    if(W % 2) lim2 += H / 2;
    if(cnt1 > lim1){
        std::cout << "No" << std::endl;
        return 0;
    }
    if(cnt2 > lim2){
        std::cout << "No" << std::endl;
        return 0;
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;
    int a[200000];
    int first,second;
    int tmp,i;
    
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++){
        scanf("%d",&a[i]);
    }
    
    if(a[0] >= a[1]){
        first = a[0];
        second = a[1];
        tmp = 0;
    }else{
        first = a[1];
        second = a[0];
        tmp = 1;
    }
    
    if(n >= 3){
        for(i = 2 ; i < n ; i++){
            if(a[i] >= first){
                tmp = i;
                second = first;
                first = a[i];
            }
            if(a[i] >= second && a[i] < first){
                second = a[i];
            }
        }
        for(i = 0 ; i < n ; i++){
            if(i == tmp) printf("%d\n",second);
            else printf("%d\n",first);
        }
    }else{
        printf("%d\n%d\n",a[1],a[0]);
    }
    
    return 0;
}


Measured memory_bytes: 2304
using namespace std;
#define SIZE 
char inp[1000003];
int solve(int num,int length){
  int io=-1,cnt=0;
  for(int i=0;i<length;i++){
    if ( io == -1){
      if ( inp[i]=='I')io=0;      
    }else {
      if ( i+1<length &&inp[i]=='O'&&inp[i+1]=='I' ){
	io++;
	i++;
	if ( io == num)cnt++,io--;
      }else if ( inp[i] == 'I')io=0;
      else if (inp[i] == 'O')io=-1;
    }    
  }

  return cnt;
}


main(){
  int n,m;
  while(cin>>n>>m && n){
    getchar();
    fgets(inp,m+1,stdin);
    cout << solve(n,m)<<endl;
  }
  return false;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

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

double solve(int N, int T, vector<int>& L, vector<int>& B){
    vector<int> label(N+1);
    for(auto i: L)label[i] = 1;
    for(auto i: B)label[i] = -1;
    vector<vector<double> > dp(T+1, vector<double>(N+1)); dp[0][0] = 1.0;
    rep(t, T)rep(i, N+1){
        if(i == N){
            dp[t+1][N] += dp[t][N];
            continue;
        }
        rep(j, 6){
            int k = i + j + 1;
            if(N < k)k = 2 * N - k;
            if(label[k] == 1){if(t + 2 <= T)dp[t+2][k] += dp[t][i] / 6.0;}
            else if(label[k] == -1)dp[t+1][0] += dp[t][i] / 6.0;
            else dp[t+1][k] += dp[t][i] / 6.0;
        }
    }
    return dp[T][N];
}

int main(){
    int N, T, L, B;
    while(cin >> N >> T >> L >> B, N|T|L|B){
        vector<int> Lose(L), Back(B);
        rep(i, L)cin >> Lose[i];
        rep(i, B)cin >> Back[i];
        cout << fixed << setprecision(6) << solve(N, T, Lose, Back) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1368
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>
 
using namespace std;
 
 
int main(){
 
    int coin[6] ={ 500,100,50,10,5,1 },sum,price;
 
    while(true){
        scanf("%d",&price);
        if(price == 0)break;
 
        sum = 0;
 
        price = 1000 - price;
 
        for(int i = 0; i <= 5; i++){
            while(price >= coin[i]){
                price -= coin[i];
                sum++;
            }
        }
 
        printf("%d\n",sum);
    }
 
    return 0;
}


Measured memory_bytes: 2660
#include <iostream>
#include <vector>
using namespace std;

void DFS(vector<vector<int>>& Tree, vector<int>& Traced, int now) {
	if (Traced[now]) return;
	Traced[now] = 1;
	for (int v : Tree[now]) if (!Traced[v]) DFS(Tree, Traced, v);
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> Tree(N);
	for (int i = 0; i < M; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		Tree[x - 1].push_back(y - 1);
		Tree[y - 1].push_back(x - 1);
	}
	vector<int> Traced(N);
	int ans = 0, first=0;
	while (first < N) {
		DFS(Tree, Traced, first);
		ans++;
		while (first < N && Traced[first]) first++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////


int main() {

	int K;
	string S;
	cin >> K;
	cin >> S;

	if (S.size() <= K) {
		cout << S << endl;
	}
	else {
		string ans;
		rep(i, K) {
			ans = ans + S[i];
		}
		ans = ans + "...";
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000
#define BEAM 220

using namespace std;

class state {
    public:
        int day;
        int previous_score;
        vector<int> previous;
        vector<int> types;

        state() {}

        state(const state& a) : day(a.day), previous_score(a.previous_score), previous(a.previous), types(a.types) {}
};

template<typename T>
int _scoring(const vector<int> &c,
        const vector<vector<int>> &s,
        int day,
        int type,
        const vector<T> &previous) {
    int score = s[day][type];

    REP(i, 26) {
        score -= c[i] * (day + 1 - previous[i]);
    }

    return score;
}

int scoring(const vector<int> &c,
        const vector<vector<int>> &s,
        state &this_state) {
    this_state.previous[this_state.types.back()] = this_state.day + 1;
    return this_state.previous_score + _scoring(c, s, this_state.day, this_state.types.back(), this_state.previous);
}

using queue_type = pair<state, int>;
struct CustomCompare
{
    bool operator()(const queue_type &a, const queue_type &b) {
        return a.second < b.second;
    }
};

int main() {
    int D;
    cin >> D;

    vector<int> c(26);
    REP(i, 26)
        cin >> c[i];

    vector<vector<int>> s(D, vector<int>(26, 0));
    REP(i, D)
        REP(j, 26)
        cin >> s[i][j];

    vector<state> initial;
    REP(i, 26) {
        state this_state;
        this_state.day = 0;
        this_state.types.reserve(D);
        this_state.types.push_back(i);
        this_state.previous_score = 0;
        this_state.previous = decltype(this_state.previous)(26, 0);
        initial.push_back(this_state);
    }

    priority_queue<queue_type, vector<queue_type>, CustomCompare> q1, q2;
    REP(i, D) {
        if (i == 0) {
            // use initial
            for (auto i : initial) {
                q2.emplace(i, scoring(c, s, i));
            }
        } else {
            // use queue
            for (int ii = 0; ii < BEAM && !q1.empty(); ++ii) {
                const auto &i = q1.top();

                REP(j, 26) {
                    state new_state = i.first;
                    new_state.day++;
                    new_state.types.push_back(j);

                    q2.emplace(new_state, scoring(c, s, new_state));
                }

                q1.pop();
            }
        }
        swap(q1, q2);

        q2 = decltype(q2)();
    }

    auto res = q1.top().first;

    for (auto t : res.types)
        cout << t + 1 << endl;

    return 0;
}



Measured memory_bytes: 26132
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=1e5+5;
int n,val[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	std::sort(val+1,val+n+1);
	int tgt=val[n]>>1,*p=std::lower_bound(val+1,val+n,tgt);
	if(p==val+n) printf("%d %d\n",val[n],*--p);
	else printf("%d %d\n",val[n],*p-tgt<=tgt-*--p?*++p:*p);
	return 0;
}


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

int main() {
	int A, B; cin >> A >> B;
	int ans=0, a[5];
	for(int i=A; i<=B; ++i){
	    int P=i;
	    for(int j=0; j<5; ++j){
	        a[j]=P%10;
	        P /= 10;
	    }
	    if(a[0]==a[4] && a[1]==a[3]) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
    fr(i,2*x-1){
      cout << y-x+i+1 << " ";
    }
}

Measured memory_bytes: 256
res = ""
n = int(input())
dig = -1

for i in range(20):
    n -= 26 ** i
    if n < 26 ** (i + 1):
        dig = i + 1
        break

for i in range(dig):
    res += chr(ord('a') + n % 26)
    n //= 26

print(res[::-1])

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

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

    const int MOD = 2019;
    
    string s; cin >> s;
    reverse(s.begin(), s.end());
    int n = s.size();
    vector<int> ssum(n+1, 0);
    int dig = 1;
    rep(i,n){
        int d = int(s[i]-'0');
        ssum[i+1] = (ssum[i] + d*dig)%2019;
        dig = (10*dig)%MOD;
    }

    map<int, ll> m;
    rep(i,n+1) m[ssum[i]]++;

    ll ans = 0LL;
    for(auto i:m){
        ll now = i.second;
        ans += now*(now-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4420
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

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

const ll mod = static_cast<ll>(1e9) + 7;

ll N, M;

const ll MAXN = 100000;
vector<pll> G[MAXN];

bool v1[MAXN];
bool v2[MAXN];

bool e1[MAXN];
bool e2[MAXN];

ll solve(ll p)
{
    if (v1[p]) { return 0; }
    v1[p] = true;

    ll res = 0;

    for (const auto& t : G[p])
    {
        const auto q = t.first;
        const auto e = t.second;

        if (e1[e]) { continue; }
        e1[e] = true;

        res += solve(q) + 1;
    }

    return res;
}

bool output(ll p)
{
    if (v2[p]) { return true; }
    v2[p] = true;

    ll ans = 0;

    for (const auto& t : G[p])
    {
        const auto q = t.first;
        const auto e = t.second;

        if (e2[e]) { continue; }
        e2[e] = true;

        const bool res = output(q);

        if (res)
        {
            cout << p + 1 << " " << q + 1 << endl;
            ++ans;
        }
        else
        {
            cout << q + 1 << " " << p + 1 << endl;
        }
    }

    return ans % 2 == 0;
}

int main()
{
    cin >> N >> M;

    rep (i, M)
    {
        ll a, b;
        cin >> a >> b;

        --a;
        --b;

        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }

    bool ok = true;

    rep (i, N)
    {
        const auto res = solve(i);
        if ((res % 2) == 1) { ok = false; }

        // cout << i << ": " << res << endl;
    }

    if (ok)
    {
        rep (i, N)
        {
            output(i);
        }
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 15104
#include <stdio.h>
int main(void){
    // Your code here!
    int n,m,i,ans = 0;
    scanf("%d %d",&n,&m);
    for(i=n+m-1;i>0;i--){
        ans = ans + i;
    }
    printf("%d",ans - n*m);
    return 0;
}

Measured memory_bytes: 128
import sys
from collections import Counter
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
C = Counter()
ans = 0
for i in range(1, N+1):
    a = A[i-1]
    ans += C[i-a]
    C[a+i] += 1
print(ans)

Measured memory_bytes: 113372
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 3;
int main (void) {
    int n[N];

    for (int i = 0; i < N; i++) {
        cin >> n[i];
    }

    int ans = 0;
    while (true) {
        if (n[0] == n[1] && n[1] == n[2]) {
            break;
        }
        ans++;
        sort(n, n + N);
        if (n[2] - n[0] >= 2) {
            n[0] += 2;
        } else {
            n[0]++;
            n[1]++;
        }
    }

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


Measured memory_bytes: 256
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]

k = int(input())

print(data[k - 1])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    p = list(map(int, input().split()))
    mod_p = sorted(p)
    count = 0

    for pi, mod_pi in zip(p, mod_p):
        if pi != mod_pi:
            count += 1

    if count <= 2:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
S = input()
n = len(S) + 1
S_ = ">" + S + "<"
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
for i in range(1, n):
    if S_[i] == "<":
        A[i] = A[i-1] + 1
for i in range(2, n+1):
    if S_[-i] == ">":
        B[-i] = B[-i+1] + 1
ans = 0
for i in range(n):
    ans += max(A[i], B[i])
print(ans)

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

int main() {
	int n,k,x,y;
  	cin >> n >> k >> x >> y;
  	if(n<=k){
      cout << x*n << endl;
    }
  	else{
      cout << x*n-(x-y)*(n-k) << endl;
    }
  	
}

Measured memory_bytes: 256
/*
______________________________
                              |
Shubham Singhal               |
                              |
CodeChef          torque      |
HackerEarth       torque      |
SPOJ              torque      |
HackerRank        torquecode  |
CodeForces        torquecode  |
______________________________| */


// If Tyrion dies, I am gonna riot :P


# include <bits/stdc++.h>
using namespace std;

# define MOD         1000000007
# define gc          getchar
# define LL          long long
# define L           long
# define pb          push_back
# define mp          make_pair
# define vi          vector<int>
# define MAXN        100005
# define INF         1e9

int main()
{

    LL a,b;
    cin>>a>>b;
    if(a<=0 && b>=0)
        cout<<"Zero";
    else if(a>=0)
        cout<<"Positive";
    else
    {
        if((b-a)%2==0)
            cout<<"Negative";
        else
            cout<<"Positive";

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  vector<int>a(5);
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  for(int i=0;i<5;i++){
    if(a[i] == 0) cout << i + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3572
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

const M: usize = std::usize::MAX;
fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, h: usize, w: usize);
    let mut ps: BTreeSet<_> = (0..w).map(|i| (i, i, i)).collect();
    let mut ds: BTreeSet<_> = (0..w).map(|i| (0, i)).collect();
    for hi in 0..h {
        parse!(it, a: u1, b: usize);
        let ts: Vec<_> = ps.range((a, 0, 0)..(b, 0, 0)).cloned().collect();
        let mut ma: Option<(usize, usize)> = None;
        for t in ts {
            ps.remove(&t);
            let (d, s, i) = t;
            ds.remove(&(d - s, i));
            ma = ma.map(|x| max(x, (s, i))).or(Some((s, i)));
        }
        if let Some((x, i)) = ma {
            if b != w {
                ps.insert((b, x, i));
                ds.insert((b - x, i));
            }
        }
        if let Some(&(d, _)) = ds.iter().next() {
            println!("{}", d + hi + 1);
        } else {
            println!("{}", -1);
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 21640
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    string ans = "No";
    for(int i = 0; 4 * i <= n; i++) {
        for(int j = 0; 7 * j <= n; j++) {
            if(4 * i + 7 * j == n) {
                ans = "Yes";
                break;
            } 
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int N = 405;
const int mod = 998244353;
int len[N], c[N][N], ex[N], f[N][N], g[N][N], tf[N], tg[N], h[N];
int n, T, rt;

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

inline void dec(int &x, int y)
{
	x -= y;
	x < 0 ? x += mod : 0;
}

inline void Update(int now, int x)
{
	for (int i = 0; i <= len[x] + len[now]; ++i)
		tf[i] = tg[i] = 0;
	for (int i = 0; i <= len[x]; ++i)
		for (int j = 0; j <= len[now]; ++j)
		{
			tf[i + j] = (1ll * f[x][i] * f[now][j] + tf[i + j]) % mod;
			tg[i + j] = (1ll * g[x][i] * g[now][j] + tg[i + j]) % mod;
		}
	len[now] += len[x];
	for (int i = 0; i <= len[now]; ++i)
		f[now][i] = tf[i], g[now][i] = tg[i];
}

inline int solve(int l, int r, int lst)
{
	if (l > r)
		return 0;
	
	int mid = l, now = ++T;
	for (int i = l + 1; i <= r; ++i)
		if (h[i] < h[mid])
			mid = i;

	int lc = solve(l, mid - 1, h[mid]),
		rc = solve(mid + 1, r, h[mid]);
	f[now][0] = g[now][0] = len[now] = 1;
	if (lc)	
		Update(now, lc);
	if (rc)
		Update(now, rc);
	int _len = len[now];
	for (int i = 1; i <= h[mid] - lst; ++i)
	{
		for (int j = 0; j <= _len; ++j)
			tf[j] = tg[j] = 0;
		if (i == 1)
		{
			int delta = 0;
			for (int j = l; j <= r; ++j)
				if (h[j] == h[mid])
					++delta;
			_len -= delta;
			for (int j = 0; j <= _len; ++j)
			{
				tf[j + delta] = (1ll * f[now][j] * (ex[j] - 1) + tf[j + delta]) % mod;
				tg[j] = (1ll * g[now][j] * (ex[j] - 1) + tg[j]) % mod;

				add(tf[j], g[now][j]);
				add(tg[j], g[now][j]);
				for (int a = 0; j + a <= _len; ++a)
					for (int b = 0; b <= delta; ++b)
						if (a + b > 0)
						{
							int tmp = 1ll * c[_len - j][a] * c[delta][b] % mod * ex[j] % mod;
							tf[j + a + delta] = (1ll * tmp * f[now][j] + tf[j + a + delta]) % mod;
							tg[j + a + b] = (1ll * tmp * g[now][j] + tg[j + a + b]) % mod;
						}
			}
			_len += delta;
		}
		else
		{
			for (int j = 0; j <= _len; ++j)
			{
				tf[j] = (1ll * f[now][j] * (ex[j] - 1) + tf[j]) % mod;
				tg[j] = (1ll * g[now][j] * (ex[j] - 1) + tg[j]) % mod;		

				add(tf[j], g[now][j]);
				add(tg[j], g[now][j]);

				for (int k = 1; j + k <= _len; ++k)
				{
					tf[j + k] = (1ll * f[now][j] * c[_len - j][k] % mod * ex[j] + tf[j + k]) % mod;
					tg[j + k] = (1ll * g[now][j] * c[_len - j][k] % mod * ex[j] + tg[j + k]) % mod;
				}
			}
		}
		for (int j = 0; j <= _len; ++j)
			f[now][j] = tf[j], g[now][j] = tg[j];
	}
	return now;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &h[i]);

	ex[0] = 1;
	for (int i = 1; i <= n; ++i)
		add(ex[i] = ex[i - 1], ex[i - 1]);
	c[0][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			add(c[i][j] = c[i - 1][j - 1], c[i - 1][j]);
	}

	rt = solve(1, n, 0);
	printf("%d\n", f[rt][n]);
}

Measured memory_bytes: 2176
// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
const int MIN = INT_MIN;
const int MAX = INT_MAX;

bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b) {
	return (a.second < b.second) ;
}

ll binpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res = res * a;
		a = a*a;
		b = b >> 1;
	}

	return res;
}


/*
BHAI EFFORT DAAL
*/


int main(){
	ItsFUN;

	ll k, x; cin >> k >> x;
	if(k*500 >= x) {
		puts("Yes");
	}
	else puts("No");

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
bool parent[100000];
vector<int> graph[100000];
int sw[100000];
int calculate(int x) {
  if(sw[x]!=0)
    return sw[x];
  int maxx=0;
  for(int i=0; i<graph[x].size(); i++) {
    maxx=max(calculate(graph[x][i]),maxx);
  }
  return (sw[x]=maxx+1);
}
int main()
{
  int n,m,x,y,maxx;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> x >> y;
    graph[--x].push_back(--y);
  }
  maxx=0;
  for(int i=0; i<n; i++) {
    maxx=max(calculate(i),maxx);
  }
  cout << maxx-1 << '\n';
  return 0;
}


Measured memory_bytes: 8192
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[k][j]==b:
                a[k][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l]==0 and a[2][l]==0:
        ans=1
        break




if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9240
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	
	printf("%d %d %lf\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string S; cin >> S;
  ull K; cin >> K;

  char res{};
  for(ull i = 0; i < K; ++i)
  {
    if(i == S.size())
    {
      break;
    }
    res = S[i];
    if(S[i] != '1')
    {
      break;
    }
  }

  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256