akhauriyash/Code-Regression huggingface dataset:
N = int(input())
s = [input() for i in range(N)]

a = s.count('AC')
b = s.count('WA')
c = s.count('TLE')
d = s.count('RE')

print('AC x ' + str(a))
print('WA x ' + str(b))
print('TLE x ' + str(c))
print('RE x ' + str(d))

Measured memory_bytes: 16296
H,W=map(int,input().split())
alpha = [chr(x) for x in range(ord('A'),ord('Z')+1)]
for i in range(H):
  tmp = input().split()
  if 'snuke' in tmp:
    for j in range(W):
      if tmp[j] == 'snuke':
        print(alpha[j]+str(i+1))

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

using namespace std;

const int maxn = 200*1000+10;
int t, n, q, u, v, a, p, s[maxn], f[maxn], sum, arr[maxn], ans[maxn], ind[maxn];
vector<int> vec[maxn];

void pp(int x, int par)
{
	s[x] = t++;
	ind[s[x]] = x;
	for (auto w : vec[x])
	{
		if (w != par)
			pp(w, x);
	}
	f[x] = t;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> u >> v;
		u--;
		v--;
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	pp(0, -1);
	for (int i = 0; i < q; i++)
	{
		cin >> p >> a;
		p--;
		arr[s[p]] += a;
		arr[f[p]] -= a;
	}
	for (int i = 0; i < n; i++)
	{
		sum += arr[i];
		ans[ind[i]] = sum;
	}
	for (int i = 0; i < n; i++)
		cout << ans[i] << " ";
	return 0;
}


Measured memory_bytes: 26624
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    string s; cin >> s;
    int len = s.length();
    if(len%2!=0) {
        cout << "No" << endl;
        return 0;
    }
    int q = len/2;
    string h = "";
    for(int i=0; i<q; i++) {
        h += "hi";
    }
    if(h==s) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }

    return 0;
}

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

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

int main(){
    int H,N;
    cin >> H >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    rep(i,N){
        H -= vec[i];
    }
    if (H <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;

    for(int i=1;i<=9;i++){
      int j = i-1;
      int next = i*100+i*10+i; int b = j*100+j*10+j;
      if(b<N && N<=next){
        cout<<next<<endl; return 0;
      }
    }

    return 0;
}


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

template <class T> struct fenwick_tree {
    //using U = internal::to_unsigned_t<T>;
    using U = T;
  public:
    fenwick_tree() : _n(0) {}
    fenwick_tree(int n) : _n(n), data(n) {}

    void add(int p, T x) {
        assert(0 <= p && p < _n);
        p++;
        while (p <= _n) {
            data[p - 1] += U(x);
            p += p & -p;
        }
    }

    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        return sum(r) - sum(l);
    }

  private:
    int _n;
    std::vector<U> data;

    U sum(int r) {
        U s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
};

int main() {
    int N, Q, q, p, l, r;
    cin >> N >> Q;
    fenwick_tree<ll> ft(N);
    ll a, x;
    for (int i = 0; i < N; i++) {
        cin >> a;
        ft.add(i, a);
    }
    for (int i = 0; i < Q; i++) {
        cin >> q;
        if (q) {
            cin >> l >> r;
            cout << ft.sum(l, r) << "\n";
        } else {
            cin >> p >> x;
            ft.add(p, x);
        }
    }
    return 0;
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = max((a),(b))
#define chmin(a, b) a = min((a),(b))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000
 
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
 

 
int main() {
    int n;
    cin>>n;
    vll table(n);
    vll ans(n);
    ll sum=0;
    ll sum2=0;
    rep(i,n)cin>>table[i];
    rep(i,n)table[i]*=2;
    rep(i,n)sum+=table[i];
    for(int i=1;i<n;i+=2)sum2+=table[i];
    ans[0]=sum/2-sum2;
    reps(i,1,n)ans[i]=table[i-1]-ans[i-1];

    rep(i,n-1)cout<<ans[i]<<" ";
    cout<<ans[n-1]<<endl;

    
    
}

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

int main() {
  string a;
  cin >> a;
  if (a.at(0) == a.at(1) && a.at(1) == a.at(2)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>A;
    if(N<A)cout<<0<<endl;
    else cout<<10<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  set<char> st;
  REP(i, n) {
    char c;
    cin >> c;
    st.insert(c);
  }
  cout << (SZ(st) == 3 ? "Three" : "Four") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b - a - b + 1 << endl;
}

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


int main(){
  int num;
  cin >> num;
  int A,B,C,D;
  D = num % 10;
  num /= 10;
  C = num % 10;
  num /= 10;
  B = num % 10;
  A = num / 10;

  bool loop = true;
  while(loop){
    if(A+B+C+D == 7){
      cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
      break;
    }else if(A+B+C-D == 7){
      cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
      break;
    }else if(A+B-C+D == 7){
      cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
       break;
    }else if(A+B-C-D == 7){
      cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
      break;
    }else if(A-B+C+D == 7){
      cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
      break;
    }else if(A-B+C-D == 7){
      cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
      break;
    }else if(A-B-C+D == 7){
      cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
      break;
    }else if(A-B-C-D == 7){
      cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
      break;
    }else{
      loop = false;
    }
  }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, a;
  scanf("%d", &n);
  int b = 0, c = 1e9 + 1;
  rep(i,n)
  {
    cin >> a;
    c = min(c, a);
    b = max(b, a);
  }
  printf("%d", b - c);
  return 0;
}


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

int main(void){
    long long h, n;
    cin >> h >> n;
    
    vector<int> a(n), b(n);
    int max = 0;
    rep(i, n){
        cin >> a.at(i) >> b.at(i);
        if(a.at(i) > max){
            max = a.at(i);
        }
    }

    vector<long long> d(h+1);
    rep(i, h+1){
        d.at(i) = 1000000000000000000;
    }
    d.at(0) = 0;
    
    for(int i = 1; i < h+1+max; i++){
        rep(j, n){
            if(i-a.at(j) <= 0){
                if(a.at(j)>h){
                    if(d.at(h) > b.at(j) + d.at(0)){
                        d.at(h) = b.at(j) + d.at(0);
                    }
                }
                else if(d.at(i) > b.at(j) + d.at(0)){
                    d.at(i) = b.at(j) + d.at(0);
                }
            }
            else if(i > h){
                if(i - a.at(j) <= h){
                    if(d.at(h) > b.at(j) + d.at(i-a.at(j))){
                        d.at(h) = b.at(j) + d.at(i-a.at(j));
                    }
                }
            }
            else {
                if(d.at(i) > b.at(j) + d.at(i-a.at(j))){
                    d.at(i) = b.at(j) + d.at(i-a.at(j));
                }
            }
        }
    }

    cout << d.at(h) << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#include <math.h>

using namespace std;

int main(int argc, char* argv[]) {

  	int n;
  	cin >> n;

  	int negative_count = 0;
  	long min = 100000000000;
  	long sum = 0;
	vector<long> ar(n);
  	for (int i=0; i<n; i++) {
    	cin >> ar[i];
      	if (ar[i] < 0) {
        	negative_count ++;
        }
      	int r = labs(ar[i]);
      	if (r < min) {
          min = r;
        }
      	sum += r;
    }

    //printf("sum:%ld, min:%ld\n", sum, min);
	
	if (negative_count % 2 != 0) {
		sum -= min * 2;
    }
  
  
  	cout << sum << endl;
  	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long m1, d1, m2, d2;

int main(){
    scanf("%ld%ld%ld%ld", &m1, &d1, &m2, &d2);
    if((m1 + 1 == m2 || m1 == 12) && d2 == 1){
        printf("1\n");
    }else{
        printf("0\n");
    }
}


Measured memory_bytes: 256
import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype=int)
for i in range(1,n):
    s=max(0,i-k)
    dp[i]=min(dp[s:i]+abs(h[s:i]-h[i]))
print(dp[-1])

Measured memory_bytes: 22724
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

int memo[100002] = {-1};

int compute(int startPos, int n, int h[]){
    if(memo[startPos] != -1){
        return memo[startPos];
    }
    if(startPos == n - 1){
        return 0;
    }
    if(startPos == n - 2){
        return abs(h[n - 2] - h[n - 1]);
    }
    int min1 = abs(h[startPos] - h[startPos + 1]) + compute(startPos + 1, n, h);
    min1 = min(abs(h[startPos] - h[startPos + 2]) + compute(startPos + 2, n, h), min1);
    memo[startPos] = min1;
    return min1;
}

int main(){
    int n;
    cin >> n;
    int h[n] = {0};
    for(int i = 0; i < n; i++){
        cin >> h[i];
        memo[i] = -1;
    }
    cout << compute(0, n, h) << endl;
    return 0;
}

Measured memory_bytes: 8832
n = int(input())
p = [int(input()) for _ in range(n)]
q = [-1] * n
for i, j in enumerate(p):
    q[j - 1] = i
res = n
tmp = 1
for i, j in zip(q, q[1:]):
    if i < j:
        tmp += 1
    else:
        res = min(res, n - tmp)
        tmp = 1
else:
    res = min(res, n - tmp)
print(res)


Measured memory_bytes: 20424
K, N = map(int, input().split())

a_l = [int(i) for i in input().split()]

max_len = a_l[0] + (K - a_l[-1])

past = a_l[0]
for a in a_l[1:]:
    length = a - past
    if length > max_len:
        max_len = length
    past = a
print(K-max_len)

Measured memory_bytes: 31568
n = int(input())

count = 0
flag = 0

for i in range(n):
    dn = list(map(int, input().split()))
    if dn[0] == dn[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        flag += 1
        print("Yes")
        break

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

Measured memory_bytes: 9180
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef pair<int,int> PII;
typedef long long LL;
typedef vector <LL> VLL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PIL> VPIL;


//#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
//#define sort(c) sort((c).begin(),(c).end())

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

#define BASE 2000
#define MAX 4000
#define MOD 1000000007

LL F[MAX*2+1],Finv[MAX+1];
LL dp[MAX+2][MAX+2];
int A[200000],B[200000];

LL pow_mod(LL b,LL e){
    LL ret = 1;
    for (;e>0;e>>=1){
        if(e&1) ret = ret * b % MOD;
        b = b * b % MOD;
    }
    return ret;
}
int main(){
	int N,A_MAX=0,B_MAX=0;
	LL ans = 0,dup;
	F[0] = 1;
	rep(i,MAX*2) F[i+1] = F[i]*(i+1) % MOD;
	Finv[MAX] = pow_mod(F[MAX],MOD-2);
	rep(i,MAX) Finv[MAX-i-1] = Finv[MAX-i]*(MAX-i) % MOD;
	rep(i,MAX+1) rep(j,MAX+1) dp[i][j] = 0;
	scanf("%d",&N);
	rep(i,N){
		scanf("%d %d",A+i,B+i);
		A_MAX = max(A_MAX,A[i]);
		B_MAX = max(B_MAX,B[i]);
		dp[BASE-B[i]][BASE-A[i]] += 1;
	}
	range(i,BASE-B_MAX,BASE+B_MAX+1){
		range(j,BASE-A_MAX,BASE+A_MAX+1){
			dp[i+1][j] = (dp[i+1][j]+dp[i][j])%MOD;
			dp[i][j+1] = (dp[i][j+1]+dp[i][j])%MOD;
		}
	}
	rep(i,N){
		dup = F[A[i]*2+B[i]*2]*Finv[A[i]*2]%MOD*Finv[B[i]*2]%MOD;
		ans = (ans + dp[BASE+B[i]][BASE+A[i]] - dup + MOD) % MOD;
	}
	printf("%lld\n",ans*pow_mod(2,MOD-2)%MOD);
	return 0;
}

Measured memory_bytes: 126976
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {

        static long D = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] Ps = Read(Console.ReadLine());
            int ans = 0;
            int min = 0;
            for (int i = 0; i < Ps.Length; i++)
            {
                if(i == 0)
                {
                    ans++;
                    min = Ps[0];
                }
                else
                {
                    if (min >= Ps[i]) ans++;
                    min = Math.Min(min, Ps[i]);
                }
            }

            Console.WriteLine(ans);

            Console.ReadLine();
        }

        private static int[] Read(string input)
        {
            string[] aaa = input.Split(' ');
            int num = aaa.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(aaa[i]);
            }
            
            return ints;
        }


    }


}


Measured memory_bytes: 29404
#include<iostream>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    string S;
    cin >> S;
    int size;
    size = S.size();

    for(int i=0; i<size; i++){
        cout << "x";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

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

	sort(a.begin(), a.end(), greater<int>());

	int alice = 0, bob = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0) alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

lint dp[105][MAX];

int main(){
    lint n, W; cin >> n >> W;
    repn(i, n){
        lint w, v; cin >> w >> v;
        repn(j, W){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(j-w>=0) dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v);
        }
    }
    out(dp[n][W]);
}

Measured memory_bytes: 156416
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	n--; k--;
	cout << (n + k - 1) / k << endl;
	return 0;	
}

Measured memory_bytes: 256
n,h = (int(x) for x in input().split())
seq = []
maxa = 0
sumb = 0
cnt = 0
for i in range(n):
    a, b = [int(x) for x in input().split()]
    if a > maxa:
        maxa = a
        cnt = 1
    elif a == maxa:
        cnt += 1
    seq.append((a,b))
    sumb += b
s = sorted(seq, key=lambda x: x[1], reverse=True)
i = 0
ans = 0
while h > 0:
    a,b = s[i]
    h -= b
    ans += 1
    if a == maxa and cnt > 1:
        cnt -= 1
    elif a == maxa:
        i += 1
        while i < n:
            a,b = s[i]
            if b > maxa:
                ans += 1
                h -= b
                i += 1
            else:
                break

        ans += (h + maxa - 1) // maxa
        break
    i += 1
print(ans)

Measured memory_bytes: 64216
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] food = new int[M+1];
    	for (int i = 0; i < N; i++) {
    		int K = sc.nextInt();
    		for (int j = 0; j < K; j++) {
    			food[sc.nextInt()]++;
    		}
    	}
    	int count = 0;
    	for (int score : food) {
    		if (score == N) {
    			count++;
    		}
    	}
    	System.out.println(count);
    }
}

Measured memory_bytes: 24400
#include <iostream>
using namespace std;
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i=0; i<n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1) {
        minv = INFTY;
        u = -1;
        for(int i=0; i<n; i++) {
            if(minv >d[i] && color[i]!=BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if(u==-1) {
            break;
        }
        color[u] = BLACK;
        for(int v=0; v<n; v++) {
            if(color[v]!=BLACK && M[u][v]!=INFTY) {
                if(d[v]>M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(int i=0; i<n; i++) {
        if(p[i]!=-1) {
            sum += M[i][p[i]];
        }
    }

    return sum;
}

int main() {
    cin >> n;

    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            int e;
            cin >> e;
            if(e==-1) {
                M[i][j] = INFTY;
            }
            else {
                M[i][j] = e;
            }
        }
    }

    cout << prim() << endl;

    return 0;
}


Measured memory_bytes: 3120
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  string S,T; cin>>S>>T;
  int A,B; cin>>A>>B;
  string U; cin>>U;
  
  if (U == S) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;


  return 0;
}


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

int main(void)
{
    double x1, y1, x2, y2, xq, yq;

    while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)){
        double dx1 = x2 - x1, dy1 = y2 - y1;
        double dx2 = xq - x2, dy2 = yq - y2;
        double dx3 = x1 - xq, dy3 = y1 - yq;
        double a1, b1, a2, b2;
        double x, y;

        if (dx1 == 0){
            printf("%.10f %.10f\n", x1 + dx3, yq);
            continue;
        }
        if (dy1 == 0){
            printf("%.10f %.10f\n", xq, y1 + dy3);
            continue;
        }

        a1 = dy1 / dx1;
        b1 = y1 - x1 * a1;
        a2 = -(1 / a1);
        b2 = yq - xq * a2;
        x = (b2 - b1) / (a1 - a2);
        y = a1 * x + b1;
        printf("%.10f %.10f\n", x + x - xq, y + y - yq);
    }

    return 0;
}

Measured memory_bytes: 652
var stdin = function() {
	if (require('os').type().toString().match('Windows')) return 0;
	else return '/dev/stdin';
}();
var S = Number(require('fs').readFileSync(stdin).toString().trim());
var s = S % 60, M = (S - s) / 60, m = M % 60, h = (M - m) / 60;
console.log(h + ":" + m + ":" + s);

Measured memory_bytes: 15528
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define inf 1e18

ll sum(vector<ll>&a,ll l ,ll r)
{
  ll s=0;
  for(ll i=l;i<=r;i++)
    s+=a[i];
  return s;
}


int main()
{
  ll n;
  cin>>n;

  vector<ll>a(n);
  for(auto &it:a)
      cin>>it;
  ll dp[n+5][n+5];
  for(ll i=0;i<n;i++)
    for(ll j=0;j<n;j++)
      dp[i][j]=0;

  for(ll l=n-1;l>=0;l--)
  {
    for(ll r=l;r<n;r++)
    {
      if(l==r)
        dp[l][r]=0;
      else
      {
        ll s=sum(a,l,r);
        dp[l][r]=inf;
        for(ll i=l;i<r;i++)
        {
          dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+s);
        }
      }
    }
  }

  cout<<dp[0][n-1]<<endl;



}



Measured memory_bytes: 4880
N = int(input())
s_list = []
for i in range(N):
    p = input()
    s_list.append(p)
M = int(input())
t_list = []
for i in range(M):
    p2 = input()
    t_list.append(p2)
s_count_list = [0 for i in range(N)]
#s_listの中身を１つずつ計算しますよ…
for i in range(N):
    name = s_list[i]
    count = 0
    #このnameと同じものを探しカウントする
    for k in range(N):
        if s_list[k] == name:
            count += 1
    for t in range(M):
        if t_list[t] == name:
            count -= 1
    s_count_list[i] = count
max_c = max(s_count_list)
if max_c < 0:
    max_c = 0
print(max_c)

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

#define int long long

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

  int N, M;
  while ( cin >> N >> M, N ) {

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

    int ans = -1;
    for ( int i = 0; i < N; i++ ) {
      for ( int j = i+1; j < N; j++ ) {
	if ( i == j ) continue;	
	if ( a[i]+a[j] <= M ) ans = max(ans, a[i]+a[j]);
      }
    }

    if ( ans == -1 ) cout << "NONE" << endl;    
    else cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3092
<?php
$input = trim(fgets(STDIN));
$input = str_replace(array("\r\n","\r","\n"), '', $input);

while ($input) {
    $array[] = $input;
    $input = trim(fgets(STDIN));
    $input = str_replace(array("\r\n","\r","\n"), '', $input);
}

if ($array[0] > $array[1]) {
    echo "GREATER";
} elseif ( $array[0] < $array[1] ) {
    echo "LESS";
} else {
    echo "EQUAL";
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793238462643383279;
int main(){
 int N; cin >> N; 
 vector<double> x(N); vector<double> y(N);
  for(int i = 0; i < N; i++){ cin >> x[i] >> y[i];}
  double ans = 0.0;
  for(int i = 0; i < 100100; i++){
    double s = cos((double)(i*pi)/5050);
    double t = sin((double)(i*pi)/5050);
    double X = 0.0; double Y = 0.0;
    for(int i = 0; i < N; i++){
      if( x[i]*s + y[i]*t >= 0){ X += x[i]; Y += y[i];}
    }
  ans = max(ans, sqrt(X*X+Y*Y));}
  
  cout << fixed << setprecision(15) << ans << endl; return 0;}
    

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	string s,t; cin >> s >> t;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return;
		}
	}
	if (s.length() == t.length()) {
		cout << "No" << endl;
		return;
	}
	cout << "Yes"<< endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    rep(i, N)cin >> v[i];
    ll ans = 0;
    for(int i = 0; i <= K; i++){
        for(int j = 0; i + j <= K; j++){
            priority_queue<ll, vector<ll>, greater<ll> > queue;
            queue.push(0);
            int lindex = 0, rindex = N - 1;
            ll sum = 0;
            // cout << i << j<<endl;
            for(lindex; lindex < i; lindex++){
                if(lindex >= N - 1){
                    lindex = N - 1;
                    break;
                }
                sum += v[lindex];
                queue.push(v[lindex]);
            }
            // cout << "i: " << i << " j: " << j << endl;
            // cout << lindex << " " << rindex << endl;
            // cout << sum << endl;
            for(rindex; rindex > N - j - 1; rindex--){
                sum += v[rindex];
                queue.push(v[rindex]);
                if(rindex == lindex)break;
            }
            
            for(int n = 0; n < K - i - j; n++){
                if(queue.top() < 0){
                    sum -= queue.top();
                    queue.pop();
                }else break;
            }
            // cout << "i: " << i << " j: " << j << " sum: " <<sum<<endl;
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE() freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define pii pair<int,int>
#define sl2(x,y) scanf("%lld %lld",&x,&y)
typedef long long ll;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};

//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

//vector<int>G[100];

//map<int,vector<int> >G;
//map<int,int>level;

ll mod=1e9+7;

bool cmp(pii a,pii b)
{
    return a.first>b.first;
}
int arr[200005];
int main()
{
//    READ
    int n,k,ind;
    sf2(n,k);
    for(int i=1;i<=n;i++)
    {
        sf(arr[i]);
        if(arr[i]==1)
        {
            ind=i;
        }
    }
    int countt=0;
    countt+=((ind-1)/(k-1));
    int rem=(ind-1)%(k-1);
//    cout<<countt<<endl;
    countt+=((n-ind+rem)/(k-1));
    rem=(n-ind+rem)%(k-1);
    if(rem)
    countt++;
    cout<<countt<<endl;
    return 0;
}


Measured memory_bytes: 640
MOD = pow(10, 9)+7
N, M = map(int, raw_input().split())

def myfact(num):
	res = 1
	for i in range(num+1)[1:]:
		res *= i
		if res > MOD:
			res %= MOD
	return res
if abs(N - M) > 1:
	print 0
else:
	if N == M:

		res = ( myfact(N) * myfact(N) * 2 )%MOD
	else:
		res = ( myfact(N) * myfact(M) )%MOD
	print res

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

int N, K;
vector<int> A;

bool judge(int t) {

    int cnt = 0;
    for(int i = 0; i < N; i++) {
        cnt += A.at(i) / t;
        if(A.at(i) % t == 0) {
            cnt--;
        }
    }

    if(cnt <= K) {
        return true;
    } else {
        return false;
    }
}

int binary_search(int ng, int ok) {

    int mid;
    while(abs(ok - ng) != 1) {
        mid = (ok + ng) / 2;
        if(judge(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    return ok;
}

int main() {

    cin >> N >> K;

    A.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int ans;
    ans = binary_search(0, 1000000000);
    cout << ans << endl;
}


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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, r;
ll s;
map<ll,ll> m;

signed main() {
	cin >> n;
	m[0] = 1;
	rep(i,n) {
		cin >> a;
		s += a;
		m[s]++;
	}
	each(i,m) r += i.se*(i.se-1)/2;
	cout << r << ln;
}

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

int main(){
    int n;cin>>n;
    vi a(n);
    double sum = 0;
    
    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }
    
    sum /= n;
    
    double dif = 100;
    int ans;
    
    rep(i,n){
        if(dif>abs(sum-a[i])){
            ans = i;
            dif = abs(sum-a[i]);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main(void) {
	int a, b; cin >> a >> b;
	int port_num = 1;
	int cnt = 0;
	while (port_num < b) {
		port_num += a - 1;
		cnt++;
	}
	cout << cnt << endl;

	return 0;
}

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


int main(){
  
  int N, K;
  cin >> N >> K;
  
  if(N == 1){
    cout << "1" << endl;
  }
  
  for(int i=0; i < N; i++){
   	if(pow(K, i) > N){
      cout << i << endl;
      break;
    }
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
 
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;
 
 
const int mod=1000000007;
//const int mod=998244353;

 
 

 
int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> n;
    vi v;
    a=0;
    b=1;
    while(n-b>=0){
        a++;
        n-=b;
        b*=26;
    }
    for(int i=0; i<a; i++){
        v.pb(n%26);
        n/=26;
    }
    reverse(all(v));
    for(int i=0; i<v.size(); i++){
        cout << char(v[i]+'a');
    }
    cout << el;
    return 0;
}


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

h = [0] * 999
t = 0
for i in range(1, 1000):
    t += i
    h[i-1] = t

import bisect

x = 1
while True:
    i = bisect.bisect_left(h, a+x)
    if h[i] == a+x and h[i+1] == b+x:
        break
    x += 1

print(x)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n;
llint a[105], cnt[105];

int main(void)
{
	cin >> n;
	
	llint mn = inf, mx = -inf;
	for(int i = 1; i <= n; i++){
		cin >> a[i], cnt[a[i]]++;
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	if(cnt[mn] >= 3){
		cout << "Impossible" << endl;
		return 0;
	}
	if(cnt[mn] == 1 && mx != 2*mn){
		cout << "Impossible" << endl;
		return 0;
	}
	if(cnt[mn] == 2 && mx != 2*mn-1){
		cout << "Impossible" << endl;
		return 0;
	}
	
	for(int i = mn+1; i <= mx; i++){
		if(cnt[i] < 2){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;
	
	return 0;
}


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

a = [1]
for _ in range(n):
  a.append(2 * a[-1] + 3)

p = [1]
for _ in range(n):
  p.append(2 * p[-1] + 1)

# print(a)
# print(p)


def f(l, y):
  # print('f({0},{1})'.format(l, y))
  global a, p
  if l == 0:
    return 1
  if y <= 1:
    return 0
  elif y <= a[l - 1] + 1:
    return f(l - 1, y - 1)
  elif y <= a[l - 1] + 2:
    return p[l - 1] + 1
  else:
    return p[l - 1] + 1 + f(l - 1, y - 1 - a[l - 1] - 1)


print(f(n, x))

# dp = ['P'] + [''] * 50

# def Burger(l):
#   if dp[l] != '':
#     return dp[l]
#   else:
#     dp[l] = 'B' + Burger(l - 1) + 'P' + Burger(l - 1) + 'B'
#     return dp[l]


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GS(S);
  int mx = 1;
  FOR(i, S.size() - 1) mx *= 2;
  ll sum = 0;
  FOR(i, mx) {
    ll token = S[0] - '0';
    for (int j = 1; j < S.size(); ++j) {
      if ((i >> (j - 1)) & 1) {
        sum += token;
        token = S[j] - '0';
      } else {
        token = token * 10 + S[j] - '0';
      }
    }
    sum += token;
  }
  print(sum);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

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

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a, b;
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		ll n;
		cin >> n;
	}
	if ((a - 1) % (b - 1) == 0) {
		cout << (a-1) / (b-1) << endl;
	}
	else {
		cout << (a - 1) / (b - 1) + 1 << endl;
	}
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef pair<int, int> pii;

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;

int N;
string input[1010];

int s_to_i(string s) {
	stringstream ss(s);
	int res; ss >> res;
	return res;
}

bool is_x(string s) {
	return s[0] == 'x';
}

void solve() {
	int lb = -iINF, ub = iINF;
	
	for_(i,1,N) {
		if (is_x(input[i])) {
			if (is_x(input[i + 1])) {
				cout << "none" << endl;
				return;
			} else {
				int val = s_to_i(input[i + 1]);
				if (i % 2) {
					ub = min(ub, val - 1);
				} else {
					lb = max(lb, val + 1);
				}
			}
		} else {
			if (is_x(input[i + 1])) {
				int val = s_to_i(input[i]);
				if ((i + 1) % 2) {
					ub = min(ub, val - 1);
				} else {
					lb = max(lb, val + 1);
				}
			} else {
				int lval = s_to_i(input[i]), rval = s_to_i(input[i + 1]);
				if (i % 2 && lval >= rval) {
					cout << "none" << endl;
					return;
				} else if (i % 2 == 0 && lval <= rval) {
					cout << "none" << endl;
					return;
				}
			}
		}
		
		/*
		if (is_x(input[i])) {
			if (i < N && is_x(input[i + 1])) {
				cout << "none" << endl;
				return;
			} else if (i == N) {
				int val = s_to_i(input[i - 1]);
				if (i % 2) {
					ub = min(ub, val - 1);
				} else {
					lb = max(lb, val + 1);
				}
			} else if (i == 1) {
				int val = s_to_i(input[i + 1]);
				ub = min(ub, val - 1);
			} else {
				int lval = s_to_i(input[i - 1]), rval = s_to_i(input[i + 1]);
				if (i % 2) {
					ub = min(ub, min(rval, lval) - 1);
				} else {
					lb = max(lb, max(rval, lval) + 1);
				}
			}
			
		} else {
			int value = s_to_i(input[i]);
			
			if (i < N && !is_x(input[i + 1])) {
				int val2 = s_to_i(input[i + 1]);
				if (i % 2 && value >= val2) {
					cout << "none" << endl;
					return;
				}
				if (i % 2 == 0 && value <= val2) {
					cout << "none" << endl;
					return;
				}
			}
		}*/
		
		if (lb > ub) {
			cout << "none" << endl;
			return;
		}
	}
	
	if (lb == ub) {
		cout << lb << endl;
	} else {
		cout << "ambiguous" << endl;
	}
}

int main() {
	while (cin >> N, N) {
		for_(i,1,N + 1) cin >> input[i];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1292
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int[] num = io.r<int>(' ');

        if (num[0] > num[1])
        {
            io.w("a > b");
        }
        else if (num[0] < num[1])
        {
            io.w("a < b");
        }
        else
        {
            io.w("a == b");
        }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10360
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int a[9];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		a[min(b / 400,8)]++;
	}
	int ans = 0;
	for (int i = 0; i < 8; i++) {
		if (a[i])ans++;
	}
	int fr = a[8];
	int mn;
	if (ans)mn = ans;
	else mn = ans + 1;
	int mx = ans + fr;
	cout << mn << ' ' << mx << endl;
}

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

using namespace std;

int main(){
  int i,N,M,sum,all; 
  bool can;
  int A[100];
  can=false;
  //  string S,A;
  
  cin>>N>>M;
  for(i=0;i<N;i++){
    cin>>A[i];
  }
  all=0;
  sum=0;
  for(i=0;i<N;i++){
    all+=A[i];
  }
  for(i=0;i<N;i++){
    if(A[i]>=(all/(4.0*M)))sum+=1;
  }
  if(sum>=M){
  cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n;
  cin >> n;
  ll cur = 100;
  ll cnt = 0;
  while(cur < n){
      ll temp = cur/100;
      cur += temp;
      cnt++;
  }
  cout << cnt << endl;
    
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, Q, p[100000] = {};
    cin >> N >> K >> Q;
    REP(i, Q) {
        int A;
        cin >> A;
        p[A - 1]++;
    }
    REP(i, N) {
        if (K - Q + p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024