akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b = sc.nextInt();
		int max = b;
		int out = 0;
		int min = b;
		int sec = -1000000000;
		int thr = -1000000000;
		for(int i = 1;i <= size - 1;i++){
			int num = sc.nextInt();
			if (max <= num){
				max = num;
				if(sec < max - min){
					sec = max - min;
				}		
			}else if(min > num){
				min = num;
				if(thr < min - max){
					thr = min - max;
				}
				max = num;
			}
			
		}
		if(sec < thr){
			out = thr;
		}else{
			out = sec;
		}
		System.out.println(out);
	}
	
	
}

Measured memory_bytes: 68536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

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

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

int S[1005];

int main()
{
	while (true)
	{
		int N;
		cin >> N;
		if (N == 0)break;

		double sum = 0;
		REP(i, N)
		{
			cin >> S[i];
			sum += S[i];
		}
		sum /= N;

		double A = 0;
		REP(i, N)
		{
			A += pow((S[i] - sum), 2);
		}
		A /= N;
		A = sqrt(A);
		cout << OF64 << A << endl;
	}
	return 0;
}


Measured memory_bytes: 3300
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C, D, E, F =  MAP()
A *= 100
B *= 100
# 溶ける最大濃度
limit = E / (100+E)

# dp[i][j] := 水i、砂糖jの状態を実施可能か
dp = list2d(F+1, F+1, 0)
dp[0][0] = 1
for i in range(F+1):
    for j in range(F+1):
        # 枝刈り
        if i+j > F:
            break
        # 実施可能な状態なら、4つの行動を遷移させる
        if i+A <= F:
            dp[i+A][j] |= dp[i][j]
        if i+B <= F:
            dp[i+B][j] |= dp[i][j]
        if j+C <= F:
            dp[i][j+C] |= dp[i][j]
        if j+D <= F:
            dp[i][j+D] |= dp[i][j]

ans1 = ans2 = mx = 0
for a in range(F+1):
    for b in range(F+1):
        if a+b > F:
            break
        if a == b == 0:
            continue
        if dp[a][b]:
            x = b / (a+b)
            # 濃度が濃すぎて溶け切らない
            if x > limit:
                continue
            # 最大濃度の更新
            if mx <= x:
                mx = x
                ans1 = a + b
                ans2 = b
print(ans1, ans2)


Measured memory_bytes: 108892
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define mod 1000000007
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x; i<n; i++)
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)),x.resize(distance(x.begin(),unique(all(x))))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
void solve()
{
  int a,b;
  cin>>a>>b;
  if((a==1 && b==2) || (b==1 && a==2))
  cout<<3;
  else if((a==2 && b==3) || (b==2 && a==3))
  cout<<1;
  else if((a==1 && b==3) || (b==1 && a==3))
  cout<<2;
}

int main()
{
// fast();
// #ifndef ONLINE_JUDGE
//             freopen("input.txt", "r", stdin);
//             freopen("output.txt","w",stdout);
// #endif
    // int t;
    // cin>>t;
    // while(t--)
    // {
    //     cout<<"satyam";
    // }
    solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

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


ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}



// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};



int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll res = a[0];
    for(int i = 1; i < n; i++){
        res = gcd(res, a[i]);
    }

    cout << res << endl;

    return 0;
}

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

int main() {
  vector<int> s(3);
  cin >> s[0] >> s[1] >> s[2];
  sort(s.begin(), s.end(), greater<int>());
  if (s[0] != s[1] && s[1] == s[2]) {
    cout << s[0] << endl;
  } else {
    cout << s[2] << endl;
  }
}

Measured memory_bytes: 256
import numpy as np

# 初期値を入力

N = int(input())
L = [int(x) for x in input().split()]


# メインプログラム

L = np.array(L)
Max_L = max(L)

if Max_L < sum(L) - Max_L:
    print("Yes")

else:
    print("No")


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int H, W; scanf("%d %d", &H, &W);
  vector<string> grid(H);
  for (int i = 0; i < H; ++i) {
    cin >> grid[i];
  }
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      if (grid[r][c] != '#') { continue; }
      bool ok = false;
      for (int dr = -1; dr <= 1; ++dr) {
        for (int dc = -1; dc <= 1; ++dc) {
          if (abs(dr) + abs(dc) != 1) { continue; }
          int nr = r + dr, nc = c + dc;
          if (0 <= nr and nr < H and 0 <= nc and nc < W and grid[nr][nc] == '#') {
            ok = true;
          }
        }
      }
      if (not ok) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if(n == 0 && m == 0) {
				break;
			}
			int[] p = new int[n];
			for(int i = 0; i < n; i++) {
				p[i] = stdIn.nextInt();
			}
			Arrays.sort(p);
			int sum = 0;
			int counter = 0;
			for(int i = p.length-1; i >= 0; i--) {
				if(counter == m - 1) {
					counter = 0;
					continue;
				}
				sum += p[i];
				counter++;
			}
			System.out.println(sum);
			
		}
	}
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int Ans=0;
  int Sum=0;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    Sum+=A.at(i);
  }
  int Bar;
  if(Sum%(4*M)==0){
    Bar=Sum/(4*M)-1;
  }
  else{
    Bar=Sum/(4*M);
  }
  for(int i=0; i<N; i++){
    Ans+=A.at(i)>Bar;
  }
  if(Ans>=M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	
	int k, s;
	cin>>k>>s;
	int d;
	int ans = 0;
	for(int i = 0; i <= k; i++)
	{
		d = s-i;
		for(int j = 0; j <= k; j++)
		{
			int l = d - j;
			// d = d - j;
			// p(l);
			if(l>=0 and l<=k) ans++;
		}
	}
	p(ans);
	return 0;
}	

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define M 50
const int di[4] = {0, -1, 0, 1};
const int dj[4] = {1, 0, -1, 0};
char L[M][M], R[M][M];

int W, H, lg, rg;

bool check(int y, int x){
    return 0 <= y && 0 <= x && y < H && x < W;
}
bool dfs(int lp, int rp){
    bool V[M*M][M*M];
    rep(i, W*H) rep(j, W*H) V[i][j] = false;
    stack<pair<int, int> > S;
    S.push(make_pair(lp, rp));
    pair<int, int> u, v;
    while(!S.empty()){
	u = S.top(); S.pop();
	lp = u.first; rp = u.second;
	if ( lp == lg && rp == rg ) return true;
	if ( lp == lg || rp == rg ) continue;
	int lny, lnx, rny, rnx;
	rep(d, 4){
	    lny = lp/W + di[d];
	    lnx = lp%W + dj[d];
	    rny = rp/W + ((d%2==1)?di[d]:di[(d+2)%4]);
	    rnx = rp%W + ((d%2==1)?dj[d]:dj[(d+2)%4]);
	    if ( !(check(lny, lnx) && L[lny][lnx] != '#')) { lny = lp/W; lnx = lp%W; }
	    if ( !(check(rny, rnx) && R[rny][rnx] != '#')) { rny = rp/W; rnx = rp%W; }
	    int l = lny*W+lnx;
	    int r = rny*W+rnx;
	    if ( !V[l][r] ) { V[l][r] = true; S.push(make_pair(l, r));}
	}
    }
    return false;
}

main(){
    int lp, rp;
    while( cin >> W >> H && W ){
	rep(i, H) {
	    rep(j, W) {
		cin >> L[i][j];
		if ( L[i][j] == 'L' ) lp = i*W+j;
		if ( L[i][j] == '%' ) lg = i*W+j;
	    }
	    rep(j, W) {
		cin >> R[i][j];
		if ( R[i][j] == 'R' ) rp = i*W+j;
		if ( R[i][j] == '%' ) rg = i*W+j;
	    }
	}
	if ( dfs(lp, rp) ) cout << "Yes" << endl;
	else cout << "No" << endl;
    }
}

Measured memory_bytes: 15000
#include<bits/stdc++.h>
using namespace std;
int a[110000],q[110000];
int n,ans;
int main() {
  scanf("%d",&n);
  for(int i=1;i<=n;++i) scanf("%d",&a[i]);
  
  sort(a+1,a+n+1);
  
  for(int i=1;i<=n-2;i++) {
  	int t=0,h=1;
  	q[++t]=a[i+1];
		for(int j=i+2;j<=n;j++) {
  		while (h <= t && a[i] + q[h] <= a[j]) ++ h;
  		ans += t - h + 1;
  		q[++t]=a[j];
  	}
  }
  
  printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
char s[110];
char t[8]={"keyence"};
int book[110];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=0;i<=7;i++)
    {
        memset(book,0,sizeof(book));
        for(int j=i+1;j<=i+n-7;j++)  book[j]=1;
        int len=0;
        int flag=0;
        for(int j=1;j<=n;j++)
        {
            if(book[j]==0)
            {
                if(s[j]!=t[len]){
                    flag=1;
                    break;
                }
                len++;
            }
        }
        if(flag==0){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
mini = 1000000
for i in range(N):
    sum_mae = sum(W[:i])
    sum_ato = sum(W[i:])
    if mini > abs(sum_mae - sum_ato):
        mini = abs(sum_mae - sum_ato)
print(mini)

Measured memory_bytes: 3060
from itertools import product
h, w, k = [int(_) for _ in input().split()]

c = [input() for i in range(h)]
ans = 0
for x in product([0, 1], repeat=h):
    for y in product([0, 1], repeat=w):
        d = 0
        for i in range(h):
            for j in range(w):
                if c[i][j] == '#' and x[i] and y[j]:
                    d += 1
        if d == k:
            ans += 1

print(ans)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
long dist(long a,long b){
    long m=min(a,b),M=max(a,b);
    
    if(m==M){
        return m;
    }else{
        return 2*((M-1)/m)*m + dist(m,(M-1)%m+1);
    }
}
int main() {
    long N,X;
    cin>>N>>X;
    cout<<N+dist(X,N-X)<<endl;
}


Measured memory_bytes: 256
X=int(input())
if 400<=X<=599:
  print("8")
elif 600<=X<=799:
  print("7")
elif 800<=X<=999:
  print("6")
elif 1000<=X<=1199:
  print("5")
elif 1200<=X<=1399:
  print("4")
elif 1400<=X<=1599:
  print("3")
elif 1600<=X<=1799:
  print("2")
else:
  print("1")


Measured memory_bytes: 9180
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 2*(10**9)
for i in range(n-k+1):
    total_d = x[i+k-1] - x[i]
    zero_d = min(abs(x[i]), abs(x[i+k-1]))
    ans = min(ans, total_d + zero_d)
print(ans) 

Measured memory_bytes: 14664
#include <iostream>
#include <string>

int main() {
    bool s['z' - 'a' + 1] = {};
    std::string str;
    std::cin >> str;
    for (auto c: str) {
        int i = c - 'a';
        if (s[i]) {
            std::cout << "no" << std::endl;
            return 0;
        }
        s[i] = true;
    }
    std::cout << "yes" << std::endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type txy struct {
	t int
	x int
	y int
}

type PointTime struct {
	time int
	dx   int
	dy   int
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()

	slice := []txy{
		{
			t: 0,
			x: 0,
			y: 0,
		},
	}

	for i := 0; i < N; i++ {
		t := nextInt()
		x := nextInt()
		y := nextInt()

		slice = append(slice, txy{
			t: t,
			x: x,
			y: y,
		})
	}

	can := true
	for i := 0; i < N; i++ {
		dt := slice[i+1].t - slice[i].t
		dist := int(math.Abs(float64(slice[i+1].x-slice[i].x)) + math.Abs(float64(slice[i+1].y-slice[i].y)))
		if dt < dist {
			can = false
		}

		if dist%2 != dt%2 {
			can = false
		}

	}

	if can {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 10752
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M;
  map<string,int> mp;
  cin>>N;
  REP(i,N){
    string s;
    cin>>s;
    mp[s]++;
  }
  cin>>M;
  REP(i,M){
    string s;
    cin>>s;
    mp[s]--;
  }

  int ans=0;
  for(auto e:mp){
    ans=max(e.second,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] w = new int[n];
		for (int i = 0; i < w.length; i++) {
			w[i] = Integer.parseInt(sc.next());
		}
		int ans = 100;
		for (int i = 0; i < n; i++) {
			int less = 0;
			int more = 0;
			for (int j = 0; j < w.length; j++) {
				if (j <= i) {
					less += w[j];
				} else {
					more += w[j];
				}
			}
			ans = Math.min(ans, Math.abs(more - less));
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main { 
    char[] cs;

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

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        for (int i = 0; i < cs.length; i++) {
            if ((i & 1) == 0) {
                System.out.print(cs[i]);
            }
        }
        System.out.println();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 27540
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	string s;
	int ans,sl,q;
	while(cin>>s){
		if(s=="EOF") break;
		ans=0;
		q=INF;
		sl=size(s);
		for(int i=0;i<sl;i++){
			if(s[i]=='I'){
				if(q>=1) ans+=1;
				else ans-=1;
				q=1;
			}
			if(s[i]=='V'){
				if(q>=5) ans+=5;
				else ans=ans+5-q-q;
				q=5;
			}
			if(s[i]=='X'){
				if(q>=10) ans+=10;
				else ans=ans+10-q-q;
				q=10;
			}
			if(s[i]=='L'){
				if(q>=50) ans+=50;
				else ans=ans+50-q-q;
				q=50;
			}
			if(s[i]=='C'){
				if(q>=100) ans+=100;
				else ans=ans+100-q-q;
				q=100;
			}
			if(s[i]=='D'){
				if(q>=500) ans+=500;
				else ans=ans+500-q-q;
				q=500;
			}
			if(s[i]=='M'){
				if(q>=1000) ans+=1000;
				else ans=ans+1000-q-q;
				q=1000;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1196
import java.util.*;

class Main {
    static long[] bit0,bit1;
    static int[] a;
    static int m,n;
    static int maxN = 100000+100;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        a = new int[n+1];
        bit0 = new long[100000+100];
        bit1 = new long[100000+100];
        for(int i=1;i<=n;i++) a[i]=sc.nextInt();
        long oriSum = 0;
        for(int i=1;i<n;i++) oriSum += a[i]<a[i+1]?a[i+1]-a[i]:m-a[i]+a[i+1];
        long temp[] = new long[m+1];
        for(int i=1;i<=n-1;i++) {
            handle(a[i],a[i+1]);
        }
        long res = 0;
        for(int j=1;j<=m;j++) temp[j] = sim_sum(j);
        for(int i=1;i<=m;i++) res = Math.max(res,temp[i]);
        System.out.println(oriSum-res);
    }

    static long sum(long[] bit, int i){
        long ans = 0;
        while(i>0){
            ans += bit[i];
            i -= i&(-i);
        }
        return ans;
    }

    static void add(long[] bit, int idx, long val){
        while(idx<=m){
            bit[idx] += val;
            idx += idx&(-idx);
        }
    }

    static long sim_sum(int i){
        return sum(bit1,i)*i+sum(bit0,i);
    }
    // here simulate adding val to all position within the interval [left,right]
    static void sim_add(int left, int right, long val){
        if(left>right){
            return;
        }
        add(bit0,left,-val*(left-1));
        add(bit1,left,val);
        add(bit0,right+1,val*right);
        add(bit1,right+1,-val);
    }

    static void handle(int from, int to){
        if(from<to){
            if(from==to-1) return;
            sim_add(from+2,to,1);
            sim_add(to+1,to+1,-(to-from-1));
        } else if(from > to){
            sim_add(from+2,m,1);
            sim_add(1,1,m-from);
            sim_add(2,to,1);
            sim_add(to+1,to+1,-(m-from+to-1));
        }
    }
}


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

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    s.insert(s.begin(), '#');
    vector<int> last(n + 2, -1e9);
    vector<int> count(n + 2, 0);
    vector<int> last_rev(n + 2, 1e9);
    vector<int> count_rev(n + 2, 0);
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'o' && last[i - 1] + c < i) {
            last[i] = i;
            count[i] = count[i - 1] + 1;
        } else {
            last[i] = last[i - 1];
            count[i] = count[i - 1];
        }
    }
    for (int i = n; i >= 1; i--) {
        if (s[i] == 'o' && last_rev[i + 1] - c > i) {
            last_rev[i] = i;
            count_rev[i] = count_rev[i + 1] + 1;
        } else {
            last_rev[i] = last_rev[i + 1];
            count_rev[i] = count_rev[i + 1];
        }
    }
    for (int i = 1; i <= n; i++) {
        if (last[i] == i && last_rev[i] == i && count[i] + count_rev[i] == k + 1) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 4996
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        double min = 0;
        for (int i = 1; i < 100000; i++) {
            double pow = Math.pow(i, 2);
            if (pow > n) {
                break;
            }
            min = pow;
        }
        System.out.println((int) min);
    }

}


Measured memory_bytes: 21844
from collections import deque

n, m = map(int, input().split())

adj = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

q = deque()

dist = [-1] * n
ans = [0] * n

q.append(0)
while len(q) != 0:
    now = q.popleft()
    for to in adj[now]:
        if dist[to] != -1:
            continue
        dist[to] += 1
        ans[to] = now
        q.append(to)

print("Yes")
for i in range(1,n):
    print(ans[i] + 1)

Measured memory_bytes: 34988
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll N, M, K;
ll A[200005];
ll B[200005];

const ll INF = 1e15;

int main()
{
    cin >> N >> M >> K;
    for(ll i = 0;i < N;i++)
    {
        cin >> A[i];
    }
    for(ll i = 0;i < M;i++)
    {
        cin >> B[i];
    }
    A[N] = INF;
    B[M] = INF;
    ll sumt = 0;
    ll suma = 0;
    ll sumb = 0;
    ll ans = 0;
    ll i = 0, j = 0;
    while(sumt + A[i] <= K)
    {
        sumt += A[i];
        i++;
    }
    while(sumt + B[j] <= K)
    {
        sumt += B[j];
        j++;
    }
    ans = i+j;
    while(i > 0)
    {
        i--;
        sumt -= A[i];
        while(sumt + B[j] <= K)
        {
            sumt += B[j];
            j++;
        }
        ans = max(ans, i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6284
#include<stdio.h>

int main()
{

  int n,A[100000],i,j,pivot,small,big,swap;
  scanf("%d",&n);
  for(i= 0 ;i<n;i++)scanf("%d",&A[i]);
  i = -1;
  
    for(j = 0 ;j <n-1 ; j++)
      {
	if(A[j] <= A[n-1])
	  {
	    i++;
	    swap = A[j];
	    A[j] = A[i];
	    A[i] = swap;
	  }
	
      }
    swap = A[i+1];
    A[i+1] = A[n-1];
    A[n-1] = swap;
    j = i+1;
    
  for(i = 0 ; i<n ; i++)
    {
      if(i == j)
	{
	  printf("[%d] ",A[i]);
	  continue;
	}
      
      if(i == n -1)
	{
	  printf("%d\n",A[i]);
	  break;
	}
     
      printf("%d ",A[i]);
      
	}
  
}



Measured memory_bytes: 2184
S = input()
Q = int(input())

T = ""
for i in range(Q) :
    Query = list(input().split())
    if Query[0] == "1" :
        S, T = T, S
    elif Query[0] == "2" :
        if Query[1] == "1" :
            T = T + Query[2]
        elif Query[1] == "2" :
            S = S + Query[2]

T = T[::-1]
T = T + S
print(T)

Measured memory_bytes: 4312
n=int(input())
h=list(map(int,input().split()))
ans=0
for i in range(max(h)):
    x=h[:]
    for j in range(n):
        if j==0 and x[0]!=0:
            ans+=1
            h[j]-=1
        if j!=0:
            if x[j-1]==0 and x[j]!=0:
                ans+=1
            if x[j]!=0:
                h[j]-=1
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 22;
string grid[N];
int dis[N][N];

int get(int sx, int sy) {
  memset(dis, -1, sizeof dis);

  queue<PII> Q;
  Q.emplace(sx, sy); dis[sx][sy] = 0;
  int res = 0;

  while (!Q.empty()) {
    int x, y; tie(x, y) = Q.front(); Q.pop();
    if (grid[x][y] != '.') continue;
    res = max(res, dis[x][y]);

    for (int dx: {-1, 0, 1}) {
      for (int dy: {-1, 0, 1}) {
        if (abs(dx) + abs(dy) != 1) continue;
        int xx = x + dx, yy = y + dy;
        if (dis[xx][yy] == -1) {
          dis[xx][yy] = dis[x][y] + 1;
          Q.emplace(xx, yy);
        }
      }
    }
  }

  return res;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int h, w; cin >> h >> w;
  grid[0] = grid[h + 1] = string(N, '#');
  for (int i = 1; i <= h; i++) {
    string s; cin >> s;
    grid[i] = "#" + s + "#";
  }

  int ans = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      ans = max(ans, get(i, j));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *

def readline():
    return list(map(int,input().split(' ')))

n = readline()[0]
prev = 0
ans = 0
for i in range(0,n):
    x = readline()[0]
    s = min(prev,x)
    prev = prev -s
    x = x - s
    ans = ans + s
    s = x >> 1
    ans = ans + s
    prev = x - s * 2

print(ans)


Measured memory_bytes: 4336
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
D=[1]*(A[-1]+1)
for i in A:
  if D[i]==1:
    for j in range(A[-1]//i):
      D[i*(j+1)]=0
    D[i]=1
dic={}
for i in A:
  if i not in dic:
    dic[i]=1
  else:
    dic[i]+=1

for i in dic:
  if dic[i]>1:
    D[i]=0
    
ans=0
for i in A:
  if D[i]==1:
    ans+=1
print(ans)

Measured memory_bytes: 43648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

struct Point{
    ll x;
    ll y;
};


bool cmp_x(const Point &a, const Point &b ){
    return a.x < b.x;
}

bool cmp_y(const Point &a, const Point &b ){
    return a.y < b.y;
}


void cp_vec(vector <Point> &from, vector <Point> &to, int first, int last){

    to.resize(last - first + 1);
    for(int i = first; i <= last; i++){
        to[i - first] = from[i];
    }

}

int main(){

    ll N, K;
    cin >> N >> K;

    vector< Point > p(N);
    for(ll i = 0; i < N; i++){
        cin >> p[i].x >> p[i].y;
    }

    sort(all(p), cmp_x);

    ll ans = LLONG_MAX;
        	 
    for(int first = 0; first < N; first ++){

        vector< Point > q;
        for(int last = first + K - 1; last < N; last ++){
            ll width = p[last].x -  p[first].x;
            if(DEBAG){
                cout << endl;
                cout << "first : " << first << endl;
                cout << "last : " << last << endl;
                cout << "width : " << width << endl;
            }


            cp_vec(p, q, first, last);
            sort(all(q), cmp_y);
            ll height = q[q.size() - 1].y - q[0].y;
            if(DEBAG){
                cout << endl;
                cout << "first : " << first << endl;
                cout << "last : " << last << endl;
                cout << "height : " << height << endl;
            }
            for(int y_ind = 0; y_ind + K <= q.size(); y_ind ++){
                height = min(height, q[y_ind + K - 1].y - q[y_ind].y);
            }

            ll area = width * height;
            if(DEBAG){
                cout << endl;
                cout << "area = " << area << "  " << width << "  " << height <<  endl;
            }
            
            ans = min(ans, area);
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args []){
    	Scanner sc=new Scanner(System.in);
      	char a[]=sc.next().toCharArray();
      	char b[]=sc.next().toCharArray();
      	int count=0;
      	for(int i=0;i<a.length;i++){
        	if(a[i]==b[i]){
            	count++;
            }
        }
      	System.out.println(count);
      
    }
}

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

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


using ll=long long;
using P=pair<ll,ll>;
template <class T> using vec=vector<T>;
template <class T> using vvec=vec<vec<T>>;



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

    while(true){
        ll n,m;
        cin>>n>>m;
        if(n==0 && m==0) break;

        vec<ll> sum(n,0);

        REP(i,m-1){
            ll aa,x;
            cin>>aa>>x;
            x--;
            for(int j=x-1;j>=0;--j){
                ll b=aa-(x-j)*(x-j);
                if(b>0){
                    sum[j]+= b;
                }else{
                    break;
                }
            }
            for(int j=x;j<n;++j){
                ll b=aa-(x-j)*(x-j);
                if(b>0){
                    sum[j]+= b;
                }else{
                    break;
                }
            }
        }
        ll a;
        cin>>a;

        auto check = [&](ll x)->bool{
            ll th=-1;
            REP(i,n){
                if(sum[i] < x){
                    ll b = sum[i] - x + a;
                    if(b<0) return false;
                    else{
                        ll d = (ll)sqrt(b);
                        if(th == -1) th = i+d;
                        else{
                            if(abs(th-i)>d){
                                if(i+d<th){
                                    th=i+d;
                                    
                                }else{
                                    return false;
                                }
                            } 
                        }
                    }
                }
            }
            return true;
        };

        ll l=0;
        ll r=1e14+10;
        while(l+1<r){
            ll m=l+r>>1;
            if(check(m)) l=m;
            else r=m;
        }
        cout<<l<<"\n";
    }
    return 0;
}


Measured memory_bytes: 10984
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n;
  	map<string,int> mp;
  cin>>n;
  int mini=-1;
  for(int i=0;i<n;i++){
  	string s;
    cin>>s;
    mp[s]++;
 	if(mp[s]>mini)mini=mp[s];
  }
  map<string,int>::iterator it=mp.begin();
  while(it!=mp.end()){
  	if(it->second==mini)cout<<it->first<<endl;
    it++;
  }
}

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

using namespace std;

void selectionSort(vector<int> vec , size_t N){
  size_t minj=0;
  size_t count=0;
  for(size_t i=0; i<N; i++){
    minj =i;
    for(size_t j=i; j< N ; j++ ){
      if(vec[j] < vec[minj] ){
        minj =j;


      }

    }
    swap(vec[i],vec[minj]);
    if(i!=minj){
      count++;
    }
  }

  for(size_t i=0 ; i< N ; i++){
     if(i == N-1){
       cout<< vec[i];
     }
 else    cout<< vec[i] << " " ;
  }
  cout <<endl;

  cout<< count << endl;
}



int main(){
  size_t N;
  cin >> N;
  vector<int> vec(N);
  for(size_t i=0; i< N ; i++){
    cin>> vec[i];
  }

  selectionSort(vec,N);

  return 0;
}



Measured memory_bytes: 3156
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
  
def ser(sum,d,bef,used)
  if(d == @size - 1)
    @ans = [sum,@ans].min
    return
  end
  @size.times do |i|
    next if used[i] 
    used[i] = true
    ser(sum+@rt[bef][@r[i]],d+1,i,used)
    used[i] = false
  end
  
end
n,m,r = inp
r = inp
@ans = 1e20
@r = r
@size = r.size
d = []
path = na2(n+1,0)
m.times do|i|
  a,b,c = inp
  path[a].push([b,c])
  path[b].push([a,c])
end
@rt = []
r.each do |start|
  dist = na(n+1,1e20)
  dist[start] = 0
  dc = 0
  used = na(n+1,false)
  while dc < n
    i = nil
    min = 1e20
    (1..n).each do |j|
      next if used[j]
      if dist[j] <= min
        i = j
        min = dist[j]
      end
    end
    used[i] = true
    path[i].each do |nex,path_dist|
      next if used[nex]
      dist[nex] = [dist[nex],dist[i]+path_dist].min
    end
    dc += 1
  end
  @rt.push(copy(dist))
end
@size.times do |i|
  used = na(@size,false)
  used[i] = true
  ser(0,0,i,used)
  used[i] = false
end
p @ans
=begin

=end

Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int exp(int x){
   int ans = 1;
   rep(i,0,5) ans*=x;
   return ans;
}

signed main(){
   IOS;
   int x; cin >> x;
   rep(i,1,201){
      for(int j = -i;j<=i;j++){
         if(exp(i)-exp(j) == x){
            cout << i << " " << j << "\n";
            return 0;
         }
      }
   }  
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 

int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}

int32_t main()
{
	fast;
	int x;
	cin>>x;
	vector<int> v(x+1, 0);
	if(x<105)
	{
		if(x<100)
			cout<<0<<endl;
		else
			cout<<1<<endl;
		return 0;
	}
	v[100]=1;
	v[101]=1;
	v[102]=1;
	v[103]=1;
	v[104]=1;
	v[105]=1;
	for(int i=106;i<=x;i++)
	{
		for(int j=100;j<106;j++)
		{
			if(v[i-j]==1)
			{
				v[i]=1;
				break;
			}
		}
	}
	cout<<v[x]<<endl;
	return 0;
}

Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
long a,b;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",strout);
	b=2,cin>>a;
	for(int i=1;i<=a;i++)
	{
		b=(b+1)*2;
	}
	cout<<b<<"\n";

	return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
k -= n*(n-1)//2 - (n-1)
if k > 0:
  print(-1)
  exit()
else:
  i = 2
  j = 3
  tl = [(1,f) for f in range(2,n+1)]
  for _ in range(-k):
    tl.append((i,j))
    j += 1
    if j > n:
      i += 1
      j = i+1
print(len(tl))
for x,y in tl:
  print(x,y)

Measured memory_bytes: 3992
#include <vector>
#include <cstdio>

using namespace std;

int main(){
    vector<vector<int>> v;
    int n, q, c, t, x;
    scanf("%d %d", &n, &q);
    for(int i = 0; i<n; i++){
        v.push_back(vector<int>());
    }
    for(int i = 0; i < q; i++){
        scanf("%d %d", &c, &t);
        if(c == 0){
            scanf("%d", &x);
            v.at(t).push_back(x);
        }else if(c == 1){
            for(auto itr = v.at(t).begin(); itr != v.at(t).end(); itr++){
                if(itr != v.at(t).begin()){
                    printf(" ");
                }
                printf("%d", *itr);
            }
            printf("\n");
        }else{
            v.at(t).clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5420
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,k;cin>>n>>k;
  ll ans;
  ans=1+(n-k)/(k-1)+((n-k)%(k-1)?1:0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define vi vector
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int len(int m) {
	int length = 0;
	while (m > 0) {
		m /= 10;
		length++;
	}
	return length;
}

int M = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	int k; cin >> k;
	vector<int>num(10);
	rep(i, k) {
		int a;
		cin >> a;
		num[a]++;
	}
	deque<int>base;
	rep(i, 10) {
		if (num[i] == 0) {
			base.push_back(i);
		}
	}
	int m = n;
	int size = len(n);
	while (1) {
		int tmp = m;
		int count = 0;
		while (tmp >0) {
			rep(i, base.size()) {
				if (tmp % 10 == base[i]) {
					count++;
					i = base.size();
				}
			}
			tmp /= 10;
		}
		if (count==len(m)) {
			break;
		}
		m++;
	}
	cout << m << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[10][10];
bool flag[10][10];
bool flag2[10][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<double>x(n), y(n), a(n);
	ll res = 1;
	rep(i, n) {
		cin >> x[i] >> y[i];
		a[i] = i;
		res *= (i + 1);
	}
	double total = 0;
	ll res2 = 0;
	do {
		res2++;
		rep(i, n - 1) {
			total += sqrt(pow(x[a[i]] - x[a[i + 1]], 2) + pow(y[a[i]] - y[a[i + 1]], 2));
		}
	} while (next_permutation(a.begin(), a.end()));
	total /= res;
	exout(total);
	return 0;
}

Measured memory_bytes: 3692
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    ll a;
    int b, c;
    char _;

    cin >> a >> b >> _ >> c;
	
    cout << a*(100*b+c)/100 << endl;
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3652
# include <bits/stdc++.h>
using namespace std;
const int N = 3005, mod = 1e9 + 7;
int n, ans, dp[N][N], sum[N];
string s;
int add(int a, int b){
    if((a += b) >= mod)a -= mod; 
    return a;
}
int f(int l, int r){
    return add(sum[r], mod - sum[l - 1]);
}
int main(){
    cin >> n >> s;s = '#' + s;
    dp[1][1] = 1; sum[1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= i; j++){
            if(s[i - 1] == '<'){
                dp[i][j] = add(dp[i][j], f(1, j - 1));
            }else{
                dp[i][j] = add(dp[i][j], f(j, i - 1)); 
            }
        }
        sum[0] = 0;
        for(int j = 1; j <= i; j++){
            sum[j] = add(sum[j - 1], dp[i][j]);
        }
    }
    for(int i = 1; i <= n; i++){
        ans = add(ans, dp[n][i]);
    }
    cout << ans << endl;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> data(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> data.at(i).at(j);
    }
  }
  vector<int> dx={-1,0,1,0};
  vector<int> dy={0,1,0,-1};
  bool jd = true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(data.at(i).at(j)=='#'){
        bool found=false;
        for(int k=0;k<4;k++){
          int x=i+dx.at(k);
          int y=j+dy.at(k);
          if(x>=0&&x<h&&y>=0&&y<w&&data.at(x).at(y)=='#'){found=true;}
        }
        if(!found){jd=false;}
      }
    }
  }
  if(jd){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

void newremain(int num, int keta, int mod, vector<int> &remain, vector<int> &nr){
  for (int i=0; i<13; i++){
    nr.at((i+num*keta)%13)=nr.at((i+num*keta)%13)%mod+remain.at(i)%mod;
  }
}

int main(){
  string s;
  cin>> s;
  int mod=pow(10,9)+7;
  
  vector<int> remain(13);
  remain.at(0)=1;
  int keta=1;
  for (int i=s.size()-1; i>=0; i--){
    vector<int> nr(13);
    if (s.at(i)=='?'){
      for (int j=0; j<10; j++){
        newremain(j,keta,mod,remain,nr);
      }
    }
    else{
      newremain((int)s.at(i)-48,keta,mod,remain,nr);
    } //一桁の数字は (int)char-48 でOK
    remain=nr;
    keta=(keta*10)%13;
  }
  cout<< remain.at(5)%mod <<endl;
}

Measured memory_bytes: 512
import itertools
N,M = [int(i) for i in input().split(' ')]

x = []

for i in range(N):
    x.append([int(i) for i in input().split(' ')])
tab = [0]*N
ans = 0
#p = list(itertools.permutations(x,M));
for S in [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]:
    for j in range(N):
        a = 0
        a += x[j][0]*S[0]
        a += x[j][1]*S[1]
        a += x[j][2]*S[2]
        tab[j] = a
    tab.sort()
#    print(tab)
    a =0
    for j in range(M):
        a += tab[N-j-1]
 #   print(a)
    if a > ans:
        ans = a

#print(p)
print(ans)
   


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main()
{
	int n;
	int arr[21];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int ans = 0;
	for (int i = 1; i < n - 1; i++)
	{
		int check = 0;
		if (arr[i] > arr[i - 1])
			check++;
		if (arr[i] > arr[i + 1])
			check++;
		if (check == 1)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
struct po{int lx,ly,rx,ry;};
int w,h;
string mp[2][51];
bool visited[51][51][51][51];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

bool bfs(int lx,int ly,int rx,int ry){
  queue <po> Q;
  Q.push((po){lx,ly,rx,ry});
  while(!Q.empty()){
    po t=Q.front();Q.pop();
    int cnt=(mp[0][t.ly][t.lx]=='%')+(mp[1][t.ry][t.rx]=='%');
    if(cnt==2)return true;
    if(visited[t.lx][t.ly][t.rx][t.ry]||cnt==1)continue;
    visited[t.lx][t.ly][t.rx][t.ry]=1;
    for(int i=0;i<4;i++){
      int flg=0;
      int nlx=t.lx+dx[i],nly=t.ly+dy[i];
      int nrx=t.rx-dx[i],nry=t.ry+dy[i];
      if(nlx<0||nly<0||nlx>=w||nly>=h||mp[0][nly][nlx]=='#')nlx=t.lx,nly=t.ly,flg++;
      if(nrx<0||nry<0||nrx>=w||nry>=h||mp[1][nry][nrx]=='#')nrx=t.rx,nry=t.ry,flg++;
      if(flg==2||visited[nlx][nly][nrx][nry])continue;
      Q.push((po){nlx,nly,nrx,nry});
    }
  }
  return false;
}

int main(){
  while(1){
    cin >>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++)cin>>mp[0][i]>>mp[1][i];
    int lx,ly,rx,ry;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	if(mp[0][i][j]=='L')lx=j,ly=i;
	if(mp[1][i][j]=='R')rx=j,ry=i;
      }

    memset(visited,0,sizeof(visited));
    if(bfs(lx,ly,rx,ry))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 9592