akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();

        int[] A = new int[N];
        int[] B = new int[N];

        for (int i = 0; i < N; ++i)
        {
            A[i] = cin.nextInt();
            B[i] = A[i];
        }

        Array.Sort(B);

        for (int i = 0; i < N; ++i)
        {
            if (A[i] == B[N - 1])
            {
                WriteLine(B[N-2]);
            }
            else
            {
                WriteLine(B[N-1]);
            }
        }
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


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

using namespace std;


int main() {

 	int a, b;
 	cin >> a >> b;
 
 	if(a == 1 && b == 1) {
		cout << "Draw" << endl; 
	}
	else if(a == 1 && b > a) {
		cout << "Alice" << endl;
	}
	else if(b == 1 && a > b) {
		cout << "Bob" << endl;
	}
	else if(a > b) {
		cout << "Alice" << endl;
	}
	else if(b > a) {
		cout << "Bob" << endl;
	}
	else if(a == b) {
		cout << "Draw" << endl;
	}
    return 0;
}










Measured memory_bytes: 256
#include<vector>
#include<string>
#include <iostream>
using namespace std;
int main()
{
	string x;
	cin>>x;
	if (x == "ani")
	{
		cout<<"square1001\n";
	}
	else if (x == "otouto")
	{
		cout<<"e869120\n";
	}
    return false; 
}


Measured memory_bytes: 3144
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int N;
int seq[1000100] = {0};
int a[100010] = {0};
int front,back;
int main(){
	scanf("%d",&N);
	for(int i = 1;i <= N;i++)scanf("%d",&a[i]);
	if(N & 1){
		for(int i = N;i >= 1;i-= 2)printf("%d ",a[i]);
		for(int i = 2;i <= N;i+= 2)printf("%d ",a[i]);	
	}
	else{
		for(int i = N;i >= 2;i-=2)printf("%d ",a[i]);
		for(int i = 1;i <= N;i+=2)printf("%d ",a[i]);	
	}
	return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<cstdio>
using namespace std;

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if (a+b == 15) printf("+\n");
  else if (a*b == 15) printf("*\n");
  else printf("x\n");
}

Measured memory_bytes: 128
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[K],u[K];
long long k;
vector<int> c;
void findcycle(int b,int e,int x)
{
	c.push_back(x);
	if(x==e)
		return ;
	findcycle(b,e,a[x]);
}
void go(int x,long long now,int last)
{
	if(now==k)
	{
		cout<<x;
		return ;
	}
	if(a[x]==x)
	{
		cout<<x;
		return ;
	}
	if(u[x]==1)
	{
		findcycle(x,last,x);
		long long left=k-now;
		left%=((long long)(c.size()));
		cout<<c[left];
		return ;
	}
	u[x]=1;
	go(a[x],now+1,x);
	u[x]=2;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	if(a[1]==1)
	{
		cout<<1;
		return 0;
	}
	go(1,0ll,-1);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.length();
    bool e = true;
    REP(i, N - 1) {
        if (S[i] != S[i + 1])
            e = false;
    }
    ll ans = INF;
    REP(i, N - 1) {
        if (S[i] == S[i + 1])
            continue;
        ans = std::min(ans, std::max(i + 1, N - 1 - i));
    }
    if (e)
        ans = N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//scanf("%lld", &h);
    while(h--){ 
            ll n;
            cin >> n;
            ll x[n];
            ll l[n];
            vector<pair<ll, ll> > v;
            for(int i = 0; i < n; i++){
                cin >> x[i] >> l[i];
                v.pb({x[i] - l[i], x[i] + l[i]});
            } 
            sort(v.begin(), v.end(), [] (pair<ll, ll> &a, pair<ll, ll> &b) {if(a.ss == b.ss){ return a.ff < b.ff ;}return a.ss < b.ss;});
            ll out = 1;
            ll fin = v[0].ss;
            for(int i = 1; i < n; i++){
                if(v[i].ff >= fin){
                    out ++;
                    fin = v[i].ss;
                }
            }
            cout << out << endl;
        }
    }       

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll n,p;
	cin >> n >> p;
	ll waru = 2;
	ll x = p;
	unordered_map<ll,ll> insu;
	const ll aa = 1e7;
	bool arr[aa];
	for (int i = 0;i < aa;i++) {
		arr[i] = true;
	}
	for(int i = 2; i < aa; i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) < aa; j++){
				arr[i *(j + 2)] = false;
			}
		}
	}
	for(int i = 2; i < aa; i++){
		if(arr[i]){
			while(x%i == 0) {
				x/=i;
				insu[i]++;
			}
		}
	}

	// while(x!=1) {
	// 	if (x % waru == 0) {
	// 		while(x%waru == 0) {
	// 			x/=waru;
	// 			insu[waru]++;
	// 		}
	// 	} else {
	// 		waru++;
	// 	}
	// // }
	// for (int i = 0;i < 1e6+10;i++) {
	// 	if (p%i == 0) {
	// 		insu[i] = 0;
	// 	}
	// }
	ll ans = 1;
	for (auto itr = insu.begin();itr != insu.end();itr++) {
		ans *= round(pow(itr->first,itr->second/n));
	}
	if (n == 1) {ans = p;}
	cout << ans << endl;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    LL n,m;
    while(scanf("%lld%lld",&n,&m)==2)
    {
        LL sum=0;
        LL k=0;
        int flag=0;;
        for(LL i=0;i<=n;i++)
        {
            if(i*10000<=m)
            for(LL j=0;j<=n;j++)
            {
                sum=m-10000*i-5000*j;
                if(sum>=0){
                    k=n-i-j;
                    if(k*1000==sum)
                    {
                        flag=1;
                        printf("%lld %lld %lld\n",i,j,k);
                        break;
                    }
                }
            }
            if(flag) break;
        }
        if(!flag)
        {
            printf("-1 -1 -1\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int min(int x, int y, int z){
    int w = (x<y) ? x : y;
    return (w<z) ? w : z;
}

int main(){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", min(a+b,b+c,c+a));
    return 0;
}

Measured memory_bytes: 128
a,b = map(int,input().split())

if a<b:
    ret = a
    a = b
    b = ret


def gcd(a,b):
    c = a % b 
    if c == 0:
        return b
    else: 
        return gcd(b,c)

print(str(gcd(a,b)))

    

Measured memory_bytes: 7648
import math
from scipy.misc import comb

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

x, y = (int(i) for i in input().split())
af, a = math.modf((2*y-x)/3)
bf, b = math.modf((2*x-y)/3)
a, b = int(a), int(b)
if (af != 0) or (bf != 0) or (a < 0) or (b < 0):
    print(0)
else:
    aa, bb = min(a, b), max(a, b)
    print(comb(aa+bb, aa, 10**9+7))

Measured memory_bytes: 15260
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	D, X = map(int, input().split(" "))
	
	A = []
	for i in range(N):
		tmp = int(input())
		A.append(tmp)
		
	ans = X	
	for i, val in enumerate(A):
		#print("ddd")
		for j in range(1, D+1, val):
			#print(j)
			ans += 1
		
	print(ans)
			
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13996
xy=input().split()
xy=[int(s) for s in xy]
x=int(xy[0])
y=int(xy[1])

t=0
r=0
for t in range(t,x+1):
    if((t*2)+(x-t)*4==y):
        r=r+1

if(r>0):
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 9184
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

void mergesort(int array[],int top,int end);

void mergesort(int array[],int top,int end)
{
  int mid;

  if(top >= end)
    {
      return;
    }

  mid = (end+top) / 2;

  mergesort(array,top,mid);

  mergesort(array,mid+1,end);

  int *left,*right,n1,n2,i,j,k;
  n1 = mid - top + 1;
  n2 = end - mid;
  left = (int *)malloc(sizeof(int)*(n1+1));
  right = (int *)malloc(sizeof(int)*(n2+1));
  
  j=0;
  for(i=top;i<=mid;i++)
    {
      left[j] = array[i];
      j++;
    }
  
  j=0;
  for(i=mid+1;i<=end;i++)
    {
      right[j] = array[i];
      j++;
    }
  
  left[n1] = INT_MAX;
  right[n2] = INT_MAX;
  
  i=0; j=0;
  for(k=top;k<=end;k++)
    {
      if(left[i] <= right[j])
	{
	  array[k] = left[i];
	  i++;
	}
      else
	{
	  array[k] = right[j];
	  j++;
	}
    }
  
  free(left);
  free(right);
}


int main(void)
{
  int n,i,j,temp,counter,ans=0;
  scanf("%d",&n);
  int array[n];
  for(i=0;i<n;i++)
    {
      scanf("%d",&array[i]);
    }
  
  mergesort(array,0,n-1);

  for(i=0;i<n;i++)
    {
      temp = array[i];
      counter = 0;
      while(1)
	{
	if(temp == array[i])
	  {
	    counter++;
	    i++;
	  }
	else
	  {
	    i--;
	    if(counter < array[i])
	      {
		ans += counter;
	      }
	    else if(counter > array[i])
	      {
		ans += (counter-array[i]);
	      }
	    break;
	  }
	}
    }

  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<ll> a, num(n+1, 0), sum(n+1, 0);
    ll x, total=0;
    rep(i, n){
        cin >> x;
        a.push_back(x);
        num[x]++;
    }
    rep2(i, 1, n+1){
        ll x = num[i];
        sum[i] = x * (x-1) / 2LL;
        total += sum[i];
    }
    rep2(i, 1, n+1){
        ll now = a[i-1];
        cout << total - sum[now] + (num[now]-1) * (num[now]-2) / 2LL << endl;
    }
    return 0;
}

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

int N, Q, A[100010], B[100010], C[100010], D[100010], E[100010], x[100010], y[100010], ANS[100010];
vector <int> T[100010], Y[100010];
priority_queue <pair <int, int> > q;

int main () {	
	scanf ("%d", &N);
	for (int i = 1; i <= N; i++) scanf ("%d%d", &A[i], &B[i]);
	for (int i = 1; i <= N + 1; i++) scanf ("%d", &C[i]);
	scanf ("%d", &Q);
	for (int i = 1; i <= Q; i++) scanf ("%d%d", &D[i], &E[i]);
	
	sort (C + 1, C + N + 2);
	for (int i = 1; i <= N; i++)
		A[i] = lower_bound (C + 1, C + N + 2, A[i]) - C,
		B[i] = lower_bound (C + 1, C + N + 2, B[i]) - C;
	for (int i = 1; i <= Q; i++)
		D[i] = lower_bound (C + 1, C + N + 2, D[i]) - C,
		E[i] = lower_bound (C + 1, C + N + 2, E[i]) - C;
	
	for (int i = 1; i <= N + 1; i++) x[i] = -1;
	for (int i = 1; i <= N; i++) if (A[i] <= N + 1) x[A[i]]++;
	for (int i = 2; i <= N + 1; i++) x[i] += x[i - 1];
	
	for (int i = 1; i <= N; i++) if (B[i] < A[i]) T[A[i] - 1].push_back (B[i]);
	
	int Ans = N;
	for (int i = N + 1, w = 0; i >= 1; i--) {
		sort (T[i].begin (), T[i].end ());
		for (unsigned int p = 0; p < T[i].size (); p++) q.push (make_pair (-T[i][p], i));
		for (int j = x[i] + w; j < -1; j++) {
			if (q.empty ()) { while (Q--) printf ("-1\n"); return 0; }
			pair <int, int> p = q.top (); q.pop ();
			if (-p.first > i) { while (Q--) printf ("-1\n"); return 0; }
			T[p.second].erase (T[p.second].begin ()); 
			y[-p.first]++, y[p.second + 1]--, Ans--, w++;
		}
		w -= y[i];
	}
	
	for (int i = 1; i <= N + 1; i++) y[i] += y[i - 1], x[i] += y[i];
	while (!q.empty ()) q.pop ();
	
	for (int i = N + 1; i >= 1; i--)
		for (unsigned int p = 0; p < T[i].size (); p++)
			Y[T[i][p]].push_back (i);
	
	memset (y, 0, sizeof (y));
	memset (ANS, -1, sizeof (ANS));
	for (int i = 1, w = 0; i <= N + 1; i++) {
		ANS[i] = Ans;
		for (unsigned int p = 0; p < Y[i].size (); p++) q.push (make_pair (Y[i][p], i));
		for (int j = x[i] + w; j < 0;j++) {
			if (q.empty ()) goto end;
			pair <int, int> p = q.top (); q.pop ();
			if (p.first < i) goto end;
			y[p.first]++, Ans--, w++;
		}
		w -= y[i];
	}
	ANS[N + 2] = Ans;
	end:;
	
	for (int i = 1; i <= Q; i++) {
		int p = ANS[D[i]], q = ANS[E[i]];
		if (p != -1) p++;
		printf ("%d\n", max (p, q));
	}
	
	return 0;
}

Measured memory_bytes: 15728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll K;
    cin >> K;

    queue<ll> que;
    rep(i, 9) que.push(i+1);

    ll cnt = 0;
    while(!que.empty()) {
        ll v = que.front();
        que.pop();
        cnt++;
        if(cnt == K) {
            cout << v << endl;
            return 0;
        }

        ll x = v % 10;
        for(int i = -1; i <= 1; i++) {
            if(x == 0 && i == -1) continue;
            if(x == 9 && i == 1) continue;
            que.push(10 * v + x + i);
        }
    }
}


Measured memory_bytes: 1792
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0: break
    for j in range(h):
        for i in range(w):
            if (i + j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7008
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rgL2iRE5WFMthrP7HjT3>?N)<}_ktheS4Xo<ei7_PoeeIYAr-@HyX4svbbz}4a*pKbBS|2M@Nhu^SJRG&La5R-_MVd5TB(Y}e-g4A8z7>{rm7z|E$~I}jxM)CX)$TrWcZxmm33R;sO=Sd>Zc&zL0`A<XngW9@<N-c+C<PRg$e-GgQ@4!FFgA|a!24$jwGq|#%=l^y-k``~=`<^+38WErFbde@Yt+c0;ym*%kY3GP?o9?a2%9aa$P(Y-9+q3UM0Wf)!YiyW$^!b~5XwIpJ_!Dgj_?I})T{S}eZ#odYVH*c)<=OWAA%2^!fC#`DJ_M8!k8v!wB4PlMjKZZ)wKIekut>NVk~GVL7q!bByw#3`pwYr2#t@BTd6Il2bC>eB!>mPCO8teMSmGcBp0$5!Ql`bj*k2V((Sr6")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12960
//Goldbach's Conjecture
#include<bits/stdc++.h>
using namespace std;

vector<int> p;
int ans[50001];

void solve(){
  int ret=0;
  for(int i=0; i<p.size(); i++)
    for(int j=i; j<p.size(); j++){
      if(p[i]+p[j]>50000)break;
      ans[p[i]+p[j]]++;
    }
}

int main(){
  p.push_back(2);
  for(int i=3; i<50000; i+=2){
    bool flag=true;
    for(int j=0; j<p.size(); j++)
      if(i%p[j]==0){flag=false; break;}
    if(flag){p.push_back(i);}
  }
  solve();

  int n;
  while(true){
    cin>>n;
    if(n==0)break;
    cout<<ans[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1468
a,b,c,d = map(int,input().split())

import math

bc = b//c
bd = b//d
bcd = b//(c*d//math.gcd(c,d))

ac = (a-1)//c
ad = (a-1)//d
acd = (a-1)//(c*d//math.gcd(c,d))

ans = (b-bc-bd+bcd)-((a-1)-ac-ad+acd)

print(ans)


Measured memory_bytes: 9128
ans = [105,135,165,189]
n = int(input())
if n < 105:
  print(0)
elif n < 135:
  print(1)
elif n < 165:
  print(2)
elif n < 189:
  print(3)
elif n < 195:
  print(4)
else:
  print(5)

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

int main(){
	int n;
	cin >> n;
	int r[n], p[n];
	for(int i = 0; i < n; i++) cin >> p[i];
	for(int i = 0; i < n; i++) r[--p[i]] = i;
	for(int i = 0; i < n; i++) cout << 30000 * (i + 1) << ' ';
	cout << endl;
	for(int i = 0; i < n; i++) cout << 30000 * (n - i + 1) + r[i] << ' ';
	cout << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAX_N = 100000;
ll fact[MAX_N + 1];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll ans;
	fact[0] = 0;
	fact[1] = 1;
	ll fs = 1;
	for (int i = 2; i < MAX_N + 1; i++){
		fs = (fs*i) % MOD;
		fact[i] = (fact[i-1] + fs) % MOD;
	}
	while (1){
		int N, R;
		cin >> N;
		if (N == 0) break;
		vector<int> word(N);
		for (int i = 0; i < N; i++) word[i] = i;
		word.push_back(0);
		ans = 0;
		cin >> R;
		vector<int> s(2*R+2, 0);
		s[2 * R + 1] = N;
		for (int i = 0; i < R; i++){
			cin >> s[i] >> s[i+R];
			s[i]--; s[i+R]--;
			s.push_back(s[i] + 1);
			s.push_back(s[i+R] + 1);
			swap(word[s[i]], word[s[i+R]]);
		}
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		for (int i = 0, R = s.size() - 1; i < R; i++){
			ll tmp = fact[N - s[i] - 1] - fact[N - s[i+1] - 1];
			tmp = (tmp * word[s[i]]) % MOD;
			ans =(ans + tmp) % MOD;
			int dif = s[i+1] - s[i];
			for (int j = i + 1; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[s[i]] ? dif : 0);
			}
		}
		cout << (ans + MOD) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 2792
# include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int flag=0;
    for(int i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        {
            flag=1;
            break;
        }
    }
    if(flag==0&&s2.length()-s1.length()==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}


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

using ll = long long ;

int main(){
  string s;
  cin >> s;
  int n = s.size() - 1; //＋記号を入れる場所の数
  ll sum = 0; //合計
  
  for(int bit =0; bit < (1 << n); bit++){
    ll t = s[0] - '0'; //charを数字に変換 足し算するまで，これを10倍してs[i＋1]を足していく
    
    for(int i =0; i <n; i++){
      if(bit & (1 << i)){ //+の記号があるとき
        sum += t;
        t = s[i+1] - '0';
      }
      else{ //記号がなかったとき
        t *= 10;
        t += s[i+1] - '0';
      }
    }
    sum += t; //ループが終わったら，sumに足していく
  }
   cout << sum << endl;
}

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

X = input().split()
X2 = [0 for _ in range(N)]
for i in range(N):
    X[i]=int(X[i])
    X2[i]=int(X[i])**2
sigma_X = sum(X)
sigma_X2 = sum(X2)
ans = []
    
for P in range(101):
    ans.append(sigma_X2 + N*P**2 - 2*P*sigma_X)
    
print(min(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  lol ans = UPDight(n, min({a, b, c, d, e}));
  ans += 4;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cctype>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=210;
int n,tot,k,s,ans,w[N][N],dis[N][N],vis[N],pre[N][N],f[N],tmp[N];
int find(int x){
	return x==f[x]?x:f[x]=find(f[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		f[i]=i;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			char c;
			do c=getchar();
			while(!isdigit(c));
			if(i<j&&c=='1'){
				int fx=find(i),fy=find(j);
				f[fy]=fx;
			}
			dis[i][j]=w[i][j]=('1'-c)*99999999+1;
			if(i==j)
				dis[i][j]=0;
		}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++){
				if(dis[i][k]+dis[k][j]<dis[i][j]){
					dis[i][j]=dis[i][k]+dis[k][j];
					pre[i][j]=pre[k][j];
				}
			}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			if(dis[i][j]!=1e9)
				tmp[find(i)]=max(tmp[find(i)],dis[i][j]+1);
		for(int j=1;j<=n;j++)
			for(int k=j;k;k=pre[i][k])
				vis[k]=i;
		for(int j=1;j<=n;j++){
			if(vis[j]==i){
				for(int k=1;k<=n;k++){
					if(vis[k]==i&&w[j][k]==1&&pre[i][j]!=k&&pre[i][k]!=j){
						if(abs(dis[i][j]-dis[i][k])!=1){
							puts("-1");
							return 0;
						}
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
		if(i==find(i))
			ans+=tmp[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
H, W = map(int, input().split())

# num = H * W


if H == 0 or W == 0:
    print(int(0))

elif H == 1 or W == 1:
    print(int(1))

elif H % 2 == 0 and W % 2 == 0:
    print(int(H/2 * W))

elif H % 2 == 0:
    print(int(H/2 * W))

elif W % 2 == 0:
    print(int(W/2) * H)

elif H % 2 != 0 and W % 2 != 0:
    key = W // 2
    ans = H * key
    print(int(ans + (H-H//2)))
    # else:
    #     num = H // 2
    #     ans = num * W
    #     print(int(ans + (H-(num))))


Measured memory_bytes: 3060
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo 100000000000000000
const ll dx[]={-1,0,1, 0,-1,1, 1,-1};
const ll dy[]={ 0,1,0,-1, 1,1,-1,-1};
void solve(){
   ll n;
   cin>>n;
   string s;
   if(n%2==0||n%5==0){
       cout<<"-1";
       return;
   }
   ll no = 0;
   for(ll i = 1;i<=n;i++){
       no = (no*10LL+7)%n;
       if(no==0){
           cout<<i;
           return;
       }
   }
   cout<<"-1";
   
}
int main(){
    Boost();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
    ci(n);
  ll a,b;
  a=n/10;
  b=n%1000;
  if(a%111==0||b%111==0){
    co("Yes")
  }
  else{
    co("No")
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    vector<int> A(N,1);
    for(int i=0;i<N-1;i++){
        if(S.at(i)==S.at(i+1)){
            int j=i+1;
            while(S.at(i)==S.at(j)){
                A.at(i)++;
                j++;
                if(j==N) break;
            }
            i=j-1;
        }
    }
    vector<int> Ind;
    int m=0;
    for(int i=0;i<N;i++){
        if(A.at(i)>m){
            while(Ind.size()!=0) Ind.pop_back();
            Ind.push_back(i);
            m=A.at(i);
        }
        else if(A.at(i)==m){
            Ind.push_back(i);
        }
    }
    for(int i:Ind){
        cout << S.at(i) << endl;
    }
    
}

Measured memory_bytes: 15992
N,K=map(int,input().split())
x=[int(_) for _ in input().split()]
m=10**15
for i in range(N-K+1):
    l=abs(x[i])+abs(x[i]-x[i+K-1])
    r=abs(x[i+K-1])+abs(x[i+K-1]-x[i])
    if l<m:
        m=l
    if r<m:
        m=r
print(m)

Measured memory_bytes: 62576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

struct Hld {
    vector<int> a, ia, par, head;

    template<class G>
    Hld(const G& g, int root) {
        build(g, root);
    }
    
    template<class G>
    void build(const G& g, int root) {
        int n = g.size();
        vector<int> size(n);
        dfs_size(g, size, root, -1);
        ia.resize(n);
        par.resize(n);
        dfs_build(g, size, root, -1, 0);
    }

    template<class G>
    void dfs_size(const G& g, vector<int>& size, int u, int p) {
        size[u] = 1;
        for (int v : g[u]) {
            if (v == p) continue;
            dfs_size(g, size, v, u);
            size[u] += size[v];
        }
    }

    template<class G>
    void dfs_build(const G& g, const vector<int>& size, int u, int p, int h) {
        ia[u] = a.size();
        par[a.size()] = p == -1 ? -1 : ia[p];
        a.push_back(u);
        head.push_back(h);
        int heavy_v = -1, max_size = 0;
        for (int v : g[u]) {
            if (size[v] > max_size) {
                heavy_v = v;
                max_size = size[v];
            }
        }
        if (heavy_v != -1) dfs_build(g, size, heavy_v, u, h);
        for (int v : g[u]) {
            if (v == p || v == heavy_v) continue;
            dfs_build(g, size, v, u, head.size());
        }
    }

    int lca(int u, int v) {
        u = ia[u];
        v = ia[v];
        while (true) {
            if (u > v) swap(u, v);
            if (head[u] == head[v]) return a[u];
            v = par[head[v]];
        }
    }
};


int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int c;
            cin >> c;
            g[i].push_back(c);
        }
    } 
    Hld hld(g, 0);

    for (int u = 0; u < n; ++u) {
        // cerr << u << " g:" << hld.a[u] << " head:" << hld.head[u] << " par:" << hld.par[u] << endl;
    }

    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << hld.lca(u, v) << '\n';
    }
    return 0;
}


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

int main(){
 int n, m, x;
 cin>>n>>m>>x;
 int left=0, rgh=m;
 int *point = new int[m];
 for(int i=0;i<m;i++){
  cin>>point[i];
  if(point[i]<x){
   left++;
   rgh--;
  }
 }
 if(left<rgh)cout<<left<<endl;
 else cout<<rgh<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r) //math.factorial(r)

import math
import numpy as np
r=0
n1=n+1
for ii in np.arange(k,n1+1):
    """print(n+1,ii,permutations_count(n1, ii))
    r+=permutations_count(n1, ii)"""
    r+=((2*n1-ii+1)*ii)/2-((ii+1)*ii)/2+1
print(int(r)%(10**9+7))

Measured memory_bytes: 27980
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i] = INFTY;
  d[s]=0;
  int u;
  while (!q.empty())
  {
    u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0)continue;
      if(d[v]!= INFTY)continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << ((d[i]==INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main(){
  int u,k,v;

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j= 0;j<n;j++) M[i][j]=0;
  }
  for(int i= 0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j= 0; j<k;j++){
      cin >> v;
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  return 0;
}




Measured memory_bytes: 3128
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<cmath>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<string>
#include<numeric>
#include<bitset>
//#include<bits/stdc++.h>
using namespace std;

int main(){
	string s;
	cin >> s;
	
	int ans1 =0;
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='1'){
			ans1++;
		}
	}

	for(int i=1;i<s.size();i+=2){
		if(s[i]=='0'){
			ans1++;
		}
	}

	int ans2 =0;
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='0'){
			ans2++;
		}
	}

	for(int i=1;i<s.size();i+=2){
		if(s[i]=='1'){
			ans2++;
		}
	}

	if(ans1<=ans2){
		cout << ans1;
	}else{
		cout << ans2;
	}
	
}

Measured memory_bytes: 512
n=gets.to_i
words=Hash.new
beforeWord=""
ruleSafed="Yes"
n.times do
  word = gets.chomp
  if !words.key?(word)
	words.store(word,1)
  else
    ruleSafed="No"
    break
  end
  if (beforeWord != "") && (beforeWord[beforeWord.length-1] != word[0])
    ruleSafed="No"
    break
  else
    beforeWord = word
  end
end
puts ruleSafed

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

int n;
int x[24],y[24],r[24],c[24];
bool memo[1<<24];

bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n;
    for(int i=0;i<n;i++)if((bit>>i)&1)ret--;

    for(int i=0;i<n;i++){
        if(((bit>>i)&1)==0||ok(i,bit)==false)continue;
        for(int j=i+1;j<n;j++){
            if(((bit>>j)&1)==0||ok(j,bit)==false)continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(c[i]==c[j]&&!memo[to_bit]){
                ret=max(ret,dfs(to_bit));
            }
        }
    }


    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}



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

Measured memory_bytes: 17544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    int q; cin >> q;
    ll a, b;
    for(int i=0; i<q; i++){
        cin >> a >> b;
        if(a == b){
            cout << (a - 1) * 2 << "\n";
            continue;
        }
        ll l = -1, r = a + b, mid;
        while(r-l > 1){
            mid = (r + l) / 2;
            if((mid / 2 + 1) * ((mid + 1) / 2) < a * b){
                l = mid;
            }
            else{
                r = mid;
            }
        }
        cout << r - 2 << "\n";
    }
    return 0;
}

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

int main(){
    string s;
    cin>>s;
    for(int i=0; i<s.length(); i++){
        if((i%2&&s[i]=='R')
            ||(!(i%2)&&s[i]=='L')){
                cout<<"No\n";
                return 0;
        }
        
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    cout << (x >= 30 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int l=0,r=N;
  while(r-l>1) {
    int m=(l+r)/2;
    bool flag=false;
    vector<string> s;
    rep(i,N-m+1) s.push_back(S.substr(i,m));
    rep(i,N-m*2+1) {
      rep2(j,i+m,N-m+1) flag|=s[i]==s[j];
    }
    if(flag) l=m;
    else r=m;
  }
  
  cout << l << endl;
}

Measured memory_bytes: 6536
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = INT()
print(S[K-1])

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

//INT_MAX = 2^31 - 1
//LLONG_MAX = 2^63 - 1
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n;
	cin >> n;

	while(n % 111 != 0) n++;

	cout << n << endl;

	rtn 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) cout << s << endl;
# define printStr(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

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

    int res=0;
    if(str.substr(0,1)=="o") res++;
    if(str.substr(1,1)=="o") res++;
    if(str.substr(2,1)=="o") res++;
    res = 700 + res*100;

    p(res)
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

vector<int> minfactor(1000001,-1);
vector<bool> isprime(1000001,true);

void init(void) {
    // osa_k method
    isprime[0] = false; isprime[1] = false;
    minfactor[1] = 1;
    for (int i=2;i<=1000000;i++) {
        if (isprime[i]) {
            minfactor[i] = i;
            for (int j=2*i;j<=1000000;j+=i) {
                isprime[j] = false;
                minfactor[j] = i;
            }
        }
    }
}

vector<int> prime(ll X) {
    vector<int> res;
    int i = minfactor[X];
    while (X > 1) {
        res.push_back(i);
        X /= i;
        i = minfactor[X];
    }
    sort(res.begin(),res.end());
    return res;
}

vector<int> lcm(vector<int> A, vector<int> B) {
    vector<int> res1;
    // 最小公倍数は A と B の和集合
    set_union(A.begin(),A.end(),B.begin(),B.end(),inserter(res1, std::end(res1)));
    // multiset<int> res2(res1.begin(),res1.end());
    return res1;
}

ll div(vector<int> V, vector<int> X) {
    vector<int> D;
    // 割り算は A と B の差集合
    set_difference(V.begin(),V.end(),X.begin(),X.end(),inserter(D,D.end()));
    // for (auto itr: X) {
    //     V.erase(lower_bound(V.begin(),V.end(),itr));
    // }
    ll res = 1;
    for (auto itr: D) {
        res *= itr;
        res %= MOD;
    }
    return res;
}

int main(void) {
    int N;
    vector<ll> A(10010);
    cin >> N;
    for (int i=0;i<N;i++) cin >> A[i];
    init();
    // cout << "init" << endl;

    vector<vector<int>> M(N);
    for (int i=0;i<N;i++) M[i] = prime(A[i]);
    // cout << "prime" << endl;
    // for (int i=0;i<N;i++) {
    //     cout << A[i] << endl;
    //     for (auto itr: M[i]) {
    //         cout << "\t" << itr.first << ": " << itr.second << endl;
    //     }
    // }
    vector<int> V(M[0].begin(),M[0].end());
    for (int i=1;i<N;i++) V = lcm(V,M[i]);
    // cout << "lcm" << endl;
    sort(V.begin(),V.end());
    ll res = 0;
    for (int i=0;i<N;i++) {
        res += div(V,M[i]);
        res %= MOD;
    }
    // cout << "div" << endl;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5228
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

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

func nextInt() uint64 {
	sc.Scan()
	i, e := strconv.ParseUint(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func intArray(n []string) []int {
	var m []int
	for i, _ := range n {
		v, _ := strconv.Atoi(n[i])
		m = append(m, v)
	}
	return m
}

func uint64Array(arr []string) (newArr []uint64) {
	for i, _ := range arr {
		n, _ := strconv.ParseUint(arr[i], 10, 64)
		newArr = append(newArr, n)
	}
	return
}

func intExistIn(v int, arr []int) bool {
	for _, a := range arr {
		if a == v {
			return true
		}
	}

	return false
}

func stringExistIn(v string, arr []string) bool {
	for _, a := range arr {
		if a == v {
			return true
		}
	}

	return false
}

func gcd(m, n uint64) uint64 {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(m)
	b := new(big.Int).SetUint64(n)
	return z.GCD(x, y, a, b).Uint64()
}

func uintArrayToStr(a []uint64) string {
	var S string

	for _, v := range a {
		S += strconv.Itoa(int(v))
	}
	return S
}

func remove(x []uint64, y int) []uint64 {
	var newArray []uint64
	for i, _ := range x {
		if i != y {
			newArray = append(newArray, x[i])
		}
	}
	return newArray
}

func ascendSort(a []uint64) []uint64 {
	for i := 0; i < len(a); i++ {
		for i := 0; i < len(a)-1; i++ {
			if a[i] > a[i+1] {
				tmp := a[i+1]
				a[i+1] = a[i]
				a[i] = tmp
			}
		}
	}
	return a
}

func descendSort(a []uint64) []uint64 {
	for i := 0; i < len(a); i++ {
		for i := 0; i < len(a)-1; i++ {
			if a[i] < a[i+1] {
				tmp := a[i+1]
				a[i+1] = a[i]
				a[i] = tmp
			}
		}
	}
	return a
}

func maxAndIndex(a []uint64) (uint64, int) {
	max := uint64(0)
	index := 0
	for i, v := range a {
		if v > max {
			max = v
			index = i
		}
	}
	return max, index
}

func sum(a []uint64) uint64 {
	sum := uint64(0)
	for _, v := range a {
		sum += v
	}
	return sum
}

func main() {
	_ = readLine()
	L := uint64Array(strings.Split(readLine(), " "))

	for i := len(L) - 1; i > 0; i-- {
		if L[i-1] > L[i] {
			if L[i-1] -= 1; L[i-1] > L[i] {
				fmt.Println("No")
				os.Exit(0)
			}
		}
	}

	fmt.Println("Yes")
}


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

typedef long long ll;

int n, m; ll t;
int s[300005]; char d[300005];
pair<int,int> o[300005];
int res[300005];

int main() {
    scanf("%d%d%lld", &n, &m, &t);
    FO(i,0,n) scanf("%d %c", s+i, d+i);
    FO(i,0,n) o[i] = make_pair(s[i],i);
    sort(o,o+n);
    vector<ll> p;
    ll nc = 0;
    FO(i,0,n) {
        int dir = d[i] == '2' ? -1 : 1;
        ll pos = s[i] + dir * t;
        ll fp = ((pos%m)+m)%m;
        ll g = pos > 0 ? pos / m : (pos-m+1) / m;
        nc += g;
        p.push_back(fp);
    }
    nc = ((nc%n)+n)%n;
    sort(p.begin(),p.end());
    FO(i,0,n) res[o[i].second] = p[(i+nc)%n];
    FO(i,0,n) printf("%d%c", (res[i]), " \n"[i+1==n]);
}

Measured memory_bytes: 5492
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.Diagnostics;

namespace CompetitiveProgramming
{
  class Solve
  {
    public Solve()
    {
      int[] num = new int[11];
      int A = Scanner.nextInt();
      int B = Scanner.nextInt();
      int C = Scanner.nextInt();
      num[A]++;
      num[B]++;
      num[C]++;
      if (num[5] == 2 && num[7] == 1)
      {
        Console.WriteLine("YES");
      }
      else 
      {
        Console.WriteLine("NO");
      }
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
        new Solve();
    }
  }

  public class Pair<T, U>
  {
    public Pair()
    {

    }
    public Pair(T first, U second)
    {
      this.first = first;
      this.second = second;
    }
    public T first { get; set; }
    public U second { get; set; }
  }

  class Scanner
  {
    private static List<string> buf = new List<string>();

    private static void next()
    {
      if (buf.Count == 0)
      {
        buf = Console.ReadLine().Split().ToList();
      }
    }

    private static string pop()
    {
      string ret = buf[0];
      buf.RemoveAt(0);
      return ret;
    }

    public static int nextInt()
    {
      next();
      return int.Parse(pop());
    }
    public static long nextLong()
    {
      next();
      return long.Parse(pop());
    }
    public static string nextString()
    {
      next();
      return pop();
    }
    public static double nextDouble()
    {
      next();
      return double.Parse(pop());
    }
  }
}


Measured memory_bytes: 2776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
LL a[100010];
LL b[100010];
LL res=0;
int t=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	b[1]=a[0];
	for (int i=2;i<=n;i++) b[i]=b[i-1]+a[i-1];
	res=b[n];
	for (int i=1;i<n;i++)
	{
		if (!a[i])
		{
			res-=(b[i]-b[t])%2;
			//cout <<i<<" "<<b[i]-b[t]<<" ##\n";
			t=i;
		}
	}
	cout <<res/2;
	return 0;
}

Measured memory_bytes: 1792