akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int dfs(int n, int k, int s, int now) {
  if (s < 0) return 0;
  if (s == 0) {
    if (k == 0) return 1;
    return 0;
  }
  if (now == n + 1) {
    if (s == 0) return 1;
    return 0;
  }
  return dfs(n, k - 1, s - now, now + 1) + dfs(n, k, s, now + 1);
}

int main() {
  while (true) {
    int n, k, s;
    cin >> n >> k >> s;
    if (n == 0 && k == 0 && s == 0) return 0;

    int count = dfs(n, k, s, 1);
    cout << count << endl;
  }
}

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

int main(){
  char a;
  cin >> a;
  string b="aiueo";
  bool flag=false;
  for (int i = 0; i < 5; i++) {
    if (a==b.at(i)) flag=true;
  }
  if(flag) cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


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

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

int main()
{
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    REP(x, k+1){
        REP(y, k+1){
            if (k >= s-(x+y) && s-(x+y) >= 0)
            ++cnt;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
X_h = []
Y_h = []
H = []
X_0 = []
Y_0 = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        X_0.append(x)
        Y_0.append(y)
    else:
        X_h.append(x)
        Y_h.append(y)
        H.append(h)


def solve(H, X_h, Y_h, X_0, Y_0):
    for C_x in range(101):
        for C_y in range(101):
            h = H[0] + abs(X_h[0] - C_x) + abs(Y_h[0] - C_y)
            flag = True
            for i in range(1, len(X_h)):
                if h != H[i] + abs(X_h[i] - C_x) + abs(Y_h[i] - C_y):
                    flag = False
                    break
            if flag:
                for j in range(len(X_0)):
                    if h - abs(X_0[j] - C_x) - abs(Y_0[j] - C_y) > 0:
                        flag = False
                        break
                if flag:
                    return C_x, C_y, h


C_x, C_y, H = solve(H, X_h, Y_h, X_0, Y_0)
print(C_x, C_y, H)


Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{ 
	LL n,m;
	cin>>n>>m;
	LL a[n];
	for(LL i=0; i<n; i++)
	cin>>a[i];
	LL count=0;
	LL a1[m],b1[m];
	map<LL,LL>m1;
	map<LL,LL>m2;
	LL temp1,temp2;
	for(LL i=0; i<m; i++)
	{
	cin>>a1[i]>>b1[i];
	temp1=a[b1[i]-1];
	m1[a1[i]]=max(m1[a1[i]],temp1);
	temp2=a[a1[i]-1];
	m1[b1[i]]=max(m1[b1[i]],temp2);
	
	}
	sort(a1,a1+m);
	sort(b1,b1+m);
	for(LL i=1; i<=n; i++)
	{
		if(a[i-1]>m1[i])
		count++;
		
	}
	cout<<count<<"\n";
}


Measured memory_bytes: 12224
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double maxc = 0;
    int answ = 100 * a, anss = 0;
    for (int i = 0; 100 * a * i <= f; ++i) {
        for (int j = 0; 100 * b * j <= f; ++j) {
            int w = 100 * a * i + 100 * b * j;
            if (w > f) break;
            if (w == 0) continue;
            for (int k = 0; c * k <= f; ++k) {
                for (int l = 0; d * l <= f; ++l) {
                    int s = c * k + d * l;
                    if (w + s > f || w + s == 0) break;

                    double dens = 100.0 * s / (w + s);

                    if (dens > 100.0 * e / (100 + e)) continue;
                    if (maxc < dens) {
                        answ = w;
                        anss = s;
                        maxc = dens;
                    }
                }
            }
        }
    }

    cout << answ + anss << " " << anss << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	string s;
	bool d[4] = { 0 };

	cin >> s;

	rep(i, s.size()) {
		if (s[i] == 'W') {
			d[0] = 1;
		}
		else if (s[i] == 'E') {
			d[1] = 1;
		}
		else if (s[i] == 'N') {
			d[2] = 1;
		}
		else {
			d[3] = 1;
		}
	}

	if (d[0] && d[1] && d[2] && d[3]) {
		Yes;
	}
	else if (d[0] && d[1] && !d[2] && !d[3]) {
		Yes;
	}
	else if (!d[0] && !d[1] && d[2] && d[3]) {
		Yes;
	}
	else {
		No;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,t,num;
int main()
{
	cin>>a>>b>>c;
	cin>>t;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++){
		if(i*500+j*100+k*50==t)num++;		
	}
	cout<<num;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll X,x;
  cin>>X>>x;
  ll ans=0;
  ll a[X];
  ll sabun[X+1]={};

  FOR(i,0,X-1){
    cin>>a[i];
  }

  FOR(i,1,X-1){
    sabun[i]=a[i]+a[i-1];
    //cout<<sabun[i]<<endl;
  }
  sabun[0]=a[0];
  sabun[X]=a[X-1];
  FOR(i,0,X){
    sabun[i]=sabun[i]-x;
    sabun[i]=max(0,sabun[i]);
    //cout<<sabun[i]<<endl;
  }

  FOR(i,0,X){
    if(sabun[i]>0){

      sabun[i+1]=sabun[i+1]-sabun[i];
      ans=ans+sabun[i];
      sabun[i]=0;
    }
  }

  cout<<ans<<endl;



  return 0;
}
 


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int A[n][m];
    int B[m];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            int c;
            cin >> c;
            A[i][j] = c;
        }
    }
    for (int i = 0; i < m; i++){
        int d;
        cin >> d;
        B[i] = d;
    }
    
    for (int i = 0; i < n; i++){
        int  result = 0;
        for (int j = 0; j < m; j++){
            result += A[i][j] * B[j];
        }
        cout << result << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


def main():
    N = int_raw()
    BAs = []
    for i in range(N):
        A,B = ints_raw()
        BAs.append([B,A])
    BAs.sort()
    t = 0
    for BA in BAs:
        B,A = BA
        t+=A
        if B<t:
            return "No"
    return "Yes"


print(main())


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

const int maxn = 32;
int val[maxn];

void show(int n){
	for (int i = 0; i < n; ++i){
		if (i)putchar(' ');
		printf("%d", val[i]);
	}
	putchar('\n');
}

void rec(int n, int m)
{
	if (!n)show(m);
	else{
		for (int i = 0; i < n; ++i){
			val[m] = n - i;
			if (m && val[m] > val[m - 1])continue;
			rec(i, m + 1);
		}
	}
}

int main(){
	int n;
	while (cin >> n){
		if (!n)return 0;
		rec(n, 0);
	}
}


Measured memory_bytes: 3072
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

if a.any?{|aa| aa == 0}
  p 0
  exit
end

ans = 1
a.each do |aa|
  ans *= aa
  if ans > 10**18
    p -1
    exit
  end
end
p ans


Measured memory_bytes: 23436
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define PB push_back
struct triple{
	int a;
	int b;
	int c;
	void out(){
		printf("%d %d %d\n",a,b,c);
		return ;
	}
};
int main(){
	int n,k,a,b,c,cnt,now=0;
	vector<triple> v;
	scanf("%d%d",&n,&k);
	v.resize(n);
	for(int i=0;i<n;i++)v[i].c=k+n*3-1-i;
	for(int i=n-1;i>=0;i-=2)v[now++].b=k+n+i;
	cnt=n-now;
	for(int i=n-2;i>=0;i-=2)v[now++].b=k+n+i;
	for(int i=cnt-1;i>=0;i--)v[--now].a=k+i;
	for(int i=n-1;i>=cnt;i--)v[--now].a=k+i;
	for(triple i:v)if(i.a+i.b>i.c){
		printf("-1\n");
		return 0;
	}
	for(triple i:v)i.out();
}


Measured memory_bytes: 3456
#include<stdio.h>
#include<stdlib.h>
int fun(int [],int );
int cmp(const void *,const void *);
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int fun(int a[],int n)
{
    int i,sum=0;
    qsort(a,2*n,sizeof(a[i]),cmp);
    for(i=0;i<2*n;i++)
    {
        if(i%2==0)
        {
            sum=sum+a[i];
        }
    }
    return sum;
}
int main()
{
    int a[201];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<2*n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf("%d\n",fun(a,n));
    return 0;
}

Measured memory_bytes: 128
A,B,C,X,Y = map(int,input().split())

if A+B >= 2*C:
    planA = 2*C*max(X,Y)
    if X < Y:
        planB = 2*C*X + B * abs(X-Y)
    elif X > Y:
        planB = 2*C*Y + A * abs(X-Y)
    else:
        planB = planA
    
    ans = min(planA,planB)
else:
    ans = A*X + B*Y

print(ans)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

constexpr int MOD = 1e9+7;

namespace math { namespace integer {

template<class value_type> value_type mod_mul(value_type x, value_type k, ll m = MOD) { if(k == 0) { return 0; } if(k % 2 == 0) { return mod_mul((x+x) % m, k/2, m); } else { return (x + mod_mul(x, k-1, m)) % m; } }
template<class value_type> value_type mod_pow(value_type x, value_type n, ll mod = MOD) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(mod_mul(x, x, mod) % mod, n / 2, mod); } else { return mod_mul(x, mod_pow(x, n - 1, mod), mod); } }
template<class value_type> value_type extgcd(value_type a, value_type b, value_type& x, value_type& y) { value_type d = a; if(b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; }
template<class value_type> value_type mod_inverse(value_type x, ll mod = MOD) { return mod_pow(x, value_type(mod-2), mod); /* use fermat */ }
template<class value_type> value_type mod_inverse_composite_num_mod(value_type a, ll mod = MOD) { value_type x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; }

}}
using namespace math::integer;

namespace math {

constexpr int MaxFact = 100010;

struct FactRevFactList {

  array<long long, MaxFact+1> fact_;
  array<long long, MaxFact+1> rev_fact_;

  FactRevFactList() {
    fact_[0] = 1;
    for(int i=1; i<MaxFact; i++) {
      fact_[i] = fact_[i-1] * i;
      fact_[i] %= MOD;
    }

    rev_fact_[MaxFact-1] = mod_pow(fact_[MaxFact-1], (long long)MOD-2, MOD);

    for(int i=MaxFact-2; i>=0; i--) {
      rev_fact_[i] = rev_fact_[i+1] * (i+1);
      rev_fact_[i] %= MOD;
    }
  }

  long long fact(int x) const { return fact_[x]; }
  long long fact_inv(int x) const { return rev_fact_[x]; }

};

}

int main() {

  math::FactRevFactList F;

  ll N, M; cin >> N >> M;
  if (abs(N - M) > 1) {
    cout << 0 << endl;
  } else {
    auto NMfact = mod_mul(F.fact(N), F.fact(M));
    if (N == M) {
      cout << mod_mul(2LL, NMfact) << endl;
    } else {
      cout << NMfact << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1792
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
    string s,ss;
    cin>>s>>ss;
    int ans=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=ss[i])
            ans++;
    }
    cout<<ans<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
using namespace std;
int main() {
    int m, n;
    cin >> m >> n;
    ll k = n / 10000;
    ll h = n % 10000;
    ll s = 1;
    rip(i, 10000)s = (s * m) % 1000000007;
    ll p = 1;
    if (k != 0)rip(i, k)p = p * s % 1000000007;
    if (h != 0)rip(i, h) p = p * m % 1000000007;
    cout << p << endl;
}


Measured memory_bytes: 3120
N, M = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
cb = [0] * M
for i in range(M):
    b, c = [int(x) for x in input().split()]
    cb[i] = [c, b]
list.sort(cb, reverse=True)

D = [0] * N
k = 0
for i in range(M):
    for j in range(cb[i][1]):
        if k < N:
            D[k] = cb[i][0]
            k += 1
        else:
            i = M
            break

S = 0
list.sort(A)
for i in range(N):
    if D[i] > A[i]:
        S += D[i]
    else:
        S += A[i]
print(S)

Measured memory_bytes: 24648
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
string s;
int main(){FAST;
cin>>s;
sort(all(s));
s.resize(distance(s.begin(),unique(all(s))));
if(s.size() == 3)cout<<"Yes";
else cout<<"No";
return 0;
}

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

int main() {
    ll t1,t2,a1,a2,b1,b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    a1 *= t1;
    a2 *= t2;
    b1 *= t1;
    b2 *= t2;
    a2 += a1;
    b2 += b1;
    if(a2 == b2) {
        cout << "infinity" << '\n';
        return 0;
    }
    if(a2 < b2) {
        swap(a1, b1);
        swap(a2, b2);
    }

    if(a1 > b1) {
        cout << 0 << '\n';
        return 0;
    }

    ll c = b1-a1;
    ll d = a2-b2;

    // how many turns c can catch up d
    cout << c/d*2 + (c%d>0) << '\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;
typedef long long ll;

const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n / 2 << endl;
  } else {
    cout << n / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	while(cin>>n>>m,n,m){
		int num[101]={},ans=0;
		m--;
		for(int i=0,x,y,a=m;i<n;i++){
			cin>>x;
			for(;x>0;x--){
				cin>>y;
				num[y]++;
				if(num[y]>m){
					m=num[y];
					ans=y;
				}
				else if(num[y]==m&&a!=m)ans=min(ans,y);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
// 133_A_T_or_T.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>

using namespace std;

int main()
{
	int N, A, B = 0;

	cin >> N >> A >> B;

	int trainFee = N * A;
	int taxiFee = B;

	if (trainFee >= taxiFee)
	{
		cout << taxiFee;
	}
	else
	{
		cout << trainFee;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>

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

  std::multiset<int> d;
  for (int i = 0; i < n; ++i) {
    int di;
    scanf("%d", &di);
    d.insert(di);
  }

  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int t;
    scanf("%d", &t);
    auto it = d.find(t);
    if (it == d.end()) return puts("NO"), 0;
    d.erase(it);
  }

  puts("YES");
}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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 = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  char c[5]={'M','A','R','C','H'};
  map<char,ll>mp;
  REP(i,N){
    string s;
    cin>>s;
    mp[s[0]]++;
  }
  ll ans=0;
  vector<int> nums={0,0,1,1,1};
  do {
    ll tmp=1;
    for(int i=0;i<5;i++){
      if(nums[i]) tmp*=mp[c[i]];
    }
    ans+=tmp;
  } while (std::next_permutation(nums.begin(), nums.end()));

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        mut A:[usize;N]
    }
    A.sort();
    let mut ans = 1;
    let mut S = 0;
    for i in 0..N{
        let a = A[i];
        if S*2>=a{
            ans += 1;
        } else {
            ans = 1;
        }
        S += a;
    }
    println!("{}",ans);
}

Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int ans = N * (N - 1) / 2;
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    //b[i]:=番号iの黒玉の初期位置、w[i]:=番号iの白玉の初期位置
    int b[N], w[N];
    rep(i, 2*N){
        char c;
        int a;
        cin >> c >> a;
        if(c == 'B') b[a-1] = i;
        else w[a-1] = i;
    }
    //cost_b[i][j]:=黒をi個(0〜i-1)、白をj個(0〜j-1)置いてるときに番号iの黒を置くときにかかる転倒数
    //cost_w[i][j]:=黒をi個(0〜i-1)、白をj個(0〜j-1)置いてるときに番号jの白を置くときにかかる転倒数
    int cost_b[N][N+1], cost_w[N+1][N];
    rep(i, N){
        cost_b[i][0] = 0;
        //最初自分より右ですでに置かれてるものの数を数える
        rep(k, i){
            if(b[k] > b[i]) cost_b[i][0]++;
        }
        rep(j, N){
            cost_b[i][j+1] = cost_b[i][j];
            if(w[j] > b[i]) cost_b[i][j+1]++;
        }
    }
    rep(j, N){
        cost_w[0][j] = 0;
        rep(k, j){
            if(w[k] > w[j]) cost_w[0][j]++;
        }
        rep(i, N){
            cost_w[i+1][j] = cost_w[i][j];
            if(b[i] > w[j]) cost_w[i+1][j]++;
        }
    }
    //dp[i][j]:=黒を番号の小さい方からi個、白を小さい方からj個並べるのに必要な最小の操作の回数
    int dp[N+1][N+1];
    dp[0][0] = 0;
    rep2(i, 1, N){
        dp[i][0] = dp[i-1][0] + cost_b[i-1][0];
        dp[0][i] = dp[0][i-1] + cost_w[0][i-1];
    }
    rep2(i, 1, N){
        rep2(j, 1, N){
            dp[i][j] = min(dp[i-1][j]+cost_b[i-1][j], dp[i][j-1]+cost_w[i][j-1]);
        }
    }
    cout << dp[N][N] << endl;
}

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

const int MOD = 1e9 + 7;

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

    int len = L.size();
    vector<int64_t> dp1(len+1), dp2(len+1);
    dp2[0] = 1;

    for (int i = 0; i < len; i++) {
        if (L[i] == '1') {
            (dp1[i+1] = dp1[i] * 3 + dp2[i]) %= MOD;
            (dp2[i+1] = dp2[i] * 2) %= MOD;
        } else {
            (dp1[i+1] = dp1[i] * 3) %= MOD;
            dp2[i+1] = dp2[i];
        }
    }
    cout << (dp1[len] + dp2[len]) % MOD << endl;
}

Measured memory_bytes: 2048
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
int n,a[2000],cnt;
using namespace std;
int main()
    {
        cin>>n;
        for(int i=1;i<=n;i++)
            {
                cin>>a[i];
            }
        for(int i=1;i<=n-1;i++)
            {
                if(a[i]==a[i+1]) cnt++;
                if(a[i]==a[i+2]&&a[i]==a[i+1]) a[i+1]=0;
            }
            if(cnt<=10000) cout<<cnt<<endl;
            return 0;
    }


Measured memory_bytes: 256
#include <stdio.h>

int sum(char, int);

int main(void){
  char scan[32], a[10], b[10], input_c;
  int loop, loop1, loop2, n, tmp = 0, mm, cc, xx, ii;

  fgets(scan, 20, stdin);
  n = atoi(scan);

  for(loop = 0; loop < n; loop++){
    for(loop1 = 0; loop1 < 32; loop1++){
      scan[loop1] = '\0';
    }

    fgets(scan, 32, stdin);

    for(loop1 = 0; scan[loop1] != ' '; loop1++){
      a[loop1] = scan[loop1];
    }
    a[loop1] = '\0';
    loop1++;
    for(loop2 = 0; scan[loop1] != '\n'; loop1++, loop2++){
      b[loop2] = scan[loop1];
    }
    b[loop2] = '\0';

    //    printf("%s\n%s\n", a, b);


    for(loop1 = 0; a[loop1] != '\0'; loop1++){
      if(a[loop1] == 'm')  tmp += 1000;
      else if(a[loop1] == 'c')  tmp += 100;
      else if(a[loop1] == 'x')  tmp += 10;
      else if(a[loop1] == 'i')  tmp += 1;

      else{
	tmp += sum(a[loop1 + 1], a[loop1] - 48);
	loop1++;
      }
    }
    //    printf("%d\n", tmp);
    for(loop1 = 0; b[loop1] != '\0'; loop1++){
      if(b[loop1] == 'm')  tmp += 1000;
      else if(b[loop1] == 'c')  tmp += 100;
      else if(b[loop1] == 'x')  tmp += 10;
      else if(b[loop1] == 'i')  tmp += 1;

      else{
	tmp += sum(b[loop1 + 1], b[loop1] - 48);
	loop1++;
      }
    }
    //    printf("%d\n", tmp);



    for(loop1 = 0; loop1 < 10; loop1++){
      a[loop1] = '\0';
    }
    loop1 = 0;

    mm = tmp / 1000;
    if(mm > 1){
      a[loop1] = mm + 48;
      loop1++;
    }
    if(mm > 0){
      a[loop1] = 'm';
      loop1++;
    }
    tmp -= mm * 1000;
    cc = tmp / 100;
    if(cc > 1){
      a[loop1] = cc + 48;
      loop1++;
    }
    if(cc > 0){
      a[loop1] = 'c';
      loop1++;
    }
    tmp -= cc * 100;
    xx = tmp / 10;
    if(xx > 1){
      a[loop1] = xx + 48;
      loop1++;
    }
    if(xx > 0){
      a[loop1] = 'x';
      loop1++;
    }
    tmp -= xx * 10;
    ii = tmp;
    if(ii > 1){
      a[loop1] = ii + 48;
      loop1++;
    }
    if(ii > 0){
      a[loop1] = 'i';
      loop1++;
    }

    printf("%s\n", a);


    tmp = 0;
    for(loop1 = 0; loop1 < 10; loop1++){
      a[loop1] = '\0';
      b[loop1] = '\0';
    }
    for(loop1 = 0; loop1 < 32; loop1++){
      scan[loop1] = '\0';
    }
  }


  return 0;

}


int sum(char c, int n){

  int result;

  if(c =='m') result = 1000* n;
  else if(c =='c') result = 100* n;
  else if(c =='x') result = 10* n;
  else result = 1* n;

  return result;

}

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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

int n, m;
int ban[N];
ll f[N];

int main() {
    ios :: sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1 ; i <= m ; ++ i) {
        int x; cin >> x;
        ban[x] = 1;
    }
    f[0] = 1;
    for(int i = 1 ; i <= n ; ++ i) {
        if(ban[i]) continue;
        for(int j = 1 ; j <= 2 ; ++ j) {
            if(i - j >= 0) {
                f[i] = (f[i] + f[i - j]) % mod;
            }
        }
    }
    cout << f[n] << endl;
}


Measured memory_bytes: 1408
def main():
    X, Y = map(int, input().split())
    # a = n * X
    # x = m * Y: NG
    # a % Y = 0: NG
    if X % Y == 0:
        print(-1)
        return

    ans = X * (Y - 1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    let mut n: i32 = 700;
    for c in s.as_str().chars() {
        if c == 'o' {
            n += 100;
        }
    }
    println!("{}", n);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, int>;

int main() {
  int N, mx=0, x=0;
  string S;
  cin >> N >> S;
  for (char c:S) {
    if (c=='I') {
      x++;
    }
    else {
      x--;
    }
    mx=max(mx, x);
  }
  cout << mx << endl;
}

Measured memory_bytes: 3616
// Implement stak using queue
// making push operation costly
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n+1];
    int count = 0;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2 && i%2)
            count++;
    }
    cout << count;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define PP pair<int,P>


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

  int n;
  cin>>n;
  int a[310][310];

  rep(i,n){
    rep(j,n){
      cin>>a[i][j];
    }
  }

  bool d[310][310]={};

  rep(k,n){
    rep(i,n){
      rep(j,n){
        if(i==j||j==k||k==i) continue;
        if(a[i][k]+a[k][j]<a[i][j]){
          cout<<-1<<endl;
          return 0;
        }else if(a[i][k]+a[k][j]==a[i][j]){
          //cout<<sum<<' '<<' '<<i<<' '<<j<<' '<<k<<' '<<a[i][j]<<endl;
          d[i][j]=true;
        }
      }
    }
  }

  int sum=0;

  rep(i,n){
    rep(j,n){
      if(!d[i][j]&&i!=j) sum+=a[i][j];
    }
  }

  cout<<sum/2<<endl;

}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
#define MAX_V 100000

int n, v, q;
vector<int> G[MAX_V];
bool visited[MAX_V];
int group[MAX_V];


void init(){
  for(int i = 0; i < v; i++){
    visited[i] = false;
    group[i] = -1;
  }
}

void dfs(int v, int g){
  group[v] = g;
  visited[v] = true;
  for(int i = 0; i < G[v].size(); i++){
    int to = G[v][i];
    if(!visited[to]){
      dfs(to, g);
    }
  }
}

int main(void){
  cin >> v >> n;
  for(int i = 0; i < n; i++){
    int from, to;
    cin >> from >> to;
    G[from].push_back(to);
    G[to].push_back(from);
  }
  init();
  for(int i = 0; i < v; i++){
    if(!visited[i]) dfs(i, i);
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    int s, t;
    cin >> s >> t;
    if(group[s] != -1 && group[t] != -1 && group[s] == group[t]) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 10284
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = str(input())
  if '7' in n:
    print('Yes')
  else:
    print('No')
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 112345;
const int MOD = 1e9 + 7;

int h, n, a[SZ];

int main() {
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  LL s = 0;
  for (int i = n - 1; i >= 0; i--) {
    s += a[i];
    if (s >= h) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

int main() {
    int n; cin >> n;
    string s;
    int p;
    vector<pair<pair<string, int>, int>> x(n); 
    rep(i, n){
        cin >> s >> p;
        x[i] = make_pair(make_pair(s, -p), i);
    }

    sort(x.begin(), x.end());

    rep(i, n) cout << x[i].second+1 << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                    ans += 1
print(ans)

Measured memory_bytes: 68268
#include<cstdio>
#define MAX 120
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
void solve(char data[], int i, int j, int H, int W){
  int i_,j_;
  char fruit = data[i * H + j];
  data[i*H + j] = '!';
  for(int k = 0 ; k < 4 ; k++){
    j_ = j + dx[k];
    i_ = i + dy[k];
    if(i_ >= 0 && i_ < H && j_ >= 0 && j_ < W && data[i_ * H + j_] == fruit)
      solve(data,i_,j_,H,W);
  }
}
int main(){
  while(true){
    int H,W;
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0)
      break;
    char data[H*W];
    char str[MAX];
    for(int i = 0 ; i < H ; i++){
      scanf("%s",str);
      for(int j = 0 ; j < W ; j++)
        data[i * H + j] = str[j];
    }
    int ans = 0;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        if(data[i * H + j] != '!'){
          solve(data,i,j,H,W);
          ans++;
        }
      }
    }
    printf("%d\n",ans);
  }
}



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

typedef long long ll;
const ll INF = 1e10;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;
  std::vector< std::vector<ll> > vopen(N, std::vector<ll>(10, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 10; x++) {
      std::cin >> vopen[y][x];
    }
  }
  std::vector< std::vector<ll> > vp(N, std::vector<ll>(11, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < 11; x++) {
      std::cin >> vp[y][x];
    }
  }

  ll ans = -INF;
  for (ll S = 1; S < std::pow(2, 10); S++) {
    ll state = S;
    ll open[10];
    ll i = 0;
    while (state > 0) {
      open[i] = state % 2;
      state /= 2;
      i++;
    }
    ll benefit = 0LL;
    for (ll y = 0; y < N; y++) {
      ll cnt = 0;
      for (ll x = 0; x < 10; x++) {
	if (open[x] == 1 && vopen[y][x] == 1) {
	  cnt++;
	}
      }
      benefit += vp[y][cnt];
    }
    ans = std::max(ans, benefit);
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
string s;
int rui[200001];

signed main() {
	int i;
	
	cin >> n >> s;
	rep(i, n) rui[i + 1] = rui[i] + (s[i] == '#');
	
	int ans = 1e+9;
	rep(i, n + 1) {
		int cst = rui[i] + n - i - (rui[n] - rui[i]);
		ans = min(ans, cst);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        if(a >= k) cout << k << endl;
        else cout << a << endl;
    } 
    else if(a + b >= k) cout << a << endl;
    else {
        long minus = k-a-b, ans = a - minus;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var d1, d2 int
	cnt := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&d1, &d2)
		if d1 == d2 {
			cnt++
			if cnt == 3 {
				break
			}
		} else {
			cnt = 0
		}
	}

	if cnt == 3 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 2e2+ 10, mod = 1e9 + 7;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] == a[j]) {
				continue;
			}
			for (int k = j + 1; k < n; k++) {
				if (a[k] == a[j] || a[k] == a[i]) {
					continue;
				}
				if (a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[i] + a[k] > a[j]) {
					ans++;
				}
			}
		}
	}
	cout << ans;
}

int main() {
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		solve();
	}
}

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

int main() {
    int L, R, d;
    cin >> L >> R >> d;

    int ans = 0;
    for (int i = L; i <= R; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
        
    }
    
    cout << ans << endl;
    return 0;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}


 
int main() {
    int K, A, B;

    cin >> K;
    cin >> A >> B;

    int cur = K;
    if(K > B){
      cout << "NG"<< endl;
      return 0;
    }

    rep(i, 1, 1001){
      if(A <=  cur && cur <= B){
        cout << "OK" << endl;
        return 0;
      }
      cur += K;
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int people= sc.nextInt();
            int days = sc.nextInt();
            int rest_cho = sc.nextInt();
            int ans = 0;
            for(int i = 0; i < people; i++){
              int eat = sc.nextInt();
              for(int j = 1; j <= days;){
      			ans++;
                j += eat;
            }
            }
        	
            System.out.println(ans + rest_cho);
      }
}

Measured memory_bytes: 21844
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

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

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = int;
using ld = long double;
using uint = unsigned int;
using ull = unsigned int;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n; cin >> n;
  set <string> s;
  for(int i = 0; i < n; i++) {
    string x; cin >> x; s.insert(x);
  }
  cout << s.size() << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

Measured memory_bytes: 19124
import sys

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

def main():
    x=II()
    if x<1200:print("ABC")
    else:print("ARC")

main()

Measured memory_bytes: 3064
n,m=map(int,input().split())
pref=[[] for _ in range(n)]
ans=[]
for i in range(m):
  p,y=map(int,input().split())
  pref[p-1].append((i,p,y))
for i in range(n):
  pref[i].sort(key=lambda x: x[2])
  for j,t in enumerate(pref[i]):
    k,q,z=t
    s='0'*(6-len(str(q)))+str(q)+'0'*(6-len(str(j+1)))+str(j+1)
    ans.append((k,s))
ans.sort(key=lambda x: x[0])
for g,h in ans:
  print(h)

Measured memory_bytes: 46448
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
        ifstream in("input.txt");
        ofstream out("output.txt");
        #define cin in
        #define cout out
#endif
int main(){
	int n;
	cin>>n;
	vector<int> a(n), b(n), c(n);
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
	vector<int> dpa(n,0), dpb(n,0), dpc(n,0);
	dpa[0]=a[0];
	dpb[0]=b[0];
	dpc[0]=c[0];
	for(int i=1;i<n;i++){
		dpa[i]=max(dpb[i-1],dpc[i-1])+a[i];
		dpb[i]=max(dpa[i-1],dpc[i-1])+b[i];
		dpc[i]=max(dpa[i-1],dpb[i-1])+c[i];
	}
	cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
} 

Measured memory_bytes: 2560
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using namespace std;

int main(){
	int N,X;
	scanf("%d%d",&N ,&X);
	vector<int> m(N);
	rep(i, N)scanf("%d", &m[i]);
	int sum = 0;
	rep(i, N)sum += m[i];
	sort(m.begin(), m.end());
	printf("%d", N + (X - sum) / m[0]);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    A = opt[i-1] + abs(h[i-1] - h[i])
    B = opt[i-2] + abs(h[i-2] - h[i])
    opt[i] = min(A, B)
print(opt[-1])

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

typedef long long ll;

ll ara[100];

ll ans;

int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>ara[i];
  
  for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) ans+=(ara[i]*ara[j]);
  
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 256