akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<set>
#include<cstdlib>

using namespace std;

int comb(int n, int k, int target, string num, set< vector<string> > &parts){
  int *p;
  bool loop = false;
  int min_diff = target + 1;
  
  p = new int[k];
  for(int i = 0; i < k; i++) p[i] = i;
  
  do{ loop = false;
    
    // TODO
    int sum = 0;
    int st = 0;
    string s;
    vector<string> vp;
    for(int i = 0; i < k; ++i){
      //cout << num.substr(st,p[i]-st+1) << '@';
      s = num.substr(st,p[i]-st+1);
      if(s.length()>0)
	vp.push_back(s);
      st = p[i]+1;
    }
    if(st<n){
      s = num.substr(st,n-st+1);
      if(s.length()>0)vp.push_back(s);
    }

    for(int i = 0; i < (int)vp.size(); ++i){
      sum += atoi(vp[i].c_str());
      //cout << vp[i] << '@';
    }
    //cout << endl;
    //cout << sum << endl;
    if( target - sum >= 0 && min_diff > target - sum ){
      min_diff = target - sum;
      parts.clear();
      parts.insert(vp);
    }else if( target - sum >= 0 && min_diff == target - sum ){
      parts.insert(vp);
    }
    
    for(int pk=k-1;pk>=0;pk--){p[pk]++;if(p[pk]<=n-(k-pk)){for(int j=pk+1;j<k;j++)p[j]=p[j-1]+1;pk++;loop=true;break;}}
  }while(loop);
  delete [] p;
  return min_diff;
}

int solve(int target, string num, set< vector<string> > &parts){
  int len = num.length();
  int min = target + 1;
  for(int part = 1; part <= len; ++part){
    set< vector<string> > tmp_parts;
    int t = comb(len,part,target,num,tmp_parts);
    if( min > t ){
      min = t;
      parts = tmp_parts;
    }else if( min == t ){
      for(set< vector<string> >::iterator it = tmp_parts.begin(); it != tmp_parts.end(); ++it){
	parts.insert( *it );
      }
    }
  }
  return min;
}

int main()
{
  while(true){
    int target;
    string num;
    set< vector<string> > parts;

    cin >> target >> num;
    if( target == 0 && num == "0" ) break;
    int res = solve( target, num, parts );
    if( res == target + 1 ){
      cout << "error" << endl;
    }else if( parts.size() > 1 ){
      cout << "rejected" << endl;
    }else{
      cout << target - res;
      vector<string> p = *(parts.begin());
      for(int i = 0; i < (int)p.size(); ++i){
	cout << ' ' << p[i];
      }
      cout << endl;
    }
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size() - i + 1; j++) {
      string str = s.substr(i, j);
      //cout << str << endl;
      bool flag = true;
      for (int k = 0; k < str.size(); k++) {
        if (str.at(k) == 'A' || str.at(k) == 'C' || str.at(k) == 'G' || str.at(k) == 'T') {
          continue;
        } else {
          flag = false;
        }
      }
      if (flag) {
        int a = str.size();
        ans = max(ans, a);
      }
    }
  }
  cout << ans << endl;
}



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

typedef long long ll;

int n;
map<string,int> ada;
string s;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ll ans = 0ll;
	for(int i=1;i<=n;i++){
		cin >> s;
		sort(s.begin(),s.end());
		ans += (ll)(ada[s]);
		ada[s]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>

int main(){
    std::string s, t, u;
    int a, b;
    std::cin >> s >> t >> a >> b >> u;
    if(s == u){
        std::cout << a-1 << ' ' << b << std::endl;
    }else{
        std::cout << a << ' ' << b-1 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
import System.IO

quick [] = []
quick (x:xs)=
    let sma_eq = [a | a <- xs,a <= x]
        lar    = [a | a <- xs,a >  x]
    in  quick sma_eq ++ [x] ++ quick lar


main = do
    ss <- (map read . words) <$> getLine
    if (sum ss == 17) && (minimum ss == 5) && (maximum ss ==7)
        then putStrLn "YES"
        else putStrLn "NO"

Measured memory_bytes: 508
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    int p;
    int ans = 0;
    bool last = false;
    for(int i = 1;i <= n;i++){
        cin >> p;
        if(p==i){
            if(last) last = false;
            else{
                ans++;
                last = true;
            }
        }
        else{
            last = false;
        }
    }
    cout << ans << endl;
}

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

int n,y;

int main()
{
	cin>>n>>y;
	for(int i=0;i<=n;i++) for(int j=0;j<=n-i;j++)
	{
		int r=y-i*10000-j*5000;
		if(r>=0&&r%1000==0&&i+j+r/1000==n) {cout<<i<<' '<<j<<' '<<n-i-j;return 0;}
	}
	cout<<-1<<' '<<-1<<' '<<-1;
	return 0;
}

Measured memory_bytes: 256
import copy
k, n = map(int, input().split())
a = list(map(int, input().split()))
tonari = copy.copy(a)
last = tonari.pop(0)
tonari.append(last + k)
for i in range(n):
    a[i] = tonari[i]-a[i]
print(k - max(a))

Measured memory_bytes: 26932
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

ll k, ans;
vector<vector<ll>> es(1e5 + 10, vector<ll>());
vector<ll> gs(1e5 + 10, 0);

void dfs(ll v, ll bf)
{
    ++gs[v];
    ++gs[bf];
    ans = ans * (k - gs[bf]) % mod;
    for (ll nv : es[v])
    {
        if (nv == bf)
            continue;
        dfs(nv, v);
    }
}

int main()
{
    ll n;
    cin >> n >> k;
    rep(i, 0, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;
        es[a].push_back(b);
        es[b].push_back(a);
    }
    gs[0] = -1;
    gs[n] = -1;
    ans = 1;
    dfs(0, n);
    cout << ans << endl;
    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll L, R; cin >> L >> R;
    ll ans = 2018;
    for(ll i = L; i < min(L+2019, R); i++)
    {
        for(ll j = i+1; j <= min(L+2019, R); j++)
        {
            ans = min(ans, ((i%2019)*(j%2019))%2019);
        }
    }
    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

using namespace std;

int main() {

	int n, min=INT_MAX, max=INT_MIN,tmp;
	long long sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		min = std::min(min, tmp);
		max = std::max(max, tmp);
		sum += tmp;
	}

	cout << min << ' ' << max << ' ' << sum << endl;

	return 0;

}

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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  for(int i = 1; i<S.size();i++){
    if(S.at(i-1) != S.at(i))
      count++;
  }
  
  cout << count << endl;
}

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

using namespace std;

int main() {
    int n, a[100009];
    cin >> n;
    a[0] = a[n+1] = 0;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    int def_cost = 0;
    for(int i=0; i<=n; i++)
        def_cost += abs(a[i] - a[i+1]);
    for(int i=1; i<=n; i++) {
        cout << def_cost - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]) << endl;
    }

}

Measured memory_bytes: 1664
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    var list = List[Int]()

    for(in <- StdIn.readLine.split(" ").map(_.toInt)){
      list = in :: list
    }

    list = list.reverse
    val w = list(0)
    val h = list(1)
    val x = list(2)
    val y = list(3)
    val r = list(4)

    if((x+r) > w || (x-r) < 0 || (y+r) > h || (y-r) < 0){
      println("No")
    }
    else{
      println("Yes")
    }
  }
}

Measured memory_bytes: 43996
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using gint = mp::cpp_int;
 
int main() {
  long N,K;
  cin >> N >> K;
  gint H[N];
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  sort(H, H + N, greater<>());
  gint h = 0;
  if(N <= K) cout << "0" << endl;
  else{
    for(int j = K; j < N; j++) h += H[j];
    cout << h << endl;
  }
}

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

using ll = long long;
using ull = unsigned long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
    ll n,q;
    cin >> n >> q;
    fenwick_tree<ll> ft(n);
    rep(i,n){
        cin >> t1;
        ft.add(i,t1);
    }
    rep(i,q){
        cin >> t1 >> t2 >> t3;
        if(t1 == 0){
            ft.add(t2,t3);
        }else{
            cout << ft.sum(t2,t3) << endl;;
        }
    }
}

Measured memory_bytes: 8220
from operator import itemgetter
from itertools import chain

n = int(input())
aaa = [tuple(map(int, input().split())) for _ in range(n)]
flatten = list(chain.from_iterable([(a, i), (b, i)] for i, (a, b) in enumerate(aaa)))
flatten.sort()
flag = True
picked = set()
ans = 0

for ab, i in flatten[:n]:
    if flag and i in picked:
        flag = False
    picked.add(i)
    ans += ab

if flag:
    exclude = flatten[n - 1]
    include = flatten[n]
    if exclude[1] == include[1]:
        tmp1 = include[0] - flatten[n - 2][0]
        tmp2 = flatten[n + 1][0] - exclude[0]
        ans += min(tmp1, tmp2)
    else:
        ans -= exclude[0]
        ans += include[0]

ans = min(ans, sum(map(itemgetter(0), aaa)), sum(map(itemgetter(1), aaa)))

print(ans)


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

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

ll n, s;

ll f(ll b, ll n) {
	if (n<b) return n;
	return f(b, n/b) + n%b;
}

int main() {
	cin >> n >> s;
	if (n==s) {
		cout << n+1 << ln;
		return 0;
	}
	
	// まず√nまで全探索
	for (ll b = 2; b*b <= n; ++b) {
		if (f(b,n)==s) {
			cout << b << ln;
			return 0;
		}
	}
	
	// ここまでで見つからなかったら、bが存在するとしたら(√n, n]の範囲
	// √n<bのときはnのb進表記ってのは2桁になる (適当な数字で実際に考えるとわかる)
	// 上位桁をp、下位桁をqとするとn = pb+qで、題意からp+q = sも成り立つ
	// この2式をいろいろやるとb = (n-s)/p + 1 (qが消せる)
	// つまり題意を満たすbってのは下位桁qに依存せず上位桁pから一意に決まるってことがわかる
	// あとはpを全探索してこのbでf(b,n)==sがほんとに成り立つか確認
	ll ans = linf;
	for (ll p = 1; p*p <= n-s; ++p) {
		if ((n-s)%p!=0) continue;
		ll b = (n-s)/p + 1;
		if (f(b,n)==s) chmin(ans, b);
	}
	if (ans!=linf) cout << ans << ln;
	else cout << -1 << ln;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    left = 0
    right = 0
    for i in range(n):
        if s[i] == '(':
            right += 1
        else:
            if right == 0:
                left += 1
            else:
                right -= 1
    print('('*left+s+')'*right)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>
class BST{
private:
    struct node{
        ll high;
        T key;
        U a;
        node *parent;
        node *right;
        node *left;
    };
    
    list<node> tree;
    node* root;
    node leaf={0,T(),U(),NULL,NULL,NULL};
    ll Size;
    
    node* search(T key){
        if(Size==0){return err();}
        node* where=root;
        while(1){
            if((*where).key==key){return where;}
            if((*where).right!=err() && (*where).key<key){where=(*where).right; continue;}
            if((*where).left!=err() && key<(*where).key){where=(*where).left; continue;}
            return where;
        }
        return err();
    }
    
    node* err(){return &leaf;}
    
    void High(node &where){
        node* right=where.right;
        node* left=where.left;
        where.high=max((*left).high,(*right).high)+1;
    }
    
public:
    BST(){
        Size=0;
        root=&leaf;
    }
    
    void insert(T key,U a){
        if(Size==0){
            tree.push_front({1,key,a,err(),err(),err()});
            Size++;
            root=&(*tree.begin());
            return;
        }
        node* where=search(key);
        if((*where).key==key){(*where).a=a;}
        else{
            tree.push_front({1,key,a,where,err(),err()});
            node* New=&(*tree.begin());
            if((*where).key<key){(*where).right=New;}
            else{(*where).left=New;}
            while(where!=err()){
                High(*where);
                where=(*where).parent;
            }
        }
    }
    
    U* find(T key){
        if(Size==0){return end();}
        node* where=search(key);
        if((*where).key==key){return &(*where).a;}
        return end();
    }
    
    U* end(){return &leaf.a;}
    
    void print(){
        if(Size==0){return;}
        dfs(root);
    }
    
    void dfs(node* where){
        cout<<(*where).key<<endl;
        if((*where).right!=err()){dfs((*where).right);}
        if((*where).left!=err()){dfs((*where).right);}
    }
};




int main(){
    BST<ll,ll> B;
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        B.insert(i,b);
    }
    for(ll i=n-1;i>=0;i--){
        cout<<*B.find(i);
        if(i!=0){cout<<" ";}
    }
    cout<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3112
import java.util.*;

public class Main {

  private long criticalTime = 0; 
  private long people = 0;

  public static void main(String[] args) {
    Main m = new Main();
    m.read();
    m.exec();
  }

  private void read() {
    Scanner scan = new Scanner(System.in);
    people = scan.nextLong();
    criticalTime = people;
    for (int i = 0; i < 5; i++) {
      long time = scan.nextLong();
      if (criticalTime > time) {
        criticalTime = time;
      }
    }
  }

  private void exec() {
    long totalTime = people / criticalTime + 4;
    if (people % criticalTime != 0) {
      totalTime++;
    }
    System.out.println(totalTime);
  }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  double n,k;
  cin >> n >> k;
  double ans = 0;

  if(n >= k){
    ans = ans + (n-k+1)/n;
  }

  FOR(i,1,min(k,n+1)){
    int x = log2(k)-log2(i);
    while(true){
      if(pow(2,x) * i >= k) break;
      else x++;
    }
    //cout << i << ' ' << x << endl;
    //printf("%0.10f\n",(1/n)* (1./pow(2,x)));

    ans = ans + (1/n)* (1./pow(2,x));
    //printf("%0.10f\n",ans);
  }
  printf("%0.10f\n",ans);
  return 0;
}


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

int main(){
 int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int sum=0;
  int ans =0;
  for(int i=0;i<N-1;i++){
    if(A.at(i)>=A.at(i+1)){
      sum++;
    }else if(sum>ans){
      ans =sum;
      sum=0;
    }else{
      sum=0;
    }
  }
 if(sum>ans){
   cout<<sum<<endl;
 }else{
   cout<<ans<<endl;
 }
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int A[MAX];

void solve(void){
    int N;
    cin >> N;
    rep(N, i) {
        scanf("%d ", &A[i+1]);
    }
    ll sum = 0LL;
    rep(N+1, i) {
        sum += abs(A[i+1]-A[i]);
    }
    rep(N, i) {
        printf("%lld\n", sum - abs(A[i]-A[i+1]) - abs(A[i+2]-A[i+1]) + abs(A[i+2]-A[i]));
    }
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 1664
N = int(input())
   
count = 0
for n in range(0, N+1):
    if 1 <= n <= 9:
        count = count + 1
    if 100 <= n <= 999:
        count = count + 1
    if 10000 <= n <= 99999:
        count = count + 1
print(count)

Measured memory_bytes: 9048
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
		
		
		String str = in.readLine();
		int length = str.length();
		
		String s = "KIHBR";
		
		StringBuilder noA = new StringBuilder();
		for(int i = 0; i < length; i++){
			if(str.charAt(i) != 'A'){
				noA.append(str.charAt(i));
			}
		}
		
		boolean failed = false;
		
		//System.err.println(noA.toString());
		if(s.equals(noA.toString())){
			//GOOD
			//have to check #of As
			int i = 0;
			char c = str.charAt(i);
			int count  = 0;
			while(str.charAt(i) != 'K'){
				count++;
				i++;
			}
			if(count > 1){
				//System.err.println("Failed at K");
				//out.write("NO" + "\n");
				failed =true;
			}
			count = 0;
			i++;
			if(str.charAt(i) != 'I'){
				//System.err.println("Failed at I");
				//out.write("NO" + "\n");
				failed =true;
			}
			i++;
			if(str.charAt(i) != 'H'){
				//System.err.println("Failed at H");
				//out.write("NO" + "\n");
				failed =true;
			}
			i++;
			while(str.charAt(i) != 'B'){
				count++;
				i++;
			}
			if(count > 1){
				//System.err.println("Failed at B");
				//out.write("NO" + "\n");
				failed =true;
			}
			count = 0;
			i++;
			while(str.charAt(i) != 'R'){
				count++;
				i++;
			}
			if(count > 1){
				//System.err.println("Failed at R");
				//out.write("NO" + "\n");
				failed =true;
			}
			count = 0;
			i++;
			while(i < str.length()){
				count++;
				i++;
			}
			if(count > 1){
				//System.err.println("Failed at LAST As");
				//out.write("NO" + "\n");
				failed =true;
			}
			if(!failed){
				out.write("YES" + "\n");
			}
			else{
				out.write("NO" + "\n");
			}
			
		}
		else{
			//System.err.println("Failed at BASE");
			out.write("NO" + "\n");
		}
		
		
		out.close();
		in.close();
	}
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli cnt[10010];
bool vis[10010];
vector<lli> G[10010];

void func(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){

    sort(c.rbegin(),c.rend());

    vector<lli> ans(N);

    lli startIndex;
    lli startC = 0;
    lli sum = 0;
    REP(i,0,N){
        if(startC<cnt[i]){
            startIndex = i;
            startC = cnt[i];
        }
    }

    vis[startIndex]=true;
    queue<lli> q;
    q.push(startIndex);
    lli num = 0;

    while(q.size()){
        lli top = q.front();
        q.pop();
        ans[top] = c[num];
        num++;
        for(auto e:G[top]){
            if(vis[e])continue;
            vis[e]=true;
            q.push(e);
        }
    }
    REP(i,0,N)sum+=c[i];
    sum -= c[0];

    cout<<sum<<endl;
    REP(i,0,ans.size())cout<<ans[i]<<" ";
    cout<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        a[i]--,b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&c[i]);
    }
    func(N, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 1408
def solve():
    N = int(input())
    Si = []
    for i in range(N):
        Si.append(sorted(input()))

    ds = []
    for s in Si:
        dic = {}
        for c in s:
            if c in dic:
                dic[c] += 1
            else:
                dic[c] = 1
        ds.append(dic)

    # print(ds)

    res = []
    for code in range(ord("a"), ord("z") + 1):
        c = chr(code)

        flag = True
        for d in ds:
            if c not in d:
                flag = False
                break

        if flag:
            m = 100000
            for d in ds:
                m = min(m, d[c])
            res.append((c, m))

    res = sorted(res, key=lambda x: x[0])

    answer = ""
    for r in res:
        answer += r[0] * r[1]

    return answer


if __name__ == '__main__':
    res = solve()
    print(res)


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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    qsort(a,3,sizeof(int),compare_int);
    if(a[2]==a[0]+a[1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

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

	int a, b;
	cin >> a >> b;

	int num = 1;
	int ans = 0;
	for (;;) {
		if (num >= b)break;
		ans++;
		num--;
		num += a;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

  map<int,int> mp;
  set<int> keys;

  for(int i = 1;i <= n;i++){
    int tmp = i;
    for(int p = 2;p <= tmp;p++){
      if(tmp%p == 0)keys.insert(p);
      while(tmp%p == 0){
	mp[p] += 1;
	tmp /= p;
      }
    }
    if(tmp > 1)mp[tmp] += 1;
  }

  int os = 0;
  int ts = 0;
  int fs = 0;
  int fts = 0;
  int tfs = 0;
  int sfs = 0;

  set<int>::iterator itr = keys.begin();
  for(;itr != keys.end();itr++){
    if(mp[*itr] >= 2)ts++;
    if(mp[*itr] >= 4)fs++;
    if(mp[*itr] >= 14)fts++;
    if(mp[*itr] >= 24)tfs++;
    if(mp[*itr] >= 74)sfs++;  
  }

  int ret = 0;
  ret += max(0,sfs);
  //cout << ret << endl;
  ret += max(0,(ts-1)*tfs);
  //cout << ret << endl;
  ret += max(0,(fs-1)*fts);
  //cout << ret << endl;
  ret += max(0,(ts-2)*(fs-1)*fs/2);
  
  cout << ret << endl;
}

Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

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

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

const lint MOD = 998244353;

lint myPow(lint x, int k) {
	lint ret = 1;
	while (k) {
		if (k & 1) modMul(ret, x, MOD);
		modMul(x, x, MOD);
		k >>= 1;
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	
	vector< int > d(N);
	vector< lint > cnt(N, 0);
	int max_d = 0;
	for (int i=0; i<N; ++i) {
		cin >> d[i];
		cnt[d[i]]++;
		maxUpdate(max_d, d[i]);
	}
	
	if (d[0] != 0 || cnt[0] != 1) {
		puts("0");
	}
	else {
		lint ans = 1;
		for (int i=1; i<=max_d; ++i) modMul(ans, myPow(cnt[i-1], cnt[i]), MOD);
		cout << ans << endl;
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

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; }

// 無限大の値
const int INF = 1e9 + 7;
const int MAX_N = 100005;

int n;
int h[MAX_N];
int dp[MAX_N];

int main() {
  cin >> n;
  for (int k = 0; k < n; k++) cin >> h[k];

  for (int i = 0; i < 100005; ++i) dp[i] = INF;
  dp[0] = 0;

  for (int i = 0; i < n; ++i) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

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


Measured memory_bytes: 1024
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let s = getline();
    let x: i32 = s.trim().parse().unwrap();
    let ans = if x < 1200 { "ABC" } else { "ARC" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import math

k = int(input())
def ans():
    sum = 0
    temp = 0
    for l in range(1,k+1):
        for m in range(1,k+1):
            temp = math.gcd(l,m)
            for n in range(1,k+1):
                sum += math.gcd(temp,n)
    return(sum)
print(ans())

Measured memory_bytes: 9008
while True:
    n=int(input())
    if n==0:
        break
    else:
        c=0
        for i in range(1,n+1):
            S=i
            for j in range(i+1,n+1):
                S+=j
                if S==n:
                    c+=1
                    break
                if S>n:
                    break
        print(c)


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

int main(void){
    string s;
    int cnt[26] = {0};
    cin >> s;
    for (int i=0; i<s.size(); i++){
        if (cnt[s[i]-'a'] == 1){
            cout << "no" << endl;
            return 0;
        } else{
            cnt[s[i]-'a'] = 1;
        }
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 3648
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    res=0
    for i in range(1,N+1):
        if i%3==0 or i%5==0:
            pass
        else:
            res+=i

    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 9180
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(5);
    int k;
    REP(i,5){
        cin >> a[i];
    }
    cin >> k;
    REP(i,5){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k){
                cout << ":(\n";
                return 0;
            }
        }
    }
    cout << "Yay!\n";
    return 0;
}

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main()
{
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a;
    for(int i =1; i<n+1;++i)
    {
        string s;
        int p;
        cin >> s >> p;
        p *= -1;
        a.emplace_back(tie(s, p, i));
    }

    sort(a.begin(), a.end());
    rep(i, n)
    {
        cout << get<2>(a[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int a, b;
    cin >> a >> b;
    a*= 3;
    cout << (a + b) /2;
    }



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

int main(){
	string a,b,c; cin>>a>>b>>c;
	char ca=a[0]-32;
	char cb=b[0]-32;
	char cc=c[0]-32;
	cout<<ca<<cb<<cc<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

vector<int> map(10000);
int solve(int n){
    int res=0;
    for(int i=1;i*(i+2)<=n;i++){
        for(int j=1;j*(j+2)<=n;j++){
            int s=i+j;
            int t=n-i*i-j*j-i*j;
            for(int k=1;k*(k+s)<=t;k++){
                if(k*(k+s)==t){
                    res++;
                }
            }
        }
    }
    return res;
}

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

    int ans=0;
    for(int i=1;i<=N;i++){
        ans=solve(i);
        cout<<ans<<endl;

    }

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


//素因数分解
vector<pair<long long, int>> factorize(long long n) {
	vector<pair<long long, int>> res;
	for (long long i = 2; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

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

unordered_set<int> usedf;
int N;
vector<int> A;
int main() {
	bool pairwise = true;
	cin >> N;
	A.resize(N);
	REP(i, 0, N) {
		cin >> A[i];
		if (!pairwise) continue;
		auto f = factorize(A[i]);
		for(auto & p : f) {
			if (usedf.count(p.first) > 0) {
				pairwise = false;
				break;
			}
			usedf.insert(p.first);
		}
	}
	if (pairwise) {
		PRI("pairwise coprime");
		return 0;
	}
	ll g = gcd(A[0], A[1]);
	REP(i, 2, N) {
		g = gcd(g, A[i]);
	}
	if (g == 1) {
		PRI("setwise coprime");
	}
	else PRI("not coprime");
	return 0;
}




Measured memory_bytes: 7064
#include<iostream>
using namespace std;
static const int INFTY = (1 << 21);

int n, m[100][100];

void dijkstra() {
    int minv;
    int d[100], color[100];
    
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = 0;
    }
    
    d[0] = 0;
    color[0] = 1;
    while(1) {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != 2) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = 2;
        for (int v = 0; v < n; v++) {
            if (color[v] != 2 && m[u][v] != INFTY) {
                if (d[v] > d[u] + m[u][v]) {
                    d[v] = d[u] + m[u][v];
                    color[v] = 1;
                } 
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i]) << endl;  
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            m[i][j] = INFTY;
        }
    }
    
    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            m[u][v] = c;
        }
    }
    dijkstra();
    
    return 0;
}


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

int n,m,ans=2e9;
int a[305][305];
int f[305];
bool v[305];

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

    for(int i=1; i<=m; i++)
        v[i]=1;

    for(int i=1; i<=n; i++)
    for(int j=1; j<=m; j++)
        cin>>a[i][j];

    int fmax,vmax;
    for(int k=0; k<m; k++)
    {
        fmax=vmax=0;

        for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            if(v[a[i][j]])
            {
                f[a[i][j]]++;
                if(f[a[i][j]]>fmax)
                {
                    fmax=f[a[i][j]];
                    vmax=a[i][j];
                }
                break;
            }

        memset(f, 0x00, sizeof f);

        ans=min(ans,fmax);
        v[vmax]=0;
    }

    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
pr = {i: 0 for i in range(1, n+1)}
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and pr[p] >= 0:
        pr[p] += 1
    elif pr[p] >= 0:
        ac += 1
        wa += pr[p]
        pr[p] = -1
print(ac, wa)

Measured memory_bytes: 15084
# 全部出す版
N,H=gets.chomp.split(' ').map{|n| n.to_i}
a = Array.new(N) { |i| 0 }
b = Array.new(N) { |i| 0 }
0.upto(N-1){|i|
	a[i], b[i] = gets.chomp.split(' ').map{|n| n.to_i}
}
amax = a.sort{|a,b| b <=> a}[0]
dmg = 0
atknum = 0
b.select{|bi| bi > amax}.sort{|a,b| b <=> a}.each{|bi|
	dmg += bi
	atknum += 1
	if(dmg >= H)
		puts "#{atknum}"
		break
	end
}
if(dmg < H)
	#amax = a.sort[0]
	remdmg = H - dmg
	atknum += remdmg / amax
	if(remdmg % amax != 0)
		atknum += 1
	end
	puts "#{atknum}"
end




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


int bubbleSort(int A[],int N){
int i,j,count,flag;
   flag = 1;
   count = 0;
   while(flag){
     flag = 0;
     for(j=N-1;j>0;j--){
       if(A[j]<A[j-1]){
         swap(A[j],A[j-1]);
         flag = 1;
         count++;
       }
     }
   }
   return count;
}

int main(){
   int N,i,count,A[100];
   cin >> N;
   for(i=0;i<N;i++)cin >> A[i];
   
   count = bubbleSort(A,N);
   
   for(i=0;i<N;i++){
     if(i)cout << " ";
     cout << A[i];
   }

   cout << endl;
   cout << count << endl;

   return 0;
}

Measured memory_bytes: 1164
import sys

s=input()

chars2=[int(s[i: i+2])for i in range(0,len(s),2)]

if (chars2[0]>0 and  chars2[0]<13):
    if (chars2[1]>0 and  chars2[1]<13):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if (chars2[1]>0 and  chars2[1]<13):
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 3060
/* basic header */
#include <bits/stdc++.h>
/* define */
#define ll long long
#define dou double
#define pb emplace_back
#define mp make_pair
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;++i)
#define rep0(i,a,b) for(int i=a;i<b;++i)
#define eps 1e-8
#define int_inf 0x3f3f3f3f
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lson (curpos<<1)
#define rson (curpos<<1|1)
/* namespace */
using namespace std;
/* header end */

int a, b;

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

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

#define ss 3000
int main()
{
    int d[ss] = {0}, f[ss] = {0}, g[ss] = {0};
    int a, b, c, n, x, y, z;
    int cnt = 0, sum;
    cin >> a >> b >> c >> n;
    for(int i = 0; i <= n/a; i++){
        for(int j = 0; j <= n/b; j++){
            sum = a*i + b*j;

            if(sum <= n && (n-sum)% c == 0){
                cnt++;
            }
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int even = 0;
		int odd = 0;
		for(int i = 0 ; i < n ; i++) {
			if(a[i] % 2 == 0) even++;
			else odd++;
		}
		if(odd % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 50248
#include<iostream>
#define N 100
using namespace std;

int main(){
  int n,a[N],mini,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    mini=i;
    for(int j=i;j<n;j++)
      if(a[j]<a[mini])mini=j;
    if(i!=mini){
      cnt++;
      int t=a[i];
      a[i]=a[mini];
      a[mini]=t;
    }
  }
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<a[i];
  }
  cout<<endl<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1160
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    
    string s;
    cin>>s;
    if(s[s.length()-1] != 's') cout<<s + "s";
    else cout<<s+"es";
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main(){
    int i,n;
    long long a,b,c;

    scanf("%d",&n);

    if(n==0){
        printf("2");
        return 0;
    }
    if(n==1){
        printf("1");
        return 0;
    }

    a=2;b=1;
    for(i=2;i<=n;i++){
        c=a+b;
        a=b;b=c;
    }
    printf("%lld",c);

    return 0;
}



Measured memory_bytes: 128
d,n = map(int,input().split())
if d == 0:
  if n!= 100:
    print(n)
  else:
    print(101)
  
elif d == 1:
  if n != 100:
    print(100*n)
  else:
    print(101*100)
else:
  if n != 100:
    print(10000*n)
  else:
    print(101*10000)

Measured memory_bytes: 3060
#include <stdio.h>

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

	if (N % 10 == 3) {
		printf("bon\n");
	}
	else if ((N % 10 == 0) || (N % 10 == 1) || (N % 10 == 6) || (N % 10 == 8)) {
		printf("pon\n");
	}
	else {
		printf("hon\n");
	}

}

Measured memory_bytes: 1620
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

S=0
for i in range(N):
    Y=min(A[i],B[i])
    S+=Y
    B[i]-=Y

    Z=min(A[i+1],B[i])
    A[i+1]-=Z
    S+=Z

print(S)


Measured memory_bytes: 97772
import math
N,K=map(int,input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1,K+1):
    if i>min(K,N-K+1):print(0)
    else:print(((combinations_count(N-K+1,i))*(combinations_count(K-1,i-1)))%1000000007)

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<char>input(n); vector<int>v(26, 0);
		rep(i, 0, n)cin >> input[i];
		rep(i, 0, n) {
			v[input[i] - 'A']++;
			auto it = max_element(v.begin(), v.end());
			pair<int, int> first(distance(v.begin(), it), *it),second(0, 0);
			rep(j, 0, 26) {
				if (second.second < v[j]&&j!=first.first) {
					second.second = v[j];
					second.first = j;
				}
			}
			if (first.second > second.second + n - (i + 1)) {
				cout << (char)(first.first + 'A') << " " << i + 1 << endl;
				break;
			}
			else if (i == n - 1 && first.second == second.second) {
				cout << "TIE" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> c(n+1);
  for(int i=2;i<=n;i++){
    int num=i;
    for(int j=2;j<=i;j++){
      while(num%j==0){
        c[j]++;
        num/=j;
      }
    }
  }
  vector<int> x(5);
  for(int i=2;i<=n;i++){
    if(c[i]>=74){
      x[0]++;
    }
    if(c[i]>=24){
      x[1]++;
    }
    if(c[i]>=14){
      x[2]++;
    }
    if(c[i]>=4){
      x[3]++;
    }
    if(c[i]>=2){
      x[4]++;
    }
  }
  cout << x[0]+x[1]*(x[4]-1)+x[2]*(x[3]-1)+x[3]*(x[3]-1)/2*(x[4]-2) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll a,b,n;
    cin>>a>>b>>n;
    ll x = min(b-1,n);
    cout<<(a*x)/b - a*(x/b)<<endl;
}

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

Measured memory_bytes: 256