akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,s.length()){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;

    return 0; 
}


Measured memory_bytes: 3916
import math
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0
a=math.floor(X/500)
for i in range(min(A,a)+1):
    X2=X-500*i
    b=math.floor(X2/100)
    for j in range(min(B,b)+1):
        X3=X2-100*j
        if X3%50==0:
            c=X3/50
            if c<=C:
                ans+=1
            else:
                continue
        else:
            continue
print(ans)

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

int main()
{
	int n;
	cin >> n;
	int t = 0;
	char c = '0';
	getchar();
	while(n--){
		char cc = getchar();
		if(c != cc){
//			cout << cc << endl;
			c = cc;
			t++;
		}
	}
	cout << t << endl;
	return 0;
}

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

const long long int INF=1e16;

vector<vector<long long int>> get_dis(vector<map<int,long long int>> &edge){
  vector<vector<long long int>> d(edge.size(),vector<long long int>(edge.size(),INF));
  for(int i=0;i<edge.size();i++){
    for(int j=0;j<edge.size();j++){
      if(edge[i].count(j)){
        d[i][j]=edge[i][j];
      }
    }

  }
  for(int k=0;k<edge.size();k++){
    for(int i=0;i<edge.size();i++){
      for(int j=0;j<edge.size();j++){
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  return d;
}
int main(){
  int n,m;
  while(cin>>n>>m,n){
    vector<map<int,long long int>> land_edge(n);
    vector<map<int,long long int>> sea_edge(n);
    for(int i=0;i<n;i++){
      land_edge[i][i]=0;
      sea_edge[i][i]=0;
    }
    for(int i=0;i<m;i++){
      int x,y;
      long long int t;
      char sl;
      cin>>x>>y>>t;
      x--,y--;
      cin>>sl;
      if(sl=='L'){
	if(land_edge[x].count(y)){
	  land_edge[x][y]=min(land_edge[x][y],t);
	  land_edge[y][x]=min(land_edge[y][x],t);
	}
	else{
	  land_edge[x][y]=t;
	  land_edge[y][x]=t;
	}
      }
      else{
	if(sea_edge[x].count(y)){
	  sea_edge[x][y]=min(sea_edge[x][y],t);
	  sea_edge[y][x]=min(sea_edge[y][x],t);
	}
	else{
	  sea_edge[x][y]=t;
	  sea_edge[y][x]=t;
	}
      }

    }
    auto land_d=get_dis(land_edge);
    auto sea_d=get_dis(sea_edge);

    
    int r;
    cin>>r;
    vector<vector<long long int>> dp(r,vector<long long int>(n,INF));
    int from,to;
    cin>>from;
    from--;
    dp[0][from]=0;
    for(int task=0;task<r-1;task++){
      cin>>to;
      to--;
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  if(i==j) dp[task+1][j]=min(dp[task+1][j],dp[task][j]+land_d[from][to]);
	  else dp[task+1][j]=min(dp[task+1][j],dp[task][i]+land_d[from][i]+sea_d[i][j]+land_d[j][to]);
	}
      }

      from=to;
    }
    cout<<*min_element(dp[r-1].begin(),dp[r-1].end())<<endl;
  }
  return 0;

}

Measured memory_bytes: 6544
L, R = map(int, input().split())
mod = 2019

if R - L >= mod:
    print(0)
else:
    L = L % mod
    R = R % mod
    if L >= R:
        print(0)
    else:
        ans = float('inf')
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                ans = min(ans, (i * j) % mod)
        print(ans)


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005


int32_t main(){
sp;
    int n;
    cin>>n;
    int a[n];
    int mx1=INT_MIN,mx2=INT_MIN;
    for(int i=1; i<=n; ++i){
        cin>>a[i];
        if(a[i]>mx1){
            mx2=mx1;
            mx1=a[i];
        }
        else if(a[i]>mx2)
            mx2=a[i];
    }
    for(int i=1; i<=n; ++i)
        if(a[i]==mx1)
            cout<<mx2<<"\n";
        else
            cout<<mx1<<"\n";
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int INF = 1e9;

int n;

int main() {
   // 入力:
   cin >> n;
   vec<int> a(n);
   rep (i, n) { cin >> a[i]; }
   // 初期化
   vec<int> dp(n+1);
   fill(all(dp), INF);
   dp[0] = -1;

   for (int i = 1; i <= n; i++) {
      vec<int>::iterator ite = lower_bound(all(dp), a[i-1]);
      if (ite != a.end()) *ite = a[i-1];
   }
   int res = 0;
   for (int i = 0; i <= n; i++) {
      if (dp[i] != INF) res = i;
   }
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	cout<<s.substr(0,4)+" "+s.substr(4)<<endl;
}





Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;


int main() {
    cout << fixed << setprecision(15);
  long double L; cin>>L;
  cout<<(L/3)*(L/3)*(L/3);
}


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

int main()
{
    double a, b, c, s, l;
    cin >> a >> b >> c;
    double pi = acos(-1);
    l = sqrt(a * a + b * b - 2 * a * b * cos(c * pi / 180));

    cout
        << setprecision(8) << 0.5 * a * b * sin(c * pi / 180) << "\n"
        << setprecision(8) << l + a + b << "\n"
        << setprecision(8) << b * sin(c * pi / 180)
        << endl;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n;
    cin >> n;
    ll a[n];
    vector<P> ans,vec;
    bool flag1 = true,flag2 = true;

    rep(i,0,n){
        cin >> a[i];
        vec.push_back(P(a[i],i));
        if(a[i] < 0) flag1 = false;
        else flag2 = false;
    }

    if(!flag1 && !flag2){
        sort(vec.begin(),vec.end());
        if(abs(vec[n-1].fs) >= abs(vec[0].fs)){
            rep(i,0,n){
                a[i] += a[vec[n-1].sc];
                ans.push_back(P(vec[n-1].sc,i));
            }
            flag1 = true;
        }
        else{
            rep(i,0,n){
                a[i] += a[vec[0].sc];
                ans.push_back(P(vec[0].sc,i));
            }
            flag2 = true;
        }
    }

    if(flag1){ //すべて非負整数
        rep(i,0,n-1){
            a[i+1] += a[i];
            ans.push_back(P(i,i+1));
        }
    }
    else if(flag2){ 
        rep(i,0,n-1){
            a[n-i-2] += a[n-i-1];
            ans.push_back(P(n-i-1,n-i-2));
        }
    }
    

    cout << (ll)ans.size() << endl;
    rep(i,0,(ll)ans.size()){
        cout << ans[i].fs +1 << " " << ans[i].sc + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
li=[list(map(int,input().split()))for _ in range(N)]
li.sort()
n=0
price=0
for i ,j in li:
  n+=j
  price+=i*j
  if n>M:
    price-=i*(n-M)
    break
print(price)

Measured memory_bytes: 27760
#include <stdio.h>

int main () {
	int x;
	int a;
	int b;
	int total1;
	int total2;
	scanf("%d%d%d", &x, &a, &b);
	total1 = x-a;
	total2 = x-b;
	
	if(total1<0){
        total1 = total1 * -1;
}
	
	if(total2<0){
        total2 = total2 * -1;
    }

	if (total1>total2){
		printf("B");
	}
	if (total1<total2) {
		printf("A");
	}
		return 0;
	
	
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <random>
#include <complex>
#include <random>
 
using namespace std;

const int INF = 1e9 + 239;

int h, w;

set<pair<int, int>> bans;
set<pair<int, int>> tars;

vector<set<int>> ban;
vector<set<int>> tar;

void add_tar(int x, int y) {
    tars.insert({x - y, y});
}

void add_ban(int x, int y) {
    bans.insert({x - y, y});
}

void init() {
    set<pair<int, int>> ntars;
    for (auto t : tars) {
        if (!bans.count(t)) {
            ntars.insert(t);
        }
    }
    tars = ntars;
    ban.resize(h);
    tar.resize(h);
    for (auto t : tars) {
        tar[t.first].insert(t.second);
    }
    for (auto t : bans) {
        ban[t.first].insert(t.second);
    }
    for (int i = 0; i < h; i++) {
        ban[i].insert(w);
    }
}

void print() {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (tars.count({i, j})) {
                cout << 'T';
            } else if (bans.count({i, j})) {
                cout << 'B';
            } else {
                cout << '.';
            }
        }
        cout << endl;
    }
}

int getl(set<int> &pb, set<int> &cb, int pl) {
    while (pb.count(pl) || cb.count(pl)) {
        pl++;
    }
    return pl;
}

int getr(set<int> &pb, set<int> &cb, int pr) {
    while (pb.count(pr) || cb.count(pr)) {
        pr--;
    }
    return pr;
}

int trimr(set<int> &cb, int pr) {
    return *cb.upper_bound(pr) - 1;
}

int solve() {
    int ans = INF;
    set<int> pb;
    int l = 0;
    int r = 0;
    for (int i = 0; i < h; i++) {
        l = getl(pb, ban[i], l);
        r = getr(pb, ban[i], r);
        r = trimr(ban[i], r);
        for (auto x : tar[i]) {
            if (l <= x && x <= r) {
                ans = min(ans, i + x);
            }
        }
    }
    return ans;
}

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

    int n;
    cin >> h >> w >> n;
    while (n--) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (x >= y) {
            add_ban(x, y);
        }
        if (x > y) {
            add_tar(x - 1, y);
        }
    }
    init();
    // print();
    int ans = solve();
    cout << min(h, ans + 1) << endl;
}


Measured memory_bytes: 61056
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define vec vector<int>
#define mp make_pair
using namespace std;
int dp[100001],h[100001];
int ans(int n)
{
  if(n==1)
    return 0;
  if(dp[n]!=-1)
        return dp[n];
  if(n==2)
    return dp[n]=abs(h[n]-h[n-1])+ans(n-1);
  else
  {
    return dp[n]=min(abs(h[n]-h[n-1])+ans(n-1),abs(h[n]-h[n-2])+ans(n-2));
  }
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
        cin>>h[i];
    cout<<ans(n);
  }
}

Measured memory_bytes: 7448
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};

//a^n (mod m)
const ll mod = 1e9+7;
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

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

    ll n;
    cin>>n;
    ll a[n];
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        sum %= mod;
        ans += (sum+mod-a[i]) * a[i] % mod;
        ans %= mod;
    }
    ans *= modinv(2);
    ans %= mod;
    cout << ans << endl;
    
}   

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

int main(){
	string S;
	cin >> S;
	rep(i, 19){
		if(i != 5 && i != 13){
			cout << S.at(i);
		} else {
			cout << " ";
		}
	}
	cout << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second

const ll MOD=1000000007;

template<int sz=1<<17>
struct BIT{
	ll s[sz+2];
	void init(){
		for(int i=1;i<=sz;i++){
			s[i]=0;
		}
	}
	void add(int k,ll x){
		while(k<=sz){
			s[k]+=x;
			if(s[k]>=MOD)s[k]-=MOD;
			k+=k&-k;
		}
	}
	ll sum(int k){
		ll ret=0;
		while(k>0){
			ret+=s[k];
			k-=k&-k;
		}
		return ret%MOD;
	}
};

int main(){
	static int n,m;
	static int x[100010],y[100010];
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",&x[i]);
	for(int i=0;i<m;i++)scanf("%d",&y[i]);
	
	static int a[100010],b[100010];
	static vector<int> Y;
	for(int i=0;i<m;i++)Y.push_back(y[i]);
	sort(Y.begin(),Y.end());
	int cnt=0;
	for(int i=0;i<n;i++){
		if(x[i]<Y[0]||Y[Y.size()-1]<x[i])continue;
		a[cnt]=*lower_bound(Y.begin(),Y.end(),x[i])-x[i];
		b[cnt]=x[i]-*--lower_bound(Y.begin(),Y.end(),x[i]);
		cnt++;
	}
	static vector<int> A,B;
	for(int i=0;i<cnt;i++){
		A.push_back(a[i]);
		B.push_back(b[i]);
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	for(int i=0;i<cnt;i++){
		a[i]=lower_bound(A.begin(),A.end(),a[i])-A.begin();
		b[i]=lower_bound(B.begin(),B.end(),b[i])-B.begin();
		b[i]+=2;
	}
	static set<int> c[100010];
	for(int i=0;i<cnt;i++){
		c[a[i]].insert(b[i]);
	}
	static ll dp[100010];
	static BIT<1<<17> bit;
	bit.add(1,1);
	for(int i=0;i<cnt;i++){
		for(auto itr=c[i].end();itr!=c[i].begin();){
			--itr;
			ll ndp=bit.sum(*itr);
			bit.add(*itr,(ndp+MOD-dp[*itr])%MOD);
			dp[*itr]=ndp;
			//cerr<<i<<" "<<*itr<<" "<<ndp<<endl;
			//cerr<<bit.sum(1<<17)<<endl;
		}
	}
	cout<<bit.sum(1<<17)<<endl;
}



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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, m, k = 0;
    cin >> n >> m;

    string cur;

    for(int i = 0; i < n; ++i){
        cin >> cur;

        /*

        // Forgot to account the case where you go down but go back up again

        if(i > 0){
            for(int j = 1; j < m; ++j){
                if(prev[j] == '#' && cur[j] == '#' && cur[j - 1] == '#'){
                    cout << "Impossible";
                    return 0;
                }
            }
        }*/

        for(auto j : cur){
            if(j == '#')
                ++k;
        }

        //prev = cur;
    }

    if(k == n + m - 1)
        cout << "Possible";
    else
        cout << "Impossible";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
typedef long double ld;
signed main(){
  ld n=0,m=0,co=0,ans=0;
  ld d=0;
  cin >>n>>m;
  vector<int>aa(n);
  REP(i,n){
    cin >>aa[i];
   co+=aa[i];
  }
  SORT(aa);
  REVE(aa);
  d=co/(4*m);
  REP(i,n){
   if(aa[i]>=d){
   ans++;
     if(ans>=m){
     cout << "Yes";
       return 0;
     }
   }
  }
  cout <<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
int main(){bool*v=new bool[500000];int m,n=999999,o,c,d,i,e;memset(v,1,c=n/2+1);for(i=m=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;for(o=m*2+1,d=o*3;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(;!(std::cin>>n).eof();){if(n<3)e=n>1;else{c=(n&1?n:--n)/2+1;e=1;for(i=1;i<c;)e+=v[i++];}printf("%d\n",e);}delete[]v;}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
  int X, Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;
  return 0;
}



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

int main(void) {

  // 入力
  int n;
  scanf("%d",&n);
  int list[n];
  for(int i=0;i<n;i++){
    scanf("%d",&list[i]);
  }
  
  int matchCnt=0;
  for(int i=2;i<n;i++){
    if(list[i-2]<list[i-1]&&list[i-1]<list[i])matchCnt+=1;
    else if(list[i-2]>list[i-1]&&list[i-1]>list[i])matchCnt+=1;
  }
  
  printf("%d\n",matchCnt);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count=0;
  for(int i=0;i<(int)s.size();i++){
   if(s[i] == 'o'){
     count++;
   }
  }
  
  cout <<700+count*100<< endl;
  return 0; 
}

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

int main(){
  
  char c;
  cin >> c;

  char boin[] = {'a','e','i','o','u'};

  string ans = "consonant";
  rep(i, 5){
    if(c == boin[i]) ans = "vowel";
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    var vals = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
    int N=vals[0];
    int A=vals[1];
    int B=vals[2];
    Console.WriteLine(Math.Min(N*A,B));
    }
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
ll n,m;
ll fact[100004];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m;
    fact[0]=1;
    rep(i,1,100001) fact[i]=(i*fact[i-1])%M;
    if(abs(n-m) >=2){
        cout<<0<<endl;
        return 0;
    }
    if(n == m){
        cout<<((fact[n]*fact[m])%M * 2)%M<<endl;
    }
    else cout<<((fact[n]*fact[m])%M )%M<<endl;

}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int f(int y,int m,int d){
    return (y-1)/3*590+(y-1)%3*195+(m-1)/2*(39+!(y%3))+(m-1)%2*20+d;
}

int main(void){
    int n=in(),y,m,d;
    while(n--){
        y=in();
        m=in();
        d=in();
        print(f(1000,1,1)-f(y,m,d));
    }
    return 0;
}



Measured memory_bytes: 2108
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    s = S()
    a = s.count("a")
    b = s.count("b")
    c = 3-a-b
    if a&b&c:
        print("Yes")
    else:
        print("No")
#B
def B():
    a,b,k = LI()
    ans = []
    for i in range(a,min(a+k,b+1)):
        ans.append(i)
    for i in range(max(a,b-k+1),b+1):
        ans.append(i)
    ans = list(set(ans))
    ans.sort()
    for i in ans:
        print(i)

#C
def C():
    a,b,c = LI()
    ans = 0
    if a%2:
        if b%2:
            if not c%2:
                ans += 1
                a += 1
                b += 1
        else:
            ans += 1
            if not c%2:
                b += 1
                c += 1
            else:
                a += 1
                c += 1
    else:
        if b%2:
            ans += 1
            if not c%2:
                a += 1
                c += 1
            else:
                b += 1
                c += 1
        else:
            if c%2:
                ans += 1
                a += 1
                b += 1
    ans += (3*max(a,b,c)-a-b-c)//2
    print(ans)
#D
def D():
    q = I()
    for i in range(q):
        a,b = LI()
        x = int((a*b)**0.5)
        y = math.ceil((a*b)/x)-1
        ans = x+y-2
        if a==b:
            ans += 1
        print(ans)

#E
def E():
    s = S()
    f = {"N":0,"W":0,"S":0,"E":0}
    for i in s:
        f[i] = 1
    if f["N"]^f["S"]:
        print("No")
    elif f["W"]^f["E"]:
        print("No")
    else:
        print("Yes")
#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 40048
N, M = map(int, input().split())
import sys
PY = [list(map(int,sys.stdin.readline().rstrip().split())) for _ in range(M)]

# ken = {p[0] for p in PY}
# ken_d = {k:[] for k in ken}
ken_d = [[] for _ in range(N+1)]

rankdic = {} # 通し番号：県における順位

for i, p in enumerate(PY):
    # print(p)
    ken_d[p[0]].append([i, p[1]])

for k in range(N+1):
    ken_d[k].sort(key=lambda x:x[1])
    for i, v in enumerate(ken_d[k]):
        rankdic[v[0]] = i # 通し番号辞書に入れる

for i, p in enumerate(PY):
    x = rankdic[i] + 1
    print(str(p[0]).zfill(6) + str(x).zfill(6))


Measured memory_bytes: 57308
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	int a;
	string s;
	cin >> a >>s;
	if(a<3200) puts("red");
	else cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: i32,
        k: i32,
        x: i32,
        y: i32,
    }
    let ans = match n <= k {
        true  => n * x,
        false => k * x + (n - k) * y,
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int X, Y;
    string ans;
    cin >> X >> Y;
    ans = "No";

    for(int i = 0; i < 101; i++){
        for(int z = 0; z < 101; z++){
            if(i * 2 + z * 4 == Y && i + z == X) {
                ans = "Yes";
            }
        }
    }

    cout << ans << endl;

    return 0;
            
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;
typedef unsigned int uint;

int main() {
    int n;
    while (cin >> n, n) {
        uint num = n, sum = 0;
        uint p;
        for (int i=0; i<n; ++i) {
            cin >> p;
            sum += p;
        }
        vector<uint> joint;
        uint j;
        for (int i=0; i<n-1; ++i) {
            cin >> j;
            joint.push_back(j);
        }
        sort(joint.begin(), joint.end(), greater<uint>());
        uint res = sum * n;
        for (int i=0; i<n-1; ++i) {
            sum += joint[i];
            num -= 1;
            if (res < sum * num) {
                res = sum * num;
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

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

	int sum = 0;
	int ans = 1;

	for (int i = 0; i < N; i++) {
		cin >> L;
		sum += L;

		if (sum <= X) {
			ans++;
		}
	}

	cout << ans << "\n";

}

Measured memory_bytes: 256
# include<iostream>
 
using namespace std;
int main() {
  int M, D;
  cin >> M >> D;
  int cnt = 0;
  for(int im = 4; im <= M; ++im) {
    for(int id = 22; id <= D; ++id) {
      int d10 = id / 10;
      int d1 = id % 10;
      if(d1 < 2) { continue; }
      if(d10 < 2) { continue; }
      if(im == d10 * d1) {
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x , y, z , o ,x1=0,x2=0,x3=0 ;
	cin>>x>>y>>z>>o;
	if(x>=z)
	x1=x;
	else 
	x1=z;
    if(y<=o)
	x2=y;
	else
	x2=o;
	x3=x2-x1;
	if(x3<=0)
	cout<<"0";
	else
    cout<<x3;
	return 0;
	
	
}

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

int CalcString(string ss){
    int X[4];
    int result;
    for(int i=0; i<4; i++){
        //cout << "i ss " << ss.substr(2*i,1) << endl;
        X[i]=stoi(ss.substr(2*i,1));
    }
    result=X[0];
    for(int i=0; i<3; i++){
        if( ss[2*i+1]=='+' ){
            result+=X[i+1];
        }else if( ss[2*i+1]=='-' ){
            result-=X[i+1];
        }
    }
    return result;
}

int main(){
    string S,S2;
    cin >> S;
    string ans;
    string ops="+-";
    S2="0000000";
    for( int i=0; i<2; i++ ){
        for( int j=0; j<2; j++ ){
            for( int k=0; k<2; k++ ){
                S2[0]=S[0];
                S2[1]=ops[i];
                S2[2]=S[1];
                S2[3]=ops[j];
                S2[4]=S[2];
                S2[5]=ops[k];
                S2[6]=S[3];
                //cout << "S2= " << S2 << endl;
                //out << "result= " << CalcString(S2) << endl;
                if( CalcString(S2)==7 ){
                    S2.append("=7");
                    cout <<S2 <<endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	char Yes,No;
	1<=a<=100;
	1<=b<=100;
	1<=c<=100;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b+c||b==a+c||c==a+b)
	printf("%s","Yes");
	else
	printf("%s","No");
	return 0;
}

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

int main() {
  	int n,h,a,b;
  cin >> n >> h;
  vector<int> counter(n);
  for(int i = 0;i < h;i++){
    cin >> a >> b;
    counter.at(a-1)++;
    counter.at(b-1)++;
  }
  for (int k = 0;k < n;k++){
    cout << counter.at(k) << endl;
  }
  
  
}

Measured memory_bytes: 3604
#include <cstdio>
#include <exception>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;

const int CAP = 2e5;
const int N = 1e6;
const int T = 1e7;
const long long INF = 1LL << 60;

struct line {
	long long a;
	long long b;
	long long eval(long long x) {
		return a * x + b;
	}
};

bool vis[T];
line c[T];

void modify(int i, int l, int r, line a) {
	if (!vis[i]) {
		vis[i] = 1;
		c[i] = a;
		return;
	}
	int mid = (l + r) >> 1;
	if (a.eval(l) <= c[i].eval(l) && a.eval(r) <= c[i].eval(r)) {
		swap(c[i], a);
		return;
	}
	if (a.eval(l) >= c[i].eval(l) && a.eval(r) >= c[i].eval(r)) {
		return;
	}
	if (a.eval(l) < c[i].eval(l)) {
		swap(a, c[i]);
	}

	if (a.eval(mid) > c[i].eval(mid)) {
		modify(i * 2 + 1, mid, r, a);
	} else {
		swap(a, c[i]);
		modify(i * 2, l, mid - 1, a);
	}
}

long long value(int i, int l, int r, int x) {
	if (!vis[i]) {
		return INF;
	}
	if (l == r) {
		return c[i].eval(x);
	}
	long long ans = c[i].eval(x);
	int mid = (l + r) >> 1;
	if (x < mid) {
		return min(ans, value(2 * i, l, mid - 1, x));
	} else {
		return min(ans, value(2 * i + 1, mid, r, x));
	}
}

long long dp[N];

int main() {
	::ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	long long c;
	cin >> n >> c;
	for (int i = 0; i < n; ++i) {
		static long long h;
		cin >> h;
		if (i != 0) {
			dp[i] = value(1, 1, N, h) + c + h * h;
		}
		line cur = { -2 * h, dp[i] + h * h };
		modify(1, 1, N, cur);
		//cout << dp[i] << " ";
	}
	cout << dp[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 40704
n = int(input())
s = [input() for i in range(n)]

ans = [0] * 4

for i in s:
  if i == "AC":
    ans[0] += 1
  elif i == "WA":
    ans[1] += 1
  elif i == "TLE":
    ans[2] += 1
  else:
    ans[3] += 1
    
print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

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

struct node {
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x) {
  while(x -> left != NIL) {
    x = x -> left;
  }
  return x;
}

Node treeSearch(Node u, int k) {
  if(u == NIL || k == u -> key) {
    return u;
  }
  if(k < u -> key) {
    return treeSearch(u -> left, k);
  }
  else {
    return treeSearch(u -> right, k);
  }
}

Node treeSuccessor(Node x) {
  Node y;
  if(x -> right != NIL) {
    return treeMinimum(x -> right);
  }
  y = x -> parent;
  while(y != NIL && x == y -> right) {
    x = y;
    y = y -> parent;
  }
  return y;
}

void treeDelete(Node z) {
  Node y;
  Node x;
} 

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z -> key < x -> key) {
      x = x -> left;
    }
    else {
      x = x -> right;
    }
  }
  z -> parent = y;
  if(y == NIL) {
    root = z;
  }
  else if(z -> key < y -> key) {
    y -> left = z;
  }
  else {
    y -> right = z;
  }
}

void inorder(Node u) {
  if(u != NIL) {
    inorder(u -> left);
    printf(" %d", u -> key);
    inorder(u -> right);
  }
}

void preorder(Node u) {
  printf(" %d", u -> key);
  if(u != NIL) {
    if(u -> left != NIL) preorder(u -> left);
    if(u -> right != NIL) preorder(u -> right);
  }
}

main() {
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    scanf("%s", com);
    if(com[0] == 'f') {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    }
    else if(com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0] == 'd') {
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

struct box{
	int digit,cnt[10];
	box(){
		digit = 0;
		for(int i=0;i<10;i++){
			cnt[i]=0;
		}
	}
	bool operator >(const box other){
		if( digit != other.digit ) return digit > other.digit;
		for(int d = 9 ; d >= 1 ; --d ){
			if( cnt[d] != other.cnt[d] ) return cnt[d] > other.cnt[d];
		}
		return true;
	}
};
const int maxn = 1e4+10;
vector<box>dp(maxn);
vector<int>cost={0,2,5,5,4,5,6,3,7,6};
int32_t main(){
	IOS	
	int n,m;cin>>n>>m;
	for(int i = 0; i< m; i++){
		int d;cin>>d;
		for(int j = 0; j + cost[d] <= n ; j++ ){
			if( j && !dp[j].digit )continue;
			box cur = dp[j];
			cur.digit++;
			cur.cnt[d]++;
			//bug5( i , d , cur.digit , dp[j+cost[d]].digit , (dp[j+cost[d]] < cur) );
			if( cur > dp[j+cost[d]]  ){
				dp[j+cost[d]] = cur;
			}
		}
	}
	for(int d=9;d>=1;d--){
		while( dp[n].cnt[d] ){
			cout << d;
			dp[n].cnt[d]--;
		}
	}
	/*
	while( par[n] ){
		bug3( pard[n] , cost[pard[n]] , par[n] );
		n = par[n];
	}*/
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 3856
n = gets.to_i
a = gets.split.map &:to_i
dp = Array.new(n){ 10**12 }
dp[0] = 0

n.times do |i|
  (1..2).each do |j|
    next if i + j >= n
    k = (a[i+j] - a[i]).abs + dp[i]
    dp[i+j] = k if dp[i+j] > k
  end
end

puts dp[n-1]

Measured memory_bytes: 8836
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#define sorn(i, n) char((i == n-1)?'\n':' ')
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

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

    vector<int> info;
    while(n > 0) {
        int digit = n%26;
        info.push_back(digit-1);
        n /= 26;
    }

    rep(i, info.size() - 1) {
        if(info[i] < 0) {
            info[i] += 26;
            info[i+1]--;
        }
    }
    if(info[info.size() - 1] < 0) info.pop_back();
    reverse(all(info));

    string ans = "";
    for(int i : info) {
        ans += 'a' + i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
n=int(input())
d=[(0,0,0)]+[tuple(map(int,input().split())) for _ in range(n)]
ans = 'Yes'
for i in range(n):
	dt = d[i+1][0]-d[i][0]
	dd = abs(d[i+1][1]-d[i][1])+abs(d[i+1][2]-d[i][2])
	if dt < dd or dt%2!=dd%2:
		ans='No'
		break
print(ans)

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    priority_queue<double, vector<double>, greater<>> que;
    REP(i, N) {
        double v;
        cin >> v;
        que.push(v);
    }

    REP(i, N - 1) {
        double v1 = que.top();
        que.pop();
        double v2 = que.top();
        que.pop();

        que.push((v1 + v2) / 2);
    }

    printf("%.8f\n", que.top());

    return 0;
}


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

int main(){
    int a, b;
    int d, r;
    double f;

    cin >> a >> b;

    d = a/b;
    r = a%b;
    f = (double)a/(double)b;

    printf("%d %d %.8lf\n", d, r, f);

    return 0;
}

Measured memory_bytes: 1192
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Restricted
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  cin >> a >> b;

  int c = a + b;
  if (c >= 10) puts("error");
  else printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int H,W;
	int i,j;

	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) {
			break;
		}
		for (i = 0; i < H; ++i) {
			for (j = 0; j < W; ++j) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0
alphabets = [chr(97 + i) for i in range(26)]


ans = ""
for i in range(len(S) - 1):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s


ans += alphabets[(alphabets.index(S[-1]) + K) % 26]
print(ans)


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		vl s(n+1);
		rep(i,n) s[i+1]=s[i]+a[i];

		map<ll,ll> f;
		ll res=0;
		rep(i,n+1)
			res+=f[s[i]]++;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 15104
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		List<List<Integer>> adj = new ArrayList<>();
		int n = scan.nextInt();
		int m = scan.nextInt();

		for (int i = 0; i <= n; i++) {
			adj.add(i, new ArrayList<>());
		}

		for (int i = 1; i <= m; i++) {
			adj.get(scan.nextInt()).add(scan.nextInt());
		}

		int[] dp = new int[n + 1];
		int path = Integer.MIN_VALUE;
		
		for (int i = 1; i <= n; i++) {
			path = Math.max(path, findLongestPath(adj, i, dp));
		}
		System.out.println(path);

	}

	public static int findLongestPath(List<List<Integer>> adj, int node, int dp[]) {
		if (adj.get(node).size() == 0) {
			return 0;
		}

		if (dp[node] != 0) {
			return dp[node];
		}
		List<Integer> nbrs = adj.get(node);
		int path = Integer.MIN_VALUE;
		for (int nbr : nbrs) {
			path = Math.max(path, findLongestPath(adj, nbr, dp));
		}

		dp[node] = path + 1;
		return dp[node];

	}
}


Measured memory_bytes: 70296
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define _GLIBCXX_DEBUG
// head

int main(){
    char x,y;
    cin >> x >> y;
    if (x > y) cout << ">" << endl;
    else if (x == y) cout <<  "="  << endl;
    else  cout << "<" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
using namespace std;
const int N=5005;
int n,a[N];
ll f[N],A,B;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>A>>B;
	fo(i,1,n)cin>>a[i];
	a[n+1]=n+1;
	fo(i,1,n+1){
		int ct=0,ct2=0,mx=0;
		f[i]=1e18;
		fd(j,0,i-1)
			if(a[j]<a[i]){
				if(a[j]<mx){
					++ct2;
					continue;
				}
				f[i]=min(f[i],f[j]+A*ct+B*ct2);
				++ct2;mx=a[j];
			}else ++ct;
	}
	cout<<f[n+1];
}

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

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

int main() {
    int n; cin >> n;
    vector<int> p(n); rep(i, n) cin >> p[i];
    int cnt = 0;
    for(int i =0; i<n-2; i++){
        if(min(p[i], min(p[i+1], p[i+2])) != p[i+1] && \
           max(p[i], max(p[i+1], p[i+2])) != p[i+1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

long long gcd(int x,int y){
    return y?gcd(y,x%y):x;
}

int main(){
    long long A,B,C,D;
    scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
    long long lcm=C*D/gcd(C,D);
    printf("%lld",(B-A+1)-((B/C)-((A-1)/C))-((B/D)-((A-1)/D))+((B/lcm)-((A-1)/lcm)));
}


Measured memory_bytes: 128