akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
   
    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var diclist = new HashSet<string>[5];
            var M = new HashSet<string>();
            var A = new HashSet<string>();
            var R = new HashSet<string>();
            var C = new HashSet<string>();
            var H = new HashSet<string>();

            for (int i = 0; i < N; i++)
            {
                string str = Console.ReadLine();
                if (str[0] == 'M') M.Add(str);
                else if (str[0] == 'A') A.Add(str);
                else if (str[0] == 'R') R.Add(str);
                else if (str[0] == 'C') C.Add(str);
                else if (str[0] == 'H') H.Add(str);
            }

            diclist[0] = M;
            diclist[1] = A;
            diclist[2] = R;
            diclist[3] = C;
            diclist[4] = H;

            long ans = 0;            
            for(int i = 0; i <= 2; i++)
            {
                for(int j = i + 1; j <= 3; j++)
                {
                    for(int k = j + 1; k <= 4; k++)
                    {
                        ans += (long)diclist[i].Count * diclist[j].Count * diclist[k].Count;
                    }
                }
            }
            
            Console.WriteLine(ans);
            
        }
    }
}

Measured memory_bytes: 26844
#include<stdio.h>
int main(void) {
	int X, c500, c5, Y, u500, u5, u;
	scanf("%d", &X);
	if (X >= 500) {
		c500 = X / 500;
		Y = X - (c500 * 500);
		c5 = Y / 5;
		u500 = 1000 * c500;
		u5 = 5 * c5;
		u = u500 + u5;
		printf("%d\n",u);
	}
	else if (X >= 5) {
		c5 = X / 5;
		u5 = 5 * c5;
		u = u5;
		printf("%d\n",u);
	}
	else {
		u = 0;
		printf("%d\n",u);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD ((int)(1e9+7))

using namespace std;

long long mem[22][(1<<22)];
int arr[22][22];
int n;

long long go(int x,int mas)
{
	if(x==n) return 1;
	if(mem[x][mas]!=-1) return mem[x][mas];
	mem[x][mas]=0;
	for(int i=0;i<n;i++)
	{
		if(arr[x][i]==0||(mas&(1<<i))) continue;
		mem[x][mas]=(mem[x][mas]+go(x+1,mas|(1<<i)))%MOD;
	}
	return mem[x][mas];
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin >> arr[i][j];
	memset(mem,-1,sizeof mem);
	cout << go(0,0) << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll X, K, D;
    cin >> X >> K >> D;
    if (X < 0) X = -X;
    ll a = X / D;
    if (K < a) {
        prints()(X - K * D);
    }
    else {
        if ((K - a) & 1) {
            prints()((a + 1) * D - X);
        }
        else {
            prints()(X - a * D);
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3648
//
// Created by yamunaku on 2019/10/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vi d(n);
    int ans=0;
    rep(i,n){
        cin >> d[i];
    }
    rep(i,n){
        rep(j,i){
            ans+=d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    string S(4, '$');
    for (int i = 0; i < 4; ++i) {
        cin >> S[i];
    }

    for (int q = 0; q < 24; ++q) {
        if (S == "1974") {
            cout << "YES" << endl;
            return 0;
        }
        next_permutation(S.begin(), S.end());
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define GBN_USE_C
#ifdef GBN_USE_C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#else
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#endif

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const ll INF_LONG = 1LL << 62;
const ll INF_LONG_NEG = INF_LONG * -1;

int main()
{
    int N, K; cin >> N >> K;
    vector<double> p(N);
    rep(i, N){
        int a; cin >> a;
        p[i] = (1 + a) * a / 2.0 / a;
    }

    double ans = 0.0;
    rep(i, K) ans += p[i];
    double prev = ans;
    for (int i = 1; i <= N - K; ++i){
        double ans2 = prev - p[i - 1] + p[i + K - 1];
        ans = max(ans, ans2);
        prev = ans2;
    }

    printf("%.9f\n", ans);
    return 0;
}


Measured memory_bytes: 1792
import sys


def decode_roman_number(data):
    """ ???????????°????????¢????????¢??°??????????????????
    ????????§??????????????¨????????????????????§???I, V, X??????????????????????????????????????¢????????¢??°???????????????????????????

    ?????¬????????????????????????????????????????????????????????????????????????????????§???????????°??????????????¨???????????¨???????????§????????????????????????????????????????????????
    ?¬??????????????????????????°????????????£?????????????????§????????°(???: V ??? I)??????????????????????????§????????°??????????????¨??¨?????????????????????
    ??????????????§???????????£?????????????????§????????°(???: I ??? V)??????????????????????????§????????°??????????????¨??¨?????????????????????
    ???????????????????????°??????????¬????????????¨????????????????????????????????????
    ??¨???????????????????????????????????????????????£????????????????????¨???????????¨???
    """
    numbers = []
    for d in data:
        if d == 'I':
            numbers.append(1)
        elif d == 'V':
            numbers.append(5)
        elif d == 'X':
            numbers.append(10)
        elif d == 'L':
            numbers.append(50)
        elif d == 'C':
            numbers.append(100)
        elif d == 'D':
            numbers.append(500)
        elif d == 'M':
            numbers.append(1000)
        else:
            raise ValueError

    decoded_number = 0  # ??¢????????¢??°??????????????????????????????
    my_stack = []
    for n in numbers:
        if len(my_stack) == 0:  # ???????????????????????????????????§??????????????§?????¨?????????????????????????????????
            my_stack.append(n)
        else:
            while len(my_stack) > 0 and my_stack[-1] < n:  # I???V ??? X???C ??????????????±?????????????????¨
                decoded_number -= my_stack.pop()
            while len(my_stack) > 0:
                decoded_number += my_stack.pop()
            my_stack.append(n)  # ???????????????????¬????????????¨??????????????????????????§??????????????????????????¨???XXIV(24)???????????£????????????????????§????????????
    while len(my_stack) > 0:
        decoded_number += my_stack.pop()
    return decoded_number


if __name__ == '__main__':
    #
    for line in sys.stdin:
        data = line.strip()
        # data = 'CCCCLXXXXVIIII'
        # data = 'MCMXLV'

        # ???????????°???????§£???
        ans = decode_roman_number(data)

        # ???????????¨???
        print(ans)

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

string lcs(string s, string t) {
	int n = s.size();
	int m = t.size();
	vector<vector<int>> D(n + 1, vector<int>(m + 1, 0));
	vector<vector<int>> P(n + 1, vector<int>(m + 1, 0));

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			if (s[i - 1] == t[j - 1]) {
				D[i][j] = D[i - 1][j - 1] + 1;
				P[i][j] = 0;
			}
			else {
				if (D[i - 1][j] > D[i][j - 1]) {
					D[i][j] = D[i - 1][j];
					P[i][j] = -1;
				} else {
					D[i][j] = D[i][j - 1];
					P[i][j] = 1;
				}
			}
		}


	string ans = "";
	int a = n, b = m;

	//cout << D[n][m] << endl;
	while (ans.size() < D[n][m]) {
		int n_a, n_b;
		if (P[a][b] == 0) {
			n_a = a - 1;
			n_b = b - 1;
			ans += s[a - 1];
		} else if (P[a][b] == 1) {
			n_a = a;
			n_b = b - 1;
		} else {
			n_a = a - 1;
			n_b = b;
		}

		//cout << n_a << " " << n_b << endl;



		//cout << ans.size() << endl;
		a = n_a;
		b = n_b;


	}

	reverse(ans.begin(), ans.end());

	return ans;
}

int main() {
	string s, t;
	cin >> s >> t;
	cout << lcs(s, t) << endl;


	return 0;
}



Measured memory_bytes: 70912
#include<ctime>
#include<bitset>
#include <cstdio>
#include <cmath>
#include <complex>
#include <algorithm>
#include <iostream>
#include<string.h>
#include<vector>
#include<set>
#define rep(i,t,n)  for(int i =(t);i<=(n);++i)
#define per(i,n,t)  for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
typedef long long ll;
using namespace std;
const int maxn = 1.1e6;

#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))
#include <complex>
using namespace std;
ll inv[maxn], fac[maxn];
ll c[maxn];
const ll mod = 1e9 + 7;


#define ONLINE_JUDGE
int smain();
int main() {
	//ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	FILE *myfile;
	myfile = freopen("C:\\Users\\acm-14\\Desktop\\test\\b.in", "r", stdin);
	if (myfile == NULL)
		fprintf(stdout, "error on input freopen\n");
	FILE *outfile;
	outfile = freopen("C:\\Users\\acm-14\\Desktop\\test\\out.txt", "w", stdout);
	if (outfile == NULL)
		fprintf(stdout, "error on output freopen\n");
	long _begin_time = clock();
#endif
	smain();
#ifndef ONLINE_JUDGE
	long _end_time = clock();
	printf("time = %ld ms.", _end_time - _begin_time);
#endif
	return 0;
}
int a[105];
ll s[105];
int n; ll x;

int smain() {
	
	cin >> n >> x;
	ll sum = 0;
	rep(i, 1, n) { cin >> a[i]; }
	sort(a + 1, a + 1 + n);
	rep(i, 1, n)s[i] = a[i] + s[i - 1];
	int ans = 0;
	per(i, n, 0) {
		if (s[i] <= x) {
			ans = i; break;
		}
	}
	if (ans == n && x > s[n])ans--;
	
	cout << ans << endl;
	cin >> n;
	return 0;
}
/*


*/

Measured memory_bytes: 256
n= int(input())
table=[[[0]*10 for i in range(0,3)]for j in range(0,4)]
for k in range(n):
    b,f,r,v = map(int,input().split())
    table[b-1][f-1][r-1] +=v
x=0
for i in range(4):
    if x !=0:
        print("#"*20)
    x =x+1
    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end="")
        print()


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

using namespace std;

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

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

    int cnt = 1;
    for (int i = 0; i < N - 1; i++){
        if (d[i] < d[i + 1]){
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string();  
lli x,y,d;
void gcd(lli a,lli b){
	if(b==0){
		d=a;
		x=1;
		y=0;
		return ;
	}
	gcd(b,a%b);
	lli temp=x;
	x=y;
	y=temp-(a/b)*y;
	return;
}
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    string st;
    cin>>st;
    lli n=st.size();
    lli an=0;
    for(lli i=0;i<n;i++)if(st[i]=='o')an++;
    if(an+(15-n)>=8)cout<<"YES";
	else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;

using namespace std;

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

    ll sum = 0, maxn = 0, k;
    while(n--)
    {
        scanf("%lld", &k);
        sum += k;
        if(t < sum)
        {
            printf("1\n");
            continue;
        }
        else
        {
            maxn = max(maxn, k);
            printf("%lld\n", (t - sum)/maxn + 2);
        }
    }
    return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <string.h>
int main(void)
{
    int a,b;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if(strncmp(&op, "+", 1)==0) printf("%d", a+b);
    else printf("%d", a-b);
    return 0;
}

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

int main() { 
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    bool one = false, two = false, three = true;
    int n = s.size(), cnt = 0;
    if(s[0] == 'A') {
        one = true;
    }
    for(int i = 1; i < n; i++) {
        if(i>=2 && i < n-1 && s[i] == 'C') {
            cnt++;
        }
        if(s[i] != 'C' && (s[i] < 'a' || s[i] > 'z')) {
            three = false;
        }
    }
    if(cnt == 1) {
        two = true;
    }
    if(one && two && three) {
        cout << "AC\n";
    } else {
        cout << "WA\n";
    }
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main() {
    ll N;
    cin >> N;
    vector<ll> div(N);

    for (ll i = 0; i < N; ++i) {
        ll n;
        cin >> n;

        ll count = 0;
        while ((n % 2) == 0) {
            count++;
            n /= 2;
        }
        div[i] = count;
    }

    ll count = *min_element(div.begin(), div.end());
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mod 1000000007
#define mx 200007
using namespace std;
typedef long long int LL;
int ara[mx], curAra[mx];
LL dp[mx], previous[mx];
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> ara[i];
    }
    curAra[1] = ara[1];
    int counter = 1;
    for(int i = 2; i <= n; i++) {
        if(ara[i] == ara[i - 1]) {
            continue;
        }
        else {
            curAra[++counter] = ara[i];
        }
    }
    dp[1] = 1;
    previous[curAra[1]] = 1;
    for(int i = 2; i <= counter; i++) {
        int pre = previous[curAra[i]];
        dp[i] = (dp[i - 1] + dp[pre]) % mod;
        previous[curAra[i]] = i;
       //cout << dp[i] << " pre " <<pre <<" "<<dp[pre] << endl;
    }
    cout << dp[counter] << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(){
  int c, a, n, q, t;
  scanf("%d", &q);
  while(q--){
    scanf("%d%d%d", &c, &a, &n);
    t = 0;
    while(1){
      if(c && a && n){ --c; --a; --n; t++;}
      else if(c >= 2 && a){ c -= 2; --a; t++;}
      else if(c >= 3){ c-=3; t++;}
      else break;
    }
    printf("%d\n", t);
  }
  return 0;
}

Measured memory_bytes: 600
# 再帰で3,5,7を振り分けるのめんどくさそうだなと思ったら、
# 振り分けずに0個以上あればあればいいセットを作ってそこから省く、という手段を使うのか...

n = int(input())
sitigosan = []


def f(i):
    if i <= 10 ** 9:
        sitigosan.append(i)
        f(i * 10 + 3)
        f(i * 10 + 5)
        f(i * 10 + 7)


f(3)
f(5)
f(7)
# これだと3から埋めていってダメだと5、7に変えていってるので昇順に並んでない

sitigosan = sorted(sitigosan)
count = 0
for sgs in sitigosan:
    if sgs > n:
        break
    str_sgs = str(sgs)
    if "3" in str_sgs and "5" in str_sgs and "7" in str_sgs:
        count += 1
print(count)


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

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

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut a: Vec<i64> = vec![];

    for _ in 0..n {
        a.push(read());
    }

    if k == 2 {
        println!("{}", n - 1);
        return;
    }
    println!("{}", (n - 1) / (k - 1) + (n % k != 0) as usize);
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n,l;
    cin >> n >> l;

    vector<string> s(n);

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

    sort(ALL(s));

    rep(i, n){
        cout << s[i];
    }
    cout << endl;

    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 REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)
#define INF 1e18

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int MAX_N=300;

int main(){
	string s;
	cin>>s;
	int count[3];
	string ans;
	REP(i,3)count[i]=0;
	int type=0;
	REP(i,s.size()){
		if(s[i]=='a')count[0]++;
		else if(s[i]=='b')count[1]++;
		else if(s[i]=='c')count[2]++;
	}
	for(int i=0;i<3;i++){
		if(count[i]>0)type++;
	}
	if(type==1){
		if(count[0]>1 || count[1]>1 || count[2]>1){
			ans="NO";
		}else ans="YES";
	}else if(type==2){
		int num=0;
		if((count[0]==count[1] || count[1]==count[2] || count[2]==count[0]) && s.size()==2)ans="YES";
		else ans="NO";
	}else if(type==3){
		if(abs(count[0]-count[1])>1 || abs(count[1]-count[2])>1 || abs(count[2]-count[0])>1)ans="NO";
		else ans="YES";
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    random.seed(0)
    while time.time() - start < 1.9:
        last_d = [0 for i in range(26)]
        score2 = 0  
        tmp1 = 0
        tmp2 = 1
        tmp3 = 2
        if random.randint(0,1):           
            idx1 = random.randint(0,25)
            idx2 = random.randint(0,25)
            idx3 = random.randint(0,25)
            d1 = random.randint(0,D-1) 
            d2 = random.randint(0,D-1)
            d3 = random.randint(0,D-1)        
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            ans[d1] = idx1
            ans[d2] = idx2
            ans[d3] = idx3           
        else:
            d1 = random.randint(0,D-15) 
            d2 = random.randint(d1+1,d1+7)
            d3 = random.randint(d2+1,d2+7) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp1
            ans[d2] = tmp2
            ans[d3] = tmp3
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9668
n,m = map(int, input().split())
h = [0]+list(map(int, input().split()))
g = [1] * (n+1)
g[0]=-1
for i in range(m):
    a,b = map(int, input().split())
    if h[a] > h[b]:
        g[b] = -1
    elif h[a] < h[b]:
        g[a] = -1
    else:
        g[a],g[b]=-1,-1

print(g.count(1))




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

int main() {
  int n;
  cin >> n ;
  int dig=0;
  int m=n;
  while(n>0){
    n/=10;
    dig++;
  }
  int ans;
  if(dig==1) ans=m;
  else if(dig==2) ans=9;
  else if(dig==3) ans=m-90;
  else if(dig==4) ans=909;
  else if(dig==5) ans=m-9090;
  else if(dig==6) ans=90909;
    
  cout <<ans <<endl;
}

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; 
using P = pair<int,int>;

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

const long long INF = 1LL << 60;


int main(void){
	string s;cin >> s;
	list<char> str_list; 
	for(int i=0;i<s.size();i++){
		str_list.push_back(s[i]);
	}
	int q;cin >> q;
	bool flip = true;
	for(int i=0;i<q;i++){
		int a,b;
		char c;
		cin >> a;
		if(a == 1){
			flip = !flip;
			continue;
		}
		cin >> b >> c;
		if(flip == false) b = 3-b; 
		if(b==1){
			str_list.push_front(c);
		}else{
			str_list.push_back(c);
		}
	}
	if(!flip) reverse(str_list.begin(),str_list.end());
	auto it = str_list.begin();
	while(it != str_list.end()){
		cout << *it;
		it++;
	}	
	cout << endl;	
	return 0; 
}


Measured memory_bytes: 9984
/*
 * Created by Dipta Das on 14-01-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define endl "\n"
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    ll a, b, k;
    cin >> a >> b >> k;
    int turn = 1;
    while (k--) {
        if (turn == 1) {
            // A
            if (a&1) --a;
            b += a/2;
            a /= 2;
        } else {
            if (b&1) --b;
            a += b/2;
            b /= 2;
        }
        turn *= -1;
    }

    cout << a << " " << b << endl;
    


    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;


namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int b = int.Parse(str[2]);
                char op = char.Parse(str[1]);
                              
                if (op == '+')
                {
                    Console.WriteLine("{0}", a + b);
                }
                else if (op == '-')
                {
                    Console.WriteLine("{0}", a - b);
                }
                else if (op == '*')
                {
                    Console.WriteLine("{0}", a * b);
                }
                else if (op == '/')
                {
                    Console.WriteLine("{0}", a / b);
                }
                else if (op == '?')
                {
                    break;
                }
                
            }
        }
    }
 }

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B,C;
  cin >> A >> B >> C;
  if (A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0)){
    cout << "YES";
  } else {
    cout << "NO";
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
	  	Scanner sc = new Scanner(System.in);
	  	int K = sc.nextInt();
      	int oddNums = K % 2 == 0 ? K / 2 : (K - 1) / 2;
	
 		System.out.println(oddNums * (K - oddNums));
	}
}

Measured memory_bytes: 21844
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    n = int(input())
    abc = [list(map(int,input().split())) for i in range(n)]
    dp = [[0]*3 for i in range(n+1)]
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if j == k:continue
                dp[i+1][k] = max(dp[i+1][k],dp[i][j]+abc[i][k])
    print(max(dp[n]))

if __name__ == "__main__":
    main() #endline===============================================

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N, M;
    cin >> N >> M;
    vector<bool> isSafe(N + 1, true);
    REP(i, M) {
        int a;
        cin >> a;
        isSafe[a] = false;
    }
    vector<int> dp(N + 1, 0);
    dp[0] = 1;
    if (isSafe[1]) dp[1] = 1;
    for (int i = 2; i <= N; ++i) {
        if (isSafe[i - 1]) {
            dp[i] += dp[i - 1];
        }
        if (isSafe[i - 2]) {
            dp[i] += dp[i - 2];
        }
        dp[i] %= MOD;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll s;
  cin>>s;
  vector<ll>v(s);
  for(ll i=0;i<s;i++)
  cin>>v[i];
  ll q;
  cin>>q;
  while(q--){
  ll x;
    cin>>x;
    if(binary_search(v.begin(),v.end(),x))
      cout<<1;
    else
      cout<<0;
    cout<<endl;
  }

}



Measured memory_bytes: 3548
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N, A, B, C, D int
	fmt.Scan(&N, &A, &B, &C, &D)
	var S string
	fmt.Scan(&S)

	s1 := S[A-1 : D]
	if strings.Contains(s1, "##") {
		fmt.Println("No")
		return
	}
	if C > D {
		s2 := S[B-2 : D+1]
		if !strings.Contains(s2, "...") {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=100005;

int main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout); 
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int k,x;cin >> k >> x;
	rep(i,2*k-1){
		cout << x-k+i+1 <<" ";
	}


}
	

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

int main(){
    int n,k,d,c,ans;
    cin>>n>>k;
    vector<int> v(n,-1);
    ans=n;
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>c;
            c--;
            if(v[c]==-1){
            v[c]=1;
            ans--;
            }
        }
    }
cout<<ans;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	while(cin >> n, n){
		vvi m(n, vi(0));
		rep (i, n) {
			int sz; cin >> sz;
			int p;
			rep (j, sz) {
				cin >> p;
				m[i].push_back(p);
			}
		}
		int k; cin >> k;
		vi l(k);
		string pear = "", berry = "";
		rep (i, k){
			cin >> l[i];
			pear += "0";
			berry += "1";
		}
		int cnt = 0;
		int ans = -1;
		rep (i, n) {
			string comp = pear;
			rep (j, m[i].size()) {
				rep (va, k) {
					if (m[i][j] == l[va]) {
						comp[va]++;
					}
				}
			}
			if (comp == berry) {
				cnt++;
				ans = i + 1;
			}
		}
		if(cnt == 1)
			cout << ans << endl;
		else
			cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3232
module Main where
import Data.List
import qualified Data.Vector as V
 
main :: IO()
main = do    
  n <- (read <$> getLine) :: IO Int
  a <- (fmap read <$> words <$> getLine) :: IO [Int]
  let l = V.fromList $ scanl' gcd 0 a
  let r = V.fromList $ reverse $ scanl' gcd 0 (reverse a)
 
  --print $ foldl max 0 $
  --  fmap (\i-> gcd (l V.! i) (r V.! (i+1))) [0..(n-1)]
        
  --print $ maximum $
  --  zipWith gcd l r
 
  print $ foldr max 0 $
     [ gcd (l V.! i) (r V.! (i + 1)) | i <- [0 .. ((fromIntegral n) - 1)] ]


Measured memory_bytes: 84348
using System;

namespace ITP1_7_D
{
    class Program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int l = int.Parse(str[2]);
            long[,] a = new long[n, m];
            long[,] b = new long[m, l];

            for (int i = 0; i < n; i++)
            {
                str = Console.ReadLine().Split(' ');

                for (int j = 0; j < m; j++) a[i, j] = long.Parse(str[j]);
            }
            for (int i = 0; i < m; i++)
            {
                str = Console.ReadLine().Split(' ');

                for (int j = 0; j < l; j++) b[i, j] = long.Parse(str[j]);
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < l; j++)
                {
                    long c = 0;

                    for (int k = 0; k < m; k++) c += a[i, k] * b[k, j];

                    if (j != l - 1) Console.Write(c + " ");

                    else Console.WriteLine(c);
                }
            }
        }
    }
}

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

int main() {
  int h, a; cin >> h >> a;
  cout << (h + a - 1) / a;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int x; cin>>x;
  int ans = 0;
  for(int i=1; i<=x; i++)
  {
    int temp = i, d = 0;
    while(temp>0)
    {
      d++;
      temp /= 10;
    }
    ans += (d & 1);
  }
  cout<<ans<<"\n";
}

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

int main()
{
  double32 Q, H, S, D;
  int64 N;
  cin >> Q >> H >> S >> D >> N;

  double32 mq = Q * 4.0;
  double32 mh = H * 2.0;
  double32 ms = S * 1.0;
  double32 md = D / 2.0;

  double32 m = min(mq, min(mh, ms));
  
  int64 ans;
  if (N % 2 == 1) {
    if (m <= md) ans = N * m;
    else ans = (int64)(N / 2) * md * 2 + m;
  } else {
    if (m <= md) ans = N * m;
    else ans = N * md;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a[5]={0},i,k;
	for(i=0;i<3;i++)
	{
	    cin>>k;
	    a[k]++;
	    cin>>k;
	    a[k]++;
	}
	if(a[1]<=2&&a[2]<=2&&a[3]<=2&&a[4]<=2)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
}

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

int H, W, N, X[200009], Y[200009]; map<pair<int, int>, int>M;
vector<int>Z[200009];

void add(int px, int py) {
	Z[py].push_back(px);
	M[make_pair(px, py)] = 1;
}

int get_value(int cx, int cy) {
	int pos1 = lower_bound(Z[cy].begin(), Z[cy].end(), cx) - Z[cy].begin();
	if (pos1 == Z[cy].size()) return (1 << 30);
	return Z[cy][pos1];
}

int main() {
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
		add(X[i], Y[i]);
	}
	for (int i = 1; i <= W; i++) add(H + 1, i);
	for (int i = 1; i <= H; i++) add(i, W + 1);
	for (int i = 1; i <= W; i++) sort(Z[i].begin(), Z[i].end());

	int cx = 1, cy = 1, minx = get_value(1, 1);
	while (true) {
		if (M[make_pair(cx + 1, cy)] == 0) {
			cx++;
			if (M[make_pair(cx, cy + 1)] == 0) {
				cy++; minx = min(minx, get_value(cx, cy));
			}
		}
		else {
			break;
		}
	}
	cout << minx - 1 << endl;
	return 0;
}

Measured memory_bytes: 71796
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
set<string>st;
int main(){
    string  s;
    cin >> s;
    int k;
    cin >> k;
    int n = (int)s.size();
    rep(i,n){
        for(int j = 1; j <= 5; j++){
            if(i+j>=n+1)continue;
            st.insert(s.substr(i,j));
        }
        if(st.size()>6){
            st.erase(*st.end());
        }
    }
    rep(i,k){
        if(i!=k-1)st.erase(*st.begin());
        else{
            cout << *st.begin() << endl;
        }
    }
}

Measured memory_bytes: 1152
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

template <typename T>
void show_all(T t) {
  rep (i, t.size()) {
    rep (j, t[0].size()) {
      cout << t[i][j];
    }
    cout << endl;
  }
}

int main() {
  string sentence;

  while (getline(cin, sentence)) {
    if (sentence == ".") {
      break;
    }
    int position = 0;

    stack<char> a;
    a.push('B');

    rep (i, sentence.size()) {
      if (sentence[i] == '(') a.push(sentence[i]);
      if (sentence[i] == '[') a.push(sentence[i]);

      if (sentence[i] == ')') {
        if ('(' == a.top()) a.pop();
        else {
          a.push('B');
        }
      }
      if (sentence[i] == ']') {
        if ('[' == a.top()) a.pop();
        else {
          a.push('B');
        }
      }
    }

    cout << (a.size() == 1 ? "yes" : "no") << endl;
  }
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a<=0 && 0<=b)
        cout<<"Zero"<<endl;
    else if((a>0 && b>0) || ((a-b+1)%2 == 0))
        cout<<"Positive"<<endl;
    else if((a-b+1)%2!=0)
        cout<<"Negative"<<endl;

    return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    VI p;
    FOR(i,1,1000){
        if(i*(i+1)*(i+2)/6 > 1e6) break;
        p.push_back(i*(i+1)*(i+2)/6);
    }

    VI dp(1e6,INT_INF);
    dp[0] = 0;
    for(int i : p){
        for(int j = i; j < 1e6; j++) chmin(dp[j], dp[j-i]+1);
    }
    VI dp1(1e6,INT_INF);
    dp1[0] = 0;
    for(int i : p){
        if(i%2 == 0) continue;
        for(int j = i; j < 1e6; j++) chmin(dp1[j], dp1[j-i]+1);
    }

    int x; cin >> x;
    while(x != 0){
        cout << dp[x] << " " << dp1[x] << en;
        cin >> x;
    }
    return 0;
}


Measured memory_bytes: 10580
import kotlin.math.ceil

fun main (args:Array<String>) {
    var (itemNum , popItem) = readLine()!!.split(" ").map(String::toInt)
    var vote = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var numVote = 0

    vote.forEach{                         //総得票数を求めるため
        numVote += it
    }
    val aaa = ceil(numVote.toDouble()/(4*popItem))   //人気商品を選ぶ基準の数字を決定,voteの中にaaa以上のものがpopItem以上あればYes,popItem未満であればNo
    var bbb = 0
    vote.sortDescending()
//    print(vote[0]..vote[popItem-1])

    vote.forEach {
        if (it >= aaa) bbb += 1
    }

    if(bbb >= popItem){
        print("Yes")
        return
    }
    print("No")



//    print(numVote)
//    print(numVote/(4*b))
//    for (i in vote) {
//        if (numVote / (4 * popItem) < i) {      //人気商品を選ぶための基準
//            print(i)
////            popItem - 1
////            if (popItem <= 0) break
//        }
//        else {
//            print("No")
//        }
//    }
}

Measured memory_bytes: 37968
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long n, i, a[100100], ans=1;
   cin >> n;
   for(i=0;i<n;i++){
      cin >> a[i];
      if(a[i]==0){
         cout << 0 <<endl;
         return 0;
      }
   }
   for(i=0;i<n;i++){
      if(ans>=LONG_MAX/a[i]){
         cout << -1 <<endl;
         return 0;
      }
      ans=ans*a[i];
      if(ans>1000000000000000000){
         cout << -1 <<endl;
         return 0;
      }
   }
   cout << ans << endl;
   return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll ans = 0, cur = 0;
    for (int i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        if(cur <= a) cur = a;
        else {
            ans += cur - a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3548
#include <stdio.h>

int main()
{
	int i, N, W, w[101], v[101];
	scanf("%d %d", &N, &W);
	for (i = 1; i <= N; i++) scanf("%d %d", &(w[i]), &(v[i]));
	
	int j, k, l, dp[2][101][301] = {};
	for (i = 1; i <= N; i++) {
		l = w[i] - w[1];
		for (j = l; j <= i * 3; j++) {
			for (k = 0; k < i; k++) if (dp[0][k][j-l] + v[i] > dp[1][k+1][j]) dp[1][k+1][j] = dp[0][k][j-l] + v[i];
		}
		for (j = 0; j <= i * 3; j++) {
			for (k = 0; k <= i; k++) dp[0][k][j] = dp[1][k][j];
		}
	}
	
	int max = 0;
	for (k = 0; k <= 100 && w[1] * k <= W; k++) {
		for (j = 0; j <= k * 3 && w[1] * k + j <= W; j++) if (dp[0][k][j] > max) max = dp[0][k][j];
	}
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

ac = 0
wa = 0
tle = 0
re = 0

n = int(input())

for i in range(n):
    s = input()
    if s == 'AC\n':
        ac += 1
    elif s == 'WA\n':
        wa += 1
    elif s == 'TLE\n':
        tle += 1
    else:
        re += 1

print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 9208