akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
INF = 10**9

n = int(input())
a = np.array([list(map(int, input().split())) for _ in range(n)])
a_opt = floyd_warshall(a)
# for i in range(n): print(a[i], a_opt[i])

for i in range(n):
    a[i][i] = INF
    
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if a_opt[i][j] < a[i][j]:
            print(-1)
            exit()
        else:
            d = a[i][j]
            if d < np.min(a[i]+a[j]):
                ans += d
                
            # Straight solution, but TLE in python
            # for k in range(n):
            #     if k in [i, j]:
            #         continue
            #     elif a[i][k]+a[k][j] == d:
            #         d = 0
            # ans += d
print(ans)


Measured memory_bytes: 18020
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range (1,n-1):
  if p[i] <= p[i-1] and p[i] > p[i+1]:
    cnt += 1
  if p[i] <= p[i+1] and p[i] > p[i-1]:
    cnt += 1
print(cnt)

Measured memory_bytes: 9096
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 50516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A, B, N; cin >> A >> B >> N;
    ll i;
    if (N >= B-1) i = B-1;
    else i = N;
    cout << (A*i/B) - A * (i/B) << '\n';
}



Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>

int main(void){
  char input[100] = "";

  scanf("%s\n",input);

  int length = strlen(input);

  for(int i = 0;i<length; i++){
    if (i % 2 == 0) { //奇数
      if (input[i]=='R' || input[i] == 'U' || input[i] == 'D') {
      }else{
        printf("No\n");
        return 0;
      }
    }else {//偶数
      if (input[i] == 'L' || input[i] == 'U' || input[i] == 'D') {
      }else{
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始

int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i = 0; i < s.length(); i++){
        // cout<<s[i]-'A'<<endl;
        cout<<(char)((s[i]-'A'+n)%26+'A');
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    int length;     cin >> length;

    int height[1000000], answer = 0, fanswer = 0;
    cin >> height[0];
    for (int i = 1; i < length; i++){
        cin >> height[i];
        if (height[i] <= height[i-1]){
            answer++;
        }
        else {
            answer = 0;
        }

        if (answer > fanswer){
            fanswer = answer;
        }
    }

    cout << fanswer << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef pair<int,int> P;
const int INF = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    int sum = 0;
    rep(i,k){
        sum += p.at(i);
    }
    cout << sum;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define debug 1

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int a,b;
	cin>>a>>b;
	if((a+b) % 2==0) cout<<(a+b)/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> a(N), b(N);
    rep (i, N) {
        cin >> a[i];
    }
    rep (i, N) {
        cin >> b[i];
    }

    ll cnt = 0;
    rep (i, N) {
        if (a[i] < b[i]) {
            cnt += (b[i]-a[i])/2;
        } else {
            cnt -= (a[i]-b[i]);
        }
    }

    if (cnt < 0) {
        No;
    } else {
        Yes;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int>X(3);
  for(int i=0;i<3;i++){cin>>X.at(i);}
  sort(X.begin(),X.end());
  int M;
  if((3*X.at(2)-(X.at(0)+X.at(1)+X.at(2)))%2!=0){
   cout<<(3*(X.at(2)+1)-(X.at(0)+X.at(1)+X.at(2)))/2<<endl;}
   else {cout<<(3*X.at(2)-(X.at(0)+X.at(1)+X.at(2)))/2<<endl;}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

int N; cin >> N;
VI A(N); invec(A);

multiset<i64> s;

rep(i, 0, N){
    i64 now = A[i];
    multiset<i64>::iterator it = s.lower_bound(now);
    if (it != s.begin()) s.erase(--it);
    s.insert(now);
}
cout << s.size() << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

struct UnionFind {
    vector<int> parent;
    
    UnionFind(int n) : parent(n, -1) { }
    void init(int n) { parent.assign(n, -1); }
    
    int root(int x) {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y); // merge technique
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
    
    int size(int x) {
        return -parent[root(x)];
    }
};
 
int main(){
    long long N,M;
    cin >> N >> M;
    vector<pair<int,int>> B(M);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        B[i] = make_pair(a,b);
    }

    UnionFind U(N);
    long long ans = N * (N-1) / 2;
    vector<long long> res;
    for(int i=M-1;0<=i;i--){
        res.emplace_back(ans);
        if(U.issame(B[i].first,B[i].second)) continue;
        long long N1 = U.size(B[i].first);
        long long N2 = U.size(B[i].second);
        ans -= N1 * N2;
        U.merge(B[i].first,B[i].second);
    }
    for(int i=res.size()-1;0<=i;i--) cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 3444
N=int(input())
if len(str(N))==1:
    print(N)
elif len(str(N))==2:
    print(9)
elif len(str(N))==3:
    print(N-90)
elif len(str(N))==4:
    print(909)
elif len(str(N))==5:
    print(N-9090)
else:
    print(90909)

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

const int INF = 1e9;

struct SegTree {
	int n;
	vector<pair<int, int>> t;

	SegTree(int n) : n(n), t(4 * n, make_pair(INF, -1)) {}

	void update(int p, int x) {
		update_(0, 0, n, p, x);
	}

	pair<int, int> query(int l, int r) {
		return query_(0, 0, n, l, r);
	}

private:
	void update_(int v, int l, int r, int p, int x) {
		if (l + 1 == r) {
			t[v] = make_pair(x, p);
			return;
		}
		int m = (l + r) / 2;
		if (p < m)
			update_(v * 2 + 1, l, m, p, x);
		else
			update_(v * 2 + 2, m, r, p, x);
		t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
	}

	pair<int, int> query_(int v, int l, int r, int ql, int qr) {
		if (ql >= qr) {
			return make_pair(INF, -1);
		}
		if (l == ql && r == qr) {
			return t[v];
		}
		int m = (l + r) / 2;
		auto xl = query_(v * 2 + 1, l, m, ql, min(qr, m));
		auto xr = query_(v * 2 + 2, m, r, max(ql, m), qr);
		return min(xl, xr);
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	SegTree t(n + 1);
	t.update(n, 0);
	vector<int> ans(n + 1, -1);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '1') {
			continue;
		}
		pair<int, int> b = t.query(i + 1, min(i + m + 1, n + 1));
		if (b.first != INF) {
			t.update(i, b.first + 1);
			ans[i] = b.second;
		}
	}
	if (ans[0] == -1) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < n; i = ans[i]) {
		cout << ans[i] - i << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4224
from sys import stdin
input = stdin.buffer.readline

def main():
    n, m = map(int, input().split())

    yp = [(0, 0)] * m
    for i in range(m):
        p, y = map(int, input().split())
        yp[i] = (y, p-1, i)

    yp.sort(key=lambda x: x[0])

    ans = [('', '')] * m
    cnt = [1] * n
    for y, p, i in yp:
        ans[i] = (str(p+1), str(cnt[p]))
        cnt[p] += 1

    for i, j in ans:
        print('0' * (6 - len(i)) + i + '0' * (6 - len(j)) + j)

main()

Measured memory_bytes: 99764
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   ll n, k;
   cin >> n >> k;
   ll ans = n % k;
   ans = min(ans, abs((ans - k) % k)); 
   cout << ans << endl;
   return 0;
}

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

ll solve() {
    ll H, W , N;
    cin >> H >> W >> N;
    if ( H > W ) {
        return (N+H-1)/H;
    } else {
        return (N+W-1)/W;
    }
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    set<int> S(begin(A), end(A));
    if (S.size() == N) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 10368
def frog(H):
    n = len(H)
    cost = 0
    n_2 = 0
    n_1 = 0
    for i in range(n):
        if i >= 1:
            cost = abs(H[i] - H[i - 1]) + n_1
            if i >= 2:
                cost = min(cost, abs(H[i] - H[i - 2]) + n_2)
        n_2 = n_1
        n_1 = cost
    return cost

assert frog([10, 10, 10]) == 0
assert frog([10, 10]) == 0
assert frog([10, 30, 40, 20]) == 30
assert frog([30, 10, 60, 10, 60, 50]) == 40

n = int(input())
H = list(map(int, input().split()))
ans = frog(H)
print(ans)


Measured memory_bytes: 13908
n,m=map(int,input().split())
a=0
for i in range(1,int(m**0.5)+1):
    if m%i==0 and m//i>=n:
        a=max(a,i)
    if m%i==0 and i>=n:
        a=max(a,m//i)
print(a)

Measured memory_bytes: 38640
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d", &a, &b);
    if(a < b){
        printf("a < b\n");
    }
    if(a > b){
        printf("a > b\n");
    }
    if(a == b){
        printf("a == b\n");
    }
    return 0;
}
    



Measured memory_bytes: 2032
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
ll dp[100001],w[101],v[101];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,W,i,j;
	int T=0;
	cin>>n>>W;
	for(i=1;i<=n;++i) cin>>w[i]>>v[i],T+=v[i];
	memset(dp,63,sizeof(dp));
	dp[0]=0;
	for(i=1;i<=n;++i) for(j=T;j>=v[i];--j) dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	for(i=T;i>=0;--i) if(dp[i]<=W){
		cout<<i<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

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

#print(a)

gu = 0
ki = 0
for i in range(n):
	if a[i]%2==0:
		gu = gu + 1
	else:
		ki = ki + 1

#print(gu,ki)

if ki==0:
	if p==1:
		print(0)
		exit()
	elif p==0:
		print(int(2**n))
		exit()

ans = 2**gu * (2**ki)/2
print(int(ans))




Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

int main()
{
    Fast;

    ll a,b,i;
    cin>>a>>b;
    for(i=b-a+1;i<=b+a-1;i++)
        cout<<i<<" ";
}

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

int main() {
  int K;
  cin>>K;
  int ans=0;
  for(int a=1;a<K+1;a++){
    for(int b=1;b<K+1;b++){
      for(int c=1;c<K+1;c++){
        int i=min((a,b),c);
        for(i;i>0;i--){
          if(a%i==0 && b%i==0 && c%i==0){
            ans+=i;
            break;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

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

int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	int a, b;
	
	cin >> a >> b;
	cout << gcd(a, b) << endl;

	return 0;
}



Measured memory_bytes: 3112
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let x: u32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut mv = vec![0u32; n];
    for i in 0..n {
        mv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }
    let sum_m = mv.iter().sum::<u32>();
    let min_m = mv.iter().min().unwrap();
    let ans = n as u32 + (x - sum_m) / min_m;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>

using namespace std;
int main(void)
{
	int n,x,i;
	int m[1000];
	n=0; x=0;
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&m[i]);
		x-=m[i];
	}
	sort(m,m+n);
	x=x/m[0];
	printf("%d\n",n+x);
}	
	

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EPS 1e-9
#define PI acos(-1)
using namespace std;
typedef long long ll;
const int maxn = 1e5+100;
const int mod = 1e9+7;
int a[maxn];
int vis[maxn];
ll f1[maxn],f2[maxn];

ll quick(ll x,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n%2==1)
        {
            ans=(ans*x)%mod;
        }
        n/=2;
        x=x*x%mod;
    }
    return ans;
}


void init()
{
    f1[1] = 1,f2[1] = 1,f1[0] = 1,f2[0] = 1;
    for(int i=2; i<=100005; i++)
    {
        f1[i]=(f1[i-1]*i)%mod;
        ll num =quick(i,mod-2);
        f2[i]=(f2[i-1]*num)%mod;
    }
}
ll C(ll n,ll m)
{
    return f1[n]*f2[n-m]%mod*f2[m]%mod;
}

int main()
{
    init();
    int n;
    cin>>n;
    int tmp;
    for(int i = 1; i <= n+1; i++)
    {
        cin>>a[i];
        if(vis[a[i]])
        {
            tmp = i-vis[a[i]];
        }
        else vis[a[i]] = i;
    }
    cout<<n<<endl;
    for(int i = 2; i <= n+1; i++)
    {
        ll div = 0;
        ll ans = C(n+1,i);
        if(n-tmp>=i-1)
            div = C(n-tmp,i-1);
        cout<<(ans-div+mod)%mod<<"\n";
    }
}


Measured memory_bytes: 3584
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a;
    string s;
    cin >> a >> s;
    cout << (a < 3200 ? "red" : s);
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    color = [0]*N
    color[0] = 1
    q = deque([0])
    
    while q:
        v = q.popleft()
        
        for nv in G[v]:
            if color[nv]==0:
                color[nv] = -color[v]
                q.append(nv)
    
    return color

N = int(input())
G = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

n = [0, 0, 0]

for i in range(1, N+1):
    n[i%3] += 1
    
color = bfs()
b = color.count(1)

if b>N-b:
    for i in range(N):
        color[i] *= -1
        
ans = [-1]*N

if min(b, N-b)<=n[0]:
    q = deque([i for i in range(1, N+1) if i%3==0]+[i for i in range(1, N+1) if i%3!=0])
else:
    q = deque([i for i in range(1, N+1) if i%3==1]+[i for i in range(1, N+1) if i%3==0]+[i for i in range(1, N+1) if i%3==2])

for i in range(N):
    if color[i]==1:
        ans[i] = q.popleft()
        
for i in range(N):
    if color[i]==-1:
        ans[i] = q.popleft()

print(*ans)

Measured memory_bytes: 129596
/* 
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int    int64_t
const int M = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
  //#endif
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
int v[6][100];
int c , x , y , buf , n;
string ans;
bool fit = false;
int count = 0;
cin >> n;
for(int i = 0; i <n; i++){
for(int j = 0; j <6; j++){
  cin >> v[j][i];
}
}
x=0;
for(int h = 0; h < n; h++){
x=h;
y= x + 1;

while(count <= 10000){

c =  rand()%4 ;

switch(c){
            case 0:{
                buf = v[0][x];
                v[0][x] = v[1][x];
                v[1][x] = v[5][x];
                v[5][x] = v[4][x];
                v[4][x] = buf;
                break;
            }
            case 1:{
                buf = v[0][x];
                v[0][x] = v[3][x];
                v[3][x] = v[5][x];
                v[5][x] = v[2][x];
                v[2][x] = buf;
                break;
            }
            case 2:{
                buf = v[0][x];
                v[0][x] = v[2][x];
                v[2][x] = v[5][x];
                v[5][x] = v[3][x];
                v[3][x] = buf;
                break;
            }
            case 3:{
                buf = v[0][x];
                v[0][x] = v[4][x];
                v[4][x] = v[5][x];
                v[5][x] = v[1][x];
                v[1][x] = buf;
                break;
            }
}//switch

for(int k = y; k < n; k++){
  if(v[0][x] == v[0][k] && 
  v[1][x] == v[1][k] && 
  v[2][x] == v[2][k] &&  
  v[3][x] == v[3][k] && 
  v[4][x] == v[4][k] &&
  v[5][x] == v[5][k] ){
    fit = true;
    break;
}//if(v[][])
}//if(k)

count++;
}//while
}//for(h)

if(fit == false){
  ans = "Yes";
}else if(fit == true){
  ans = "No";
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3200
import sys
from bisect import bisect_left
from itertools import product

input = sys.stdin.readline
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]

for _ in range(Q):
    x = int(input())

    i = bisect_left(s, x)
    if i == 0:
        si = [i]
    elif i == A:
        si = [i - 1]
    else:
        si = [i - 1, i]

    j = bisect_left(t, x)
    if j == 0:
        tj = [j]
    elif j == B:
        tj = [j - 1]
    else:
        tj = [j - 1, j]

    ans = float('inf')
    for i, j in product(si, tj):
        ds = x - s[i]
        dt = x - t[j]
        if ds * dt > 0:
            d = max(abs(ds), abs(dt))
        else:
            ds, dt = abs(ds), abs(dt)
            if ds < dt:
                d = 2 * ds + dt
            else:
                d = ds + 2 * dt
        ans = min(ans, d)
    print(ans)


Measured memory_bytes: 12220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = "Yes";
		String[] ch = s.split("");
		for (int i = 0; i < ch.length; i++) {
			if (!(i % 2 == 0 && (ch[i].equals("R") || ch[i].equals("U") || ch[i].equals("D")))
					&&!(i % 2 == 1 && (ch[i].equals("L") || ch[i].equals("U") || ch[i].equals("D"))))
				ans = "No";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
a,b = map(int, input().split())

ret = 0

for i in range(1,a+1): # 1,2,...,a
	tmp = 1 / a #float
	now = i
	while now < b:
		now *= 2
		tmp /= 2
	ret += tmp

# print(ret)
print("{:.12f}".format(ret))

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int a[30] , b[30] ;
int n ;

inline int calc ( int x )
{
    int X=0 , Y=0 , i=1 ;
    while ( x ) 
    {
        if ( x&1 ) X+=a[i],Y+=b[i];
        x>>=1,i++;
    }
    return X-Y;
}

int main ()
{
    int i , ans=0 ;
    scanf("%d",&n);
    for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
    for ( i=1 ; i<=n ; i++ ) scanf("%d",b+i);
    for ( i=1 ; i<(1<<n) ; i++ ) ans=max(ans,calc(i));
    printf("%d\n",ans);
    return 0 ;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, ans int
	Fscan(in, &n, &m)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Ints(a)
	minSum := sort.Search(2e5+1, func(s int) bool {
		c := 0
		for i := n - 1; i >= 0; i-- {
			j := sort.SearchInts(a, s-a[i])
			c += n - j
		}
		return c < m
	}) - 1
	s := make([]int, n+1)
	for i, v := range a {
		s[i+1] = s[i] + v
	}
	for _, v := range a {
		j := sort.SearchInts(a, minSum-v+1)
		ans += s[n] - s[j] + (n-j)*v
		m -= n - j
	}
	ans += m * minSum
	Fprint(_w, ans)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    long long int a,b,c;
    cin >> a >> b >>c;
    int count = 0;
    if(a==b){
        cout << c <<endl;
    }else if(a<b){
        cout << c <<endl;
    }else{
        for(int i=1; i<100000; i++){
            if(b*i>=a){
                count = i;
                break;
            }
        }
        cout << count*c <<endl;
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(),x.end()
ll mob=1000000007;
using namespace std;
int main()
{ 
int n,m;
cin>>n>>m;
ll h[n];
map<int,vector<ll>> g;
FOR(i,n)cin>>h[i];
FOR(i,n)
{
    g[i].push_back(0);
}
FOR(i,m)
{ int s,d;
  cin>>s>>d;
    g[s-1].push_back(h[d-1]);
    g[d-1].push_back(h[s-1]);
}
int r=0;
for(auto it:g)
{
   sort(all(it.second));
   if(h[it.first]>it.second.back())
   {
       r++;
   }
}
cout<<r;

return 0;
}











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

int main()
{
    int n=0;
    cin>>n;
    int array[n];
        for(int i=0;i<n;i++) {
            cin>>array[i];
        }
        for(int j=n-1;j>=0;--j){
            cout<<array[j];
            if(j>0) cout<<" ";
            else break;
        }
    cout<<endl;
    return 0;
}

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

import sys
import numpy as np
from operator import itemgetter

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

N, T = MAP()
AB = []
for i in range(N):
    a, b = MAP()
    AB.append((a, b))

# 各料理を時間の昇順でソート
AB.sort(key=itemgetter(1), reverse=True)
AB.sort(key=itemgetter(0))

# 後は普通のナップザック
TMAX = 6007
dp = np.zeros((N+1, TMAX), dtype=np.int64)
for i in range(N):
    a, b = AB[i]
    dp[i+1] = dp[i]
    dp[i+1,a:a+T] = np.maximum(dp[i+1,a:a+T], dp[i,:T] + b)
print(dp[N].max())


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

int main() {
    int n, m;
    cin >> n >> m;
    int k = (n + 1) / 2;
    for(int i = 0; i < m; i++) {
        if(i & 1)
            cout << (k + i / 2) % n + 1 << ' ' << (k - i / 2 - 2 + n) % n + 1
                 << '\n';
        else
            cout << (n - i / 2 - 1) % n + 1 << ' ' << i / 2 + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3564
import queue

h, w = map(int, input().split())
s = '#'*(w+2)
for _ in range(h):
    s += '#' + input() + '#'
s += '#'*(w+2)

def bfs():
    step = [0]*(w+2)*(h+2)
    step[w+2+1] = 1
    q = queue.Queue()
    q.put(w+3)
    while not q.empty():
        x = q.get()
        for i in (1, -1, w+2, -w-2):
            if s[x+i] == '#':
                continue
            if x+i == (w+2)*(h+1) - 2:
                step[x+i] = step[x] + 1
                return step[x+i]
            if step[x+i] == 0:
                step[x+i] = step[x] + 1
                q.put(x+i)
    print(-1)
    exit()

count = 0
for j in range((w+2)*(h+2)):
    if s[j] == '.':
        count += 1

print(count - bfs())

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


void solve(long long A, long long B, long long K){
  int loop = min(A, B);
  int order = 0;
  for(int i = loop; i > 0; --i){
    if(A % i == 0 && B % i == 0){
      ++order;
      if(order == K){
        cout << i << endl;
        return;
      }
    }
  }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	string S;
	cin>>S;
	int MA=0;
	rep(i,N-1){
		int same=0;
		for(int j='a';j<='z';j++){
            int x=0,y=0;
			for(int k=0;k<=i;k++){
				if(S[k]==j)x=1;
			}
			for(int k=i+1;k<N;k++){
				if(S[k]==j)y=1;
			}
			same+=x*y;
		}
		MA=max(MA,same);
	}
	cout<<MA;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]

total = 0
top = sum(range(n-k+2, n+1))
bottom = sum(range(k-1))
for i in range(k, n+2):
  top += n - i + 1
  bottom += i - 1
  total += top - bottom + 1
  
print(total % (10**9 + 7))

Measured memory_bytes: 67180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);

int main() {
    ll a,b,x; cin >> a >> b >> x;

    ll min;
    if(a==0) min=-1;
    else min=(a-1)/x;
    ll max = (b)/x;
    ll out = max-min;
    cout << out << endl;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	a = input()
    
	W = [0]*(N+1)
	E = [0]*(N+1)
	for i in range(N):
		if a[i] == 'W':
			W[i+1] = W[i] + 1
			E[i+1] = E[i]
		else:
			W[i+1] = W[i]
			E[i+1] = E[i] + 1
	E_max = E[-1]
	n_min = N
	for i in range(N):
		t = W[i] + E_max - E[i+1]
		if t < n_min:
			n_min = t
	print (n_min)
main()

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

struct P {
  int x, y;
  P(){}
  P(int x, int y):x(x), y(y){}
  bool operator == (const P &p) const {
    return x == p.x && y == p.y;
  }
  bool operator < (const P &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
};

P min(P p, P q) {
  return p < q ? p : q;
}

int W, H, N;
P ip, op;

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

bool wall[55][55][55][55];

bool in(int y, int x) {
  return 0<=y&&y<H&&0<=x&&x<W;
}

int bfs() {
  queue<P> que;
  int dist[55][55];
  memset(dist, -1, sizeof(dist));
  que.emplace(ip);
  dist[ip.y][ip.x] = 0;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    //cout << p.x << " " << p.y << ":"<< dist[p.y][p.x]<<endl; 
    if(p == op) break;   
    for(int i = 0; i < 4; i++) {
      int ny = p.y+dy[i], nx = p.x+dx[i];
      if(!in(ny, nx)) continue;
      if(dist[ny][nx] != -1) continue;
      if((i == 0 && !wall[ny][nx][ny][nx+1]) ||
	 (i == 1 && !wall[ny][nx][ny+1][nx]) ||
	 (i == 2 && !wall[p.y][p.x][p.y][p.x+1]) ||
	 (i == 3 && !wall[p.y][p.x][p.y+1][p.x])) {
	que.emplace(nx, ny);
	dist[ny][nx] = dist[p.y][p.x]+1;
	//cout<<ny<<" "<<nx<<" "<<dist[ny][nx]<<endl;
	//cout<<"          "<<dist[p.y][p.x]+1<<endl;
      }
    }
  }
  //cout<<dist[op.y][op.x]<<endl;
  return dist[op.y][op.x];
}

void print(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<wall[i][j][i][j+1]<<" "<<wall[i][j][i+1][j]<<endl;
    }
  }
  cout<<endl;
}

signed main(){
  cin >> W >> H >> N;
  for(int i = 0; i < N; i++) {
    P s, d;
    cin >> s.x >> s.y >> d.x >> d.y;
    P p = min(s, d);
    P q = p == s ? d : s;
    if(p.y == q.y) {
      for(int x = p.x; x < q.x; x++) wall[p.y][x][p.y][x+1] = true;
    } else if(p.x == q.x) {
      for(int y = p.y; y < q.y; y++) wall[y][p.x][y+1][p.x] = true;      
    } else {
      assert(false);
    }
  }

  cin >> ip.x >> ip.y >> op.x >> op.y;

  int ini = bfs(), ans = ini;
  
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(in(i+1, j) && !wall[i][j][i+1][j]) {
	wall[i][j][i+1][j] = true;
	//print();
	ans = max(ans, bfs());
	wall[i][j][i+1][j] = false;
      }
      if(in(i, j+1) && !wall[i][j][i][j+1]) {
	wall[i][j][i][j+1] = true;
	//print();
	ans = max(ans, bfs());
	wall[i][j][i][j+1] = false;
      }
    }
  }
  
  //cout << ans << " " << ini << endl;
  cout << ans - ini << endl;
  
  return 0;
}

Measured memory_bytes: 10904
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

bool isBingo(vector<bool>& bingo){
    if(bingo[0] && bingo[1] && bingo[2]){
        return true;
    }
    if(bingo[3] && bingo[4] && bingo[5]){
        return true;
    }
    if(bingo[6] && bingo[7] && bingo[8]){
        return true;
    }
    if(bingo[0] && bingo[3] && bingo[6]){
        return true;
    }
    if(bingo[1] && bingo[4] && bingo[7]){
        return true;
    }
    if(bingo[2] && bingo[5] && bingo[8]){
        return true;
    }
    if(bingo[0] && bingo[4] && bingo[8]){
        return true;
    }
    if(bingo[2] && bingo[4] && bingo[6]){
        return true;
    }
    return false;
}

int main()
{
    vector<int> A(9);
    vector<bool> bingo(9, false);
    int N;
    for(int i=0;i<9;++i){
        cin >> A[i];
    }
    cin >> N;
    vector<int> b(N);
    for(int i=0;i<N;++i){
        cin >> b[i];
    }

    for(int i=0;i<N;++i){
        for(int j=0;j<9;++j){
            if(b[i] == A[j]){
                bingo[j] = true;
                break;
            }
        }
    }
    if(isBingo(bingo)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if((A + D - 1) / D >= (C + B - 1) / B)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3596
//Prashant Tyagi
using namespace std;
#include <bits/stdc++.h>
#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
typedef  long long                     LL;
typedef  vector < int >                VI;
typedef  pair< int, int >              II;
typedef  vector < II >                 VII;
#define SI(x)                          scanf ("%d", &x)
#define SLL(x)                         scanf ("%lld", &x)
#define PI(x)                          printf ("%d\n", x)
#define PLL(x)                         printf ("%lld\n", x)
#define MOD                            98765431
#define PB                             push_back
#define MP                             make_pair
#define ALL(v)                         v.begin(), v.end()
#define VIF(x,V)                       for(int x:V)
#define FILL(a,b)                      memset(a,b,sizeof(a))
#define REP(i,j,n)                     for(int i=j;i<n;i++)
#define FLD(i,j,n)                     for(int i=n-1;i>=j;i--)
#define F                              first  
#define S                              second
#define fast_io                        ios_base::sync_with_stdio(false);cin.tie(NULL)

int main ()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;SI(n);SI(m);
	vector<int> v;
	int N;SI(N);
	REP(i,1,N+1){
		int a;SI(a);
		REP(j,0,a)v.PB(i);
	}
	int grid[n+1][m+1];
	int t=0;
	REP(i,1,n+1){
		if(i%2==1){
			REP(j,1,m+1)grid[i][j]=v[t++];
		}else {
			for(int j=m;j>=1;j--)grid[i][j]=v[t++];
		}
	}
	REP(i,1,n+1){
		REP(j,1,m+1){
			if(j==m)PI(grid[i][j]);
			else printf("%d ",grid[i][j]);
		}
	}
	return 0;
}

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

using namespace std;

const int MAXN = 2E5 + 10;

int cnt[MAXN];

int main(){
	int n;
	scanf("%d", &n);
	int m1 = n + 1, m2 = 0;
	for (int t, i = 0; i < n; ++i){
		scanf("%d", &t);
		++cnt[t];
		m1 = min(m1, t);
		m2 = max(m2, t);
	}
	bool flag = true;
	if (m2 & 1){
		flag &= m1 * 2 - 1 == m2;
		flag &= cnt[m1] == 2;
		for (int i = m1 + 1; i <= m2; ++i)
			flag &= cnt[i] >= 2;
	}
	else{
		flag &= m1 * 2 == m2;
		flag &= cnt[m1] == 1;
		for (int i = m1 + 1; i <= m2; ++i)
			flag &= cnt[i] >= 2;
	}
	puts(flag ? "Possible" : "Impossible");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >>n;
  int p[100];
  for(int i=0;i<n;i++){
    cin >>p[i];
  }
  int ans=0;
  for(int i=1;i<n-1;i++){
    if(p[i-1]<p[i]&&p[i]<p[i+1]) ans++;
    else if(p[i-1]>p[i]&&p[i]>p[i+1]) ans++;
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed<<endl;
	
	string s,t;
	cin>>s>>t;
	s=s+s+s+s+s+s+s+s+s+s;
	vector<ll>chardata[26];
	for(int i=0;i<s.length();i++)
		chardata[(s[i]-'a')].push_back(i);
	
	/*for(int i=0;i<26;i++){
		cout<<(char)('a'+i)<<endl;
		for(auto&& x : chardata[i])cout<<x<<" ";
	}*/
	
	ll ans=1;
	ll now=0;
	bool isNot=false;
	vector<ll>index(26,0);
	for(int i=0;i<t.length();i++){
		if(isNot)i--;
		isNot=false;
		ll k=(t[i]-'a');
		if(chardata[k].size()==0){
			cout<<-1<<endl;
			return 0;
		}
		if(index[k]>=(ll)chardata[k].size()){
			for(int i=0;i<26;i++)index[i]=0;
				//isNot=true;
			i--;
				ans++;
				now=0;
			continue;
		}
		while(chardata[k][index[k]]<now){
			index[k]++;
			if((ll)chardata[k].size()<=index[k])
			{
				isNot=true;
				//not find
				ans++;
				//init
				now=0;
				for(int i=0;i<26;i++)index[i]=0;
				break;
			}
		}
		if(isNot==false){
			now=(ll)chardata[k][index[k]];
			index[k]++;
		}
	//	cout<<"i= "<<t[i]<<" now..."<<now<<"ans... "<<ans<<endl;
	}
	cout<<(ll)s.length()*(ans-1)+now+1<<endl;
}


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

int main(){
  long long num,miti;
  
  cin >> num >> miti;
  
  vector<long long> vec(num);
  vector<long long> vecCheck(num);
  
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  
  long long mitiA,mitiB;
  for(int i = 0; i < miti; i++){
    cin >> mitiA >> mitiB;
    if(vec.at(mitiA-1) > vec.at(mitiB-1)){
      vecCheck.at(mitiB-1) += 1;
    }else if(vec.at(mitiA-1) < vec.at(mitiB-1)){
       vecCheck.at(mitiA-1) += 1;
    }else{
      vecCheck.at(mitiA-1) += 1;
      vecCheck.at(mitiB-1) += 1;
    }
  }
  
  long long cnt = 0;
  for(int i = 0; i < num; i++){
    if(vecCheck.at(i) == 0) cnt++;
  }
  
  cout << cnt;
}


Measured memory_bytes: 4840
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [N, M, K] = nextIntArray()
    let a = nextIntArray()
    let b = nextIntArray()

    let sumA = [0]
    for (let i = 0; i < a.length; i++) {
        sumA.push(sumA[i] + a[i])
    }
    let sumB = [0]
    for (let i = 0; i < b.length; i++) {
        sumB.push(sumB[i] + b[i])
    }
    let res = 0
    for(let i = 0, j = M; i <= N; i++){
        if(sumA[i] > K) break
        while(sumA[i] + sumB[j] > K ) j--
        res = Math.max(res, i+j)
    }
    console.log(res)
}
Main()


Measured memory_bytes: 66932
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,l; cin >> n >> l;
  vector<string> S;
  for(int i=0;i<n;i++){
  string s; cin >> s; S.push_back(s);
  }
  sort(S.begin(),S.end());
  string ans;
  for(auto a:S) ans+=a;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] bn = new int[n - 1];
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (i < n - 1) {
        bn[i] = Integer.parseInt(sc.next());
      }
      if (i == 0) {
        ans += bn[i];
      } else if (i == n - 1) {
        ans += bn[i - 1];
      } else {
        ans += Math.min(bn[i], bn[i - 1]);
      }
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 23252
import java.util.*;

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

	class P {
		int v;
		int l;
		P(int v, int l){
			this.v=v;
			this.l=l;
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		ArrayList<ArrayList<Integer>> g = new ArrayList<>();
		for(int i=0; i<n; i++) g.add(new ArrayList<>());
		for(int i=0; i<m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			a--;
			b--;
			g.get(a).add(b);
		}
		int s = sc.nextInt();
		int t = sc.nextInt();
		s--;
		t--;
		int dist[][] = new int[n][3];
		int INF = 1001001001;
		for(int i=0; i<n; i++) {
			for(int j=0; j<3; j++) {
				dist[i][j] = INF;
			}
		}
		ArrayDeque<P> q = new ArrayDeque<>();
		dist[s][0] = 0;
		q.add(new P(s,0));
		while(! q.isEmpty()) {
			P p = q.pop();
			int v = p.v;
			int l = p.l;
			int nl = (l+1)%3;
			for (int nv : g.get(v)) {
				if(dist[nv][nl] != INF) continue;
				dist[nv][nl] = dist[v][l] + 1;
				q.add(new P(nv, nl));
			}
		}
		if(dist[t][0] == INF) {
			System.out.println(-1);
			sc.close();
			return;
		}

		int ans = dist[t][0] / 3;
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 73948