akhauriyash/Code-Regression huggingface dataset:
// 2011/07/05 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			if(pm==100||pe==100||pj==100)
				cout << 'A' << endl;
			else if((pm+pe)/2>=90)
				cout << 'A' << endl;
			else if((pm+pe+pj)/3>=80)
				cout << 'A' << endl;
			else if((pm+pe+pj)/3>=70)
				cout << 'B' << endl;
			else if(((pm+pe+pj)/3>=50)&&(pm>=80||pe>=80))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}

	return 0;
}

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

int dif(int a, int b) {
  if (a <= b) return b - a;
  else return a - b;
}

int main() {
  int N;
  cin >> N;
  vector<int> h(N), d(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  
  d[1] = dif(h[0], h[1]); d[2] = dif(h[0], h[2]);
  for (int i = 3; i < N; i++) {
    d[i] = min(dif(h[i], h[i - 1]) + d[i - 1], dif(h[i], h[i - 2]) + d[i - 2]);
  }
  
  cout << d[N - 1] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char a = s.charAt(0);
    char b = s.charAt(1);
    char c = s.charAt(2);
    char d = s.charAt(3);
    if((a == b && b == c )||( b == c && c == d )) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

// long long gcd(long long a, long long b){
//     if (a < b){
//         a ^= b;
//         b ^= a;
//         a ^= b;
//     }
//     return b ? gcd(b, a % b) : a;
// }

// long long lcm(long long a, long long b){
//     return a * b / gcd(a, b);
// }

int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int bubbleSort(int A[100], int n)
{
	int c, flag = 1, j, m; // ????????£??\????´?????????¨??????
	while(flag){
		flag = 0;
		for(j = n-1; j > 0; j--){ 
		if(A[j] < A[j-1]){
		 	m = A[j];
		 	A[j] = A[j-1];
		 	A[j-1]=m;
			flag = 1;
			A[n+1]++;
			}
		}
	}
	c = A[n+1];
	return c;
}

int main (void)
{
	int n, A[100]={0}, i, c;
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	
	c = bubbleSort(A,n);
	
	for(i=0; i<n; i++){
		printf("%d", A[i]);
		if(i != n-1) printf(" ");
		if(i == n-1) printf("\n");
	}
	
	printf("%d\n", c);
	
  return 0;
}

Measured memory_bytes: 604
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int a, b, k;
    cin >> a >> b >> k;
    set<Int> ans;
    for (Int i = 0; i < k; i++) {
        if (a <= i + a && i + a <= b) {
            ans.insert(i + a);
        }
        if (a <= b - i && b - i <= b) {
            ans.insert(b - i);
        }
    }

    for (auto e : ans) {
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	string s;
	cin >> s;
	int n = s.size(), ans = 0, ans1 = 0;
	for (int i = 0; i < n; i++) {
		ans1 += s[i] - '0';
	}
	ans += s[0] - '1';
	ans += (n - 1) * 9;
	if (ans < ans1) {
		cout << ans1 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    long long int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    long long int qy = q * 4, hy = h * 2;
    double dy = d / 2.0;
    long long int ans = 0;
    if(dy < qy && dy < hy && dy < s){
        ans += d * (n/2);
        ans += min({qy, hy, s}) * (n%2);
    }else{
        ans = min({qy, hy, s}) * n;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
C = gets.chomp

cx = C.split('')

left = 0
right = cx.length - 1

count = 0
while left < right
  if cx[left] == 'W'
    if cx[right] == 'R'
      count += 1
      left += 1
      right -= 1
    else
      right -= 1
    end
  else
    left += 1
  end
end

puts count


Measured memory_bytes: 30640
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n;cin>>n;
    string s;cin>>s;
    ll cnt=0; ll ans=0;
    FOR(i,0,n-2){
        for(char c='a';c<='z';c++){
            bool b1=false;
            bool b2=false;
            FOR(j,0,i) {if (s[j]==c) b1=true;}
            FOR(j,i+1,n-1) {if(s[j]==c) b2=true;}
            if(b1 && b2) cnt++;
        }
        // cout<<i<<' '<<cnt<<endl;
        ans = max(ans,cnt);
        cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int year, month, day;
  char a, b;
  cin >> year >> a >> month >> b >> day;
  if(month <= 4){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, m;
	cin >> n >> m;

	vector<int> h(n), a(m), b(m), pos(n, 1);
	rep(i, 0, n) cin >> h[i];

	rep(i, 0, m) {
		cin >> a[i] >> b[i];
		if (h[a[i] - 1] > h[b[i] - 1]) pos[b[i] - 1] = 0;
		else if (h[b[i] - 1] > h[a[i] - 1]) pos[a[i] - 1] = 0;
		else {
			pos[a[i] - 1] = 0;
			pos[b[i] - 1] = 0;
		}
	}

	int cnt = 0;

	rep(i, 0, n) {
		if (pos[i] == 1) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 4792
from itertools import product

n, m = map(int, input().split())
c = [[int(i) for i in input().split()] for i in range(n)]
ans = 0
for i, j, k in product([-1, 1], repeat=3):
    s = [i * x + j * y + k * z for x, y, z in c]
    s.sort(reverse=True)
    ans = max(ans, sum(s[:m]))
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

struct edge
{
    int to, cost;
};
vector<int> G[8];
int check[8] = {0};
int N;
int func(int index)
{
    //今、indexにいる
    int result = 0;
    rep(i, G[index].size())
    {
        auto next = G[index][i];
        if (check[next] == 0)
        {
            check[next] = 1;
            result += func(next);
            check[next] = 0;
        }
    }
    int ans = 0;
    rep(i, N)
    {
        ans += check[i];
    }
    if (ans == N)
        return result + 1;
    else
        return result;
}

int main()
{
    int m;
    cin >> N >> m;
    rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        G[s - 1].push_back(t - 1);
        G[t - 1].push_back(s - 1);
    }
    check[0] = 1;
    int hoge = func(0);

    cout << hoge << endl;
}

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

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int p = 0, f = 0;
    for (int i = 0; i < n; i++) {
        char c = s.at(i);
        if (c == 'c') {
            cout << "No" << endl;
        }
        else if (p >= a + b) {
            cout << "No" << endl;
        }
        else if (c == 'a') {
            p++;
            cout << "Yes" << endl;
        }
        else if (c == 'b') {
            if (++f <= b) {
                p++;
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

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

F = [0]*(N+1)
N2 = int(N**0.5)

for x in range(1, N2+1):
    n = x**2

    for y in range(1, N2+1):
        n2 = n + y**2 + x*y
        if n2 > N:
            break

        for z in range(1, N2+1):
            n3 = n2 + z**2 + y*z + z*x
            if n3 > N:
                break

            F[n3] += 1


for i in range(1, N+1):
    print(F[i])



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

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m;cin>>n>>m;
  int s,c;
  vector<int> a(n,-1);
  rep(i,m){
    cin>>s>>c;
    if(!(n>=2 && s==1 && c==0)&&(a[s-1]==-1 ||a[s-1]==c)){
      a[s-1]=c;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  rep(i,n) n>=2 && i==0 && a[i]==-1 ? cout<<1 : a[i]!=-1 ? cout<<a[i] : cout<<0;
  cout<<endl;
}

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

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X < Y) {
        cout << "<" << endl;
    } else if (X > Y) {
        cout << ">" << endl;
    } else {
        cout << "=" << endl;
    }
}

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

ans = 0
for i in range(1000):
	num=str(i).zfill(3)
	
	if num[0] in S:
		p1 = S.index(num[0])
		if num[1] in S[p1+1:]:
			p2 = p1+1+S[p1+1:].index(num[1])
			if num[2] in S[p2+1:]:
				ans += 1
				# print(num)


print(ans)

			

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	int ans = 1, i = k;
	while (i < n) {
		i += k - 1;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;


//----------------------------------------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2500 + 1;//                                                             |
//----------------------------------------------------------------------------------




//main func
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
    ll t=1;
    
    
    //cin>>t;
    while(t--){
        ll n;cin>>n;
        sl v;
        vl m(2e6,0);
        ll mx=0;
        for (int i=0;i<n;i++) {ll k;cin>>k;v.pb(k);m[k]++;mx=max(mx,k);}
        ll ans=0;
        vl vis(2e6,0);
        for(auto i:v){
            ll tmp=0;
            if(!vis[i]){
                for(int j=i*2;j<=mx;j+=i){
                    tmp+=m[j];
                    vis[j]=1;
                }
                if(m[i]==1) ans++;
            }
            
        }
        cout<<ans<<"\n";
    }
    
	return 0;
}

Measured memory_bytes: 43852
//Lion's Sin Escanor 

#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define moder 1000000007
#define forn(i,n) for(int i = 0; i < n ; i++)

ll moding( ll x , ll y ){
   
    ll ans = x % y;

    if(ans < 0)ans = ans + y ;

    return ans ;

}


bool isprime(ll n){
    if(n==2) return true;
    if(n==3) return true;
    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    ll i = 5,w=2;

    while(i*i <= n){
        if(n%i == 0)return false;

        i += w;
        w = 6 - w;
    }

    return true;
}

ll cmp(string s1 , string s2){
    // 1 for diff
    // 0 for same 

    int n = s1.size();
    int m = s2.size();

    if(n!=m)return 1;

    forn(i,n)
        if(s1[i] != s2[i])return 1;


    return 0; // SAME
}




int main(){

    ll n , temp; cin >> n;



    if(n % 2 == 0){
        ll ans = 0;

        for(ll i = 5 ; i <= n; i *= 5){
            ans += (n/i)/2;
        }

        cout << ans;




    }else cout << "0";

    cout << endl;



     
     
        
    return 0;
}
      
       

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
    try{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        boolean s[] = new boolean[1000000];
        int maxnum = 1000000;
        int count = 0;
        int sc[] = new int[1000000];
        s[0] = false;//??´????°???§?????????
        s[1] = false;
        for (int i = 2; i < maxnum; i++) {
        s[i] = true;  //??´????°
        }
        for (int i = 1; i < maxnum; i++) {
        if(s[i] == true){
            count++;
            for (int j = i+i; j < maxnum; j+=i) {
            s[j]=false;
            }
        }
        sc[i] = count;
        }
        while(null != (str = br.readLine())){
        int n = Integer.parseInt(str);
        System.out.println(sc[n]);
        }
    }
    catch(Exception e){
        System.exit(0);
    }
    }
}

Measured memory_bytes: 29820
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

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

    return 0;
}

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

int n, a[100005][3], dp[100005][3];

int solve(int i, int j)
{
    if (i == n)
        return 0;
    if (dp[i][j] != -1)
        return dp[i][j];
    int c = 0;
    for (int k = 0; k < 3; k++)
        if (k != j)
            c = max(c, solve(i + 1, k) + a[i][k]);
    return dp[i][j] = c;
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < 3; j++)
        cin >> a[i][j];
    cout << solve(0, 4);
    return 0;
}

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

using namespace std;

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

typedef long long ll;

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

 ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
 bool flag=false;
  rep(m,0,n) {
    if(c*(n-1-m)-d*m<=b-a&&b-a<=d*(n-1-m)-c*m) {
  flag=true;
  break;
  }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;

int n;
int a[maxn];

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> n;
   rep(i,1,n) cin >> a[i];
   a[1]--;
   rep(i,2,n){
      if(a[i] > a[i - 1]) a[i]--;
   }
   rep(i,2,n){
      if(a[i] < a[i - 1]) {
          cout << "No" ;
          return 0;
      }
   }   
   cout << "Yes";
   return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<tuple>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main(){
    int n;
    cin>>n;
    vector<int> v;
    int a;
    rep(i, n){
        cin>>a;
        if(n%2==0){
            if(i%2==0)
                v.push_back(a);
            else
                v.insert(v.begin(), a);
        }
        else{
            if(i%2==0)
                v.insert(v.begin(), a);
            else
                v.push_back(a);
            }
    }
    rep(i, n){
        cout<<v[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                1e18L
#define endl               '\n' 
#define PI                  3.14159265
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        rep(i ,0, n)cin >> a[i];
        sort(a , a + n);
        int ans = 1;
        rep(i, 0, n)
        {
        	if(ans > inf / a[i])
        	{
        		cout << -1;
        		return 0;
        	}
        	ans *= a[i];
        }
        if(ans > 1e18L)cout << -1;
       	else cout << ans;
    }
    return 0;
}

Measured memory_bytes: 4404
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.append(n)
    # divisors.sort()
    return divisors

n=int(input())
l=[]
# print(make_divisors(n))
md=make_divisors(n)
if 1 in md:
    md.remove(1)
for i in md:
    k=i-1
    if n//k==n%k:
        # print(k+1,n//k,n%k)
        l.append(k)
# print(l)
print(sum(l))



Measured memory_bytes: 39280
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    int N = inputValue();
    if (N>100)return 0;
    if (N<1)return 0;

    if (N==1){
        cout << 1 <<endl;
        return 0;
    }
    if (N%2 == 0){
        cout << 0.5 << endl;
        return 0;
    } else {
        double res = (double)(N+1)/(2*N);
        output(res, 6);
 //       cout << res << endl;
        return 0;
    }
    // source code
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;


int main(){
    int N;
    cin >> N;
    int i = 0;
    int kurai[1000];
  if(N == 0)printf("0\n");
  else{
    while(N != 0){
        kurai[i] = abs(N) % 2;
        N -= (1 - 2 * (i % 2)) * kurai[i];
        N /= 2;
        i++;
    }
    REP(j, i){
        printf("%d", kurai[i - j - 1]);
    }
    printf("\n");
  }
}


Measured memory_bytes: 256
#! /usr/local/bin/python3
# coding: utf-8

from bisect import bisect_left

def search(S, y):
    pos = bisect_left(S, y)
    return S[pos] == y

def count(S, T):
    c = 0
    for y in T:
        if search(S, y):
            c += 1
    return c

_ = int(input())
S = [int(x) for x in input().split()]

_ = int(input())
T = [int(y) for y in input().split()]

print(count(S, T))



Measured memory_bytes: 16928
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()

print('Yes' if n==m else 'No')

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

int main(){
    string S ;
    string days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cin >> S;

    for(int i=0; i<7; i++){
        if (S.compare(days[i]) == 0){
            if (i==0){
                cout << 7;
            }
            else{
                cout << 7 - i;
            }
        }
    }

    return 0;
}

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

int main (void){
  char a;
  cin >> a;
  
  if(isupper(a)) cout << 'A' << endl;
  else cout << 'a' << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(int argc,char* argv[]){
  
  char str[101];

  while(scanf("%s",str) != EOF){
    int i,j,loop;
    char at;
    for(i = 0; str[i] != '\0'; i++){
      if(str[i] == '@'){
	loop = str[i+1] - '0';
	at = str[i+2];
	for(j = 0; j < loop; j++){
	  printf("%c",at);
	}
	i += 2;
      }else{
	printf("%c",str[i]);
      }
    }
    printf("\n");
  }
  
  return 0;
  
}

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

int main(){
  int n, m, border, sum = 0, count=0;
  cin >> n >> m;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    sum = sum + a.at(i);
  }
  border = ceil((double)sum/(double)(4*m));
  sort(a.begin(), a.end());
  if(a.at(n-m)>=border)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
	int N;
	ll D;
	cin >> N >> D;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ll X, Y;
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sin = new Scanner(System.in);
		while (true) {
			int judgeCount = sin.nextInt();
			if (judgeCount == 0) break;
			int[] points = new int[judgeCount];
			int point = 0;
			for (int i = 0; i < judgeCount; i++) {
				point += points[i]  = sin.nextInt();
			}
			System.out.println(Math.round((point - max(points) - min(points))/(judgeCount-2)));
		}
	}
	
	private static int max(int[] datas){
		int result = datas[0];
		for (int i : datas) {
			result = Math.max(result, i);
		}
		return result;
	}
	
	private static int min(int[] datas){
		int result = datas[0];
		for (int i : datas) {
			result = Math.min(result, i);
		}
		return result;
	}
	
	
}

Measured memory_bytes: 0
import sys
for line in sys.stdin.readlines():
  m = int(line)
  c = 0
  l = []
  while m > 0:
    a = m % 2
    if a == 1:
      l.append(str(2**c))
    m = m // 2
    c += 1
  print(' '.join(l))

Measured memory_bytes: 7620
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main() {
  int w = readln.chomp.to!int;

  int[] amida;
  amida.length = w + 1;
  foreach (i, ref n; amida) {
    n = i.to!int;
  }

  int n = readln.chomp.to!int;
  for (int i = 0; i < n; i++) {
    auto ab = readln.chomp.split(",").map!(to!int);
    swap(amida[ab[0]], amida[ab[1]]);
  }

  foreach (x; amida[1..$]) {
    x.writeln;
  }
}

Measured memory_bytes: 1072
# coding: utf-8
import bisect
import math
N, c, k = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
i=0
#print(T)
ans = 0
while True:
    t=bisect.bisect_right(T, T[i]+k)
    #print("i="+str(i))
    if t >= i+c:
        i += c
    else:
        i = t
    ans += 1
    #print(i, ans)
    if i >= N:
        break
print(ans)

Measured memory_bytes: 81056
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val n = readInt
  val arr = readLine.split(" ").map(_.toInt)

  var swapCount = 0
  for (i <- 0 until n; mini = i; j <- i until n) {
    var mini = i
    for (j <- i until n) {
      if (arr(j) < arr(mini)) {
        mini = j
      }
    }
    if (i != mini) {
      swap(arr, i, mini)
      swapCount += 1
    }
  }

  println(arr.mkString(" "))
  println(swapCount)

  def swap(arr: Array[Int], i: Int, j: Int): Unit = {
    arr(i) = arr(i) ^ arr(j)
    arr(j) = arr(i) ^ arr(j)
    arr(i) = arr(i) ^ arr(j)
  }

}



Measured memory_bytes: 44780
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
	fast


		
	int n;
	cin>>n;

	vi v(n-1);
	forn(i,0,n-1)
	{
		cin>>v[i];
	}	

	ll sum = v[0];
	forn(i,0,n-2)
	{
		sum += min(v[i],v[i+1]);
	}

	sum += v[n-2];

	cout<<sum;







	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int H, W, h, w;
	cin >> H >> W;
	cin >> h >> w;
	cout << H * W - (H*w+W*h-h*w);
}

Measured memory_bytes: 256
from fractions import*
from functools import*
M=10**9+7
_,a=open(0)
*a,=map(int,a.split())
s=reduce(lambda x,y:x//gcd(x,y)*y,a)%M
c=0
for i in a:
    c+=s*pow(i,M-2,M)
    c%=M
print(c)

Measured memory_bytes: 6200
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> breads >>= mapM_ print . solve 

solve :: [Int] -> [Int]
solve as = calcs $ 0 : as
    where
        s = visit $ 0 : as

        visit (x : y : zs) = abs (x - y) + visit (y : zs)
        visit (x : _) = abs x

        calcs (w : x : y : zs) = s + abs (w - y) - abs (w - x) - abs (x - y) : calcs (x : y : zs)
        calcs (w : x : _) = [s + abs w - abs (w - x) - abs x]

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 13564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int a,b;cin>>a>>b;int ans=-1;
        for(int i=1;i<=1000;i++){
            if(a==((i*8)/100)&&b==(i/10)){
                ans=i;break;
            }
        }
        cout<<ans;
    }   
    return 0;   
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w,h,n;
    cin>>w>>h>>n;
    // int tot = w*h;
    vector<vector<int> > V(h,vector<int>(w,0));
    for(int i = 0; i < n; i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
 
        if(c==1)
        {
            for(int i = 0; i < h; i++)
                for(int j = 0; j < a; j++)
                    V[i][j] = 1;
        
            // /tot -= a*h;
        }
        else if(c == 4)
        {
            for(int i = b; i < h; i++)
                for(int j = 0; j < w; j++)
                    V[i][j] = 1;
        }
        else if(c == 2)
        {
            for(int i = 0; i < h; i++)
                for(int j = a; j < w; j++)  V[i][j] = 1;
        }
        else 
        {
           for(int i = 0; i < b; i++)
            for(int j = 0; j < w; j++)
                V[i][j] = 1;
        }
    }
    int tot = 0;
    for(int i = 0; i < h ; i++) for(int j = 0; j < w; j++)  if(V[i][j] == 0)   tot++;
    cout<<tot<<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N  =sc.nextInt();
        int [] list = new int[N];
        for(int i=1;i<=N;i++){
            int num = sc.nextInt();
            list[num-1]=i;
        }
        for(int i=0;i<N;i++) System.out.print(list[i]+" ");
        System.out.println();
    }
}


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

using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    ll take1 = min(k, a);
    k -= take1;
    sum += take1;
    ll take2 = min(k, b);
    k -= take2;
    ll take3 = min(k, c);
    sum -= take3;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int h,w,i,j,k;

    for(k=1;;k++){
    scanf("%d %d",&w,&h);
    if(w==0&&h==0){
        
    break;
}

  //  printf("\n");
    for(i=1;i<=w;i++){
        for(j=1;j<=h;j++)
            printf("#");
            printf("\n");
        
    }
    printf("\n");
 
    
   
}
return 0;
}



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

int main(void){
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0, ans = 0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='0'){
            if(cnt1==0) ++cnt0;
            else{
                --cnt1;
                ans = ans+2;
            }
        }else{
            if(cnt0==0) ++cnt1;
            else{
                --cnt0;
                ans  = ans + 2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  int i,j;
  char c[21];
  for(i=0;;i++)
    {
      scanf("%c",&c[i]);
      if(c[i]=='\n') break;
    }
  for(j=i-1;j>=0;j--) printf("%c",c[j]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
<?php

fscanf(STDIN, '%s %s', $s, $t);
fscanf(STDIN, '%d %d', $a, $b);
fscanf(STDIN, '%s', $u);

if ($u === $s) {
    $a--;
} else {
    $b--;
}
echo "$a $b".PHP_EOL;

Measured memory_bytes: 4856
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        System.out.println(solve(in));
        
      }
      
      public static String solve(Scanner in) {
       int A = in.nextInt();
       int B = in.nextInt();
       int C = in.nextInt();

       return C + " " + A + " " + B;
      }
    
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second

 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  i64 a, b, c, d;
  cin >> a >> b >> c >> d;
  i64 tot = b - a + 1;
  auto solve = [&] (int x) {
    tot -= b / x;
    tot += (a - 1) / x;
  };
  solve (c); solve (d);
  i64 lcm = (c * d) / __gcd (c, d);
  tot += b / lcm;
  tot -= (a - 1) / lcm;
  cout << tot << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int P;

int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);
		if (half > P)return -1;
		return half * half;
	}
	else {
		int b = modpow(a, p - 1);
		if (b > P)return -1;
		return a * b;
	}
}


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

	int N; cin >> N >> P;
	if (N == 1) {
		cout << P << endl;
		return 0;
	}
	int ans = 1;
	int i = 2;
	while (1) {
		int tmp = modpow(i, N);
		//cout << tmp << endl;
		if (tmp <= 1)break;
		if (tmp > P)break;
		if (P%tmp == 0)chmax(ans, i);
		i++;
	}


	cout << ans << endl;

	return 0;
}



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

int main() {
    vector<int> c(4, 0);
    string s; cin >> s;
    for (string::iterator i = s.begin(); i != s.end(); i++) {
        switch (*i) {
            case 'K':
                c[0]++;
                break;
            case 'U':
                c[1]++;
                break;
            case 'P':
                c[2]++;
                break;
            case 'C':
                c[3]++;
                break;
        }
    }
    cout << *min_element(c.begin(), c.end()) << endl;
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

int main(){

   int ans = 0;

   string S;

   cin >> S;

   for(int i = 0;i < 4;i++){
	   if(S[i] == '+'){
		   ans++;
	   }else{
		   ans--;
	   }
   }

   cout << ans << endl;



   return 0;

}


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

#define AC 0
#define WA 1
#define TLE 2
#define RE 3

using namespace std;

int main(void)
{
    int N;
    string S;
    int cnt[4] = {0};

    cin >> N;

    for(int i = 0; i < N; i++)
    {
        cin >> S;

        if(S == "AC")
        {
            cnt[AC]++;
        }
        else if(S == "WA")
        {
            cnt[WA]++;
        }
        else if(S == "TLE")
        {
            cnt[TLE]++;
        }
        else if(S == "RE")
        {
            cnt[RE]++;
        }
        else
        {
            /* nothing */
        }
    }

    cout << "AC x "  <<  cnt[AC]  << endl;
    cout << "WA x "  <<  cnt[WA]  << endl;
    cout << "TLE x " <<  cnt[TLE] << endl;
    cout << "RE x "  <<  cnt[RE]  << endl;

    return 0;
}


Measured memory_bytes: 3628
import sys

def input():
    return sys.stdin.readline().rstrip()

N, K, Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
P = [K for _ in range(N)]
W = [0 for _ in range(N)]

for num1 in A:
    W[num1 - 1] += 1

for i, num2 in enumerate(W):
    P[i] += num2 - Q

for fin in P:
    if fin > 0:
        print('Yes')
    else:
        print('No')

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int mul4;mul4=0;
    int mul2;mul2=0;
    int odd;odd=0;
    int temp;
    REP(i,N){
        cin>>temp;
        if(temp%4==0){
            mul4++;
        }else if(temp%2==0){
            mul2++;
        }else{
            odd++;
        }
    }
    //debug(mul4);debug(mul2);debug(odd);
    if(mul2==0){
        if(mul4-odd>=-1){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }else{
        if(mul4-odd>=0){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
}

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

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793


int main()
{
    ll n;
    cin >> n;
    if (n % 10 == 3) {
        cout << "bon" << endl;
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }

    //cout << "" << endl;

    return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    exit()

x = a[0]
for i in range(n - 1):
    x *= a[i + 1]
    if x > 10 ** 18:
        print(-1)
        exit()
print(x)

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

int digitSum(int x){
  int sum=0;
  while(x>0){
    sum += x%10;
    x /= 10;
  }
  return sum;
}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int c=0;
  for(int i=1;i<=n;i++){
    int s =digitSum(i);
    if(a<=s&&s<=b) c+=i;
  }
cout<<c<<endl;
}


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

int main()
{
  int A, B, C, D, ans = 0;
  cin >> A >> B >> C >> D;

  for (int i = 0; i < D; ++i)
  {
    if (A > 0)
    {
      ans += 1;
      A--;
    }
    else if (B > 0)
    {
      B--;
    }
    else if (C > 0)
    {
      ans -= 1;
      C--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624