akhauriyash/Code-Regression huggingface dataset:
a,b,c,x,y = map(int, input().split())

#ApかBp買ってからABpにする
ans = a*x+b*y
for i in range(1, max(x, y)+1):
    if i <= min(x, y):
        ans = min(ans, ans-a-b+2*c)
    else:
        if x < y:
            ans = min(ans, ans-b+2*c)
        else:
            ans = min(ans, ans-a+2*c)
print(ans)

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

struct st{
    ll b,l,u;
};
std::vector<st> sts(100010);

bool comp(const st &light,const st &r){
    return light.u*x-r.u*x-light.b*light.u+r.b*r.u+light.b*light.l-r.b*r.l > 0;
}

int main() {
    
    std::cin >> n>>x;
    
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> sts[i].b>>sts[i].l>>sts[i].u;
        sum += sts[i].b*sts[i].l;
    }
    sort(sts.begin(),sts.end(),comp);
    
    ll now = -1;
    
    vector<ll> d(n);
    vector<ll> d_sum(n);
    // std::cout << sum<<" sum" << std::endl;
    for (int i = 0; i < n; i++) {
        d[i] = (x-sts[i].b)*sts[i].u+sts[i].b*sts[i].l;

        if(i>0){
            d_sum[i] = d_sum[i-1]+d[i];
        }else{
            d_sum[i] = d[i];
        }
        // std::cout << i<<" "<<d_sum[i] << std::endl;
        if(d_sum[i] >= sum && now == -1){
            now = i;
        }
    }
    ll result = 1e10;
     // 中途半端になるやつ
    for (int i = 0; i < n; i++) {
        ll now_sum = sum;
        if( i <= now ){
            now_sum -= d_sum[now] - d[i];
        }else if(now>0){
            now_sum -= d_sum[now-1];
        }
        
        ll y = (now_sum+sts[i].b*sts[i].u-sts[i].b*sts[i].l +sts[i].u-1 )/sts[i].u;
        y = min(y,(now_sum+sts[i].l-1)/sts[i].l);

        if(0 <= y && y <= x){
            result = min(result,now*x+y);
        }
    }
    
    std::cout << result << std::endl;
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
  
  int x[101],top=0,i;
  char s[101];
  
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      top--;
      x[top]=x[top]+x[top+1];
    }
    else if(s[0]=='-'){
      top--;
      x[top]=x[top]-x[top+1];
    }
    else if(s[0]=='*'){
      top--;
      x[top]=x[top]*x[top+1];
    } 
    else{
      top++; 
      x[top]=atoi(s);
    } 
  }
  printf("%d\n",x[1]);
  
  return 0;
}



Measured memory_bytes: 2048
import sys, os, bisect

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n , k = f()
    a = f()

    ans = int(1e10)
    for i in range(n):
        if i+k-1<n:
            ans = min(ans,  abs(a[i]) + abs(a[i] - a[i+k-1]), abs(a[i+k-1]) + abs(a[i] - a[i+k-1]))

    print(ans)

solve()


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

int main(){

    ll t=1;

    while(t--){
        ll n;
        cin >> n;
        ll a[n], i;

        ll sw=0;

        for(i=0;i<n;i++){
            cin >> a[i];
            if(a[i] == 0)
            sw=1;
        }

    ll ans=1;

        if(sw==1){
            cout << 0 << endl;
            return 0;
        }


        for(i=0;i<n;i++){

            if( (1000000000000000000/ans) < a[i] ){
                    cout<<-1<<endl;
                    return 0;
            } else {
                ans *= a[i];
            }
        }

    cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4436
#include <iostream>

using namespace std;

int main(){
    long long a;
    long long b;
    cin >> a >> b;
    for(int i = 1; i <= b; i++){
        if((a * i) % b == 0){
            cout << a * i<< endl;
            return 0;
        }
    }
  	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,a,b = map(int, input().split())

    print(min(a*n, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62812
#include<bits/stdc++.h>
using namespace std;
int ara[300];
int main()
{
    int n;
    cin>>n;
    for(int i =0 ; i < n-1 ; i++ ) cin>>ara[i];
    
    int tot = ara[0];
    
    for(int i =0 ; i < n-1 ; i++ ) {
            
        tot += min(ara[i] , ara[i+1]);
    }
    tot += ara[n-2];
    cout<<tot<<endl;
    return 0;
    
}

Measured memory_bytes: 764
n, m, c = map(int, input().split())

B = [int(i) for i in input().split()]
count = 0
for j in range(n):
    sum = c
    A = [int(i) for i in input().split()]
    for i in range(m):
        sum += A[i] * B[i] 
    if sum > 0:
        count += 1

print(count)

Measured memory_bytes: 3060
def bunkai(num):
    a = []
    while num % 2 == 0:
        a.append(2)
        num //= 2
    f = 3
    while f * f <= num:
        if num % f == 0:
            a.append(f)
            num //= f
        else:
            f += 2
    a.append(num)
    if len(a) == 1:
        a.append(1)
    return a
def kake(klist):
    dst = 1
    for i in klist:
        dst *= i
    return dst
src = int(input())
kumi = bunkai(src)
kumiawase = []
for i in range(1, len(kumi)):
    for k in range(len(kumi) - i + 1):
        nums = kake(kumi[k:k + i])
        if nums not in kumiawase:
            kumiawase.append(nums)
dsti = []
for i in range(len(kumiawase)):
    dsti.append((src//kumiawase[i], kumiawase[i]))
fx = lambda x, y: len(str(x)) if len(str(x)) > len(str(y)) else len(str(y))
dst = min([fx(*i) for i in dsti])
print(dst)


Measured memory_bytes: 3064
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a,b,c=map(int,input().split())
print(min(a*b,c))

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



int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> s(n,vector<int>(n,-1));
    rep(i,n) {
        s[i][i] = 1;
        int a;
        cin >> a;
        rep(j,a) {
            int x, y;
            cin >> x >> y;
            x--;
            s[i][x] = y;
        }
    }
    
    int ans = 0;
    rep(i,1<<n) {
        vector<int> check(n,-1);
        int sum = 0;
        bool tf = true;
        
        rep(j,n) {
            if(i>>j & 1)
                check[j] = 1;
            else
                check[j] = 0;
        }
        
        rep(j,n) {
            if(check[j]) {
                sum++;
                rep(k,n) {
                    if(s[j][k] == -1) {
                        continue;
                    }
                    else {
                        if(check[k] != s[j][k]) {
                            //cout << j << " " << k << endl;
                            tf = false;
                            break;
                        }
                    }
                }
            }
            
            if(!tf)
                break;
        }
        if(tf) {
            //cout << i << endl;
            ans = max(ans, sum);
        }
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=55;
const ll INF=~0u>>2;
ll dp[2][N*N*2],n,a[N],A;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();A=read();
	for(int i=1;i<=n;++i) a[i]=read(),a[i]-=A;
	dp[0][2500]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=5000;++j) dp[i&1][j]=0;
		for(int j=0;j<=5000;++j){
			if(j+a[i]>=0) dp[i&1][j]+=dp[(i-1)&1][j+a[i]];
			dp[i&1][j]+=dp[(i-1)&1][j];
		}
	}
	printf("%lld",dp[n&1][2500]-1);
	return 0; 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

  #define cases int testcases;cin>>testcases; while(testcases--)
      


int32_t main()
{
       


    
     int n;
     cin >> n;
     int h[n+1];

     rep(i,1,n)
     {
      cin >> h[i];
     }

     int dp[n+1];

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

     rep(i,3,n)
     {
      dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
     }


     cout << dp[n];
   return 0;
} 

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int W, H, X, Y;

signed main()
{
  cin >> W >> H >> X >> Y;

  int cnt = 0;
  if((double)W/2 == (double)X && (double)H/2 == (double)Y) {
    cnt = 1;
  }

  printf("%.10f %d\n", (double)W*H/2.0, cnt);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

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

    if(a  - 2 * b<= 0) cout << 0 << endl;
    else cout << a  - 2 * b << endl;
}

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

typedef struct {
    int sp; // stack pointer
    int s_array[100];
} Stack;

void init_stack(Stack *S){
    S->sp = 0;
}

int is_empty(Stack *S){
    return S->sp == 0;
}

int pop(Stack *S){
    S->sp -= 1;
    return S->s_array[S->sp + 1];
}

void push(Stack *S, int x){
    S->sp += 1;
    S->s_array[S->sp] = x;
}


int main(void){
    Stack S;
    char str[10];
    int x, y;

    // initialize the stack
    init_stack(&S);

    while(scanf("%s", str) != EOF){
        if(str[0] == '+'){
            y = pop(&S);
            x = pop(&S);
            push(&S, x + y);
        }
        else if(str[0] == '-'){
            y = pop(&S);
            x = pop(&S);
            push(&S, x - y);
        }
        else if (str[0] == '*'){
            y = pop(&S);
            x = pop(&S);
            push(&S, x * y);
        }
        else{
            push(&S, atoi(str));
        }
    }
    
    printf("%d\n", pop(&S));

    return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
lint mod=1'000'000'007;
template<class T>using numr=std::numeric_limits<T>;
lint inverse(lint x){
    assert(x%mod);
    lint y=1,u=mod,v=0;
    while(x){lint q=u/x;u-=q*x;std::swap(u,x);v-=q*y;std::swap(v,y);}
    assert(x==0&&std::abs(u)==1&&std::abs(y)==mod&&std::abs(v)<mod);
    return v<0?v+mod:v;
}
lint normalized(lint x){if(x<=-mod||mod<=x)x%=mod;if(x<0)x+=mod;return x;}
struct mint{
    lint value;
    mint()=default;
    mint(lint x):value(normalized(x)){}
};
std::ostream&operator<<(std::ostream&os,mint x){return os<<x.value;}
mint operator+(mint x,mint y){lint z=x.value+y.value;if(mod<=z)z-=mod;return mint{z};}
mint operator-(mint x,mint y){lint z=x.value-y.value;if(z<0)z+=mod;return mint{z};}
mint operator*(mint x,mint y){return mint{x.value*y.value%mod};}
mint operator/(mint x,mint y){return mint{x.value*inverse(y.value)%mod};}
mint&operator+=(mint&x,mint y){return x=x+y;}
mint&operator-=(mint&x,mint y){return x=x-y;}
mint&operator*=(mint&x,mint y){return x=x*y;}
mint&operator/=(mint&x,mint y){return x=x/y;}
bool operator==(mint x,mint y){return x.value==y.value;}
bool operator!=(mint x,mint y){return x.value!=y.value;}
mint power(mint x,lint y){mint z=1;for(;y;y>>=1){if(y&1)z*=x;x*=x;}return z;}
struct factorials{
    lint sz;std::vector<mint>fact,finv;
    factorials(lint n):sz(n),fact(n),finv(n){
        fact.at(0)=1;
        for(lint i=1;i<n;i++)fact.at(i)=fact.at(i-1)*i;
        finv.at(n-1)=mint{1}/fact.at(n-1);
        for(lint i=n-1;i>=1;i--)finv.at(i-1)=finv.at(i)*i;
    }
    mint operator()(lint x)const{return fact.at(x);}
    mint inv(lint x)const{return finv.at(x);}
    mint binom(lint n,lint k){assert(0<=n&&n<sz);return k<0||n<k?0:fact.at(n)*finv.at(k)*finv.at(n-k);}
};
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>ckd(n,-1);
    lint a=-1,b=-1;
    for(lint i=0;i<=n;i++){
        lint x;std::cin>>x;x--;
        if(ckd.at(x)!=-1){
            a=ckd.at(x);
            b=n-i;
        }
        ckd.at(x)=i;
    }
    factorials fact(n+2);
    for(lint i=1;i<=n+1;i++){
        std::cout<<fact.binom(n+1,i)-fact.binom(a+b,i-1)<<'\n';
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ceils(ll x,ll y)
{
    ll ans=x/y;
    if(x%y)ans++;
    return ans;
}
int main()
{
    ll n;
    cin>>n;
    ll x,y;
    cin>>x>>y;
    ll a=x,b=y;
    for(ll i=1;i<n;i++)
    {
        cin>>x>>y;
        ll num=max(ceils(a,x),ceils(b,y));
        a=x*num;
        b=y*num;
    }
    cout<<a+b<<endl;
}


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

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;
    xs.insert(xs.begin(), 0);
    xs.push_back(0);

    int m;
    {
        auto nxs = xs;
        std::sort(nxs.begin(), nxs.end());
        nxs.erase(std::unique(nxs.begin(), nxs.end()), nxs.end());
        m = nxs.size();

        std::map<int, int> revx;
        for (int i = 0; i < m; ++i) {
            revx[nxs[i]] = i;
        }

        for (auto& x : xs) x = revx[x];
    }

    std::vector<bool> fall(n + 2, false);
    std::vector<std::vector<int>> pos(m);
    for (int i = 0; i <= n + 1; ++i) {
        pos[xs[i]].push_back(i);
    }

    int ans = 0, sum = 0;
    for (const auto& v : pos) {
        for (auto i : v) {
            fall[i] = true;
            if (i + 1 <= n + 1 && !fall[i + 1]) ++sum;
            if (i - 1 >= 0 && fall[i - 1]) --sum;
        }

        ans = std::max(ans, sum);
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 8856
#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);

    string a,b; cin >>a>>b;
    int ab = stoi(a+b);
    for (int n = 1; n*n <= ab; n++) {
        if (n*n==ab) {
            cout << "Yes" << endl;
            return 0;
        }
    } 
    cout << "No" <<endl;
}


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

int main()
{
    ll n,i,j,k,l=1ll,m;

    cin >> n;

    ll fuk = 0;

    string s;

    cin >> s;

    string tmp = "";
ll st;
    for(i=0;; i++)
    {
        if(s[i]=='.')
        {
            st = i;
            break;
        }

        tmp+=s[i];
    }

 //   cout << tmp <<endl;

    ll sz = tmp.size();
    ll mul=1;
    fuk = 0;
    for(i=sz-1; i>=0; i--)
    {
        fuk = (fuk+((tmp[i]-'0')*mul));
        mul = mul*10;
    }

    fuk = fuk*100;

    tmp = "";

    for(i=st+1;i<s.size();i++)
    {
        tmp +=s[i];
    }

sz =tmp.size();
mul = 1;
for(i=sz-1;i>=0;i--)
{
    fuk = (fuk+((tmp[i]-'0')*mul));
        mul = mul*10;
}

cout << (n*fuk)/100  << endl;


}


Measured memory_bytes: 3612
let str = require('fs').readFileSync('/dev/stdin', 'UTF-8').split(' ').map(Number);

const a = str[0];
const b = str[1];

const d = Math.floor(a / b);
const r = a % b;
const f = (a / b).toFixed(5);
console.log(d + ' ' + r + ' ' + f)


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

int main(){
    int n;
    cin >> n;
    
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout<<' '<<i;
            continue;
        }
        int x=i;
        while(x!=0){
            if(x%10==3){
                cout<<' '<<i;
                break;
            }
            x/=10;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,d,i,j,t=0,u=0;
   string x,y,z;
  set<int> s;
   cin>>a;
   i=a;
   while(a--){
      cin>>b;
      s.insert(b);
   }
   if(s.size()==i){
     cout<<"YES"<<endl;
   }
   else cout<<"NO"<<endl;
 return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long n, s;
	scanf("%lld%lld", &n, &s);
	if(n == s) {
		printf("%lld\n", n + 1);
		return 0;
	}
	int m = sqrt(n); m++;
	long long res = -1;
	for(int i = 2; i <= m; i++) {
		long long tmp = n, sum = 0;
		while(tmp) {
			sum += tmp % i;
			tmp /= i;
		}
		if(sum == s) {
			res = i;
			break;
		}
	}
	if(res < 0) {
		long long tmp = n - s;
			for(int i = 1; 1LL * i * i <= tmp; i++) {
				if(tmp % i == 0) {
					long long x = tmp / i + 1;
					long long b = s - i;
					if(n % x == s - i) {
						if(res < 0 || res > x) res = x;
					}
				}
			}
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<b && b<c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3084
import collections
n = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if L[i]+L[j] > L[k] and L[k]+L[j] > L[i] and L[i]+L[k] > L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    ans += 1
print(ans)

Measured memory_bytes: 68796
#include <bits/stdc++.h>
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    Yes((a+b)==c||(a+c)==b||(b+c)==a);
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,ans;
bool prime[100000];
vector<long long> p;
long long x;

void Prime(){
	prime[0]=1;prime[1]=1;
	for(int i=2;i<=1000;i++){
		if(prime[i])continue;
		for(int j=i*2;j<100000;j+=i)prime[j]=1;
	}
	rep(i,100000) if(!prime[i]) p.push_back(i);
}

void A(){
	rep(i,p.size()){
		if(p[i]*p[i]>x)break;
		if(x%p[i]==0) return;
	}
	ans++;
}

int main(){
	Prime();
	scanf("%d",&n);
	rep(i,n){
		scanf("%lld",&x);
		x=x*2+1;
		A();
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1272
#include <iostream>

using namespace std;

struct Card {
    char suit, value;
};

void printCard(Card* a, int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) { cout << " "; }
        cout << a[i].suit << a[i].value;
    }
    cout << endl;
}

bool checkStable(Card* ref, Card* test, int n) {
    for (int i = 0; i < n; i++) {
        if (ref[i].value == test[i].value and ref[i].suit != test[i].suit) {
            return false;
        }
    }
    return true;
}

void swap(Card* a, Card* b) {
    Card tmp = *a;
    *a = *b;
    *b = tmp;
}

void bubbleSort(Card* a, int n) {
    for (int i = 1; i < n; i++) for (int j = n - 1; j >= i; j--) {
        if (a[j].value < a[j-1].value) {
            swap(&a[j], &a[j-1]);
        }
    }
}

void selectionSort(Card* a, int n) {
    for (int i = 0; i < n; i++) {
        int min_j = i;
        for (int j = i; j < n; j++) {
            if (a[j].value < a[min_j].value) {
                min_j = j;
            }
        }
        swap(&a[i], &a[min_j]);
    }
}

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

    auto c1 = new Card[n];
    auto c2 = new Card[n];
    for (int i=0; i<n; i++) {
        cin >> c1[i].suit >> c1[i].value;
        c2[i] = c1[i];
    }

    bubbleSort(c1, n);
    printCard(c1, n);
    cout << "Stable" << endl;

    selectionSort(c2, n);
    printCard(c2, n);
    if (checkStable(c1, c2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstdlib>
#include<string>
#include<stdlib.h>
#include<math.h>
using namespace std;

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


int main()
{
    char x,y;
    
    cin>>x>>y;
    if(x<y)cout<<"<"<<endl;
    else if(x>y)cout<<">"<<endl;
    else cout<<"="<<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;

typedef long long ll;

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

	int x;
	cin >> x;

	int ans = 1;
	for(int i = 2; i * i <= x; i++){
		int y = i * i;
		while(y * i <= x) y *= i;
		ans = max(ans, y);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int a[21][21]={};
		rep(i,n){
			int x,y; cin>>x>>y;
			a[x][y]=1;
		}

		int nowx=10,nowy=10;
		int m; cin>>m;
		rep(i,m){
			char c; int move; cin>>c>>move;
			rep(j,move){
				if(c=='N') nowy++;
				if(c=='E') nowx++;
				if(c=='W') nowx--;
				if(c=='S') nowy--;
				a[nowx][nowy]=0;
			}
		}

		string ans="Yes";
		rep(i,21)rep(j,21){
			if(a[i][j]==1) ans="No";
		}
		cout<<ans<<endl;

	}
	return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	bool isPrime[1000000]; 
	memset(isPrime, true, sizeof(isPrime));
	isPrime[1] = false;
	for(int i=2;i<1000000;i++){
		for(int j=2;i*j<1000000;j++) isPrime[i*j] = false;
	}
	int a, d, n;
	while(cin >> a >> d >> n){
		if(!a) break;
		int count = 1;
		for(int i=a;;i+=d){
			if(isPrime[i]){
				if(count == n) { cout << i << endl; break; }
				else count++;
			}
		}
	}
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__ << '\n';
#define MAX (ll)1e10
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main()
{
	ll i,n,j;
	ll a,b,c;
	cin >> n;
	ll dp[n][3];
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		if(i == 0)
		{
			dp[i][0] = a;
			dp[i][1] = b;
			dp[i][2] = c;
		}
		else
		{
			dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a;
			dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b;
			dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c;
		}
	}
	cout << *max_element(dp[n-1],dp[n-1] + 3) << '\n';	
}












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

int main(){
    int n;
    while(cin>>n){
        if(n==0){
            return 0;
        }
    vector<int> a(n,0);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    int ave=0;
    for(int i=0;i<n;i++){
        ave+=a.at(i);
    }
    ave=ave/n;
    int ans=0;
    for(int i=0;i<n;i++){
        if(a.at(i)<=ave){
            ans++;
        }
    }
    cout<<ans<<endl;
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool heihou(int N){
    bool f = false;
    for (int i = 0; i * i <= N; i++){
        if (i * i == N){
            f = true;
        }
    }
    return f;
}

int main() {

    int N, D; cin >> N >> D;
    
    int X[N][D];
    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){
            
            int sum = 0;
            for (int k = 0; k < D; k++){
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            if (heihou(sum) == true){
                ans++;
            }
            

        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
import math
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=(i+1)
a=sorted(a)  
if n%2==0:
    x=math.floor((a[int(n/2)]+a[int((n/2)-1)])/2)
else:
    x=a[int(n//2)]    
ans=0
for i in range(n):
    ans+=abs(a[i]-x)
print(ans)        
    
    
    
               
            
            
            
              

    
        

Measured memory_bytes: 26832
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int N,A[200100],B[200100];
signed main(){
  cin>>N;
  for(int i=0;i<200000;i++)A[i]=-1;
  B[0]=1;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    B[i+1]=(B[i]+(A[a-1]!=i && A[a-1]!=-1?B[A[a-1]]:0))%mod;
    A[a-1]=i+1;
  }
  cout<<B[N]<<endl;
}

Measured memory_bytes: 6760
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String num = br.readLine();
		String[] str = num.split(" ", 0);
		List<Integer> a = new ArrayList<>();
		a.add(Integer.parseInt(str[0]));
		a.add(Integer.parseInt(str[1]));
		a.add(Integer.parseInt(str[2]));
		Collections.sort(a);
		System.out.println((a.get(0)+a.get(1)));
	}
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF LLONG_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1000000007;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

struct edge {
	int from, to;
	ll cost;
	edge(int from, int to, int cost) : from(from), to(to), cost(cost) {};
};
vector<edge> es;
ll dist[1024];
int N, M;

void Bellman_Ford() {
	rep(i, N) rep(j, es.size()) {
		if (dist[es[j].from] != -INF && dist[es[j].to] < dist[es[j].from] + es[j].cost) {
			dist[es[j].to] = dist[es[j].from] + es[j].cost;
		}
	}
}

int main() {
	scanf("%d %d", &N, &M);
	rep(i, M) {
		int a, b;
		ll c;
		scanf("%d %d %lld", &a, &b, &c);
		--a; --b;
		es.push_back(edge(a, b, c));
	}
	fill(dist, dist + 1024, -INF);
	dist[0] = 0;
	Bellman_Ford();
	ll flag = dist[N - 1];
	Bellman_Ford();
	(flag >= dist[N - 1] ) ? printf("%lld\n", dist[N - 1]) : printf("inf\n");
	return 0;
}

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

long long gcd(long long x,long long y){
  if(max(x,y)%min(x,y)==0){
  return min(x,y);
  }
  else{
  return gcd(min(x,y),max(x,y)%min(x,y));
  }
}

int main(){
  int n;
  long long x;
  cin>>n>>x;
  vector<long long>y(n);
  for(int i=0;i<n;i++){
  int z;
  cin>>z;
  if(z>=x){
  y[i]=z-x;
  }
  else{
  y[i]=x-z;
  }
  }
  if(n<=1){
  cout<<y[0]<<endl;
  }
  else{
  long long ans=y[0];
  for(int j=1;j<n;j++){
  ans=gcd(ans,y[j]);
  }
  cout<<ans<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int A[51]; //袋の中に入ったビスケットの数
long long DP[51][2];
int main()
{
  int N,P;
  cin >> N >> P;

  for (int k = 0; k < 50; k++)
    for (int j = 0; j < 50; j++)
      DP[k][j] = 0;
  DP[0][0] = 1;

  for (int i = 1; i < N; i++)
    cin >> A[i];

  //動的計画法
  for (int i = 1; i <= N; i++){
    DP[i][0] += DP[i-1][0];
    DP[i][1] += DP[i-1][1];
    if (A[i]%2 == 0) {
      DP[i][0] += DP[i-1][0];
      DP[i][1] += DP[i-1][1];
    }
    else {
      DP[i][0] += DP[i-1][1];
      DP[i][1] += DP[i-1][0];
    }
  }

  cout << DP[N][P] << endl;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))

# wをなめていって、w[:i]とw[i:]の差の絶対値が小さいものを選べば良い。
# 累積和で高速化できるが、制約が弱いため不要
ans = float('inf')
for i in range(n):
    temp = abs(sum(w[:i]) - sum(w[i:]))
    if ans > temp:
        ans = temp
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
  long int n,m,d;
  double ans,a,b;
  cin >> n>>m>>d;
  a = (double)n;
  b = (double)m;
  if (d == 0){
    ans = (b-1)/a;
  }
  else{
    ans = (b-1)*2*(a-d)/(a*a);
  }
  printf("%.10f\n",ans);
}


Measured memory_bytes: 888
function Main(input) {
  input = input.trim()
  input = input.split("").map(Number);
  if(input[1]==input[2]&&(input[0]==input[1]||input[2]==input[3])) console.log("Yes")
  else console.log("No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


int main(){
	char matrix[52][52];
	int Matrix[52][52];
	int H,W;
	cin >> H >> W;
	for(int i=0;i<51;i++){
		for(int j=0;j<51;j++){
			Matrix[i][j] = 0;
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> matrix[i][j];
			if(matrix[i][j] != '#')continue;
			Matrix[i-1][j]++;
			Matrix[i][j-1]++;
			Matrix[i+1][j]++;
			Matrix[i][j+1]++;
			Matrix[i+1][j+1]++;
			Matrix[i-1][j-1]++;
			Matrix[i+1][j-1]++;
			Matrix[i-1][j+1]++;
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(matrix[i][j] == '#'){
				cout << "#";
			}else{
				cout << Matrix[i][j];
			}
		}
		cout << endl;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int a, b, c; cin >> a >> b >> c;

  int cnt = 0;
  for (int i = a; i <= b; ++i) {
    cnt += (c % i == 0);
  }
  print(cnt);

  return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;

int main() {
    ll A, B, C, K;

    cin >> A >> B >> C >> K;

    if (A > K){
        cout << K << endl;
    }
    else if (A + B >= K){
        cout << A << endl;
    }
    else cout << (2 * A - K + B) << endl;
}

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

constexpr double inf = 1e20;

int main() {
    int n, m, k;
    while(cin >> n >> m >> k, n) {
        const int max_len = n + k + 10;
        vector<double> t1(n), t2(n), V(m);
        vector<int> idx(max_len, -1);
        vector<double> gate_time(n);
        for(int i = 0; i < n; ++i) {
            int X, L, F, D, UD;
            cin >> X >> L >> F >> D >> UD;
            t1[i] = (double)L / D; // east -> west
            t2[i] = (double)L / F; // west -> east
            if(UD == 1) {
                swap(t1[i], t2[i]);
                gate_time[i] = t1[i];
            }
            idx[X] = i;
        }
        for(auto& v : V) cin >> v;

        vector<vector<double>> reach(m, vector<double>(max_len));
        for(int i = 0; i < m; ++i) {
            double cur = 0;
            for(int j = 0; j < max_len; ++j) {
                if(j == 0) {
                    cur = i / V[i];
                } else {
                    cur += 1 / V[i];
                }
                if(i != 0 && j + 1 < max_len) {
                    cur = max(cur, reach[i - 1][j + 1]);
                }
                reach[i][j] = cur;

                if(idx[j] != -1) {
                    const int id = idx[j];
                    const double enter = max(cur, gate_time[id]);
                    cur = enter + t2[id];
                    gate_time[id] = enter + t1[id] + t2[id];
                }
            }
        }

        cout << fixed << setprecision(10) << reach[m - 1][k] << endl;
    }
}



Measured memory_bytes: 3768
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;



public class Main {
	public static class FastReader {
			BufferedReader br;
			StringTokenizer root;
			
	 
			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	 
			String next() {
				while (root == null || !root.hasMoreTokens()) {
					try {
						root = new StringTokenizer(br.readLine());
					} catch (Exception addd) {
						addd.printStackTrace();
					}
				}
				return root.nextToken();
			}
	 
			int nextInt() {
				return Integer.parseInt(next());
			}
	 
			double nextDouble() {
				return Double.parseDouble(next());
			}
	 
			long nextLong() {
				return Long.parseLong(next());
			}
	 
			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception addd) {
					addd.printStackTrace();
				}
				return str;
			}
		}
	 
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static FastReader sc = new FastReader();
 
	static int mod = (int)(1e9+7),MAX=(int)(1e5+10);
	static List<int[]>[] edges;
	
	public static void main(String[] args) throws IOException{
	
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;++i) a[i] = sc.nextInt();
		Arrays.sort(a);
		long ans = 0;
		for(int i=0;i<k;++i) ans+=a[i];
		out.print(ans);
	    
	  out.close();
	}
}

Measured memory_bytes: 33284
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
  long long N;
  cin >> N;
  vector<long long> a;
  froop1(1,sqrt(N) + 1){
    if(N % i == 0){
      a.push_back(N / i);
    }
  }
  sort(a.begin(),a.end());
  int count = 0,c = a.at(0);
  while(c > 0){
	c /= 10;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18;

ll dp[42][2][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    ll G=0;
    for (int i=0;i<N;++i){
        cin >> A[i];
        if (i>=2) G^=A[i];
    }
    ll sum=A[0]+A[1];
    for (int i=0;i<42;++i){
        for (int j=0;j<2;++j){
            for (int k=0;k<2;++k){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[41][0][0]=0;
    map<pair<int,int>,pair<int,int>> to;
    to[{0,0}]={0,0}; to[{0,1}]={0,1};
    to[{1,0}]={1,1}; to[{1,1}]={0,0};
    to[{2,0}]={1,0}; to[{2,1}]={1,1};
    int g,s,a,ds,k,nk;
    for (int i=40;i>=0;--i){
        g=(G&1LL<<i)>>i,s=(sum&1LL<<i)>>i,a=(A[0]&1LL<<i)>>i;
        for (int j=0;j<2;++j){
            ds=j+(g^j);
            if (!to.count({ds,s})) continue;
            k=to[{ds,s}].first,nk=to[{ds,s}].second;
            if (a==j) dp[i][0][nk]=min(dp[i][0][nk],dp[i+1][0][k]);
            if (a==1&&j==0) dp[i][1][nk]=min(dp[i][1][nk],dp[i+1][0][k]+1);
            dp[i][1][nk]=min(dp[i][1][nk],(dp[i+1][1][k]<<1LL)+a-j);
        }
    }
    ll ans=min(dp[0][0][0],dp[0][1][0]);
    cout << (ans==A[0]||ans==INF?-1:ans) << '\n';
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int> s;
	int a, b, c, d, e,i,j,change;
	cin >> a >> b >> c >> d >> e;
	s.push_back(a);
	s.push_back(b);
	s.push_back(c);
	s.push_back(d);
	s.push_back(e);
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4-i; j++) {
			if (s[j] < s[j + 1]) {
				change = s[j];
				s[j] = s[j+1];
				s[j+1] = change;
			}
		}
    }
	cout << s[0] << " " << s[1] << " " << s[2] << " " << s[3] << " " << s[4] << endl;
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	string n; cin >> n;
	for(char c:n) 
	{
		if (c=='1') cout << 9;
		else cout << 1;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, M; cin >> N >> M;
  vector<pair<pair<int,int>, ll>> LRC(M);
  rep(i,M){
    cin >> LRC[i].first.first >> LRC[i].first.second >> LRC[i].second;
    LRC[i].first.first--;
    LRC[i].first.second--;
  }
  vector<vector<int>> G(N);
  vector<vector<ll>> CO(N);
  rep(i,M){
    G[LRC[i].first.first].pb(LRC[i].first.second);
    CO[LRC[i].first.first].pb(LRC[i].second);
  }
  rep(i,N-1){
    G[i+1].pb(i);
    CO[i+1].pb(0);
  }

  // ここからダイクストラ
  vector<ll> D(N, -1);
  vector<bool> used(N, false);
  priority_queue<pair<ll,int>,
                 vector<pair<ll,int>>,
                 greater<pair<ll,int>>> q;

  q.push({0,0});
  while(!q.empty()){
    pair<ll,int> nowNode = q.top(); q.pop();
    ll d = nowNode.first; int to = nowNode.second;
    if(used[to]) continue;
    used[to] = true;
    D[to] = d;
    rep(i, (int)G[to].size()){
      if(D[G[to][i]] != -1 && D[G[to][i]] <= D[to] + CO[to][i]) continue;
      q.push({D[to] + CO[to][i], G[to][i]});
    }
  }
  cout << D.back() << endl;
  return 0;
}


Measured memory_bytes: 15988
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#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<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
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(){
	int n,m;
	cin>>n>>m;
	if(n>m){
		cout<<0<<endl;
		return 0;
	}
	vvi dp(n+1,vi(n+1));
	ll MOD=1000000007;
	dp[1][1]=1;
	rep(q,m){
		vvi ndp(n+1,vi(n+1));
		loop(i,1,n+1)loop(j,1,n+1){
			if(i!=n)(ndp[i+1][j]+=dp[i][j]*(n-i))%=MOD;
			        (ndp[i  ][j]+=dp[i][j]*(i-j))%=MOD;
			        (ndp[i  ][i]+=dp[i][j]*(j  ))%=MOD;
		}
		dp=ndp;
	}
	cout<<dp[n][n]<<endl;
}









Measured memory_bytes: 1728
main::IO ()
main = do
    _ <- readLn::IO Int
    xs <- map read . words <$> getLine
    
    let two = length [x | x <- xs,x`mod`2 == 0,x`mod`4 /= 0] 
        four = length [x | x <- xs,x`mod`4 == 0] 
    putStrLn $ solve two four (length xs)


solve:: Int -> Int -> Int -> String
solve a b xs
    |a + b == 0 = "No" 
    |xs `div` 2 <= b = "Yes"
    |xs  == a + b  = "Yes"
    |xs - a <= 2 * b = "Yes"
    |otherwise = "No"



Measured memory_bytes: 33148
import itertools

h,w,k=map(int,input().split())
c=[list(input()) for i in range(h)]
ans=0
for filter_row in range(2**h):
  for filter_col in range(2**w):
    cnt=0
    for i in range(h):
      for j in range(w):
        if (filter_row>>i&1)!=0 and (filter_col>>j&1)!=0 and c[i][j]=='#':
          cnt+=1
    if cnt==k:
      ans+=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	string a, b;
	cin >> n >> a >> b;
	REP(i, n)cout << a[i] << b[i];
	cout << endl;
}



Measured memory_bytes: 256
/*input
4
1 1 2 3
1 2 3 3
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

const ll MX = 200005;
stack<ll> idx[MX];
ll f[MX];

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n; cin >> n;
	vector<ll> a(n);
	vector<pair<ll, ll> > b(n);
	for(ll i = 0; i < n; i++) {
		cin >> a[i];
		f[a[i]]++;
		idx[a[i]].push(i);
	}
	set<ll> d;
	for(ll i = 0; i < n; i++) {
		cin >> b[i].first;
		b[i].second = i;
		d.insert(b[i].first);
	}
	vector<ll> dis;
	for(auto val: d) {
		dis.push_back(val);
	}
	sort(dis.begin(), dis.end(), [&](ll x, ll y) -> bool {
		if(f[x] == f[y]) return x < y;
		return f[x] > f[y];
	});	
	queue<ll> dist;
	for(ll i = 0; i < dis.size(); i++) {
		dist.push(dis[i]);
	}
	sort(b.begin(), b.end(), [&](pair<ll, ll> x, pair<ll, ll> y) -> bool {
		if(f[x.first] == f[y.first]) return x.second < y.second;
		return f[x.first] > f[y.first];
	});
	vector<ll> ans(n);
	deque<pair<ll, ll> > pending;
	bool fi = true;
	for(ll i = 0; i < n; i++) {
		if(dist.size() && b[i].first == dist.front()) dist.pop();
		while(dist.size() && !idx[dist.front()].size()) dist.pop();
		if(dist.size()) {
			ll pos = idx[dist.front()].top();
			idx[dist.front()].pop();
			ans[pos] = b[i].first;
		}
		else {
			if(fi) {
				fi = false;
				for(ll i = 1; i <= n; i++) {
					while(idx[i].size()) {
						pending.push_back({i, idx[i].top()});
						idx[i].pop();
					}
				}
			}
			if(b[i].first == pending.front().first) {
				ans[pending.back().second] = b[i].first;
				pending.pop_back();
			}
			else {
				ans[pending.front().second] = b[i].first;
				pending.pop_front();
			}
		}
	}
	bool ok = true;
	for(ll i = 0; i < n; i++) {
		ok &= (a[i] != ans[i]);
	}
	if(ok) {
		cout << "Yes" << endl;
		for(ll i = 0; i < n; i++) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}




















Measured memory_bytes: 157904
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n : i32 = s.trim().parse().ok().unwrap();
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let k : i32 = t.trim().parse().ok().unwrap();

    let mut ans = 1;
    for _i in 0..n {
        if ans < k {
            ans *= 2;
        }
        else {
            ans += k;
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352