akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;

#define fn(x)((x) == 0 ? 1 : 1 << ((x) - 1))

int getDigit(ll x)
{
    stringstream ss;
    
    ss << x;
    
    return ss.str().size();
}

int main() {
	ll S;
	
	scanf("%lld", &S);
	
	int size = getDigit(S);
	int NUM[size];
	size--;
	int i = size;
	int j;
	ll n;
	ll ans = 0;
	
	while (S) {
	    NUM[i--] = S % 10;
	    S /= 10;
	}
	
	for (i = 0; i <= size; i++) {
	    n = 0;
	    
	    for (j = i; j <= size; j++) {
	        n = n * 10 + NUM[j];
	        /////////////
	        // LOG //
	        /////////////
	        //printf("%lld\n", n * fn(i) * fn(size - j));
	        /////////////////////
	        // END LOG //
	        /////////////////////
	        ans = ans + n * fn(i) * fn(size - j);
	    }
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i, x, y;
    for(i = 1; 1; i++){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0 )
            break;
        if(x <= y)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
    }
    return 0;
}

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

typedef long long ll;
int main() {
  double tax = 1.08;
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double low, high;
  low = n / tax;
  high = (n + 1) / tax;
  int candidate = (int) high;
  if ((int) (candidate * 1.08) == n) cout << candidate << "\n";
  else cout << ":(";
  return 0;
}

Measured memory_bytes: 256
# inputList = list(map(int, '''6
# 5 2 4 6 1 3'''.split()))
# N = inputList.pop(0)


def formatting(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i], end=' ')
        else:
            print(nums[i])


def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]

            j-=1
        A[j+1] = v
        formatting(A)


N = int(input())
inputList = list(map(int, input().split()))

formatting(inputList)
insertionSort(inputList, N)



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

int n;
int a[100010];
map<int, int> x;

int modpow(int p, int q, int mod) {
	int res = 1;
	while (q > 0) {
		if (q & 1) {
			res = res * p % mod;
		}
		q >>= 1;
		p = p * p % mod;
	}
	return res;
}

signed main() {
	cin >> n;
	rep(i,n)
	{
		cin >> a[i];
		if ((n % 2) == (a[i] % 2)) {
			cout << 0 << endl;
			return 0;
		}
		if (++x[a[i]] == 3) {
			cout << 0 << endl;
			return 0;
		}
		if (a[i] == 0 && x[a[i]] == 2) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << modpow(2, x.size() - n % 2, 1000000007) << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N,M;
  cin>>N>>M;
  vl a(N),b(N),c(M),d(M);
  rep(i,N)cin>>a[i]>>b[i];
  rep(i,M)cin>>c[i]>>d[i];
  vi e(N);
  for(int i=0;i<N;i++){
    ll dis = 1000000000;
    for(int j=0;j<M;j++){
      if(abs(a[i]-c[j]) +abs(b[i]-d[j]) < dis ){
        e[i] = j+1;
        dis=abs(a[i]-c[j]) +abs(b[i]-d[j]);
      }
    }
  }
  rep(i,N)cout<<e[i]<<endl;
}
  
   





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;

//std::cout << std::setprecision(12) << s << '\n';
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

double dp[3003][3003][2];
double pre[3003];
ll n;
double a[3003];



int main()
{
    run;
    cin>>n;
    pre[0]=1;
    fr(i,1,n+1)
    {
        cin>>a[i];
        pre[i]=pre[i-1]*a[i];
       // a[i]=1.0-a[i];
    }

    dp[1][0][0]=1-a[1];
    dp[1][1][1]=a[1];
    dp[1][1][0]=0;



    fr(i,2,n+1)
    {
        fr(j,0,i+1)
        {
             dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])*(1-a[i]);
             if(!j)
             {
                 continue;
             }
             dp[i][j][1]=(dp[i-1][j-1][0]+dp[i-1][j-1][1])*a[i];
        }
    }

    ll p=n/2;
    p++;
    double s=0.0;
    fr(i,p,n+1)
    {
        s+=dp[n][i][0]+dp[n][i][1];
    }
    std::cout << std::setprecision(12) << s << '\n';







}


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

int main() {
	int a[100], n;

	cin >> n;

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

	for (int i = n - 1; i > 0; i--) {
		cout << a[i] << ' ';
	}
	
	cout << a[0] << endl;

	return 0;
}



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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int N = 10005;
signed main() {
	vector<bool>p(N, true);
	p[0] = p[1] = false;
	rep(i, 2, sqrt(N)) {
		if (p[i]) {
			for (int j = i + i; j < N; j += i) {
				p[j] = false;
			}
		}
	}
	int n;
	while (cin >> n, n) {
		int a, b;
		for (int i = n; i >= 0; i--) {
			if (p[i] && p[i - 2]) {
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3076
#include<stdio.h>
#include<string.h>

int main(void){
    char N[200001];
    int l,i,sum=0;

    scanf("%s",N);
    l = strlen(N);
    for(i=0;i<l;i++){
        sum = (sum+(N[i]-'0'))%9;
    }

    if(sum%9==0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1904
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;

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

	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n) ans += (i + 1) * (i + 2) / 2;
	rep(i, n - 1) {
		ll u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		ans -= u * (n + 1 - v);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
// using namespace std;
int N;
int i = 2;
int num;
char buf[8], out[20];
char k;
s;
size_t ii;
int main()
{
  s = read(0, buf, 8);
  for (;;)

  {
    k = buf[ii++];
    if (k < '0')
      break;
    N = N * 10 + k - '0';
  }
  // printf("%d\n", N);
  long long ans = (long long)N * (N + 1) - 1;

  for (; i * i <= N; i++)
  {
    num = N / i;
    // ans += (long long)(num - i + 1) * i * (i + num) - i * i;
    ans += (long long)i * ((long long)num * num - i * i + num);
  }
  printf("%lld\n", ans);
}


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

int work[400000][3];

int cmp(const void *a, const void *b) {
	const int *ai = a, *bi = b;
	return ai[0] - bi[0];
}

struct node {
	int n;
	struct node *l, *r;
};

void twalk(const struct node *root) {
	if (root == NULL) return;
	printf("walk: %d\n", root->n);
	twalk(root->l);
	twalk(root->r);
}

void tpush(struct node **root, int n) {
	//printf("push %d\n", n);
	while (*root)
		if ((*root)->n >= n) root = &(*root)->l;
		else root = &(*root)->r;

	*root = malloc(sizeof **root);
	(*root)->n = n;
	(*root)->l = NULL;
	(*root)->r = NULL;
}

void tpop(struct node **root, int n) {
	//printf("pop %d\n", n);
	while ((*root)->n != n)
		if ((*root)->n > n) root = &(*root)->l;
		else if ((*root)->n < n) root = &(*root)->r;

	struct node *c = NULL;
	if ((*root)->l == NULL) c = (*root)->r;
	else if ((*root)->r == NULL) c = (*root)->l;
	else {
		struct node **cp = &(*root)->r;
		while ((*cp)->l) cp = &(*cp)->l;
		(*root)->n = (*cp)->n;
		struct node *rem = *cp;
		if ((*cp)->l) *cp = (*cp)->l;
		else *cp = (*cp)->r;
		free(rem);
		return;
	}

	free(*root);
	*root = c;
}

int tmin(const struct node *root) {
	if (root == NULL) return -1;
	while (root->l) root = root->l;
	return root->n;
}

int main(void) {
	int n, q;
	scanf("%d%d", &n, &q);

	for (int i = 0; i < n; i++) {
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		work[i*2][0] = s-x;
		work[i*2][1] = 1;
		work[i*2][2] = x;
		work[i*2+1][0] = t-x;
		work[i*2+1][1] = 0;
		work[i*2+1][2] = x;
	}
	qsort(work, 2*n, sizeof work[0], cmp);

	struct node *root = NULL;
	int ind = 0;
	for (int i = 0; i < q; i++) {
		int d;
		scanf("%d", &d);
		while (ind < 2*n && work[ind][0] <= d) {
			//printf("work[%d]: %d %d %d\n", ind, work[ind][0], work[ind][1], work[ind][2]);
			if (work[ind][1]) tpush(&root, work[ind][2]);
			else tpop(&root, work[ind][2]);
			//twalk(root);
			ind++;
		}
		printf("%d\n", tmin(root));
	}
}


Measured memory_bytes: 12096
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}

// kの階乗を計算する.(sgnを0以外に設定すると逆元を返す)
ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % mod);
		inv.push_back(mod - inv[mod % nx] * (mod / nx) % mod);
		finv.push_back(finv[nx - 1] * inv[nx] % mod);
		++nx;
	}
	if (sgn == 0)
		return fac[k];
	return finv[k];
}

// aCbを計算する.
ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % mod * fact(a - b, 1) % mod;
}


signed main() {
	ll r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll res = 0;
	for (ll i = r1; i <= r2; ++i) {
		ll tmp = (c2 + 1) * comb(c2 + i + 1, i) % mod;
		tmp -= c1 * comb(c1 + i, i) % mod;
		tmp = (tmp + mod) % mod;
		tmp *= inverse(i + 1);
		tmp %= mod;
		res = (res + tmp) % mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 48688
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long tint;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);
#define dbg cout << "hu" << endl;
 
const tint INF = 11000000;
const int MOD = 1000000007;
 
const int N = 5e5+5;
int t[4*N];
int n;
map<int,int> id;
 
void build(int v, int tl, int tr){
	if(tl == tr){
		t[v] = 0;
	}else{
		int tm = (tl+tr)/2;
		build(2*v, tl, tm);
		build(2*v+1, tm+1, tr);
		t[v] = t[2*v]+t[2*v+1];
	}
}
 
int sum(int v, int tl, int tr, int l, int r){
	if(l > r) return 0;
	if(l == tl && r == tr) return t[v];
	int tm = (tl+tr)/2;
	return sum(2*v, tl, tm, l, min(r, tm))+sum(2*v+1, tm+1, tr, max(l, tm+1), r);
}
 
void update(int v, int tl, int tr, int pos, int val){
	if(tl == tr) t[v] = val;
	else{
		int tm = (tl+tr)/2;
		if(pos <= tm) update(2*v, tl, tm, pos, val);
		else update(2*v+1, tm+1, tr, pos, val);
		t[v] = t[2*v]+t[2*v+1];
	}
}
 
struct Q{
	int l, r, id;
	bool operator<(const Q &ot) const{
		return r < ot.r;
	}
};
 
int main(){
	NACHO;
	int q; cin >> n >> q;
	vector<int> a (n);
	forn(i, n){
		cin >> a[i];
		if(id[a[i]] == 0) id[a[i]] = int(id.size());
		a[i] = id[a[i]];
	}
	build(1, 0, n-1);
	vector<Q> query(q);
	forn(i, q){
		cin >> query[i].l >> query[i].r;
		query[i].l--; query[i].r--;
		query[i].id = i;
	}
	sort(all(query));
	vector<int> last (N, -1);
	int ret[q];
	int contQ = 0;
	forn(i, n){
		if(last[a[i]] != -1){
			update(1, 0, n-1, last[a[i]], 0);
		}
		last[a[i]] = i;
		update(1, 0, n-1, i, 1);
		while(contQ < q && query[contQ].r == i){
			if(query[contQ].l == 0){
				ret[query[contQ].id] = sum(1, 0, n-1, 0, query[contQ].r);
			}else{
				ret[query[contQ].id] = sum(1, 0, n-1, 0, query[contQ].r)-sum(1, 0, n-1, 0,  query[contQ].l-1);
			}
			contQ++;
		}
	}
	forn(i, q){
		cout << ret[i] << "\n";
	}
}
 


Measured memory_bytes: 43052
use proconio::{input, fastout};

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }

    let mut last = vec![0; TYPE_COUNT];

    for s in ss {
        let mut max = 0;
        let mut index = 0;
        for (i, x) in s.into_iter().enumerate() {
            let x = x + cc[i] * last[i];
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        println!("{}", index+1);
    }
}

Measured memory_bytes: 2344
#! python3
# dice_i.py

class dice():
    def __init__(self, arr):
        self.top = arr[0]
        self.south = arr[1]
        self.east = arr[2]
        self.west = arr[3]
        self.north = arr[4]
        self.bottom = arr[5]

    def rotate(self, ope):
        if ope == 'S':
            self.top, self.north, self.bottom, self.south = self.north, self.bottom, self.south, self.top
        elif ope == 'N':
            self.top, self.south, self.bottom, self.north = self.south, self.bottom, self.north, self.top
        elif ope == 'E':
            self.top, self.west, self.bottom, self.east = self.west, self.bottom, self.east, self.top
        elif ope == 'W':
            self.top, self.east, self.bottom, self.west = self.east, self.bottom, self.west, self.top
        elif ope == 'R': # clockwise
            self.south, self.east, self.north, self.west = self.east, self.north, self.west, self.south
        elif ope == 'L': # reversed clockwise
            self.south, self.east, self.north, self.west = self.west, self.north, self.east, self.south

dc = dice([int(x) for x in input().split(' ')])
q = int(input())
top_souths = [[int(x) for x in input().split(' ')] for i in range(q)]

for top, south in top_souths:
    if dc.top != top:
        opes = ['S', 'E', 'S', 'E', 'S']
        for op in opes:
            dc.rotate(op)
            if dc.top == top: break
    for i in range(4):
        if dc.south == south:
            break
        dc.rotate('R')
    print(dc.east)



Measured memory_bytes: 5608
import scala.io.StdIn

object Main extends App {
  val s = Array(StdIn.readLine)

  val res = s.filter(_.charAt(0) == 'A')
    .filter(_.count(_.isUpper) == 2)
    .map(_.toCharArray)
    .map(a => a.slice(2,a.length-1))
    .exists(a => a.count(_ == 'C') == 1)

  println(if (res) "AC" else "WA")
}


Measured memory_bytes: 25544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll C1 = A1-B1, C2 = A2-B2, D1 = C1*T1, D2 = C2*T2;
    if(D1+D2 == 0 || D1*D2 == 0) cout << "infinity" << endl;
    elif(D1+D2 > 0){
        if(D1 > 0) cout << 0 << endl;
        else{
            if((-D1)%(D1+D2) == 0){
                cout << 2*((-D1)/(D1+D2)) << endl;
            }
            else{
                cout << 2*((-D1)/(D1+D2))+1 << endl;
            }
        }
    }
    else{
        if(D1 < 0) cout << 0 << endl;
        else{
            if(D1%(-D1-D2) == 0){
                cout << 2*(D1/(-D1-D2)) << endl;
            }
            else{
                cout << 2*(D1/(-D1-D2))+1 << endl;
            }
        }
    }
}

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

long long dp[110][100010];
pair<int, int> p[110];

void solve()
{
  int n, w; cin >> n >> w;
  for (int i = 0; i < n; i++)
  {
    int a, b; cin >> a >> b;
    p[i + 1] = make_pair(a, b);
  }
  
  for (int i = 1; i <= n; i++)
  {
    for (int j = 0; j <= w; j++)
    {
      if (j - p[i].first >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - p[i].first] + p[i].second);
      else dp[i][j] = dp[i - 1][j];
    }
  }
  
  cout << dp[n][w] << endl;
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<cmath>

using namespace std;
using ll=long long;

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

    ll base = pow(100, d);
    ll ans = base*n;
    if(ans%(base*100) == 0){
        ans += base;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(x):print(x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    D = int(input())
    #N, K = map(int, input().split())
    cs = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(D)) #改行行列
    ls=[0]*26
    for i in range(D):
        s=S[i]
        if i==0:
            msc=-1000000
            ans=-1
            for j in range(26):
                sc=s[j]+cs[j]

                if msc<sc:
                    ans=j
                    msc=sc
            ls[ans]=1

            print(ans+1)
            continue
        msc=0
        ans=-1
        dec=[-cs[j]*(i+1-ls[j]) for j in range(26)]
        msc=-10000000
        ans=-1
        for j in range(26):
            sc=s[j]-dec[j]
            if msc<sc:
                ans=j
                msc=sc
        ls[ans]=i+1
        print(ans+1)



            
                    
            






if __name__ == "__main__":
    main()

Measured memory_bytes: 74260
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]

from collections import defaultdict

memo = defaultdict(list)

for ele in ab:
    memo[ele[0]-1].append(ele[1]-1)
    memo[ele[1]-1].append(ele[0]-1)

que = []
visited = defaultdict(int)
ans = [0]

def dfs(visited,node,pre_node,tmp_sum):
    if tmp_sum == N:
        ans[0] += 1
        return

    for nn in memo[node]:
        if nn == pre_node: continue
        if visited[nn]==1: continue
        visited[nn] = 1
        dfs(visited,nn,node,tmp_sum+1)
        visited[nn] = 0

    return
        
flag = [False]
visited[0]=1
dfs(visited,0,-1,1)

print(ans[0])

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

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

int main(){
    int N;
    cin >> N;
    int ans = 1;
    
    cout << N*N*N << endl;
    return 0;

}

Measured memory_bytes: 256
N=int(input())
XYU=[tuple(input().split()) for _ in range(N)]
U=[]
R=[]
D=[]
L=[]
for x,y,u in XYU:
    x,y = int(x),int(y)
    if u=="U":
        U.append((x,y))
    elif u=="D":
        D.append((x,y))
    elif u=="L":
        L.append((x,y))
    else:
        R.append((x,y))
ans=[10**9]
def z(A):
    A.sort()
    n=p=-10**9
    for k,c,a in A:
        if k!=n:
            if a==1:
                n=k
                p=c
            continue
        if a==1:
            p=c
            continue
        if (c-p)*5<ans[0]:
            ans[0]=(c-p)*5
z([(x,y,1) for x, y in U]+[(x,y,-1) for x,y in D])
z([(y,x,1) for x, y in R]+[(y,x,-1) for x,y in L])
z([(x+y,x-y,1) for x, y in R]+[(x+y,x-y,-1) for x,y in U])
z([(x+y,x-y,1) for x, y in D]+[(x+y,x-y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in U]+[(x-y,x+y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in R]+[(x-y,x+y,-1) for x,y in D])
print("SAFE" if ans[0]>=10**9 else ans[0])


Measured memory_bytes: 102928
#include <stdio.h>
#include <string.h>
int main(void){
	int n,i,c;
	char text[110];
	while(fgets(text,105,stdin)!=NULL){
		n=strlen(text);
		for(i=0;i<n;i++){
			if(text[i]=='@'){
				c=text[i+1]-(int)'0';
				for(i+=2;c>0;c--)printf("%c",text[i]);
			}else printf("%c",text[i]);
		}
	}
	return 0;
}

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

int main() {
	int q; cin >> q;
	for (int i = 0; i < q; i ++) {
		long long a, b; cin >> a >> b;
		long long root = sqrt(a*b);
		long long ans = root + (a*b-1)/root - (a!=b);
		if (root >= a) ans --;
		if ((a*b-1)/root >= b) ans --;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
array = [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]
puts array[gets.to_i - 1]

Measured memory_bytes: 1788
N, K, Q = map(int, input().split())
A = [int(input())-1 for i in range(Q)]
P = [K for i in range(N)]
B = 0
for l in range(Q):
    P[A[l]] += 1
    B += 1
for m in range(N):
    if P[m] > B:
        print('Yes')
    else:
        print('No')
   

Measured memory_bytes: 10452
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n,m,q,x[10],a[50],b[50],c[50],d[50],ans=0,k;
bool ok;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m >> q;
	rep(q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	rep(n) x[i]=1;
	while(1){
		rep3(i,n-1,0){
			if(x[i]<m){
				x[i]++;
				rep2(j,i+1,n) x[j]=x[i];
				break;
			}
		}
		k=0;
		rep(q){
			if(x[b[i]-1]-x[a[i]-1]==c[i]) k+=d[i];
		}
		ans=max(ans,k);
		ok=false;
		rep(n) if(x[i]!=m) ok=true;
		if(!ok) break;
	}
	print1(ans);
	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var k = cin.nextInt();
            var s = cin.nextInt();

            var ans = 0L;
            for (int x = 0; x <= k; x++)
            {
                for (int y = 0; y <= k; y++)
                {
                    var tmp = (s - (x + y));
                    if (0<= tmp && tmp <= k)
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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


int main() {
  string s;
  cin >> s;
  reverse(rng(s));
  for(int i=0; i<s.size(); i++) {
    if(s.substr(i,5)=="maerd") i+=4;
    else if(s.substr(i,5)=="esare") i+=4;
    else if(s.substr(i,6)=="resare") i+=5;
    else if(s.substr(i,7)=="remaerd") i+=6;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int N;
   cin>>N;
   vector<int> math(N);
   int sum=0;
   for(int i = 0;i<N;i++){
       cin >> math.at(i);
       sum += math.at(i);
   }
   
   
   int max=0;
   for (int j = 0; j<N;j++){
       if(max < math.at(j)){
           max = math.at(j);
       }
   }
    if(max*2<sum){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
   
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c, cnt;
    cin >> a >> b >> c;
	if ((a == b) && (b == c)){
      cnt = 1;
    }
    else {
      if ((a != b) && (b != c) && (a != c)){
        cnt = 3;
      }
      else {
        cnt = 2;
      } 
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
i,o,t,j,l,s,z=map(int,input().split())
if i>=1 and j>=1 and l>=1:
    print(max(o + 2 * ((i - 1) // 2 + (j - 1) // 2 + (l - 1) // 2) + 3, o + (i // 2 + j // 2 + l // 2) * 2, 0))
else:
    print(o + (i // 2 + j // 2 + l // 2) * 2)

Measured memory_bytes: 38384
import numpy as np
words = lambda t : list(map(t, input().split()))

n, k = words(int)

ans = 0
for i in range(1,n+1):
    if i < k:
        t = (1/n) * (1/2)**(np.ceil(np.log2(k/i)))
    else:
        t = (1/n)
    #print(i, t)
    ans += t

print(ans)


Measured memory_bytes: 21236
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


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

Measured memory_bytes: 384
def divide(l):
	for i in range(len(l)):
		if l[i] % 2 == 0:
			l[i] = int(l[i] / 2)
		else:
			return False
			
	return True


n = int(input())
l = list(map(int, input().split()))

count = 0
while divide(l):
	count += 1
		
print(count)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string a,b;
  cin>>a;
  cin >>b;
  
 if (a.size() > b.size()){
   cout << "GREATER" << endl;
 } 
 
   else if (a.size() <b.size()){
     cout << "LESS" << endl;
   }
  
  else {
    
    for(int i=0; i<a.size() ; i++){
      if(a[i] > b[i]){
        cout << "GREATER" <<endl;
        return 0;
      }
      if(a[i] < b[i]){
        cout << "LESS" << endl;
        return 0;
    }
  
}
    cout << "EQUAL" << endl;
}
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string S;
cin>>S;
S.erase(unique(S.begin(),S.end()),S.end()); //STL大法好啊！
cout<<S.size() - 1 << endl;//输出加换行
return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n, 0);
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        a[x]++;
        a[y]++;
    }
    for (int i = 0; i < n; i++) {
        if ((a[i] & 1) != 0) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
constexpr int mod = 1e9 + 7;
template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        long long d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod );
    }
}
template<class T> T mod_nCr(T n, T r, T mod ) {
    T denom = 1;
    T numer = 1;
    for (T i = 1; i <= r; i++) numer = (numer * i) % mod;
    for (T i = n - r + 1; i <= n; i++) denom = (denom * i) % mod;
    return (denom * modpow(numer, mod - 2) % mod);
}
signed main(){
    cin >> H >> W;
    vector<string>grid(H);
    for(auto& s : grid) cin >> s;
    vector<vector<int>>dp(H,vector<int>(W,0LL));
    for(int i = 0; i < H and grid[i][0] != '#'; ++i) dp[i][0] = 1;
    for(int j = 0; j < W and grid[0][j] != '#'; ++j) dp[0][j] = 1;
    for(int i = 1; i < H; ++i){
        for(int j = 1; j < W; ++j){
            if(grid[i][j] == '#') continue;
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= mod;
        }
    }
    cout << dp.back().back() << endl;
}


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

int solve(int x){
  return min(abs(x),24-abs(x));
}

int main(){
  int N;
  cin>>N;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin>>D.at(i);
  }
  vector<int> count(13,0);
  for(int i=0;i<N;i++){
    count.at(D.at(i))++;
  }
  bool flag=false;
  for(int i=1;i<12;i++){
    if(count.at(i)>2){
      flag=true;
    }
  }
  if(count.at(12)>1){
    flag=true;
  }
  if(count.at(0)>0){
    flag=true;
  }
  if(flag){
    cout<<0<<endl;
  }else{
    int ans=0;
    vector<int> a,b;
    a.push_back(0);
    for(int i=1;i<12;i++){
      if(count.at(i)==2){
        a.push_back(i);
        a.push_back(-i);
      }else if(count.at(i)==1){
        b.push_back(i);
      }
    }
    if(count.at(12)==1){
      a.push_back(12);
    }
    int n=b.size();
    for(int i=0;i<(1<<n);i++){
      int sub=12;
      vector<int> A=a;
      int res=i;
      for(int j=0;j<n;j++){
        if(res%2==0){
          A.push_back(b.at(j));
        }else{
          A.push_back(-b.at(j));
        }
        res>>=1;
      }
      int m=A.size();
      for(int j=0;j<m;j++){
        for(int k=j+1;k<m;k++){
          sub=min(sub,solve(A.at(j)-A.at(k)));
        }
      }
      ans=max(ans,sub);
    }
    cout<<ans<<endl;
  }
}


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

int f[10][10];
void solve(){

}
int dx[] = {0,1,0,-1,0,1,1,-1,-1,2,0,-2,0};
int dy[] = {0,0,1,0,-1,1,-1,1,-1,0,2,0,-2};
int cnt, d;
void ink(int x, int y, int s){  
  for(int i = 0; i <= 4*s; i++){
    int nx = dx[i] + x;
    int ny = dy[i] + y;
    if(nx < 0 || nx >= 10 || ny < 0 || ny >= 10)continue;  
    f[ny][nx]++;
    if(f[ny][nx] == 1)cnt++;
    d = max(d, f[ny][nx]);
  }
}
int main(){
  int x,y,size;
  cnt = d = 0;
  char c;
  memset(f, 0, sizeof(f));
  while(cin >> x >> c >> y >> c >> size){
    ink(x,y,size);
  }
  cout << 100 - cnt << endl << d << endl;
  return 0;
}

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



Measured memory_bytes: 2040
// abc111_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    int ans = ((n + 110) / 111) * 111;
    print(ans);

    return 0;
}








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

long long int max(long long int a, long long int b) {
    return a > b? a: b; 
}

long long int dp(vector<vector<long long int>>& mem, vector<int>& w, vector<int>& v, int j, int i) {
    if(i == 0 || j == 0) {
        mem[i][j] = 0;
        return mem[i][j];
    }
    if(w[i-1] <= j) {
        long long int x = mem[i-1][j-w[i-1]] > -1? (mem[i-1][j-w[i-1]] + v[i-1]): (dp(mem, w, v, j-w[i-1], i-1) + v[i-1]);
        long long int y = mem[i-1][j] > -1? mem[i-1][j]: dp(mem, w, v, j, i-1); 
        mem[i][j] = max(x, y);
        return mem[i][j];
    }
    mem[i][j] = mem[i-1][j] > -1? mem[i-1][j]: dp(mem, w, v, j, i-1);
    return mem[i][j];
}

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    vector<vector<long long int>> mem(n+1, vector<long long int>(W+1, -1));
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    // for(int i = 1; i <= n; i++) {
    //     for(int j = 1; j <= W; j++) {
    //         if(w[i-1] <= j) {
    //             mem[i][j] = max(mem[i-1][j], mem[i-1][j-w[i-1]] + v[i-1]);
    //         }
    //         else {
    //             mem[i][j] = mem[i-1][j];   
    //         }
    //     }
    // }
    long long int ans = dp(mem, w, v, W, n);
    cout << ans;
    return 0;
}

Measured memory_bytes: 83072
import java.util.*;
import java.math.BigDecimal;

class Main {
	private static Map<Long,Long> longMap = new HashMap<>();
	private static long a;
	private static long b;
	private static long c;
	private static long d;
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
    	for(int i = 0; i < t; i++) {
    		long n = sc.nextLong();
    		a = sc.nextLong();
    		b = sc.nextLong();
    		c = sc.nextLong();
    		d = sc.nextLong();
    		longMap = new HashMap<>();
    		System.out.println(solve(n));
    	}
    }
	
	public static long solve(long n) {
		if(n == 0) {
			return 0;
		}
		if(n == 1) {
			return d;
		}
		if(longMap.containsKey(n)){
			return longMap.get(n);
		}
		long l2 = (n / 2) * 2;
		long b2 = ((n+1) / 2) * 2; 
		long l3 = (n / 3) * 3;
		long b3 = ((n+2) / 3) * 3;
		long l5 = (n / 5) * 5;
		long b5 = ((n+4)/ 5) * 5;
		
		long ans = Long.MAX_VALUE;
		if(new BigDecimal(d).multiply(new BigDecimal(n)).compareTo(new BigDecimal(ans)) == -1) {
			ans = n * d;
		}
		ans = Math.min(ans, solve(l2 / 2) + (n - l2) * d + a);
		ans = Math.min(ans, solve(b2 / 2) + (b2 - n) * d + a);
		ans = Math.min(ans, solve(l3 / 3) + (n - l3) * d + b);
		ans = Math.min(ans, solve(b3 / 3) + (b3 - n) * d + b);
		ans = Math.min(ans, solve(l5 / 5) + (n - l5) * d + c);
		ans = Math.min(ans, solve(b5 / 5) + (b5 - n) * d + c);
		
		longMap.put(n, ans);
		return ans;
	}
}

Measured memory_bytes: 49920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int n,q;
string s;
char t[200010],d[200010];

bool isLOK(int x){
    int cur=x;
    for(int i=0;i<q;i++){
        if(s[cur]==t[i]){
            if(d[i]=='L')cur--;
            else cur++;
            if(cur<0)return false;
            if(n<=cur)return true;
        }
    }
    return true;
}

bool isROK(int x){
    int cur=x;
    for(int i=0;i<q;i++){
        if(s[cur]==t[i]){
            if(d[i]=='L')cur--;
            else cur++;
            if(cur<0)return true;
            if(n<=cur)return false;
        }
    }
    return true;
}

int main(){
    cin>>n>>q>>s;
    for(int i=0;i<q;i++){
        cin>>t[i]>>d[i];
    }
    int lng=-1,lok=n;
    while(abs(lng-lok)>1){
        int mid=(lng+lok)/2;
        if(isLOK(mid))lok=mid;
        else lng=mid;
    }
    int rok=-1,rng=n;
    while(abs(rok-rng)>1){
        int mid=(rok+rng)/2;
        if(isROK(mid))rok=mid;
        else rng=mid;
    }
    cout<<max(0,rok-lok+1)<<endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	
	char c[3][3];

	REP(i,3){
		REP(j,3){
			cin>>c[i][j];
			if(i==j)cout<<c[i][j];
		}
	}

	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long int LL;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef string::iterator STI;
const int INF = (int)2e9;

int h, w;
int field[1010][1010];
int broken[1010][1010];
int ans = 0;
int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
queue<PII> sr;
int main()
{
  cin >> h >> w;
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++){
      char in;
      cin >> in;
      if(in == '.')
	field[i][j] = 0;
      else{
	field[i][j] = in - '0';
	broken[i][j] = INF;
      }
    }

  for(int i = 1; i < h - 1; i++)
    for(int j = 1; j < w - 1; j++){
      if(!(broken[i][j] <= 1)){
	int many = 0;
	for(int k = 0; k < 8; k++)
	  if(broken[i + dx[k]][j + dy[k]] < 1)
	    many++;
	if(many >= field[i][j]){
	  sr.push(MP(i, j));
	  broken[i][j] = 1;
	}
      }
    }
  
  while(!sr.empty()){
    ans++;
    
    int sz = sr.size();
    for(int i = 0; i < sz; i++){
      PII now = sr.front();
      sr.pop();
      
      for(int j = 0; j < 8; j++){
	PII next = MP(now.first + dx[j], now.second + dy[j]);
	
	if(!(broken[next.first][next.second] <= ans + 1)){
	  int many = 0;
	  for(int k = 0; k < 8; k++)
	    if(broken[next.first + dx[k]][next.second + dy[k]] < ans + 1)
	      many++;
	  
	  if(many >= field[next.first][next.second]){
	    sr.push(MP(next.first, next.second));
	    broken[next.first][next.second] = ans + 1;
	  }
	}
      }
      
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

template<class T1, class T2>
void chmin(T1 &a, T2 b) {
	if (b < a) a = b;
}

int dp[41][444][444];

int main() {
	fill_n(**dp, sizeof(dp) / 4, 1e9);

	int n, ma, mb;
	cin >> n >> ma >> mb;

	dp[0][0][0] = 0;

	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		for (int j = 0; j < 410; j++) {
			for (int k = 0; k < 410; k++) {
				chmin(dp[i + 1][j][k], dp[i][j][k]);
				chmin(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
			}
		}
	}

	int ans = 1e9;
	for (int i = 1; i < 410; i++) {
		for (int j = 1; j < 410; j++) {
			if (ma * j == i * mb) {
				ans = min(ans, dp[n][i][j]);
			}
		}
	}
	if (ans == 1e9) ans = -1;
	cout << ans << endl;
}



Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	while(cin>>x>>y){
		if(x==0&&y==0)
		break;
		
		if(x<y)
			cout<<x<<" "<<y<<endl;
		else
			cout<<y<<" "<<x<<endl;
	}
	return 0;
}


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

bool IsPrime(int num){
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    int num = x;

    while(true) {
        if (IsPrime(num)){
            cout << num << endl;
            return 0;
        }
        num++;
    }

    return 0;
}

Measured memory_bytes: 256