akhauriyash/Code-Regression huggingface dataset:
n = int(input())
six_list = [1,6,36,216,1296,7776,46656]
nine_list = [1,9,81,729,6561,59049]
six_list.reverse()
nine_list.reverse()
rest = n
ans = n

#問題の条件に6の累乗だけでなく9の累乗もあるから話がややこしくなる（6と9の累乗をまとめたリストの大きいものから引き出していっても最適解にならない)
#そこで問題を分割するために、n円のうち、いくら分を6の累乗の形で引き出し、残りを9の累乗の形で引き出すかを全部試す

for a in range(n+1):
        
        six_rest = a #n円のうちa円を6の累乗の形で引き出す
        nine_rest = n-a
        count_6 = 0
        count_9 = 0
        for number in six_list:
                if six_rest//number >= 1:
                        count_6 += six_rest//number
                        six_rest -= six_rest//number * number
        for number in nine_list:
                if nine_rest//number >= 1:
                        count_9 += nine_rest//number
                        nine_rest -= nine_rest//number * number
        if ans > count_6 + count_9:
                ans = count_6 + count_9

print(ans)


Measured memory_bytes: 3064
object Main extends App {
  val n: Int = io.StdIn.readLine().toInt
  val arr: Array[String] = io.StdIn.readLine().split(' ')
  val arrInt: Array[Int] = arr.map(str => str.toInt)
  val map = scala.collection.mutable.Map[Int,Int]()
  for (x <- arrInt ) {
    map.put(x - 1, map.getOrElse(x - 1, 0) + 1)
    map.put(x,     map.getOrElse(x, 0) + 1)
    map.put(x + 1, map.getOrElse(x + 1, 0) + 1)
  }
  println(map.maxBy(_._2)._2)
}

Measured memory_bytes: 61724
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines[0]);
    var A = lines[1].split(" ").map(value => Number(value));

    for (var i = 0; i < N; i++) {
        for (var j = 0; j < N; j++) {
            result = Math.max(result,Math.abs(A[i] - A[j]));
        }
    }
    console.log(result);
});

Measured memory_bytes: 7872
n, t = map(int, input().split())
 
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
 
a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)
 
dp = [[0 for j in range(t)] for i in range(n+1)]
 
for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]
 
ans = 0
 
for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])
 
print(ans)


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

int main(){
  int n;
  int ans = 0;
  cin >> n;
  vector<int> pan;
  for(int i=0; i<n; ++i){
    int tmp;
    cin >> tmp;
    if(tmp%2==0){
      ans += tmp;
    }else{
      pan.push_back(tmp);
    }
  }
  sort(pan.begin(),pan.end(),greater<int>());
  if(pan.size()%2==0){
    for(auto i: pan){
      ans += i; 
    }
  }else{
    pan.pop_back();
    for(auto i: pan){
      ans += i;
    }
  }
  cout << ans/2 << endl;
}



Measured memory_bytes: 3164
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d%d", &a, &b);

    for(int i=0; i<=1100; i++){
        if( (int)(i*0.08) == a && (int)(i*0.10) == b ){
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 1736
N, A, B = map(int, input().split())
S = input()
passed = 0
passed_foreign = 0
ans = [False for _ in range(N)]

for i, human in enumerate(S):
    if human == 'a' and passed < A+B:
        passed += 1
        ans[i] = True
    if human == 'b' and passed < A+B and passed_foreign < B:
        passed += 1
        passed_foreign += 1
        ans[i] = True

for a in ans:
    print('Yes' if a else 'No')

Measured memory_bytes: 50080
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = float("inf")
for i in range(N - K + 1):
    res = min(
        abs(x[i]) + abs(x[i + K - 1] - x[i]),
        abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]),
    )
    ans = min(res, ans)
print(ans)


Measured memory_bytes: 14224
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<int,int>m;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  ---------------------------------MAIN-------------------------------------------*/

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int sum=0,temp=0;
	if(a>=k)
	{
		sum+=k;
		cout<<k<<endl;
		return 0;
	}
	else
	{
		k=k-a;
		sum+=a;
		if(b>=k)
		{
			// sum+=k;
			cout<<sum<<endl;
			return 0;
		}
		else
		{
			k-=b;
			// sum+=b;
			sum-=k;
			cout<<sum<<endl;
			return 0;
		}
	}

}

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

/* if文使いまくるやつ
int main()
{
	char s; cin >> s;
	char ans;

	if (s == 'A') ans = 'T';
	if (s == 'T') ans = 'A';
	if (s == 'C') ans = 'G';
	if (s == 'G') ans = 'C';

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


/* stringを2つ使ってやる方法
int main()
{
	char s; cin >> s;
	char ans;

	string before = "ATCG";
	string after = "TAGC";

	for (int i = 0; i < before.size(); i++)
	{
		if (s == before[i]) ans = after[i];
	}
	cout << ans << endl;
	return 0;
}
*/

// mapを使う方法
int main()
{
	char s; cin >> s;
	char ans;

	string before = "ATCG";
	string after = "TAGC";

	map<char, char> m;

	for (int i = 0; i < before.size(); i++)
	{
		m[before[i]] = after[i];
	}
	ans = m[s];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        mll v;
        rep(i, n){
            cin >> a;
            v[a - 1]++, v[a]++, v[a + 1]++;
        }
        ans = 0;
        each(p, v){
            maxs(ans, p.second);
        }
        print(ans);
    }
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,d;
  cin >> a >> b >>c >>d;
  cout << max(a*b, c*d) << endl;
  return 0;
    

}


Measured memory_bytes: 256
from collections import deque
import numpy as np
H,W = map(int,input().split())
maze = [input() for _ in range(H)]
ans = 0
for x in range(H):
  for y in range(W):
    if maze[x][y]=='#':
      continue
    dist = [[0]*W for i in range(H)]
    Q = deque([[x,y]])
    while Q:
      h,w = Q.popleft()
      for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
        h2,w2 = h+i,w+j
        if 0<=h2<H and 0<=w2<W and dist[h2][w2]==0 and maze[h2][w2]!='#':
          dist[h2][w2] = dist[h][w]+1
          Q.append([h2,w2])
    dist[x][y] = 0
    ans = max(ans, np.max(dist))
print(ans)

Measured memory_bytes: 27304
s = input()
t = input()
ss = [s+'a', s+'b', s+'c', s+'d', s+'e', s+'f', s+'g', s+'h', s+'i', s+'j', s+'k', s+'l', s+'m', s+'n', s+'o', s+'p', s+'q', s+'r', s+'s', s+'t', s+'u', s+'v', s+'w', s+'x', s+'y', s+'z']
if (t in ss):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9132
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 10 21:00:15 JST 2020
 **/

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

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

const Int INF = 1e18;
signed main() {
    Int n, m, X;
    std::cin >> n >> m >> X;
    std::vector<Int> c(n);
    auto a = make_vec<Int>(n, m, 0);
    REP(i, n) {
        std::cin >> c[i];
        REP(j, m) std::cin >> a[i][j];
    }
    Int ans = INF;
    REP(S, 1 << n) {
        std::vector<Int> acc(m);
        Int total = 0;
        REP(i, n) {
            if ((S >> i & 1) == 0) continue;
            total += c[i];
            REP(j, m) acc[j] += a[i][j];
        }
        if (std::all_of(acc.begin(), acc.end(), [&](Int x) { return x >= X; })) chmin(ans, total);
    }
    std::cout << (ans == INF ? -1 : ans) << std::endl;
}


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

int main() {
  int N;
  cin >> N;
  double ans;
  
  if (N % 2 == 0)
    ans = 0.5000000000;
  else
    ans = (double)((N/2)+1)/(double)N;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,m;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    if(n == 1){
        if(m == 1) cout<<1;
        else
            cout<<m - 2;
    }
    else{
        if(m == 1) cout<<n - 2;
        else{
            cout<<(n - 2) * (m - 2);
        }
    }
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int n = 1;
  for (int i = 0; i < N; i++) {
    if (n < K)
      n = 2 * n;
    else
      n = n + K;
  }
  cout << n << endl;
}
    


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

struct mo_t {
  int n;
  vector<pair<int, int>> lr;
  mo_t(int _n) : n(_n) {}
  void add(int l, int r) { lr.emplace_back(l, r); }
  template <class AL, class AR, class RL, class RR, class O>
  void run(AL add_left, AR add_right, RL remove_left, RR remove_right, O out) {
    int q = size(lr), bs = n / clamp<int>(sqrt(2 * q), 1, n);
    vector<int> ord(q);
    iota(begin(ord), end(ord), 0);
    sort(begin(ord), end(ord), [&](int i, int j) {
      auto [li, ri] = lr[i];
      auto [lj, rj] = lr[j];
      li /= bs, lj /= bs;
      return li != lj ? li < lj : li & 1 ? ri > rj : ri < rj;
    });
    int l = 0, r = 0;
    for (int i : ord) {
      auto [li, ri] = lr[i];
      while (l > li) add_left(--l);
      while (r < ri) add_right(r++);
      while (l < li) remove_left(l++);
      while (r > ri) remove_right(--r);
      out(i);
    }
  }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> c(n);
  for (auto&& e : c) cin >> e, --e;
  mo_t mo(n);
  vector<int> res(q), cnt(n);
  int cur = 0;
  auto add = [&](int i) {
    cur += cnt[c[i]]++ == 0;
  };
  auto remove = [&](int i) {
    cur -= --cnt[c[i]] == 0;
  };
  auto out = [&](int id) {
    res[id] = cur;
  };
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    mo.add(l, r);
  }
  mo.run(add, add, remove, remove, out);
  for (int e : res) {
    cout << e << '\n';
  }
}


Measured memory_bytes: 15468
# bellman_ford : O(V E)
# dijkstra : O(E log V), 負辺は無理
# warshall_floyd : O(V**3)

from collections import namedtuple
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


def solve():
    inf = 10 ** 14 + 10

    Edge = namedtuple('Edge', 'cost to')

    def dfs(v: 'vertex_index, 0-indexed') -> None:
        for e_ in e[v]:
            if d[e_.to] != inf:
                continue
            d[e_.to] = d[v] + e_.cost
            dfs(e_.to)

    n = int(input())
    e = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        e[a].add(Edge(cost=c, to=b))
        e[b].add(Edge(cost=c, to=a))

    q, v = map(int, input().split())
    v -= 1

    d = [inf] * n
    d[v] = 0

    dfs(v)

    for _ in range(q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        print(d[x] + d[y])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 165188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n,m; cin>>n>>m;
    Graph G(n);
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool>seen(n,false);
    ll gsize=0;
    vector<ll>gnum(n,0);
    rep(i,n){
        queue<ll>q;
        if(seen[i]==true)continue;
        seen[i]=true;
        q.push(i);
        while(!q.empty()){
            ll v=q.front();
            q.pop();
            for(auto nv:G[v]){
                if(seen[nv]==true)continue;
            seen[nv]=true;
            q.push(nv);
            gnum[gsize]++;
        }

        }
        gnum[gsize]++;
        gsize++;
     
    }
       gnum.resize(gsize);
       if(gsize==1){
           cout<<n<<endl;
           return 0;
       }
       sort(gnum.begin(),gnum.end());
       reverse(gnum.begin(),gnum.end());
       ll ans=gnum[0];
       cout<<ans<<endl;

}













































































Measured memory_bytes: 16540
import sys
n=[19890107,19261224,19120729,18680907]
for e in sys.stdin:
 y,m,d=map(int,e.split())
 t=y*1e4+m*100+d
 for i in range(4):
  if n[i]<t:print([f'heisei {y-1988}',f'showa {y-1925}',f'taisho {y-1911}',f'meiji {y-1867}'][i],m,d);break
 else:print('pre-meiji')


Measured memory_bytes: 5628
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[200000+2];
int cnt[2019];
int main(){
  int i;
  int tmp = 0;
  int mul = 1;
  long long res = 0;
  N = rd(S);
  cnt[tmp]++;
  for(i=(N)-1;i>=(0);i--){
    tmp = (tmp + (S[i] - '0') * mul) % 2019;
    mul = (mul * 10) % 2019;
    res += (cnt[tmp]++);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200430-1

// --- original code ---
// int N;
// char S[2d5+2];
// int cnt[2019];
// {
//   int tmp = 0, mul = 1;
//   ll res = 0;
//   rd(S@N);
//   cnt[tmp]++;
//   rrep(i,N){
//     tmp = (tmp + (S[i] - '0') * mul) % 2019;
//     mul = (mul * 10) % 2019;
//     res += (cnt[tmp]++);
//   }
//   wt(res);
// }


Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
//12 1 12
//12 2 6
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int ans = 1;
    REPS(i, sqrt(M))
    {
        if (M % i == 0)
        {
            if (i >= N)
            {
                ans = max(ans, M / i);
            }
            if (M / i >= N)
            {
                ans = max(ans, i);
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
char buf[10000000],out[11];
sz;
cnt[60];
main()
{
	read(0,buf,10000000);
	long N=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;buf[sz]>='0';)
	{
		long A=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A=A*10+k-'0';
		}
		for(int i=0;i<60;i++)
		{
			cnt[i]+=A&1;
			A>>=1;
		}
	}
	long ans=0;
	for(int i=59;i>=0;i--)
	{
		ans=ans*2+(N-cnt[i])*cnt[i];
		if(ans>3000000000000000000)ans%=1000000007;
	}
	ans%=1000000007;
	int outsz=10;
	do{
		out[--outsz]=ans%10+'0';
	}while(ans/=10);
	write(1,out+outsz,10-outsz);
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  map< ll, ll > m;
  ll l=4;
  while(l--)
  {
  	ll k;
  	cin>>k;
  	m[k]++;
  }
  if(m[1]&&m[9]&&m[7]&&m[4])
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2604
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

vector<int> s;
priority_queue <int,vector<int>,less<int> >q;


long long ans=0;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        s.push_back(x);
    }
    sort(s.begin(),s.end());
    int len=s.size();
    if(len==2)
    {
        cout<<s[len-1]<<endl;
        return 0;
    }
    q.push(s[len-2]);
    q.push(s[len-2]);
    ans+=s[len-1];
    for(int i=len-3;i>=0;i--)
    {
        ans+=q.top();
        q.pop();
        q.push(s[i]);
        q.push(s[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5552
// problem: "https://atcoder.jp/contests/abc123/tasks/abc123_b"

#include<iostream>
#include<vector>

using namespace std;

int main()
{
    vector<int>V(5);
    int i;

    for(i=0;i!=5;i++)
        cin>>V[i];

    int m = 10,s = 0;

    for(i=0;i!=5;i++)
    {
        if(V[i]%10==0)
        {
            s += V[i];
        }
        else
        {
            s += (V[i]+10-V[i]%10);
            m = min(m,V[i]%10);
        }
    }


    cout<<s-(-m+10);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 1000000007
using namespace std;
int main(){
	int n,ans=0;
	vector<string> s,cop;
	cin>>n;
	for(int i=0;i<n;i++){
		string x;
		cin>>x;
		s.push_back(x);
		cop.push_back(x);
	}
	for(int a=0;a<n;a++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cop[i][j]=s[(i+a)%n][j];
			}
		}
		int f=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(cop[i][j]!=cop[j][i])f=0;
			}
		}
		if(f==1)ans+=n;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  sort(ALL(a));
  if (a.front() > 0 && a.back() > 0) {
    vector<long long> x, y;
    long long tmp = a[0];
    FOR(i, 1, n - 1) {
      x.emplace_back(tmp);
      y.emplace_back(a[i]);
      tmp -= a[i];
    }
    x.emplace_back(a[n-1]);
    y.emplace_back(tmp);
    tmp = a[n-1] - tmp;
    cout << tmp << '\n';
    REP(i, n - 1) cout << x[i] << ' ' << y[i] << '\n';
  } else if (a.front() < 0 && a.back() < 0) {
    vector<long long> x, y;
    long long tmp = a[n-1];
    REP(i, n - 1) {
      x.emplace_back(tmp);
      y.emplace_back(a[i]);
      tmp -= a[i];
    }
    cout << tmp << '\n';
    REP(i, n - 1) cout << x[i] << ' ' << y[i] << '\n';
  } else {
    int idx;
    FOR(i, 1, n) {
      if (a[i] >= 0) {
        idx = i;
        break;
      }
    }
    vector<int> x, y;
    FOR(i, idx, n - 1) {
      x.emplace_back(a[0]);
      y.emplace_back(a[i]);
      a[0] -= a[i];
    }
    REP(i, idx) {
      x.emplace_back(a[n-1]);
      y.emplace_back(a[i]);
      a[n-1] -= a[i];
    }
    cout << a[n-1] << '\n';
    REP(i, n - 1) cout << x[i] << ' ' << y[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define int long long
int arr[123456],ans[123456];
int32_t main(){
	ios::sync_with_stdio();
	cin.tie(0);
	int n;cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	sum/=2;
	int even=0,odd=0;
	for(int i=0;i<n-1;i+=2) even+=arr[i];
	for(int i=1;i<n-1;i+=2) odd+=arr[i];
	ans[0]=sum-odd;ans[n-1]=sum-even;
	for(int i=1;i<n-1;i++) ans[i]=arr[i-1]-ans[i-1];
	for(int i=0;i<n;i++) cout<<2*ans[i]<<' ';
	cout<<endl;
}

Measured memory_bytes: 2816
# スペース区切りの整数の入力
n, y = map(int, input().split())

i = 0
j = 0
k = 0

l = [-1,-1,-1]
#print(l)

for i in reversed(range(0,n+1)):
    #print('i= %d' % i)
    if  y >= i*10000:
        for j in reversed(range(0,n-i+1)):
            #print('j= %d' % j)
            k = n - i - j
            #print('k= %d' % k)
            if  y == i*10000 + j*5000 + k*1000:
                l = [i, j, k]
                #print(l)

print(l[0], l[1], l[2])


Measured memory_bytes: 3064
x = int(input())

fives = [i**5 for i in range(10**5)]

for a5 in fives:
    b5 = abs(a5 - x)
    if b5 in fives:
        idx_a = fives.index(a5)
        idx_b = fives.index(b5)
        if a5 - b5 == x:
            pass
        if a5 + b5 == x:
            idx_b = -idx_b
        ans = [idx_a, idx_b]
        break
print(ans[0], ans[1])

Measured memory_bytes: 82424
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
        final long RISHI = s.nextLong();
        // int yokin = 100;
        double d_yokin = 100.0;
        int year = 0;

        while (d_yokin < RISHI) {
            d_yokin = Math.floor(d_yokin * 1.01);
            year++;
        }
        System.out.println(year);
  }
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l=a+b;
  int r=c+d;
  if(l<r){
    cout<<"Right"<<endl;
  }
  if(l==r){
    cout<<"Balanced"<<endl;
  }
  if(l>r){
    cout<<"Left"<<endl;
  }
 
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
long N, P; string S; cin >> N >> P >> S;
long i, ans=0;
if(P==2||P==5){ 
  for(i=0; i<N; i++){ if((S[i]-'0')%P==0){ ans+=(i+1); } }
  cout << ans << "\n"; return 0;
}
long c=0, t=1; vector<long> R(N+1);
for(i=N-1; i>=0; i--){ R[i]=(t*(S[i]-'0')+R[i+1])%P; t=(10*t)%P; }
sort(R.begin(), R.end());
for(i=0; i<=N; i+=c, c=0){
  while(i+c<=N&&R[i]==R[i+c]){ c++; }
  ans+=c*(c-1)/2;
}
cout << ans << "\n"; return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);

    for(int i = 0; i < n; ++i) cin >> w[i];

    int s1 = accumulate(w.begin(),w.end(),0),s2 = 0;

    int pre = abs(s1 - s2);

    for(int i = w.size() - 1; i > 0; --i){
        if(abs((s1 - w[i]) - (s2 + w[i])) < pre){
            s1 -= w[i];
            s2 += w[i];
            pre = abs(s1 - s2);
        }else{
            break;
        }
    }

    cout << pre << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long int lint;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  rep(i,n){
    if((a[i]%2==0)&&(a[i]%3!=0&&a[i]%5!=0)){
      cout<<"DENIED\n";
      return 0;
    }
  }
  cout<<"APPROVED\n";
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n);
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


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

  if(b <= a) cout << "delicious" << endl;
  else if(b <= a+x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
    
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);
ll s[200010];
ll l[200010];
ll r[200010];
int main()
{
    ll n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> s[i];
    for(int i = 1; i <= n; i++){
        if(i-s[i]>0){
            r[i-s[i]]++;
        }
        if(i+s[i]<=n){
            l[i+s[i]]++;
        }
    }
    ll cnt = 0;
    for(int i = 1; i <= n; i++){
        cnt += l[i]*r[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 8328
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  for( int i = 0; i < n1; i++ )L[i] = A[left + i];
  for( int i = 0; i < n2; i++ )R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right){
  if( left+1 < right){
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main(){
  int n,k,l[MAX];cin>>n>>k;
  for(int i=0;i<n;i++)cin>>l[i];
  mergeSort(l,n,0,n);
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=l[n-i-1];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    repeat(readLine()!!.toInt()){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        val map = Array(y + 1){ypos -> Array(x + 1){xpos -> Cross(Point(xpos, ypos))}}
        map[0][0] = Home
        for (i in 1 .. y) for (j in 0 .. x) map[i][j].addUpCross(map[i - 1][j])
        for (i in 0 .. y) for (j in 1 .. x) map[i][j].addLeftCross(map[i][j - 1])
        repeat(readLine()!!.trim().toInt()){
            val (x1, y1, x2, y2) = readLine()!!.trim().split(' ').map(String::toInt)
            map[maxOf(y1, y2)][maxOf(x1, x2)].remove(Point(minOf(x1, x2), minOf(y1, y1)))
        }
        println(if (map[y][x].countRoute() == 0L) "Miserable Hokusai!" else map[y][x].countRoute() )
    }
}
data class Point(val x:Int, val y:Int)
object Home:Cross(Point(0, 0)){
    override fun countRoute(): Long = 1
}
open class Cross(val position:Point){
    private var mRouteMemo:Long = -1
    private var mUpCross:Cross? = null
    private var mLeftCross:Cross? = null
    fun addUpCross(other:Cross):Unit {
        mUpCross = other
    }
    fun addLeftCross(other:Cross):Unit {
        mLeftCross = other
    }
    fun remove(point:Point):Unit {
        when (point.x){
            position.x -> mUpCross = null
            else -> mLeftCross = null
        }
    }
    open fun countRoute():Long {
        return when(mRouteMemo){
            -1L -> {
                mRouteMemo = mUpCross?.countRoute() ?: 0
                mRouteMemo += mLeftCross?.countRoute() ?: 0
                mRouteMemo
            }
            else -> mRouteMemo
        }
    }
}


Measured memory_bytes: 32492
open System

let N = stdin.ReadLine()|>int
let v = stdin.ReadLine().Split()|>Array.map double |>Array.sort
[<EntryPoint>]
let main argv =
    let rec av cur k = if k = N-1 then cur else av ((cur + v.[k+1])/2.0) (k+1)
    stdout.WriteLine (av v.[0] 0)
    0

Measured memory_bytes: 14176
A,B,K = map(int, input().split())
A = [i for i in range(1, (A+1)) if A%i==0]
B = [i for i in range(1, (B+1)) if B%i==0]
common_list = []
for i in A:
        for j in B:
                if i == j:
                        common_list.append(i)
print(common_list[-K])


Measured memory_bytes: 3060
#!/usr/bin/env python3

def main():
    x, y, a, b, c = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    p = list(reversed(sorted(p)))[:x]
    q = list(reversed(sorted(q)))[:y]
    pq = sorted(p + q)
    r = list(reversed(sorted(r)))
    for i in range(min(len(pq), len(r))):
        pq[i] = max(pq[i], r[i])
    print(sum(pq))

if __name__ == "__main__":
    main()


Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b;
  cin>>a>>b;
  vector<vector<int>> c(10,vector<int>(10)),d(a,vector<int>(b));
  fo(i,10){
    fo(j,10)
      cin>>c[i][j];
  }
  fo(i,a){
    fo(j,b)
      cin>>d[i][j];
  }
  vector<int> e(10);
  fo(k,10){
    fo(i,10){
      fo(j,10){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  int f=0;
  fo(i,a){
    fo(j,b){
      if(d[i][j]!=-1)
        f+=c[d[i][j]][1];
    }
  }
  cout<<f<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
	vector<int> a(5);
	int k;
	cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> a.at(4) >> k;

	for(int i=0; i<4; i++){
		for(int j=i+1; j<5; j++){
			if(abs(a.at(i)-a.at(j))>k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI (ld)3.14159265358979324
#define mp make_pair 
#define pb push_back
#define ft first
#define sd second
#define sz(a) (ll)a.size()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define loop(i, n) for(int (i) = 0; (i) < (n) ; ++ (i))
#define forn(i, l, r) for(int (i) = (l); (i) < (r) ; ++ (i))
#define vec vector 
#define str string
/*******************************************************/

void solve() {
    int n,x;
    cin >> n >> x;
    int all = 2*n - 1;
    if(x == 1 || x == all) {
        cout << "No";
        return;
    } 

    cout <<"Yes" <<endl;
    int mid = (all  + 1)/ 2 ;
    int dist = x - mid;
    if(dist == 0) {
        loop(i,all) {
            cout << i + 1 <<endl;
        }
        return;
    }

    vec<int> ans;
    ans.reserve(all);
    if(dist > 0) {
        forn(i,mid, x) {
            ans.pb(i);
        }
        loop(i,mid - dist - 1) {
            ans.pb(i + 1);
        }
        forn(i,x-1,all) ans.pb(i + 1);

        forn(i,mid - dist - 1,mid-1) {
            ans.pb(i + 1);
        }

        loop(i,all) {
            cout << ans[i] <<endl;
        }
        return;
    }

    dist *= -1;
    // cout << mid << endl;
    // return;
    forn(i,mid,mid+dist) {
        ans.pb(i + 1);
    }    

    forn(i,0,x) ans.pb(i+1);

    forn(i,mid+dist,all) ans.pb(i+1);
    forn(i,x,mid) ans.pb(i+1);
    loop(i,all) {
        cout << ans[i] <<endl;
    }

}

int main()
{
    // freopen("in.txt","r", stdin);
    ios_base::sync_with_stdio(false);   
    // cout << fixed;
    // cout.precision(3);

    solve();
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll dp[100][1000001];

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

    vector<int> wi(n), vi(n);
    for (int i=0; i<n; i++) {
        cin >> wi[i] >> vi[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    dp[0][wi[0]] = vi[0];

    for (int i = 1; i < n; i++) {
        for (int j=0; j<=w; j++) {
            if (dp[i-1][j] != -1) {
                if (dp[i][j] < dp[i-1][j]) {
                    dp[i][j] = dp[i-1][j];
                }
                if (j + wi[i] <= w && dp[i][j+wi[i]] < dp[i-1][j] + vi[i]) {
                    dp[i][j+wi[i]] = dp[i-1][j] + vi[i];
                }
            }
        }
    }

    ll maxval = 0;
    for (int i=0; i<=w; i++) {
        if (maxval < dp[n-1][i]) {
            maxval = dp[n-1][i];
        }
    }

    cout << maxval << endl;

    return 0;
}

Measured memory_bytes: 285696
while True:
    table = input().split()
    a = int(table[0])
    op = table[1]
    b = int(table[2])
    
    if op == '?':
        break
    
    if op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op =='/':
        print("%d"%(a/b))
    else:
        print("%d"%(a*b))


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

using namespace std;

int main()
{
	string S;
    cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size(); i++){
		
		if (S[i] == '1' ){
			ans++;
			
	}
	}
	cout << ans << endl;
}



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

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int just_count=0;
  for (int i=0;i*R<=N;i++){
    for (int j=0;j*G<=N;j++){
      int remainder=i*R+j*G;
      if ((N-remainder)%B==0 && N-remainder>=0){
        just_count++;
      }
    }
  }
  cout << just_count << endl;
}
    
    
    
    
  

Measured memory_bytes: 256
n = int(input())

steps = [int(i) for i in input().split()]
dp = ['inf'] * n

dp[0:2] = 0, abs(steps[0] - steps[1])

for i in range(2, n):
    if dp[i-2] + abs(steps[i] - steps[i-2]) >= dp[i-1] + abs(steps[i] - steps[i-1]):
        dp[i] = dp[i-1] + abs(steps[i] - steps[i-1])
    else:
        dp[i] = dp[i-2] + abs(steps[i] - steps[i-2])

print(dp[n-1])

Measured memory_bytes: 14056
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(N-1) << endl;
}

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(A>0 && C>0){
    A -= D;
    C -= B;
  }
  if(C<=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

int64 xsqrt(int64 v){
    int64 a = sqrt(v) - 2;
    while (a * a < v)
        a++;

    if (a * a > v) return -1;
    else return a;
}

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

    int n; cin >> n;

    map<vector<pair<int64,int>>, int> tot;

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

        vector<pair<int64,int>> r;

        for (int j = 2; j <= 2200; j++){
            int k = 0;

            while (v % j == 0){
                k++;
                v /= j;
            }

            k %= 3;

            if (k)
                r.push_back({j, k});
        }

        if (v > 1){
            auto sv = xsqrt(v);

            if (sv == -1){
                r.push_back({v, 1});
            } else {
                r.push_back({sv, 2});
            }
        }

        tot[r]++;
    }

    int answer = 0;

    for (auto cur : tot){
        int prev_answer = answer;

        if (cur.first.empty()){
            answer++;
        } else {
            auto rc = cur.first;
            for (auto &x : rc){
                x.second = 3 - x.second;
            }

            int64 tr = tot.find(rc) != tot.end() ? tot[rc] : 0;

            if (cur.second > tr || (cur.second == tr && cur.first[0].second == 1))
                answer += cur.second;
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 14592
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;

#define len 1010
static char s[len];

int main(int argc, char **argv)
{
	int sum, i;
	for (;;) {
		fgets(s, len, stdin);
		if (s[0] == '0' && (s[1] == '\0' || s[1] == '\n')) break;
		sum = 0;
		for (i = 0; s[i] != '\0' && s[i] != '\n'; i++) {
			sum += s[i] - '0';
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>

int primeNum(int n){
  int cout = 0, i, prime[1000000];
  for(i=1; i<=n; i++){
    prime[i] = 1;
  }
  prime[0] = 0;
  int j;
  for(i=1; i<n/i; i++){
    if(prime[i]==1){
      for(j= i+1; (i+1)*j <= n; j++){
        prime[(i+1)*j -1] = 0;
      }
    }
  }
  for(i=0; i<n; i++){
    if(prime[i] == 1){
      cout += 1;
    }
  }
  return cout;
}
int main(){
  int n;
  int list[50];
  int j = 0;
  while(scanf("%d", &n) != EOF){
    list[j] = primeNum(n);
    j += 1;
  }
  int i;
  for(i=0; i<j; i++)
    printf("%d\n", list[i]);
  return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> s;
  s[3] = '8';
  print(s);
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 62;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i += 2)cout << s[i]; cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int d;
    REP(i, 100){
        if(N <= bit(i)){
            d = i;
            break;
        }
    }
    if(N == bit(d)){
        Out("No");
        return 0;
    }

    //N>=3
    pairs ans;
    ans.pb(Pii(1, 3));
    ans.pb(Pii(3, 2));
    ans.pb(Pii(2, 1 + N));
    ans.pb(Pii(1 + N, 3 + N));
    ans.pb(Pii(3 + N, 2 + N));

    for(int i = 4; i <= N; i += 2){
        if(i == N){
            ans.pb(Pii(i, bit(d - 1)));
            int r = N ^ bit(d - 1) ^ 1;
            ans.pb(Pii(i + N, r + N));
        }else{
            ans.pb(Pii(i, 1));
            ans.pb(Pii(i + 1, i));
            ans.pb(Pii(i + 1 + N, i + N));
            ans.pb(Pii(i + 1 + N, 1 + N));
        }
    }

    Out("Yes");
    REP(i, 2 * N - 1) cout << ans[i].f << " " << ans[i].s << endl;

    return 0;
}


Measured memory_bytes: 6764
n,l=map(int,input().split())
list=[]
for i in range(1,n+1):
  a=i+l-1
  list.append(a)
A=sum(list)
cnt=0
for i in list:
  if i<0:
    cnt+=1
if cnt==n:
  print(A-list[-1])
elif 0 in list:
  print(A)
elif cnt==0:
  print(A-list[0])

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

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

    unsigned long long numW = 0;
    unsigned long long sumDistance = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S.substr(i, 1) == "W")
        {
            numW++;
            sumDistance += i + 1;
        }
    }
    if (numW == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << sumDistance - numW * (numW + 1) / 2 << endl;
    }
}


Measured memory_bytes: 640