akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int b[105];

int main(){
	int d,c=0;
	for(int i=0;i<12;i++){
		cin>>d;
		b[d-1]++;
	}
	for(int i=0;i<100;i++){
		if(b[i]==4) c+=1;
		if(b[i]==8) c+=2;
		if(b[i]==12) c+=3;
	}
	if(c==3) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}


Measured memory_bytes: 3092
// D - Flat Subsequence

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

const int MAX_A = 300000;

int op(int a, int b) {
	return max(a, b);
}

int e() {
	return 0;
}

int main() {
	int N, K;
	cin >> N >> K;

	vector<int> A(N);

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

	segtree<int, op, e> dp(MAX_A + 1); // dp[k]: 最後に選んだ値がkのときの部分列の最大の長さ

	for (int i=0; i<N; i++) {
		int L = max(0, A[i] - K);
		int R = min(MAX_A, A[i] + K);
		int max_len = dp.prod(L, R+1);
		dp.set(A[i], max_len + 1);
	}

	int ans = dp.all_prod();

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9612
#include<stdio.h>
#include<math.h>
int a, b;
int main(){
    scanf("%d %d", &a, &b);
    if ( a<b ){
        printf("a < b\n");
    }else if ( a>b ){
        printf("a > b\n");
    }else if ( a==b) {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
#include<iostream>

typedef long long _L;

int As[210000];
_L Sa[210000];

int N;

void Input()
{
	scanf("%d",&N);
	int wi;
	for(wi=1;wi<=N;++wi)
	{
		scanf("%d",As+wi);
		Sa[wi]=Sa[wi-1]+As[wi];
	}
}

_L max(_L a,_L b){return a>b?a:b;}
_L min(_L a,_L b){return a>b?b:a;}


_L Abs(_L a){return a>0?a:-a;}

void AC()
{
	int wm;
	int pa,pb;
	pa=1;
	pb=3;
	_L Min=0x3FFFFFFFFFFFFLL;
	for(wm=2;wm<N-1;++wm)
	{
		while(Abs(Sa[wm]-Sa[pa]-Sa[pa])>Abs(Sa[wm]-Sa[pa+1]-Sa[pa+1]))
			++pa;
		while(Abs(Sa[N]-Sa[pb]-(Sa[pb]-Sa[wm]))>Abs(Sa[N]-Sa[pb+1]-(Sa[pb+1]-Sa[wm])))
			++pb;
		Min=min(Min,max(max(Sa[wm]-Sa[pa],Sa[pa]),max(Sa[N]-Sa[pb],Sa[pb]-Sa[wm]))-
			min(min(Sa[wm]-Sa[pa],Sa[pa]),min(Sa[N]-Sa[pb],Sa[pb]-Sa[wm])));
	}
	std::cout<<Min;
}

int main()
{
	Input();
	AC();
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()



int main(){
  ll N,M,ans=0;
  cin >> N >> M;
  vector<vector<ll>> V(N,vector<ll>(N,0));
  rep(i,M){
    ll a,b;
    cin >> a >> b;
    V.at(a-1).at(b-1)=1;
    V.at(b-1).at(a-1)=1;
  }
  vector<ll> v(N);
  rep(i,N) v.at(i)=i;
  do {
    ll t=0;
    rep(i,N-1){
      if(V.at(v.at(i)).at(v.at(i+1))!=1){
        t=1;
        break;
      }
    }
    if(t==0){
      ans++;
    }
  } while (next_permutation(v.begin()+1, v.end()));
  cout << ans << endl;
}
  
  

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int flag=0;
  while(a>0 && c>0)
  {
    if(flag==0)
    {
      c=max(0,c-b);
      flag=1;
    }
    else
    {
      a=max(0,a-d);
      flag=0;
    }
  }
  if(a<=0)
  cout<<"No";
  else if(c<=0)
  cout<<"Yes";
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// 約数の列挙O(√n)
vector<ll> enum_divisors(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            // 重複しないならばiの相方であるN/iもpush
            if(i!=n/i) res.push_back(n/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

// 桁数を返す
int cnt_digits(ll X){
    int cnt=0;
    while(X>0){
        X/=10;
        cnt++;
    }
    return cnt;
}

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

    int ans=INF;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,max(cnt_digits(i),cnt_digits(n/i)));
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	int cntac=0,cntwa=0,cnttle=0,cntre=0;
	while(t--){
		string s;
		cin>>s;
		if(s=="AC")
			cntac++;
		else if(s=="WA")
			cntwa++;
		else if(s=="TLE")
			cnttle++;
		else
			cntre++;
		}
		cout<<"AC"<<" "<<"x"<<" "<<cntac<<"\n";
		cout<<"WA"<<" "<<"x"<<" "<<cntwa<<"\n";
		cout<<"TLE"<<" "<<"x"<<" "<<cnttle<<"\n";
		cout<<"RE"<<" "<<"x"<<" "<<cntre<<"\n";
		
	}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=924844033,MAX=1503*1503,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;
        int a,L;cin>>a>>L;
        S=to_string(a);
        if(L==0) break;
        
        int cnt=2;
        map<int,int> MA;
        MA[a]=1;
        while(1){
            while(S.size()<L) S='0'+S;
            
            string T=S;
            sort(all(T));
            
            int A,B;
            B=stoi(T);
            
            reverse(all(T));
            A=stoi(T);
            
            if(MA[A-B]!=0){
                cout<<MA[A-B]-1<<" "<<A-B<<" "<<cnt-MA[A-B]<<endl;
                break;
            }
            MA[A-B]=cnt;
            
            cnt++;
            S=to_string(A-B);
        }
    }
}






Measured memory_bytes: 3300
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep(i, K) ans += a[i];
    pt(ans);
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 100007;
const LD EPS = 1e-7;

int n;

int gcd(int a, int b) { return (a ? gcd(b % a, a) : b); }

int solve(vector <int> B)
{
	int cnt = 0, p;
	REP(i, n)
		if (B[i] & 1)
			p = i;
		else
			++cnt;
	if (cnt & 1)
		return 1;
	if (cnt < n - 1 || B[p] == 1)
		return 2;
	--B[p];
	int g = B[0];
	REP(i, n)
		g = gcd(g, B[i]);
	REP(i, n)
		B[i] /= g;
	return 3 - solve(B);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	cin >> n;
	vector <int> A(n);
	REP(i, n)
		cin >> A[i];
	cout << (solve(A) == 1 ? "First" : "Second");
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll> m(n);
    REP(i,n){
        cin >> m[i];
    }
    x -= accumulate(m.begin(),m.end(),0ll);
    sort(m.begin(),m.end());
    ll ans = n;
    ans += x/m[0];
    cout << ans << endl;
}


Measured memory_bytes: 256
k,t,*a=map(int,open(0).read().split())
a.sort()
x=a[0]
ans=a[0]
for i in range(1,t):
  if x<a[i]:
    ans=+(a[i]-x)
  else:
    ans=0
  x+=a[i]
print(max(ans-1,0))

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

int main(){
    int ans=0,sum=0;

    string s;
    cin >>s;
    int n[s.size()]={};

    int i=0;


    while (i < s.size()){
        int r,l;
        int rn,ln;
        
        if(s[i]=='R'){
            r=i;

            while (s[i]!='L'){
                i++;
            }

            l=i;
            rn=i-r;
            r=i-1;

            if(i==s.size()-1){
                ln=1;
                i++;
            }else{

                while (s[i]!='R' && i<s.size()){
                    i++;
                }
                
                ln = i-l;
            }

            //cout << r<<l<< s[i] <<endl;


            n[r] = rn - (rn/2) + (ln/2);
            n[l] = ln - (ln/2) + (rn/2);

        }
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    for (int j = 0; j < s.size(); j++)
    {
        cout << n[j] << ' ';
    }
    cout << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
using namespace std;
using ll=long long;
using ld=long double;
#define ssort(n) sort((n).begin(),(n).end())
typedef pair<int,int> P;

int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> d(K);
    rep(i,K)cin >> d[i];
    int cost=N;
    int beam=0;
    vector<bool> dontlike(10);
    rep(i,10)dontlike[i]=false;
    rep(i,K)dontlike[d[i]]=true;
    int val;
    bool flag=true;
    while(1){
        cost=N;
        while(cost>=1){
            val=cost%10;
            if(dontlike[val]==true){
                flag=false;
                break;
            }
            cost/=10;
        }
        if(flag){
            cout << N << endl;
            return 0;
        }else{
            N+=1;
            flag=true;
        }
    }
 

}

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

int main(){
  int N; std::cin >> N;
  auto r = 1;
  auto odd = 1;
  for(auto i=0; i<N; ++i){
    int a; std::cin >> a;
    r *= 3;
    if(a%2 == 0)
      odd *= 2;
  }
  std::cout << r-odd << '\n';
}


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

using namespace std;

using ii = pair<int, int>;
using ll = long long;

int const maxn = 3030;
int const maxm = 201010;
int const mod = 1e9 + 7;

int fac[maxm], invf[maxm];

int mul(int a, int b) {
    return (ll)a*b%mod;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0) {
        a += mod;
    }
    return a;
}

int fexp(int a, int b) {
    int res = 1;
    while (b) {
        if (b&1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

int inv(int x) {
    return fexp(x, mod-2);
}

void init() {
    fac[0] = 1;
    invf[0] = 1;
    for (int i = 1; i < maxm; i++) {
        fac[i] = mul(fac[i-1], i);
        invf[i] = inv(fac[i]);
    }
}

int bin(int n, int k) {
    if (n < 0 or k < 0 or k > n) return 0;
    return mul(fac[n], mul(invf[n-k], invf[k]));
}

int f(int x, int y) {
    return bin(x+y, y);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    init();

    int h, w, n;
    cin >> h >> w >> n;

    vector<ii> v(n);
    for (auto& i : v) {
        cin >> i.first >> i.second;
    }

    v.emplace_back(h, w);

    sort(
        v.begin(), v.end(),
        [] (ii a, ii b) {
            return a.first + a.second < b.first + b.second;
        }
    );

    vector<int> dp(n+1);

    for (int i = 0; i <= n; i++) {
        int r = f(v[i].first-1, v[i].second-1);
        for (int j = 0; j < i; j++) {
            if (v[j].first <= v[i].first and v[j].second <= v[i].second) {
                r = sub(r, mul(dp[j], f(v[i].first - v[j].first, v[i].second - v[j].second)));
            }
        }
        dp[i] = r;
    }
    cout << dp[n] << "\n";
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e6 + 123;

int n, k;
set <int> s;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif	
	Fast_Read_Out();
	Random();
	string s = "";
	cin >> s;
	for(int i = 1; i <= sz(s); i++) cout << 'x';
}                                

Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc146/tasks/abc146_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;

    int x;

    if(s == "SUN")
        x = 7;
    else if(s == "SAT")
        x = 1;
    else if(s == "FRI")
        x = 2;
    else if(s == "THU")
        x = 3;
    else if(s == "WED")
        x = 4;
    else if(s == "TUE")
        x = 5;
    else if(s == "MON")
        x = 6;

    cout<<x;

    return 0;
}


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

int main() {

	string res = "No";
	string S, T; cin >> S >> T;
	T = T + T;
	int mylen = S.length();

	for (int i = 0; i <= mylen - 1; i++) if (T.substr(i, mylen) == S) res = "Yes";

	cout << res << endl;
}

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

struct State {
  int i, j, v;
};
string m[1002];
int H, W, N;
bool visit[1002][1002];
const int di[4] = {0,0,-1,1};
const int dj[4] = {1,-1,0,0};

int solve() {
  int srcI, srcJ;
  // search source
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      if (m[i][j] == 'S')
	srcI = i, srcJ = j;
  // bfs
  int ret = 0;
  for (int destValue = 1; destValue <= N; ++destValue) {
    queue<State> Q;
    memset(visit, 0, sizeof visit);
    Q.push((State){srcI, srcJ, 0});
    while(!Q.empty()) {
      State s = Q.front(); Q.pop();
      if (visit[s.i][s.j]) continue;
      visit[s.i][s.j] = true;
      // is goal
      if (m[s.i][s.j]-'0' == destValue) {
	srcI = s.i, srcJ = s.j;
	ret += s.v;
	break;
      }
      for (int i = 0; i < 4; ++i) {
	const int ni = s.i + di[i], nj = s.j + dj[i];
	if (ni < 0 || nj < 0 || H <= ni || W <= nj) continue;
	if (visit[ni][nj] || m[ni][nj] == 'X') continue;
	Q.push((State){ni, nj, s.v + 1});
      }
    }
  }
  return ret;
}

int main() {
  while (cin >> H >> W >> N) {
    for (int i = 0; i < H; ++i)
      cin >> m[i];
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (ll)(n); ++i)
#define MAX 50000001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int mazeMin(int sx, int sy, int gx, int gy);

int ans, cnt;
int H, W;
vector<vector<char>> maze;


int main() {
	cin >> H >> W;
	maze.assign(H, vector<char>(W, '~'));
	rep(i, H) {
		rep(j, W) {
			cin >> maze[i][j];
		}
	}
	
	/*rep(i, H) {
		rep(j, W) {
			cout << maze[i][j] << " ";
		}
		cout << endl;
	}*/
	
	rep(xi, H) {
		rep(yi, W) {
			rep(xj, H) {
				rep(yj, W) {
					if (maze[xi][yi] != '#' && maze[xj][yj] != '#') {
						int temp = mazeMin(xi, yi, xj, yj);
						ans = max(ans, temp);
					}
				}
			}
		}
	}
	cout << ans << endl;
	

	return 0;
}


const int INF = 1000000;
typedef pair<int, int> P;

int d[30][30];

int mazeMin(int sx, int sy, int gx, int gy) {
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };

	queue<P> que;
	rep(i, H) {
		rep(j, W) {
			d[i][j] = INF;
		}
	}
	que.push(P(sx, sy));
	d[sx][sy] = 0;

	while (que.size()) {
		P p = que.front();
		que.pop();

		if (p.first == gx && p.second == gy) break;

		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}



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

int main(){

    int N, M; 
    cin >> N >> M;
    int H[N];
    rep (i, N) cin >> H[i];
    int A[M];
    int B[M];
    rep (i, M){
        int a, b;
        cin >> a >> b;
        A[i] = a - 1;
        B[i] = b - 1;
    }

    vector<int> good(N, 1);
    rep (i, M){
        if (H[A[i]] > H[B[i]]) good[B[i]] = 0;
        else if (H[B[i]] > H[A[i]]) good[A[i]] = 0;
        else {
            good[A[i]] = 0;
            good[B[i]] = 0;
        }
    }

    int ans = 0;
    rep (i, N) ans += good[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int cnt1 = h1 * 60 + m1;
  int cnt2 = h2 * 60 + m2;
  cout << cnt2 - cnt1 - k << '\n';




  
  return 0;
}

Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int i = in.nextInt();

            out.println(n - i + 1);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21460
#include <stdio.h>
 struct C {
    char suit;
    int number;
};
int main() {
    int i, j, n, fl = 0, minj;
    char s[5];
    struct C cap1[36], cap2[36], v;
  
    scanf("%d", &n);
    for (i = 0; i < n; i++) { 
        scanf("%s", s);
        cap1[i].suit = s[0];
        cap1[i].number = atoi(s + 1);
        cap2[i] = cap1[i];
    }
    for (i = 0; i < n; i++) {
        for (j = n - 1; j >= i; j--) {
            if (cap1[j].number < cap1[j - 1].number) {
                v = cap1[j];
                cap1[j] = cap1[j - 1];
                cap1[j - 1] = v;
            }
        }
    }
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            if (cap2[j].number < cap2[minj].number){
                minj = j;
            }
        }
        v = cap2[i];
        cap2[i] = cap2[minj];
        cap2[minj] = v;
    }
    for (i = 0; i < n; i++) {
        printf("%c%d", cap1[i].suit, cap1[i].number);
        if (i != n - 1){
            printf(" ");
        }
    }
    printf("\nStable\n");
    for (i = 0; i < n; i++) {
        printf("%c%d", cap2[i].suit, cap2[i].number);
        if (i != n - 1){
            printf(" ");
        }
    }
    for (i = 0; i < n; i++) {
        if ((cap1[i].suit != cap2[i].suit) || (cap1[i].number != cap2[i].number)) { 
            fl = 1;
            break;
        }
    }
    if (fl == 1){
        printf("\nNot stable\n");
    }
    else printf("\nStable\n");
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<pair<int, int>>> v(C+1);
    for(int i=0; i<N; ++i){
        int s, t, c;
        cin >> s >> t >> c;
        v[c].push_back(make_pair(s, t));
    }
    vector<int> cnt(100001, 0);
    for(int i=1; i<=C; ++i){
        sort(v[i].begin(), v[i].end());
        int now=0;
        for(int j=0; now<v[i].size(); ++j){
            if(v[i][now].first<=j) ++cnt[j];
            if(v[i][now].second==j) ++now;
        }
    }
    int ans=0;
    for(int i=0; i<100001; ++i) ans=max(ans, cnt[i]);
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize, m: usize,
        p: [(Usize1, Usize1); m],
    }
    let mut c = vec![0; n];
    for (a, b) in p {
        c[a] += 1;
        c[b] += 1;
    }
    println!("{}", c.iter().map(|i| i.to_string()).join("\n"));
}


Measured memory_bytes: 2132
n = input()
x = list(map(int,input().split()))
x.sort()
sum = 1
done = False



for i in x:

    # if 0 sum must be 0
    if i == 0:
        sum = 0
        break

    sum = sum * i

    if sum > 10**18:
        break

    



if sum > 10**18:
    print(-1)
else:
    print(sum)


Measured memory_bytes: 21580
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static int ArgMax<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) < 0) { m = a[i]; mi = i; } return mi; }
	static int ArgMin<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) > 0) { m = a[i]; mi = i; } return mi; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var S = MakeArray(N, _ => Str);
		// ...A, B..., B...A, other
		int cA = 0, cB = 0, cBA = 0;
		var ans = 0;
		foreach (var s in S)
		{
			if (s[0] == 'B' && s[s.Length - 1] == 'A') cBA++;
			else if (s[0] == 'B') cB++;
			else if (s[s.Length - 1] == 'A') cA++;
			for (var i = 1; i < s.Length; i++) if (s[i - 1] == 'A' && s[i] == 'B') ans++;
		}
		//WriteLine($"ans={ans}, cA={cA}, cB={cB}, cBA={cBA}");
		if (cA == 0 && cB == 0)
		{
			if (cBA >= 2) ans += cBA - 1;
		}
		else if (cA == 0 || cB == 0) ans += cBA;
		else ans += Min(cB + cBA, cA + cBA);
		WriteLine(ans);
	}
}


Measured memory_bytes: 13216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int ans = 0;

		for(int i = a; i <= b; i++){
			if(c%i == 0)ans++;
		}

		System.out.printf("%d\n",ans);
	}
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, T;
  cin >> N >> T;
  int c[N], t[N];
  for (int i = 0; i < N; i++) cin >> c[i] >> t[i];

  int ans = 100000;
  for (int i = 0; i < N; i++) if (t[i] <= T) {
    ans = min(ans, c[i]);
  }
  
  if (ans == 100000) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


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

n1, n2 = map(int, input().split())

l1 = [int(x) for x in list(str(n1))]
l2 = [int(x) for x in list(str(n2))]

n1Low = n1%100
n2Low = n2%100

n1HighRev = int(str(l1[1])+str(l1[0]))
n2HighRev = int(str(l2[1])+str(l2[0]))

ans = 0

if n1Low <= n1HighRev:
    ans += 1
if n2Low >= n2HighRev:
    ans += 1

if l1[0] != l2[0]:
    ans += 9 - l1[2] + l2[2]
    ans += (l2[0] - l1[0] - 1) * 100
    ans += (9 - l1[1] + l2[1]) * 10
else:
    if l1[1] != l2[1]:
        ans += 9 - l1[2] + l2[2]
        ans += (l2[1] - l1[1] - 1) * 10
    else:
        ans += l2[2] - l1[2]-1
print(ans)



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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

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

    int N;
    cin >> N;

    string c;
    cin >> c;

    // 0 ... N
    vector<int> W(N + 1, 0);
    vector<int> R(N + 1, 0);

    REPinit(i, 1, N + 1) {
        W[i] = W[i - 1] + ((c[i - 1] == 'W') ? 1 : 0);
        R[N - i] = R[N - i + 1] + ((c[N - i] == 'R') ? 1 : 0);
    }

    int ans = 200001;
    REPinit(i, 0, N + 1) {
        if (W[i] <= R[i]) {
            ans = ((ans < R[i]) ?  ans : R[i]);
        }
        else {
            ans = ((ans < W[i]) ?  ans : W[i]);
        }
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5168
#include <stdio.h>

int main(void)
{
    char S[11],T[11],U[11];
    int A,B,f=0,i=0;

    scanf("%s %s",S,T);
    scanf("%d %d",&A,&B);
    scanf("%s",U);

    while(U[i] != '\0'){
        if(S[i]!=U[i]){
            f=1;
        }
        i++;
    }
    if(f == 1){
        printf("%d %d\n",A,B-1);
    } else {
        printf("%d %d\n",A-1,B);
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
const int maxn = 310;
const int mod = 998244353;

ll dp[maxn][maxn*maxn][2];
int n, sum;

void add(ll &x, ll y) { x += y; if(x >= mod) x -= mod; }

ll ksm(ll a, ll n) {
    ll res = 1;
    while(n) {
        if(n&1) res = res*a%mod;
        a = a*a%mod;
        n >>= 1;
    }
    return res;
}

int main() {
    scanf("%d", &n);
    dp[0][0][0] = dp[0][0][1] = 1;
    for (int x, i=1; i<=n; ++i) {
        scanf("%d", &x);
        sum += x;
        for (int j=0; j<=sum; ++j) {
            dp[i][j][0] = dp[i-1][j][0];
            dp[i][j][1] = dp[i-1][j][1]*2%mod;
            if(j>=x) {
                add(dp[i][j][0], dp[i-1][j-x][0]);
                add(dp[i][j][1], dp[i-1][j-x][1]);
            }
        }
    }

    ll ans = ksm(3, n);
    for (int i=(sum+1)/2; i<=sum; ++i) add(ans, mod-dp[n][i][1]*3%mod);
    if(sum%2==0) add(ans, dp[n][sum/2][0]*3%mod);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 450816
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int b[200010];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		if((a[i]+i+1)<=200005&&a[i]<=200000){
			b[a[i]+i+1]++;
		}
		if((i-a[i]+1)>=0) ans+=b[i-a[i]+1];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5184
def main():
    price, dilike_num = map(int, input().split())
    # dislike_data = list(map(int, input().split()))
    dislike_data = input().split()
    dislike_set = set(dislike_data)

    now_price = price
    while 1:
        now_price_set = set(list(str(now_price)))
        if len(now_price_set & dislike_set) == 0:
            break
        now_price += 1

    print(now_price)


if __name__ == '__main__':
    main()

Measured memory_bytes: 40812
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int n, l, q;
int x[100010];
int cango[100010][21] = {};

void calc()
{
	for(int i = 1; i <= n; i++){
		int cnt = cango[i - 1][0] + 1;
		while(cnt <= n && x[cnt] - x[i] <= l) cnt++;
		cnt--;
		cango[i][0] = cnt;
	}
	for(int i = 1; i <= 20; i++){
		for(int j = 1; j <= n; j++){
			cango[j][i] = cango[cango[j][i - 1]][i - 1];
		}
	}
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> x[i];
	}
	cin >> l;
	calc();
	cin >> q;
	for(int i = 0; i < q; i++){
		int a, b;
		cin >> a >> b;
		if(a > b) swap(a, b);
		int ans = 1;
		for(int i = 20; i >= 0; i--){
			if(cango[a][i] < b){
				ans += (int)pow(2, i);
				a = cango[a][i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	int d, r;
	double x = 0, y = 0, nr = 0;
	while( scanf("%d,%d", &d, &r), d || r ){
		double rad = nr/180*M_PI;
		x += (cos(rad)*d);
		y += (sin(rad)*d);
		nr += r;
	}
	cout << (int)y << endl;
	cout << (int)x << endl;
}

Measured memory_bytes: 1212
#include<stdio.h>

int main(void){

  long long int h,w,sum;
  scanf("%llu %llu",&h,&w);
   sum=h*w;

  if(h==1 || w==1){
    printf("1");
  }

  else if(sum%2==0){
    printf("%lld",sum/2);
  }
  else if(sum%2!=0){
    printf("%lld",sum/2+1);
  }

  return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())

NS = N
Nc = M
Ncc = Nc // 2

if NS < Ncc:
    # ccが余ってる
    Nc_single = Nc - NS * 2
    ans = NS + Nc_single // 4
else:
    # Sが余ってる
    ans = Ncc

print(ans)


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

using namespace std;

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

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

    sort(a, a + N, greater<int>());

    int tmp = 0, ans = 0;
    for (int i = 0; i < N; ++i) {
        if (tmp == a[i]) continue;
        tmp = a[i];
        ans++;
    }

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

    return 0;
}


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


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

    a, b, c = -1, -1, -1
    loop_max = int(y / 10000)
    for ia in range(loop_max + 1):
        if ia * 10000 > y:
            continue

        for ib in range(n - ia + 1):
            ic = n - ia - ib
            total = ia * 10000 + ib * 5000 + ic * 1000
            if total == y and (ia + ib + ic) == n:
                a = ia
                b = ib
                c = ic
                break

    print(" ".join(map(str, (a, b, c))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
#define MAX 100000

int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> a(MAX, 0);
    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == 'A' && s[i+1] == 'C') a[i+1] = 1;
    }
    vector<int> S(MAX + 1, 0);
    for (int i = 0; i < n; i++) {
        S[i+1] = S[i] + a[i];
    }

    for (int i = 0; i < q; i++) {
        int l, r; cin >> l >> r;
        cout << S[r] - S[l] << endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

int n;
const int Maxd=1e5+7;
vector<int>ch[Maxd],p(Maxd,-1),sz(Maxd,0);

void dfs(int x,vector<int> &p,vector<int> &sz)
{
	sz[x]=1;
	REP(i,ch[x].size())
	{
		if(ch[x][i]!=p[x])
		{
			p[ch[x][i]]=x;
			dfs(ch[x][i],p,sz);
			sz[x]+=sz[ch[x][i]];
		}
	}
}


int main()
{
	cin>>n;
	REP(i,n-1)
	{
		int x;int y;
		cin>>x>>y;
		--x,--y;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	dfs(0,p,sz);
	int c=n-1,psz=0;vector<int> path;
	while(c>=0)
	{
		path.push_back(sz[c]-psz);
		psz=sz[c];
		c=p[c];
	}
	int a=0,b=n-1,ls=0,rs=0;
	reverse(path.begin(),path.end());
	REP(i,(path.size()+1)/2)
		ls+=path[i];
	for(int i=(path.size()+1)/2;i<path.size();i++)
		rs+=path[i];
	cout<<(ls<=rs?"Snuke":"Fennec")<<endl;
	return 0;
}


Measured memory_bytes: 13436
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint x;
	cin>>x;
	cout<<1000*(x/500)+((x%500)/5)*5<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,num=9;queue<long long>q;
void bfs()
{
	while(!q.empty())
	{
		long long x=q.front(),lst=x%10;q.pop();
		for(int i=lst-1;i<=lst+1;++i)
		{
			if(i<0||i>9) continue;
			q.push(x*10+i);++num;
			if(num==k)
			{
				cout<<x*10+i;
				return;
			}
		}
	}
}
int main()
{
	cin>>k;
	for(int i=1;i<=9;++i)
	 q.push(i);
	if(k<=9) cout<<k;
	else bfs();
	return 0;
}

Measured memory_bytes: 4168
local bls, brs = bit.lshift, bit.rshift
local xor = bit.bxor
local n = io.read("*n")
local tbl = {}
for i = 1, n do
  tbl[i] = i
end
local tasks = {tbl}
local ret = {}
for i = 1, n - 1 do
  ret[i] = {}
  for j = i + 1, n do
    ret[i][j - i] = 0
  end
end
local function getlen(x)
  local len = 0
  for j = 1, 9 do
    len = len + x % 2
    x = brs(x, 1)
  end
  return len % 2
end
local levels = {1}
while 0 < #tasks do
  local level = levels[#levels]
  local tbl = tasks[#tasks]
  table.remove(levels)
  table.remove(tasks)
  local tn = #tbl
  for i = 1, tn - 1 do
    for j = i + 1, tn do
      if getlen(xor(i - 1, j - 1)) == 1 then
        ret[tbl[i]][tbl[j] - tbl[i]] = level
      end
    end
  end
  local tbl1 = {}
  local tbl2 = {}
  for i = 1, tn do
    local len = getlen(i - 1)
    if len % 2 == 0 then
      table.insert(tbl1, tbl[i])
    else
      table.insert(tbl2, tbl[i])
    end
  end
  if 1 < #tbl1 then
    table.insert(tasks, tbl1)
    table.insert(levels, level + 1)
  end
  if 1 < #tbl2 then
    table.insert(tasks, tbl2)
    table.insert(levels, level + 1)
  end
end
for i = 1, n - 1 do
  for j = i + 1, n do
    io.write(ret[i][j - i])
    io.write(j == n and "\n" or " ")
  end
end


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[5], k;
ll c = 0;
int main()
{
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    cin >> k;
    for(int i = 0; i < 3; i++){

        if(k <= 0)break;
        if(i == 0){

            if(k-a[0]<= 0)c += k;
            else c += a[0]*1;
            k-=a[0];
        }
        else if(i == 1){
            if(k-a[i]<=0)c += 0;
            else c+=0;
            k-= a[i];
        }
        else{
            if(k-a[i] <= 0)c -= (1*k);
            else c-= a[i]*(1);
            k-= a[i];
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3636
inp=int(input())
top=inp//100
bot=inp-top*100
if top>=1 and top<=12:
  if bot>=1 and bot<=12:
  	print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if bot>=1 and bot<=12:
  	print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,i;
  cin >> n;
  for(i = 0;i < n;i++){
    string x;
    cin >> x;
    if(x == "Y") break;
  }
  if(i == n) cout << "Three"<<endl;
  else cout << "Four" << endl;
  // ここにプログラムを追記
}

Measured memory_bytes: 256
//C - Train Ticket

#include <iostream>
#include <string>
#include <vector>
int main()
{
  std::string strABCD;
  std::cin >> strABCD;
  size_t sizeABCD = strABCD.length();
  std::vector<int> vABCD(sizeABCD);
  for(int i = 0; i < sizeABCD; i++) vABCD[i] = strABCD[i] - '0';

  for(int i = 0; i < (1 << 3); i++)
  {
    int pro_ABCD = vABCD[0];
    for(int j = 0; j < 3; j++) //j= 0:op1, 1:op2, 2:op3　についてチェック
    {
      if(i & (1 << j)) pro_ABCD += vABCD[j + 1];
      else pro_ABCD -= vABCD[j + 1];
    }
    
    //成立する式になることが分かれば、1文字ずつ出力
    if(pro_ABCD == 7)
    {
      std::cout << vABCD[0];
      for(int j = 0; j < 3; j++)
      {
        if(i & (1 << j)) std::cout << '+';
        else std::cout << '-';
        std::cout << vABCD[j+1];
      }
      std::cout << "=7" << std::endl;
      return 0;
    }
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int H,W; cin >> H >> W;

    cout << string(W+2,'#') << "\n";

    F0R(i,H) {
        cout << "#";
        string x; cin >> x;
        cout << x << "#\n";
    }
    cout << string(W+2,'#') << "\n";



}




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

int main(){
	int N, K;
	cin >> N >> K;
	ll ans = -1e18, a[N+1], sum[N+1], pos_sum[N+1];
	sum[0] = 0, pos_sum[0] = 0;
	for(int i=1; i<=N; i++){
		cin >> a[i];
		sum[i] = sum[i-1] + a[i];
		if(a[i] > 0) pos_sum[i] = pos_sum[i-1] + a[i];
		else pos_sum[i] = pos_sum[i-1];
	}
	for(int i=1; i<=N-K+1; i++){
		ll t = sum[i+K-1] - sum[i-1] + pos_sum[i-1] + pos_sum[N] - pos_sum[i+K-1];
		if(t > ans) ans = t;
		ll s = pos_sum[i-1] + pos_sum[N] - pos_sum[i+K-1];
		if(s > ans) ans = s;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string S, T;
    cin >> S >> T;
    
    int ans = 0;
    rep(i, S.size())
        if (S[i] != T[i])ans++;
    cout << ans;
    return 0;
}



Measured memory_bytes: 3832
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import *
from sys import *


lis = ["(%s%s%s%s%s%s%s)","(%s%s%s%s(%s%s%s))","(%s%s(%s%s%s)%s%s)","((%s%s%s)%s%s%s%s)","(%s%s(%s%s%s%s%s))","((%s%s%s%s%s)%s%s)","((%s%s%s)%s(%s%s%s))"]

def makeall2(a,b,c,d):
  for e in permutations([a,b,c,d]):
    for f in product("+-*",repeat=3):
      for l in lis:
        v = l % (e[0],f[0],e[1],f[1],e[2],f[2],e[3])
        if eval(v) == 10: return v
  return 0

for s in stdin:
  [a,b,c,d] = map(int,s.split())
  if [a,b,c,d] == [0,0,0,0]: break
  print makeall2(a,b,c,d)

Measured memory_bytes: 4400
/*
srt: 2017年04月23日 09時23分44秒
		秦观《浣溪沙·漠漠轻寒上小楼》
漠漠轻寒上小楼。晓阴无赖似穷秋。淡烟流水画屏幽。
自在飞花轻似梦，无边丝雨细如愁。宝帘闲挂小银钩。
end: 2017年04月23日 09時28分07秒
*/

#include<cstdio>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();while(c!='-'&&(c<'0'||c>'9'));
	register bool f=c=='-'&&(c=getchar());
	do r=r*10+c-'0',c=getchar();while(c>='0'&&c<='9');
	if(f)r=-r;
}

int main()
{
	int n,x;long long p1=0,s1=0,p2=0,s2=0;read(n);
	while(n--)
	{
		read(x);
		p1+=x,p2+=x;
		if(n&1)
		{
			if(p1>=0)s1+=1+p1,p1=-1;
			if(p2<=0)s2+=1-p2,p2=1;
		}
		else
		{
			if(p1<=0)s1+=1-p1,p1=1;
			if(p2>=0)s2+=1+p2,p2=-1;
		}
	}
	printf("%lld\n",s1<s2?s1:s2);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    if(k==1) cout<<0<<endl;
    else cout<<n-k<<endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    k=int(input())
    ans=1
    for _ in range(n):
        ans=min(ans*2,ans+k)
    print(ans)
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template<typename T>
struct BIT {
  // 1-indexed
  int n;
  vector<T> bit;

  BIT(int n_, T d = 0):n(n_), bit(n_+1, d) {}

  void add(int i, T a) {
    if (i == 0) return;
    for (int x = i; x <= n; x += x&-x) {
      bit[x] += a;
    }
  }

  T sum(int i) {
    T s = bit[0];
    for (int x = i; x > 0; x -= x&-x) {
      s += bit[x];
    }
    return s;
  }

  T sum_between(int l, int r) {
    return sum(r) - sum(l-1);
  }

  // bit[1] + bit[2] + ... + bit[x] >= w;
  int lower_bound(T w){
    if (w <= 0) return 0;
    int x = 0, r = 1;
    while (r < n) r <<= 1;
    for (int k = r; k > 0; k >>= 1){
      if(x+k <= n && bit[x+k] < w){
        w -= bit[x+k];
        x += k;
      }
    }
    return x+1;
  }

  void add0(int i, T a) {
    add(i+1, a);
  }

  T sum0(int i) {
    return sum(i+1);
  }

  T sum_between0(int l, int r) {
    return sum(r+1) - sum(l);
  }
};

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

  int n, q;
  cin >> n >> q;

  BIT<int> bit(n);

  rep(i, q) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a) {
      cout << bit.sum_between(b, c) << endl;
    } else {
      bit.add(b, c);
    }
  }
}



Measured memory_bytes: 3272
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int k,l;
	string s;
	cin>>k;
	cin>>s;
	l=s.length();
	if(l<=k)
		cout<<s<<endl;
	else
	{
		for (int i = 0; i < k; ++i)
		{
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3616