akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Rishabhdeep Singh
 */

// doot diddly donger cuckerino Hahahahahah
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define PB              push_back
#define EB              emplace_back
#define F               first
#define S               second
#define all(x)          begin(x), end(x)
#define rall(x)         rbegin(x), rend(x)
#define sz(x)           (long long) (x).size()
#define IOS             ios::sync_with_stdio(false);cin.tie(NULL); cout << fixed << setprecision(12);
#define IN_REP          int tt; cin >> tt; while(tt--)
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos(-1);

template<typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> void mini(T& x, T y) { x = min(x, y); }
template<typename T> void maxi(T& x, T y) { x = max(x, y); }
template<typename T, typename U> string to_string(pair<T, U> p) { return to_string(p.F) + " " + to_string(p.S); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class DBrickBreak {
  public:

    void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin >> n;
        int nxt = 1;
        int ans = 0;
        for(int i = 0; i < n; ++i){
            int x;
            cin >> x;
            if(nxt == x){
                nxt++;
            }else{
                ++ans;
            }
        }
        if(ans == n) ans = -1;
        cout << ans << '\n';
    }
};

int main() {
    IOS;
	DBrickBreak solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define int long long
/*int maxi1=INT_MIN;
void segment(int l,int r,long long dp[],long long &maxi)
{
if(l==r)
{
  maxi=dp[l];
  return;	
}	
if(l+1==r)
{
	if(dp[l]>dp[r])
	{
		maxi=dp[l];
	}
	else
	maxi=dp[r];
	
	return ;
}

int mid=(l+r)/2;

segment(l,mid,dp,maxi1);
segment(mid+1,r,dp,maxi);

if(maxi1>maxi)
maxi=maxi1;

	
	
}
*/
void construct(int dp[],int tree[],int low,int  high, int pos)
{
	if(low==high)
{
	tree[pos]=dp[low];

		return;
}

int mid=(low+high)/2;

construct(dp,tree,low,mid,2*pos+1);
construct(dp,tree,mid+1,high,2*pos+2);
tree[pos]=max(tree[2*pos+1],tree[2*pos+2]);



}
int rangemax(int tree[],int qlow,int qhigh, int low,int high,int pos)
{
	if(qlow<=low&&qhigh>=high)
	return tree[pos];
	
	if(qlow>high||qhigh<low)
	return INT_MIN;
	
	int mid=(low+high)/2;
	
	return max(rangemax(tree,qlow,qhigh,low,mid,2*pos+1),rangemax(tree,qlow,qhigh,mid+1,high,2*pos+2));
	
	
}


void update(int tree[],int l,int h,int i,int v,int pos)
{
  if(l==h)
  {
    tree[pos]=v;
    return ;
  }
  int mid=(l+h)/2;
  
  
  if(i<=mid)
  update(tree,l,mid,i,v,2*pos+1);
  else
    update(tree,mid+1,h,i,v,2*pos+2);
  
  tree[pos]=max(tree[2*pos+1],tree[2*pos+2]);

  
}
  

int32_t main()
{
	int n; 
	cin>>n;
	 int h[n],a[n];
	 
	
	 for(int i=0; i<n; i++)
	 {
	 
	 cin>>h[i];
     
    }
    
	 for(int i=0; i<n; i++)
	{
		
	  cin>>a[i];
	 
	 
    }
    
    long long dp[n+1]={0};
    
    int tsize=1;
    
    while(tsize<=n)
    {
    	tsize*=2;
    	
	}
	
    int tree[2*tsize]={0};
  
    // construct(dp,tree,0,n,0);
    
    for(int i=0; i<n; i++)
    {
    	
		
		
		/*for(int j=0; j<h[i]; j++)
    	dp[h[i]]=max(dp[h[i]],dp[j]+a[i]);
    	
    	""for O(n^2) TC""
    	
    	
         */	
         
       
        
        int x=rangemax(tree,0,h[i]-1,0,n,0);
        
        dp[h[i]]=x+a[i];
        
		  update(tree,0,n,h[i],dp[h[i]],0);
      
      
		
	}
	
	long long mx=0;
	
	for(int i=0; i<=n; i++)
	 
	{
	  //cout<<dp[i]<<" ";
	 mx=max(mx,dp[i]);
    }
	 
	 cout<<mx;
	 
	 
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include<iomanip>

using namespace std;

int main() {
	int S = 0, T = 0, a;
	for (int i = 0; i < 4; i++)
	{
		cin >> a;
		S += a;
	}
	for (int i = 0; i < 4; i++)
	{
		cin >> a;
		T += a;
	}
	cout << max(S, T) << endl;
	return 0;
}

Measured memory_bytes: 1164
# n, m = map(int, input().split())
maze = []
for i in range(3):
    a_row = list(map(int,input().split()))
    maze.append(a_row)
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        row = maze[j]
        for k in range(3):
            if row[k] == b:
                row[k] = 0
for i in range(3):
    if sum(maze[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    if maze[0][i] + maze[1][i] + maze[2][i] == 0:
        print("Yes")
        exit()
if maze[0][0] + maze[1][1] + maze[2][2] == 0 or maze[0][2] + maze[1][1] + maze[2][0] == 0:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int ans = 700;
  if(s[0] == 'o') ans += 100;
  if(s[1] == 'o') ans += 100;
  if(s[2] == 'o') ans += 100;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;

const int mod = (int)1e9 + 7;


int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;
	int l, r;
	cin >> l >> r;
	for(int i = 0; i < m - 1; i++){
		int tempL, tempR;
		cin >> tempL >> tempR;
		int array[] = {l, r, tempL, tempR};
		sort(array, array+4);

		int x = array[1], y = array[2];

		if((l <= x && y <= r) && (tempL <= x && y <= tempR)){
			l = x;
			r = y;
		}
		else{
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (r - l + 1) << endl;


}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  swap(a,b);
  int A = a / k,B = (b - 1) / k;
  if(A - B >= 1)cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3644
from bisect import bisect_left

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]
            ic_end = bisect_left(L, a+b, lo=ib+1)
            ans += ic_end - (ib+1)

    print(ans)
main()

Measured memory_bytes: 73156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int sum = 0;
    for(int i = 1; i <= 999; i++){
        sum += i;
        if(sum - a == sum + i + 1 -b){
            cout << sum - a;
            break;
        }
    }
}

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

using namespace std;

vector<int> graph[100];

int main(){
  graph[0].push_back(1);
  graph[1].push_back(0);
  int a,b;
  while(cin>>a>>b){
    if(a==0&&b==0){
      bool is_euler = true;
      for(int i=0;i<100;++i){
        if(graph[i].size()%2==1){
          is_euler = false;
          break;
        }
      }
      if(is_euler){
        cout << "OK" << endl;
      }else{
        cout << "NG" << endl;
      }

      for(int i=0;i<100;++i){
        graph[i].resize(0);
      }
      graph[0].push_back(1);
      graph[1].push_back(0);
    }else{
      graph[a-1].push_back(b-1);
      graph[b-1].push_back(a-1);
    }
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

vector<int64> t;
int n;

int64 inf = 100000000000000000L;

int64 getmin(int r)
{
	int64 result = inf;
	for (; r >= 0; r = (r & (r + 1)) - 1)
		result = min(result, t[r]);
	return result;
}

void update(int i, int64 val)
{
	for (; i < n; i = (i | (i + 1)))
		t[i] = min (t[i], val);
}

int main() {
	ios_base::sync_with_stdio(0);
    int m;
	cin >> n >> m;
    vector<pair<int, pair<int, int>>> a(m);
    for (int i = 0; i < m; ++i) {
	    int l, r, c;
		cin >> l >> r >> c;
		--l;
		--r;
		a[i] = mp(l, mp(r, c));
	}
	sort(all(a));
	reverse(all(a));
	t.assign(n, inf);
	update(n - 1, 0);
	for (int i = 0; i < m; ++i) {
	    int l = a[i].first;
		int r = a[i].second.first;
		int c = a[i].second.second;
		int64 val = getmin(r);
		update(l, c + val);
	}
	int64 ans =  getmin(0);
	if (ans > inf / 2) {
	    cout << "-1" << endl;
		return 0;
	}
	cout << ans << endl;
    return 0;
}


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

int findmincost(int a[],int dp[],int k,int p){
    if(dp[p]!=-1)
       return dp[p];
    int i=1,currmin=INT_MAX;
    for(i=1;i<=k && p-i>=0;i++)
        currmin=min(currmin,findmincost(a,dp,k,p-i)+abs(a[p]-a[p-i]));
    dp[p]=currmin;
    return dp[p];
}

int main() {
	int n,k;
	cin>>n>>k;
	int a[n],i,dp[n];
	for(i=0;i<n;i++){
	   cin>>a[i];
	   dp[i]=-1;
	}
	dp[0]=0;
	findmincost(a,dp,k,n-1);
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 10368
program ABC_079_C_TrainTicket
   implicit none
   integer N, i, D, A(1:4)
   read(*, *) N
   do i = 1, 4
       A(5 - i) = mod(N, 10)
	   N = N / 10
   end do
   D = 7 - A(1)
   if(A(2) + A(3) + A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'+',A(2),'+',A(3),'+',A(4),'=',7
   else if(-A(2) + A(3) + A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'-',A(2),'+',A(3),'+',A(4),'=',7
   else if(A(2) - A(3) + A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'+',A(2),'-',A(3),'+',A(4),'=',7
   else if(A(2) + A(3) - A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'+',A(2),'+',A(3),'-',A(4),'=',7
   else if(A(2) + A(3) + A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'-',A(2),'+',A(3),'+',A(4),'=',7
   else if(-A(2) - A(3) + A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'-',A(2),'-',A(3),'+',A(4),'=',7
   else if(-A(2) + A(3) - A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'-',A(2),'+',A(3),'-',A(4),'=',7
   else if(A(2) - A(3) - A(4) == D) then
       write(*, "(i1,a1,i1,a1,i1,a1,i1,a1,i1)")A(1),'+',A(2),'-',A(3),'-',A(4),'=',7
   end if
end program ABC_079_C_TrainTicket

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

int main()
{
    long long ans=0;
    int n;
    cin>>n;
    //map<string,int> list;
    vector<string> them;
    vector<int> legth;
    string x;
    string s;
    int t;
    for(int i=0;i<n;i++){
        cin >>s>>t;
        //list.insert(make_pair(s,t));
        them.push_back(s);
        legth.push_back(t);
    }
    cin >>x;
    int flag=0;
    for (int itr = 0; itr < n; ++itr)
    {
        if (flag==1){
            ans+=(legth.at(itr));
          //  cout << ans<<endl;
        }
            if (them.at(itr) == x)
            {
                flag = 1;
            }

    }
    cout<< ans;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int N,A,B; cin >>N>>A>>B;

    cout << min(B,N*A) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#define ALL(x) (x).begin(), (x).end()
typedef long long lld;
const int MAXS = 1e5+5;
const int NOPE = -1;
std::vector<int> dex[MAXS]{ };
char S[MAXS];
char T[MAXS];
int M, N;

lld solve() {
  for (int i = 0; i < N; ++i) {
    dex[S[i] - 'a'].push_back(i);
  }
  int pos = -1;
  lld ret = 0;
  for (int i = 0; i < M; ++i) {
    int c = T[i] - 'a';
    if (dex[c].empty()) {
      return NOPE;
    }
    auto ptr = std::upper_bound(ALL(dex[c]), pos);
    if (ptr == dex[c].end()) {
      ret += (N - pos) + dex[c].front();
      pos = dex[c].front();
    } else {
      ret += *ptr - pos;
      pos = *ptr;
    }
  }
  return ret;
}

int main() {
  scanf(" %s%s", S, T);
  N = strlen(S);
  M = strlen(T);
  printf("%lld\n", solve());
  return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll n;
    cin>>n;
    ll a[n];
    for(int x=0;x<n;x++)cin>>a[x];
    ll ans=0;
    for(int x=0;x<n;x++)
        for(int y=x+1;y<n;y++)
          for(int z=y+1;z<n;z++)
             {
                ll s=a[x]+a[y]+a[z];
                if(s-a[z]>a[z] && s-a[y]>a[y] && s-a[x]>a[x] && a[x]!=a[y] && a[y]!=a[z] && a[z]!=a[x])
                    ++ans;
             }
            cout<<ans;
}


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

int Board[102][102];    //Board[j, x, w][i, y, h]
bool isOK;              //迷路がOKかNGか
int xs, ys, xg, yg;     //StartとGoalの座標

void DFS(int c, int x, int y){
    if(Board[x][y] != c){
        return;
    }
    else if(x==xg && y==yg){
        isOK = true;    //Goalなら迷路はOK
        return;
    }

    Board[x][y] = 0;

    DFS(c, x+1, y  );
    DFS(c, x  , y+1);
    DFS(c, x-1, y  );
    DFS(c, x  , y-1);
}

int main(){
    int w,h;
    while(true){
        cin >> w >> h;
        if(w==0 && h==0)
            break;
        
        isOK = false;               //初期値をNGに
        for(int i=1;i<=100;i++){    //Boardの初期化
            for(int j=1;j<=100;j++)
                Board[j][i] = -1;
        } 
        cin >> xs >> ys >> xg >> yg;

        int n, c, d, x, y;
        cin >> n;
        for(int t=0;t<n;t++){
            cin >> c >> d >> x >> y;
            int wb = 2+(!d*2);      //d=0なら横長
            int hb = 2+(d*2);       //d=1なら縦長
            for(int i=0;i<hb;i++){
                for(int j=0;j<wb;j++)
                    Board[x+j][y+i] = c;
            }
        }

        DFS(Board[xs][ys], xs, ys);

        if(isOK)
            cout << "OK" << endl;
        else
            cout << "NG" << endl;
        
    }
    return 0;
}



Measured memory_bytes: 3732
from collections import Counter
H,W,N = map(int,input().split())
ab = []
corner = []
countlist = [0 for i in range(10)]
for i in range(N):
    a,b = map(int,input().split())
    for h in range(-2,1):
        for w in range(-2,1):
            if 1 <= a+h <= H-2 and 1 <= b+w <= W-2:
                corner.append((a+h,b+w))
cc = Counter(corner)
clist = list(cc.values())
clistc = Counter(clist)
for k,v in clistc.items():
    countlist[k] += v
countlist[0] = (H-2)*(W-2) - sum(countlist)
for i in countlist:
    print(i)

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

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

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main(){
  
  long long i, A, B, C, D, Ca, Da, CD, CDa;
  cin >> A >> B >> C >> D;
  
  Ca = B/C - (A/C + 1 - (A%C==0)) + 1;
  Da = B/D - (A/D + 1 - (A%D==0)) + 1;
  CD = lcm(C, D);
  CDa = B/CD - (A/CD + 1 - (A%CD==0)) + 1;
  
  cout << B - A + 1 - (Ca + Da - CDa) << endl;
  return 0;
}

Measured memory_bytes: 3588
n = int(input())
h = list(map(int, input().split()))

count = 0
count_list = []

for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        count_list.append(count)
        count = 0
else:
    count_list.append(count)
        
print(max(count_list))

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int ceil_div(int x, int y){
	return (x%y==0 ? x/y : (x/y)+1);
}

int main(){
	ll K, N;
	cin >> N >> K;
	cout << ceil_div(N-1, K-1) << endl;
    return 0;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:i64
    }

    let mut ans = n - 1;
    for i in 2.. {
        if i * i > n {
            break;
        }

        if n % i == 0 {
            let j = n / i;
            chmin(&mut ans, i + j - 2);
        }
    }

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


Measured memory_bytes: 4352
N=int(input())
s=[list(input()) for _ in range(N)]

for n in range(N):
    s[n].sort()
s.sort()

cnt=[]
i=0
for n in range(1,N):
    if s[n]==s[n-1]:
        i+=1
    else:
        cnt.append(i)
        i=0
if i!=0:
    cnt.append(i)

ans=0
for e in cnt:
    ans+=(e+1)*e//2
print(ans)

Measured memory_bytes: 25108
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
	int [] dp;
	int max = 1000;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int sum = 0;
			for(int i = 0 ; i < n; i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				int h = sc.nextInt();
				int w = sc.nextInt();
				int size = x + y + h;
				int res = calc(size, w);
				sum += res;
			}
			System.out.println(sum);
		}
	}

	private int calc(int size, int w) {
		if(size <= 60 && w <= 2){
			return 600;
		}
		if(size <= 80 && w <= 5){
			return 800;
		}
		if(size <= 100 && w <= 10){
			return 1000;
		}
		if(size <= 120 && w <= 15){
			return 1200;
		}
		if(size <= 140 && w <= 20){
			return 1400;
		}
		if(size <= 160 && w <= 25){
			return 1600;
		}
		return 0;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, k;
    cin >> n >> k;
    ll p[n], ans = 0;
    rep(i, n) {
        cin >> p[i];
        p[i]++;
    }
    int i = 0, j = 0;
    ll num = 0;
    while(i + k - 1 >= j)
        num += p[j++];
    ans = num;
    for(; j < n; i++, j++) {
        num -= p[i];
        num += p[j];
        chmax(ans, num);
    }
    printf("%.10f\n", (double)ans / 2.0);
}

Measured memory_bytes: 1792
H,W = map(int,input().split())
ans = [H//2+W//3+1,H//3+W//2+1,H,W]

if(H%3==0 or W%3==0):
  ans+=[0]
if(H%2==0):
  ans+=[H//2]
if(W%2==0):
  ans+=[W//2]

print(min(ans))

Measured memory_bytes: 9080
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
# stdin = open("sample.txt")

K = int(stdin.readline().rstrip())
a = deque(range(1,10))
ans_list = []
attack = 100000
while attack > 0:
    ans = a.popleft()
    ue = ans*10
    shimo = ans%10
    ans_list.append(ans)
    if shimo == 0:
        a.append(ue)
        a.append(ue+1)
    elif shimo == 9:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
    else:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
        a.append(ue+shimo+1)
    attack -= 1

print(ans_list[K-1])

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

int main() {
    int h,w;
    cin>>h>>w;
    string f;
    for (int i=0;i<w+2;i++)
        f+="#";
    cout<<f<<endl;
    for (int i=0;i<h;i++) {
        string s;
        cin>>s;
        cout<<"#"<<s<<"#"<<endl;
    }
    cout<<f<<endl;
    return 0;
}

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

int main(){
	int k,n,max_val=-1;
	cin>>k>>n;
  int a[n];
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  for(int i=0;i<n-1;i++)
    max_val=max(abs(a[i]-a[i+1]),max_val);
  max_val=max(max_val,k-a[n-1]+a[0]);
  cout<<k-max_val<<endl;
  
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a, b, c, m = 0, ans = 0;
  cin >>a >>b >> c;
  m = max({a, b, c});
  ans = 10*m + a + b + c - m; 
    cout << ans << endl;
    return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(W-x>=r&&x>=r&&H-y>=r&&y>=r){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
	return 0;
	}

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

typedef long long int int64;

typedef struct directedGraph{
  int *vertex;
  int *next;
  int *start;
  int v,e;
  int pointer;
} graph;

graph* newGraph(const int v,const int e){
  graph *g=(graph *)malloc(sizeof(graph));
  g->vertex=(int *)calloc(e,sizeof(int));
  g->next=(int *)calloc(e,sizeof(int));
  g->start=(int *)calloc(v,sizeof(int));
  for(int i=0;i<v;i++) g->start[i]=-1;
  g->v=v;
  g->e=e;
  g->pointer=0;
  return g;
}

void freeGraph(graph *g){
  free(g->vertex);
  free(g->next);
  free(g->start);
  free(g);
  return;
}

void addEdge(graph *g,const int from,const int to){
  const int p=g->pointer;
  g->vertex[p]=to;
  g->next[p]=g->start[from];
  g->start[from]=p;
  g->pointer++;
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  graph *g=newGraph(n,2*n);
  int i;
  for(i=0;i<n-1;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    x--;y--;
    addEdge(g,x,y);
    addEdge(g,y,x);
  }
  int *parent=(int *)calloc(n,sizeof(int));
  int *q=(int *)calloc(n,sizeof(int));
  parent[0]=-1;
  int front=0,last=0;
  q[last++]=0;
  while(last<n){
    const int v=q[front++];
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      const int u=g->vertex[p];
      if(u==parent[v]) continue;
      parent[u]=v;
      q[last++]=u;
    }
  }
  const int mod=1000000007;
  int *dp=(int *)calloc(2*n,sizeof(int));
  for(i=n-1;i>=0;i--){
    const int v=q[i];
    dp[2*v]=dp[2*v+1]=1;
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      const int u=g->vertex[p];
      if(parent[u]==v){
	dp[2*v]=(int64)dp[2*v]*(dp[2*u]+dp[2*u+1])%mod;
	dp[2*v+1]=(int64)dp[2*v+1]*dp[2*u]%mod;
      }
    }
  }
  printf("%d\n",(dp[0]+dp[1])%mod);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=100,up=80*80*2;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,m,a[maxn][maxn],b[maxn][maxn],f[81][81][26244];
int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n>>m;
    _rep(i,1,n)
        _rep(j,1,m)
            cin>>a[i][j];
    _rep(i,1,n)
        _rep(j,1,m)
            cin>>b[i][j];
    
    f[1][1][a[1][1]-b[1][1]+up]=1;
    f[1][1][b[1][1]-a[1][1]+up]=1;

    _rep(i,1,n)
        _rep(j,1,m)
        {   
            int p=a[i][j]-b[i][j];
            for(int k=0;k<=2*up;k++)
            {
                if(f[i-1][j][k]&&i>1)
                    f[i][j][k+p]=1,f[i][j][k-p]=1;
                if(f[i][j-1][k]&&j>1)
                    f[i][j][k+p]=1,f[i][j][k-p]=1;
            }
        }
    int ans=INF;
    for(int i=0;i<=up*2;i++)
        if(f[n][m][i])
            ans=min(ans,abs(i-up));

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

Measured memory_bytes: 664704
s=list(input())
n=[int(x) for x in s]
min_abs=999
for i in range(len(n)-2):
    if abs(753-(n[i]*100+n[i+1]*10+n[i+2]))<min_abs:
        min_abs=abs(753-(n[i]*100+n[i+1]*10+n[i+2]))
print(min_abs)

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

using namespace std;

int main()
{
    int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int q;
	cin>>q;
	while(q--)
    {
		int b,m,e;
		cin>>b>>m>>e;
		rotate(a+b,a+m,a+e);
	}
	for(int i=0;i<n;i++)
	{
		if(i)
            cout<<' ';
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}



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

table = list(map(int,input().split()))

swap_count = 0
for i in range(N-1):
    for k in range(N-1,i,-1):
        if table[k]<table[k-1]:
            table[k],table[k-1] = table[k-1],table[k]
            swap_count+=1

print(" ".join(map(str,table)))
print(swap_count)


Measured memory_bytes: 5600
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias AB = Tuple!(long, "a", long, "b");

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    AB[] abs;
    foreach (_; 0..N) {
        auto ab = readln.split.to!(long[]);
        abs ~= AB(ab[0], ab[1]);
    }
    sort!"a.a < b.a"(abs);
    long s;
    for (;;) {
        auto a = abs[0].a;
        auto b = abs[0].b;
        if (M > b) {
            s += a*b;
            M -= b;
        } else {
            s += a*M;
            break;
        }
        abs = abs[1..$];
    }
    writeln(s);
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

bool pairCompare(const pll& firstElof, const pll& secondElof)
{
    return firstElof.first < secondElof.first;
}

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

  vector<pll> vec;
  for( int i=0; i<N; i++ ){
    long A, B;
    cin >> A >> B;
    vec.pb(mp(A,B));
  }
  sort(vec.begin(), vec.end(), pairCompare);

  long long ret = 0;
  for( auto val : vec ){
    if( M > val.second ){
      M -= val.second;
      ret += val.first * val.second;
    } else {
      ret += val.first * M;
      break;
    }
  }

  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    map<int,int> ct;
    int ans = 0;
    rep(i,n) {
        int a; cin >> a;
        ct[a]++;
    }
    for (auto itr = ct.begin(); itr != ct.end(); itr++) {
        if (itr->second % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
/*
Author : N_o_o_B
Created : April 22 2020 16:12:43 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

bool prime(int n){
    if(n < 2) return 0;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int x;
    cin >> x;
    while(1){
        if(prime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }



    time_taken();
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  t.erase(s.size());
  if(s==t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int sz=1005;
int x,y,z,k;
long long a[sz],b[sz],c[sz];
vector<long long> ans;
map<int,bool> visited[sz][sz];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d %d %d",&x,&y,&z,&k);
    for(int i=0;i<x;i++) scanf("%lld",&a[i]);
    for(int i=0;i<y;i++) scanf("%lld",&b[i]);
    for(int i=0;i<z;i++) scanf("%lld",&c[i]);
    sort(a,a+x,greater<long long>());
    sort(b,b+y,greater<long long>());
    sort(c,c+z,greater<long long>());
    priority_queue<pair<pair<long long,int>,pair<int,int>>> q;
    q.push(make_pair(make_pair(a[0]+b[0]+c[0],0),make_pair(0,0)));
    while(!q.empty()&&k--){
        auto curr=q.top();
        q.pop();
        int xi=curr.first.second,yi=curr.second.first,zi=curr.second.second;
        long long v=curr.first.first;
        ans.push_back(v);
        if(xi+1<x&&!visited[xi+1][yi][zi]){
            q.push(make_pair(make_pair(v-(a[xi]-a[xi+1]),xi+1),make_pair(yi,zi)));
            visited[xi+1][yi][zi]=1;
        }
        if(yi+1<y&&!visited[xi][yi+1][zi]){
            q.push(make_pair(make_pair(v-(b[yi]-b[yi+1]),xi),make_pair(yi+1,zi)));
            visited[xi][yi+1][zi]=1;
        }
        if(zi+1<z&&!visited[xi][yi][zi+1]){
            q.push(make_pair(make_pair(v-(c[zi]-c[zi+1]),xi),make_pair(yi,zi+1)));
            visited[xi][yi][zi+1]=1;
        }
    }
    for(auto u:ans) printf("%lld\n",u);
    return 0;
}


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

int main() {
  int a;
int b=0;
int c=0;
int d=0;
int e=0;
  cin >> a ;
  for(int i=0;i<a;i++)
{
string f;
cin >>f;
if(f=="AC")
{
b+=1;
}
if(f=="WA")
{
c+=1;
}
if(f=="TLE")
{
d+=1;
}
if(f=="RE")
{
e+=1;
}
}
cout<<"AC x "<<b<<endl;
cout<<"WA x "<<c<<endl;
cout<<"TLE x "<<d<<endl;
cout<<"RE x "<<e<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 10010;

int n;


void solve() {
	cin >> n;
	
	vector <int> infrontbetter[n+2];
	vector <int> behindbetter[n+2];
	
	int ans = 0;
	
	for (int i =1;i<=n;i++) {
		int k, l, r; cin >> k >> l >> r;
		if (l >= r) infrontbetter[k].push_back(l - r);
		else behindbetter[k].push_back(r - l);
			
		ans += min(l,r);
	}
	//cout << "ANS: " << ans << "\n";
	
	multiset <int> S;
	for (int i = 1; i<= n;i++) {
		for (auto j : infrontbetter[i]) {
			S.insert(j);
		}
		while ((int) S.size() > i) S.erase(S.begin());
	}
	
	for (auto i: S) ans += i;
	//cout << "ANS: " << ans << "\n";
	
	S.clear();
	for (int i = n; i >= 2; i--) {
		for (auto j: behindbetter[i-1]) {
			S.insert(j);
		}
		//for (auto j : S) cout << j << "\n";
		while ((int) S.size() > (n - i + 1)) S.erase(S.begin());
	}
	
	for (auto i: S) ans += i;
	//cout << "ANS: " << ans << "\n";
	cout << ans << "\n";
	
}


int32_t main() {
	FAST
	int tc; cin >> tc;
	while (tc--) solve();

}




Measured memory_bytes: 22296
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	//freopen(".inp","r",stdin);
	//freopen(".out","w",stdout);
	int a , b ;
	cin >> a >> b ;
	if( a >= b )
	{
		for( int i = 1 ; i <= a ; i++) cout << char( b + 48 ) ;
		return 0 ;
	}
	if( b > a )
	{
		for( int i = 1 ; i <= b ; i++) cout << char( a + 48 ) ;
		return 0 ;
	}
    return 0 ;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  while (cin >> n, n) {
    vi a(n);
    cin >> a;
    int k;
    cin >> k;
    int up = n - 1, low = 0;
    int c = 0;
    forever {
      int mid = low + (up - low) / 2;
      c++;
      if (a[mid] == k || low == up) break;
      if (a[mid] > k) up = mid - 1;
      if (a[mid] < k) low = mid + 1;
      if (up < low) break;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)

int const N=1e5+5;
int const inf=1e9+5;
void solve(){
int n;
cin>>n;
vector<int> dp(n,inf);
vector<int> v(n);
for(int i=0;i<n;i++)
    cin>>v[i];
    dp[0]=0;
for(int i=0;i<n;i++){
      for(int j=i+1;j<min(n,i+3);j++)
        dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
}
cout<<dp[n-1]<<endl;
}
int main(){
    fast;

solve();

return 0;}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    rep(a, n+1)rep(b, m+1)if(k==(n-a)*(m-b)+a*b){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int x;cin>>x;
  REP(i,x+1){
    if(((i+1)*i)/2 >= x){
      P(i);
      return 0;
    }
  }
  return 0;
}


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

int main(void) {
   double r,S,A;
   
   scanf("%lf", &r);
   
   S = r * r * M_PI;
   
   A = 2 * M_PI * r;
   
   printf("%lf %lf\n", S, A);
	return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "SUN") cout << "7" << endl;
	else if (s == "MON")cout << "6" << endl;
	else if (s == "TUE")cout << "5" << endl;
	else if (s == "WED")cout << "4" << endl;
	else if (s == "THU")cout << "3" << endl;
	else if (s == "FRI")cout << "2" << endl;
	else if (s == "SAT")cout << "1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {

	int N;
	string s;
	cin >> N >> s;
	string h;
	rep(i, s.size() / 2) {
		h.push_back(s[i]);
	}
	if (h + h == s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n) {
        cin >> a[i];
    } 
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i-1]) {
            ans++;
            a[i] += 1000;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
li=[]
ans=0
for i in range(n):
  li.append(i+l)
  ans+=i+l
for i in range(n):
    li[i]=abs(li[i])
if ans<0:
  print(ans+min(li))
else:
  print(ans-min(li))

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

int main(){
  string c;
  cin >> c;
  if(c == "a") cout << "b" << endl;
  if(c == "b") cout << "c" << endl;
  if(c == "c") cout << "d" << endl;
  if(c == "d") cout << "e" << endl;
  if(c == "e") cout << "f" << endl;
  if(c == "f") cout << "g" << endl;
  if(c == "g") cout << "h" << endl;
  if(c == "h") cout << "i" << endl;
  if(c == "i") cout << "j" << endl;
  if(c == "j") cout << "k" << endl;
  if(c == "k") cout << "l" << endl;
  if(c == "l") cout << "m" << endl;
  if(c == "m") cout << "n" << endl;
  if(c == "n") cout << "o" << endl;
  if(c == "o") cout << "p" << endl;
  if(c == "p") cout << "q" << endl;
  if(c == "q") cout << "r" << endl;
  if(c == "r") cout << "s" << endl;
  if(c == "s") cout << "t" << endl;
  if(c == "t") cout << "u" << endl;
  if(c == "u") cout << "v" << endl;
  if(c == "v") cout << "w" << endl;
  if(c == "w") cout << "x" << endl;
  if(c == "x") cout << "y" << endl;
  if(c == "y") cout << "z" << endl;
}


Measured memory_bytes: 256
def solve(n, s, t, x):
    for i in range(n):
        if s[i] == x:
            return sum(t[i+1:])
    return 0

n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i], t[i] = input().split()
    t[i] = int(t[i])
x = input()
print(solve(n, s, t, x))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main (void){
        long long int n,m,d;
        double ans;
        scanf("%lld",&n );
        scanf("%lld",&m );
        scanf("%lld",&d );
if (d==0) {
  ans=(double)(m-1)/n;
  printf("%.20lf",ans );
}else{
  ans=(double)(m-1)*2*(n-d)/n/n;
  printf("%.20lf",ans );
}

return 0;

}


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

void solve(int N, vector<int> A)
{
    vector<int> mx;
    mx.push_back(A.at(0));
    for (int i = 1; i < N; i++)
    {
        int Ai = A.at(i);
        int l = -1, r = mx.size();
        while (l + 1 < r)
        {
            int m = (l + r) / 2;
            if (mx.at(m) < Ai)
                r = m;
            else
                l = m;
        }
        if (r == (int)mx.size())
            mx.push_back(Ai);
        else
            mx.at(r) = Ai;
    }
    cout << mx.size() << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    solve(N, move(A));
    return 0;
}


Measured memory_bytes: 1276