akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def calc_n_plus(required_diff, max_diff, min_diff, n):
    if (max_diff == 0) & (min_diff == 0):
        return 0
    return min(
        (required_diff + n * max_diff) // (max_diff + min_diff),
        n
    )


def check_in_max(required_diff, max_diff, min_diff, n, n_plus):
    max_val = n_plus * (min_diff + max_diff) - n * min_diff
    return required_diff <= max_val


# min_val = i * (min_diff + max_diff) - N * max_diff
# max_val = i * (min_diff + max_diff) - N * min_diff


def solve(N: int, A: int, B: int, C: int, D: int):
    n_plus = calc_n_plus(abs(B - A), D, C, N - 1)
    res = check_in_max(abs(B - A), D, C, N - 1, n_plus)
    print([NO, YES][res])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # root検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)


from collections import deque

def solve():
    N, K, L = tuple(map(int, input().split()))

    PQ = []
    for _ in range(K):
        PQ.append(tuple(map(int, input().split())))
    RS = []
    for _ in range(L):
        RS.append(tuple(map(int, input().split())))

    # print(N, K, L)
    # print(PQ)
    # print(RS)

    road = UnionFind(10**5*2 + 1)
    rail = UnionFind(10**5*2 + 1)

    for a, b in PQ:
        road.union(a, b)

    for a, b in RS:
        rail.union(a, b)

    d = {}
    for i in range(N):
        i += 1
        road_root = road.find(i)
        rail_root = rail.find(i)
        if not (road_root, rail_root) in d:
            d[(road_root, rail_root)] = 1
        else:
            d[(road_root, rail_root)] += 1

    ans = deque()
    for i in range(N):
        i += 1
        road_root = road.find(i)
        rail_root = rail.find(i)
        ans.append(d[(road_root, rail_root)])

    return " ".join(tuple(map(str, ans)))


if __name__ == '__main__':
    res = solve()
    print(res)


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

int H,W;
char t[200][200];
int si,sj,ti,tj;
int d[200][200];
int di[]={-1,0,1,0};
int dj[]={0,1,0,-1};

int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>t[i][j];
      if(t[i][j]=='@'){
        si=i;
        sj=j;
      }
      if(t[i][j]=='%'){
        ti=i;
        tj=j;
      }
    }
  }
  memset(d,1,sizeof(d));
  d[ti][tj]=0;
  queue<int> qi,qj;
  qi.push(ti);
  qj.push(tj);
  while(!qi.empty()){
    int pi=qi.front();qi.pop();
    int pj=qj.front();qj.pop();
    for(int dir=0;dir<4;dir++){
      int ni=pi+di[dir];
      int nj=pj+dj[dir];
      if(ni<0||nj<0||ni>=H||nj>=W)continue;
      if(t[ni][nj]=='#')continue;
      if(d[ni][nj]>d[pi][pj]+1){
        d[ni][nj]=d[pi][pj]+1;
        qi.push(ni);
        qj.push(nj);
      }
    }
  }
  int dist=d[si][sj];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(t[i][j]=='$')
        if(d[i][j]<=dist)
          dist=0;
  if(dist)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3360
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
txy.insert(0,[0,0,0])
for i in range(n):
  d=txy[i+1][1]-txy[i][1]+txy[i+1][2]-txy[i][2]
  t=txy[i+1][0]-txy[i][0]
  if not(d<=t and t%2==d%2):
    print("No")
    exit()
print("Yes")

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
void output(int t, int m){
    cout << t << ':';
    if(m < 10) cout << 0;
    cout << m;
  }

int main(){
  int n, m;
  int j, h;
  vector<pair<int,int>> time;

  cin >> n;
  REP(i, n){
      cin >> j >> h;
      time.pb(make_pair(j,h));
    }

    cin >> m;
    REP(i, m){
        cin >> j >> h;
        time.pb(make_pair(j,h));
      }
      sort(time.begin(),time.end());
      time.erase(unique(time.begin(),time.end()), time.end());

  int s = time.size() - 1;
  REP(i, s){
      output(time[i].first,time[i].second);
      cout << " ";
    }
    output(time[s].first, time[s].second);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3072
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

const int K=4;
int a[30][K][K];
void init(){
    a[0][0][1]=a[0][1][2]=a[0][2][3]=1;
    a[0][3][1]=1,a[0][3][2]=mod-2,a[0][3][3]=4;
    rep(i,1,30){
        rep(j,0,K){
            rep(k,0,K){
                rep(r,0,K){
                    add(a[i][j][k],1LL*a[i-1][j][r]*a[i-1][r][k]%mod);
                }
            }
        }
    }
}
int v[4],nv[4],b[N];
void cal(int n){
    per(i,0,30)if(n>>i&1){
        rep(j,0,K){
            int &x=nv[j];
            x=0;
            rep(k,0,K){
                add(x,1LL*v[k]*a[i][j][k]%mod);
            }
        }
        swap(v,nv);
    }
}
int main(){
    //freopen("A.in","r",stdin);
    //freopen("B.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int i,j,k,ca=0,m,n;
    scanf("%d%d",&n,&m);
    rep(i,0,m){
        scanf("%d",&b[i]);
    }
    init();
    int last=0;
    v[0]=1,v[1]=1,v[2]=5,v[3]=18;
    rep(i,0,m){
        cal(b[i]-last);
        last=b[i];
        ll x=mod-v[0];if(x==mod)x=0;
        add(v[0],x);add(v[1],x);add(v[2],x*5%mod);add(v[3],x*18%mod);
    }
    cal(n-last);
    printf("%d\n",v[0]);
    //cerr<<clock()*1./CLOCKS_PER_SEC<<"ms\n";
    return 0;
}

Measured memory_bytes: 640
#Nへの代入
N=int(input())

#データのリストdata [x座標,y座標,高さ]
k=0
data=list()
for i in range(N):
    l=list(map(int,input().split()))
    data.append(l)
    if(l[2]>0):
        k=i

#中心点の探索
for x in range(101):
    for y in range(101):
        H=data[k][2]+abs(x-data[k][0])+abs(y-data[k][1])
        if all([max(H-abs(x-l[0])-abs(y-l[1]),0)==l[2] for l in data]):
            print(x,y,H)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next(),t;
		int countOdd=0,countEven=0;
		for(int i=0;i<s.length();i++) {
			if(i%2==0)t="0";
			else t="1";
			if(!s.substring(i, i+1).equals(t))countOdd++;
		}
		for(int i=0;i<s.length();i++) {
			if(i%2==0)t="1";
			else t="0";
			if(!s.substring(i, i+1).equals(t))countEven++;
		}
		System.out.println((int)Math.min(countOdd,countEven));
	}
}



Measured memory_bytes: 34140
//arc062_c.cpp
//Sun Jun 10 19:15:51 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	int n;
	cin >> n;
	ll tpoll = 0;
	ll apoll = 0; 
	int t[n],a[n];
	for (int i=0;i<n;i++){
		cin >> t[i] >> a[i];
		if (t[i] > tpoll && a[i] > apoll){
			tpoll = t[i];
			apoll = a[i];
		}else{
			ll tratio = tpoll/t[i];
			if (tpoll%t[i]!=0){
				tratio = tratio+1;
			}
			ll aratio = apoll/a[i];
			if (apoll%a[i]!=0){
				aratio = aratio+1;
			}
			ll wratio = 0;
			if (tratio > aratio){
				wratio = tratio;
			}else {
				wratio = aratio;
			}
			tpoll = wratio*t[i];
			apoll = wratio*a[i];
		}
	}

	ll total = tpoll + apoll;

	cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int k,a,b,x,y,ans,c,t1,t2,B;
struct node { int x,y; };
vector<node> s;
void add(int X,int Y) {
	s.push_back((node){X,Y});
}
int main() {
	//freopen("1.txt","r",stdin);
	read(k); read(a); read(b);
	if (a) t1=abs(a)/a; else t1=1;
	if (b) t2=abs(b)/b; else t2=1;
	a=abs(a); b=abs(b);
	if (k%2==0&&(a+b)%2==1) { printf("-1\n"); return 0; }
	if ((a+b)%k==0) ans=(a+b)/k;
	else ans=(a+b)/k+1;
	if (ans==1&&a+b!=k) ans++;
	if ((ans*k)%2!=(a+b)%2) ans++;
	B=(ans*k-a-b)/2;
	while (B) {
		c=min(B,k);
		if (abs(a-x)<abs(b-y)) x-=c,y+=k-c;
		else y-=c,x+=k-c;
		add(x,y); B-=c;
	}
	while (x+k<=a) x+=k,add(x,y);
	while (y+k<=b) y+=k,add(x,y);
	if (x!=a||y!=b) add(a,b);
	printf("%d\n",ans);
	for (int i=0;i<s.size();i++)
		printf("%d %d\n",s[i].x*t1,s[i].y*t2);
	return 0;
}

Measured memory_bytes: 3952
#include<stdio.h>
int main()
{
    int n,i=0,count=0;
    while(scanf("%d",&n)==1)
    {
        count++;
        if(n==0)
        {
            break;
        }
        if(n>=1 && n<=10000 && count<=10000)
        {
            i++;
            printf("Case %d: %d\n",i,n);
        }
    }
    return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;		// N:回数　K:足す数値
  int num = 1;	// n:掲示板の数値
  
  cin >> N >> K;	//入力
  for( int i=0 ; i<N ; i++){
    if( num <= K ){
      num *= 2;
    }else{
      num += K;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
let m = 1039999

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let to_x = Array.make 128 0

let to_key s =
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(to_x.(Char.code s.[i]))) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  to_x.(Char.code 'A') <- 1;
  to_x.(Char.code 'C') <- 2;
  to_x.(Char.code 'G') <- 3;
  to_x.(Char.code 'T') <- 4;
  let n = read_int () in
  let t = Array.make m "\000" in
  for _ = 0 to n - 1 do
    match split_on_char ' ' (read_line ()) with
    | ["find"; s] -> Printf.printf "%s\n" (if find s t then "yes" else "no")
    | [_; s] -> insert s t
    | _ -> assert false
  done

Measured memory_bytes: 20876
def output(list):
    for i,row in enumerate(list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    
def main():
    s = input()
    s_list = []
    s_list = list(map(int,input().split()))

    output(s_list)
    print()

    i = 0
    for count in range(len(s_list)-1):

#   Judge: now > next
        if s_list[i] > s_list[i+1]:

#       Change: now > next
            ins_num = s_list[i+1]
            s_list[i+1] = s_list[i]
            s_list[i]   = ins_num

            j = i - 1

            while j >= 0:
                if s_list[j] > ins_num:
                    s_list[j+1] = s_list[j]
                    s_list[j]   = ins_num

                j -= 1
            output(s_list)
        else:
           output(s_list)        
    
        print()
        i += 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 8440
[n,m] = [int(x) for x in input().split()]
ac=[0]*(n+1)
wa=[0]*(n+1)
cnt_ac=0
cnt_wa=0
for i in range(m):
	p,s=input().split()
	p=int(p)
	if s=="AC":
		if ac[p]==0:
			cnt_ac+=1
			cnt_wa+=wa[p]
			ac[p]=1
	else: 
		wa[p]+=1

print(int(cnt_ac),int(cnt_wa))

Measured memory_bytes: 4596
#include<stdio.h>
int main(void)
{
	int n,m,a,s,d,x=0,w,p=0,h=0;
	scanf("%d %d %d %d %d",&n,&m,&a,&s,&d);
	w=1;
	x=s;
	h=d;
	while(1){
		if(m<=s&&a<=d) break;
		s+=x;
		d+=h;
		w++;
		
	}
	n=n-w;
	printf("%d\n",n);
}	

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dp[3010][3010];
int main(){
    string s,t;
    cin >> s >> t;
    rep(i,s.length()){
        rep(j,t.length()){
            if(s[i]==t[j]){
                dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1]);
            }
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j+1]);
        }
    }
    int i = s.length();
    int j = t.length();
    string ans;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]){
            i--;
        }
        else if(dp[i][j]==dp[i][j-1]){
            j--;
        }
        else{
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[200000];
set<int> st;

signed main(){

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

  st.insert(0);
  for(int i = 0; i < n; i++){
    for(auto p = st.rbegin(); p != st.rend(); p++){
      st.insert(*p + a[i]);
    }
  }

  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int m; cin >> m;
    if(st.find(m) != st.end()) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int l,sum[100];
 
inline char rev(int x)
{
	if(x>=1&&x<=26) return char('a'+x-1);
	else if(x>=27&&x<=52) return char('A'+x-27);
	else return char('0'+x-53);
}

inline int check(string t)
{
	cout<<"? "<<t<<endl;
	fflush(stdout);
	int x;cin>>x;
	return x;
}

signed main()
{
	priority_queue<pair<int,string> > q;
	for(int i=1;i<=62;i++){
		char s=rev(i);
		string c="";
		for(int j=1;j<=128;j++) c+=s;
		cout<<"? "<<c<<endl;
		fflush(stdout);
		int x;cin>>x;
		sum[i]=128-x;
		if(sum[i]>0){
			l+=sum[i];
			string nw="";
			for(int j=1;j<=sum[i];j++) nw+=s;
			q.push(make_pair(-sum[i],nw));
		}
	}
	while(q.size()>1){
		pair<int,string> t1=q.top();q.pop();
		pair<int,string> t2=q.top();q.pop();
		string ans="";
		int pos1=0,pos2=0;
		while(pos1<t1.second.size()||pos2<t2.second.size()){
			if(pos1==t1.second.size()){
				ans+=t2.second[pos2];pos2++;
			}
			else if(pos2==t2.second.size()){
				ans+=t1.second[pos1];pos1++;
			}
			else{
				string str=ans+t1.second[pos1];
				for(int i=pos2;i<t2.second.size();i++) str+=t2.second[i];
				if(check(str)==l-str.size()){
					ans+=t1.second[pos1];pos1++;
				}
				else{
					ans+=t2.second[pos2];pos2++;
				}
			}
		}
		q.push(make_pair(t1.first+t2.first,ans));
	}
	cout<<"! "<<q.top().second<<endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3780
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int i,n,x,y,b=0;cin>>n;
	if(n==2){cout<<"-1"<<endl;return 0;}
	vector<string> goo={
		"aabee",
		"d.bff",
		"dccgg",
		"hij..",
		"hij.."
	};
	vector<string> yon={
		"aaef",
		"bbef",
		"cdgg",
		"cdhh"
	};
	vector<string>nna={
		"aab...e",
		"d.b...e",
		"dcc...f",
		"...aabf",
		"...d.bg",
		"...dccg",
		"hhiijj."
	};
	
	vector<string> ans(n,string(n,'.'));
	if(n==3||n==6){
		while(b<n){
			for(y=0;y<3;y++){
				for(x=0;x<3;x++){ans[b+y][b+x]=goo[y][x];}
				
			}
			b+=3;
		}
	}else if(n==7||n==11){
		for(y=0;y<7;y++){
			for(x=0;x<7;x++){ans[b+y][b+x]=nna[y][x];}
		}
		b+=7;
		if(n==11){
			for(y=0;y<4;y++){
				for(x=0;x<4;x++){ans[b+y][b+x]=yon[y][x];}
			}
		}
	}else{
		//4-5パターン
		int Gk=n%4,Yk=(n-Gk*5)/4;
		for(i=0;i<Gk;i++){
			for(y=0;y<5;y++){
				for(x=0;x<5;x++){ans[b+y][b+x]=goo[y][x];}
			}
			b+=5;
		}
		for(i=0;i<Yk;i++){
			for(y=0;y<4;y++){
				for(x=0;x<4;x++){ans[b+y][b+x]=yon[y][x];}
			}
			b+=4;
		}
	}
	for(auto it:ans){cout<<it<<endl;}
	return 0;
}




Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<long long>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int get_digits(int n){
    int d=0;
    while(n!=0){
        d++;
        n/=10;
    }
    return d;

}
void solve(){
    int n;
    cin>>n;
    int sq = (int)sqrt(n)+1;
    int ans = get_digits(n);
    rep(i,1,sq){
        if(n%i==0) ans = min(ans,max(get_digits(i),get_digits(n/i)));
    }
    cout<<ans<<endl;

}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,k;
int main()
{
cin>>a>>b>>c;
if(b>=a)
{
cout<<1<<endl;
return 0;
}
if(c>=b)
{
cout<<-1<<endl;
return 0;
}
if((a-b)%(b-c)>=1)k=1;
cout<<((a-b)/(b-c)+k)*2+1<<endl;
return 0;
}

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

int main(){
    int n, m, A[100][100], b[100], c[100];
    
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cin >> A[i][j];
    }
    for(int i = 0; i < m; i++) cin >> b[i];
    
    for(int i = 0; i < n; i++){
        c[i] = 0;
        for(int j = 0; j < m; j++){
            c[i] += A[i][j] * b[j];
        }
    }
    for(int i = 0; i < n; i++) cout << c[i] << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <cstdio>
#include <sstream>
#include <algorithm>
#define endl '\n'
#define all(var) var.begin(), var.end()
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a == b && a != c) || (a == c && a != b) || (b == c && b != a))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[105];


int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {	
		scanf("%lld", &arr[i]);
	}
	double sum = 0;
	for(int i = 0; i < N; i++) {
		sum += 1.0 / arr[i];
	}
	double ans = 1.0 / sum;
	printf("%0.12lf\n", ans); 
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
[r, g, b] = map(int,input().split(' '))
K = int(input())
loop = 1
flag = False

while loop <= K+1:
  if b <= r or b <= g:
    b*=2
    loop += 1
    continue
  if g <= r:
    g*=2
    loop += 1
    continue
  if r < g < b:
    flag = True
    break
  loop += 1
  
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
struct input_t{template<class T>operator T(){T t;std::cin>>t;return t;}}input;
auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n=input,m=input,s=input;
    cmn(s,m*50);
    lint k=s+m*50;
    lint N=n*k;
    std::vector<std::vector<std::pair<lint,lint>>>g(N);
    for(lint u=0;u<n;u++){
        for(lint i=1;i<k;i++){
            g.at(i*n+u).emplace_back((i-1)*n+u,0);
        }
    }
    while(m--){
        lint u=input,v=input,a=input,b=input;u--,v--;
        for(lint i=a;i<k;i++){
            g.at(i*n+u).emplace_back((i-a)*n+v,b);
            g.at(i*n+v).emplace_back((i-a)*n+u,b);
        }
    }
    for(lint u=0;u<n;u++){
        lint c=input,d=input;
        for(lint i=0;i+c<k;i++){
            g.at(i*n+u).emplace_back((i+c)*n+u,d);
        }
    }

    std::priority_queue<std::pair<lint,lint>>que;
    lint r=s*n+0;
    que.emplace(0,r);
    lint inf=numr<lint>::max();
    std::vector<lint>dist(N,inf);
    dist.at(r)=0;
    while(!que.empty()){
        lint x=que.top().second;que.pop();
        for(auto[y,w]:g.at(x)){
            lint nd=dist.at(x)+w;
            if(dist.at(y)<=nd)continue;
            dist.at(y)=nd;
            que.emplace(-nd,y);
        }
    }

    for(lint i=1;i<n;i++){
        std::cout<<dist.at(i)<<'\n';
    }
}


Measured memory_bytes: 48272
#include<stdio.h>

int linearSearch(int n, int key, int *S){
  
  int i=0;
  
  S[n]=key;
  if(S[0]==key){
    return 1;
  }
    
  while(S[i]!=key){
    i++;
  }
    if(i==n){
      return 0;
    }

  return 1;
}

    
int main(){

  int i,n,q,key,count=0;
  int S[1000001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(linearSearch(n,key,S)){
      count++;
    }
  }

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

  return 0;
}
 

Measured memory_bytes: 996
#include<stdio.h>
#include<math.h>

int main(){
  double x1,y1,x2,y2,distance;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  distance=sqrt( pow(x2-x1,2) + pow(y2-y1,2) );
  printf("%lf\n",distance);

  return 0;
}

Measured memory_bytes: 652
#include<cstdio>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;

int n,t;
int p;
LL ans;
int a[900002];

inline int qr()
{
	int w=1,x=0;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a>='0'&&a<='9'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

bool mycmp(int a,int b)
{
	return a>b;
}

int main()
{
	n=qr();
	t=qr();
	for(int i=1;i<=n;i++)
		a[i]=qr();
	sort(a+1,a+n+1,mycmp);
	if(t>=n)
		cout<<"0"<<endl;
	else
	{
		for(int i=t+1;i<=n;i++)
			ans+=a[i];
		cout<<ans<<endl;
	}
	return 0;
} 

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

using namespace std;
using ll = long long;

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

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

  vector<int> num(n, -1);

  bool ok = true;

  rep(i, m) {
    int s, c;
    cin >> s >> c;
    --s;
    if (num[s] == -1) {
      num[s] = c;
      if (s == 0 && c == 0 && n != 1) ok = false;
    } else {
      if (num[s] != c) ok = false;
    }
  }

  // for (auto v : num) {
  //   cout << v;
  // }
  // cout << '\n';

  // if (num[0] == 0 && n != 1) {
  //   ok = false;
  // }

  if (!ok) {
    cout << -1 << '\n';
    return 0;
  }

  string ans;
  rep(i, n) {
    if (num[i] == -1) {
      if (i == 0 && n != 1)
        ans += '1';
      else if (i == 0 && n == 1) {
        ans += '0';
      } else
        ans += '0';
    } else
      ans += num[i] + '0';
  }

  // while (ans[0] == '0' && ans.length() > 1) {
  //   ans = ans.substr(1, ans.length());
  // }

  if (ans.length() == n)
    cout << ans << '\n';
  else
    cout << -1 << '\n';

  return 0;
}


Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
t= input()
ns = len(s)
nt = len(t)
for i in range(ns-nt+1):
  count = 0
  for j in range(nt):
    if s[i+j] != t[j]:
      count += 1
  mans = min(mans,count)
print(mans)
    


Measured memory_bytes: 73780
i = gets.to_i
array = gets.chomp.split.map(&:to_i)

diff = []

for num in 0...i-1
  if array[num].to_i > array[num + 1].to_i
    diff << array[num].to_i - array[num + 1].to_i
    array[num + 1] = array[num].to_i
  end
  num += 1
end

puts diff.sum

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

int main() {
  int N,M;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  cin >> M;
  vector<vector<int>> b(M,vector<int>(2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> b.at(i).at(j);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += a.at(i);
  }
  for (int i = 0; i < M; i++) {
    int s = b.at(i).at(0);
    int d = b.at(i).at(1);
    cout << ans - a.at(s-1) + d <<endl;
  }
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

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

    ll n;
    string s;
    unordered_set<string> u;
    cin >> n;
    while (n--)
    {
        cin >> s;
        u.insert(s);
    }
    cout << u.size() << endl;
}

Measured memory_bytes: 17680
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin>>N;
  double revsum=0.0;
  vector<int> vec(N);
  for(int i;i<N;i++) {
  cin>>vec.at(i);}
  for(int i;i<N;i++) {
  revsum += 1.0/vec.at(i);}
  cout<<1/revsum<<endl;
}

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

int main(){
    ll w,h,x,y;
    int flag = 0;
    cin >> w >> h >> x >> y;
    double max = w * h / 2.0;
    if(2*x == w && 2*y == h){
        flag = 1;
    }
    printf("%.10lf %d",max,flag);
}

Measured memory_bytes: 3724
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	
	int N, M;
	cin >> N >> M;
	int ans = 0;

	cout << (N * N - N) / 2 + (M * M - M) / 2;











}



Measured memory_bytes: 256
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (L, R) = *readInt()
    if ((R-L) >= 2019) {
        print(0)
    } else {
        var mins = 2019
        for i in L..<R {
            for j in (i+1)...R {
                mins = min(mins, (i * j) % 2019)
            }
        }
        print(mins)
    }
}
main()


Measured memory_bytes: 13600
N, A, B, C = map(int, input().split())
s = [[ord(i) - ord('A') for i in input()] for _ in range(N)]

L = [A, B, C]
ret = []
for i in range(N) :
  x, y = s[i]
  done = False
  if L[x] + 1 >= 0 and L[y] - 1 >= 0 :
    L[x] += 1
    L[y] -= 1
    if i + 1 != len(s) :
      u, v = s[i + 1]
      if (L[u] + 1 >= 0 and L[v] - 1 >= 0) or (L[u] - 1 >= 0 and L[v] + 1 >= 0) :
        done = True
        ret.append(x)
    else :
      done = True
      ret.append(x)
    if not done :
      L[x] -= 1
      L[y] += 1
        
  if not done and L[x] - 1 >= 0 and L[y] + 1 >= 0 :
    L[x] -= 1
    L[y] += 1
    if i + 1 != len(s) :
      u, v = s[i + 1]
      if (L[u] - 1 >= 0 and L[v] + 1 >= 0) or (L[u] + 1 >= 0 and L[v] - 1 >= 0) :
        done = True
        ret.append(y)    
    else :
      done = True
      ret.append(y)
    if not done :
      L[x] += 1
      L[y] -= 1
  
  if not done :
    print('No')
    break
else :
  print('Yes')
  for r in ret :
    print(chr(ord('A') + r))

Measured memory_bytes: 91428
import math
n,d=map(int,input().split())
a=[[int(i) for i in input().split()] for l in range(n)]
c=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for x,y in zip(a[i],a[j]):
            sum+=(abs(x-y))**2
        if math.sqrt(sum)%1==0:c+=1
print(c)

Measured memory_bytes: 3060
s = list(input())
ops = ['+', '-']

for x in ops:
    for y in ops:
        for z in ops:
            fom = s[0] + x + s[1] + y + s[2] + z + s[3]
            if eval(fom) == 7:
                print(fom + '=7')
                exit(0)

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

typedef long long LL;

#define INF 1000000000
#define INF_LL_YJ 1145141919810364364

using namespace std;

#define MAX_N 100005

int N;
LL A[MAX_N];

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

map<LL, LL> mapS;
map<LL, int> indexS;
priority_queue<LL> kindS;
set<LL> SetS;

LL ans[MAX_N];
void solve()
{
  for (int i = 0; i < N; i++) {
    mapS[A[i]]++;
    if(indexS.find(A[i]) == indexS.end()){
      indexS[A[i]] = i;
    }
    if(SetS.insert(A[i]).second){
      kindS.push(A[i]);
    }
  }
  kindS.push(0);

  LL nextKind = kindS.top();
  kindS.pop();

  int index = indexS[nextKind];
  LL m = mapS[nextKind];

  while(kindS.size()){

    int k = kindS.top();
    int nextIndex = indexS[k];
    kindS.pop();

    ans[index] += m*(nextKind - k);

    if(k == 0){
      break;
    }

    index = min(index, nextIndex);
    m += mapS[k];
    nextKind = k;
  }

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

int main()
{
  input();

  solve();

  return 0;
}


Measured memory_bytes: 21876
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(all(a));
  sort(all(b));
  vll bb(n);
  sort(all(c));
  ll ans=0;
  rep(i,n){
    auto it = upper_bound(all(c), b[i]);
    ll k=c.end()-it;
    bb[i]=k;
  }
  for(int i=n-2;i>=0;i--){
    bb[i]+=bb[i+1];
  }
  rep(i,n){
    auto it = upper_bound(all(b), a[i]);
    ll k=it - b.begin();
    ans+=bb[k];
  }
  COUT(ans);
}

Measured memory_bytes: 3328
from heapq import heapify, heappush, heappop

import sys
sys.setrecursionlimit(100000000)

n = int(input())
G = [[] for _ in range(n + 1)]

for _ in range(n - 1):
    ai, bi, ci = map(int, input().split())
    G[ai].append((bi, ci))
    G[bi].append((ai, ci))

Q, K = map(int, input().split())

# # 頂点KからDFSする
# d = [None for _ in range(n + 1)]
# d[K] = 0

# def dfs(v, dist):
#     for (u, cvu) in G[v]:
#         if d[u] is None:
#             d[u] = dist + cvu
#             dfs(u, dist + cvu)

# dfs(K, 0)

# 頂点KからDFSする (heap ver.)
queue = []
d = [None for _ in range(n + 1)]
heappush(queue, (0, K, -1))
while len(queue) > 0:
    dist, index, parent = heappop(queue)
    if d[index] is not None:
        continue
    d[index] = dist
    for (u, cvu) in G[index]:
        if u == parent:
            continue
        heappush(queue, (dist + cvu, u, index))

for _ in range(Q):
    xi, yi = map(int, input().split())
    print(d[xi] + d[yi])


Measured memory_bytes: 94880
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll n,m;
    cin >> n >> m;
    ll a[n],b[n],c[m],d[m];
    ll i,j;
    for(i=0;i<n;i++){
      cin >> a[i]>>b[i];
    }
    for(j=0;j<m;j++){
      cin >> c[j]>>d[j];
    }
    ll tmp,ans=0;
    for(i=0;i<n;i++){
      tmp=10000000000000;
      for(j=0;j<m;j++){
        if(tmp>abs(a[i]-c[j])+abs(b[i]-d[j])){
          tmp=abs(a[i]-c[j])+abs(b[i]-d[j]);
          ans=j;
        }
      }
      cout << ans+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
a = []

def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1, 10):
    dfs(i)
a = sorted(a)
k = int(input())
print(a[k-1])


Measured memory_bytes: 8512
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()
cnt = 0
tmp = ""
word = ""
for i in s:
	word += i
	if tmp != word:
		cnt += 1
		tmp = word
		word = ""
print(cnt)

Measured memory_bytes: 9360
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int k, n; cin >> k >> n;
  vector<int> a(n);
  vector<int> aida(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n - 1; i++){
    aida[i] = a[i + 1] - a[i];
  }
  aida[n - 1] = k - a[n - 1] + a[0];
  int maxaida = 0;
  for(int i = 0; i < n; i++){
    maxaida = max(aida[i], maxaida);
  }
  cout << k - maxaida << endl;
  return;
}

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


Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    t = 1
    for i in range(N):
        if A[i] == t:
            t += 1

    if t == 1:
        print(-1)
    else:
        print(N - (t - 1))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 33128
#include<stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(W>=x+r && x-r>=0 && H>=y+r && y-r>=0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2612
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	int x, y, z;
	cin >> x >> y >> z; 
	cout << (x-z) / (y + z) << endl;
}


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

typedef pair<int, int> ii;

int A[25];
int B[25];

const int INF = 1012345678;

long long nxs(long long r){
    long long ls1 = r&(-r);
    long long rest = r+ls1;
    return rest|(((rest^r)/ls1) >> 2);
}

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

    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
    }

    for(int i = 0; i < N; i ++){
        scanf("%d", &B[i]);
    }

    int ans = INF;
    int noBits = (N+1)>>1;
    vector<ii> set1 = vector<ii>();
    vector<ii> set2 = vector<ii>();
    vector<int> perm;
    for(int i = (1<<noBits)-1; i < (1<<N); i = nxs(i)){
        //printf("i=%d\n", i);
        set1.clear();
        set2.clear();
        perm.clear();
        for(int j = 0; j < N; j ++){
            if(i&(1<<j)){
                // Place in first set, parity is even (0-indexed)
                if((j&1) == 0){
                    set1.push_back(ii(A[j], j));
                }else{
                    set1.push_back(ii(B[j], j));
                }
            }else{
                // Place in second set, parity is odd
                if((j&1) == 0){
                    set2.push_back(ii(B[j], j));
                }else{
                    set2.push_back(ii(A[j], j));
                }
            }
        }

        sort(set1.begin(), set1.end());
        sort(set2.begin(), set2.end());

        bool boleh = true;
        for(int j = 0; j < (int)set2.size(); j ++){
            //printf("set1[%d]=ii(%d, %d), set2[%d]=ii(%d, %d)\n", j, set1[j].first, set1[j].second, j, set2[j].first, set2[j].second);
            if(set1[j].first > set2[j].first){
                boleh = false;
                break;
            }

            if( ((N&1) == 0) && j == (int)set2.size()-1 ){
                break;
            }

            if(set1[j+1].first < set2[j].first){
                boleh = false;
                break;
            }
        }

        if(boleh){
            for(int j = 0; j < (int)set2.size(); j ++){
                perm.push_back(set1[j].second);
                perm.push_back(set2[j].second);
            }
            if(N&1){
                perm.push_back(set1[set2.size()].second);
            }

            /*for(int j = 0; j < N; j ++){
                printf("%d ", perm[j]);
            }
            printf("\n");*/

            int inv = 0;
            for(int j = 0; j < N; j ++){
                for(int k = j+1; k < N; k ++){
                    if(perm[j] > perm[k]){
                        inv ++;
                    }
                }
            }

            ans = min(ans, inv);
        }
    }

    if(ans == INF){ans = -1;}
    printf("%d", ans);
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string b2s(ll x,ll n){
  string res;
  rep(i,n)res+='0'+((x>>i)&1);
  return res;
}

ll s2b(string x,ll n){
  ll res=0;
  rep(i,n)if(x[i]=='1')res|=(1<<i);
  return res;
}

vector<string> dfs(ll n,string a,string b){
  if(n==0){
    vector<string> res(1,"0");
    return res;
  }
  vector<string> res;
  rep(i,n){
    if(a[i]!=b[i]){
      string na=a.substr(0,i)+a.substr(i+1,n-1-i);
      string nb=b.substr(0,i)+b.substr(i+1,n-1-i);
      string nc=na;
      if(nc[0]=='0')nc[0]='1';
      else nc[0]='0';
      vector<string> crta=dfs(n-1,na,nc);
      vector<string> crtb=dfs(n-1,nc,nb);
      rep(j,(1<<(n-1))){
        string nxt=crta[j];
        res.push_back(nxt.substr(0,i)+a.substr(i,1)+nxt.substr(i,n-1-i));
      }
      rep(j,(1<<(n-1))){
        string nxt=crtb[j];
        res.push_back(nxt.substr(0,i)+b.substr(i,1)+nxt.substr(i,n-1-i));
      }
      break;
    }
  }
  return res;
}

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

  ll n,a,b;
  cin>>n>>a>>b;
  if(bcnt(a)%2==bcnt(b)%2){
    cout<<"NO"<<endl;
    return 0;
  }
  string sa,sb;

  rep(i,n)sa+='0'+((a>>i)&1);
  rep(i,n)sb+='0'+((b>>i)&1);

  vector<string> res=dfs(n,sa,sb);

  cout<<"YES"<<endl;
  rep(i,res.size()){
    ll ans=0;
    rep(j,n)if(res[i][j]=='1')ans+=(1<<j);
    cout<<ans<<" ";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 18800
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let v: Vec<usize> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    let k:usize = v[1];
    let mut buf2 = String::new();
    stdin
        .read_line(&mut buf2)
        .expect("ERROR Can't read array size");
    let mut l: Vec<i64> = buf2.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    l.sort_by(|a, b| b.cmp(a));
    let mut ans: i64 = 0;

    for i in 0..k {
        ans += l[i];
    }

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


Measured memory_bytes: 4352