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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



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

    int n,m,cnt=0;
    cin>>n>>m;
    vii adj[n+2];
    vii v(n+1);
    rep(i,n) cin>>v[i+1];
    rep(i,m)
    {
        int x,y;cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    for(int i=1;i<=n;++i)
    {
        int ht = v[i];
        bool f=1;
        for(auto j: adj[i])
        {
            if(ht<=v[j])
            {
                f=0;break;
            }
        }
        if(f)
            ++cnt;
    }
    cout<<cnt;

    return 0;
}


Measured memory_bytes: 8732
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

typedef long long ll;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;

typedef pair<int,int> P;

vector<P> xs,ys;

struct UnionFind
{
	vector<int> par_;

	void init(int size)
	{
		par_.resize(size, 0);
		for (int i = 0; i < size; i++)
		{
			par_[i] = i;
		}
	}
	int root(int x)
	{
		return par_[x] == x ? x : par_[x] = root(par_[x]);
	}

	bool unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y)
			return true;
		par_[x] = y;
		return false;
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
};

int main()
{
	cin >> n;


	for(int i = 0;i < n;i++)
	{
		int a,b;
		cin >> a >> b;

		xs.push_back(P(a,i));
		ys.push_back(P(b,i));

	}

	sort(xs.begin(),xs.end());
	sort(ys.begin(),ys.end());

	typedef pair<int,P> P2;

	priority_queue<P2,vector<P2>,greater<P2>> que;

	for(int i = 0;i < xs.size() - 1;i++)
	{
		int i1 = xs[i].second;
		int i2 = xs[i + 1].second;
		que.push(P2(xs[i + 1].first - xs[i].first,P(i1,i2)));
	}
	for(int i = 0;i < ys.size() - 1;i++)
	{
		int i1 = ys[i].second;
		int i2 = ys[i + 1].second;
		que.push(P2(ys[i + 1].first - ys[i].first,P(i1,i2)));
	}

	UnionFind uf;
	uf.init(n);

	int c = 0;
	int res = 0;
	while(c < n - 1)
	{
		P2 p = que.top();
		que.pop();

		int a = p.second.first;
		int b = p.second.second;

		if(!uf.same(a,b))
		{
			uf.unite(a,b);
			res += p.first;
			c++;
		}
	}

	cout << res << endl;
	return 0;






}


Measured memory_bytes: 7144
#include <iostream>
#include <vector>
#include <stack>
#include <tuple>

const int pq_max = 800;
const int n_max = 7;
const int a_max = 12000;


int f( int p, int q, int a, int n, int low ) {
	int S = 0;
	if ( p == 0 ) {return 1;}
	if ( n == 0 ) {return 0;}
	//int m = gcd(p, q);
	//p /= m; q /= m;
	
	if ( q / p > low ) low = q / p;
	int high = q * n / p;
	if ( high >= (a) ) { high = a; }

	//for ( int i = 1; i <= j; ++i ) {
	for ( int i = low; i <= high; ++i ) {
		//if ( i*p - q < 0 ) continue;
		//if ( i * b > a ) break;
		int s = i*p - q;
		int r = q * i;

		S += f(s, r, a / i, n-1, i);
	}
	return S;
}

int main(void)
{
	while ( true ) {
		int p, q, a, n;

		std::cin >> p >> q >> a >> n;
		if ( p == 0 && q == 0 ) break;
		std::cout << f(p, q, a, n, 1) << std::endl;
		
	}
	return 0;
}

Measured memory_bytes: 3004
n = int(input())
a = list(map(int, input().split()))
counter = {}
for x in a:
    if x not in counter:
        counter[x] = 1
    else:
        counter[x] += 1
ret = 0
for i, c in counter.items():
    if c >= i:
        ret += c-i
    else:
        ret += c
print(ret)

Measured memory_bytes: 17780
#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

ll sum(int l, int r, vector<ll>& pref) {
	return pref[r] - (l ? pref[l - 1] : 0);
}

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m, v, p;
	cin >> n >> m >> v >> p;

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

	sort(all(a), greater<int>());

	int ans = 0;

	if (v <= p) {
		for (int i = 0; i < n; i++) {

			if (a[i] + m >= a[p - 1]) {
				ans++;
			}
		}
		cout << ans;
		return 0;
	}

	vector<ll> pref(a.begin(), a.end());
	for (int i = 1; i < n; i++) {
		pref[i] = pref[i - 1] + a[i];
	}

	for (int i = 0; i < n; i++) {

		if (a[i] >= a[p - 1]) {
			ans++;
			continue;
		}

		int x = a[i] + m;

		if (x < a[p - 1]) continue;

		ll need = (ll)m * (v - p);
		ll can;

		if (x - a.back() < m) {

			can = (ll)x * (n - p) - (sum(p - 1, n - 1, pref) - a[i]);
		}
		else {

			int lf = p - 1;
			int rg = n - 1;
			
			while (lf < rg) {

				int md = (lf + rg) >> 1;

				if (x - a[md] < m) {

					lf = md + 1;
				}
				else {

					rg = md;
				}
			}

			can = (ll)x * (lf - p + 1) - sum(p - 1, lf - 1, pref);
			can += (ll)(n - lf) * m;
			if (i < lf) {
				
				can -= (x - a[i]);
			}
			else {

				can -= m;
			}
		}

		if (can >= need) {
			ans++;
		}
	}

	cout << ans;
}


Measured memory_bytes: 1408
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
//#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main()
{
  /*  #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif */
    fio;
    ll a,b,k;
    cin>>a>>b>>k;
    ll a1=a;
    a=max((ll)0,a-k);
    if(a==0)
    {
        k=k-a1;
    }
    else
    {
        k=0;
    }
    b=max((ll)0,b-k);
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000001
 
int Partition(int, int );
int A[N];
 
int main(void){
int i,n,y;
  
 scanf("%d",&n);
 
 for(i=1;i<=n;i++){
   scanf("%d",&A[i]);
 }
  
 y=Partition(1,(n));
  
 for(i=1;i<n;i++){
 
   if (i==y){
     printf("[%d] ",A[i]);
   }
   else printf("%d ",A[i]);
 }
  
 printf("%d\n",A[n]);
  
 return 0;
  
}
 
int Partition(int p, int r){
  int i, j, x, k;
   
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
 
    if(A[j]<=x){
      i++;      
      k=A[i];
      A[i]=A[j];
      A[j]=k; 
    }
 
  }
  k=A[i+1];
  A[i + 1] = A[r];
  A[r]=k;
  return i+1;
   
}

Measured memory_bytes: 988
#include <iostream>
#include <cmath>

using namespace std;

int n;
double sin60, cos60;

void f(double x1, double y1, double x2, double y2, int d) {
    if (d == n) {
        cout << x2 << " " << y2 << endl;
        return;
    }

    double sx, sy, tx, ty, ux, uy;
    sx = (2 * x1 + x2) / 3;
    sy = (2 * y1 + y2) / 3;
    tx = (x1 + 2 * x2) / 3;
    ty = (y1 + 2 * y2) / 3;
    ux = (tx - sx) * cos60 - (ty - sy) * sin60 + sx;
    uy = (tx - sx) * sin60 + (ty - sy) * cos60 + sy;

    f(x1, y1, sx, sy, d + 1);
    f(sx, sy, ux, uy, d + 1);
    f(ux, uy, tx, ty, d + 1);
    f(tx, ty, x2, y2, d + 1);
}

int main() {
    sin60 = sin(M_PI / 3);
    cos60 = cos(M_PI / 3);
    cin >> n;

    cout << "0 0" << endl;
    f(0, 0, 100, 0, 0);

    return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
  int W,n,v[1000],w[1000],dp[1001][1001],t=1;

  while(cin >> W,W){
    cin >> n;

    for(int i=0;i<n;i++)
    scanf("%d,%d",&v[i],&w[i]);

    for(int i=0;i<1000;i++)
      for(int j=0;j<1000;j++)
	dp[i][j]=0;
    
    for(int i=0;i<n;i++)
      for(int j=0;j<=W;j++)
	if(j<w[i])dp[i+1][j]=dp[i][j];
	else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);

    cout << "Case " << t << ":" << endl;
    
    for(int i=W;i>=0;i--){
      if(dp[n][i] != dp[n][W]){
	cout << dp[n][W] << endl << i+1 << endl;
	break;
      }
    }
      t++;
  }

  return 0;
}

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

int MOD=1000000007;

int main(){
  int N; long long K; cin >> N >> K;
  int A[2000];
  for(int i=0; i<N; i++) cin >> A[i];
  
  long long inner=0,outer=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(A[i]>A[j]){
        outer++;
        if(i<j) inner++;
      }
    }
  }
  cout << (inner*K+outer*(K*(K-1)/2%MOD))%MOD << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define evn(a) (a<0?-10:(a)/2*2)
int main(){
  long I,O,J,L;
  cin>>I>>O>>J>>J>>L;
  cout<<max(O+max(evn(I)+evn(J)+evn(L),evn(I-1)+evn(J-1)+evn(L-1)+3),0L)<<"\n";
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
ps = gets.split.map(&:to_i)
rev = []
N.times do |i|
    rev[ps[i]-1] = i
end

a, b = [], []
a[0] = 1
b[0] = 10**9

(1...N).each do |i|
    diff = rev[i] - rev[i-1]
    if diff >= 0
        a[i] = a[i-1] + diff + 1
        b[i] = b[i-1] - 1
    else
        a[i] = a[i-1] + 1
        b[i] = b[i-1] + diff - 1
    end
end

puts a.join(' '), b.join(' ')

Measured memory_bytes: 5244
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double)a / (double)b;
        System.out.println(d+" "+r+" "+String.format("%.10f", f));
    }
}



Measured memory_bytes: 26500
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N;
	cin >> N;
	string res;
	for (int i = 0; i < S.size(); i+=N) {
		res.push_back(S[i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1)/2)<<endl;
}

Measured memory_bytes: 256
x,n=map(int,input().split())
l=list(map(int,input().split()))
def y(x,l):
    k=0
    while k>-1:
        if x-k not in l:
            return (x-k)

        elif x+k not in l:
            return (x+k)
        else:
            k+=1

print(y(x,l))

Measured memory_bytes: 9184
#include<bits/stdc++.h>
long long go_jo[1000];
int main(){
    for(long long i=0LL; i<1000LL; i++){
        go_jo[i] = pow(i,5);
    }
    int x;
    std::cin >> x;
    int a=10000, b=10000;
    for(int i=0; i<1000; i++){
        if(a!=10000) break;
        for(int j=i+1; j<1000; j++){
            if(go_jo[i]+go_jo[j] == x) {
                a=i;
                b=-j;
                break;
            }
            if(go_jo[i]-go_jo[j] == x) {
                a = i;
                b = j;
                break;
            }
            if(-go_jo[i]+go_jo[j] == x) {
                a=j;
                b=i;
                break;
            }
            if(-go_jo[i]-go_jo[j] == x) {
                a = -i;
                b = j;
                break;
            }
        }
    };

    std::cout << a << ' ' << b << std::endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - T or T
            var line = ReadLine();
            int N = line[0];
            int A = line[1];
            int B = line[2];

            if (A * N > B)
            {
                Console.WriteLine(B);
            }
            else
            {
                Console.WriteLine(A * N);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

int main(){
  int n,deli;
  cin >> n;
  deli=0;
  vector<int> a(n,0),b(n,0),c(n-1,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  for(int i=0;i<n;i++){
    deli+=b[a[i]-1];
    if(a[i]-1==a[i-1])
      deli+=c[a[i]-2];
  }
  cout << deli << endl;
  

}
             
            
          
      
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  cin >> n;
  vt<i64> a(n);
  i64 sum = 0;
  rep(i, 0, n) {
    cin >> a[i];
    sum += a[i];
  }

  i64 ans = 1e18;
  i64 l = 0, r = sum;
  rep(i, 0, n - 1) {
    l += a[i], r -= a[i];

    i64 res = 0;
    if(l < r) res = r - l;
    else res = l - r;
    ans = min(ans, res);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn];
int main()
{
	int n;cin>>n;
	ll k;cin>>k;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	ll ans = 0;
	ll tmp = (k*(k-1)/2) % mod;
	for(int i=1;i<=n;i++){
		int x = 0,y = 0;
		for(int j=1;j<=n;j++)
			if(a[j]<a[i])x++;
		for(int j=i+1;j<=n;j++)
			if(a[j]<a[i])y++;
		ans = (ans+y*k+x*tmp) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll maxn = 200000 + 10;

ll R, C, n, stk[maxn << 1], top = 0;
struct data{
  ll l, r;
  data() {}
  data(ll _l, ll _r):l(_l), r(_r) {}
  
  friend bool operator < (data a, data b) {
    return a.l < b.l;
	}
}a[maxn], b[maxn << 1];

int main() {
  scanf("%d%d%d", &R, &C, &n);
  R ++; C ++; ll tot = 0;
  for(ll i = 1;i <= n;i ++) {
    ll x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x1 ++; x2 ++; y1 ++; y2 ++;
    if(x1 > x2) swap(x1,x2), swap(y1,y2);
    if(x1 == 1 && x2 == R) {
      a[++ tot] = data(R + C + C - y2 + 1,y1);
      continue;
		}
		if(y1 > y2) swap(x1,x2), swap(y1,y2);
		if(y1 == 1 && y2 == C) {
		  a[++ tot] = data(R + 2 * C + R - x1 + 1,C + x2); 
		  continue;
		}
		if(y2 == 1 && x1 == 1) swap(x1,x2), swap(y1,y2);
		if(y1 == 1 && x2 == 1) {
			a[++ tot] = data(R + 2 * C + R - x1 + 1,y2);
			continue;
		}
		if(y2 == 1 && x1 == R) swap(x1,x2), swap(y1,y2);
		if(y1 == 1 && x2 == R) {
		  a[++ tot] = data(R + 2 * C + R - x1 + 1,R + C + C - y2 + 1);
		  continue;
		}
		if(x2 == R && y1 == C) swap(x1,x2), swap(y1,y2);
		if(x1 == R && y2 == C) {
			a[++ tot] = data(R + C + C - y1 + 1,C + x2);
			continue;
		}
		if(x2 == 1 && y1 == C) swap(x1,x2), swap(y1,y2);
		if(x1 == 1 && y2 == C) {
			a[++ tot] = data(C + x2,y1);
			continue;
		}
		if(x1 == 1 && x2 == 1) {
		  a[++ tot] = data(y2,y1);
		  continue;
		}
		if(y1 == C && y2 == C) {
		  a[++ tot] = data(C + x2,C + x1);
		  continue;
		}
		if(x1 == R && x2 == R) {
		  a[++ tot] = data(R + C + C - y1 + 1,R + C + C - y2 + 1);
		  continue;
		}
		if(y1 == 1 && y2 == 1) {
		  a[++ tot] = data(R + 2 * C + R - x1 + 1,R + 2 * C + R - x2 + 1);
		  continue;
		}
	}
	for(int i = 1;i <= tot;i ++) if(a[i].l > a[i].r) swap(a[i].l,a[i].r); 
	ll cnt = 0;
	for(ll i = 1;i <= tot;i ++) {
	  b[++ cnt].l = a[i].l, b[cnt].r = i;
	  b[++ cnt].l = a[i].r, b[cnt].r = - i;
	}
	sort(b + 1,b + cnt + 1);
	top = 0;
	for(ll i = 1;i <= cnt;i ++) {
		if(b[i].r > 0) stk[++ top] = b[i].r;
		else {
		  if(stk[top] != - b[i].r) {
		    puts("NO");
		    return 0;
			}
			top --;
		}
	}
	if(top) puts("NO");
	else puts("YES");
  return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin>>n>>s;
    if(n%2){
        cout <<"No"<<endl;
    }
    else{
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                cout << "No"<<endl;
                return 0;
            }
        }
        cout<< "Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, i, j;
	while(1){
		scanf("%d%d", &a, &b);
		if(a == 0 && b == 0){
			break;
		}
		for(i = 0;i < b;i++){
			printf("#");
		}
		printf("\n");
		for(i = 2;i < a;i++){
			printf("#");
			for(j = 2;j < b;j++){
				printf(".");
			}
			printf("#\n");
		}
		for(i = 0;i < b;i++){
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <set>

int n, m, k;
std::vector<std::vector<int>> blocks;
std::vector<int> father, size, friends;

int find (int x) {
  return x == father[x] ? x : father[x] = find(father[x]);
}

void merge (int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx != fy) {
    father[fx] = fy;
    size[fy] += size[fx];
  }
}

int main () {
  std::cin >> n >> m >> k;
  father.resize(n);
  blocks.resize(n);
  friends.assign (n, 0);
  size.assign(n, 1);
  for (int i = 0; i < n; ++i)
    father[i] = i;
  for (int i = 0; i < m; ++i) {
    int x, y;
    std::cin >> x >> y;
    x--, y--;
    merge(x, y);
    friends[x]++, friends[y]++;
  }
  for (int i = 0; i < k; ++i) {
    int x, y;
    std::cin >> x >> y;
    x--, y--;
    blocks[x].push_back(y);
    blocks[y].push_back(x);
  }
//  for (int i = 0; i < n; ++i)
//    std::cout << friends[i] << " \n"[i+1==n];
//  for (int i = 0; i < n; ++i)
//    std::cout << find (i) << " \n"[i+1==n];
//  for (int i = 0; i < n; ++i)
//    std::cout << size[i] << " \n"[i+1==n];
  for (int i = 0; i < n; ++i) {
    int ans = size[find(i)];
    for (int j = 0; j < blocks[i].size(); ++j)
      if (find(i) == find(blocks[i][j]))
        ans--;
    std::cout << ans - friends[i] - 1 << " \n"[i+1==n];
  }
  return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>fruit(n);
  for(int i=0; i<n; i++) cin>>fruit[i];
  int sum = 0;
  sort(fruit.begin(),fruit.end());
  for(int i=0; i<k; i++) sum+=fruit[i];
  cout<<sum;
}

Measured memory_bytes: 3192
function main(lines) {
  const a = lines[0];

  const res = /[A-Z]/.test(a) ? 'A' : 'a';
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 29672
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

N = int(input())

ru = -2*10**9
lu = -2*10**9
ld = -2*10**9
rd = -2*10**9

for _ in range(N):
    x,y = map(int,input().split())
    a = x+y
    b = x-y
    ru = max2(ru,a)
    lu = max2(lu,-b)
    ld = max2(ld,-a)
    rd = max2(rd,b)

print(max2(ru+ld,lu+rd))

Measured memory_bytes: 69956
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 15;
const int INF = 0x3f3f3f3f;
int n,m,f[1<<MAXN];
int main(){
    cin >> n >> m;
    memset(f,255,sizeof(f));
    f[0] = 0;
    for(int i = 1; i <= m; i++){
        int a,b;
        cin >> a >> b;
        int msk = 0;
        while(b--){
            int t;
            cin >> t;
            msk |= (1<<(t-1));
        }
        for(int k = 0; k < (1<<n); k++){
            if(f[k]==-1) continue;
            if(f[k|msk]==-1) f[k|msk] = f[k]+a;
            else f[k|msk] = min(f[k|msk],f[k]+a);
        }
    }
    if(f[(1<<n)-1]==INF) cout << -1 << endl;
    else cout << f[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define init(a, b) memset(a, b, sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

#define MOD = 1e9+7;

/******* Debugging Class Template *******/
#define DEBUG

#ifdef DEBUG

    #define de(args...)     (Debugger()) , args

    class Debugger
    {
        public:
        Debugger(const std::string& _separator = " - ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std:cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std:cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif





int32_t main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    IOS
    
    int n,k;
    cin>>n>>k;
    vi dp(n+1,INT_MAX);
    vi cost(n+1);
    for(int i=1;i<n+1;i++) cin>>cost[i];
    dp[1]=0;
    for(int i=2;i<=n;i++){
        int ct=k;
        for(int j=i-1;j>0&&ct;j--,ct--){
            dp[i]=min(dp[i],dp[j]+abs(cost[j]-cost[i]));
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

void per(long long int n){
	long long int res=0;
	if(n>1)res++;
	for(int a=2;a*a<=n;a++){
		if(n%a==0){
			if(a==n);
			else{
				if(a==n/a)res+=a;
				else res+=a+n/a;
			}
		}
	}
	if(res>n)cout << "abundant number" << endl;
	if(res==n)cout << "perfect number" << endl;
	if(res<n)cout << "deficient number" << endl;
}

int main(void){
	long long int n;
	while(1){
		cin >> n;
		if(n==0)break;
		per(n);
	}
    return 0;
}

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

typedef long long LL;
const int N = 5005;
const LL inf = 0x3f3f3f3f3f3f3f3f;

int n, a, b;
LL dp[N][N], ans = inf;

void down(LL &x, LL y) { x = std::min(x, y); }
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::memset(dp, 0x3f, sizeof dp), std::cin >> n >> a >> b;
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i) {
		int x; std::cin >> x;
		for (int j = 0; j <= n; ++j) if (dp[i][j] < inf) {
			if (x < j)
				down(dp[i + 1][j], dp[i][j] + b);
			else
				down(dp[i + 1][x], dp[i][j]),
				down(dp[i + 1][j], dp[i][j] + a);
		}
	}
	for (int i = 0; i <= n; ++i) down(ans, dp[n][i]);
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 195968
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int S_size = S.size();
    //cout << S_size << endl; //後で削除
    int ans = 0;

    for (int i = 0; i < S_size / 2; i++) {
        if (S[i] != S[S_size - 1 - i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;


int dp[210][210];

int main(){

  int d, n;
  cin >> d >> n;

  vector<int> t(d), a(n), b(n), c(n);
  REP(i,d){
    cin >> t[i];
  }
  REP(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }

  FOR(i,1,d){
    REP(j,n){
      REP(k,n){
        if(a[j] <= t[i] && t[i] <= b[j] && a[k] <= t[i-1] && t[i-1] <= b[k]){
          dp[i+1][j] = max(dp[i+1][j], dp[i][k] + abs(c[j] - c[k]));
          }
      }
    }
  }

  int ans = 0;
  REP(i,n){
    ans = max(ans, dp[d][i]);
  }

  cout << ans << endl;


  return 0;
}




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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

ll n, a, b;

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

    cin >> n >> a >> b;
    ll ans=n/(a+b)*a;
    n%=(a+b);
    ans+=min(a, n);
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	LL n; sci(n);
	double ans = 0;
	string btc = "BTC";
	string jpy = "JPY";
	while (n--) {
		double amt; string cur;
		cin >> amt >> cur;
		if (cur == "JPY") ans += amt;
		else {
			ans += amt * 380000;
		}
	}
	printf("%lf", ans);
		return 0;
}

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

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll N,A,B;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, n){
		if(s[i] == 'A'){
			i++;
			if(i < n && s[i] == 'B'){
				i++;
				if(i < n && s[i] == 'C') ans++;
				i--;
			}
			i--;
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> as(n+1, 0), bs(n+1, 0); 
    for (int i = 1; i < n+1; ++i) {
        int a; 
        cin >> as[i];
    }
    for (int i = n; i >= 1; --i) {
        int x = as[i];
        for (int j = 2; i*j <= n; ++j) x += bs[i*j];
        bs[i] = x%2;
    }
    int m = accumulate(bs.begin(), bs.end(), 0);
    cout << m << endl;
    for (int i = 1; i < n+1; ++i) {
        if (bs[i]) cout << i << " "; 
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
n = int(input())
balls = list(map(int, input().split()))
counts = {}
for ball in balls:
    if ball in counts:
        counts[ball] = counts[ball] + 1
    else:
        counts[ball] = 1

total = 0
used = set([])
for ball in balls:
    if not ball in used:
        total += counts[ball] * (counts[ball] - 1) // 2
        used.add(ball)

for ball in balls:
    removed = counts[ball] * (counts[ball] - 1) // 2
    added = (counts[ball] - 2) * (counts[ball] - 1) // 2
    print(total - removed + added)

Measured memory_bytes: 28192
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define PI 3.14159265358979323846264338327950L
 
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d  >> e;

  int r,t;
  r = a * 60;
  t = c * 60;

  int z = t + d;
  int f = z - e;
  int q = f - (r + b);
  cout << q;

  }


Measured memory_bytes: 3596
n = int(input())
input1 = input()
an = input1.split(" ")

an_sorted = sorted(an)
flag = 0
for i in range(len(an_sorted)-1):
    if an_sorted[i] == an_sorted[i+1]:
        flag = 1
if flag == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 22328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int a, b;
    cin >> a>> b;

    if (0 < a && a < 10 && 0 < b && b < 10) {
        cout << a *b << endl;
    } else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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();

    String ans = "No";
    if (a + b == c) ans = "Yes";
    if (b + c == a) ans = "Yes";
    if (a + c == b) ans = "Yes";

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}

int main()
{
	map<string,ll> s;
	string once;
	ll N;
	cin >> N;
	for(int i=0;i<N;++i)
	{
		cin >> once;
		sort(once.begin(),once.end());
		if(s.count(once)==0)
			s[once] = 1;
		else
			s[once] ++;
	}
	ll ans = 0;
	for( auto i = s.begin(); i != s.end() ; ++i ) {
		//cout << i->first << " " << i->second << endl;
		ans += i->second*(i->second-1)/2;
    }
    cout << ans << endl;
	return 0;
}




















Measured memory_bytes: 11136
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, W = na()
wv = [na() for _ in range(n)]
dp = [0]+[float("inf")]*(10**5)
for i in range(n):
      for j in range(10**5,wv[i][1]-1,-1):
        dp[j] = min(dp[j],dp[j-wv[i][1]]+wv[i][0])

res = 0
for v,e in enumerate(dp):
  if e <= W:
    res = v
    
print(res)
      

Measured memory_bytes: 93244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll minn(ll a,ll b)
{
    if(b>a) return a;
    else return b;
}
int dp[100002];
int dpsolve(vector<int> &v,int n,int i)
{
    if(dp[i]!=-1) return dp[i];
    if(i>=n) return 0;
    if(i==n-1) return dp[i]=abs(v[i+1]-v[i]);
    else if(i<=n-2)
    {
        return dp[i]=min(abs(v[i+1]-v[i])+dpsolve(v,n,i+1),abs(v[i+2]-v[i])+dpsolve(v,n,i+2));
    }
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k,v1,i=1;
    cin >> n;
    vector<int> v;
    v.push_back(0);
    for(int i=n-1;i>=0;i--)
    {
        cin >> v1;
        v.push_back(v1);
    }
    memset(dp,-1,sizeof(dp));
    cout << dpsolve(v,n,i);
	return 0;
}


Measured memory_bytes: 7988
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=505;
struct node{ll p,id;}a[N];
ll f[N][N],n,mod,l[N],r[N],cnt,ans;
ll solve(ll k){
	memset(f,0,sizeof(f));cnt=0;f[0][0]=1;
	for(ll i=1;i<=n<<1;i++){
		if(a[i-1].id<n)cnt++;
		for(ll j=0;j<=k;j++){
			if(a[i-1].id<n){
				f[i][j]=f[i-1][j]*(r[a[i-1].id]+1-((n<<1)-1-a[i-1].id+k-j))%mod;
				if(j)f[i][j]=(f[i][j]+f[i-1][j-1]*(a[i-1].p+1-(i-1-(cnt-j)))%mod)%mod;
			}else f[i][j]=f[i-1][j]*(a[i-1].p+1-(i-1-(cnt-j)))%mod;
		}
	}return f[n<<1][k];
}
signed main(){
	n=read(),mod=read();
	for(ll i=0;i<n<<1;i++){
		a[i].id=i;r[i]=min((n<<1)-1,(ll)floor(sqrt(4*n*n-i*i)));
		if(i>=n)a[i].p=r[i];else l[i]=ceil(sqrt(n*n-i*i)),a[i].p=l[i]-1;
	}sort(a,a+(n<<1),[](node a,node b){return a.p==b.p?a.id>b.id:a.p<b.p;});
	for(ll i=0;i<=n;i++)ans=(ans+(i&1?mod-1:1)*solve(i)%mod)%mod;
	return cout<<ans,signed();
}
/*
2 998244353
10 998244353
200 998244353
*/

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

int solve(int N){
    int k[10000];
    int MAX=0;
    int zcnt=0;
    for(int i=0;i<N;i++){
        cin>>k[i];
        MAX=max(MAX,k[i]);
        if(k[i]==0) zcnt++;
    }
    if(MAX<=1) cout<<"NA"<<endl;
    else cout<<N-zcnt+1<<endl;
}

int main(){
    while(1){
        int N;
        cin>>N;
        if(1<=N&&N<=10000) solve(N);
        else break;
    }
}


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

int main(){
  int a,b,x;
  cin>>a>>b>>x;
  
  if (a<=x and x<=a+b){
    cout<<"YES"<<endl;
  }
  
  else {
    cout<<"NO"<<endl;
  }
  
    
  
}

  













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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int p = c - a, q = d - b;
  cout << c - q << " " << d + p << " " << a - q << " " << b + p << endl;
}

Measured memory_bytes: 3652
/* 
    Author : Jeff Ahn
    Sat 15 Aug 2020 05:05:30 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

const int mn = 110;
int l[mn];

signed main() {
  fastio;

  int N; cin >> N;
  rep(i,N) {
    cin >> l[i];
  }

  int res = 0;
  for (int i = 0; i < N; i++) {
    int li = l[i];
    for (int j = i + 1; j < N; j++) {
      int lj = l[j];
      if (li == lj) continue;
      for (int k = j + 1; k < N; k++) {
        int lk = l[k];
        if (lk == li or lk == lj) continue;
        if (li + lj > lk and li + lk > lj and lk + lj > li) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3648
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int T, X;
  	cin >> T >> X;
  	cout << (double)T/X << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

int main() {
  int N, H;
  cin >> N >> H;
  vector<pair<int, int> > data(2*N);
  int ans = 0;
  REP(i,N) {
    int a, b; cin>>a>>b;
    data[2*i] = make_pair(a, 1);
    data[2*i+1] = make_pair(b, 0);
  }
  sort(data.begin(), data.end());
  for(int i = data.size() - 1; i >= 0; i--) {
#ifdef DEBUG
    cout << data[i].first << " " << data[i].second << endl;
#endif
    if(data[i].second == 1) {
      int tmp = H / data[i].first;
      H -= tmp * data[i].first;
      ans += tmp;
      if(H > 0) {ans++; H-=data[i].first;}
#ifdef DEBUG
      cout << "A " << data[i].first << " " << ans << " " << H << endl;;
#endif
      break;
    } else {
      H -= data[i].first;
      ans++;
#ifdef DEBUG
      cout << "B " << data[i].first << " " << ans << " " << H << endl;;
#endif
      if(H <= 0) break;
    }
  }
  cout << ans  << endl;
  return 0;
}


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

int main() {
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int diff = b - a;
    if(diff % 2 == 0) puts("Alice");
    else puts("Borys");
    return 0;
}

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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,b,c,a;
string s;

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    if(n==1)cout<<"Hello World"<<endl;
    else cout<<a+b<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
    
}
int main(){
    string s;
    cin >> s;
    if(s.at(0) == '7' || s.at(1) == '7' || s.at(2) == '7'){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    solve();
    return 0;
}



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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	ll x, k, d; cin >> x >> k >> d;
	ll need = abs(x) / d;
	if (need > k) {
		if (x > 0)x -= k * d;
		else x += k * d;
		cout << abs(x); return ;
	}
	if (x > 0) {
		x -= need * d;
		k -= need;
		if (k & 1)cout << abs(x - d);
		else cout << x;
	}
	else {
		x += need * d;
		k -= need;
		if (k & 1)cout << abs(x + d);
		else cout << abs(x);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

int main(){
   string s;
   int q,k,u;
   char c;
   cin>>s>>q;
   int flag=0;
   while(q--){
    cin>>u;
    if(u==1){
        flag++;
    }
    else{
        cin>>k>>c;
        if(flag%2==0){
            if(k==1) s.insert(s.begin(),c);
            else s.insert(s.end(),c);
        }
        else{
            if(k==1) s.insert(s.end(),c);
            else s.insert(s.begin(),c);
        }
      }
   }
   if(flag%2==1) reverse(s.begin(),s.end());
   cout<<s;
   return 0;
}


Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  cioacc();
  int n;
  cin >> n;
  vl a(n);
  REP(i,n){
    int in;
    cin >> in;
    a.at(i) = in -i-1;
  }
  sort(ALL(a));
  int md = a.at((n-1)/2);
  int ans = 0;
  REP(i,n) ans += abs(a.at(i)-md);
  cout << ans << endl;
  // cout << accumulate(ALL(a),0,[](int left,int right){return left+abs(right);}) << endl;
}

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

int main() {
	int N, A[USHRT_MAX];
	cin >> N;

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

	sort(A, A + N);
	cout << A[N - 1] - A[0] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int a,b,n;
    char t;
    string str,order,p;
    cin >> str >> n;
    for(int i=0;i<n;i++){
        cin >> order >> a >> b;
        if(order == "print"){
            cout << str.substr(a,b-a+1) << endl;
        }
        
        else if(order == "reverse"){
            for (int i=0;i<(b-a+1)/2;i++){
				char t = str[a+i];
				str[a+i] = str[b-i];
				str[b-i] = t;
			}
        }
        else if(order == "replace"){
            cin >> p;
            str = str.erase(a,b-a+1);
            str = str.insert(a,p);
        }
    }
}


Measured memory_bytes: 3220