akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    string s;
    int k;
    cin >> s >> k;
    int t = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            t++;
        }else{
            cout << s[i] << endl;
            return 0;
        }
        if(t==k){
            cout << 1 << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 888
n = int(input())

def dfs(x, f3, f5, f7):
  cnt = 0
  if x>n:
    return 0
  if f3>0 and f5>0 and f7>0:
    cnt += 1

  t1 = x*10+3
  t2 = x*10+5
  t3 = x*10+7
  cnt += dfs(t1, f3+1, f5, f7)
  cnt += dfs(t2, f3, f5+1, f7)
  cnt += dfs(t3, f3, f5, f7+1)
  return cnt

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)



typedef struct t{ll l,r,x;}T;
int sort(const void*a,const void*b){
	T*p=(T*)a,*q=(T*)b;
	if((*p).r<(*q).r)return -1;
	return 1;
}

ll dp[310][310][310];
T c[310];
#define add(p,q)(p=(p+q)%MOD)
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll l,r,x;
		scanf("%lld%lld%lld",&l,&r,&x);
		c[i].l=l;
		c[i].r=r;
		c[i].x=x;
	}
	qsort(c,m,sizeof(T),sort);
	
	ll cnt=0;
	while(c[cnt].r==1){
		if(c[cnt].x>1){
			puts("0");
			return 0;
		}
		cnt++;
	}
	
	dp[1][0][0]=3;
	rep(i,2,n+1){
		//i番目を決める
		rep(j,0,i-1)rep(k,0,i-1){
			add(dp[i][j][k],dp[i-1][j][k]);
			add(dp[i][i-1][k],dp[i-1][j][k]);
			add(dp[i][i-1][j],dp[i-1][j][k]);
		}
		while(c[cnt].r==i){
			rep(j,0,i+1)rep(k,0,j+1){
				ll temp=1;
				if(j>=c[cnt].l)temp++;
				if(k>=c[cnt].l)temp++;
				if(temp!=c[cnt].x)dp[i][j][k]=0;
			}
			cnt++;
		}
	}
	ll ans=0;
	rep(j,0,n+1)rep(k,0,n+1)add(ans,dp[n][j][k]);
	printf("%lld",ans);
}

Measured memory_bytes: 225532
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll P = 1000000007;
vvl dp = vv(100003, 2, -1, ll);
string s;
bitset<100003> bt;

ll calc(ll b, ll f){
  if(b==-1) return 1;
  if(dp[b][f]!=-1) return dp[b][f];
  ll ret = 0;
  if(f==1) ret = (3*calc(b-1, 1))%P;
  else{
    if(bt[b]) ret = (2*calc(b-1, 0) + calc(b-1, 1))%P;
    else ret = calc(b-1, 0);
  }
  return dp[b][f] = ret;
}
int main(int argc, char const *argv[]) {
  std::cin >> s;
  bt = bitset<100003>(s);
  std::cout << calc(100002, 0) << '\n';
  return 0;
}


Measured memory_bytes: 12224
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        long X = in.nextLong();
        long Y = in.nextLong();

        if (X % Y == 0){
            System.out.println(-1);
            return;
        }
        System.out.println(X);







    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21076
import heapq

N, M = map(int, input().split(" "))
AB = [list(map(int, input().split(" "))) for _ in range(N)]
# N, M = (10**5, 10**5)
# AB = [(i, i//100) for i in range(N)]

l = [[] for _ in range(10**5+1)]
for a, b in AB:
    l[a].append(b)
l = [sorted(l_i, reverse=True) for l_i in l]

l = [[(-l_j, l_j) for l_j in l_i] for l_i in l]

point = 0
p = []
for i in range(M, -1, -1):
    for l_j in l[M-i]:
        heapq.heappush(p, l_j)
    # print(p)
    if p == []:
        continue
    point += heapq.heappop(p)[1]

print(point)

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

#define SIZE 8

int main() {
	string source[SIZE];
	while (cin >> source[0]) {
		for (int i = 1; i < SIZE; i++) {
			cin >> source[i];
		}

		bool map[14][14] = {false}, f = true;
		int x = SIZE, y = SIZE;
		for (int i = 0; i < SIZE; i++) {
			for (int j = 0; j < SIZE; j++) {
				map[i + 3][j + 3] = (source[i][j] == '1' ? true : false);
				if (map[i + 3][j + 3] && f) {
					x = j;
					y = i;
					f = false;
				}
			}
		}

		x += 3;
		y += 3;

		if (map[y + 1][x + 1] && map[y][x + 1] && map[y + 1][x]) {
			cout << "A";
		} 
		if (map[y + 1][x + 1] && map[y + 2][x + 1] && map[y + 1][x]) {
			cout << "F";
		}
		if (map[y + 1][x + 1] && map[y + 1][x + 2] && map[y][x + 1]) {
			cout << "E";
		}
		if (map[y + 1][x - 1] && map[y][x + 1] && map[y + 1][x]) {
			cout << "G";
		}
		if (map[y + 1][x - 1] && map[y + 2][x - 1] && map[y + 1][x]) {
			cout << "D";
		}
		if (map[y + 1][x] && map[y + 2][x] && map[y + 3][x]) {
			cout << "B";
		}
		if (map[y][x + 1] && map[y][x + 2] && map[y][x + 3]) {
			cout << "C";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
import math


def mod_pow(a: int, n: int, mod: int)->int:
    ret = 1
    for _ in range(n):
        ret = (ret * a) % mod
    return ret


def lining_up(N: int, A: list)->int:
    pos = [0] * math.ceil(N / 2)

    for a in A:
        i = (N-a-1)//2
        pos[i] += 1

        if pos[i] > 2:
            return 0

    if N % 2 == 0 and any(p != 2 for p in pos):
        return 0
    if N % 2 == 1 and any(p != 2 for p in pos[:-1]) and pos[-1] != 1:
        return 0

    return mod_pow(2, N // 2, 10**9+7)


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = lining_up(N, A)
    print(ans)


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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  map<pair<string, string>, int> ll, rr;

  for (int k=0; k<(1<<n); k++) {
    int xi=0, yi=0;
    string x(n, ' '), y(n, ' ');
    for (int i=0; i<n; i++) {
      if (k & (1<<i)) x[xi++] = s[i];
      else            y[yi++] = s[i];
    }
    ll[make_pair(x, y)]++;
  }
  for (int k=0; k<(1<<n); k++) {
    int xi=0, yi=0;
    string x(n, ' '), y(n, ' ');
    for (int i=0; i<n; i++) {
      if (k & (1<<i)) x[xi++] = s[2*n-i-1];
      else            y[yi++] = s[2*n-i-1];
    }
    rr[make_pair(x, y)]++;
  }
  long long r = 0;
  for (auto it: ll) {
    r += (long long)ll[it.first] * rr[it.first];
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 114944
from collections import deque
H, W = map(int, input().split())
X = [[1 if a == "#" else 0 for a in input()] for _ in range(H)]

def BFS(i0=0):
    Q = deque([i0])
    D = [-1] * (H * W)
    D[i0] = X[0][0]
    while Q:
        x = Q.popleft()
        i, j = x // W, x % W
        for di, dj in ((0, 1), (1, 0)):
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W:
                y = ni * W + nj
                if X[ni][nj] == X[i][j]:
                    if D[y] == -1:
                        D[y] = D[x]
                        Q.appendleft(y)
                else:
                    if D[y] == -1:
                        D[y] = D[x] + 1
                        Q.append(y)
                        
    return D

print(BFS(0)[-1] + 1 >> 1)

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

int main(){
    int n;
    cin >> n;
    string t, s;
    cin >> t;
    s = t;
    reverse(t.begin(), t.end());

    vector<int> w(n), e(n);

    for(int i=0; i<n-1; i++){
        w[i+1] += w[i];
        if(s[i] == 'W') w[i+1]++;

        e[i+1] += e[i];
        if(t[i] == 'E') e[i+1]++;
    }
    reverse(e.begin(), e.end());

    int ans = 1e9;
    for(int i=0; i<n; i++) ans = min(ans, e[i]+w[i]);
    cout << ans << endl;
    return 0;
}

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

int main()
{
  double N, s = 0;
  cin >> N;
  vector<double> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
    s += A[i];
  }
  double ave = s / N;
  double m = 100, mi;
  for (int i = 0; i < N; i++)
  {
    double d = abs(ave - A[i]);
    if (d < m)
    {
      m = d;
      mi = i;
    }
  }
  cout << mi << endl;
}

Measured memory_bytes: 256
from collections import deque
k=int(input())
l=deque([1,2,3,4,5,6,7,8,9])
for i in range(k-1):
  d=l.popleft()
  a=d%10
  if a!=0:
    l.append(d*10+a-1)
  l.append(d*10+a)
  if a!=9:
    l.append(d*10+a+1)
print(l.popleft())

Measured memory_bytes: 11956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF 2000000000
#define INFLL 9000000000000000000
using namespace std;
int main(void)
{
	int a, b;

	cin>>a>>b;

	if((a+b)%2){
		cout<<(a+b)/2+1<<endl;
	} else{
		cout<<(a+b)/2<<endl;
	}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#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__) << "] "
int main()
{
char ch;
cin>>ch;
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
cout<<"vowel";
else
cout<<"consonant";

return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int n;
    cin >> n;
    int ta = -2, pa;
    vi a;
    REP(i, n) {
        pa = ta;
        cin >> ta;
        if(pa == ta - 1) a.push_back(pa);
    }
    int ans = 0;
    REP(i, n) {
        int b;
        cin >> b;
        ans += b;
    }
    sort(ALL(a));
    REP(i, n - 1) {
        int c;
        cin >> c;
        if(a.size() > 0 && i + 1 == a[0]) {
            ans += c;
            a.erase(a.begin());
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
INF = float('inf')
def dfs(i,a,b,c):
    # さいごまで到達したときの操作  
    if i == N:
        if a==0 or b==0 or c==0:
            return INF
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    # すべての手順
    ans0 = dfs(i+1, a, b, c)
    ans1 = dfs(i+1, a+L[i], b, c) + (10 if a != 0 else 0)
    ans2 = dfs(i+1, a, b+L[i], c) + (10 if b != 0 else 0)
    ans3 = dfs(i+1, a, b, c+L[i]) + (10 if c != 0 else 0)
    
    ans = min(ans0, ans1, ans2, ans3)
    return ans

def main():
    print(dfs(0,0,0,0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

    ll a = 0;
    rep(i, n.size()){
        a += (int)(n[i] - '0');
    }
    if(a%9==0){
        out("Yes");
    }
    else{
        out("No");
    }

}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (int i = 0; i < N; ++i) cin >> m.at(i);
  sort(m.begin(), m.end());
  int sum_m = 0;
  int cnt = 0;
  while (sum_m <= X) {
    cnt++;
    if (cnt < N)
      sum_m += m.at(cnt);
    else
      sum_m += m.at(0);
  }
  cout << cnt - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N; string S0; string S[1010];
//---------------------------------------------------------------------------------------------------
bool isNum(char c) {
    if ('0' <= c and c <= '9') return 1;
    return 0;
}
//---------------------------------------------------------------------------------------------------
#define greater "+"
#define lesser "-"
string solve(string a, string b) {
    int na = a.length();
    int nb = b.length();

    int n = min(na, nb);
    rep(i, 0, n) {
        if (isNum(a[i]) and !isNum(b[i])) return greater;
        if (!isNum(a[i]) and isNum(b[i])) return lesser;
        if (!isNum(a[i]) and !isNum(b[i])) {
            if (a[i] == b[i]) continue;
            if (a[i] < b[i]) return greater;
            return lesser;
        }

        if (isNum(a[i]) and isNum(b[i])) {
            int cnta = 0, ida = i;
            while (ida < na and isNum(a[ida])) cnta++, ida++;

            int cntb = 0, idb = i;
            while (idb < nb and isNum(b[idb])) cntb++, idb++;

            if (cnta < cntb) return greater;
            if (cnta > cntb) return lesser;

            rep(j, i, i + cnta) {
                if (a[j] == b[j]) continue;
                if (a[j] < b[j]) return greater;
                return lesser;
            }

            i += cnta - 1;
        }
    }

    if (na == nb) return greater;
    if (na < nb) return greater;
    return lesser;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> S0;
    rep(i, 0, N) cin >> S[i];
    rep(i, 0, N) cout << solve(S0, S[i]) << endl;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5 + 100;

ll n, c;
ll H[MAXN], DP[MAXN];
vector<pair<LL,ll> > v;

void insert(pair<LL, ll> ve) {
	LL v3 = ve.f;
	while(v.size() >= 2) {
		LL v1 = v[v.size() - 2].f;
		LL v2 = v[v.size() - 1].f;
		if ((v3.s - v2.s) * (v1.f - v2.f) > (v2.s - v1.s) * (v2.f - v3.f)) break;
		v.pop_back();
	}
	v.pb(ve);
	return;
}

ll binser(ll now) {
	ll res = 0;
	if (v.size() == 1);
	else {
		int kiri = 0, kanan = v.size() - 2;
		res = v.size() - 1;;
		while (kiri <= kanan) {
			int tengah = (kiri + kanan) >> 1;
			LL v1 = v[tengah].f;
			LL v2 = v[tengah + 1].f;
			if (v2.s - v1.s >= now * (v1.f - v2.f)) {
				res = tengah;
				kanan = tengah - 1;		
			}
			else kiri = tengah + 1;
		}
	}
	return v[res].f.s + now * v[res].f.f;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> c;
	REP(i, n) cin >> H[i];
	for(int i = n - 1; i >= 0; i--) {
		if (i == n - 1) DP[i] = 0;
		else DP[i] = binser(-2 * H[i]) + H[i] * H[i] + c;
		pair<LL, ll> now = mp(mp(H[i], DP[i] + H[i] * H[i]), i);
		insert(now);
		//cout << i << ' ' << DP[i] << '\n';
	}
	cout << DP[0] << '\n';
}

Measured memory_bytes: 11248
'''
https://atcoder.jp/contests/abc150/tasks/abc150_c
'''
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007


    n = int(input())
    a = tuple(map(int, input().split()))
    b = tuple(map(int, input().split()))
    for i, x in enumerate(permutations(range(1, n+1), n)):
        if a==x:
            a = i
        if b==x:
            b = i
    print(abs(a-b))


if __name__ == '__main__':
    main()

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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {
	
	int n;
	vector<ll>v;
	string s;

	cin >> n;

	rep(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
	}
	
	if (n % 2 == 0) {
		for (int i = n-1; i >= 1; i -= 2) {
			if (i != n -1)cout << ' ';
			cout << v[i];
		}
		for (int i = 0; i < n - 1; i += 2) {
			cout << ' ' << v[i];
		}
		cout << endl;
	}
	else {
		for (int i = n - 1; i >= 0; i -= 2) {
			if (i != n - 1)cout << ' ';
			cout << v[i];
		}
		for (int i = 1; i <= n - 1; i += 2) {
			cout << ' ' << v[i];
		}
		cout << endl;
	}
	
	return 0;

}

Measured memory_bytes: 3824
N = int(input())
K = int(input())
 
def keta1(n):
    s = str(n)
    return (len(s) - 1) * 9 + int(s[0])
 
def keta2(n):
    if n < 10:
      return 0
    s = str(n)
    cnt = [0] * 101
    for i in range(2, 101):
        cnt[i] = 9 * 9 * (i - 1)
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta1(10 ** (len(s) - 1) - 1) + keta1(int(s[1:]))
    return res
 
def keta3(n):
    s = str(n)
    cnt = [0] * 101
    for i in range(3, 101):
        cnt[i] = 9 * 9 * 9 * (i - 1) * (i - 2) // 2
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta2(10 ** (len(s) - 1) - 1) + keta2(int(s[1:]))
    return res
 
if K == 1:
    print(keta1(N))
elif K == 2:
    print(keta2(N))
elif K == 3:
    print(keta3(N))

Measured memory_bytes: 38384
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN 100

const char *p;

int expr();
int term();
int fact();
int number();

int expr() {
	int res = term();
	while(*p == '+' || *p == '-') {
		const char operator = *p;
		++p;
		switch(operator) {
		case '+': res += term(); break;
		case '-': res -= term(); break;
		default: assert(false);
		}
	}
	return res;
}

int term() {
	int res = fact();
	while(*p == '*' || *p == '/') {
		const char operator = *p;
		++p;
		switch(operator) {
		case '*': res *= fact(); break;
		case '/': res /= fact(); break;
		default: assert(false);
		}
	}
	return res;
}

int fact() {
	if(*p == '-') {
		++p;
		return -fact();
	}
	else if(*p == '(') {
		++p;
		const int res = expr();
		assert(*p == ')');
		++p;
		return res;
	}
	else if(isdigit(*p)) {
		return number();
	}
	else {
		assert(false);
	}
}

int number() {
	int res = 0;
	while(isdigit(*p)) {
		res = res * 10 + (*p - '0');
		++p;
	}
	return res;
}

int main() {
	char input[MAX_LEN + 1];
	int i;
	int n;
	scanf("%d\n", &n);

	for(i = 0; i < n; ++i) {
		fgets(input, MAX_LEN + 1, stdin);
		p = input;
		const int ans = expr();
		assert(*p == '=');
		printf("%d\n", ans);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 600
#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;
}
const int N=20;
ll a[N][N]={0};
int main()
{
 ll n,d;
 CloseIo;
 map<ll,ll>mp;
 for(ll i=0;i<=10000;i++)
 mp[i*i]=1; 
 cin>> n >> d;
 ll ans = 0;
 rep(i,0,n)
 {
 	 rep(j,0,d)
 	   {
 	      cin >> a[i][j];	
	   }
 }
 rep(i,0,n)
 {
 	 rep(j,i+1,n)
 	 {   ll res = 0;
 	 	 rep(k,0,d)
 	 	  {
 	 	  	 res+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
		 //cout<<i<<" "<<j<<" "<<res<<"\n";
		 if(mp[res] == 1)
		   ans++;
	  }
 }
 cout<<ans;
}




Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

import java.math.BigInteger;

class Main {
    static final int Mod = 998244353;
    static final BigInteger MOD = BigInteger.valueOf(998244353);
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();
        combinationInit();
        BigInteger ans = BigInteger.ZERO;
        for(int allow = 0;allow<=K;allow++){
            BigInteger tmp = BigInteger.valueOf(M);
            tmp = tmp.multiply(BigInteger.valueOf(M-1).modPow(BigInteger.valueOf(N-(allow+1)), MOD));
            // tmp = tmp.multiply(BigInteger.valueOf(M).modPow(BigInteger.valueOf(allow), MOD));
            tmp = tmp.multiply(BigInteger.valueOf(combination(N-1, allow)));
            tmp = tmp.mod(MOD);
            ans = ans.add(tmp).mod(MOD);
            // System.out.println(ans);
        }
        System.out.println(ans);
    }

	static int MAX = 510000;
	static long[] fac = new long[MAX], finv = new long[MAX], inv = new long[MAX];

	static void combinationInit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < MAX; i++) {
			fac[i] = fac[i - 1] * i % Mod;
			inv[i] = Mod - inv[(int) Mod % i] * (Mod / i) % Mod;
			finv[i] = finv[i - 1] * inv[i] % Mod;
		}
	}

	static long combination(int n, int k) {
		if (n < k)
			return 0;
		if (n < 0 || k < 0)
			return 0;
		return fac[n] * (finv[k] * finv[n - k] % Mod) % Mod;
	}

    public static void main(String[] args) {
        new Main();
    }
}


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

int main () {
  int n;
  cin >>n;
  vector<int>x(n);
  int hp =0;
  int mn =1000000;
  for (int i=0;i<n;i++){
    cin>>x[i];
  }
  sort (x.begin(),x.end());

  for(int i=x[0];i<x[n-1]+1;i++){
    hp=0;
    for(int j=0;j<n;j++){     
      hp +=abs(x[j]-i)*abs(x[j]-i);
    }
  mn =min (hp,mn);
  }
  

  cout <<mn<<endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int s[][4] = {{0, 1, 2, 3}, {1, 0, 3, 2}, {2, 3, 0, 1}, {3, 2, 1, 0}};
int t[][4] = {{1, -1, -1, -1}, {1, 1, 1, -1}, {1, -1, 1, 1}, {1, 1, -1, 1}};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        for(int i=0; i<n; ++i){
            vector<int> a(4), b(4), c(4);
            for(int j=0; j<4; ++j)
                cin >> a[j];
            for(int j=0; j<4; ++j)
                cin >> b[j];

            for(int j=0; j<4; ++j){
                for(int k=0; k<4; ++k){
                    c[j] += a[k] * b[s[j][k]] * t[j][k];
                }
            }

            cout << c[0];
            for(int j=1; j<4; ++j)
                cout << ' ' << c[j];
            cout << endl;
        }
    }
}

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

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

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

const ll INF = 1LL << 60;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  rep(i, N) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  for (int i = 0; i < N; i++) {
    for (int sum_w = 0; sum_w <= W; sum_w++) {
      if (sum_w - w[i] >= 0) {
        chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
      }
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  map<int, bool> mp;
  for(int i=0;i<m;++i) {
    int tmp;
    cin >> tmp;
    mp[tmp] = true;
  }

  vector<int> dp(n+1);
  dp[0] = 1;
  if(!mp[1]) dp[1] = 1;
  for(int i=2;i<n+1;++i) {
    if(mp[i]) continue;
    dp[i] = dp[i-1] + dp[i-2];
    dp[i] %= MOD;
  }
  // printv(dp);
  cout << dp[n] << endl;
}


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

int main() {
	int s;
	cin >> s;
	vector<int> cnt(1000000, 0);
	cnt[s]++;
	int n = 1;
	while (true) {
		n++;
		if (s % 2 == 0) s /= 2;
		else s = 3 * s + 1;
		if (cnt[s] == 0) cnt[s]++;
		else {
			cout << n << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 4096
a, b, c = map(int, input().split())
ans = 0

for i in range(10000):
    if a%2 == 0 and b%2 == 0 and c%2 == 0:
        A = (b + c)/2
        B = (a + c)/2
        C = (a + b)/2
        a = A
        b = B
        c = C
        ans += 1
    else:
        break

if ans >= 10000:
    print(-1)
else:
    print(ans)

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

count = 1
num = 7
if K % 2 == 0 or K % 5 == 0:
    count = -1
else:
    while True:
        if num % K == 0:
            break
        num = (num*10 + 7) % K
        count += 1
        if count >= 10**6 * 10**5:
            count = -1
            break
print(count)

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

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

int main() {
	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);
	ll ans = 1;
	for (ll i = 2; i * i <= g; ++i) {
		if (g % i) continue;
		ans++;
		while (g % i == 0) {
			g /= i;
		}
	}
	if (g != 1) ans++;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  string s; cin >> s;
  
  if (((s[0]==s[1]&&s[2]==s[3])||(s[0]==s[2]&&s[1]==s[3])||(s[0]==s[3]&&s[1]==s[2]))&&!(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])) cout << "Yes";
  else cout << "No";
 
  return 0;
}


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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

void solve(){
    int D, T, S;
    cin >> D >> T >> S;
    if(D<=T*S) Yes;
    else No;
}


signed main(){
    cout << fixed << setprecision(18);
//    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;
const int MAXN = 100010;

int n;
int a[MAXN];

void solve() {
  int sum = 0;
  for (int i=0;i<=n;i++) {
    sum += abs(a[i+1] - a[i]);
  }
  for (int i=0;i<n;i++) {
    cout << (sum - abs(a[i+2] - a[i+1]) - abs(a[i+1] - a[i]) + abs(a[i+2] - a[i])) << endl;
  }
}

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


Measured memory_bytes: 1664
#include <stdio.h>
int prime(int x) {
    int i;
    if (x<2) return 0;
    if (x==2) return 1;
    if(x%2==0) return 0;
     
    for (i=3; i*i<=x; i+=2)
    if(x%i==0) return 0;
     
    return 1;
}
 
int main(void){
    int i,n,c=0,a;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &a);
        c+=prime(a);
    }
     
    printf("%d\n", c);
     
    return 0;
     
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long arr[3];
    for (int i=0 ; i<3 ; ++i)
    {
        cin>>arr[i];
    }
    sort (arr,arr+3);
    if (arr[1]-arr[0]==arr[2]-arr[1])
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3632
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
bool compar(const pair<string,ll> &a, const pair<string,ll> &b) 
{ 
    if(a.first==b.first)
    return (a.second < b.second);
    else
    return (a.first < b.first);
}

void comp()
{
	ll i,j,k,m,n,p,w,d,x,y;
	string s;
	cin>>n;
	vector<ll>v1;
	map<ll,ll>m1;
	fl(i,n)
	{
		cin>>j;
		m1[j]++;
		v1.pb(j);
	}
	ll ans=0;
	map<ll,ll> :: iterator it = m1.begin();
	while(it!=m1.end())
	{
		ans+=((it->second)*(it->second-1))/2;
		it++;
	}
	ll temp,temp1;
	fl(i,n)
	{
		temp=(m1[v1[i]]*(m1[v1[i]]-1))/2;
		temp1=((m1[v1[i]]-1)*(m1[v1[i]]-2))/2;
		cout<<ans-temp+temp1<<"\n";
	}
}

int main()
{
    speedup;
    ll i=0,t;
    ll n;
    //cin>>t;
    t=1;
	while(t--)
    {
    	i++;
    	//cout<<"Case #"<<i<<": ";
        comp();
    }
    return 0;
}


Measured memory_bytes: 11120
#include<stdio.h>
#define max 100
#define BLACK 2
#define WHITE 0
#define GRAY 1
//変数
struct Graph{
  int u,k;
}graph[max];
int num,result[max][max],color[max],find[max],found[max],cnt_found;
int g[max][max];
//関数
void dfs();
void visit(int);

int main(){
  int i,j;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    result[i][i]=0;
    color[i]=WHITE;
    find[i]=0;
    found[i]=0;
    graph[i].u=0;
    graph[i].k=0;
  }
  for(i=1;i<num+1;i++){
    scanf("%d %d",&graph[i].u,&graph[i].k);
    for(j=1;j<(graph[i].k)+1;j++){
      scanf("%d",&g[i][j]);
      result[graph[i].u][g[i][j]]=1;
      }
  }

  dfs();
  return 0;
}
void dfs(){
  int u;
  cnt_found=0;
  for(u=1;u<num+1;u++){
  if(color[u]==WHITE){
    visit(u);
  }
  }
  for(u=1;u<num+1;u++){
    printf("%d %d %d\n",u,find[u],found[u]);
  }
}

void visit(int u){
  int v;
  color[u]=GRAY;
  find[u]=++cnt_found;
  for(v=1;v<num+1;v++){
    if(result[u][v]==0){
      continue;
    }
    if(color[v]==WHITE){
      visit(v);
    }
  }
  color[u]=BLACK;
  found[u]=++cnt_found;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
template <class T> struct FenwickTree {

   vector<T> node;
   FenwickTree (int n) : node(n,0) {}

   void add(int idx, T val) {
      for (int i = idx; i < node.size(); i |= i + 1) {
         node[i] += val;
      }
   }

   T sum(int idx) {
      T ret = 0;
      for (int i = idx - 1; i >= 0; i = (i & (i + 1)) - 1) {
         ret += node[i];
      }
      return ret;
   }

};
 
int N,M;
vector< pair<int,int> > add;
vector<int> l,r;
FenwickTree<int> inst(100010);
 
int main() {
 
  cin >> N >> M;
  l.resize(N);
  r.resize(N);
 
  REP(i,N) {
    int lt,rt; cin >> lt >> rt;
    l[i] = lt;
    r[i] = rt;
    add.push_back(make_pair(rt - lt + 1, i));
  }
  
  sort(add.begin(),add.end());
 
  int j = 0;
  for(int i=1; i<=M; i++) {
    while(j < add.size()) {
      if(add[j].first >= i) break;
      int idx = add[j].second;
      inst.add(l[idx],1);
      inst.add(r[idx]+1,-1);
      j++;
    }
 
    int ans = N - j;
    for(int k=i; k<=M; k+=i) ans += inst.sum(k+1);
    cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 9200
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Printf("%d\n", foundNum(n))
}

func foundNum(start int) int {
	for i := start; i <= 999; i++ {
		str := strconv.Itoa(i)
		letters := []rune(str)
		first := letters[0]
		sameLetter := true
		for i, l := range letters {
			if i >= 1 {
				if l != first {
					sameLetter = false
					break
				}
			}
		}

		if sameLetter {
			return i
		}
	}

	return -1
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<ll,ll>>s(n),p(m);
    for(int i=0; i<n; i++){
        ll a,b;
        cin >> a >> b;
        s[i] = make_pair(a,b);
    } 
    for(int i=0; i<m; i++){
        ll c, d;
        cin >> c >> d;
        p[i] = make_pair(c,d);
    } 
    for(int i=0; i<n; i++){
        ll d=1e18;
        int point=0;
        for(int j=0; j<m; j++){
            if(d > abs(s[i].first-p[j].first) + abs(s[i].second-p[j].second)){
                d = abs(s[i].first-p[j].first) + abs(s[i].second-p[j].second);
                point = j+1;
            }
        }
        cout << point << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		//charに変換して1文字ずつ比べる
		char[] C = S.toCharArray();
		
		int count = 1;
		//すべての文字列が等しいときは1なのでcountを1にする
		//例：aabba→abaは3となるため
		//forでi番目とi+1番目が等しくないときはcountに+1をする
		for(int i=0; i<N-1; i++) {
			if(C[i]!=C[i+1]) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 27092
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(K);
    READAR(A,N);
    sort(A,A+N);
    ll sum=0;
    FORI(i,0,K)
    {
        sum+=A[i];
    }
    cout<<sum<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

ll func(ll n, ll k)
{
    ll L = 1, M = (1LL<<(n+1))-1, R = (1LL<<(n+2))-3;
    ll P = (1LL<<n)-1;
    if(n > 0) {
        if(k == L) return 0;
        else if(L < k && k < M) return func(n-1, k-1);
        else if(k == M) return P + 1;
        else if(M < k && k < R) return func(n-1, k-M) + P + 1;
        else if(k == R) return P * 2 + 1;
        else return 0;
    }
    else return 1;
}

int main()
{
    ll N, X;
    cin >> N >> X;

    ll ans = func(N, X);
    PR(ans);

    return 0;
}

/*



*/

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a[9]={5,3,3,3,3,3,4,3,4},n;
  int ln;
  char c[9][6]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  string s;
  string *t;
  cin>>n;
  t=new string[n];
  for(i=0;i<n;i++){
    cin>>s;
    ln=s.length();
    t[i]="";
    for(j=0;j<ln;j=k){
      for(;j<ln&&s[j]=='0';j++);
      for(k=j;k<ln&&s[j]==s[k];k++);
      if(k-j)
	t[i]+=c[s[j]-'1'][(k-j-1)%a[s[j]-'1']];
    }
  }
  for(i=0;i<n;i++)
    cout<<t[i]<<endl;
  delete[]t;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

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

    cout << n % m << endl;
    return 0;
}


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

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

	int n = s.size();
	static long long dp[20];

	for (int i = 0; i < n; i++) {
		for (int j = 1; i + j <= n; j++) {
			dp[i + j] += dp[i] + stoll(s.substr(i, j)) * (i == 0 ? 1 : (1ll << (i - 1)));
		}
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  C - Lower
//
//  Created by Hashizo on 2019/09/01.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll n;
	ll cnt = 0;
	ll maxcnt = 0;
	cin >> n;

	vector<ll> h(n);
	REP(i, n) {
		cin >> h[i];
	}

	REP(i, n-1) {
		if(h[i] >= h[i+1]) {
			cnt++;
		}
		else {
			if (maxcnt < cnt) {
				maxcnt = cnt;
			}
			cnt = 0;
		}
	}
	if (maxcnt < cnt) {
		maxcnt = cnt;
	}
	
	
	
	cout << maxcnt << endl;
	return 0;
}


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

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define MOD 1000000007

int n,m;
int a[125252], b[125252];
ll x[125252];

const int B = 300;
ll db[B+10][B+10];

// xj = sum_i (a_i+j)%b_i

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d",a+i,b+i);
  ll imov = 0;
  ll acv = 0;
  REP(i,m){
    if(b[i]<B){
      // db[b[i]][x] := j%b[i]==x のときの加算値
      REP(j,b[i]){
        db[b[i]][j] += (a[i]+j)%b[i];
      }
    }else{
      x[0] += a[i];
      imov++;
      int tmp = a[i];
      int it = 0;
      while(it <= n+10){
        int add = (b[i]-tmp);
        it += add;
        if(it>n+10)break;
        x[it] -= b[i];
        tmp = 0;
      }
    }
    // REP(i,n+1)printf("%lld, ",x[i]);puts("");
  }
  REP(i,n+1){
    acv += x[i];
    x[i] = (ll)i*imov + acv;
    FOR(j,1,B)x[i] += db[j][i%j];
  }
  FOR(i,1,n+1)printf("%lld\n",x[i]);
  return 0;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256