akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int kou[6]={500,100,50,10,5,1};
int main(){
	int N,res;
	while(true){
		cin>>N;
		if(N==0) break;
		N=1000-N;
		res=0;
		for(int i=0;i<6;i++){
			while(N>=kou[i]){
				res++;
				N-=kou[i];
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

struct point {
    int x;
    int y;
};

int distance(struct point p1, struct point p2) {
    return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}

int main(void) {
    int h, w, d;
    struct point p[90000 + 1];//don't use a[0]
    int q;
    int dd[90000 + 1] = {0};//don't use dd[0]

    scanf("%d%d%d", &h, &w, &d);
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int a;
            scanf("%d", &a);
            p[a].x = i;
            p[a].y = j;
        }
    }

    //dd[k] is the distance of p[k] and p[k % d] (if k % d == 0, distance of p[k] and p[d])
    for (int k = d + 1; k <= h * w; k++) {
        dd[k] = dd[k - d] + distance(p[k], p[k - d]);
    }

    scanf("%d", &q);
    for (int k = 0; k < q; k++) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", dd[r] - dd[l]);
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

long mod = 1000000007;
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

int isbroken[100050] = {0};
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a;
    rep(i, m){ int tmp; cin >> tmp; isbroken[tmp] = 1;}

    vector<mint> dp(n+1);
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (isbroken[i] == 1) continue;
        if (isbroken[i-1] == 0) dp[i] += dp[i-1];
        if (isbroken[i-2] == 0 && i-2 >= 0) dp[i] += dp[i-2];
    }
    cout << dp[n].x << endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main(){
    int N; cin >> N;
    stack<int> st;

    int p;
    for(int i=1;i<=N;i++){
        cin >> p;
        if(p == i){
            if(st.empty()) st.push(i);
            else if(st.top() == i-1) continue;
            else if(st.top() != i-1) st.push(i);
        }
    }

    cout << st.size() << endl;
    return 0;
    
}

Measured memory_bytes: 512
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n = get_int
  sq = Math.sqrt(n)
  divs = []
  1.upto(sq) do |i|
    if n % i == 0
      divs << [i, n/i]
    end
  end

  a, b = divs[-1]
  puts (a - 1 + b - 1)
end

if __FILE__ == $0
  main
end


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

long long n;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    for(int j = i + 1; j < n; ++j) {
      if(j != i + 1) cout << " ";
      for(int k = 0; k < 60; ++k)
        if((i >> k & 1) != (j >> k & 1)) {
          cout << k + 1;
          break;
        }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
  long long a;
  cin >> a;
  
  long long minm = a-1;

  for(long long i = 1; i <= a/2; i++) {
    if(i > 1000000) {
      break;
    }
    long long b;
    b = a/i; // iで割ったあまり
    if(a%i == 0) {
      long long c;
      c = i + b -2;
      minm = min(c, minm);
    }
  }

  cout << minm;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <deque>
#include <unordered_set>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/floyd_warshall_shortest.hpp>


int main() {
	using namespace std;
	using Graph = typename boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, 
	                         boost::no_property, boost::property<boost::edge_weight_t, int>>;
		
	// recieve |V| and |E|
	int V, E; std::cin >> V >> E;

	// adjacency list
	std::vector<std::vector<std::pair<int, int>>> G(V);
	
	// distance行列、次のノード
    vector<vector<int>> paths(V, vector<int>(V, 99999999)), next = paths;

	for(int i = 0; i < E; i++) {
		// recieve edges
		int u, v, d; std::cin >> u >> v >> d;
		u--; v--;
		G[u].push_back({v, d});
		G[v].push_back({u, d});
		
		paths[u][v] = paths[v][u] = d;
		next[u][v] = v;
		next[v][u] = u;
	}
	
	// 全点対の最短距離をあらかじめ求めておく（ワーシャル＝フロイド法）
    for (int k = 0; k < V; k++)
 	   for (int i = 0; i < V; i++)
 		   for (int j = 0; j < V; j++) {
 		   	const int distance = paths[i][k] + paths[k][j];
 		   	if (paths[i][j] > distance) {
 		   		paths[i][j] = distance;
 		   		next[i][j] = next[i][k];
 		   	}
 		   }
	
	// recieve freqencies
	// orders:注文[ID]のリスト
	std::vector<int> freq(V), orders;
	for(int i = 0; i < V; i++) std::cin >> freq[i];
	
	int Tmax; std::cin >> Tmax;
    int togo = 0, charges = 0;
    // 積んでいる荷物のリスト
 	unordered_set<int> loading;
 	// 在庫
    deque<int> stock;
  	int current = 0;

  orders.resize(Tmax+1);
	for(int t = 0; t < Tmax; t++) {

		// the number of new order
		int Nnew; std::cin >> Nnew;
		for(int j = 0; j < Nnew; j++) {
			int new_id, dst; std::cin >> new_id >> dst;
			orders[new_id] = --dst;
          stock.push_back(dst);
		}
	
		// the number of items transfered into the car at time t.
		int Nput; std::cin >> Nput;
		for(int j = 0; j < Nput; j++) {
			int put_id; std::cin >> put_id;
            loading.insert(put_id);
          stock.clear();
		}

    // insert your code here to get more meaningful output
    
    if (charges > 0) {
    	charges--;
		std::cout << togo << std::endl;
    }
	else {
 		   pair<int, int> shortest = {999999999, -1};
 		   
		// you have to output a command here

		for (const auto& i : loading)
			shortest = min(shortest, make_pair(paths[current][orders[i]], next[current][orders[i]]));
		for (const auto& i : stock)
			shortest = min(shortest, make_pair(paths[current][0] + paths[0][i], next[current][0]));
			
        if (shortest.second == -1) {
          charges = 0;
          togo = -1;
        }
        else {
          charges = paths[current][shortest.second] - 1;
		  togo = shortest.second+1;
        }
		std::cout << togo << std::endl;
        if (shortest.second != -1) 
          current = shortest.second;
	}
		
		std::string verdict; std::cin >> verdict;
		if(verdict == "NG") {
			return 1;
		}

		// the number of orders that have been delivered at time t.
		int Nachive; std::cin >> Nachive;
		for(int j = 0; j < Nachive; j++) {
			int achive_id; std::cin >> achive_id;
          loading.erase(achive_id);
		}
		
	}

	return 0;
}




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

int main(void) {
    int A,B,C,D;
    int cnt = 0;
    cin >> A>> B >> C >> D;

    while(A > 0 && C > 0) {
        if(cnt % 2) {
            A -= D;
        } else {
            C -= B;
        }
        cnt++;
    }
    if(cnt %2){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b)
{
	if(b!=0)
		return GCD(b,a%b);
	return a;
}
long long LCD(long long a,long long b)
{
	return a*b/GCD(a,b);
}
int main()
{
	long long a,b,c,d,x,y;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	x=b/c+b/d-b/LCD(c,d);
	y=(a-1)/c+(a-1)/d-(a-1)/LCD(c,d);
	printf("%lld",b-a+1-x+y);
    return 0;
}

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(void){
    string s;
    int k;
    cin >> s >> k;
    
    vector<vector<ll>> dp0(s.size(), vector<ll>(k+1, 0));
    vector<vector<ll>> dp1(s.size(), vector<ll>(k+1, 0));
    dp0[0][1] = ctoi(s[0])-1;
    dp1[0][1] = 1;
    for (int i = 1; i < s.size(); i++) {
        int num = ctoi(s[i]);
        dp0[i][1] = 9;
        for (int j = 1; j <= k; j++) {
            dp0[i][j] += dp0[i-1][j-1]*9 + dp0[i-1][j];
            if (num == 0) {
                dp1[i][j] = dp1[i-1][j];
            }
            else {
                dp1[i][j] = dp1[i-1][j-1];
                dp0[i][j] += dp1[i-1][j-1] * (num-1);
                dp0[i][j] += dp1[i-1][j];
            }
        }
    }
    //for (int i = 0; i < s.size(); i++)
        //cout << dp0[i][1] << " " << dp0[i][2] << " " << dp1[i][1] << " " << dp1[i][2] << endl;
    cout << dp1[s.size()-1][k]+dp0[s.size()-1][k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

signed main(){
	int n, m, d, A = 0;
	scanf("%lld%lld%lld", &n, &m, &d);
	if(d == 0)A = n;
	else if(2*d < n){
		A += 2*(n-2*d);
		A += 2*d;
	}else{
		A += 2*(n-d);
	}
	double ans = (double)A*(m-1)/((double)n*n);
	printf("%.8lf\n", ans);
	return 0;
}






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();
    StringBuilder sb = new StringBuilder();
    for(int i=1; i<=n; i++){
      if(i%3==0 || i%10==3 ){
        sb.append(" ").append(i);
      }
      else {
        int j = i;
        while(j>=10) {
          j = j/10;
          if(j%10==3){sb.append(" ").append(i);break;} 
        }
      }
    }
    System.out.println(sb);
  }
}

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

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

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

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

    std::pair<int, int> dp[n + 1];
    dp[0].first = dp[0].second = 0;

    for (int i = 0; i < n; i++) {
        std::pair<int, int> added;

        added.first = dp[i].first + value[i];
        added.second = dp[i].second + cost[i];

        if (added.first - added.second > dp[i].first - dp[i].second) {
            dp[i + 1] = added;
        } else {
            dp[i + 1] = dp[i];
        }
    }

    std::cout << dp[n].first - dp[n].second << std::endl;
}


Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	arr := scanArrayInt()
	max := -10000000000000000
	if max < arr[0]+arr[1] {
		max = arr[0] + arr[1]
	}
	if max < arr[0]-arr[1] {
		max = arr[0] - arr[1]
	}
	if max < arr[0]*arr[1] {
		max = arr[0] * arr[1]
	}
	fmt.Println(max)
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int r,g,b,n;
long long ans,k[3005];

int main(){
	cin>>r>>g>>b>>n;
	for(int i=0;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			if(i*r+j*g<=3000) k[i*r+j*g]++;
		}
	}
	for(int i=0;i<=3000;i++){
		if(i*b<=n) ans+=k[n-i*b];
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int a,b;
	cin>>a>>b;
	cout<<(b-a)+b<<endl;
	return 0;
}
	

Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
int n,x,t;
int main()
{
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=-INF;
  cin>>N;
  ll A[N];
  REP(i,N) cin>>A[i];
  
  if(N%2==0){
    ans=0;
    REP(i,N/2) ans+=A[i*2];
    ll cnt=ans;
    REP(i,N/2){
      cnt=cnt-A[N-2-i*2]+A[N-1-i*2];
      chmax(ans,cnt);
    }
  }
  else{
    ll DP[N/2][3];
    REP(i,N/2){
      REP(j,3){
        DP[i][j]=-INF;
      }
    }
    
    DP[0][0]=A[0];
    DP[0][1]=A[1];
    DP[0][2]=A[2];
    RREP(i,N/2-1){
      chmax(DP[i][0],DP[i-1][0]+A[i*2]);
      chmax(DP[i][1],DP[i-1][0]+A[i*2+1]);
      chmax(DP[i][1],DP[i-1][1]+A[i*2+1]);
      chmax(DP[i][2],DP[i-1][0]+A[i*2+2]);
      chmax(DP[i][2],DP[i-1][1]+A[i*2+2]);
      chmax(DP[i][2],DP[i-1][2]+A[i*2+2]);
    }
    
    chmax(ans,DP[N/2-1][0]);
    chmax(ans,DP[N/2-1][1]);
    chmax(ans,DP[N/2-1][2]);
  }
  co(ans);
  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

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

int main() {
    std::ios::sync_with_stdio(false);
    LL q, h, s, d;cin >> q >> h >> s >> d;
    LL n;cin >> n;
    LL ans = 0LL;
    if(q*8LL > d && h*4LL > d && s*2LL > d){
        ans += n/2LL*d;
        n %= 2LL;
    }
    ans += n*min({q*4LL, h*2LL, s});
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    SegmentTree<int> seg(f, def) のように宣言する
    RMQ の場合 : 
    auto f = [](int a, int b){return min(a, b);};
    int def = INF;
*/
template <typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
    int n;
    vector<Monoid> dat;
    F f;
    Monoid def;

    SegmentTree(F f, Monoid def) : f(f), def(def) {}

    void build(const vector<Monoid> & vec){
        int sz = vec.size();
        n = 1;
        while(n < sz) n *= 2;
        dat.assign(2 * n - 1, def);
        for(int i = 0; i < sz; i++) dat[n - 1 + i] = vec[i];
        for(int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void update(int k, Monoid x){
        k += (n - 1);
        dat[k] = x;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

private:
    Monoid query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return dat[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

signed main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    auto f = [](ll a, ll b){return min(a, b);};
    SegmentTree<ll> seg(f,LINF);
    seg.build(a);
    ll ans = LINF;
    for(int i = 0; i < n; i++){
        ll sum = x * i;
        for(int j = 0; j < n; j++){
            sum += min(seg.query(max(0, j - i), j + 1), (j - i < 0 ? seg.query(n - (i - j), n) : LINF));
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    char c;
    cin >> c;
    
    cout << (char)(c + 1) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    string S;
    cin >> S;
    int K;
    cin >> K;
    vector<lint> lst;
    lst.push_back(1);
    FOR(i, 1, S.size()) {
        if(S[i] != S[i-1]) {
            lst.push_back(1);
        } else {
            lst[lst.size()-1]++;
        }
    }
    lint ans = 0;
    if(lst.size() == 1) {
        ans = (lst[0] * K) / 2;
    } else {
        REP(i, lst.size()) {
            ans += lst[i] / 2;
        }

        if(S[0] == S[S.size()-1]) {
            lst[0] += lst[lst.size()-1];
            lst[lst.size()-1] = 0;
        }
        REP(i, lst.size()) {
            ans += (lst[i] / 2) * (K-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// abc137c.cpp : Green Bin
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	vector<ll> v;
	while (n--){
		string s; cin>>s;
		sort(s.begin(), s.end());
		ll k = 0LL, power = 1LL;
		for(int j=9; j>=0; j--){
			k += power * (s[j]-'a');
			power *= 26LL;
		}
		v.push_back(k);
	}

	sort(v.begin(), v.end());

	ll ans = 0LL, c = 1LL, d = v[0];
	for(int i=1; i<v.size(); i++){
		if(d==v[i]) c++;
		else{
			ans += c * (c-1LL) / 2LL;
			c = 1LL;
			d = v[i];
		}
	}
	ans += c * (c-1LL) / 2LL;
	cout<< ans << endl;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 20;

int main() {
  int n, p[MAX_N], ans = 0;
  std::cin >> n;
  rep(i,n) std::cin >> p[i];

  for(int i = 1; i < n - 1; ++i) {
    int large = std::max(p[i - 1], p[i + 1]);
    int small = std::min(p[i - 1], p[i + 1]);
    if(small < p[i] and p[i] < large) ++ans;
  }

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


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

using namespace std;

typedef long long LL;

int n,x,f[100005],ans,m,a[100005];

int main()
{
	scanf("%d",&n);m=0;
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		if (i==x) a[++m]=i;
	}
	ans=0;
	int i=1;
	while (i<=m)
	{
		int j=i;
		while (j<=m&&a[j]==a[i]+j-i) ++j;
		ans+=(j-i+1)/2;
		i=j;
	}
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 640
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]

k = int(input())
s = str(input())

if len(s) <= k:
    print(s)
    exit()
else:
    result = s[0:k] + "..."
    print(result)
    exit()


Measured memory_bytes: 61720
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,m;
    lli c=0;
    cin>>n>>m;
    if(n>1)
        c+=(n*(n-1))/2;
    if(m>1)
        c+=(m*(m-1))/2;
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<cmath>
#define int long long int
int32_t main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n,m;
	 cin>>n>>m;
	 char mat[n+2][m+2];
	 int i,j;
	 for(i=0;i<=n+1;i++)
	 {
		 for(j=0;j<=m+1;j++)
		 {
			 mat[i][j]='#';
		 }
	 }
	 for(i=1;i<=n;i++)
     {
		 for(j=1;j<=m;j++)
		 {
			 cin>>mat[i][j];
		 }
	 }
	 for(i=0;i<=n+1;i++)
	 {
		 for(j=0;j<=m+1;j++)
		 {
			 cout<<mat[i][j];
		 }
		 cout<<endl;
	 }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    if(n%1000==0) cout << 0 << endl;
    else cout << 1000-n%1000 << endl;
}

Measured memory_bytes: 3184
#include <stdio.h> 
 #include <stdbool.h> 


int main(){ 
 int i, j, x;
 int num;
 char ch; 
 char marks[4]={'S', 'H', 'C', 'D'}; 
    int cards[4][13]={false};

     scanf("%d ", &x); 
     for(i=0;i<x;i++){ 
         scanf("%c %d ", &ch, &num); 
         for(j=0;j<4;j++){ 
             if(ch==marks[j]){ 
                 cards[j][num-1]=true; 
                 break; 
             } 
         } 
     } 
     for(i=0;i<4;i++){ 
         for(j=0;j<13;j++){ 
             if(!cards[i][j]){ 
                 printf("%c %d\n", marks[i], j+1); 
             } 
 } 
     }
     return 0; 
 } 


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

typedef long long ll;

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> s(N + 1, 0);
    rep(i, N - 1) {
        s[i + 2] = s[i + 1];
        if (S[i] == 'A' && S[i + 1] == 'C') s[i + 2]++;
    }
    int r, l;
    rep(i, Q) {
        cin >> l >> r;
        cout << s[r] - s[l] << endl;
    }
    //rep(i, N + 1) cout << s[i] << endl;
}

Measured memory_bytes: 1408
def main():
  h, w = map(int, input().split())
  s = [input() + '#' for _ in range(h)]
  s.append('#' * (w + 1))

  yoko = [[0] * w for _ in range(h)]
  tate = [[0] * w for _ in range(h)]

  tstart = [-1] * (w + 1)
  for i in range(h + 1):
    si = s[i]
    ystart = -1
    for j in range(w + 1):
      if si[j] == '#':
        if ystart != -1:
          for k in range(ystart, j):
            yoko[i][k] = j - ystart
          ystart = -1
        if tstart[j] != -1:
          for k in range(tstart[j], i):
            tate[k][j] = i - tstart[j]
          tstart[j] = -1
      else:
        if ystart == -1:
          ystart = j
        if tstart[j] == -1:
          tstart[j] = i

  result = 0
  for i in range(h):
    yokoi = yoko[i]
    tatei = tate[i]
    for j in range(w):
      t = yokoi[j] + tatei[j] - 1
      if t > result:
        result = t

  print(result)

main()

Measured memory_bytes: 123480
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 200005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

v<ll> fact(N);
v<ll> prime_check(1e7 + 2);
v<ll> primes;

long long powmod(long long x, long long y, long long m)
{
    long long res = 1LL;
    while (y)
    {
        if (y & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return res;
}

void init_fact()
{
    fact[0] = 1;
    for (ll i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll C(ll n, ll r)
{
    if (n < r)
        return 0;
    ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
    temp *= powmod(fact[n - r], mod - 2, mod);
    temp %= mod;
    return temp;
}

void Sieve()
{
    for (ll i = 2; i <= 1e7 + 1; i++)
    {
        if (prime_check[i])
            continue;
        primes.pb(i);
        for (ll j = 2 * i; j <= 1e7 + 1; j += i)
            prime_check[j] = i;
    }
}
ll phi(ll n)
{
    ll i, res = n;
    for (i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            while (n % i == 0)
                n /= i;
            res -= res / i;
        }
    if (n > 1)
        res -= res / n;
    return res;
}

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    ll n, k;
    cin >> n >> k;
    v<ll> a(n + 1);
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    sort(a.begin() + 1, a.begin() + n + 1);
    ll ans = 0;
    for (ll i = 1; i <= k; i++)
        ans += a[i];
    cout << ans << "\n";
}

Measured memory_bytes: 82756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    rep(i,K){
        cout << "ACL";
    }
    cout << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3652
a, b, c, d = map(int, list(input()))

def calc(n, a, b):
  if n == 0:
    return a + b
  else:
    return a - b

pm = "+-"
for i in range(2):
  num = calc(i, a, b)
  for j in range(2):
    num2 = calc(j, num, c)
    for k in range(2):
      num3 = calc(k, num2, d)
      if num3 == 7:
        ans = str(a) + pm[i] + str(b) + pm[j] + str(c) + pm[k] + str(d) + "=7"
        print(ans)
        exit()

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

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int a;
	for(int i = 0; i < m; i++) {
		scanf("%d", &a);
		n -= a;
	}
	printf("%d\n", (n < 0) ? -1 : n);
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,d,x,res=0;
    cin>>n;
    cin>>d>>x;
    int ara[n+2];
    for(int i=0;i<n;i++)cin>>ara[i];
    for(int i=0;i<n;i++)
    {
        int cnt=1,j=1;
        while(cnt<=d)
        {
            //res+=cnt;
            res++;
            cnt=(ara[i]*j)+1;
            j++;

        }
    }
    cout<<res+x<<endl;
    return 0;
}


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

using namespace std;

int N,x;
int a[200001];

int main() {
  cin >> N >> x;
  if(x == 1 || x == 2 * N - 1){
    cout <<"No"<<endl;
    return 0;
  }

  a[N-2] = x-1;
  a[N-1] = x;
  a[N] = x+1;
  int c = 1;
  for(int i = 0; i < 2 * N-1; i++) {
    if(i == N-2 || i == N-1 || i == N) continue;
    else if(c == x-1 || c == x || c == x+1) {
      i--;
      c++;
    }
    else a[i] = c++;
  }
  cout <<"Yes"<<endl;
  for(int i = 0; i < 2 * N-1; i++) cout <<a[i]<<endl;
}
    
  


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int N = 2e5 + 1;

void findAns()
{
    int n, m;
    cin >> n >> m;

    int data[m];

    for (auto&it : data) cin >> it;

    int sum = 0;

    for (int i = 0; i < m; i++) sum += data[i];

   if(sum>n)
   {
     cout<<"-1";
   }
   else if(sum==n) cout<<"0";
   else
    cout<<n-sum;
}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
// #endif

    fastio;

    // ll int t;
    // cin >> t;

    // while (t--)
    findAns();
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
bool ass[MOD];
int N;
long long ask(long long a){
  int b=0,c=0,d=0;
  while(a>0){
    if(a%10==3) b=1;
    if(a%10==5) c=1;
    if(a%10==7) d=1;
    a=a/10;
  }
  if(b==1){
    if(c==1){
    if(d==1){
    return 1;
    }
    }
  }
  else 
    return 0;
}
void aii(long long a){
  if(ask(a)==1){
    ass[a]=true;
  }
  if(a<MOD/10){
  aii(a*10+3);
  aii(a*10+5);
  aii(a*10+7);
  }
}
int main (){
  int aaa=0;
  cin>>N;
  aii(3);
  aii(5);
  aii(7);
  rep(i,N){
    if(ass[i+1]) aaa++;
  }
  cout<<aaa;
}


Measured memory_bytes: 86528
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<double> mean(n);
    for(int i = 0; i < n; i++){
        double p;
        cin >> p;
        mean[i] = (p+1.0) / 2.0;
    }
    double sum = 0;
    double mx = 0;
    for(int i = 0; i < k; i++){
            sum+= mean[i];
            mx = max(sum, mx);
    }
    for(int i = 1; i <= n - k; i++){
        sum += mean[i+k-1] - mean[i-1];
        mx = max(sum, mx); 
    }
    cout << setprecision(15) << mx << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdlib>
 
bool compare(int* a, int* b, int length){
  for(int i = 0; i < length; i++){
    if(a[i] != b[i])
      return false;
  }
  return true;
}
 
int main() {
  // int myints[] = {1,2,3};
 
  int n;
  std::cin >> n;
 
  int a[n];
  int per[n];
  int b[n];
  int rank1 = 0;
  int rank2 = 0;
  int rankCounter = 1;
 
 
  for(int i = 0; i < n; i++){
    int x;
    std::cin >> x;
    a[i] = x;
    per[i] = x;
  }
 
  for(int i = 0; i < n; i++){
    std::cin >> b[i];
  }
 
 
 
  std::sort (per,per+n);
  do {
    rankCounter++;
    if(compare(per, a, n)){
      rank1 = rankCounter;
    }
    if(compare(per, b, n)){
      rank2 = rankCounter;
    }
    if(rank1 != 0 && rank2 != 0){
      break;
    }
  } while(std::next_permutation(per, per+n));
  
  std::cout << abs(rank1-rank2) << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String[] input = sc.next().split("");
		for (int i = 0; i < input.length; i++) {
			if (i == A) {
				if (!input[i].equals("-")) {
					System.out.println("No");
					System.exit(0);
				} else {
					continue;
				}
			}
			try {
				Integer.parseInt(input[i]);
			} catch (Exception e) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}
}


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

#define MIN(A,B) (A)<(B)?(A):(B)
#define MAX(A,B) (A)>(B)?(A):(B)

#define N 5

int main(){
  int n, a, b, c=0, i, z;
  int A[100], B[100], C[100];

  scanf("%d", &n);
  for (i=1; i<=n; i++) scanf("%d", &A[i]);
  for (i=1; i<=n; i++) scanf("%d", &B[i]);
  for (i=1; i<=n-1; i++) scanf("%d", &C[i]);

  z=0;
  for (i=1; i<=n; i++){
    z+=B[A[i]];
    if (i>=2) {
      if (A[i]==A[i-1]+1) z+=C[A[i-1]];
    }
  }
  printf("%d\n", z);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	vector<string>v={""};
	int x,y;
	cin>>x>>y;
	if(x==6&&y==4)x=4,y=4,v={"AA"};
	if(x==5&&y==5)x=4,y=4,v={"AB","BA"};
	if(x==4&&y==6)x=4,y=4,v={"BB"};
	if(x==5)x=4,v={"A"};
	if(y==5)y=4,v={"B"};
	string perm;
	for(;x--;)perm+='A';
	for(;y--;)perm+='B';
	do{
		for(auto &e:v)cout<<perm<<e<<endl;
	}while(next_permutation(perm.begin(),perm.end()));
}

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

int main() {
  string s;
  cin >> s;
  int count, target;
  count = 0;
  target = s.size() / 2;
  for (int i = 0; i < target; ++i) {
    if (s[i] != s[s.size() - i -1]) ++count;
  }
  cout << count << endl;
} 



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

int main(){string s, t;
cin >> s >> t;
sort(s.begin(), s.end());
sort(t.begin(), t.end());
reverse(t.begin(), t.end());
rep(i, min(s.size(), t.size())){
    if(s.at(i) < t.at(i)){
        cout << "Yes" << endl;
        return 0;
    }
    else if(s.at(i) > t.at(i)){
        cout << "No" << endl;
        return 0;
    }
    
}
if(s.size() >= t.size()) cout << "No" << endl;
else cout << "Yes" << endl;
// cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
  string D;
  string S = "AIDUNYAN";
  string R = "AIZUNYAN";
  int len;
  cin >> D;
  len = D.size();
  D += "*****";
  sort(S.begin(), S.end());
  string ans = D;
  do{
    for(int i = 0; i <= D.size() - S.size(); i++){
      if(D.substr(i, S.size()) == S){
	for(int j = 0; j < S.size(); j++){
	  ans[i + j] = R[j];
	}
      }
    }
  }while(next_permutation(S.begin(), S.end()));
  cout << ans.substr(0, len) << endl;
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int w[n];
  for(int i=0;i<n;i++)cin >> w[i];
  int d=0;
  int dd=0;
  for(int i=0;i<n;i++){
  dd+=w[i];
  }
  int m=1000000;
  for(int t=0;t<n;t++){
  	d+=w[t];
    dd-=w[t];
    m=min(abs(d-dd),m);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
var stdin = function() {
	if (require('os').type().toString().match('Windows')) return 0;
	else return '/dev/stdin';
}();
var ab = require('fs').readFileSync(stdin).toString().split(/ /).map(Number);
var a = ab[0], b = ab[1];
console.log(a * b, 2 * (a + b));

Measured memory_bytes: 15804
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i;cin>>n;
	cout<<(n+(1110-n)%111)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

const int N=300035;

int n,a[N];
ll ans=-1e18,sum,f[N],g[N];
priority_queue<int,vector<int>,greater<int> >q;

int main() {
	n=rd();
	For (i,1,3*n) a[i]=rd();
	For (i,1,n) q.push(a[i]),sum+=a[i];
	
	For (i,n+1,2*n) {
		f[i-1]=sum;
		if (q.top()<a[i]) sum-=q.top(),q.pop(),sum+=a[i],q.push(a[i]);
	}
	f[2*n]=sum,sum=0;
	while (!q.empty()) q.pop();
	
	Dep (i,3*n,2*n+1) q.push(-a[i]),sum+=a[i];
	Dep (i,2*n,n) {
		g[i+1]=sum;
		if (-q.top()>-a[i]) sum+=q.top(),q.pop(),sum+=a[i],q.push(-a[i]);
	}
	g[n]=sum;
	
	For (i,n,2*n) ans=max(ans,f[i]-g[i+1]);
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 4856
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    /*public static StreamTokenizer in;
    static {
        try{
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in))));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public static int nextInt() throws IOException{ in.nextToken(); return (int)in.nval; }*/
    public static void main(String[] args) throws IOException{
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        long a=sc.nextLong();
        long b=100;
        int ans=0;
        for(int i=0;;i++){
            b*=1.01;
            ans++;
            if(b>=a){
                System.out.println(ans);
                break;
            }
        }
    }
}


Measured memory_bytes: 35780
N = gets.to_i
T,A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)

argmin = -1
min = 10**9

H.each_with_index do |x, i|
  tmp = ((T - H[i] * 0.006) - A).abs

  if tmp < min
    min = tmp
    argmin = i+1
  end
end

puts argmin


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007ll;
//const long long MOD = 998244353ll;
const int INF = 1000000001;
 
long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}
 
ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  while (q-- >0) {
    int n;
    cin >> n;

    int f[n + 1];
    f[1] = 1;
    ll res = 0ll;
    for (int i = 1; i <= n; ++i) {
      int m = n / i;
      res += i * 1ll * (m * 1ll * (m + 1) / 2);
    }
    cout << res << endl;
  }

 
  return 0;
}


Measured memory_bytes: 3648
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
using namespace std;
typedef long long int ll;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};
ll mod=1000000007LL;
ll n;
ll big[200002]={};
ll small[200002]={};

ll modk(ll a, ll b){
	a=(a*b)%mod;
	return a;
}
ll modk(ll a, ll b, ll c){
	a=(a*b)%mod;
	a=(a*c)%mod;
	return a;
}


int main(){
	ll k,n;
	cin>>n>>k;
	ll bigcounter=0;
	ll smallcounter=0;
	for(ll i=0;i<n;i++){
		ll temp;cin>>temp;
		if(temp>=0){
			big[bigcounter]=temp;
			bigcounter++;
		}
		if(temp<0){
			small[smallcounter]=-temp;
			smallcounter++;
		}
	}
	sort(big,big+bigcounter);
	sort(small,small+smallcounter);
	bigcounter--;
	smallcounter--;
	ll ans=1;
	if(bigcounter!=-1 or k%2==0){
		while(k>0){
			if(k>=2){
				if(bigcounter>=1 and smallcounter>=1){
					if(big[bigcounter]*big[bigcounter-1]>small[smallcounter]*small[smallcounter-1]){
						k--;
						ans=modk(ans,big[bigcounter]);
						bigcounter--;
					}
					else{
						k=k-2;
						ans=modk(ans,small[smallcounter],small[smallcounter-1]);
						smallcounter=smallcounter-2;
					}
				}
				else{
					if(smallcounter<=0){
						if(bigcounter!=-1){
							k--;
							ans=modk(ans,big[bigcounter]);
							bigcounter--;
						}
						else{
							k--;
							ans=mod-modk(ans,small[smallcounter]);
							ans=ans%mod;
							smallcounter--;
						}
					}
					else{
						if(k%2==1){
							k--;
							ans=modk(ans,big[bigcounter]);
							bigcounter--;
						}
						else{
							k=k-2;
							ans=modk(ans,small[smallcounter],small[smallcounter-1]);
							smallcounter=smallcounter-2;
						}
					}
				}
			}
			else{
				if(bigcounter!=-1){
					k--;
					ans=modk(ans,big[bigcounter]);
					bigcounter--;
				}
				else{
					k--;
					ans=mod-modk(ans,small[smallcounter]);
					ans=ans%mod;
					smallcounter--;
				}
			}
			//cout<<ans<<" "<<k<<" "<<smallcounter<<" "<<bigcounter<<endl;
		}
	}
	else{
		ll temp=0;
		while(k>0){
			k--;
			ans=mod-modk(ans,small[temp]);
			ans=ans%mod;
			temp++;
		}
	}
	ans=ans%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 5160
for i in range(50):
    m, f, r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif  m + f >= 80:
        print("A")
    elif  m + f >= 65:
        print("B")
    elif  m + f >= 50:
        print("C")
    elif  m + f >= 30:
        if r >= 50:
            print("C")
        else:       
            print("D")
    else:
        print("F")    


Measured memory_bytes: 5596
#横にn個入力
n, k = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
nli = []
b = 0
for i in range(n):
    for j in range(i, n):
        b += a[j]
        nli.append(b)
    b = 0
nli.sort(reverse=True)
m = 41
x = 0

cnt = 0
candili = []
for i in range(m - 1, -1, -1):
    if x == 0:
        for j in range(len(nli)):
            if nli[j] & (x + 2 ** i) == x + 2 ** i:
                candili.append(nli[j])
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
            candili = []
    else:
        for j in candili:
            if j & (x + 2 ** i) == x + 2 ** i:
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
print(x)

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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=1000000;

ll N,a[MAX_N];

int main(){
  cin>>N;
  a[0]=0;
  for(ll i=1;i<=N;i++)cin>>a[i];
  a[N+1]=0;
  ll asum=0;
  for(ll i=0;i<=N;i++){
    asum+=abs(a[i+1]-a[i]);
  }
  for(ll i=1;i<=N;i++){
    cout<<(asum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))<<endl;
  }
  return 0;
}


Measured memory_bytes: 2048