akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
//P e[10000];
int es[105][1005] = { 0 };
int main() {
	while (true) {
		int n, m, a;
		cin >> n >> m >> a;
		if (n == 0) return 0;
		for (int i = 0; i < 105; i++)
			for (int j = 0; j < 1005; j++) es[i][j] = 0;
		for (int i = 0; i < m; i++) {
			int h, p, q;
			cin >> h >> p >> q;
			//e[h] = P(p, q);
			es[p][h] = q;
			es[q][h] = p;
		}
		int now = 1000;
		int ite = a;
		while (now >= 1) {
			if (es[ite][now] > 0) {
				ite = es[ite][now];
			}
			now--;
		}
		cout << ite << endl;
	}
	return 0;
}


Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n;
char s[N];
void input()
{
	scanf("%s",s+1);
	n=strlen(s+1);
}
int sum[N],nex[N][3];
const int mo=1e9+7;
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
int dp[N],ans;
void work()
{
	int flag=0;
	For(i,2,n)if(s[i]==s[i-1])flag=1;
	if(!flag){puts("1");return;}
	For(i,1,n)sum[i]=sum[i-1]+(s[i]-'a'+1);
	For(i,0,2)nex[n+1][i]=n+1;
	Fordown(i,n,1)
	{
		For(j,0,2)nex[i][j]=nex[i+1][j];
		nex[i][sum[i]%3]=i;
	}
	dp[0]=1;
	For(i,0,n)
	{
		For(j,1,2)
		{
			add(dp[nex[i+1][(sum[i]+j)%3]],dp[i]);
			//cout<<i<<' '<<nex[i+1][(sum[i]+j)%3]<<endl;
		}
		if(i&&sum[i]%3==sum[n]%3)add(ans,dp[i]);
	}
	write(ans,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 2432
a = input()
n= len(a)
if n == 3:
  print('Yes')
  exit()
for i in range(n//2):
  if a[i] != a[-1-i]:
    print('No')
    exit()
for i in range(n//2//2):
  if a[i] != a[n//2-1-i]:
    print('No')
    exit()
  if a[(n-1+3)//2+i] != a[-1-i]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll a,b;
int main(void){
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int B[109];

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

	int N; cin >> N;
	for (int i = 0; i < N - 1; i++) cin >> B[i];

	int ans = B[0] + B[N - 2];
	for (int i = 0; i < N - 2; i++) {
		ans += min(B[i], B[i + 1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N;
    cin >> N;
    cout << N * 800 - (N / 15) * 200 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read();
int f[202][202];
char s[202][202];
int main() {
    int h = read(), w = read();
    for (int i = 1; i <= h; ++i) scanf("%s", s[i] + 1);
    for (int i = 1; i <= w; ++i)
        f[1][i] = f[1][i - 1] + (s[1][i] == '#') -
                  (s[1][i] == '#' && s[1][i - 1] == '#');
    for (int i = 2; i <= h; ++i) {
        f[i][1] = f[i - 1][1] + (s[i][1] == '#') -
                  (s[i][1] == '#' && s[i - 1][1] == '#');
        for (int j = 2; j <= w; ++j)
            f[i][j] = min(f[i - 1][j] + (s[i][j] == '#') -
                              (s[i][j] == '#' && s[i - 1][j] == '#'),
                          f[i][j - 1] + (s[i][j] == '#') -
                              (s[i][j] == '#' && s[i][j - 1] == '#'));
    }
    printf("%d\n", f[h][w]);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 384
#include<algorithm>
#include<cstdio>
using namespace std;
int n,K,sl,fh,f[1<<21][22];
char X[1<<20];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void print(int s,int i)
{
	for(--i;~i;putchar(((s>>i)&1)+'0'),--i);
	puts("");
}
int main()
{
	n=rd();K=rd();int x,s1,s2,res;
	for(int i=0;i<=n;++i)
	{
		scanf("%s",X);
		for(int j=0;j<1<<i;++j)
			f[(1<<i)|j][i]=X[j]=='1';
	}
	for(int p,i=n;i;--i)
		for(int j=0;j<1<<i;++j)
			for(int k=i;k;--k)
				if((res=f[x=(1<<i)|j][k]))
				{
					s1=x>>k;s2=x^(s1<<k);
					if(k) f[s1][0]+=res;
					if(s2)
					{
						p=k-1;for(;(~p)&&!((s2>>p)&1);--p);
						f[(s1<<1|1)<<p|(s2&((1<<p)-1))][p]+=res;
					}
					if((~s2)&((1<<k)-1))
					{
						p=k-1;for(;(~p)&&((s2>>p)&1);--p);
						f[(s1<<1)<<p|(s2&((1<<p)-1))][p]+=res;
					}
				}
	for(int i=n;i;--i)
		for(int j=0;j<1<<i;++j)
			if(f[(1<<i)|j][0]>=K)
				return print(j,i),0;
	return 0;
}

Measured memory_bytes: 181504
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,m,n,a,b;
    cin>>a>>b;
    if((a==1||a==5||a==3||a==7||a==8||a==10||a==12)&&(b==1||b==5||b==3||b==7||b==8||b==10||b==12))
    {
        cout<<"Yes"<<endl;
    }
    else if((a==4||a==6||a==9||a==11)&&(b==4||b==6||b==9||b==11))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  vector<pair<ll,ll> > v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(mp(a,i));
  }
  sort(all(v));
  rep(i,0,v.sz){
    cout << v[i].se+1;
    if(v.sz-1!=i)cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2544
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double W = sc.nextDouble();
    double H = sc.nextDouble();
    double x = sc.nextDouble();
    double y = sc.nextDouble();
    
    int judge = 0;
    double ans = W*H/2;
    if(W/2==x && H/2==y){
      judge = 1;
    }
    
    System.out.println(ans + " " + judge);
    
  }
}

Measured memory_bytes: 39396
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  ll n,m,h;
  cin >> n >> m >> h;
  vector<vector<ll>>A(n , vector<ll>(m));
  vector<vector<ll>>B(m , vector<ll>(h));
  for (int i = 0; i < n; i++) {
    for (int l = 0; l < m; l++) {
      cin >> A[i][l];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int l = 0; l < h; l++) {
      cin >> B[i][l];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int l = 0; l < h; l++) {
      ll ans = 0;
      for (int j = 0; j < m; j++) {
        ans += A[i][j] * B[j][l];
      }
      cout << ans << (l == h-1 ? "" : " ");
    }
    cout << endl;
  }
}




Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	int W;
	cin>>W;
	string s[2];
	rep(i,2) cin>>s[i];
	int p = 3;
	ll ans = 1;
	rep(i,W){
		if(s[0][i]==s[1][i]){
			ans *= p;
			p = 2;
		}else{
			if(p!=1) ans *= p*(p-1);
			else ans *= 3;
			p = 1;
			i++;
		}
	}
	int mod = 1e9+7;
	cout<<ans%mod<<endl;
}


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

def make_lunlun(lunlun_lst):
    ret_lunlun = []
    for num in lunlun_lst:
        num_str = str(num)
        if num_str[-1] != "0":
            num_tmp = num_str + str(int(num_str[-1]) - 1)
            ret_lunlun.append(int(num_tmp))
        if num_str[-1] != "9":
            num_tmp = num_str + str(int(num_str[-1]) + 1)
            ret_lunlun.append(int(num_tmp))
        num_tmp = num_str + num_str[-1]
        ret_lunlun.append(int(num_tmp))
    return ret_lunlun

lunlun_lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]

while 1:
    if len(lunlun_lst) < k:
        k -= len(lunlun_lst)
        lunlun_lst = make_lunlun(lunlun_lst)
    else:
        lunlun_lst.sort()
        print(lunlun_lst[k - 1])
        break


Measured memory_bytes: 16128
import java.util.*;
public class Main {
	

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		
		
		int x = sc.nextInt();
		int a = sc.nextInt();
		
		System.out.println(x < a ? 0 : 10 );
		
	}
	


}

Measured memory_bytes: 22740
import java.util.*;
class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int K = sc.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
    int A = sc.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
    int B = sc.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
    
    while(A <=B){
      if (A % K == 0){
        System.out.println("OK");
        return;
      }
      A++;
    }
    System.out.println("NG");
        
  }
}


Measured memory_bytes: 35756
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int dh[4]={1, 0, -1, 0};
const int dw[4]={0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    int ans=H*W;
    for(int h=0; h<H; h++) {
        cin >> field[h];
        for(int w=0; w<W; w++) {
            if(field[h][w]=='#') ans--;
        }
    }
    
    vector<vector<int> > dist(H, vector<int>(W, -1));
    dist[0][0]=1;
    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        int curh=que.front()/W;
        int curw=que.front()%W;
        que.pop();
        
        for(int dir=0; dir<4; dir++) {
            if(curh+dh[dir]<0 || curh+dh[dir]>=H || curw+dw[dir]<0 || curw+dw[dir]>=W) continue;
            if(field[curh+dh[dir]][curw+dw[dir]]=='#') continue;
            if(dist[curh+dh[dir]][curw+dw[dir]]!=-1) continue;
            
            dist[curh+dh[dir]][curw+dw[dir]] = dist[curh][curw]+1;
            que.push((curh+dh[dir])*W+curw+dw[dir]);
        }
    }
    
    if(dist[H-1][W-1]==-1) {
        cout << -1 << endl;
    } else {
        cout << ans-dist[H-1][W-1] << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
typedef pair<int,pi> pp;
#define p(x,y,z) pp(z,pi(x,y))

set <string> S;
int n;

int32_t main() {
	cin >> n;
	for (int i =0;i<n;i++) {
		string s; cin >> s;
		S.insert(s);
	}
	cout << S.size();
}




Measured memory_bytes: 19124
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)
 
class UnionFind {
  vector<int> p;
public:
  UnionFind (int n) : p(n, -1) {}
  int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};
 
int n,m;
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n>>m;
  UnionFind uf(n+m);
  REP(i,n)
  {
    int k; cin>>k;
    REP(j,k)
    {
      int l; cin>>l; l--;
      uf.unite(i, n+l);
    }
  }
  int r = uf.root(0);
  REP(i,n)
  {
    if (r != uf.root(i))
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846

const int MAX_N = 100;
vector<int> xy(MAX_N);
 
void solve()
{
        int n; cin >> n;
        vector<int> a(n);
        forn(i, n) cin >> a[i];
        sort(rall(a));
        int alice = 0, bob = 0;
        forn(i, n)
        {
                if(i % 2 == 0)
                {
                        alice += a[i];
                }
                else bob += a[i];
        }
        cout << alice - bob;
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 256
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;
int dp[SIZE];
int cnt[SIZE];


void solve(){
	int a,b;
	cin >> a >> b;
	cout << max(0,a-b*2) << endl;
}













int main(){
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


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

int N;

void solve(){
    double ans;
    if(N % 2 == 0) ans = (double) 1 / 2;
    else ans = (double)((N - 1) / 2 + 1) / N;
    cout << fixed << setprecision(10) << ans;
}
int main(){
    cin >> N;
    solve();
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> f(N + 1);
    for (int x = 1; x * x <= N; ++x) {
        for (int y = 1; y * y <= N; ++y) {
            for (int z = 1; z * z <= N; ++z) {
                int lhs = x*x + y*y + z*z + x*y + y*z + z*x;
                if (lhs > N) continue;
                f[lhs]++;
            }
        }
    }

    for (int i = 1; i <= N; ++i) {
        cout << f[i] << endl;
    }
}



Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
 int n=rr,sum=0;
 int v[55];
 rep(i,0,n)
 {
   v[i]=rr;
 } 
rep(i,0,n)
 {
   int c=rr;
   if(v[i]>c)sum+=(v[i]-c);
 } 
cout<<sum;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls (rt<<1)
#define rs ((rt<<1)|1)
#define cmin(a,b) a=min(a,b)
using namespace std;
typedef long long ll;
ll n,Q,A,B;
ll rd()
{
	ll rx=0,fx=1;char c=getchar();
	while(c<48||c>57)
	{
		if(c=='-') fx=-1;
		c=getchar();
	}
	while(c>=48&&c<=57)
	{
		rx=rx*10+c-48;
		c=getchar();
	}
	return rx*fx;
}
const ll N=2e5+50,V=N<<2,inf=1e15;
ll X[N];
struct Segment_tree
{
	ll vmi[V],ami[V],bmi[V],tag[V];
	void cover(ll rt,ll w)
	{
		vmi[rt]+=w;ami[rt]+=w;bmi[rt]+=w;tag[rt]+=w;
	}
	void mdown(ll rt)
	{
		if(tag[rt])
		{
			cover(ls,tag[rt]);cover(rs,tag[rt]);
			tag[rt]=0;
		}
	}
	void mup(ll rt)
	{
		vmi[rt]=min(vmi[ls],vmi[rs]);
		ami[rt]=min(ami[ls],ami[rs]);
		bmi[rt]=min(bmi[ls],bmi[rs]);
	}
	void build(ll rt,ll l,ll r)
	{
		if(l==r)
		{
			vmi[rt]=ami[rt]=bmi[rt]=inf;return ;
		}
		ll mid=(l+r)>>1;
		build(ls,l,mid);build(rs,mid+1,r);
		mup(rt);
	}
	void chg(ll rt,ll l,ll r,ll x,ll w)
	{
		if(l==r)
		{
			vmi[rt]=w;ami[rt]=w-l;bmi[rt]=w+l;
			//printf("U%lld %lld\n",x,w);
			return ;
		}
		ll mid=(l+r)>>1;
		mdown(rt);
		if(mid>=x) chg(ls,l,mid,x,w);
		else chg(rs,mid+1,r,x,w);
		mup(rt);
	}
	ll qry(ll rt,ll l,ll r,ll x,ll y,ll typ)
	{
		if(l>=x&&r<=y)
		{
			if(typ==0) return ami[rt];
			else return bmi[rt];
		}
		ll mid=(l+r)>>1,ras=inf;
		mdown(rt);
		if(mid>=x) cmin(ras,qry(ls,l,mid,x,y,typ));
		if(mid<y) cmin(ras,qry(rs,mid+1,r,x,y,typ));
		return ras; 
	}
}sgt;
int main()
{
	ll i,val;
	n=rd();Q=rd();A=rd();B=rd();	
	sgt.build(1,1,n);
	sgt.chg(1,1,n,B,0);
	X[0]=A;
	for(i=1;i<=Q;i++) X[i]=rd();
	for(i=1;i<=Q;i++)
	{
		val=min(sgt.qry(1,1,n,1,X[i],0)+X[i],sgt.qry(1,1,n,X[i],n,1)-X[i]);
		//printf("P%lld %lld %lld %lld\n",i,val,sgt.qry(1,1,n,1,X[i],0),sgt.qry(1,1,n,X[i],n,1));
		sgt.cover(1,abs(X[i]-X[i-1]));
		sgt.chg(1,1,n,X[i-1],val);
	}
	printf("%lld",sgt.vmi[1]);
	return 0;
}

Measured memory_bytes: 26368
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;

	return 0;
}


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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, train, taxi;
    cin >> n >> train >> taxi;
    train = train * n;
    cout << min(train, taxi) << '\n';
    return 0;
}

Measured memory_bytes: 256
import itertools
t=[0]*5
for i in range(5): t[i]=int(input())
t=list(itertools.permutations(t))
ans=10**5
for i in t:
    a=0
    for j in i:
        if a!=0: a+=0 if a%10==0 else 10-(a%10)
        a+=j
    ans=min(ans,a)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

void call(int n);

int main()
{
    int n = 0;
    std::cin >> n;
    call( n );
}

void call(int n)
{
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  int hh,ah,dh,sh;
  cin>>hh>>ah>>dh>>sh;
  pair<int,int> p[40000];
  long long dmg=0;
  int INF=1<<30;
  long long dpt=0;
  for(int i=0;i<n;i++){
    int h,a,d,s;
    cin>>h>>a>>d>>s;
    int of=max(0,a-dh);
    int df=max(0,ah-d);
    if(s>sh){
      dmg+=of;
      if(dmg>=hh){
	cout<<-1<<endl;
	return 0;
      }
    }
    dpt+=of;
    p[i]=make_pair(of,df?(h+df-1)/df:INF);
  }
  sort(p,p+n,[](pair<int,int> a,pair<int,int> b){
      return a.first*1./a.second>b.first*1./b.second;
    });
  for(int i=0;i<n;i++){
    if(p[i].second==0){
      if(p[i].first>0){
	cout<<-1<<endl;
	return 0;
      }
    }else{
      dmg+=dpt*p[i].second-p[i].first;
      if(dmg>=hh){
	cout<<-1<<endl;
	return 0;
      }
      dpt-=p[i].first;
    }
  }
  cout<<dmg<<endl;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
vector<string> v;
vi a;
int fun(string s){
	int res = 0;
	reverse(all(s));
	for(int i=0 ; i<sz(s) ; i++){
		res += pow(10,i)*(s[i] - '0');
	}
	return res;
}
void dfs(string s , int len){
	if(len == 11){
		v.pb(s);
		return ;
	}
 	if(len == 0){
		for(int i=0 ; i<=9 ; i++){
			dfs(s  + to_string(i) , len + 1);
		}
	}
	else{
		int last = s.back() - '0';
		int pp = fun(s);
			if(pp == 0){
				for(int i=0 ; i<=9 ; i++){
				dfs(s  + to_string(i) , len + 1);
				}
				return;
			}
		for(int i=-1 ; i<=1 ; i++){
			if(last + i >=0 && last + i <= 9){
				dfs(s + to_string(last + i) , len + 1);
			}
		}
 	}
}

int32_t main(){
	fast;
	dfs("",0);
	int k;
	cin >> k;
	for(auto ss : v) a.pb(fun(ss));
	sort(all(a));
 	cout << a[k];
}


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

#define long long long

using namespace std;

const int N = 2e3+5;
const int M = 998244353;

long modpow(long a, long b) {
    long ret = 1;
    for( ; b; b >>= 1) {
        if(b & 1) ret = (ret * a) % M;
        a = (a * a) % M;
    }
    return ret;
}

long f[2 * N], inv[2 * N];

long ncr(int a, int b) {
    if(b > a || a < 0 || b < 0) return 0;
    return f[a] * inv[b] % M * inv[a - b] % M;
}

int n, k;

void solve(int x) {
    int cnt = 0, left;
    for(int i = 1; i <= k; i++) if(1 <= x - i && x - i <= k)
        ++cnt;
    left = k - cnt, cnt >>= 1;
    long ans = 0;
    for(int i = 0; i <= cnt; i++) {
        long now;
        if(x & 1) now = ncr(n + left - 1, i + left - 1);
        else {
            now = ncr(n + left - 1, i + left - 1);
            now = (now + ncr(n + left - 2, i + left - 1)) % M;
        }
        now = now * ncr(cnt, i) % M * modpow(2, i) % M;
        ans = (ans + now) % M;
    }
    printf("%lld\n", ans);
}

int main() {
    f[0] = inv[0] = 1;
    for(int i = 1; i < 2 * N; i++) {
        f[i] = (f[i-1] * i) % M;
        inv[i] = modpow(f[i], M-2);
    }

    scanf("%d %d", &k, &n);
    for(int i = 2; i <= 2 * k; i++) solve(i);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>

typedef long long ll;

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

   std::string S;
   ll counts[] = {0, 0, 0, 0, 0};
   for(int i=0; i<N; ++i){
      std::cin >> S;
      if(S[0]=='M'){
	 ++counts[0];
      }else if(S[0]=='A'){
	 ++counts[1];
      }else if(S[0]=='R'){
	 ++counts[2];
      }else if(S[0]=='C'){
	 ++counts[3];
      }else if(S[0]=='H'){
	 ++counts[4];
      }
   }

   ll ans = 0;
   for(int i=0; i<3; ++i){
      for(int j=i+1; j<4; ++j){
	 for(int k=j+1; k<5; ++k){
	    ans += counts[i] * counts[j] * counts[k];
	 }
      }
   }
   std::cout << ans << std::endl;
   return 0;
}


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

int main() {
    int MAX = 10000;
    int n;
    int a[MAX] = {};

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

    for (int i = 0; i < n; ++i) {
        cout << a[n - i - 1];
        if (i == (n-1)) {
            cout << endl;
        } else {
            cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>

#define EPS 1e-8

using namespace std;

typedef complex<double> P; 
typedef vector<P> G;

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

struct L : public vector<P> {
    L(const P &a, const P &b){
        push_back(a);
        push_back(b);
    }
    L(){}
};

struct C{
    P p;
    double r;
    C(const P &p, double r) : p(p), r(r) { }
    C(){}
};

bool intersectSP(const L &s, const P &p) {
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

#define curr(G, i) G[i]
#define next(G, i) G[(i+1)%G.size()]
enum { OUT, ON, IN };
int contains(const G &g, const P &p) {
    bool in = false;
    for (int i = 0; i < g.size(); ++i) {
        P a = curr(g,i) - p, b = next(g,i) - p;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b))
            if (cross(a, b) < 0) in = !in;
        if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
    }
    return in ? IN : OUT;
}

int main(){
    int tmpx, tmpy,r;
    while(cin >> tmpx >> tmpy){
        if((tmpx | tmpy) == 0) break;
        G v(3);
        L *e = new L[3];
        C c;
        v[0] = P(tmpx, tmpy);
        cin >> tmpx >> tmpy;
        v[1] = P(tmpx, tmpy);
        cin >> tmpx >> tmpy;
        v[2] = P(tmpx, tmpy);
        e[0] = L(v[0],v[1]);
        e[1] = L(v[0],v[2]);
        e[2] = L(v[1],v[2]);
        cin >> tmpx >> tmpy >> r;
        c = C(P(tmpx,tmpy), r);
        //a:T contains C
        bool isA = true;
        for(int i=0;i<3;i++){
            //for all edges
            if(distanceSP(e[i], c.p) < r){
                isA = false;
            }
        }
        if(isA && contains(v, c.p) == IN){
            cout << "a" << endl;
            continue;
        }
        //b:C contains T
        bool isB = true;
        for(int i=0;i<3;i++){
            //for all vertex
            if(abs(v[i] - c.p) > r){
                isB = false;
            }
        }
        if(isB){
            cout << "b" << endl;
            continue;
        }
        bool isC = false;
        for(int i=0;i<3;i++){
            if(distanceSP(e[i], c.p) <= r){
                isC = true;
            }
        }
        if(isC){
            cout << "c" << endl;
        }else{
            cout << "d" << endl;
        }
    }
}

Measured memory_bytes: 0
import itertools
n = int(input())

lst = [0] * 10 ** 5
combs = list(itertools.combinations_with_replacement([_ for _ in range(1, 100)], 3))

st = {1:1, 2:3, 3:6}
for _ in combs:
    x, y, z = _[0], _[1], _[2]
    num = x ** 2 + y ** 2 + z ** 2 + (x * y) + (y * z) + (z * x)
    lst[num-1] += st[len(set(_))]

for _ in range(n):
  print(lst[_])

Measured memory_bytes: 89880
import scala.io.Source.stdin

case class Node(
  id: Int,
  children: List[Int],
  parent: Int = -1,
  depth: Int = 0
) {
  override def toString() = {
    val name = if (depth == 0) {
      "root"
    } else if (children.length > 0) {
      "internal node"
    } else {
      "leaf"
    }
    s"node $id: parent = $parent, depth = $depth, ${ name }, [${children.mkString(", ")}]"
  }
}

object Main {
  def main(argv: Array[String]) = {
    val head :: tail = stdin.getLines.toList
    val count = head.toInt
    val nodes = new Array[Node](count)

    tail.foreach { line =>
      val id :: count :: children = line.split(" ").map(_.toInt).toList
      nodes(id) = Node(id, children)
    }

    nodes foreach { node =>
      node.children.foreach { id =>
        val child = nodes(id)
        nodes(id) = child.copy(parent = node.id)
      }
    }

    nodes.find(n => n.parent == -1).foreach { root =>
      recursive(0, root, nodes)
    }

    nodes.foreach { node =>
      println(node)
    }
  }

  def recursive(currentDepth: Int, node: Node, nodes: Array[Node]): Unit = {
    node.children.foreach { id =>
      nodes(id) = nodes(id).copy(depth = currentDepth + 1)
    }

    node.children.foreach { id =>
      recursive(currentDepth + 1, nodes(id), nodes)
    }
  }
}



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

int main(void){
  int n;
  char c;

  scanf("%d",&n);

  int ans = 0,now = 0;

  c = getchar();

  for(int i=0;i<n;i++){
    c = getchar();
    if(c=='I')
      now++;
    else
      now--;
    ans = max(ans,now);
  }

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

  return 0;
}


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

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


using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;



P swap(P p){
  int tmp = p.first;
  p.first = p.second;
  p.second = tmp;
  return p;
}

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  if(is_sorted(p.begin(),p.end())){
    cout << "YES" << endl;
    return 0;
  }
  rep(i,N-1){
    for(int j = i+1; j < N; ++j){
      P s = make_pair(p[i],p[j]);
      s = swap(s);
      p[i] = s.first;
      p[j] = s.second;
      if(is_sorted(p.begin(),p.end())){
        cout << "YES" << endl;
        return 0;
      }
      //配列は非破壊
      s = swap(s);
      p[i] = s.first;
      p[j] = s.second;
    }
  }
  cout << "NO" << endl;
  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_Q 100000
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i + 1);
  }
  sort(A.begin(), A.end());
  rep(i, N) {
    if (i == N - 1)
      cout << A[i].second << endl;
    else
      cout << A[i].second << " ";
  }
  return 0;
}


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

int main()
{
	for(int i = 1; i < 10; i++)
	{
		for(int j = 1; j < 10; j++)
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
int main(){
  const int mod = 1000000007;

  int n;
  long long dp[201][201] = {{}};
  char c[200];

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  dp[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= i; j++){
      if(c[i] == '-'){
        dp[i + 1][j] = dp[i][j];
      } else if(c[i] == 'U') {
        (dp[i + 1][j] += dp[i][j] * j) %= mod;
        (dp[i + 1][j + 1] += dp[i][j]) %= mod;
      } else {
        (dp[i + 1][j] += dp[i][j] * j) %= mod;
        if(j) (dp[i + 1][j - 1] += dp[i][j] * j * j) %= mod;
      }
    }
  }
  cout << dp[n][0] << endl;
}

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

int main(){
  int a,b,c,d,sum,max,m[110],sumn;
  cin >> a >> b >> c >> d;
  sum=d;
  sumn=b;
  max=d/b;
  for(int i=0;i<a;i++)cin >> m[i];
  sort(m,m+a);

  for(int i=a-1;i>=0;i--){
    sum+=m[i];
    sumn+=c;
    if(max<sum/sumn)max=sum/sumn;
  }
  cout << max << endl;
}

Measured memory_bytes: 1176
n=int(input())
d=[10*[0]for _ in range(10)]
for i in range(1,n+1):d[int(str(i)[0])][int(str(i)[-1])]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):ans+=d[i][j]*d[j][i]
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)

n=int(input())
edge=[[]for i in range(n+1)]

for i in range(n-1):
    u,v,w=map(int,input().split())
    if w%2==0:
        edge[u].append((v,1))
        edge[v].append((u,1))
    else:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
        
color=[None]*(n+1)

def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)

set_color(1,1)
for i in color[1:]:
    print((i+1)//2)


Measured memory_bytes: 76464
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

unsigned long long str_to_int(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	string s;
	cin >> s;
	int len = s.length();
	rep(i,len){
		s = s.substr(0,s.length()-1);
		if(s.substr(0,s.length()/2) == s.substr(s.length()/2,s.length()/2) and s.length() % 2 == 0){
			P(s.length());
			return;
		}
	}
}

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

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

Measured memory_bytes: 128
import sys
input=sys.stdin.readline
from heapq import heappush,heappushpop
x,y,z=map(int,input().split())
ABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]
ABC.sort(key=lambda x: x[0]-x[1])
cy=0
hq=[]
for a,b,c in ABC[:y]:
    cy+=b
    heappush(hq,b-c)
Ly=[cy]
for a,b,c in ABC[y:y+z]:
    cy+=b-heappushpop(hq,b-c)
    Ly.append(cy)
cx=0
hq=[]
for a,b,c in ABC[y+z:]:
    cx+=a
    heappush(hq,a-c)
Lx=[cx]
for a,b,c in reversed(ABC[y:y+z]):
    cx+=a-heappushpop(hq,a-c)
    Lx.append(cx)
print(max(i+j for i,j in zip(Lx[::-1],Ly)))

Measured memory_bytes: 75356
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
typedef long long ll;

int main(void){
    int h, w;
    char a[105];
    
    cin >> h >> w;
    
    int c[26];
    for (int i = 0; i < 26; i++) c[i] = 0;
    for (int i = 0; i < h; i++) {
        cin >> a;
        for (int j = 0; j < w; j++) c[a[j] - 'a']++;
    }
    
    int x = 0, y = 0, z = 0;
    for (int i = 0; i < 26; i++) {
        if (c[i] % 2 == 1) x++;
        if (c[i] % 4 == 2) y++;
        z += c[i] / 4;
    }
    
    if (h % 2 == 1 && w % 2 == 1) {
        if (x != 1) cout << "No" << endl;
        else if ((h / 2 + w / 2) < y && (h / 2 + w / 2) % 2 != y % 2) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    else if (h % 2 == 0 && w % 2 == 0) {
        if (x == 0 && z == h * w / 4) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if (h % 2 == 1) {
            if (x == 0 && w / 2 >= y && (w % 4) / 2 == y % 2) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        else {
            if (x == 0 && h / 2 >= y && (h % 4) / 2 == y % 2) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
    
    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int ans=(h2-h1)*60+(m2-m1)-k;
	if(ans<=0)ans=0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, n, m, L, R;
long long int N, M, K, T, n, m, L, R;


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

	cin >> n >> m;
	int sy, sx, ny, nx;
    cin >> sy >> sx >> ny >> nx;
	sy--, sx--, ny--, nx--;
	vector<string>s(n);
	for (auto &i : s)cin >> i;
	vector<vector<int>>dis(n, vector<int>(m,MOD));
	deque<pair<int, int>>q;
	q.push_back({ sy,sx });
	dis[sy][sx] = 0;
    int dir[] = { 1,0,-1,0,1 };
    while (!q.empty()) {
        int cy, cx;
        tie(cy, cx) = q.front();
        q.pop_front();
        for (int i = 0; i < 4; i++) {
            int ny = cy + dir[i];
            int nx = cx + dir[i + 1];
            //if (ny < 0 || nx < 0 || ny >= n || nx >= m)continue;
            //if (s[ny][nx] == '#')continue;
            if(unsigned(nx)<m&&unsigned(ny)<n&&s[ny][nx]=='.'){
                if (dis[ny][nx] > dis[cy][cx]) {
                    dis[ny][nx] = dis[cy][cx];
                    q.push_front({ ny,nx });
                }
            }
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int ny = cy + i;
                int nx = cx + j;
                //if (ny < 0 || nx < 0 || ny >= n || nx >= m)continue;
                //if (s[ny][nx] == '#')continue;
                if(unsigned(nx)<m&&unsigned(ny)<n&&s[ny][nx]=='.'){
                    if (dis[ny][nx] > dis[cy][cx] + 1) {
                        dis[ny][nx] = dis[cy][cx] + 1;
                        q.push_back({ ny,nx });
                    }
                }
            }
        }
    }
    if (dis[ny][nx] == MOD)dis[ny][nx] = -1;
    cout << dis[ny][nx] << endl;
}


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


int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2 + 1;}

int main(){
    int H, i;
    cin >> H;
    int A[H+1];
    for(i=1; i<=H; i++) cin >> A[i];

    for(i=1; i<=H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

template<class T> struct Grid {
    vector<T> data;
    const size_t h, w;
    Grid(size_t h, size_t w, T v = T()) : data(h * w, v), h(h), w(w) {}
    T& operator()(size_t i, size_t j) { return data[i * w + j]; }
    friend istream& operator>>(istream& in, Grid& g) {
        for (auto& v : g.data) in >> v;
        return in;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    Grid<char> a(n, n), b(m, m);
    cin >> a >> b;
    for (auto i : irange(0, n - m + 1)) {
        for (auto j : irange(0, n - m + 1)) {
            bool match = true;
            for (auto r : irange(0, m)) {
                for (auto c : irange(0, m)) {
                    if (a(i + r, j + c) != b(r, c)) {
                        match = false;
                        break;
                    }
                }
                if (!match) break;
            }
            if (match) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


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

cnt = 0
lst = [1,2,3,4,5,6,7,8,9]
def makeRunrun(s):
    if len(s) > 9:
        return
    for i in range(10):
        if abs(int(s[-1])-i) <= 1:
            ns = s+str(i)
            lst.append(int(ns))
            makeRunrun(ns)

for i in range(1,10):
    makeRunrun(str(i))

lst.sort()
print(lst[K-1])

Measured memory_bytes: 12804
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int N, a[MAX];

int main(int argc, char ** argv) {
	bool ok = false;
	scanf("%d", &N);
	REP(i, 1, N) scanf("%d", a+i);
	REP(i, 1, N) ok |= (a[i] == 1);
	int p = 1, j = 1;
	int ans = 0;
	while(p <= N) {
		while(a[j] != p && j <= N) ans++, j++;
		if(a[j] == p) j++, p++;
		else break;
	}
	if(!ok) ans = -1;
	printf("%d\n", ans);
	return 0;
}


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

// 2つの整数の場合
long long GetGreatestCommonDivisor(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main() {

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

	// 3つ以上の整数の場合
	long long gcd = a[0];
	for (int i = 1; i < n; i++) {
		gcd = GetGreatestCommonDivisor(gcd, a[i]);
	}
	cout << gcd << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n),b(n),c(n);
  for(int i = 0; n > i; i++)cin>>a[i];
  for(int i = 0; n > i; i++)cin>>b[i];
  for(int i = 0; n > i; i++)cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  long long ans = 0;
  for(int i = 0; n > i; i++){
    
    auto y = upper_bound(a.begin(),a.end(),b[i]-1);
    auto z = lower_bound(c.begin(),c.end(),b[i]+1);
    ans += (y-a.begin()) * (c.end()-z);
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 1408
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, k;
vector<int> v[101010];
int c[101010];
bool used[101010];

int main(){
	cin >> n >> k;
	for(int i = 1; i < n; i++){
		int a , b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
		c[a]++; c[b]++;
	}
	
	int pos = 1;
	for(int i = 1; i <= n; i++){
		if(c[i] == 1) pos = i;
	}
	
	queue<P> q;
	q.push(P(pos, k));
	i64 ans = 1;
	while(!q.empty()){
		P p = q.front();
		q.pop();
		if(used[p.first]) continue;
		used[p.first] = 1;
		ans *= p.second;
		ans %= INF;
		int cnt = 0;
		for(int i = 0; i < v[p.first].size(); i++){
			if(used[v[p.first][i]]) cnt++;
		}
		for(int i = 0; i < v[p.first].size(); i++){
			if(used[v[p.first][i]]) continue;
			cnt++;
			q.push(P(v[p.first][i], k-cnt));
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) A[i]=0;
  for(int i=0;i<N-1;i++){
    int tmp;
    cin >> tmp;
    A[tmp-1]++;
  }
  
  for(int i=0;i<N;i++) cout << A[i] << endl;
  
}

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

int main(){
	string S;
	cin >> S;
	int n=0, s=0, w=0, e=0;
	rep(i,S.size()){
		switch (S[i]) {
			case 'N':
				n++;
				break;
			case 'S':
				s++;
				break;
			case 'W':
				w++;
				break;
			case 'E':
				e++;
				break;
		}
	}

	if ((n!=0 && s==0) || (n==0 && s!=0)) {
		cout << "No" << endl;
	}
	else if ((w!=0 && e==0) || (w==0 && e!=0)) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3588