akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

static class Program
{
    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    static Dictionary<int, int> Factorize(int n)
    {
        var primes = new Dictionary<int, int>();
        for (int i = 2; i * i <= n; ++i)
        {
            while (n % i == 0)
            {
                if (!primes.ContainsKey(i)) { primes[i] = 0; }
                ++primes[i];
                n /= i;
            }
        }
        if (n > 1)
        {
            if (!primes.ContainsKey(n)) { primes[n] = 0; }
            ++primes[n];
        }
        return primes;
    }

    static void Gcd(Dictionary<int, int> primes, int n)
    {
        for (int i = 0; i < primes.Count; ++i)
        {
            var pair = primes.ElementAt(i);
            for (int j = 0; j < pair.Value; ++j)
            {
                if (n % pair.Key != 0)
                {
                    primes[pair.Key] = j;
                    break;
                }
                n /= pair.Key;
            }
        }
    }

    static bool Solve(int K, int[] A)
    {
        if (K > A.Max()) { return false; }
        var primes = Factorize(A[0]);
        for (int i = 1; i < A.Length; ++i)
        {
            Gcd(primes, A[i]);
        }
        foreach (var pair in primes)
        {
            for (int i = 0; i < pair.Value; ++i)
            {
                if (K % pair.Key != 0) { return false; }
                K /= pair.Key;
            }
        }
        return true;
    }

    static void Main(string[] args)
    {
        int[] values = ReadInts();
        Console.WriteLine(Solve(values[1], ReadInts()) ? "POSSIBLE" : "IMPOSSIBLE");
    }
}


Measured memory_bytes: 28884
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin(){ll x;scanf("%lld",&x);return x;}

int main(){
    int n=in(),m=in();
    vector<vec> a(n,vec(n)),b(m,vec(m));
    rep(i,n){
        string s=stin();
        rep(j,n)a[i][j]=s.at(j)=='#'?1:0;
    }
    rep(i,m){
        string s=stin();
        rep(j,m)b[i][j]=s.at(j)=='#'?1:0;
    }
    rep(p,n-m+1)rep(q,n-m+1){
        bool c=true;
        rep(i,m)rep(j,m)if(a[i+p][j+q]!=b[i][j])c=false;
        if(c){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  while(true){
  	if(n <= 9)break;
  	n %= 10;
  }
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon" << endl;  	
  else if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
  else cout << "bon" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> A(2 * n - 1);
    for (int i = 0; i < SZ(A); ++i) {
        cin >> A[i];
    }

    int ans = 1;
    for (int step = 1 << 18; step > 0; step /= 2) {
        int val = ans + step;
        vector<int> B(SZ(A));
        for (int i = 0; i < SZ(A); ++i) {
            B[i] = (int) (A[i] > val);
        }
        int xa;
        if (B[n] == B[n - 1] || B[n - 1] == B[n - 2]) {
            xa = B[n - 1];
        } else {
            int left = n - 1, right = n - 1;
            while (left > 0 && B[left] != B[left - 1]) {
                --left;
            }
            while (right < SZ(A) - 1 && B[right] != B[right + 1]) {
                ++right;
            }
            if ((left == 0 && right == n - 1)) {
                xa = B[n - 1] ^ (n & 1);
            } else if (n - 1 - left < right - (n - 1)) {
                xa = B[left];
            } else {
                xa = B[right];
            }
        }
        if (xa) {
            ans += step;
        }
    }
    ans++;
    cout << ans << '\n';
}

Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a>b)
    {
        for(int i=0;i<a;i++) cout<<b;
    }
    else
    {
        for(int i=0;i<b;i++) cout<<a;
    }

}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int ans=0;string s;
signed main(){
	cin>>s;int cnt=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R')cnt++;
		if(s[i]=='S'){
			ans=max(ans,cnt);cnt=0;
		}
	}
	ans=max(ans,cnt);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
from collections import Counter


def read():
    S = list(input())
    return S,


class ModInt(int):
    
    MOD = 10**9+7

    def __new__(cls, x, *args, **kwargs):
        return super().__new__(cls, x % ModInt.MOD)

    def __add__(self, other):
        return ModInt(super().__add__(other) % ModInt.MOD)

    def __radd__(self, other):
        return ModInt(super().__radd__(other) % ModInt.MOD)

    def __mul__(self, other):
        return ModInt(super().__mul__(other) % ModInt.MOD)

    def __rmul__(self, other):
        return ModInt(super().__rmul__(other) % ModInt.MOD)

    def __pow__(self, other, *args):
        return ModInt(super().__pow__(other, ModInt.MOD))

    def __rpow__(self, other, *args):
        raise NotImplementedError()

    def __truediv__(self, other):
        raise NotImplementedError()

    def __floordiv__(self, other):
        raise NotImplementedError()

    def __rtruediv__(self, other):
        raise NotImplementedError()

    def __rfloordiv__(self, other):
        raise NotImplementedError()


def solve(S, MOD=2019):
    N = len(S)
    S = list(reversed(S))
    T = [ModInt(0) for i in range(N+1)]
    ModInt.MOD = 2019
    
    mul = ModInt(1)
    for i in range(N):
        T[i+1] = T[i] + int(S[i]) * mul
        mul *= 10
    
    # T[i] == T[j] (mod 2019) となる(i, j)の組を列挙
    # <=> 0<=T[i]<2019 より、T[i]の出現数を計数すれば求められる
    # nC2 = (n * n-1) // 2
    ans = 0
    for k, v in Counter(T).most_common():
        iv = int(v)
        if iv >= 2:
            ans += v * (v-1) // 2
    return ans

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 26916
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 100000000000000;
const double PI = acos(-1);

bool negative[2010];
struct edge { LL from, to, cost; };
edge es[100000];

LL d[100000];
int V, E;
bool shortest_path(int s, int t) { // t: destination
	for (int i = 0; i <= V+1;i++) d[i] = INF;
	d[s] = 0;
	for (int i = 0; i < 2 * V;i++) {
		for (int j = 0; j < E;j++ ) {
			edge e = es[j];
			if (d[e.from] != INF && d[e.to]>d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;

				if (i >= V - 1 && e.to == t) return true;
			}
		}
	}
	return false;
}
int main() {
	cin >> V >> E;
	LL a[2010], b[2010], c[2010];
	for (int i = 0; i < E; i++) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i];
		es[i] = { a[i],b[i],c[i] };
	}
	if (shortest_path(1, V)) {
		cout << "inf" << endl;
	}
	else {
		cout << -d[V] << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
    string a = "keyence";
    string b;
    cin>>b;
   	string temp = b;
    for(ll i=0;i<b.size();i++)
    {
    	for(ll j=0;j<b.size()-i;j++)
    	{
    		b.erase(i,j);
    		if(b==a)  return cout<<"YES",0;
    		b = temp;
    	} 
    }
    cout<<"NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  long int N;
  cin >> N;
  vector<long int> A(N);

  int i;
  for(i=0; i<N; i++)
    cin >> A[i];

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

  for(i=0; i<N-1; i++)
    if(A[i] == A[i+1]){
      cout << "NO" << endl;
      return 0;
    }

  cout << "YES" << endl;
    
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void to_unique(vector<int> &v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}

int n;
void solve() {
	cin >> n;
	vector<P> v(n);
	vector<char> d(n);
	rep(i, n) {
		cin >> v[i].first >> v[i].second >> d[i];
	}
	vector<int> vx, vy;
	{
		rep(i, n) {
			vx.push_back(v[i].first);
			vy.push_back(v[i].second);
		}
		to_unique(vx), to_unique(vy);
		map<int, int> mx, my;
		rep(i, vx.size()) {
			mx[vx[i]] = i;
		}
		rep(i, vy.size()) {
			my[vy[i]] = i;
		}
		rep(i, n) {
			v[i].first = mx[v[i].first];
			v[i].second = my[v[i].second];
		}
	}
	map<P, int> mp;
	rep(i, n) {
		mp[v[i]] = i;
	}
	vector<set<int>> stx(vx.size()),sty(vy.size());
	rep(i, n) {
		stx[v[i].first].insert(v[i].second);
		sty[v[i].second].insert(v[i].first);
	}
	int ans = 0;
	rep(i, n) {
		vector<set<int>> sx = stx, sy = sty;
		int cx = v[i].first, cy = v[i].second;
		int cnt = 0;
		while (true) {
			cnt++;
			sx[cx].erase(cy);
			sy[cy].erase(cx);
			int id = mp[{cx, cy}];
			if (d[id] == '>') {
				sy[cy].insert(cx);
				auto itr = sy[cy].find(cx);
				itr++;
				if (itr == sy[cy].end())break;
				int nx = *itr;
				sy[cy].erase(cx);
				cx = nx;
			}
			else if (d[id] == '<') {
				sy[cy].insert(cx);
				auto itr = sy[cy].find(cx);
				if (itr == sy[cy].begin())break;
				itr--;
				int nx = *itr;
				sy[cy].erase(cx);
				cx = nx;
			}
			else if (d[id] == 'v') {
				sx[cx].insert(cy);
				auto itr = sx[cx].find(cy);
				itr++;
				if (itr == sx[cx].end())break;
				int ny = *itr;
				sx[cx].erase(cy);
				cy = ny;
			}
			else {
				sx[cx].insert(cy);
				auto itr = sx[cx].find(cy);
				if (itr == sx[cx].begin())break;
				itr--;
				int ny = *itr;
				sx[cx].erase(cy);
				cy = ny;
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	/*while (cin >> n>>m>>l, n) {
		solve();
	}*/
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 4140
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(n):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)

Measured memory_bytes: 4596
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    vector<ll> S(N+1);
    S[0]=0;
    map<ll,vector<ll>> mp;
    mp[0].push_back(0);
    ll tmp;
    REP(i,N){
        S[i+1]=S[i]+A[i];
        tmp=(S[i+1]-(i+1))%K;
        if(tmp<0) tmp+=K;
        mp[tmp].push_back(i+1);
    }
    ll ans=0;
    ll num;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        vector<ll> t=itr->second;
        REP(i,t.size()){
            ll n =lower_bound(t.begin(),t.end(),t[i]+K)-upper_bound(t.begin(),t.end(),t[i]);
            ans+=n;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 110;
int G[maxn][maxn];


int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        memset(G,0,sizeof(G));
        FOR(i,2,n+1)
            G[1][i] = 1;
        int cnt = (n-1)*(n-2)/2;
        if (cnt < k)
            cout << -1 << endl;
        else {
            for (int i = 2; cnt > k && i <= n; i++) {
                for (int j = i+1; cnt > k && j <= n; j++) {
                    cnt--;
                    G[i][j] = 1;
                }
            }
            if (cnt > k)
                cout << -1 << endl;
            else {
                int m = 0;
                FOR(i,1,n+1) FOR(j,1,n+1) if (G[i][j])
                    m++;
                cout << m << endl;
                FOR(i,1,n+1) FOR(j,1,n+1) if (G[i][j])
                    cout << i << ' ' << j << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/ruby

until (n = gets.to_i).zero?
  data = {}
  data.default = 0

  n.times do
    input = gets.split.map(&:to_i)

    data[input[0]] += input[1] * input[2]
  end

  keys = data.select{|k, v| v >= 1000000 }.keys.join(?\n)

  if keys.empty?
    puts "NA"
  else
    puts keys
  end
end

Measured memory_bytes: 6112
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Knight
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

int frac(int n) {
  int f = 1;
  for (int i = 1; i <= n; i++) f = (ll)f * i % MOD;
  return f;
}

int nck(int n, int k) {
  return
    (ll)frac(n) * powmod(frac(k), MOD - 2) % MOD *
    powmod(frac(n - k), MOD - 2) % MOD;
}

/* main */

/*
  |2 1||a|=|x|
  |1 2||b| |y|
  |2 1|^-1 = | 2 -1|
  |1 2|      |-1  2|/3
 */

int main() {
  int x, y;
  scanf("%d%d", &x, &y);

  int a3 = 2 * x - y;
  int b3 = 2 * y - x;

  if (a3 < 0 || b3 < 0 || a3 % 3 != 0 || b3 %3 != 0) {
    puts("0");
    return 0;
  }

  int a = a3 / 3, b = b3 / 3;
  //printf("a=%d, b=%d\n", a, b);

  printf("%d\n", nck(a + b, a));
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int price = 0;
    if(a + b > 2*c){
      int min = Math.min(x,y);
      price = 2*c * min;
      if(x >= y && 2*c < a){
        price += 2*c*(x-y);
      }
      else if(x < y && 2*c < b){
        price += 2*c*(y-x);
      }
      else{
        if(x > y){
          price += a*(x-y);
        }
        else{
          price += b*(y-x);
        }
      }
    }
    else{
      price = (a*x)+(b*y);
    }
    System.out.println(price);
  }
}

Measured memory_bytes: 21588
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int a,b;
	cin>>a>>b;
	int ma;
	int maa;
	ma = max((a+b),(a-b));
	maa = max( ma, (a*b) );
	cout<<maa<<endl;
}

Measured memory_bytes: 3644
a,b,c=map(int,input().split())
if a==b==c and a%2==0 and b%2==0 and c%2==0:
    print(-1)
else:
    p=0
    while a%2==0 and b%2==0 and c%2==0:
        aa=(b+c)//2
        bb=(c+a)//2
        cc=(b+c)//2
        a,b,c=aa,bb,cc
        p+=1
    print(p)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

string solve(string s, int depth, int& k) {
	if(depth == 0 && k > 1) {
		k--;
		return "";
	}
	else if(depth == 0 && k == 1) {
		return s;
	}
	int x = s[s.size()-1] - '0';
	for(int i = -1; i <= 1; i++) {
		if(x + i >= 0 && x + i <= 9) {
			string t = solve(s + to_string(x + i), depth - 1, k);
			if(t != "") return t;
		}
	}
	return "";
}

int main() {
//	cout << fixed << setprecision(15);
	int k;
	cin >> k;
	rep(i, 11) rep1(j, 9) {
//		if(i == 0 && j == 0) continue;
		string s = solve(to_string(j), i, k);
		if(s != "") {
			cout << s << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool f=1;
  int tmp=0;
  for(auto itr=s.begin();itr !=s.end();itr++)
  {
    if(*itr=='F'){tmp++;}
    else {
      if(f){a.push_back(tmp);}
      else{b.push_back(tmp);}
      f=!f;
    tmp=0;
  }

  }
  if(f){a.push_back(tmp);}
  else{b.push_back(tmp);}
  x-=a[0];
  x=abs(x);
  y=abs(y);
  a.erase(a.begin());
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int suma=0,sumb=0;
  for(auto itr=a.begin();itr !=a.end();itr++)
  {
    //cout<<*itr<<endl;
    suma+=*itr;
  }
  for(auto itr=b.begin();itr !=b.end();itr++)
  {
    sumb+=*itr;
    //cout<<*itr<<endl;
  }
  int flag=0;
  //cout<<x<<' '<<y<<' '<<suma<<' '<<sumb;
  if((suma-x)%2 or (sumb-y)%2){flag=0;}
  else
  {
    if(suma<x or sumb<y){flag=-2;}
    x=(suma-x)/2;
    y=(sumb-y)/2;
    //cout<<x<<' '<<y;
    vector<int> dpx(24001),dpy(24001);
    for(int i=0;i<24001;i++){dpx[i]=0;dpy[i]=0;}
    dpx[0]=1;dpx[suma]=1;
    dpy[0]=1;dpy[sumb]=1;
    for(auto itr1=a.begin();itr1 !=a.end();itr1++)
    {
      if(dpx[x]!=0 or dpx[suma-x]!=0){flag+=1;break;}
      for(int i=16000;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr1]=1;}
      }
      if(dpx[x]!=0 or dpx[suma-x]!=0){flag+=1;break;}

    }
    if(a.size()==0 and x==0){flag+=1;}
    //cout<<flag<<endl;
    for(auto itr2=b.begin();itr2 !=b.end();itr2++)
    {
      if(dpy[y]!=0 or dpy[sumb-y]!=0){flag+=1;break;}
      for(int i=16000;i>-1;i--)
      {
        if(dpy[i]==1){dpy[i+*itr2]=1;}
      }
      if(dpy[y]!=0 or dpy[sumb-y]!=0){flag+=1;break;}
    }
    if(b.size()==0 and x==0){flag+=1;}
  }
  cout<<yn(flag>=2)<<endl;




  return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
void print(vector <pii> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i].first<<" "<<X[i].second<<endl;
    }
    return;
}
 


 ll gcd(ll x, ll y) {
	 //cout<<x<<" "<<y<<endl;
	 if (y==0 || y==x) {return x;}
	 if (x==0) {return y;}
	 if (y>x) {ll r=x; x=y; y=r;}
	 return gcd(y,x%y);
	 }
	 
	 
int sigma (pll u) {
	if (u.first>0 && u.second>0) {return 1;}
	if (u.first<0 && u.second<0) {return 1;}
	return -1;
	}
 
 ll laip(ll a, ll b, ll liek) {
	 if (b==0) {return 1;}
	 a=a%liek;
	 if (b==1) {return a;}
	 ll x=laip((a*a)%liek,b/2,liek);
	 if (b%2==0) {return x;}
	 return (a*x)%liek;
	 }
 
 ll solve(vector <pii> &X, ll liek) {
	 ll ats=1;
	 for (int i=0;i<(int)X.size();i++) {
	 pii u=X[i];
	 ll v;
	 if (u.first==0) {v=laip(2,u.second,liek);}
	 if (u.second==0) {v=laip(2,u.first,liek);}
	 if (u.first>0 && u.second>0) {
	 v=laip(2,u.second,liek)+laip(2,u.first,liek)-1;}
	 v=(v+liek)%liek;
	 ats=ats*v;
	 ats=ats%liek;}
	 return ats;
	 }
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int w=0;
    vector <pll> A;
    for (int i=0;i<n;i++) {
		ll a,b;
		cin>>a>>b;
		if (a!=0 || b!=0) {
		ll x=gcd(abs(a),abs(b));
		if (b<0) {a=-a; b=-b;}
		A.push_back({a/x,b/x});}
		else {w++;}
		}
	map <pll,pii> M;
	for (int i=0;i<(int)A.size();i++) {
		pll u=A[i];
		if (u.first!=0 && u.second!=0) {
			int a=sigma(u);
			if (a==1) {
				//cout<<"Pirmas "<<u.first<<" "<<u.second<<endl;
				if (M.find(u)!=M.end()) {M[u].first++;}
				else {M[u]={1,0};}
				}
			else {
				pll v={abs(u.second),abs(u.first)};
				//cout<<"Antras "<<v.first<<" "<<v.second<<endl;
				if (M.find(v)!=M.end()) {M[v].second++;}
				else {M[v]={0,1};}
				}
			}
		else {
				pll s={0,0};
			if (u.first==0) {
				if (M.find(s)!=M.end()) {
				M[s].first++;}
				else {M[s]={1,0};}
				}
			else {
				if (M.find(s)!=M.end()) {
				M[s].second++;}
				else {M[s]={0,1};}
				}
			}
		}
	vector <pii> X;
	for (auto f:M) {
		X.push_back(f.second);
		}
	//print(X);
	ll liek=1000000007;
	ll ats=(solve(X,liek)-1+liek+w)%liek;
	cout<<ats<<endl;
    return 0;
}


Measured memory_bytes: 22396
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            if(a * b > c * d){
              System.out.println(a * b);
            } else {
              System.out.println(c * d);
            }
            
          }
}

Measured memory_bytes: 22996
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define all(v) v.begin(),v.end()
#define fio() ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define fornn(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define MAXN 100005LL
#define INF LONG_MAX
#define MOD 1e9+7LL
ll calc(vector<ll> dp[],ll ww[],ll vv[],ll i,ll j){
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	if(j-ww[i]<0){
		dp[i][j]=calc(dp,ww,vv,i-1,j);
		return dp[i][j];
	}
	dp[i][j]=max(vv[i]+calc(dp,ww,vv,i-1,j-ww[i]),calc(dp,ww,vv,i-1,j));
	return dp[i][j];
}
inline void solve(){
	ll n,totw;
	cin>>n>>totw;
	ll ww[n],vv[n];
	for(ll i=0;i<n;i++)
		cin>>ww[i]>>vv[i];
	vector<ll> dp[n];
	for(ll i=0;i<n;i++){
		dp[i].assign(totw+1LL,-1LL);
	}
	for(ll j=0;j<=totw;j++){
		if(j>=ww[0])
			dp[0][j]=vv[0];
		else
			dp[0][j]=0;
	}
	cout<<calc(dp,ww,vv,n-1,totw)<<endl;
}
int main(){
	fio();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 81544
#include <stdio.h>

int main()
{
  int A,B,i;
  int S[3] = {1,2,3};
  scanf("%d %d",&A,&B);
  while (i < 3)
  {
    if (S[i] != A && S[i] != B)
    {
      printf("%d",S[i]);
    }
    i++;
  }
}

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

int main(void){
    
    int n=0;
    string s;
    cin >> s;
    
    for(int i=0;i<3;i++){
        if(s[i] == 'o') n++;
    }
    
    cout << 700 + n * 100 <<endl;
}

Measured memory_bytes: 3560
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        k = n-i-j
        if 10000*i + 5000*j + 1000*k == y:
            print(i, j, k)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = list(mapint())
Q = []
from heapq import heappop, heappush
for a in As:
    heappush(Q, -a)
for i in range(M):
    v = heappop(Q)
    heappush(Q, v/2)
lis = [-int(x) for x in Q]
print(sum(lis))

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

namespace ConsoleApp31 {
    class Program {
        static void Main(string[] args) {
            var st1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = st1[0];
            int b = st1[1];
            int c = st1[2];

            var st2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int d = st2[0];
            int e = st2[1];
            int f = st2[2];

            var st3 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int g = st3[0];
            int h = st3[1];
            int i = st3[2];

            int diff1 = d - a;
            int diff2 = e - b;
            int diff3 = f - c;
            int diff4 = g - d;
            int diff5 = h - e;
            int diff6 = i - f;

            if (diff1 == diff2 && diff2 == diff3 && diff4 == diff5 && diff5 == diff6) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }


        }
    }
}


Measured memory_bytes: 13396
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

mind = float('inf')
minn = 0
for i in range(len(h)):
    avg = t - h[i] * 0.006
    div = abs(a - avg)
    if div < mind:
        mind = div
        minn = i + 1

print(minn)


Measured memory_bytes: 3060
//
// Created by hqnddw on 2019/4/28.
//
#include <stdio.h>

#define MAX 100000

int A[MAX], n1;

int partition(int p, int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; ++j) {
        if (A[j] <= x) {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}

int main() {
    int q;
    scanf("%d", &n1);
    for (int i = 0; i < n1; i++) {
        scanf("%d", &A[i]);
    }
    q = partition(0, n1 - 1);
    for (int j = 0; j < n1; ++j) {
        if (j) printf(" ");
        if (j == q) printf("[");
        printf("%d", A[j]);
        if (j == q) printf("]");
    }
    printf("\n");
    return 0;
}




Measured memory_bytes: 2972
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> dp(2*N, 1<<30);
    for(int i=0; i<=N; i++) dp[i] = i;
 
    vector<int> v;
 
    int a = 6;
    for(int i=0; i<100; i++){
        if(a > N) break;
        v.push_back(a);
        a *= 6;
    }
    a = 9;
    for(int i=0; i<100; i++){
        if(a > N) break;
        v.push_back(a);
        a *= 9;
    }
    for(int x : v){
        for(int i=0; i<N; i++){
            if(dp[i] == 1<<30)
                continue;
            dp[i+x] = min(dp[i+x], dp[i] + 1);
        }
    }
 
    cout << dp[N] << endl;
 return 0;
}

Measured memory_bytes: 1024
#[doc = " Ported from [bluss/permutohedron](https://github.com/bluss/permutohedron)"]
pub trait LexicalPermutation {
#[doc = " Return \'true\' if the slice was permuted, \'false\' if it is already "]
#[doc = " at the last ordered permutation."]
    fn next_permutation(&mut self) -> bool;
#[doc = " Return \'true\' if the slice was permuted, \'false\' if it is already "]
#[doc = " at the first ordered permutation."]
    fn prev_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
#[doc = " Original author in Rust: Thomas Backman <serenity@exscape.org>"]
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }
#[doc = " Original author in Rust: Thomas Backman <serenity@exscape.org>"]
    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}

fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) = {
        let nums = get_line().split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect::<Vec<usize>>();
        (nums[0], nums[1])
    };

    let mut edges: Vec<Vec<usize>> = Vec::new();
    for _ in 0..m {
        let ab = get_line().split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect::<Vec<usize>>();
        edges.push(ab);
    }

    let mut order = (1..n+1).collect::<Vec<usize>>();
    let mut count = 0;

    loop {
        let mut ok = true;
        for i in 0..n-1 {
            let mut v = vec![order[i], order[i + 1]];
            v.sort();
            if !edges.contains(&v) { ok = false; }
        }
        if ok && order[0] == 1 { count += 1; }
        if !order.next_permutation() { break; }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
n,m = gets.chomp.split.map(&:to_i)

add = [[],[],[],[],[],[],[],[]]
n.times do |i|
  x,y,z = gets.chomp.split.map(&:to_i)
  8.times do |j|
    add[j][i] = x*(1-2*(j&4)/4) + y*(1-2*(j&2)/2) + z*(1-2*(j&1))
  end
end

if m==0
  printf("%d\n",0)
  exit
end

max = 0
add.each do |a|
  sum = a.sort.reverse[0,m].reduce(&:+).to_i
  max = sum if max < sum
end

printf("%d\n",max)

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

bool isP(string s){
    string k = s;
    reverse(s.begin(), s.end());
    if(k==s)return true;
    else return false;
}


int main(){
    string s, s1, s2;
    cin >> s;
    int n = s.size(), a, b;
    a = (n-1)/2, b = (n+3)/2;
    s1 = s.substr(0, a), s2 = s.substr(b-1, n);
    if(isP(s) && isP(s1) && isP(s2))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

class UnionFindTrees{
	public:
		UnionFindTrees(int _n){
			n = _n;
			root = vector<int>(_n);
			tree_size = vector<int>(_n,1);
			rep(i,_n) root[i] = i;
		}
		int find(int x){
			if(root[x]==x) return x;
			else return root[x]=find(root[x]);			
		}
		bool same(int x, int y){
			return find(x)==find(y);
		}
		void merge(int x, int y){
			if(same(x,y)) return;
			x = find(x);
			y = find(y);
			if(tree_size[x]<tree_size[y]) swap(x,y);			
			root[y] = x;
			tree_size[x] += tree_size[y];
			n--;			
		}
		int get_tree_size(int x){
			return tree_size[find(x)];
		}
		int get_forest_size(){return n;}
	private:
		vector<int> root;
		vector<int> tree_size;
		int n;

};
int main(void) {
	int n,m,k; cin >> n >> m >> k;
	UnionFindTrees uft(n);
	vi friends(n,0);
	rep(i,m){
		int a,b; cin >> a >> b;
		a--; b--;
		uft.merge(a,b);
		friends[a]++;
		friends[b]++;
	}
	vi blocks(n,0);
	rep(i,k){
		int c,d; cin >> c >> d;
		c--; d--;
		if(uft.same(c,d)){
			blocks[c]++;
			blocks[d]++;
		}
	}
	vi ans(n);
	rep(i,n){
		ans[i] = uft.get_tree_size(i)-1;
		ans[i] -= friends[i];
		ans[i] -= blocks[i];
	}
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
}




Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int>kore={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 int k;
  cin>>k;
 cout<<kore.at(k-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007


int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int a, b; cin >> a>> b;
        cout << max(a + b, max(a * b, a - b));
return 0;
}


Measured memory_bytes: 256
num_p = int(input())
pre_height = 1
step_sum = 0
li= input().split()
for i in range(num_p):
    height = int(li[i])
    if height > pre_height:
        step_sum += 0
        pre_height = height
    else:
        step_sum += pre_height - height
        pre_height += 0
        
print(step_sum)

Measured memory_bytes: 93952
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.next());
		int Z = Integer.parseInt(in.next());
		int W = Integer.parseInt(in.next());
		int x = Z;
		int y = W;
		int[] a = new int[N];
		for (int i = 0; i < N; i++){
			a[i] = Integer.parseInt(in.next());
		}
		if(2<N){
			x = a[N-2];
			y = a[N-1];
		}else {
			x = a[N-1];
		}
		if(Math.abs(x-y)>Math.abs(y-W))System.out.println(Math.abs(x-y));
		else System.out.println(Math.abs(y-W));
	}
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = 3.141592653589;
double ans;

int main(){
  double a, b, c;
  string s, t;
  cin >> a;
  printf("%10lf\n", a * 2 * PI);
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define v vector
#define mp make_pair
typedef long long ll;
typedef pair<int, int > pii;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }
// C

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	double win[100009];
	int n, k;
	cin >> n >> k;
	win[0] = 0;
	win[k] = 1;
	RFORE(i,k-1,1){
		win[i] = 0.5*win[min(k, 2*i)];
	}
	double ans = 0;
	FORE(i,1,n){
		ans += 1.0/n*win[min(k,i)];
	}
	cout << fixed << setprecision(9) << ans << "\n";
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		x--;
		a[x]=i;
	}
	ll now=a[0];
	ll cnt=1;
	ll ans=0;
	for(int i=1;i<n;i++){
		ll next=a[i];
		//cout << now << " "<<next<<endl;
		if(now<next){
			cnt++;
			now=next;
		}
		else{
			now=next;
			ans=max(cnt,ans);
			cnt=1;
		}
	}
	//cout << ans;
	ans=max(cnt,ans);
	cout << n-ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
from collections import deque


k = int(input())
q = deque(range(1, 10))

for i in range(k):
    x = q.popleft()
    if x % 10 != 0:
        q.append(10 * x + x % 10 - 1)
    q.append(10 * x + x % 10)
    if x % 10 != 9:
        q.append(10 * x + x % 10 + 1)

print(x)

Measured memory_bytes: 11908
import sys
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key= lambda x:x[1])
time = 0
for i in ab:
    time += i[0]
    if time <= i[1]:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 53600
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef struct stu
{
    string a;
    int score;
    int id;
}stu;
stu p[12500];
bool cmp1(stu x,stu y)
{
    if(x.a!=y.a)
        return x.a<y.a;
    else
        return x.score>y.score;

}

int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        {
        cin>>p[i].a;
        cin>>p[i].score;
        p[i].id=i;
        }
        sort(p+1,p+1+n,cmp1);
        for(int i=1;i<=n;i++)
        {
        cout<<p[i].id<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int large = 100000000;

int main()
{
  int n;
  int a, i;
  cin >> n;
  bool enable = false;
  for(i = 1; i< 10 ;++i){
    if(n%i==0){
      a = n/i;
      if(a < 10){
        enable = true;
      }
    }
  }
  if(enable){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const ll P = 998244353;
const int N = 2e5 + 5;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

inline void mod(ll &x) { x >= P ? x -= P : x; }

std::string str;
std::set < std::string > s;
int n;
ll dp[N][3][3][2];
inline bool all_equal(std::string str) {
	for (int i = 0; i < n; ++i)
		if (str[i] != str[0]) return false;
	return true;
}
inline void bfs(std::string str) {
	if (s.count(str)) return;
	s.insert(str);
	for (int i = 0; i < n - 1; ++i) 
		if (str[i] != str[i + 1]) {
		std::string t = str;
		if (str[i] != 'a' && str[i + 1] != 'a') t[i] = t[i + 1] = 'a';
		if (str[i] != 'b' && str[i + 1] != 'b') t[i] = t[i + 1] = 'b';
		if (str[i] != 'c' && str[i + 1] != 'c') t[i] = t[i + 1] = 'c';
		bfs(t);
	}
} 

inline ll dp_solve() {
	int s1 = 0;
	for (int i = 0; i < n; ++i) s1 += str[i] - 'a';
	s1 %= 3;
	for (int i = 0; i < 3; ++i) dp[0][i][i][0] = 1;
	for (int i = 0; i < n - 1; ++i)
		for (int s0 = 0; s0 < 3; ++s0)
			for (int now = 0; now < 3; ++now)
				for (int type = 0; type <= 1; ++type)
					for (int nxt = 0; nxt < 3; ++nxt) 
						mod(dp[i + 1][(s0 + nxt) % 3][nxt][type | (now == nxt)] += dp[i][s0][now][type]);
	ll ans = 0;
	for (int i = 0; i < 3; ++i) mod(ans += dp[n - 1][s1][i][1]);
	int ok = 0;
	for (int i = 1; i < n; ++i)
		if (str[i] == str[i - 1]) ok = 1;
	if (! ok) mod(ans += 1);
	return ans; 
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> str;
    n = str.size();
    if (all_equal(str)) return std::cout << 1 << '\n', 0;
    if (n < 4) bfs(str), std::cout << s.size() << '\n';
    else std::cout << dp_solve() << '\n';
	return 0;
}

Measured memory_bytes: 31884
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;

vll t, v;
ll N, T;

double f(double x, double l, double r, double c) {
    if (x < l) return c + (l - x);
    else if (x < r) return c;
    else return c + (x - r);
}

double calc_min(double x) {
    double minn = inf;
    minn = min(minn, f(x, 0, 0, 0));
    minn = min(minn, f(x, T, T, 0));
    ll atime = 0;
    rep(i, N) {
        minn = min(minn, f(x, atime, atime + t[i], v[i]));
        atime += t[i];
    }
    return minn;
}

int main()
{
    cin >> N;
    t.resize(N), v.resize(N);
    rep(i, N) cin >> t[i];
    rep(i, N) cin >> v[i];
    T = accumulate(all(t), 0LL);

    double time = 0;
    double distance = 0;
    while (time < T) {
        distance += 0.25 * (calc_min(time) + calc_min(time + 0.5));
        time += 0.5;
    }
    printf("%.12lf\n", distance);
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

U = 10**6
is_prime = np.zeros(U, np.bool_)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, U, 2):
    if p * p >= U:
        break
    if is_prime[p]:
        is_prime[p * p::p + p] = 0

primes = is_prime.nonzero()[0]


def factor(N):
    div = primes[N % primes == 0]
    for p in div:
        e = 0
        while N % p == 0:
            e += 1
            N //= p
        yield (p, e)
    if N != 1:
        yield (N, 1)


A = np.zeros(100, np.int32)
for i in range(14):
    k = i * (i + 1) // 2
    A[k] = i
np.maximum.accumulate(A, out=A)

x = 0
for p, e in factor(N):
    x += A[e]
print(x)


Measured memory_bytes: 29124
(let* ((n (read))
    (m (read))
    (k (read))
    (a (make-array (+ n 1) :initial-element 0))
    (b (make-array (+ m 1) :initial-element 0))
    (pre m)
    (ans 0))
    (loop for i from 1 to n do
        (incf (aref a i) (+ (read) (aref a (- i 1))))
    )
    (loop for j from 1 to m do
        (incf (aref b j) (+ (read) (aref b (- j 1))))
    )

    (loop for i from 0 to n do
        (progn
        (loop while (and (> (+ (aref a i) (aref b pre)) k) (not (= pre 0))) do
            (decf pre)
        )
        (if (<= (+ (aref a i) (aref b pre)) k)
        (if (< ans (+ i pre))
            (setq ans (+ i pre))
        )
        )
        )
    )
    (princ ans)
)

Measured memory_bytes: 80240
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int A, B;
  cin>>A>>B;
  cout<<A*B<<endl;

  return 0;
}


Measured memory_bytes: 3640