akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};


template<typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, int s){
    
    int n = g.size();
    // numeric_limits がうまく使えない場合は自分で INF を定義する.
    const auto inf = numeric_limits<T>::max();
    vector<T> dist(n, inf);

    using P = pair<T, int>;
    // 小さい順に取り出せる
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()){
        T cost;
        int node;
        tie(cost, node) = que.top();
        que.pop();
        if(dist[node] < cost) continue;
        for(auto &e : g[node]){
            auto next_cost = cost + e.second;
            int next_node = e.first;
            if(dist[next_node] <= next_cost) continue;
            dist[next_node] = next_cost;
            que.emplace(next_cost, next_node);
        }
    }

    return dist;
}

signed main(){
    
    int V, E, R; cin >> V >> E >> R;
    vector<vector<pair<int, int>>> g(V);
    for(int i = 0; i < E; i++){
        int a, b, c; cin >> a >> b >> c;
        g[a].push_back({b, c});
    }

    auto result = dijkstra<int>(g, R);
    for(int i = 0; i < V; i++){
        if(result[i] == numeric_limits<int>::max()) puts("INF");
        else printf("%lld\n", result[i]);
    }
    return 0;
}



Measured memory_bytes: 19368
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;


int main(void)
{
    long long n,ans = 0;

    cin >> n;
    
    for (long long i = 100;;i *= 1.01,ans++)
    {
        if (i >= n)
        {
            break;
        }
    }


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


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
const double PI = 3.141592653589793238463;
lli solve(){
    vll k = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    lli n;
    cin>>n;
    cout<<k[n-1]<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    ll H, W;
    cin >> H >> W;

    ll ans = INF;

    //分割方法を全パターン試す

    //縦に3枚スライス
    if(W >= 3)
    {
        ll diff = W % 3 == 0 ? 0 : 1;
        chmin(ans, diff * H);
    }

    //横に3枚スライス
    if (H >= 3)
    {
        ll diff = H % 3 == 0 ? 0 : 1;
        chmin(ans, diff * W);
    }

    //縦のT字分割
    {
        //上下2分割
        reple(i, 1, H - 1)
        {
            vll v(3);
            v[0] = i * W;

            //下側を左右2分割（右側を大きくする）
            v[1] = (H - i) * (W / 2);
            v[2] = (H - i) * (W / 2 + W % 2);

            auto x = *max_element(all(v));
            auto y = *min_element(all(v));
            chmin(ans, x - y);
        }
    }

    {
        //左右2分割
        reple(i, 1, W - 1)
        {
            vll v(3);
            v[0] = i * H;

            //右側を上下2分割（下側を大きくする）
            v[1] = (W - i) * (H / 2);
            v[2] = (W - i) * (H / 2 + H % 2);

            auto x = *max_element(all(v));
            auto y = *min_element(all(v));
            chmin(ans, x - y);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int Solve(int n, int h, int w, const vector<int>& a, const vector<int>& b) {
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= h && b[i] >= w)
      ++ret;
  }
  return ret;
}

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> b[i];
  cout << Solve(n, h, w, a, b) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,n,t,x,s;
    scanf("%d %d %d",&a,&n,&t);
    if(a % n == 0){
        s = a / n;
    }
    else {
        s = (a / n) + 1;
    }
    x = s * t;
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 3832
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int n,w,we[105],v[105],f[100005];
int  va;
int main()
{
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    
    {
    	scanf("%d%d",&we[i],&v[i]);
    	va+=v[i];
	}
    for(int i=1;i<=va;i++)
    f[i]=w+1;
    for(int i=1;i<=n;i++)
    {
    	for(int c=va;c>=v[i];c--)
    	{
    		f[c]=min(f[c-v[i]]+we[i],f[c]);
		}
	}
	for(int i=va;i>=1;i--)
	if(f[i]<=w)
	{
		cout<<i<<endl;
		return 0;
	}
		
	
    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from operator import itemgetter

N=int(input())
T=[list(map(int,input().split()))+[i] for i in range(N)]

YtoN=[-1]*(N+1)
for x,y,n in T:
    YtoN[y]=n

T.sort(key=itemgetter(0))
MAX=N
MAXUSE=0
MIN=10**6
left=0

ANS=[-1]*N

for i in range(N):
    x,y,n=T[i]

    if y==MAX:
        MAXUSE=1
        
    MIN=min(y,MIN)

    #print(i,MAX,MIN,MAXUSE,left)

    if MAXUSE==1 and MAX-MIN==i-left:
        for j in range(left,i+1):
            ANS[T[j][2]]=MAX-MIN+1

        MAX=MIN-1
        MAXUSE=0
        left=i+1

for ans in ANS:
    print(ans)


Measured memory_bytes: 120552
a, b, c, d = map(int, input().split())
if c <= a < d:
    if b >= d:
        print(d-a)
    elif c <= b <= d:
        print(b-a)

if a < c:
    if b >= d:
        print(d-c)
    elif c <= b <= d:
        print(b-c)
    elif b < c:
        print(0)
if d <= a:
    print(0)

Measured memory_bytes: 3064
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(q)]
ans = 0
for A in combinations_with_replacement(range(1, m+1), n):
  t = 0
  for a, b, c, d in abcd:
    if A[b- 1] - A[a -1] == c:
      t += d
  ans = max(ans, t)
print(ans)

Measured memory_bytes: 9132
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    string s=to_string(n);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------




































Measured memory_bytes: 3720
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, i;
    for(i=1; i<=3000; i++)
    {
      cin >> a >> b;
      if(a > b)
       { 
         a=a+b;
         b=a-b;
         a=a-b;
       }
    
     if(a==0,b==0)
     break;
       
    cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3004
n = int(input())
a = [int(i) for i in input().split()]

cnt = 0
for i in range(n - 1):
    last = n - i - 1
    for j in range(last):
        if a[j] > a[j + 1]:
            a[j], a[j + 1] = a[j + 1], a[j]
            cnt += 1
print(' '.join(map(str, a)))
print(cnt)




Measured memory_bytes: 5604
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        List<int> a = new List<int>(n);
        var input = ReadLine().Split();
        foreach (int i in EnumerableCommon.Range(n)) a.Add(int.Parse(input[i]));
        a.Add(0);

        int res = 0;
        foreach (int i in EnumerableCommon.Range(n))
        {
            if (a[i] == a[i + 1] && a[i] != 0)
            {
                res++;
                a[i + 1] = 0;
            }
        }

        WriteLine(res);
    }

    public static partial class EnumerableCommon
    {
        public static IEnumerable<int> Range(int count)
        {
            return Enumerable.Range(0, count);
        }
    }
}

Measured memory_bytes: 11220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B, C, D;

    scanf("%d%d%d%d", &A, &B, &C, &D);

    if(A + B > C + D){
        printf("Left\n");
    }else if(A + B == C + D){
        printf("Balanced\n");
    }else{
        printf("Right\n");
    }

    return 0;
}

Measured memory_bytes: 1644
import itertools
import math

N = int(input())
M = math.factorial(N)
X = [i for i in range(1, N + 1)]
Y = list(itertools.permutations(X))

P = tuple([int(x) for x in input().split()])
Q = tuple([int(x) for x in input().split()])
for i in range(M):
    if Y[i] == P:
        a = i
    if Y[i] == Q:
        b = i

ans = abs(a - b)
print(ans)

Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<int> e[100001];
vector<int> p[2];
int N, M;
int state[100001];

void path(int x, int index){
  state[x] = 1;
  p[index].push_back(x);
  for(int i = 0; i < e[x].size(); i++){
    if(state[e[x][i]] == 0){
      path(e[x][i], index);
      break;
    }
  }
}

int main(){
  cin >> N >> M;
  fill(state, state+N, 0);
  for(int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  path(0, 0);
  path(0, 1);
  cout << p[0].size() + p[1].size() - 1 << endl;
  for(int i = p[0].size()-1; i >= 0; i--){
    cout << p[0][i]+1 << " ";
  }
  //cout << endl;
  for(int i = 1; i < p[1].size(); i++){
    cout << p[1][i]+1 << " ";
  }
  cout << endl;

  return 0;
}


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

string msg[3] = {"hon", "pon", "bon"};
double coeff[10] = { 1., 29639. / 630., -567859. / 5040., 9319711. / 90720., -138857. / 2880., 225023. / 17280., -3031. / 1440., 12161. / 60480., -211. / 20160., 83. / 362880. };

int calc(double x) {
	double y = 0, p = 1;
	for (int i = 0; i < 10; i++) {
		y += coeff[i] * p;
		p *= x;
	}
	return (int)round(y);
}

int main() {
	int n; cin >> n;
	cout << msg[calc(n % 10)] << endl;
}


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

struct Node{
    int k;
    int* c;
    int p;
};

int main(void){
    int n,i,j,id,k,depth;
    Node node[100000];
    
    cin>>n;
    
    for(i=0;i<n;i++){
        node[i].p=-1;
    }
    
    for(i=0;i<n;i++){
        cin>>id;
        cin>>k;
        node[id].k=k;
        node[id].c=(int*)malloc(sizeof(int)*k);
        for(j=0;j<k;j++){
            cin>>node[id].c[j];
            node[node[id].c[j]].p=id;
        }
    }
    
    for(i=0;i<n;i++){
        id=i;
        k=node[i].k;
        depth=0;
        while(node[id].p!=-1){
            id=node[id].p;
            depth++;
        }

        printf("node %d: parent = %d, depth = %d, ",i,node[i].p,depth);
        if(node[i].p==-1){
            printf("root, ");
            
            if(k==0){
                printf("[]\n");
                return 0;
            }
            
            printf("[");
            for(j=0;j<k-1;j++){
                printf("%d, ",node[i].c[j]);
            }
            printf("%d]",node[i].c[k-1]);
        }
        else if(k>0){
            printf("internal node, ");
            printf("[");
            for(j=0;j<node[i].k-1;j++){
                printf("%d, ",node[i].c[j]);
            }
            printf("%d]",node[i].c[k-1]);
        }
        else{
            printf("leaf, []");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 8968
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
using namespace std;

std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
    return result;
}

string trans(int i){
  string s;
  switch (i) {
    case 0:s="0";break;
    case 1:s="1";break;
    case 2:s="2";break;
    case 3:s="3";break;
    case 4:s="4";break;
    case 5:s="5";break;
    case 6:s="6";break;
    case 7:s="7";break;
    case 8:s="8";break;
    case 9:s="9";break;
  }
  return s;
}

int main(){
  int num;
  std::cin >> num;
  int ch[1000]={};
  string n;
  std::cin >> n;
  int po[3];




  for (int i = 0; i < 10; i++) {
    po[0]=n.find(trans(i));
    if(po[0]==-1 || po[0]+1>n.length())continue;

    for (int i2 = 0; i2 < 10; i2++) {

      po[1]=n.find(trans(i2),po[0]+1);
      if(po[1]==-1 || po[2]+1>n.length())continue;

        for (int i3 = 0; i3 < 10; i3++) {
          po[2]=n.find(trans(i3),po[1]+1);
          if(po[2]!=-1){
            string an=trans(i)+trans(i2)+trans(i3);
            int  num=atoi(an.c_str());
            ch[num]=1;
            //std::cout << num << '\n';
          }
        }

    }

  }

  int ans=0;
  for (int i = 0; i < 1000; i++) {
    if(ch[i]!=0)ans++;
  }
  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
		if(i%k==0)
		{
			puts("OK");
			return 0;
		}
	puts("NG");
	return 0;
}


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

int main(){

    int N, M;
    cin >> N >> M;

    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [[i for i in input()] for j in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            ct = 0
            for k in range(8):
                x = j + [0, 1, 0, -1, 1, 1, -1, -1][k]
                y = i + [1, 0, -1, 0, 1, -1, 1, -1][k]
                if 0 <= x < W and 0 <= y < H:
                    if S[y][x] == '#':
                        ct += 1
            S[i][j] = str(ct)

for i in S:
    print(''.join(i))


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


#define ll long long
#define pll pair <ll,ll>
#define fi first
#define se second
#define endl "\n"
#define sqr(b) (b)*(b)


using namespace std;



int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    ll n, k;
    ll a[111111], f[111111];

    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        f[i] = 2e9;
    }

    f[1] = 0;
    for (int i = 1; i <= n - 1; i++) {
        for (int j = 1; j <= k; j++)
            f[i + j] = min(f[i + j], f[i] + abs(a[i] - a[i + j]));
    }

    cout << f[n] << endl;

    return 0;
}


Measured memory_bytes: 5132
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int max(int a, int b) {
	if (a < b)return b;
	return a;
}
int min(int b, int a) {
	if (a > b)return b;
	return a;
}
int f(llint a) {
	int ans = 0;
	while (a) {
		a /= 2;
		ans++;
	}
	return ans;
}

int main() {
	string s;
	int k;
	cin >> k>>s;
	if (s.size() <= k)cout << s << endl;
	else {
		s = s.substr(0, k) + "...";
		cout << s << endl;
	}
	return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 9; i++) {
            String[] lines=sc.nextLine().split(" ");
            System.out.println(lines[0]+" "+(Integer.parseInt(lines[1])+Integer.parseInt(lines[2]))+" "+(Integer.parseInt(lines[1])*200+Integer.parseInt(lines[2])*300));
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e16+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n, m, arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n, arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len = v.size();
    for(int i = 0; i < len; ++i) {
        s<<v[i];
        if(i < len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len = vv.size();
    for(int i = 0; i < len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    rep(i, n) {
        REP(j,i+1,n){
            ll lv = 0;
            ll k =(i ^ j);
            while (!(k>>lv & 1LL)) {
                lv++;
            }
            cout<<lv+1<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
class union_find:
    def __init__(self, N):
        # 子なら親のインデックス、親ならunionのサイズを負数で格納
        self.par = [-1 for i in range(N)]
    
    def root(self, i):
        if self.par[i] < 0:
            return i
        else:
            # 経路圧縮
            self.par[i] = self.root(self.par[i])
            return self.par[i]
    
    def same(self, a, b):
        return self.root(a) == self.root(b)
    
    def unite(self, a, b):
        if not self.same(a, b):
            self.par[self.root(a)] += self.par[self.root(b)]
            self.par[self.root(b)] = self.root(a)

N, M = list(map(int, input().split()))
UF = union_find(N)
for _ in range(M):
    A, B = list(map(lambda x: int(x) - 1, input().split()))
    UF.unite(A, B)
    # print(UF.par)
print(-min(UF.par))

Measured memory_bytes: 85720
n = int(input())
p = list(map(int,input().split()))
nlst = [x for x in range(1,n+1)]
lst = [0]*n
#print(nlst,lst)
for i in range(n):
    if nlst[i] != p[i]:
        lst[i] = 1
    #print(lst)
print('YES' if sum(lst) in [0,2] else 'NO')

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


void solve(long long N, long long M){
    ll p =1;
    for(ll i=0; i< M; i++) p*=2;
    cout << (M*1900+(N-M)*100)*p << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


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

int main () {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3]) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			for(int i=2;i<1100;i++) {
				if((int)(i*0.08)==a  && (int)(i*0.1)==b) {
					System.out.println(i);
					return;
				}
			}
			
			
			System.out.println(-1);
			
		}

	}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int h = (b - a) * (b - a + 1) / 2 - b;
		System.out.println(h);

	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;


int main()
{
	int i, j, k,l, H, W, D, Q,sum;
	
	
	int x[90001];
	int y[90001];
	int A[300][300];
	int ans[90001] = {0};
	sum = 0;
	cin >> H >> W >> D;

	for (i = 0; i <= H - 1; i++) {
		for (j = 0; j <= W - 1; j++) {
			cin >> A[i][j];
		}
	}
	cin >> Q;
	vector<int>L(Q);
	vector<int>R(Q);
	for (i = 0; i <= Q - 1; i++) {
		cin >> L[i] >> R[i];
	}
	
	
		for (j = 0; j <= H - 1; j++) {
			for (k = 0; k <= W - 1; k++) {
				x[A[j][k]] = j + 1;
				y[A[j][k]] = k + 1;
			}
		}

		for (i = D + 1; i <= H * W; i++) {
			ans[i] = ans[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D]);
		}
		for(i=0;i<=Q-1;i++){
		cout << ans[R[i]]-ans[L[i]] << endl;
		
	}
    return 0;
}



Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int a,b,c,temp;
    cin>>a>>b>>c;
    if(a>b)
    {temp=a;
    a=b;
    b=temp;}
    if(a>c)
     {
         temp=a;
         a=c;
         c=temp;
     }
     if(b>c)
     {
         temp=b;
         b=c;
         c=temp;
     }
    printf("%d %d %d\n",a,b,c);

    return 0;
}



Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b); 
}
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	ll ans = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			for (int l = 1; l <= k; ++l) {
				ans += GCD(GCD(i, j), l);
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
	int n,a,b,c,d;
	scanf("%d",&n);
	a = n / 1000;
	b = (n - a * 1000) / 100;
	c = (n - (a * 1000 + b * 100)) / 10;
	d = n - (a * 1000 + b * 100 + c * 10);
	if (b == c && (a==b||c==d)) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
//#include<cstdio>
//#include<cstdlib>
#include <iostream>
#include <vector>
#include <queue>
//#include<bitset>
//#include<string>
//#include<stack>
//#include<set>
//#include<unordered_set>
//#include<map>
//#include<unordered_map>
//#include<cstring>
//#include<complex>
//#include<cmath>
//#include<iomanip>
//#include<numeric>
#include <algorithm>
#include <stdio.h>
//#include<list>
//#include<functional>
//#include<cassert>
using namespace std;
#define ll long long int
#define llu unsigned long long int
void pv(vector<ll> arr, ll size)
{

    for (ll i = 0; i < size; i++)
    {
        cout << arr[i] << ' ';
    }
}
void gv(vector<ll> &arr)
{
    ll size = arr.size();
    for (ll i = 0; i < size; i++)
    {
        cin >> arr[i];
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n + 1), b(n + 1), c(n + 1);
    ll arr[n + 1][3];
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (ll i = 0; i <= n; i++)
    {
        if (i == 0)
        {
            arr[0][1] = arr[0][2] = arr[0][0] = 0;
            continue;
        }
        arr[i][0] = max(arr[i - 1][1], arr[i - 1][2]) + a[i];
        arr[i][1] = max(arr[i - 1][0], arr[i - 1][2]) + b[i];
        arr[i][2] = max(arr[i - 1][1], arr[i - 1][0]) + c[i];
    }
    cout << max(arr[n][0], max(arr[n][1], arr[n][2]));
    return 0;
}

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

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

int main()
{
    string s;
    while (1)
    {

        int sum = 0;

        cin >> s;
        if (s == "0")
        {
            break;
        }
        rep(i, s.size())
        {
            sum += s.at(i) - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextInt();
		}
		insertionSort(A,N);



	}
	public static void insertionSort(int[] A, int N) { // N個の要素を含む0-オリジンの配列A
		for(int i = 0;i < N;i++) {
			int v = A[i];
			int j = i - 1;
			while(j >= 0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
				A[j+1] = v;
			}
			printArray(A);
		}
	}

	public static void printArray(int[] A) {
		for(int i = 0;i < A.length;i++) {
			System.out.print(((i==0)?"":" ") + A[i] + ((i==A.length-1)?"\n":""));
		}
	}
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  int tot = 0;
  for (int i = 0; i < n.length(); ++i) {
    tot += (int)(n[i] - '0');
  }

  cout << (stoi(n) % tot == 0 ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
    //入力
    int N;

    cin >> N;

    vector<int> a(N);
    
    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }

    //処理
    int cost,cost_min;
    cost=0;
    for(int i=0;i<N;i++){
        cost+=pow(a.at(i)+100,2);
    }
    cost_min=cost;

    for(int i =-99;i<101;i++){
        cost=0;
        for(int j=0;j<N;j++){
            cost+=pow(a.at(j)-i,2);
        }
        cost_min=min(cost,cost_min);
    }

    //出力
    cout << cost_min << endl;

}

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

int main()
{
  int n; cin >> n;
  for (int i=1; i<=n; i++) {
    int x = i * 1.08;
    if (n == x) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;

int a[maxn];

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        //memset(d,0,sizeof(d));
        for(int i=1;i<=k;i++)
        {
            a[i]=n/k;
        }
        int r=n%k;
        for(int i=1;i<=r;i++) a[i]++;
        ll ans=0;

        ans+=(ll)a[k]*(ll)a[k]*(ll)a[k];
        if(k%2==0)
            ans+=(ll)a[k/2]*(ll)a[k/2]*(ll)a[k/2];
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1024
loop do
    n = gets.to_i   
    break if n == 0
    rules = (1..n).map { gets.chomp.split }
    start = gets.chomp
    goal = gets.chomp
 
    queue = [start]
    k = 0 
    ok = false
    catch(:exit) do
        loop do
            next_queue = []
            until queue.empty?
                s = queue.pop
                if s == goal
                    ok = true
                    throw :exit
                end 
                next if s.size >= goal.size
                rules.each do |from, to|
                    if s =~ /#{from}/
                        next_queue << s.gsub(from, to) 
                    end
                end
            end 
            queue = next_queue
            break if queue.empty?
            k += 1
        end 
    end 
    puts ok ? k : -1
end

Measured memory_bytes: 11880
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {

	int n,x,t; cin >> n >> x >> t ;
	int ans = 0 ;
	while(n>0) n -= x , ans += t; 
	cout << ans ; 	
}
 
int32_t main() {
 

 
    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int POW[22];
	for(int i = 0; i < 22; i++)POW[i] = pow(2,i);

	ll N,M,A,B,P,Q;

	scanf("%lld %lld %lld %lld %lld %lld",&N,&M,&A,&B,&P,&Q);

	if(A == 1 && B == 1){

		ll num = M/(P+Q);

		if(num >= N){
			printf("%lld\n",M-N*(P+Q));
		}else{
			printf("%lld\n",min(M%(P+Q),(num+1)*(P+Q)-M)); //少し足りないと、少し多いの、差が小さい方
		}

		return 0;
	}

	vector<ll> FIRST;

	ll tmp = P+Q;
	ll a = 1, b = 1;
	ll count = 0,over_count = 0;

	double check;

	while(true){

		if(tmp > M)over_count++; //超過は1回だけ許す

		FIRST.push_back(tmp);
		count++;
		if(count == N || over_count == 1)break;

		check = P*a*A+Q*b*B;
		if(check > (double)M)break;

		a *= A;
		b *= B;

		tmp = P*a+Q*b;
	}

	//printf("count:%lld\n",count);

	//数字を2つのグループに振り分ける
	vector<ll> G[2];
	for(ll i = 0; i < FIRST.size(); i++){
		if(i <= (FIRST.size())/2){
			G[0].push_back(FIRST[i]);
		}else{
			G[1].push_back(FIRST[i]);
		}
	}

	int num[2];
	num[0] = (int)G[0].size();
	num[1] = (int)G[1].size();

	//printf("num_0:%d\n",num[0]);

	//各グループで数字を作る
	vector<ll> V[2];
	V[1].push_back(0);
	for(int group = 0; group < 2; group++){
		for(int state = 0; state < POW[num[group]]; state++){
			tmp = 0;
			for(int loop = 0; loop < num[group]; loop++){
				if(state & (1 << loop)){
					tmp += G[group][loop];
				}
			}
			V[group].push_back(tmp);
		}
		sort(V[group].begin(),V[group].end());
		V[group].erase(unique(V[group].begin(),V[group].end()),V[group].end());
	}

	ll ans = M,tmp_ans;

	int left,right,m,loc;

	for(int i = 0; i < V[0].size(); i++){

		if(V[0][i] >= M){
			ans = min(ans,V[0][i]-M);
			break;
		}

		//2分探索で、和がMを超えない、最大のindexを求める
		left = 0,right = (int)V[1].size()-1,m = (left+right);
		loc = 0;

		while(left <= right){
			if(V[0][i]+V[1][m] <= M){
				loc = m;
				left = m+1;
			}else{
				right = m-1;
			}
			m = (left+right)/2;
		}

		tmp_ans = (M-(V[0][i]+V[1][loc]));
		if(loc < (int)V[1].size()-1){
			tmp_ans = min(tmp_ans,V[0][i]+V[1][loc+1]-M);
		}
		//printf("i:%d tmp_ans:%lld\n",i,tmp_ans);
		ans = min(ans,tmp_ans);
	}

	printf("%lld\n",ans);

	return 0;
}



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int a,b;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> a >> b;

  cout << max(a+b,max(2*a-1,2*b-1)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<ll> H(N), P(N);
    rep(i, 0, N) {
        cin >> H[i] >> P[i];
    }
    vector<pair<ll, ll>> HP(N);
    rep(i, 0, N) {
        HP[i].first = H[i] + P[i];
        HP[i].second = i;

    }
    sort(all(HP));

    vector<vector<ll> > dp(N + 5, vector<ll>(N + 5, INFl));

    rep(i, 0, N) {
        dp[i][0] = 0;
    }
    rep(i, 0, N) {
        rep(j, 0, N) {
//            dp[i + 1][j + 1] = min(dp[i][j] + H[i], dp[i + 1][j + 1]);
//            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if(dp[i][j] <= H[HP[i].second]){
                dp[i + 1][j + 1] = min(dp[i][j] + P[HP[i].second], dp[i + 1][j + 1]);
            }
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    for(int j = N; j >= 0; j--){
        for(int i = 0; i <= N; i++){
            if(dp[i][j] != INFl){
                cout << j << endl;
                return 0;
            }
        }
    }


    return 0;
}


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

int main(){
    string s;
    int k;
    cin >> s;
    cin >> k;
    string s2;
    int l=s.size();
    vector <string> ans;

    int l2;
    l2=min(l,k);

    rep(i,l){
        rep(j,l2){
            s2=s.substr(i,j+1);
            ans.push_back(s2);
        }
    }

    sort(ans.begin(),ans.end());
    int ca=2;
    int i2=1;
    string s3=ans[0];
    if(k==1){
        cout << s3 << endl;
    }
    else{
    while(1){
        if(s3!=ans[i2]){
            if(ca==k){
                cout << ans[i2] << endl;
                break;
            }
            ++ca;
        }
        s3=ans[i2];
        ++i2;
    }
    }

    

    return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

class ss{
public:
    ll cost; // 名前
    int a;
    int b;
    int c;
    ss(ll cost, int a,int b,int c){ // コンストラクタ
        this->cost = cost;
        this->a = a;
        this->b = b;
        this->c = c;
    };
};

bool operator< (const ss &ss1, const ss &ss2){
    return ss1.cost < ss2.cost;
};

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

  ll x,y,z,k;
  cin >>x >>y >> z >>k;

  vector<vector <ll> > D;
  D = vector<vector<ll> >(3, vector<ll>(1000, 0));

  REP(j,x) cin >> D[0][j];
  REP(j,y) cin >> D[1][j];
  REP(j,z) cin >> D[2][j];
  REP(i,3) sort(D[i].rbegin(),D[i].rend());


  ll max;
  REP(i,3) max +=D[i][0];

  priority_queue<ss> q;
  q.push( ss (max,0,0,0 ));
  ll count=0;
  map<vector<int>,int > m;
  int a,b,c;

  while(count!=k){

    ss tmp=q.top();
    a=tmp.a;
    b=tmp.b;
    c=tmp.c;
    if(m[{a+1,b,c}]==0&&a+1<x){
      q.push(ss (  D[0][a+1] + D[1][b]   + D[2][c]  ,a+1,b,c) );
      m[{a+1,b,c}]++;
    }
    if(m[{a,b+1,c}]==0&&b+1<y) {
      q.push(ss (  D[0][a]   + D[1][b+1] + D[2][c]  ,a,b+1,c) );
      m[{a,b+1,c}]++;
    }
    if(m[{a,b,c+1}]==0&&c+1<z) {
      q.push(ss (  D[0][a]   + D[1][b]   + D[2][c+1],a,b,c+1) );
      m[{a,b,c+1}]++;
    }
    cout << D[0][a]+D[1][b]+D[2][c] <<endl;
    count++;
    q.pop();
  }
  return 0;
}


Measured memory_bytes: 1152
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define MOD 1E9+7
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}

int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    int r;
    cin>>r;
    float c;
    c=2*M_PI*r;
    cout<<setprecision(100)<<c;
    return 0;
}

Measured memory_bytes: 3808
a,b,c,d = map(int,input().split())
c1 , c2 = 0 , 0
while(a>0):
    a -= d
    c1 += 1
while(c>0):
    c  -= b
    c2 += 1

if c1>=c2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61784
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ll = long long;
using ii = pair<ll, ll>;

int32_t main(){
	ios::sync_with_stdio(0);	
	int n;
	ll d, a;
	cin >> n >> d >> a;
	d*=2LL;
	vector<ii> vs(n);
	for(auto &x:vs) cin >> x.ff >> x.ss;
	queue<ii> q;
	ll acc = 0;
	sort(all(vs));
	ll ans = 0;
	for(auto _x:vs){
		int x = _x.ff;
		int h = _x.ss;
		while(not q.empty() and q.front().ff<x) acc-=q.front().ss, q.pop();
		
		h = max(0LL, h-acc);
		ll k = (h+a-1)/a;
		ans += k;
		acc += a*k;
		q.push({x+d, a*k});

	}
	cout << ans << endl;
}


Measured memory_bytes: 6656
<?php
//error_reporting(0);
//$N = (int)trim(fgets(STDIN));
//$R = trim(fgets(STDIN));
list($S,$W) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($W >= $S) {
  printf("unsafe\n");
}
else {
  printf("safe\n");
}


Measured memory_bytes: 16124
A,B = map(int, input().split())
count = 0
for a in range(A,B+1,1):
    s = str(a)
    flg = 1
    for i in range(len(s)//2):
        if s[i]==s[-(i+1)]:
            continue
        else:
            flg = 0
            break
    if flg==1:
        count = count + 1
print(count)

Measured memory_bytes: 3060