akhauriyash/Code-Regression huggingface dataset:
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=1e5+10;

int n;
LL l,a[N];
int main() {
    R(n,l);
    REP1(i,1,n) R(a[i]);

    int w=0;
    REP1(i,1,n-1) if ( a[i]+a[i+1]>=l ) w=i;
    if ( w==0 ) {
        W("Impossible");
    } else {
        W("Possible");
        REP1(i,1,w-1) W(i);
        for ( int i=n-1; i>=w; i-- ) W(i);
    }
    return 0;
}


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

int main ( )  {

	int N, Y ;
	scanf ( "%d%d", & N, & Y ) ;
	Y /= 1000 ;

	for ( int z = 0 ; z <= N ; ++ z )  {
		static int x, y ;
		
		if ( ( Y + 4 * z - 5 * N ) % 5 )  continue ;

		x = ( Y + 4 * z - 5 * N ) / 5, y = N - z - x ;

		if ( x >= 0 && y >= 0 )  {
			return printf ( "%d %d %d\n", x, y, z ), 0 ;
		}

	}
	return puts ( "-1 -1 -1" ), 0 ;

}


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

int N;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    int two = 0, four = 0;
    rep(i, N) {
        int a; cin >> a;
        if (a%4==0) four++;
        else if (a%2==0) two++;
    }
    if (four>=N/2 or N-two-four<=four) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long N, A[100100], kotak, kotak2;
 
int main() {
    cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }
    sort(A+1, A+N+1);
    for (int i=N; i>=2; i--){
        if(A[i]==A[i-1]){
            kotak=i;
            break;
        }
    }
    for (int i=kotak-2; i>=2; i--){
        if(A[i]==A[i-1]){
            kotak2=i;
            break;
        }
    }
    cout << A[kotak]*A[kotak2] << endl;
}

Measured memory_bytes: 4348
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<bits/stdc++.h>
/*#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>*/
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;

ll is_pal(string a)
{
	ll l = 0 , r = ((ll)a.size())-1 ;
	while(l <= r)
	{
		if(a[l] != a[r])
			return 0 ;
		l++ ;
		r-- ;
	}
	return 1;
}
 
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	 
	string str ;
	cin >> str ;
	ll n = str.size() ;
	
	string a , b ;
	for(ll i = 0 ; i < n/2 ; i++)
		a += str[i] ;
	for(ll i = (n+1)/2 ; i < n ; i++)
		b += str[i] ;
	
	if((is_pal(a) && is_pal(b)) && (is_pal(str)))
	{
		cout << "Yes" << '\n' ;
	}
	else
	{
		cout << "No" << '\n' ;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <fstream>
#include <bitset>
#include <map>
#include <queue>
#include <complex>
#include <assert.h>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <stack>
#include <numeric>

typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair

using namespace std;



int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a^b^c) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 101000;
int n, nums[N], vec[N], sum[N], t[N];
long long merge( int l, int r ){
	if( l == r )
		return 0;
	int mid = (l+r) / 2;
	long long res = merge(l, mid) + merge(mid+1, r);
	int i = l, j = mid+1, k = l;
	while( i <= mid || j <= r ){
		if( j > r || (i <= mid && sum[i] <= sum[j]) )
			t[k++] = sum[i++];
		else
			t[k++] = sum[j++], res += mid - i + 1;
	}
	for( int i = l; i <= r; ++i )
		sum[i] = t[i];
	return res;
}
bool check( int x ){
	for( int i = 1; i <= n; ++i )
		sum[i] = sum[i-1] + (nums[i] < x ? -1 : 1);
	return merge(0, n) * 2 <= (long long)n * (n+1) / 2;
}
int main(){
	scanf("%d", &n);
	for( int i = 1; i <= n; ++i ){
		scanf("%d", &nums[i]);
		vec[i] = nums[i];
	}
	sort(vec+1, vec+1+n);
	int m = unique(vec+1, vec+1+n)-vec;
	int l = 0, r = m-1;
	while( l < r ){
		int mid = (l+r+1) / 2;
		if( check(vec[mid]) )
			l = mid;
		else
			r = mid-1;
	}
	printf("%d\n", vec[r]);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    int takahashi, aoki, count;
    cin >> takahashi >> aoki >> count;

    for(int i = 0; i < count; ++i)
    {
        if(i % 2){
            if(aoki % 2){
                --aoki;
            }
            int a = aoki / 2;

            takahashi += a;
            aoki -= a;

        }else{
            if(takahashi % 2){
                --takahashi;
            }
            int t = takahashi / 2;

            takahashi -= t;
            aoki += t;

        }
    }
    cout << takahashi << " " << aoki;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll ans=0;
    rep1(i,n-1) ans+=(n-1)/i;
    cout<<ans;
}

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

int main() {
  int N, A, B, C;
  cin >> N >> A >> B;
  C = N * A;
  
  if (C < B) {
    cout << C << endl;
  }
  else if(C == B) {
    cout << C << endl;
  }
  else {
    cout << B << endl;
  }
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int h,w; cin>> h >> w;
  string board[50];
  
  for(int i=0;i<h;i++)cin >> board[i];
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j]=='#')continue;
      
      int num=0;
      for(int d=0;d<8;d++){
        const int ni=i+dy[d];
        const int nj=j+dx[d];
        
        if(ni<0 || h<=ni)continue;
        if(nj<0 || w<=nj)continue;
        if(board[ni][nj]=='#')num++;
      }
      board[i][j]=char(num+'0');
    }
  }
  for(int i=0;i<h;i++)cout << board[i] << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int n, q;
    readVars(n, q);

    auto uf = UnionFind(n);

    int com, x, y;

    foreach(qi ; 0 .. q){
        readVars(com, x, y);

        if (com == 0) {
            uf.unite(x, y);
        }
        else {
            writeln(uf.same(x, y) ? 1 : 0);
        }
    }
}

struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

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

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

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

using namespace std;

int main() {
    int n; cin >> n;
    int arr[n], h[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        h[i] = i;
    }
    sort(h, h + n, [&] (int a, int b) {
        return (arr[a] < arr[b]);
    });
    for (int i = 0; i < n; i++) {
        cout << h[i] + 1 << " ";
    }
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
    int n;
    int mn = INT_MAX;
    int ans = INT_MIN;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        ans = max(ans,t-mn);
        mn = min(t, mn);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(void){
  int a,b, c, d,ac ,ab ,bc;
  scanf("%d %d %d %d", &a ,&b ,&c ,&d);

  ac = (a > c) ? a - c : c - a;
  ab = (a > b) ? a - b : b - a;
  bc = (b > c) ? b - c : c - b;
  if(ac <= d){
    printf("Yes\n");
  }else if(ab <= d && bc <= d){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i,n) cin >> a[i];
    ll ans=0;
    int c=n+1;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            ans++;
            a[i+1]=c;
            c++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main(){
  int a;cin>>a;
  string s;cin>>s;
  int k; cin >> k; k--;
  for(int i=0;i<a;i++) {
    if (s.at(i)!=s.at(k))
      cout << "*";
    else cout << s.at(i);
 }
 cout << endl;
  }
    

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

int panjang,freq[26];
string s;
bool valid;

int main(){
	cin>>s;
	panjang=s.length();
	for(int i=0;i<panjang;i++){
		freq[s[i]-'a']++;
	}
	valid=true;
	for(int i=0;i<26;i++){
		if(freq[i]>1){
			valid=false;
		}
	}
	if(valid==true){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}
}
		
	

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define REP(i,n) for(long long i = 0;i < n;++i)
#define FOR(i,a,b) for(long long i = a;i < b;++i)
using namespace std;
using ll = long long;
using point = pair< int,int >;

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if (a > b + w || a + w < b) printf("%d\n", min(abs(a + w - b), abs(b + w - a)));
    else printf("0\n");
    return 0;
}



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

int main(){
	
	for(int h,w;cin>>h>>w,h;){
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if((i+j)%2==0)cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	
	return 0;
}


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

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

clock_t time_p = clock();

void rtime() {
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float) 1000 * (time_p) / CLOCKS_PER_SEC << "\n";
}

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

const int INF=1e15;
const int MOD=1e9+7;
const int N=2e5+10;

signed main() {
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    IOS;
    int t = 1;
//    cin >> t;
    while (t--) {
        int a,b,c,k;
        cin>>a>>b>>c>>k;
        int p=a;
        if(k<=a) {
            cout<<k<<"\n";
        } else {
            k-=a;
            if(k<=b) {
                cout<<p<<"\n";
            } else {
                k-=b;
                cout<<p-k<<"\n";
            }
        }
    }
    return 0;
}

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

int main() {
  int A, B, most = 0, lol = 2;
  cin >> A >> B;
  while (lol--) {
    if (A > B) {
      most += A;
      A -= 1;
    }
    else if (A < B) {
      most += B;
      B -= 1;
    }
    else if (A == B) {
      most += A;
      A -= 1;
    }
  }
  cout << most << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H, W, i, j;
    cin >> H >> W;
    
    while(H != 0 && W != 0){
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i==0 || i==H-1){
                    cout << "#";
                }else{
                    if(j==0 || j==W-1){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
 
	int N , M, ans = 0;
	cin >> N >> M;
	double m = M;
	double tot = 0;
	vector<double> vd;
	vd.resize(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> vd[i];
		tot += vd[i];
	}
	for (int i = 1; i <= N; i++) {
		if (vd[i] >= tot / (4 * m)) ans++;
	}
	if (ans < M) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
S = list(input())

a, b = int(str(''.join(S[:2]))), int(str(''.join(S[2:])))
if a == 0 and b == 0:
  print('NA')
elif a == 0 and b <= 12:
  print('YYMM')
elif a <= 12 and b == 0:
  print('MMYY')
elif a == 0 and b > 12:
  print('NA')
elif b == 0 and a > 12:
  print('NA')
elif a > 12 and b > 12:
  print('NA')
elif a <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')
else:
  print('NA')

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

using namespace std;

int main()
{
    int n,k,q;
    cin>>n>>k>>q;

    int i;
    vector<int>V(n+1,0);

    for(i=0;i!=q;i++)
    {
        int x;
        cin>>x;
        V[x]++;
    }

    for(i=1;i!=n+1;i++)
    {
        if(k-(q-V[i]) <= 0)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }

    return 0;
}

Measured memory_bytes: 3788
using System;
public class Program{
    public static void Main(){
        string[] input =Console.ReadLine().Split(' ');
        var a=int.Parse(input[0]);
        var b=int.Parse(input[1]);
        var c=int.Parse(input[2]);
        var s=a+b+c;
       // Console.WriteLine(s);
        if(s>=22){
            Console.WriteLine("bust");
        }else if(s<22){
            Console.WriteLine("win");
        }
        
    }
}


Measured memory_bytes: 13140
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=1,pre;
  string s1,s2;
  cin >> n >> s1 >> s2;
  for(int i=0; i<s1.size(); i++) {
    if(s1[i]==s2[i]) {
      if(i==0) {
        ans*=3;
        ans%=MOD;
        pre=1;
      }
      else {
        if(pre) {
          ans*=2;
          ans%=MOD;
          pre=1;
        }
        else {
          pre=1;
        }
      }
    }
    else {
      i++;
      if(i==1) {
        ans*=6;
        ans%=MOD;
        pre=0;
      }
      else {
        if(pre) {
          ans*=2;
          ans%=MOD;
          pre=0;
        }
        else {
          ans*=3;
          ans%=MOD;
          pre=0;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while (sc.hasNext()) {
            list.add(sc.nextInt());
        }
        int n5=0, n7=0;
        for (int n:list) {
            if (n==5) n5++;
            if (n==7) n7++;
        }
        System.out.println(n5==2&&n7==1 ? "YES" : "NO");
    }
}


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


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

    long long int m = n;

    for (int i = 1; i <= (long long int)sqrt(n); i++) {
        if(n%i==0){
            long long int t = n / i;

            m = min(m, (i + t - 2));

        }
    }
    cout << m << endl;
}

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



int main(){

	int X, Y,Z;

	std::cin >> X >> Y >> Z;

	int count =0;
	while((Y+Z)*count+Z<=X){
		count++;
	}
	std::cout << count-1 <<std::endl;
	return 0;

} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	
	int s, t, i, j;
	
	s = 0;
	t = 0;
	for (i = 0; i < 4; i++){
		scanf("%d", &a[i]);
		s += a[i];
	}
	
	for (j = 0; j < 4; j++){
		scanf("%d", &b[j]);
		t += b[j];
	}
	
	if (t == s){
		printf("%d\n", s);
	}
	else if(t > s){
		printf("%d\n", t);
	}
	else {
		printf("%d\n", s);
	}
	
	return (0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    for (int i = 0; i < 3; ++i) {
        if (n[i] == '7') {
            cout << "Yes"
                 << "\n";
            return 0;
        }
    }
    cout << "No"
         << "\n";
    return 0;
}

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

int x, y, z, k;
vector<ll> a, b, c;

struct state {
  int i,j,k;
  ll value() const {
    return a[i] + b[j] + c[k];
  }
  bool operator<(const state& rhs) const {
    return value() < rhs.value();
  }
  bool operator==(const state& rhs) const {
    return i == rhs.i && j == rhs.j && k == rhs.k;
  }
};

namespace std{
    template<>
    class hash<state>{
        public:
        size_t operator () ( const state &s ) const{ return s.i + s.j*1e3 + s.k*1e6; }
    };
}

int main () {
  priority_queue<state> q;
  unordered_map<state, bool> used;

  cin >> x >> y >> z >> k;
  a = vector<ll>(x);
  b = vector<ll>(y);
  c = vector<ll>(z);
  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];

  sort(a.begin(), a.end(), greater<ll>());
  sort(b.begin(), b.end(), greater<ll>());
  sort(c.begin(), c.end(), greater<ll>());

  state s = state{0,0,0};
  q.push(s);
  used[s] = true;

  rep(i,k) {
    s = q.top(); q.pop();
    cout << s.value() << endl;

    state next[3] = { state{s.i+1, s.j, s.k}, state{s.i, s.j+1, s.k}, state{s.i, s.j, s.k+1}};
    if(next[0].i < x && !used[next[0]]) {
      q.push(next[0]);
      used[next[0]] = true;
    }
    if(next[1].j < y && !used[next[1]]) {
      q.push(next[1]);
      used[next[1]] = true;
    }
    if(next[2].k < z && !used[next[2]]) {
      q.push(next[2]);
      used[next[2]] = true;
    }
  }

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <queue>
#include <string>

int main() {

	int n, q;

	std::cin >> n >> q;

	std::queue<std::pair<std::string, int>> Q;

	for (int i = 0; i < n; ++i) {
		std::string s;
		int v;
		std::cin >> s >> v;

		Q.push(std::make_pair(s, v));
	}
	int time = 0;
	while (!Q.empty()) {
		if (Q.front().second <= q) {
			std::cout << Q.front().first << " " << Q.front().second + time << std::endl;
			time += Q.front().second;
			Q.pop();
		} else {
			Q.push(std::make_pair(Q.front().first, Q.front().second - q));
			time += q;
			Q.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 6264
import math
n = int(input())
while n != 0:
    s = list(map(float, input().split()))
    ave = sum(s) / n
    aa = 0.0
    for i in range(n):
        aa += (s[i] - ave)**2
    aa = math.sqrt(aa / n)
    print("{:10f}".format(aa))
    n = int(input())



Measured memory_bytes: 5784
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_set>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


int main() {
	ll N, ans=0; 
	cin >> N;
	for(int i= 1; i<=N; i++){
		ans += (N / i) * (N / i + 1) / 2 * i;
	}
	print(ans);
}

Measured memory_bytes: 3640
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    int w=0;
    for(int i=0;i<4;i++){
        if(s[i]=='+')
            w++;
        else
            w--;
    }
    cout<<w<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
int N,x;
vi a;
int main(){
	cin >> N >> x;
	input(a,N);
	sort(all(a));
	int cnt = 0;
	int sum = 0;
	for(int i=0;i<N;i++){
		if(sum+a[i]<=x){
			sum += a[i];
			cnt++;
		}
	}
	if(cnt==N){
		if(sum<x)cout << N-1 << endl;
		else cout << N << endl;
	}else{
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<pair<int, int>> v(N);
    for (auto &&i : v) {
        cin >> i.first >> i.second;
    }
    RSORT(v);
    ll ans = v[0].first + v[0].second;
    print(ans);

    return 0;
}

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

string s,t;

int main(){
	cin>>s;
	t=s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++){
		if(s[i]=='b') s[i]='d';
		else if(s[i]=='d') s[i]='b';
		else if(s[i]=='p') s[i]='q';
		else if(s[i]=='q') s[i]='p';
	}
	if(s==t) printf("Yes");
	else  printf("No");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
   vector<int> vec(N);
   for(int i = 0; i < N; i++){
       cin >> vec.at(i);
   }
   
   int b = 0;
   int c = 0;
   for(int i = 0;i < N; i++){
      if(b <= vec.at(i)){
          b = vec.at(i);
          c = i;
      } 
   }
   
   int wa = 0;
   for(int i = 0;i < N; i++){
       wa = wa + vec.at(i);
   }
   wa = wa - vec.at(c);
   if(wa > vec.at(c)){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
}


Measured memory_bytes: 256
h,n=map(int,input().split())
li=[]
x=[]
for i in range(n):
    A,B=map(int,input().split())
    x.append(A)
    li.append([A,B])
dp=[10**9]*(h+max(x))
dp[0]=0
for i in range(1,len(dp)):
    dp[i] = min(dp[i-a]+b for a,b in li)
print(min(dp[h:]))

    

    




Measured memory_bytes: 3776
/*\
 * ...
 * ......
 * In the name of ALLAH
 * ......
 * ...
\*/

#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10 , MN = 404 , MM = 1e5 + 10;

int n , m;
bool mk[MN] ,is[MN] , S[MN][MN];
int es[MM] , ee[MM];

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n >> m;
	for(int i=0;i<m;++i){
		int a,b;cin >>a >> b;--a,--b;
		es[i] = a , ee[i] = b;
	}
	for(int s=0;s<n;++s){
		memset(mk , 0 , sizeof mk);
		mk[s] = true;
		for(int i=m-1;~i;--i){
			if(!mk[es[i]]) swap(es[i] , ee[i]);
			if(mk[es[i]] && mk[ee[i]]) is[s] = true;
			else if(mk[es[i]]) mk[ee[i]] = true;
		}
		for(int i=0;i<n;++i) S[s][i] = mk[i];	
	}
	int ans = 0;
	for(int i=0;i<n;++i)
		for(int j=i+1;j<n;++j) if(!is[i] && !is[j]){
			bool dif = false;
			for(int l=0;l<n;++l)
				if(S[i][l] && S[j][l]) dif = true;
			ans += !dif;
		}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1152
//https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
#include<iostream>
#include<vector>

using namespace std;

int main(){
  long long N; cin >> N;
  long long n,h,w;
  for(n = 0; n < 3501; n++){
    for(h = 0; h < 3501; h++){
      if(4*h*n > N*n + N*h){
        if((N*h*n)%(4*h*n - N*n - N*h) == 0){
          w = (N*h*n)/(4*h*n - N*n - N*h);
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
N = int(input())

TXY = []
for _ in range(N):
    txy = list(map(int, input().split()))
    TXY.append(txy)

t = 0
x = 0
y = 0
for i in range(N):
    # 必要な移動距離
    ido = abs(x-TXY[i][1])+abs(y-TXY[i][2])

    # 時間までにたどり着けるか
    if ido > TXY[i][0]-t:
        break

    # その場所にいることができるか
    if ido % 2 != (TXY[i][0]-t) % 2:
        break

    t = TXY[i][0]
    x = TXY[i][1]
    y = TXY[i][2]

else:
    print('Yes')
    exit(0)
print('No')


Measured memory_bytes: 27380
#include <bits/stdc++.h> 
#define ll long long int
#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;
using namespace std;
ll INF = 1e15;
ll MOD = 1e9 + 7;
vector <ll> monster;

ll gcd(ll a, ll b)
{
    if(a==0)
        return b;
    return gcd(b%a, a);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        ll input;
        cin>>input;
        monster.push_back(input);
    }
    ll ans = monster[0];
    for(int i=0;i<n;i++)
    {
        ans = gcd(ans, monster[i]);
    }
    cout<<ans<<"\n";
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

#define MAX (1<<19)
int BIT[MAX+1];

int sum(int k) {
  int ret = 0;
  for(++k; k > 0; k -= k & -k) ret += BIT[k];
  return ret;
}

void add(int k, int x) {
  for(++k; k < MAX; k += k & -k) BIT[k] += x;
}

bool debug = 0;
int mm;
  
bool check(int sp, int x) {
  //cout << "??? sp = " << sp << ", x = " << x << " " << sum(sp+x) << " - " << ((sp-1)>=0?sum(sp-1):0) << endl;
  x += sp;
  if( x >= mm ) return false;
  return sum(x) - ((sp-1)>=0?sum(sp-1):0) == ( x - sp + 1 );
}

void solve(int n,vector<int> &vec) {
  mm = vec.size();
  vector<int> mvec = vec;
  rep(i,(int)mvec.size()) mvec[i] = mvec[i] * -1;

  if( debug ) {
    cout << "[vec]---" << endl;
    rep(i,(int)vec.size()) {
      cout << "* " << i << "-th: " << vec[i] << endl;
    }
  }
  
  vector<int> cur;
  cur.pb(0);
  add(0,1);
  rep(_,n) {
    if( debug ) {
      cout << "* Phase " << _ << ": "<< endl;
    }
    vector<int> nex = cur;
    rep(i,(int)cur.size()) {
      int v = mvec[cur[i]];
      int sp = upper_bound(ALL(mvec),v) - mvec.begin();
      if( debug ) {
	cout << "  v  = " << v << endl;
	cout << "  sp = " << sp << " ( " << ((sp<(int)vec.size())?vec[sp]:-123) << " )" << endl;
      }
      if( sp >= (int)mvec.size() ) { puts("No"); return; }

      ll L = 0, R = (int)mvec.size();
      while( R - L ) {
	ll M = ( L + R ) / 2LL;
	if( check(sp, M) ) L = M + 1;
	else               R = M;
	//cout << M << ": [" << L << "," << R << "]" << endl;
      }
      int x = L;
      x += sp;
      if( debug ) {
	cout << "  x  = " << x << " ( " << ((x<(int)vec.size())?vec[x]:-123) << " )" << endl;
      }
      if( x >= (int)vec.size() ) { puts("No"); return; }
      add(x,1);
      nex.pb(x);
    }
    cur = nex;
  }
  puts("Yes");
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(1<<n);
  rep(i,(1<<n)) cin >> vec[i];
  sort(ALL(vec),greater<int>());
  solve(n,vec);
  return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N;
veci a;

int main(void) {
    cin >> N;
    a.assign(N, 0);
    rep(i, N) cin >> a[i];

    int odd_cnt = 0;
    int four_cnt = 0;
    rep(i, N) {
        if (a[i] % 2 != 0) {
            odd_cnt += 1;
        }
        else if (a[i] % 4 == 0) {
            four_cnt += 1;
        }
    }

    if (odd_cnt > 0 && (four_cnt < odd_cnt))
    {
        if (odd_cnt - four_cnt == 1 && N - odd_cnt - four_cnt == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
    }

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
typedef long long ll;

const int maxn = 2e5 + 10;
int a[maxn];
int main() {
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		int x; scanf("%d", &x); a[x]++;
	}
	std::sort(a + 1, a + 1 + n);
	int ans = n;
	for (int i = 1; i <= k; i++)
		ans -= a[n - i + 1];
	printf("%d\n", ans);
} 

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = n + 1;
    int numOfBlack = 0;
    int totalWhite = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '.') totalWhite++;
    }
    for (int i = 0; i <= n; i++) {
        int cand = numOfBlack + (totalWhite - (i - numOfBlack));
        ans = min(ans, cand);
        if (i < n && s[i] == '#') numOfBlack++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define MAX 100

int main(){
    int i, n;
    cin >> n;
    char s[MAX], t[MAX], u[MAX*2];
    for(i=0; i<n; i++) cin >> s[i];
    for(i=0; i<n; i++) cin >> t[i];

    for(i=0; i<n; i++) cout << s[i] << t[i];
    cout << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;
		VI a(n); rep(i, n)cin >> a[i];

		bool na = true;
		rep(i, n)if (a[i] >= 2)na = false;

		int cnt = 0;
		rep(i, n)if (a[i] >= 1)cnt++;

		if (na)puts("NA");
		else cout << cnt + 1 << endl;
	}
}


Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
using namespace std;
#define int long long
int n,a[2002020],X,S,D;
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
#undef int
int main()
{
	#define int long long
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=3;i<=n;i++)X^=a[i];
	S=a[1]+a[2]; D=(S-X)/2;
	if(S-X<0 || (S-X)&1 || D&X || D>a[1]){puts("-1"); return 0;}
	for(int i=41;i>=0;i--)
		if((X&(1ll<<i)) && (D^(1ll<<i))<=a[1])D^=(1ll<<i);
	if(!D){puts("-1"); return 0;}
	D=a[1]-D; cout<<D<<endl;
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ll s;
    cin>>s;
    if(s<=1000000000)
    {
        cout<<"0 0 0 1 "<<s<<" "<<0<<endl;
    }
    else
    {
        ll l=1,r=1000000000;
        ll z;
        while(l<=r)
        {
            ll mid=(l+r)>>1;
            if(mid*1000000000-s>1000000000)
                r=mid-1;
            else if(mid*1000000000-s<0)
                l=mid+1;
            else
            {
                z=mid;
                break;
            }
        }
        cout<<"0 0 "<<1000000000<<" "<<1<<" "<<(z*1000000000-s)<<" "<<z<<endl;
    }


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int A, B, C;
	cin >> A >> B >> C;
	if(A + B < C){
		cout << A + 2 * B + 1 << endl;
	} else {
		cout << B + C << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
A = [a, b, c, d, e]
if max(A) - min(A) > k:
    print(":(")
    sys.exit(0)
print("Yay!")

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll ret = 0;
    for(int i = 1; i <= n; i++){
        if(i%3 > 0 && i%5 > 0)  ret += i;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3636
import numpy as np
H, W = map(int, input().split())
M = []
for h in range(H):
    col = []
    s = input()
    for w in range(W):
        if s[w] == '.':
            col.append(0)
        else:
            col.append(np.inf)
    M.append(col)



for h in range(H):
    for w in range(W):
        flag_h0= True
        flag_hM = True
        flag_w0 = True
        flag_wM = True
        if M[h][w] == np.inf:
            
            if h==0:
                flag_h0= False
            if h == H - 1:
                flag_hM = False
            if w== 0:
                flag_w0 = False
            if w== W-1:
                flag_wM = False
            
            if flag_h0:
                M[h-1][w] += 1
                if  flag_w0:
                    M[h-1][w-1] += 1
                if flag_wM:
                    M[h-1][w+1] += 1
            
            if flag_w0:
                M[h][w-1] += 1
            if flag_wM:
                M[h][w+1] += 1
            
            if flag_hM:
                M[h+1][w] += 1

                if flag_w0:
                    M[h+1][w-1] += 1
                if flag_wM:
                    M[h+1][w+1] += 1

                    
for h in range(H):
    tmp_ = ''
    for w in range(W):
        if M[h][w] < np.inf:
            tmp_ += str(M[h][w])
        else:
            tmp_  += '#'
    print(tmp_)
                

Measured memory_bytes: 27084
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

int main() {
   string S;
   cin >> S;
   int posw = 0;
   ll ans = 0;
   for (int i = 0; i < S.size(); i++) {
      if (S[i] == 'W') {
         ans += i - posw;
         posw++;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 640
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('ABA'), 'Yes')

    def test_2(self):
        self.assertEqual(think('BBA'), 'Yes')

    def test_3(self):
        self.assertEqual(think('BBB'), 'No')


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    return read_line(n=3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s):
    return 'Yes' if len(set(list(s))) == 2 else 'No'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

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

int main() {
  long N, K;
  cin >> N >> K;
  long m = N - N / K * K;
  m = min(m, abs(m - K));
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n, a[200010], s[200010], ss[4], c1, c2, c3;
long long get_(){
	ss[0] = s[c1] - s[0]; ss[1] = s[c3] - s[c1];
	ss[2] = s[c2] - s[c3]; ss[3] = s[n] - s[c2];
	long long maxnum, minnum;
	maxnum = -200000000000001;
	minnum = 200000000000001;
	for(int i = 0; i < 4; i++){
		maxnum = max(maxnum, ss[i]);
		minnum = min(minnum, ss[i]);
	}
	return maxnum - minnum;
}
void de1(int ll, int rr){
	int l = ll, r = rr - 1, mid;
	while(l < r){
		mid = (l + r + 1) >> 1;
		if(s[mid] - s[ll - 1] <= s[rr] - s[mid]) l = mid; else r = mid - 1;
	}
	c1 = l;
	return;
}
void de2(int ll, int rr){
	int l = ll, r = rr - 1, mid;
	while(l < r){
		mid = (l + r + 1) >> 1;
		if(s[mid] - s[ll - 1] <= s[rr] - s[mid]) l = mid; else r = mid - 1;
	}
	c2 = l;
	return;
}
int main(){
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
	long long ans = 200000000000001;
	for(int i = 2; i <= n - 2; i++){
		c3 = i;
		de1(1, i);
		de2(i + 1, n);
		ans = min(ans, get_());
		if(c1 + 1 <= i - 1){
			c1++;
			ans = min(ans, get_());
			c1--;
		}
		if(c2 + 1 <= n - 1){
			c2++;
			ans = min(ans, get_());
			c2--;
		}
		if(c1 + 1 <= i - 1 && c2 + 1 <= n - 1){
			c1++; c2++;
			ans = min(ans, get_());
			c1--; c2--;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let x: i32 = read();
    let mut ans = None;
    'outer: for i in 0..n+1 {
        for j in 0..n-i+1 {
            let k = n - i - j;
            if 10000 * i + 5000 * j + 1000 * k == x {
                ans = Some((i, j, k));
                break 'outer;
            }
        }
    }
    let (x, y, z) = ans.unwrap_or((-1, -1, -1));
    println!("{} {} {}", x, y, z);

}


Measured memory_bytes: 4352