akhauriyash/Code-Regression huggingface dataset:
def calc(a, b, c)
  a,b = b,a if a > b
  (c-(b-a)+1)/2 + b
end

n, m, k = gets.split.map(&:to_i)
l1 = Array.new(n){ [1<<31]*n }
l2 = Array.new(n){ [] }
l3 = []
n.times{ |i| l1[i][i] = -1 }
m.times do
  a, b, c = gets.split.map(&:to_i)
  a -= 1; b -= 1
  l1[a][b] = l1[b][a] = c
  l2[a] << b; l2[b] << a
  l3 << [a,b,c]
end

visited = [false]*n
arr = []
dist = [1<<31]*n
k.times do
  visited[i = gets.to_i - 1] = true
  arr << i
  dist[i] = 0
end

until arr.empty?
  s = arr.min{ |a,b| dist[a] <=> dist[b] }
  arr.delete s
  l2[s].each do |t|
    d = dist[s] + l1[s][t]
    if (old = dist[t]) > d
      dist[t] = d
      arr << t if old == 1 << 31
    end
  end
end
ret = 0
m.times{ |i| ret = [ret, calc(dist[l3[i][0]], dist[l3[i][1]], l3[i][2])].max }
p ret

Measured memory_bytes: 88548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  int counter=0;
  for(int i=0;i<N;i++){
    if((i+1)%2==1 && a.at(i)%2==1){
      counter++;
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  vi u(2);
  cin >> n >> u[0] >> u[1];
  u[0]--;
  u[1]--;
  vector<vi> g(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vi> d(2, vi(n, -1));
  rep(k, 2) {
    queue<int> q;
    q.push(u[k]);
    d[k][u[k]] = 0;
    while(!q.empty()) {
      int i = q.front();
      q.pop();
      for(auto ni : g[i]) {
        if(d[k][ni] != -1) continue;
        d[k][ni] = d[k][i] + 1;
        q.push(ni);
      }
    }
  }
  int mx = 0;
  rep(i, n) if(d[0][i] < d[1][i]) mx = max(mx, d[1][i]);
  cout << mx - 1 << endl;
}

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

int main()
{
  int n, a;cin >>n>>a;
  while (n >= 500) {
    n -= 500;
  }
  // int amari = n / 500;
  if (n <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
const int mo=1000000007;
int f[1<<19],a[25][25];
int lowbit(int x){return x&-x;}
int main(){
	memset(a,-1,sizeof a);
	int n,m,k;
	scanf("%d%d%d\n",&n,&m,&k);n--;
	for (int i=1;i<=k;i++){
		int x,y,z;
		scanf("%d%d%d\n",&x,&y,&z);
		a[x][y-1]=z;
	}
	f[0]=1;
	int L=1<<n;
	for (int i=1;i<=m;i++)
		for (int j=0;j<n;j++){
			for (int s=0;s<L;s++)
			if (f[s]){
				int x=f[s];
				if (a[i][j]==1 || ((s>>j)&1)) f[s]=0;
				if (a[i][j]) (f[(lowbit(s>>j)^1)<<j^s]+=x)%=mo;
			}
		}
	int ans=0;
	for (int i=0;i<L;i++) (ans+=f[i])%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 2176
k, n = map(int,input().split())
ls = list(map(int, input().split()))
ls2 = []
for i in range(n - 1):
    a = ls[i + 1] - ls[i]
    ls2.append(a)
a = k + ls[0] - ls[n - 1]
ls2.append(a)
print(k - max(ls2))



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
vector<int> g[N];
int dist[N], par[N];

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

	int n, m;
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		int u, v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue<int> qq;
	qq.push(1);
	dist[1] = 0;
	par[1] = -2;
	memset(par, -1, sizeof(par));
	while(!qq.empty()){
		int v = qq.front(); qq.pop();
		for(auto u : g[v]){
			if(par[u] == -1){
				par[u] = v;
				dist[u] = dist[v] + 1;
				qq.push(u);
			}
		}
	}
	for(int i = 2; i <= n; i++){
		if(par[i] == -1){
			cout<<"No"<<'\n';
			exit(0);
		}
	}
	cout<<"Yes"<<'\n';
	for(int i = 2; i <= n; i++){
		cout<<par[i]<<'\n';
	}

	return 0;
}

Measured memory_bytes: 10916
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  char c;
  std::cin >> c;

  print(char(c + 1));

  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_COL_CNT		2										// 列数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部構造体 - 数字情報
typedef struct Num {
	int miVal;													// 値
	int miCnt;													// 個数
} Num;

// 内部変数
static FILE *szpFpI;											// 入力
static Num sz2Num[D_COL_CNT][D_ARRAY_MAX + 5];					// 数字情報
static int siNCnt;												// 数字情報数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// ソート関数 - 個数降順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Num *lzpVal1 = (Num *)pzpVal1;
	Num *lzpVal2 = (Num *)pzpVal2;

	// 個数降順
	if (lzpVal1->miCnt > lzpVal2->miCnt) {
		return(-1);
	}
	else if (lzpVal1->miCnt < lzpVal2->miCnt) {
		return(1);
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// データ - 初期化
	memset(sz2Num, 0, sizeof(sz2Num));							// 数字情報

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 数字情報数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siNCnt);

	// 数字情報 - 取得
	for (i = 0; i < siNCnt; i++) {
		int liVal;
		fscanf(szpFpI, "%d", &liVal);

		// セット列
		int liCNo;
		if (i % 2) {							// 奇数番目
			liCNo = 0;
		}
		else {									// 偶数番目
			liCNo = 1;
		}

		// セット
		sz2Num[liCNo][liVal].miVal = liVal;
		(sz2Num[liCNo][liVal].miCnt)++;
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 数字情報 - ソート
	qsort(sz2Num[0], D_ARRAY_MAX + 5, sizeof(Num), fSortFnc);
	qsort(sz2Num[1], D_ARRAY_MAX + 5, sizeof(Num), fSortFnc);

	// 使用数字の取得
	int li1UNo[D_COL_CNT];
	if (sz2Num[0][0].miVal == sz2Num[1][0].miVal) {		// 最大個数の値が一致

		// １番目と２番目の合計で比較
		int liSum1 = sz2Num[0][0].miCnt + sz2Num[1][1].miCnt;
		int liSum2 = sz2Num[1][0].miCnt + sz2Num[0][1].miCnt;
		if (liSum1 > liSum2) {
			li1UNo[0] = 0;
			li1UNo[1] = 1;
		}
		else {
			li1UNo[0] = 1;
			li1UNo[1] = 0;
		}

	}
	else {
		li1UNo[0] = 0;
		li1UNo[1] = 0;
	}

	// 変更数字の合計取得
	int liSum = 0;
	for (i = 0; i < D_COL_CNT; i++) {
		liSum -= sz2Num[i][li1UNo[i]].miCnt;
		for (j = 0; j < siNCnt / 2; j++) {
			liSum += sz2Num[i][j].miCnt;
		}
	}

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liSum);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 2352
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define sum(x) accumulate(all(x),0ll);
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cout<<#x<<"\n";  each(y,x) cout<<y<<" "; cout<<'\n';}
#define debug_vp(x) { cout<<#x<<"\n";  each(y,x) cout<<y.ff<<" "<<y.ss<<'\n'; cout<<'\n';}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<bool> vb;

int main(){
	fastio;
	int n,m;
	cin>>n>>m;
	vi a(n);
	rep(i,n)cin>>a[i];
	int tot=sum(a);
	int x=tot/(4*m)+(tot%(4*m)!=0);
	srt(a);
	rev(a);
	if(a[m-1]>=x){
		cout<<"Yes";
	} else {
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    string s;
    cin >> s;
    bool b=true;
    rep(i, s.length()-1){
        if (s[i+1]!='9') {
            b=false;
        }
    }
    ll sum = 0;
    if (b) {
        rep(i, s.size()) sum+=(int)s[i]-'0';
    }else{
        if (s[0]=='1') {
            rep(i, s.size()-1) sum+=9;
        }else{
            sum=((int)s[0]-'0') -1;
            rep(i, s.size()-1) sum+=9;
        }
    }
    pr(sum);
    return 0;
}


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



int main(void){
    int prime[101010] = {};
    for (int i = 2; i < 314; i++) {
        int t = i+i;
        while (t < 101010) {
            prime[t]--;
            t += i;
        }
    }
    //for (int i = 2; i < 100; i++) if (prime[i] == 0) cout << i << " ";
    
    int a, b, c;
    int d, e, f;
    while (cin >> a >> b >> c && a) {
        d = 0; e = 0; f = 0;
        for (int i = 2; i < a; i++) {
            if (prime[i] != 0) continue;
            for (int j = 2; j <= i; j++) {
                if (prime[j] != 0) continue;
                if (i*j > a) break;
                
                if ((float)j/i >= (float)b/c) {
                    if (i*j > d) {
                        d = i*j;
                        e = i;
                        f = j;
                    }
                }
            }
        }
        cout << f << " " << e << endl;
    }
}

Measured memory_bytes: 3468
N = int(input())
c = 0
flag = 0
for _ in range(N):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0

    if c == 3:
        flag = 1

if flag == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9168
n = int(input())
l_a = list(map(int, input().split()))
l_b = list(map(int, input().split()))

ans = 0
for a, _ in enumerate(l_b):
  if l_a[a] < l_b[a] :
    if l_a[a+1] <= l_b[a] - l_a[a]:
      ans += l_a[a] + l_a[a+1]
      l_a[a+1] = 0
    else:
      ans += l_a[a] + l_b[a] - l_a[a]
      l_a[a+1] -= l_b[a] - l_a[a]
  else:
    ans += l_b[a]
print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;

int main(){
  int N,L; cin>>N>>L;
  vector<int>a(N+1);
  for(int i=1;i<=N;i++){
    a[i]=i+L-1;
  }
  int sum=0;
  for(int i=1;i<=N;i++){
    sum+=a[i];
  }
  int ans=INF;
  for(int i=1;i<=N;i++){
    int num=sum-a[i];
    int sub=abs(sum-num);
    ans=min(sub,ans);
  }
  if(sum<0){
  cout<<sum+ans<<endl;
  }
  else{
    cout<<sum-ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

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

ll calc(ll a, ll b, ll p) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = calc(a, b/2, p);
        return (d * d) % p;
    } else {
        return (a * calc(a, b-1, p)) % p;
    }
}
     
int main()
{
    ll x, a, b; cin >> x >> a >> b;
    if (-a + b <= 0)
        cout << "delicious" << endl;
    else if (-a + b <= x)
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;

}


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

int main(){
  int a, b, c, x;
  scanf("%d %d %d", &a, &b, &c);
  bool flag = false;

  for(x = 1; x <= b; x++){//!
    if(a*x%b == c){
      flag = true;
      break;
    }
  }

  if(flag){
    printf("%s\n", "YES");
  } else {
    printf("%s\n", "NO");
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,ans=0,a,b;
int main()
{
	cin>>n;
	cin>>a;
	for(int i=1;i<=n-1;i++)
	{
		cin>>b;
		if(b<a) ans+=a-b;
		else a=b;
	}
	cout<<ans;
return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>

int main(){
  int N,L,i,j,sum=0,s,min=10000;
  scanf("%d %d",&N,&L);
  for(i=0;i<N;i++){  //元の味
    sum += L+i;
  }
    
  for(i=0;i<N;i++){
    int sum2=0;
    for(j=0;j<N;j++){
     if(i!=j)
       sum2 += L+j;
    }   //sum2ができた
     if(min>abs(sum-sum2)) {
       min=abs(sum-sum2);
     s=sum2 ;   //minになる特定のiを保管しておく
     }
  }
  printf("%d",s);
} 

Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B float64
	var X float64
	fmt.Scan(&X)

LBL1:
	for i := -118.0; i <= 119; i++ {
		for j := -118.0; j <= 119; j++ {
			if math.Pow(i, 5)-math.Pow(j, 5) == X {
				A = i
				B = j
				break LBL1
			}
		}
	}
	fmt.Println(A, B)
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int a[205000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin  >> N;
    for(int i = 1; i <= N; i++) cin >> a[i];
    int ans = 0;
    int idx = 0;
    for(int i = 1; i <= N; i++) {
        if(a[i] == idx + 1) idx++;
    }
    if(idx == 0) ans = -1;
    else ans = N - idx;
    cout << ans << endl;
    return 0;
}


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

signed main() {

  int a, b, c;
  cin >> a >> b >> c;
  cout << a+b+c << endl;

}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

const int SIZE = 1300;

int main() {
    int n, m;
    while(cin >> n >> m, n|m){
        int r; scanf("%d", &r);
        vector<array<int, SIZE>> v(m);
        for (int i = 0; i < r; ++i) {
            int t, p, q, s;
            scanf("%d %d %d %d", &t, &p, &q, &s);
            if(s){
                v[q-1][t-1]++;
            }else {
                v[q-1][t-1]--;
            }
        }
        for (int i = 0; i < m; ++i) {
            for (int j = 1; j < SIZE; ++j) {
                v[i][j] += v[i][j-1];
            }
        }
        int q;
        cin >> q;
        while(q--){
            int i, j, x;
            scanf("%d %d %d", &i, &j, &x);
            int ans = 0;
            for (int k = i-1; k < j-1; ++k) {
                if(v[x-1][k]) ans++;
            }
            cout << ans << "\n";
        }
    }
    return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

int32_t main(){
	fastio;
	cin>> n;
	vector<pii> pos(n);
	for(int i = 0; i<n; ++i){
		int x,y;
		cin>> x>> y;
		pos[i] = mp(x,y);
	}

	double ans = 0;
	for(int i = 0; i<n; ++i){
		for(int j = i+1; j< n; ++j){
			double x =(double) pos[i].f - pos[j].f;
			double y = (double) pos[i].s - pos[j].s;
			ans += sqrt(x*x + y*y)*2;
		}
	}
	ans /= n;
	cout<< fixed<< setprecision(10)<< ans << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(x, y):
    return (x*y)//gcd(x, y)

N = int(input())
a = list(map(int, input().split()))
lcm2 = 1
for i in range(N):
    lcm2 = lcm(a[i], lcm2)
lcm2 -= 1
f = 0
for i in range(N):
    f += lcm2%a[i]
print(f)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<char>s(3);
  for (int i = 0; i < 3; i++) cin >> s.at(i);
  
  int count = 0;
  for( int i = 0 ; i < 3; i++){
    if(s.at(i) == '1') count++;
  } 
  cout << count;
}

Measured memory_bytes: 256
Module _20190422

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim iNum() As String = sRead.Split(" ")

        '降順に並べるバブルソート
        For i As Integer = 0 To iNum.Length - 1

            For j As Integer = iNum.Length - 1 To i + 1 Step -1

                If iNum(j) > iNum(j - 1) Then

                    Dim iTemp As String = iNum(j)
                    iNum(j) = iNum(j - 1)
                    iNum(j - 1) = iTemp

                End If

            Next

        Next

        Console.WriteLine(CInt(iNum(0).ToString & iNum(1).ToString) + iNum(2))

    End Sub

End Module

Measured memory_bytes: 19792
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 2000005, Mod = 1e9 + 7;
int n, A[N], F[N];
inline int Power(int a, int b)
{
    int ret = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mod)
        if (b & 1) ret = 1LL * ret * a % Mod;
    return (ret);
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        scanf("%d", &A[i]);
        int a = A[i];
        for (int p = 2; p * p <= A[i]; p ++)
        {
            int cnt = 0;
            while (a % p == 0)
                a /= p, cnt ++;
            F[p] = max(F[p], cnt);
        }
        if (a > 1)
            F[a] = max(F[a], 1);
    }
    int tot = 1, SM = 0;
    for (int p = 2; p < N; p ++)
        if (F[p])
            tot = 1LL * tot * Power(p, F[p]) % Mod;
    for (int i = 1; i <= n; i ++)
        SM = (SM + 1LL * tot * Power(A[i], Mod - 2)) % Mod;
    printf("%d\n", SM);
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void solve()
{ll t,n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
  cin>>n>>m;
  vector<ll> val(n+1),wt(n+1);
  for(ll i=1;i<=n;i++)
  cin>>wt[i]>>val[i];
  ll v[n+1][m+1];
  memset(v,0,sizeof(v));
  for(ll i=1;i<=n;i++)
  {
  	for(ll j=1;j<=m;j++)
  	{
  		if(wt[i]>j)
  		v[i][j]=v[i-1][j];
  		else
  		v[i][j]=max(val[i]+v[i-1][j-wt[i]],v[i-1][j]);
	}
  }
  cout<<v[n][m];
}

int main()
{

ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl '\n'
#define int long long

const int N = 3005;
int cache[N][N][2];
int n, a[N];

int solve(int i, int j, int cur) {
	if(i > j) 
		return 0;
	int &ans = cache[i][j][cur];
	if(ans != -1) 
		return ans;
	if(cur) ans = min(solve(i+1, j, cur^1) - a[i], solve(i, j-1, cur^1) - a[j]);
	else	ans = max(solve(i+1, j, cur^1) + a[i], solve(i, j-1, cur^1) + a[j]);
	return ans; 
}

int32_t main()
{
	IOS;

	cin >> n;
	for(auto &it : a) cin >> it;
	memset(cache, -1, sizeof cache);
	cout << solve(0, n-1, 0) << endl;

	return 0;
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (auto& s : S) {
        cin >> s;
    }

    sort(S.begin(), S.end());
    string ans = "";
    for (string s : S) {
        ans += s;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int n, c, k;
	vector<int> ts;

	scanf("%d%d%d", &n, &c, &k);
	ts.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &ts[i]);
	sort(ts.begin(), ts.end());

	int it = 0;
	int ans = 0;

	while(it < n) {

		int lim = it + 1;
		while(lim < n && lim - it < c && ts[it] + k >= ts[lim])
			lim += 1;

		ans += 1;
		it = lim;
	}

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

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
constexpr int MOD = 998244353, MX = 200005;
int n, m, k;
ll fact[MX] = {1}, invf[MX], ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MOD;
	invf[n] =  exp(fact[n] ,MOD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MOD * invf[b] % MOD;}
int main(){
	scanf("%d%d%d", &n, &m, &k);
	setcomb(200000);
	rep(i,k+1) (ans += comb(n-1,i) * exp(m-1, n-i-1) % MOD * m) %= MOD;
	printf("%lld\n", ans);
}

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

int cnt[3];

int main() {
	int n, a, b; cin >> n >> a >> b;
  	for (int i=0;i<n;i++) {
    	int x; cin >> x;
      	if (x<=a) cnt[0]++; else if (x<=b) cnt[1]++; else cnt[2]++;
    }
  	cout << min(cnt[0], min(cnt[1], cnt[2])) << endl;
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll ans = 0;
	string s,t;
	cin>>s>>t;
	forn(i,3){
		if(s[i]==t[i])ans++;
	}
	cout<<ans<<"\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
  double R5,R10;
 
  while(cin >> R5 >> R10){
    if(R5 < 35.50 && R10 < 71.00){
      cout << "AAA" << endl;
    }
    else if(R5 < 37.50 && R10 < 77.00){
      cout << "AA" << endl;
    }
    else if(R5 < 40.00 && R10 < 83.00){
      cout << "A" << endl;
    }
    else if(R5 < 43.00 && R10 < 89.00){
      cout << "B" << endl;
    }
    else if(R5 < 50.00 && R10 < 105.00){
      cout << "C" << endl;
    }
    else if(R5 < 55.00 && R10 < 116.00){
      cout << "D" << endl; 
    }
    else if(R5 < 70.00 && R10 < 148.00){
      cout << "E" << endl;
    }
    else{
      cout << "NA" << endl;
    }
 
  }
  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 5e5 + 123;
const ll mod = 1e9 + 7;

ll a[N], dp[N];
int n;

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

	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	for(int i = 2;i <= n;i++){
		int x = i - 1, y = max(1, i - 2);
		dp[i] = min(dp[x] + abs(a[x] - a[i]), dp[y] + abs(a[y] - a[i]));
	}
	cout << dp[n];
}

Measured memory_bytes: 5120
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	int l[60];
	int i, j;
	int t1, t2;
	for(i=0;i<=n-1;i++){
		scanf("%d", &l[i]);
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n-2;j++){
			if(l[j]<l[j+1]){
				t1=l[j];
				t2=l[j+1];
				l[j]=t2;
				l[j+1]=t1;	
			}
		}
	}
	int sum=0;
	for(i=0;i<=k-1;i++){
		sum+=l[i];
	} 
	printf("%d", sum);
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<pair<int,long long>>> g(n);
    for (int i = 1; i < n; ++i) {
        int u,v;
        long long w;
        cin>>u>>v>>w;
        --u;--v;
        g[u].emplace_back(v,w);
        g[v].emplace_back(u,w);
    }
    vector<int> bwa(n,-1);
    queue<pair<int,long long>> q;
    bwa[0]=0;
    for(auto i:g[0]){
        q.push(i);
        bwa[i.first]=i.second%2;
    }
    while(!q.empty()){
        auto t=q.front();
        q.pop();
        for(auto i:g[t.first]){
            if(bwa[i.first]!=-1)continue;
            else {
                q.push(make_pair(i.first,t.second+i.second));
                bwa[i.first]=(t.second+i.second)%2;
            }
        }
    }
    for(auto i:bwa)cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 8320
import sys
from collections import defaultdict
from bisect import bisect_right

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

N = INT()
XYD = []
for _ in range(N):
    x, y, d = input().split()
    x = int(x)
    y = int(y)
    if d == 'U':
        XYD.append([x, y, 0])
    elif d == 'R':
        XYD.append([x, y, 1])
    elif d == 'D':
        XYD.append([x, y, 2])
    else:
        XYD.append([x, y, 3])

DX = defaultdict(list)
DY = defaultdict(list)
for x, y, d in XYD:
    if d == 0:
        DX[x].append((y, 0))
    elif d == 1:
        DY[y].append((x, 0))
    elif d == 2:
        DX[x].append((y, 1))
    else:
        DY[y].append((x, 1))

ans = INF
for li in DX.values():
    li.sort()
    mxl = -1
    for y, d in li:
        if d == 0:
            mxl = y
        elif d == 1 and mxl != -1:
            ans = min(ans, (y-mxl) * 10 // 2)
for li in DY.values():
    li.sort()
    mxl = -1
    for x, d in li:
        if d == 0:
            mxl = x
        elif d == 1 and mxl != -1:
            ans = min(ans, (x-mxl) * 10 // 2)

for d1 in range(4):
    d2 = (d1+1) % 4
    D = defaultdict(list)
    for x, y, d in XYD:
        if d == d1:
            D[x+y].append(y)
    for k in D.keys():
        D[k].append(-INF)
        D[k].sort()
    for x, y, d in XYD:
        if d == d2:
            xy = x + y
            if xy in D:
                idx = bisect_right(D[xy], y) - 1
                if D[xy][idx] != -INF:
                    y2 = D[xy][idx]
                    x2 = xy - y2
                    ans = min(ans, (abs(x-x2)+abs(y-y2)) * 10 // 2)
    if d1 % 2 == 0:
        for i in range(N):
            XYD[i][0] *= -1
    else:
        for i in range(N):
            XYD[i][1] *= -1
if ans == INF:
    print('SAFE')
else:
    print(ans)


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

long long make_XOR(long long N) {
	if (N % 4 == 1) return 1;
	else if (N % 4 == 3) return 0;
	else if (N % 4 == 0) {
		return N;
	}
	else {
		long long div;
		div = N / 4;
		return div * 4 + 3;
	}
}

int main() {
	long long A, B; cin >> A >> B;
	long long XOR_A, XOR_B;
	if(A!=0) XOR_A = make_XOR(A - 1);
    else XOR_A=0;
	XOR_B = make_XOR(B);
   long long ans=XOR_A^XOR_B;
	cout <<ans << endl;
}


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


def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    求解処理.

    Args:\n
        N (int): 整数
    """
    # 求解処理
    ans = ""
    while N > 0:
        N -= 1
        ans += chr(ord("a") + N % 26)
        N //= 26
    ans = ans[::-1]

    # 結果出力
    print(ans)


if __name__ == "__main__":
    N = get_input()
    main(N)


Measured memory_bytes: 9088
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

//変数
ll N;
string S;

//解法
void solve() {

	ll ans = 0;

	rep(i, S.size()) {
		if (S[i] == 'R') {
			ans++;
		}
		else {
			ans--;
		}
	}

	if (ans > 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return;
}

int main() {

	//入力
	cin >> N >> S;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[10]= {111,222,333,444,555,666,777,888,999};
    map<int,int>mp;
    int b;
    cin>>b;
    for(int i=0; i<9; i++)
    {
        mp[arr[i]]++;
    }
    if(mp[b])
        cout<<b<<endl;
    else
    {
        for(int i=0; i<9; i++)
        {
            if(arr[i]<b && arr[i+1]>b)
            {
                cout<<arr[i+1]<<endl;
                return 0;
            }
            else if(b<110)
            {
                cout<<"111"<<endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a[3];
   cin>>a[0]>>a[1]>>a[2];
   sort(a,a+3);
   if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#define X(V,N)(0<=V+D[d][N]*z[j]&&V+D[d][N]*z[j]<n)
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[7][7][7],z[2];main(n,m,p,I,x,y,i,j,c,d){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,0,sizeof(M)),c=1,I=0;I<p;c*=-1){
		scanf("%d%d",&x,&y),x--,y--,I++;
		for(i=0;;i++)if(!M[x][y][i]){M[x][y][i]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(z[j]=0;z[j]<m;z[j]+=2*j-1)if(!X(x,0)||!X(y,1)||!X(i,2)||M[x+D[d][0]*z[j]][y+D[d][1]*z[j]][i+D[d][2]*z[j]]!=c)break;
			if(z[1]-z[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
			
	}
	puts("Draw");
next:
	for(;I<p;I++)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    vector<vector<int>> aa(w,vector<int>(h));
    rep(i,h){
        rep(j,w) {
            if (j<a) aa.at(j).at(i)=1;
            else aa.at(j).at(i)=0;
            if (i>=b) aa.at(j).at(i)=1-aa.at(j).at(i);
        }
    }
    rep(i,h){
        rep(j,w) cout << aa.at(j).at(i);
        cout << endl;
    }
}


Measured memory_bytes: 5120
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var Ai, max, min int64 = 0, 0, 0x7FFFFFFFFFFFFFFF
	for i := 0; i < N; i++ {
		fmt.Scan(&Ai)
		if max < Ai {
			max = Ai
		}
		if min > Ai {
			min = Ai
		}
	}
	fmt.Println(max - min)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
ll mod = 1e18;
map<ll, ll> ma;
void de(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		while (n != i) {
			if (n%i == 0) {
				ma[i]++;
				n /= i;
			}
			else {
				break;
			}
		}
	}
	ma[n]++;
}
void solve() {

	ll n;
	string s;
	cin >> n >> s;
	ll z = s[0]-'0';
	ll x = (s[2] - '0') * 10 + (s[3] - '0');
	ll q = n*z;
	n *= x;
	n /= 100;
	n += q;
	cout << n << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int i4 = 0; i4 <= N; i4++) {
                for (int i7 = 0; i7 <= N; i7++) {
                    if (i4 * 4 + i7 * 7 == N) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
import java.util.*;

public class Main {
	private static Integer fuctorial( Integer num , Integer fuc){
		if( fuc == 1 ) {
			return num;
		}
		return num * fuctorial( num, (fuc - 1) );
	}
	
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String sdata = sc.next();
	    try{
	       Integer idata = Integer.parseInt(sdata);
	       System.out.println(fuctorial(idata, 3));
	    } catch (Exception e) {
	    	
	    }
	}
}


Measured memory_bytes: 26144
#include<cstdio>
const int MaxN=200010;
int N,L,A[MaxN],ch[MaxN][2],stk[MaxN];
struct List{
	int*s,*t,*a,*b,n,sum,sumL;
	void reb(){
		if(!n)n++;
		int*ns=new int[n*3+1];
		if(s)for(int i=1;i<=n;i++)ns[n+i]=a[i];
		a=ns+n;t=a+n*2;b=a+(s?n:--n);s=ns;
	}
	int get(int i){return i>0&&i<=b-a?a[i]:0;}
	void pb(int x){
		if(!s||b==t)reb();*++b=x;
		if(++n>=L-1)sumL+=x;sum+=x;
	}
	void pf(int x){
		if(!s||a==s)reb();*a--=x;
		++n;sum+=x;sumL+=get(L-1);
	}
}V[MaxN][2];
bool fail[MaxN][2];
List mer(List l1,List l2,bool ty=0){
	if(l1.n>l2.n)return mer(l2,l1,1);
	ty?l2.pb(1):l2.pf(1);
	if(ty)for(int i=1;i<=l1.n;i++)l2.pb(l1.a[i]);
	else for(int i=l1.n;i;i--)l2.pf(l1.a[i]);
	return l2;
}
List cont(List l,int d){
	while(d--&&l.n){
		List nl=(List){0,0,0,0,0,0,0};
		for(int i=L;i<=l.n;i+=L){
			int x=0;
			for(int j=0;j<L;j++)x+=l.get(i+j);
			nl.pb(x);
		}
		l=nl;
	}
	return l;
}
long long qry(List&l1,List&l2){
	if(l1.n>l2.n)return qry(l2,l1);
	long long s=0;
	int tmp=l2.sumL;
	for(int i=1;i<=l1.n&&i<L-1;i++)s+=1ll*l1.get(i)*(tmp+=l2.get(L-i-1));
	return s+1ll*l1.sumL*l2.sum;
}
long long dfs(int o){
	long long s=1;
	for(int c=0,x;c<2;c++)if(x=ch[o][c]){
		s+=dfs(x);
		for(int t=0;t<2;t++)V[x][t]=cont(V[x][t],A[o]-A[x]);
		s+=V[x][!c].sumL;
	}
	s+=qry(V[ch[o][0]][1],V[ch[o][1]][0]);
	for(int c=0,x,y;c<2;c++){
		if((x=ch[o][c])&&!V[x][c].n||fail[x][c])fail[o][c]=1,V[o][c]=V[x][c];
		else y=ch[o][!c],fail[o][c]=y&&!V[y][c].n||fail[y][c],V[o][c]=mer(V[x][c],V[y][c]);
	}
	return s;
}
int main(){
	scanf("%d%d",&N,&L);
	int*top=stk;
	for(int i=1;i<=N;i++){
		scanf("%d",A+i);
		for(;top>stk&&A[*top]<A[i];top--)
			ch[i][0]=ch[top[-1]][1]=*top;
		*++top=i;
	}
	for(;top>stk;top--)ch[top[-1]][1]=*top;
	printf("%lld\n",dfs(stk[1]));
}

Measured memory_bytes: 46208
max_n = 100000

N = int(input())

dp = [N for _ in range(N+1)]
dp[0] = 0
for n in range(1, N+1):
    for pow6 in range(n+1):
        if 6 ** pow6 <= n:
            dp[n] = min(dp[n], dp[n - 6 ** pow6] + 1)
        else:
            break

    for pow9 in range(n+1):
        if 9 ** pow9 <= n:
            dp[n] = min(dp[n], dp[n - 9 ** pow9] + 1)
        else:
            break
print(dp[N])


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int cnt = 0;
    for (int i = 0; i < N; i += 2) {
        if (A[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 1e18;
vector<int> g[N];

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
       string s;
       cin>>s;
       int n=s.length();
       n--;
       while(n--)
       {
           if(n&1)continue;
           else
           {
               int x=n/2;
               string s1=s.substr(0,x);
               string s2=s.substr(x,x);
               if(s1==s2)
               {
                   cout<<n<<"\n";
                   break;
               }
           }
       }

       
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A - 2 * B > 0)
    {
        cout << A - 2 * B << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int, input().split())
price = {X:A, Y:B}

ans = min(
	2*C*max(X,Y),
	A*X + B*Y,
	price[max(X,Y)]*(max(X,Y)-min(X,Y)) + 2*C*min(X,Y),
)

print(ans)

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

int main(void){
    int n , x[1001] , y[1001] ;
    int i ;
    double p1 , p2 , p3 , p4 ;
    
    
    scanf("%d" , &n) ;
    for(i = 0 ; i < n ; i++){
        scanf("%d" , &x[i]) ;
    }
    for(i = 0 ; i < n ; i++){
        scanf("%d" , &y[i]) ;
    }
    
    //p == 1
    double ans1 = 0 , f1 ;
    for(i = 0 ; i < n ; i++){
        f1 = fabs((x[i] - y[i])) ;
        ans1 += f1 ;
    }
    printf("%f\n" , ans1) ;
    
    //p == 2
    double ans2 = 0 , f2 ;
    for(i = 0 ; i < n ; i++){
        f2 = fabs((x[i] - y[i])) ;
        f2 = pow(f2 , 2);
        ans2 += f2 ;
    }
    ans2 = sqrt(ans2) ;
    printf("%f\n" , ans2) ;
    
    //p == 3
    double ans3 = 0 , f3 ;
    for(i = 0 ; i < n ; i++){
        f3 = fabs((x[i] - y[i])) ;
        f3 = pow(f3 , 3) ;
        ans3 += f3 ;
    }
    ans3 = pow(ans3 , (1.0 / 3)) ;
    printf("%f\n" , ans3) ;
    
    //p == endless
    double max = 0 , ans4 ;
    for(i = 0 ; i < n ; i++){
        if(max < fabs((x[i] - y[i]))){
            max = fabs(x[i] - y[i]) ;
        }
    }
    ans4 = max ;
    printf("%f\n" , ans4) ;
    
    return 0 ;
}


Measured memory_bytes: 2108
#include <stdio.h>

int search(int A[],int n,int key){
	int i;
	for(i=0;i<n;i++){
		if(key == A[i]){
			return 0;
		}
	}
return -1;
}
	
int main(void){

	int i,A[10000],n,q,key,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(search(A, n, key) == 0){
			sum++;
		}
	}

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



Measured memory_bytes: 2088