akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(void){
  int N, X;
  cin >> N >> X;
  vector<int> L(N); rep(i, N) cin >> L[i];
  int D = 0;
  int cnt = 1;
  rep(i, N){
    D += L[i];
    if(D <= X) cnt++;
  }
  cout << cnt << endl;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int A[3][3];

    rep(i,3)rep(k,3)cin>>A[i][k];

    bool hit[3][3]={};
    int n;
    cin>>n;
    rep(i,n){
        int b;
        cin>>b;
        rep(l,3)rep(k,3){
            if(A[l][k]==b)hit[l][k]=true;
        }
    }
    string ans="No";
    rep(i,3){
        int now=0;
        rep(k,3)if(hit[i][k])now++;

        if(now==3)ans="Yes";
    }
    rep(i,3){
        int now=0;
        rep(k,3)if(hit[k][i])now++;

        if(now==3)ans="Yes";
    }
    int now=0;
    rep(i,3){
        if(hit[i][i])now++;
    }
    if(now==3)ans="Yes";
    now=0;
    for(int i=2;i>-1;i--){
        if(hit[2-i][i])now++;
    }
    if(now==3)ans="Yes";

    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
def e(): exit()
n="0"+input()
x=len(n)
k=int(input())
l=[int(i) for i in n]

## dp1:top   dp2:under
dp1=[[0]*(k+2) for i in range(x)]
dp2=[[0]*(k+2) for i in range(x)]

dp1[0][0]=1
dp1[0][1]=0
dp2[0][0]=0
dp2[0][1]=0

cnt=0
for i in range(1,x):
    if l[i]>0:
        cnt+=1
    if cnt<=k:
        dp1[i][cnt]=1
for i in range(1,x):
    for j in range(k+1):
        if j==0:
            dp2[i][0]=1
        else:
            dp2[i][j]=(dp2[i-1][j-1]*9)+(dp2[i-1][j])+(dp1[i-1][j-1]*max(0,l[i]-1))+([dp1[i-1][j],0][l[i]==0])
print(dp1[-1][-2]+dp2[-1][-2])

Measured memory_bytes: 38480
#include <vector>
#include <iostream>

template <typename T>
void insertion_sort(std::vector<T> &A) {
    for(std::size_t j = 1; j < A.size(); ++j) {
        T key = A[j];
        int i = j - 1;
        while(i >= 0 && A[i] > key) {
            A[i + 1] = A[i];
            --i;
        }
        A[i + 1] = key;
        
        for(std::size_t k = 0; k < A.size(); ++k) std::cout << A[k] << (k + 1 == A.size() ? '\n' : ' ');
    }
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for(int i = 0; i < n; ++i) std::cin >> A[i];

    for(std::size_t k = 0; k < A.size(); ++k) std::cout << A[k] << (k + 1 == A.size() ? '\n' : ' ');
    insertion_sort<int>(A);
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n,m;
  cin >> n;
  vector<string> s(n);
  int i,j;
  for(i = 0;i < n;++i){
    cin >> s.at(i);
  }
  cin >> m;
  vector<string> t(m);
  for(i = 0; i < m;++i){
    cin >> t.at(i);
  }
  string temp = s.at(0);
  vector<int> ans(n,0);
  for(i = 0;i < n;++i){
    temp = s.at(i);
    for(j = 0;j < n;++j){
      if(temp == s.at(j)){
        ++ans.at(i);
      }else{
        continue;
      }
    }
    for(j = 0;j < m;++j){
      if(temp == t.at(j)){
        --ans.at(i);
      }else{
        continue;
      }
    }
  }
  int max = ans.at(0);
  for(i = 0;i < n;++i){
    if(max < ans.at(i)){
      max = ans.at(i);
    }
  }
  if(max < 0){
    cout << 0 << endl;
  }else{
    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Character,Set<String>> map = new HashMap<>();
        for(int i = 0;i < n;i++){
            String str = sc.next();
            char x = str.charAt(0);
            if(!(x == 'M'||x == 'A'||x == 'R'||x == 'C'||x == 'H')){
                continue;
            }
            if(!map.containsKey(x)){
                map.put(x,new HashSet<String>());
            }
            map.get(x).add(str);
        }
        if(map.size() < 3){
            System.out.println(0);
            return;
        }
        List<Set<String>> list = new ArrayList<>(map.values());
        long ans = 0;
        for(int i = 0;i < list.size();i++){
            for(int j = i+1;j < list.size();j++){
                for(int k = j+1;k < list.size();k++){
                    long x = (long) list.get(i).size() * (long) list.get(j).size() * (long) list.get(k).size() ;
                    ans += x;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50836
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
#define mod 998244353
using namespace std;
bool check(string s){
    //cout <<s<<endl;
    int i=0;int j=s.size()-1;
    while(i<j){
        if(s[i]!=s[j])return false;
        i+=1;j-=1;
    }
    return true;
}
int main(){
    string s;cin >>s;
    int n=s.size();
    string s1=s.substr(0,(n-1)/2);
    string s2=s.substr((n+3)/2-1,(n-1)/2);
    //cout <<check(s1)<<" "<<check(s2)<<endl;
    if(check(s1) && check(s2)&&check(s)){
        cout <<"Yes"<<endl;
    }
    else{
        cout <<"No"<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int calc(int x)
{
    int res = 0;
    for(int i = 1; i <= x; i++)
    {
        if(x%i==0)
        {
            res++;
        }
    }
    return res;
}
int main()
{
    int n, ans = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        if(i%2&&calc(i)==8)
        {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define all(v)           ((v).begin()), ((v).end())
#define sz size()
#define clr(v,d)         memset(v,d,sizeof(v))
#define rep(i, v)        for(int i=0;i<(v).sz;++i)
#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define sci(a)	scanf("%d",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prii(a, b)	printf("%d %d\n",a, b)
#define DB1(a)          std::cout<<#a<<"="<<(a)<<endl
#define DB2(a,b)        std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<endl
#define DB3(a,b,c)      std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<endl
#define DB4(a,b,c,d)    std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<endl
#define DB5(a,b,c,d,e)  std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<endl
typedef pair<int, int> pii;
typedef long long ll;
const ll  inf = 1000000000000000000LL;
const double EPS = 1e-9;
const ll mod = 1000000007ll;
#define PI acos(-1)

const int maxn = 300500;

int a[maxn];
int pl[maxn];
int n;
ll fact[maxn], invf[maxn];



long long pow_mod(long long base, long long power){
	long long res = 1;
	while (power) {
		if (power & 1)res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

void prenCkmod(){
	fact[0] = invf[0] = 1;
	for (int i = 1; i < maxn; i++){
		fact[i] = fact[i - 1] * i % mod;
		invf[i] = pow_mod(fact[i], mod - 2);
	}
}

ll nCkMOD(ll n, ll k){
	if (k > n) return 0LL;
	return fact[n] * (invf[n - k] * invf[k] % mod) % mod;
}

int main(){
	prenCkmod();
	sci(n); 
	int l , r;
	memset(pl, -1, sizeof(pl));
	lp(i, n + 1) {
		sci(a[i]);
		if (pl[a[i]] != -1) l = pl[a[i]], r = i;
		else pl[a[i]] = i;
	}
	for (int i = 1; i <= n + 1; i++){
		printf("%lld\n", (nCkMOD(n + 1, i) - nCkMOD(n - r + l, i - 1) + mod) % mod);
	}
}



Measured memory_bytes: 7424
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		String T = s.next();
		
		T = T.replaceAll("\\?", "D");
		
		System.out.println(T);
    }
}

Measured memory_bytes: 53460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	string S; cin>>S;
	int x=0;
	for(auto i:S){
		int t=i-'0';
		x=(x+t)%9;
	}
	if(x==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a+b+c-max({a,b,c})<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    
    int ans = 0;
    rep(i, 3) {
        if(s[i] == t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	static List<Long>list=new ArrayList<Long>();
	static long z;
	static void saiki(long a) {
		if(a>z) {
			return;
		}
		long x=10*a+3;
		long y=10*a+5;
		long z=10*a+7;
		list.add(x);
		list.add(y);
		list.add(z);
		saiki(x);
		saiki(y);
		saiki(z);
	}
	public static void main(String[] args) throws IOException {
		z=scan.nextLong();
		saiki(0);
		int cnt=0;
		Collections.sort(list);
		for(int i=0;i<list.size();i++) {
			long x=list.get(i);
			if(x>z) {
				break;
			}
			String str=String.valueOf(x);
			if(str.indexOf("3")!=-1&&str.indexOf("5")!=-1&&str.indexOf("7")!=-1) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

using namespace std;

using ll = long long;

ll kanta[2000111];

int main() {

  ll n; cin >> n;
  ll arr[n] = {0}, ans = 0;
  for(ll i = 0; i < n; ++i){
    cin >> arr[i];
    kanta[arr[i]]++;
  }
  sort(arr, arr + n);
  for(ll i = 0; i < n; ++i){
    ll cur = arr[i], tmp = arr[i];
    if(kanta[cur] == 1)ans++;
    if(kanta[cur] == 0)continue;
    while(cur < 2000024){
        kanta[cur] = 0;
        cur += tmp;
    }
    cur = 0;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 20800
N,L = map(int,input().split())
azi = []
for i in range(N):
    azi.append(L+i)
azi.sort()
if L+1-1 >= 0:
    ans = sum(azi[1:])
elif L+N-1 < 0:
    ans = sum(azi[:-1])
else:
    ans = sum(azi)
print(ans)

Measured memory_bytes: 3060
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,Q,a,b,x[N];

#define ls (o<<1)
#define rs (o<<1|1)
ll minv[2][N<<2],addv[N<<2];
void pushup(int o) {
	minv[0][o]=min(minv[0][ls],minv[0][rs]);
	minv[1][o]=min(minv[1][ls],minv[1][rs]);
}
void pushdown(int o) {
	if (addv[o]) {
		minv[0][ls]+=addv[o],minv[1][ls]+=addv[o],addv[ls]+=addv[o];
		minv[0][rs]+=addv[o],minv[1][rs]+=addv[o],addv[rs]+=addv[o];
		addv[o]=0;
	}
}
void modify(int o,int l,int r,int p,ll w) {
	if (l==r) { minv[0][o]=w+l,minv[1][o]=w-l,addv[o]=0; return; }
	int mid=(l+r)>>1; pushdown(o);
	if (p<=mid) modify(ls,l,mid,p,w);
	else modify(rs,mid+1,r,p,w);
	pushup(o);
}
void modify(int o,int l,int r,int ql,int qr,ll w) {
	if (ql<=l&&r<=qr) { minv[0][o]+=w,minv[1][o]+=w,addv[o]+=w; return; }
	int mid=(l+r)>>1; pushdown(o);
	if (ql<=mid) modify(ls,l,mid,ql,qr,w);
	if (qr>mid) modify(rs,mid+1,r,ql,qr,w);
	pushup(o);
}
ll query(int o,int l,int r,int ql,int qr,int op) {
	if (ql<=l&&r<=qr) return minv[op][o];
	int mid=(l+r)>>1; ll res=1e18; pushdown(o);
	if (ql<=mid) res=min(res,query(ls,l,mid,ql,qr,op));
	if (qr>mid) res=min(res,query(rs,mid+1,r,ql,qr,op));
	return res;
}
ll query(int o,int l,int r) {
	if (l==r) return minv[0][o]-l;
	int mid=(l+r)>>1; pushdown(o);
	return min(query(ls,l,mid),query(rs,mid+1,r));
}
#undef ls
#undef rs

int main() {
	n=read(),Q=read(),a=read(),b=read();
	for (int i=1;i<=Q;++i) x[i]=read();
	memset(minv,0x3f,sizeof(minv));
	x[0]=a; modify(1,1,n,b,0);
	for (int i=1;i<=Q;++i) {
		ll w=min(query(1,1,n,1,x[i],1)+x[i],query(1,1,n,x[i],n,0)-x[i]);
		modify(1,1,n,1,n,abs(x[i]-x[i-1]));
		modify(1,1,n,x[i-1],w);
	}
	printf("%lld\n",query(1,1,n));
	return 0;
}

Measured memory_bytes: 21056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  int sum = a+b;
  if(sum%2==0){
    cout << sum/2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] x = new int[n];
    int[] y = new int[n];
    int[] abs = new int[n];
    double d1 = 0;
    double d2 = 0;
    double d3 = 0;
    double dinf = 0;

    for (int i = 0; i < n; i++) {
      x[i] = scan.nextInt();
    }

    for (int i = 0; i < n; i++) {
      y[i] = scan.nextInt();
    }

    for (int i = 0; i < n; i++) {
      abs[i] = Math.abs(x[i] - y[i]);
      if(dinf < abs[i]) {
        dinf = abs[i];
      }
    }

    for (int i = 0; i < n; i++) {
      d1 += abs[i];
      d2 += Math.pow(abs[i], 2);
      d3 += Math.pow(abs[i], 3);
    }
    
    System.out.println(d1);
    System.out.println(Math.sqrt(d2));
    System.out.println(Math.cbrt(d3));
    System.out.println(dinf);

  }

}



Measured memory_bytes: 26612
import Foundation
var str = readLine()!.components(separatedBy:" ")
var a = Int(str[0])!
var b = Int(str[1])!
var c = Int(str[2])!
var d = Int(str[3])!
var ans = ""

while true {
  c = c-b
  if c<=0{
    ans = "Yes"
    break
  }
  a = a-d
  if a<=0{
    ans = "No"
    break
  }
}
print(ans)

Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

string n;

int calc(int pos)
{
    if (n[pos] == '0')
        return 0;
    int res = 9 * pos + n[pos] - '0' - 1;
    Rep(i, pos + 1, n.size()) res + n[i] - '0';
    return res;
}

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

    cin >> n;
    reverse(all(n));
    int ans = 0;
    rep(i, n.size()) ans += n[i] - '0';
    rep(i, n.size()) ans = max(ans, calc(i));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}

void solve(){
	int t,w,h,a[4][30][30];
	while(cin>>w>>h,w||h){
		memset(a,0,sizeof(a));
		for(int i=0;i<h;i++){
			for(int j=0;j<w-1;j++){
				cin>>t;
				a[1][i][j]=a[3][i][j+1]=t;
			}
			if(i==h-1) continue;
			for(int j=0;j<w;j++){
				cin>>t;
				a[2][i][j]=a[0][i+1][j]=t;
			}
		}
		int f[30][30];
		for(int i=0;i<30;i++) for(int j=0;j<30;j++) f[i][j]=100000;
		priority_queue<pair<int,pair<int,int> > > q;
		q.push(make_pair(0,make_pair(0,0)));
		f[0][0]=0;
		int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
		while(!q.empty()){
			int c=-q.top().first,x=q.top().second.first,y=q.top().second.second;
			q.pop();
			if(f[y][x]<c) continue;
			for(int i=0;i<4;i++){
				int nx=x+dx[i],ny=y+dy[i];
				if(nx<0||nx>=w||ny<0||ny>=h||a[i][y][x]) continue;
				if(c+1<f[ny][nx]){
					f[ny][nx]=c+1;
					q.push(make_pair(-(c+1),make_pair(nx,ny)));
				}
			}
		}
		if(f[h-1][w-1]==100000) cout<<0<<endl;
		else cout<<f[h-1][w-1]+1<<endl;
	}
}


int main(){
	solve();

}

Measured memory_bytes: 924
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x; cin >> x;
    vector<bool> dp(x + 1, 0);
    dp[0] = 1;
    for(int i = 100; i < 106; i++) for(int j = i; j < x + 1; j++) dp[j] = dp[j] | dp[j - i];
    cout << dp[x];

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}
int IntPow(int x, int n){
    if(n == 0)
        return 1;
    if(n % 2 == 0)
        return IntPow(x * x, n / 2);
    else
        return x * IntPow(x, n - 1);
}
int BitN(int n){
    assert(n>=0);
    return (int)IntPow(2, n);
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int ans;ans=0;
    string s;
    cin>>s;
    
    int ans1=0,ans2=0;
    FOR(i, 0, s.size()){
             if(i%2==0 and s[i]=='0')ans1++;
        else if(i%2==1 and s[i]=='1')ans1++;
             if(i%2==0 and s[i]=='1')ans2++;
        else if(i%2==1 and s[i]=='0')ans2++;
    }
    //cout<<ans1<<" "<<ans2<<"\n";
    
    OutputAndReturn0(min(ans1,ans2));
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}


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

int main() {
  int N;
  string a, b="Three";
  cin >> N;
  
  for (int i=0; i<N; i++){
    cin >> a;
    if(a== "Y")
      b= "Four";
  }
  cout << b << endl;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(input())
num = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      num += 1
A = [[0 for j in range(W)] for i in range(H)]
d = deque([[0, 0]])
while len(d) > 0:
  x = d.pop()
  A[x[0]][x[1]] = 1
  if x[0] + 1 < H and S[x[0]+1][x[1]] == "#":
    d.append([x[0]+1, x[1]])
  if x[1] + 1 < W and S[x[0]][x[1]+1] == "#":
    d.append([x[0], x[1]+1])
if num == H + W - 1 and A[H-1][W-1] == 1:
  print("Possible")
else:
  print("Impossible")

Measured memory_bytes: 67264
using System;

namespace ABC149A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s, t;
            string[] ss = Console.ReadLine().Split(' ');
            s = ss[0];
            t = ss[1];
            Console.WriteLine(t + s);
            Console.ReadKey();



            
        }
    }
}

Measured memory_bytes: 11092
function Main(s) {
	s = s.split(" ").map(a => parseInt(a));
	var a, b, c, d;
	if(s[0] > s[1]){
		a = s[0];
		b = s[1];
		c = ".";
		d = "#";
	}else{
		b = s[0];
		a = s[1];
		d = ".";
		c = "#";
	}
	const h = Math.ceil(Math.sqrt(a)) * 4;
	const a1 = [c, c, c, d];
	const ab = [c, d, c, d];
	const a0 = [d, d, d, d];
	var ans = [];
	var aa = 1, bb = 1;
	for(var i = 0; i < h; i += 4){
		ans[i] = [];
		ans[i+1] = [];
		ans[i+2] = [];
		ans[i+3] = [];
		for(var j = 0; j < h; j += 4){
			if(i === 0 && j === 0){
				ans[i].push(...a1);
				ans[i+1].push(...a1);
				ans[i+2].push(...a1);
				ans[i+3].push(...a0);
			}else if(aa === a){
				ans[i].push(...a0);
				ans[i+1].push(...a0);
				ans[i+2].push(...a0);
				ans[i+3].push(...a0);
			}else if(bb === b){
				ans[i].push(...a1);
				ans[i+1].push(...a1);
				ans[i+2].push(...a1);
				ans[i+3].push(...a0);
				aa++;
			}else{
				ans[i].push(...a1);
				ans[i+1].push(...ab);
				ans[i+2].push(...a1);
				ans[i+3].push(...a0);
				aa++;
				bb++;
			}
		}
	}
	for(i = 0; i < h; i++){
		ans[i] = ans[i].join("");
	}
	console.log("%d %d\n%s", h, h, ans.join("\n"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 8368
import numpy as np
if __name__ == "__main__":
    # 入力パターン．
    # 先に要素数Nが与えられて，その数読み込むパターン
    ### N
    ### a_1 a_2 a_3 ... a_N
    N, M = map(int, input().split())
    # int型のリスト
    line = np.array(list(map(int, input().rstrip().split(' '))))
    ans = N-line.sum()
    if ans >= 0:
        print(ans)
    else:
        print(-1)




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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

int main() {
    FAST;

    int n, i, cnt = 0;
    ll d, x, y;
    cin >> n >> d;
    d = d*d;

    for (i = 0; i < n; ++i) {
        cin >> x >> y;
        cnt += (x*x+y*y <= d);
    }

    cout << cnt;

    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll n,m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return(0);
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

int mod_pow(int x,int n)
{
    int res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

signed main()
{
    int m,n; cin>>m>>n;
    cout<<mod_pow(m,n)<<endl;
}



Measured memory_bytes: 3076
package main

import (
	"bytes"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	if false {
		test()
	} else {
		solve(os.Stdin, os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n int
	fmt.Fscanln(r, &n)
	for _, p := range problems(n) {
		fmt.Fprintln(w, p)
	}
}

func problems(n int) []int {
	for max := 1; max <= n; max++ {
		s := sum(max)
		if s < n {
			continue
		} else if s == n {
			return genRange(1, max+1)
		}
		rs := make([]int, 0, max-1)
		for i := 1; i <= max; i++ {
			if s-i == n {
				continue
			}
			rs = append(rs, i)
		}
		return rs
	}
	return nil
}

func permutation([]int, int) [][]int {
	return nil
}

func genRange(i, j int) []int {
	rs := make([]int, 0, j-i)
	for ; i < j; i++ {
		rs = append(rs, i)
	}
	return rs
}

func sum(max int) int {
	r := 0
	for i := 1; i <= max; i++ {
		r += i
	}
	return r
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: "4",
			want: `1
3
`,
		},
		{
			in: "7",
			want: `1
2
4
`,
		},
		{
			in: "1",
			want: `1
`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(tt.in), buf)
		if got := buf.String(); got != tt.want {
			fmt.Printf("%d: got %v, want %v\n", i, got, tt.want)
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a>0)
    cout<<"Positive";         
    else if(b>=0)
    cout<<"Zero";          
    else if((a&1)^(b&1))
    cout<<"Positive"; 
    else cout<<"Negative";
    cout<<endl;
    return 0;
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define fr(i, a, b) for(int i = (a); i <= (b); ++i)
#define rf(i, a, b) for(int i = (a); i >= (b); --i)
#define fe(x, y) for(auto& x : y)

#define fi first
#define se second
#define pb push_back

#define pw(x) (1LL << (x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key

mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T>
bool umn(T& a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T>
bool umx(T& a, T b) { return a < b ? a = b, 1 : 0; }

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll INF = 2e18;
const ld eps = 1e-9;

vector<pll> p;
ll n;

int main() {
#ifndef LOCAL
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif
    cin >> n;
    for(int i = 2; 1LL * i * i <= n; ++i) {
        if(n % i == 0) p.pb({i, 0});
        while(n % i == 0) {
            p.back().se++;
            n /= i;
        }
    }
    if(n > 1) p.pb({n, 1});
    int ans = 0;
    fr(i, 0, sz(p) - 1) {
        int now = 1;
        while(p[i].se - now >= 0) {
            p[i].se -= now;
            ans++;
            now++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = n % 10;
        switch (r) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                System.out.println("hon");
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            case 3:
                System.out.println("bon");
                break;
        }
    }
}

Measured memory_bytes: 35748
#include <vector>
#include <queue>
#include <set>
using namespace std;

struct Graph {
  struct edge {
    int to;
    int cap;
    int cost;
    int rev;
  };

  int n;
  vector<vector<edge>> edges;

  Graph(int N) {
    n = N;
    edges.resize(n, vector<edge>());
  }

  int size() const { return n; }

  vector<edge> &operator[](int v) { return edges[v]; }
};


int minimumCostFlow(Graph& g,int s,int t,int f)
{
    const int n = g.size();
    using Pi = pair<int,int>;
    priority_queue<Pi,vector<Pi>,greater<Pi>> que;
    vector<int> prevv(n,-1);
    vector<int> preve(n,-1);
    vector<int> potential(n,0);
    int res = 0;
    while(f > 0){
        vector<int> dist(n,1e9);
        que.push({0,s});
        dist[s] = 0;
        while(!que.empty()){
            Pi p = que.top();
            que.pop();
            if(dist[p.second] < p.first) continue;
            for(int i = 0;i < g[p.second].size();i++){
                auto& e = g[p.second][i];
                int next = dist[p.second] + e.cost + potential[p.second] - potential[e.to];
                if(e.cap > 0 && dist[e.to] > next){
                    dist[e.to] = next;
                    prevv[e.to] = p.second;
                    preve[e.to] = i;
                    que.push({dist[e.to],e.to});
                }
            }
        }
        if(dist[t] == 1e9) return -1;
        for(int v = 0;v < n;v++){
            potential[v] += dist[v];
        }
        int d = f;
        for(int v = t;v != s;v = prevv[v]){
            d = min(d,g[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * potential[t];

        for(int v = t;v != s;v = prevv[v]){
            auto& e = g[prevv[v]][preve[v]];
            e.cap -= d;
            g[v][e.rev].cap += d;
        }
    }
    return res;
}

#include <iostream>

int main()
{
    int v;int e;int f;
    cin >> v >> e >> f;

    Graph g(v);
    for(int i = 0;i < e;i++)
    {
        int u,v,c,d;
        cin >> u >> v >> c >> d;
        g[u].push_back({v,c,d,(int)g[v].size()});
        g[v].push_back({u,0,-d,(int)g[u].size() - 1});
    }

    int ans = minimumCostFlow(g,0,v - 1,f);
    cout << ans << endl;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> vec;
bool turno = 0;
ll gcd(ll a, ll b){
	if(a%b==0) return b;
	return gcd(b,a%b);
}


ll gcdTodos(){
    ll act = gcd(vec[0], vec[1]);
    for(long i = 2; i < vec.size(); i++){
        act = gcd(act, vec[i]);
    }
    return act;
}

void solve(){
    //cout << turno <<'\n';
    bool todosUn = true;
    for(long i = 0; i <vec.size() ; i++){
        if(vec[i] != 1){
            todosUn = false;
            break;
        }
    }
    if(todosUn){
        if(turno){
                turno = 0;
            }else {
                turno = 1;
            }

        return;
    }
    /*for(long i = 0; i <vec.size() ; i++){
        cout << vec[i]<<" ";
    }*/
    //cout<<'\n';
    long numPar = 0;
    long numImpar = 0;
    for(long i = 0; i < vec.size(); i++){
        if(vec[i] % 2 == 0){
                numPar++;
        }else{
            numImpar++;
        }
    }
    if(numPar % 2 == 1){
        //cout << "Numero impar de pares\n";
        return ;

    }else if((numPar % 2 == 0) && (numImpar >= 2)){
        //cout<<"Par numero de pares y 2 o mas impares\n";
        if(turno){
            turno = 0;
        }else turno = 1;
        return;
    }else{
        bool cambio = false;
        //cout << "Simular\n";
        for(long i = 0; i < vec.size(); i++){
            if(vec[i] % 2 == 1 && (vec[i]!= 1)){
                cambio = true;
                vec[i]--;
                break;
            }
        }
        if(cambio){
            ll aux = gcdTodos();
            for(long i = 0; i < vec.size(); i++){
                if(vec[i] % aux == 0){
                    vec[i] /= aux;
                }
            }
            if(turno){
                turno = 0;
            }else {
                turno = 1;
            }
            solve();
        }else{
            for(long i = 0; i < vec.size(); i++){
                if(vec[i]!= 1){
                    vec[i]--;
                    break;
                }
            }
            ll aux = gcdTodos();
            for(long i = 0; i < vec.size(); i++){
                if(vec[i] % aux == 0){
                    vec[i] /= aux;
                }
            }
            if(turno){
                turno = 0;
            }else {
                turno = 1;
            }
            solve();
        }
    }
}
int main(){
    long n;
    cin >> n;
    for(long i = 0; i < n; i++){
        ll aux; cin >> aux;
        vec.push_back(aux);
    }

    solve();
    if(!turno){
        cout << "First\n";
    }else{
        cout << "Second\n";
    }

}


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

int main(){
    int X, Y, i;
    cin >> X >> Y;
    for (i=0; i<=X; i++){
        if (i * 2 + (X - i) * 4 == Y){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  vector<pair<int, long long> > v[n+1];
  for (int i = 0; i < m; i++) {
    int a, b, c; cin >> a >> b >> c;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
  }
  vector<long long> op(n+1, 0), u(n+1, -1e18);
  vector<pair<int, long long> > b(n+1);
  vector<pair<int, long long> > p[n+1];
  u[1] = 3; bool flag = false;
  queue<int> c; c.push(1); op[1] = 1;
  while(!c.empty()) {
    int q = c.front(); c.pop();
    for (int i = 0; i < (int) v[q].size(); i++) {
      int s = v[q][i].first; long long t = v[q][i].second;
      if (u[s] == -1e18) {
        u[s] = t - u[q];
        op[s] = -1 * op[q];
        b[s] = make_pair(q, t);
        c.push(s);
      } else {
        if (op[s] == -2 || op[q] == -2) {
          if (u[s] != t - u[q]) {
            cout << 0 << endl;
            return 0;
          }
          u[s] = t - u[q];
          op[s] = -2;
          continue;
        }
        if (op[s] != -1 * op[q]) {
          op[s] = -2; flag = true;
          pair<int, long long> x = {q, t};
          pair<int, long long> y = b[s];
          if (op[x.first] != 1) swap(x, y);
          long long diff = x.second - y.second;
          if ((diff - (u[x.first] - u[y.first])) % 2 == 1) {
            cout << 0 << endl;
            return 0;
          }
          long long al = (diff - (u[x.first] - u[y.first])) / 2;
          for (int i = 0; i < n; i++) {
            u[i+1] += op[i+1] * al;
          }
          u[s] = x.second - u[x.first];
        } else {
          if (u[s] != t - u[q]) {
            cout << 0 << endl;
            return 0;
          }
        }
      }
    }
  }
  if (flag) {
    for (int i = 0; i < n; i++) {
      if (u[i+1] <= 0) {
        cout << 0 << endl;
        return 0;
      }
    }
    cout << 1 << endl;
    return 0;
  } else {
    long long left = -1e18; long long right = 1e18;
    for (int i = 1; i <= n; i++) {
      if (op[i] == 1) {
        left = max(-u[i] + 1, left);
      } else {
        right = min(u[i] - 1, right);
      }
    }
    if (right < left) {
      cout << 0 << endl;
    } else cout << right - left + 1 << endl;
    return 0;
  }
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  rep2(i, n, 1000) {
    string s = to_string(i);
    if(s[0] != s[1] || s[1] != s[2]) continue;
    cout << i << endl;
    return 0;
  }
}

Measured memory_bytes: 3696
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[][] a = in.nextIntArrayArray(n - 1, 3);

            for (int i = 0; i < n - 1; i++) {
                int sum = 0;
                for (int j = i; j < n - 1; j++) {
                    if (sum <= a[j][1]) {
                        sum = a[j][1];
                    } else {
                        sum = (sum + a[j][2] - 1) / a[j][2] * a[j][2];
                    }
                    sum += a[j][0];
                }
                out.println(sum);
            }
            out.println(0);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public int[][] nextIntArrayArray(int n, int m) {
            int[][] res = new int[n][m];
            for (int i = 0; i < n; i++) {
                res[i] = nextIntArray(m);
            }
            return res;
        }

    }
}



Measured memory_bytes: 21716
use std::io::stdin;
use std::collections::HashMap;

fn read_ints() -> Vec<i32> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|token| token.parse().unwrap()).collect()
}

fn main() {
    let params = read_ints();
    let m = *params.get(1).unwrap() as i64;

    let counts = read_ints();

    let mut accumulates = HashMap::new();
    let mut acc = 0 as i64;
    accumulates.insert(acc, 1);
    for count in counts {
        acc += count as i64;
        let k = acc % m;
        let count = accumulates.entry(k).or_insert(0);
        *count += 1;
    }

    let mut ans = 0 as i64;
    for (_k, v) in accumulates.iter() {
        ans += v * (v - 1 as i64) / 2 as i64;
    }

    println!("{}", ans);
}

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

// vector<vector<int> > dp(100001,vector<int>(3,-1));
// int dfs(vector<vector<int>> &input, int prev, int row){
//     if(row==input.size()) return 0;
//     if(dp[row][prev]!=-1) return dp[row][prev];
    
//     int cons=0,ncons=0;
    
//     for( int i=0;i<3;i++){
//         if(i==prev) continue;
//         cons= max(cons,input[row][i] + dfs(input,i,row+1));
//         // ncons= dfs(input,ind+1,row);
//     }
//     dp[row][prev]=cons;
//     return dp[row][prev];
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int N;
    cin>>N;
    vector<vector<int>> input(N);
    for(int i=0;i<N;i++){
        int a,b,c; cin>>a>>b>>c;
        input[i].push_back(a);
        input[i].push_back(b);
        input[i].push_back(c);
    }
    vector<int> dp(3,0);
    vector<int> last(3,0);
    for(int i=0;i<N;i++){
        dp[0]=max(last[1],last[2]) + input[i][0];
        dp[1]=max(last[0],last[2]) + input[i][1];
        dp[2]=max(last[1],last[0]) + input[i][2];
        last=dp;
    }
    cout<< max({dp[0],dp[1],dp[2]});
//   cout<<dfs(input,0,0);
    
    
	return 0;
}

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

int main() {
  int a, b, c, d, e;
  for(int i = 0; i < 5; i++) {
    cin >> a >> b >> c >> d >> e;
  }
  if(a == 0) cout << 1 << endl;
   if(b == 0) cout << 2 << endl;
   if(c == 0) cout << 3 << endl;
   if(d == 0) cout << 4 << endl;
   if(e == 0) cout << 5 << endl;
}


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

int main(){
    int N, W, ans = 0, ans_1;
    std::cin >> N;
    vector<int> ws(N);
    
    for(int i = 0; i < N; i++){
        std::cin >> W;
        ans = ans + W;
        ws[i] = W;
    } 

    for(int i = 0; i < N; i++){
        ans = ans - 2 * ws[i];
        if(ans < 0){
            if(-1 * ans < ans_1){
                ans = -ans;
            }else{
                ans = ans_1;
            }
            break;
        }
        ans_1 = ans;
    }

    std::cout << ans;
}

Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, h, w := nextInt(), nextInt(), nextInt()
	ans := 0
	for i := 0; i < n; i++ {
		a, b := nextInt(), nextInt()
		if a >= h && b >= w {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int h1 , m1 , h2 , m2 , k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    h1 = h1 * 60 + m1 , h2 = h2 * 60 + m2;
    h2 -= k;

    cout << max(0 , h2 - h1) << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
   string s;
   cin>> s;
   int l=s.length();
   int a=0,b=0,c=0;
   for(int i=0;i<l;i++)
   {
       if(s[i]=='a')a++;
       else if(s[i]=='b')b++;
       else c++;
   }
   if(abs(a-b)<=1&&abs(a-b)<=1&&abs(a-c)<=1&&abs(b-c)<=1)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   return 0;
}


Measured memory_bytes: 3724