akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

//#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

int get(int mask, int n, int m, int k, vector<string>& a) {
    vector<vector<int>> b;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        vector<int> q(m);
        while (i < n) {
            for (int j = 0; j < m; j++) {
                if(a[i][j] == '1') q[j]++;
            }
            if (i == n - 1 || ((mask >> i) & 1)) break;
            i++;
        }
        if (i < n - 1) cnt++;
        b.push_back(q);
    }
    vector<int> last(b.size());

    for (int i = 0; i < m; i++) {
        bool good = false;
        for (int j = 0; j < b.size(); j++) {
            if (b[j][i] > k) return INF;
            if (last[j] + b[j][i] > k) good = true;
        }
        if (good) cnt++;
        for (int j = 0; j < b.size(); j++) {
            if (good) last[j] = b[j][i];
            else last[j] += b[j][i];
        }
    }
    return cnt;
}

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    int ans = INF;
    for (int mask = 0; mask < (1 << (h - 1)); mask++) {
        ans = min(ans, get(mask, h, w, k, a));
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)


int main(){
	
    std::array<int, 3> arr;
    rep(i, 3)std::cin >> arr[i];
    std::sort(arr.begin(), arr.end());

    int ans = arr[0] + arr[1];
    std::cout << ans;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {
    static final long MAX_IDX = 10000000;
    static long[] dp = new long[(int)MAX_IDX + 1];
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        long N = Long.parseLong(in1[1]);
        List<Long> A = new ArrayList<>();
        List<Long> B = new ArrayList<>();
        for(int i = 0; i < N; i++){
            in1 = br.readLine().split(" ");
            A.add(Long.parseLong(in1[0]));
            B.add(Long.parseLong(in1[1]));
        }
        br.close();

        Arrays.fill(dp, Long.MAX_VALUE);
        dp[0] = 0L;

        for(int n = 0; n < N; n++){
            long atk = A.get(n);
            long mpt = B.get(n);

            for(int h = 0; h < H; h++){
                if(dp[h] == Long.MAX_VALUE) continue;

                long next_h = h + atk;
                if(next_h >= H) next_h = H;

                dp[(int)next_h] = Math.min(dp[(int)next_h], dp[h] + mpt);
            }
        }

        System.out.println(dp[(int)H]);
    }
}

Measured memory_bytes: 104656
import itertools

cnt_500 = int(input())
cnt_100 = int(input())
cnt_50 = int(input())
target_amount = int(input())

cnt_500_arr = [i for i in range(cnt_500+1)]
cnt_100_arr = [i for i in range(cnt_100+1)]
cnt_50_arr = [i for i in range(cnt_50+1)]

coin_combinations = list(itertools.product(cnt_500_arr, cnt_100_arr, cnt_50_arr))

result_count = 0
for cnt_500, cnt_100, cnt_50 in coin_combinations:
	amount = cnt_500 * 500 + cnt_100 * 100 + cnt_50 * 50
	if amount == target_amount:
		result_count += 1
print(result_count)

Measured memory_bytes: 13604
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, M, K;
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> K;
    
    rep(i, 0, N + 1) {
        int painted = i * M;

        int d = (N - i) - i;

        // painted + d * n = K
        // d * n = K - painted

        if (d == 0 && (K - painted) == 0) {
            printf("Yes\n");
            return;
        }

        if(d) if (0 <= K - painted) if ((K - painted) % d == 0) {
            int n = (K - painted) / d;
            if (0 <= n && n <= M) {
                printf("Yes\n");
                return;
            }
        }
    }

    printf("No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[200000];
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){cin>>a[i];a[i]--;}
vector<int> idx(n);//場所
for(int i=0;i<n;i++)idx[a[i]]=i;
set<int> s;
ll ans=0;
for(int x=n-1;x>=0;x--){
int i=idx[x];
ll c=0;//個数
s.insert(i);
vector<int> l(2,-1),r(2,n),ls(2),rs(2);//左右それぞれのxより大きい数
auto ite=s.find(i);
for(int j=0;j<2;j++){
    if(ite==s.begin())break;
    ite--;
    l[j]=*ite;
}
ite=s.find(i);
for(int j=0;j<2;j++){
     ite++;//範囲外を参照しないために先に足す
    if(ite==s.end())break;
    r[j]=*ite;
}
ls[0]=i-l[0];ls[1]=l[0]-l[1];
rs[0]=r[0]-i;rs[1]=r[1]-r[0];
c=(ll)ls[0]*rs[1]+(ll)ls[1]*rs[0];
ans+=(x+1)*c;
}
cout<<ans<<endl;
}


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

int main(){
  string s;
  cin>>s;
  string ans;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      ans.push_back('0');
    }else if(s[i]=='1'){
      ans.push_back('1');
    }else if(s[i]=='B'){
      if(ans.size()>0){
      ans.pop_back();
    }
    }
  }

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


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

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

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

	vector< bool> mem( 1000000000L , 0 );

	rep( i , n ){
		ll a;
		cin>>a;
		if( mem[--a] == 1){
			cout<<"NO";
			return 0;
		}
		else mem[a] = 1;
	}
	cout<<"YES";
}


Measured memory_bytes: 122368
#include<stdio.h>
#include<math.h>
int main(){
int x,a,b;
scanf("%d%d%d",&x,&a,&b);
if((x>=1 && x<=pow(10,9))&&(a>=1 && a<=pow(10,9)&&(b>=1 && b<=pow(10,9))))
if(b<=a)
{
    printf("delicious\n");
}
else if(b<=(x+a))
{
    printf("safe\n");
}
else {
    printf("dangerous\n");
}
return 0;
}



Measured memory_bytes: 1608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define PI acos(-1)
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> x(N), y(N);
  FOR(i,0,N) cin >> x[i] >> y[i];
  FOR(i,0,N) {
    vector<double> ang;
    FOR(j,0,N) {
      if(i != j) {
        ang.push_back(atan2(y[j]-y[i], x[j]-x[i]));
      }
    }
    sort(ang.begin(), ang.end());
    double mx = 0.0;
    FOR(j,0,ang.size()-1) {
      mx = max(mx, ang[j+1]-ang[j]);
    }
    mx = max(mx, ang[0] + 2 * PI - ang[ang.size()-1]);
    double ans = mx > PI ? (mx - PI) / 2 / PI : 0.0;
    cout << fixed << setprecision(17) << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 384
n, k, q = map(int, input().split())
alis = [k-q]*n
for _ in range(q):
    a_i = int(input())
    alis[a_i - 1] += 1
for i in range(n):
    if alis[i] > 0:
        alis[i] = 'Yes'
    else:
        alis[i] = 'No'
print('\n'.join(alis))

Measured memory_bytes: 5880
import Glibc
extension String: CollectionType {}

//var abc = readLine()!.split(" ").map { Int($0)! }
var n = Int(readLine()!)!
var a = n / 1000
var b = (n % 1000) / 100
var c = (n % 100) / 10
var d = n % 10
if (a == b && b == c) || (b == c && c == d) {
  print("Yes")
} else {
  print("No")
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
int diff,ans;
string S,T;
  cin >> S >> T;
  ans = T.size();
  for (int i = 0; i <= S.size() - T.size(); ++i) {
    diff = 0;
    for (int j = 0; j < T.size(); ++j) {
   if (S[j+i] != T[j]) {diff++;} 
    }
  ans = min(ans,diff);
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main(){
  /*
  方針
  全ての地点の距離までのコストを累積和として持っておく
  */
  int H,W,D;
  cin >> H >> W >> D;
  int A[H][W];
  map<int,pair<int,int> > coordinates;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      scanf("%d",&A[i][j]);
      pair<int,int> input;
      input.first = i;
      input.second = j;
      coordinates[A[i][j]] = input;
    }
  }
  //calc cost
  vector<int> sumCost(H*W+1,0);
  for(int i = D+1; i < H*W+1; i++){
    sumCost[i] =  abs(coordinates[i].first - coordinates[i-D].first) +
                  abs(coordinates[i].second - coordinates[i-D].second);

  }

  //sum costs
  for(int i = 1; i <= H*W-D; i++){
    sumCost[i+D] += sumCost[i];
  }

  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++){
    int l,r;
    cin >> l >> r;
    cout << sumCost[r] - sumCost[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
#define ll long long
#define pll pair<ll,ll>
ll dp[105][100005];
ll wt[100005];
ll val[100005];
pll p[100005];


int main()
{

	ll n,W;
	cin>>n>>W;
	memset(dp,0,sizeof(dp));
	memset(wt,0,sizeof(wt));
	memset(val,0,sizeof(val));
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<2;j++)
		{
			if(j==0)
				cin>>wt[i];
			else
				cin>>val[i];
		}
		p[i]={wt[i],val[i]};
	}
	sort(p+1,p+n+1, greater<pll> ());
	// for(int i=1; i<=n; i++)
	// {
	// 	for(int j=0; j<2;j++)
	// 	{
	// 		if(j==0)
	// 			cout<<wt[i]<<" ";
	// 		else
	// 			cout<<val[i],nl;
	// 	}
	// }

	for(int j=1; j<=W; j++)
	{	
		for(int i=1;i<=n; i++)
		{
			int t_wt=p[i].first;
			int t_val=p[i].second;
			if(t_wt<=j)
			{
				dp[i][j]=max(dp[i-1][j-t_wt]+t_val,dp[i-1][j]);
			}
		}
	}	
	cout<<dp[n][W];
	return 0;
}

Measured memory_bytes: 83840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    string s, t;
    cin >> s >> t;
    string ans = "Yes";
    if (s.size()+1!=t.size()) ans = "No";
    else {
        rep(i, s.size()) {
            if (s[i]!=t[i]) ans = "No";
        }
    }
    
    
    
    
    cout << ans << endl;
    return 0;
}


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

int main(void) {

    int A, B, V, W;
    int T;

    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if (V <= W) {
        cout << "NO" << '\n';
        return 0;
    }

    long long dist = (V - W) * T;

    int diff = abs(A - B);

    if (dist >= diff) cout << "YES" << '\n';
    else cout << "NO" << '\n';


    return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>

int main()
{
    int a, b, c, k, i;

    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);

    for (i = 1; i <= k; i ++) {
        if (c <= b) {
            c = c * 2;
            continue;
        }

        if (b <= a) {
            b = b * 2;
        }
    }

    if (b > a && c > b) printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>

using namespace std;


int main() {

	int N, K;
	cin >> N >> K;

	int a[200010];
	for (int i = 1; i <= N; ++i) cin >> a[i];

	int num[200010] = { 0 };//バケット

	for (int i = 1; i <= N; ++i) {
		num[a[i]]++;
		
	}

	/*for (int i = 1; i <= N; ++i) {
		cout << i << ":" << num[i] << " ";
	}*/

	sort(num+1, num + (N+1), greater<int>());//大きい順にソート

	cout << endl;

	/*for (int i = 1; i <= N; ++i) {
		cout << i << ":" << num[i] << " ";
	}*/

	int sum = 0;
	for (int i = K + 1; i <= N; ++i) sum += num[i];

	cout << endl<< sum << endl;

}

Measured memory_bytes: 1792
n,k = map(int, input().split())
okashi = [0]*n

for i in range(k*2):
  a = list(map(int, input().split()))
  if i % 2 == 1:
    for j in range(len(a)):
      okashi[a[j]-1] = 1
      
print(okashi.count(0))

Measured memory_bytes: 9076
#include <stdio.h>
#include <stdlib.h>
   
long long inv;
int *B;
   
long long countup(int *A, int p, int r);
   
int main(int argc, char *argv[])
{
  int n, i, j;
  int *A;
   
  inv = 0;
   
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
   
  inv = countup(A, 0, n - 1);
   
  printf("%lld\n", inv);
   
  return 0;
}
   
long long countup(int *A, int p, int r)
{
  int q = p + (r-p)/2;
  int i, j, k, tmp;
  long long ct = 0;
   
  if (r - p < 3) {
    for (i = p; i < r; i++) {
      for (j = r; j > i; j--) {
    if (A[j] < A[j-1]) {
      tmp = A[j-1];
      A[j-1] = A[j];
      A[j] = tmp;
      ct++;
    }
      }
    }
    return ct;
  }
  ct += countup(A, p, q);
  ct += countup(A, q+1, r);
   
  i = p;
  j = q + 1;
  for (k = p; k <= r; k++) {
    if (i >= q + 1 || j >= r + 1) {
      if (i >= q + 1) B[k] = A[j++];
      else B[k] = A[i++];
    } else {
      if (A[i] > A[j]) {
    B[k] = A[j];
    ct += q - i + 1;
    j++;
      } else {
    B[k] = A[i];
    i++;
      }
    }
  }
  for (k = p; k <= r; k++) A[k] = B[k];
  return ct;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,K;
    int A[214514];
    vector<int> Po,Ne,Ze;
    cin >> N >> K;
    REP(i,N){
        cin >> A[i];
        if(A[i]>0){
            Po.push_back(A[i]);
        }else if(A[i]<0){
            Ne.push_back(A[i]);
        }else{
            Ze.push_back(A[i]);
        }
    }
    int Se=0,Fu=0,Mu=0;
    Se+=(Po.size())*(Po.size()-1)/2;
    Se+=(Ne.size())*(Ne.size()-1)/2;
    Fu+=(Ne.size())*(Po.size());
    Mu+=(Ze.size())*(Ze.size()-1)/2;
    Mu+=(Ze.size())*(Po.size());
    Mu+=(Ze.size())*(Ne.size());
    
    sort(Po.begin(),Po.end());
    sort(Ne.begin(),Ne.end());
    //cout << Se MM Fu MM Mu << endl;
    if(K<=Fu){
        //答えは負
        int l=-INF,r=-1,mid;
        while(abs(r-l)>1){
            mid=(l+r)/2;
            int num=0;
            REP(i,Ne.size()){
                decltype(Po)::iterator it = std::upper_bound(Po.begin(), Po.end(), mid/Ne[i]);
                num+=it-Po.begin();
            }
            //cout << l MM r MM mid MM Fu-num << endl;
            if(Fu-num>=K){
                r=mid;
            }else{
                l=mid;
            }
        }
        cout <<l << endl;
        return 0;
        
    }else if(K<=Fu+Mu){
        cout << 0 << endl;
        return 0;
    }else{
        //答えは正
        REP(i,Ne.size()){
            Ne[i]*=-1;
        }
        sort(Ne.begin(),Ne.end());
        int l=1,r=INF,mid;
        while(abs(r-l)>1){
            mid=(l+r)/2;
            int num=0;
            int num1=0,num2=0;
            REP(i,Po.size()){
                decltype(Po)::iterator it = std::upper_bound(Po.begin(), Po.end(), mid/Po[i]);
                num1+=max(0ll,(it-Po.begin())-i-1);
            }
            REP(i,Ne.size()){
                decltype(Ne)::iterator it = std::upper_bound(Ne.begin(), Ne.end(), mid/Ne[i]);
                num2+=max(0ll,(it-Ne.begin())-i-1);
            }
            //num2=((Ne.size())*(Ne.size()-1)/2)-num2;
            num=num1+num2;
            //cout << l MM r MM mid MM num1 MM num2 MM num MM Fu+Mu+num << endl;
            if(Fu+Mu+num>=K){
                r=mid;
            }else{
                l=mid;
            }
        }
        cout << r << endl;
        
    }
    
    return 0;
}



Measured memory_bytes: 3700
#include<stdio.h>

/*
int dig(number){
    int count = 0;
    while(number != 0){
        number /=10;
        printf("%d",number);
        count++;
    }
    return count;
}
*/

int sum(num){
    int sum = 0;
    int dig = 0;
    while(num!=0){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
//        printf("dig=%3d sum=%3d num=%3d \n",dig,sum,num);
    }
    return sum;
}

int main(){

    int lim, min, max;
    int chk, chk_sum;
    chk_sum = 0;
    scanf("%d %d %d", &lim, &min, &max);
//    int digit = dig(lim);

    for(int i=1; i <= lim; i++){
        chk = sum(i);
        if(chk >= min && chk <= max){
//            printf("--- %d ---\n",i);
            chk_sum += i;
        }
//        printf("%d %d\n",i, digit);
    }
    printf("%d\n", chk_sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;

const double pi = acos(-1);

int main(){
  int i,j;
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  double sH,sM;
  sH=(H/12.0)*2.0*pi+(M/60.0)*2*pi/12.0;
  sM=(M/60.0)*2.0*pi;
  double ans;
  ans=sqrt(pow(A,2.0)+pow(B,2.0)-2*A*B*cos(sH-sM));
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
  
}
  

Measured memory_bytes: 4228
// Problem : B - TAKOYAKI FESTIVAL 2019
// Contest : AtCoder - AtCoder Beginner Contest 143
// URL : https://atcoder.jp/contests/abc143/tasks/abc143_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back;
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
using namespace std;
int main()
{
	lli n,i,j,ans=0;
	cin>>n;
	lli a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			ans+=a[i]*a[j];
		}
		ans-=a[i]*a[i];
	}
	cout<<ans/2;
	
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (A + B <= 2 * C) {
        cout << A * X + B * Y << endl;
        return 0;
    }
    int cost1 = 2 * X * C + max(Y - X, 0) * B;
    int cost2 = 2 * Y * C + max(X - Y, 0) * A;
    cout << min(cost1, cost2) << endl;
    return 0;
}


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

int main(){
  string s;
  ull i,sum=0;
  cin>>s;
  for(ull i=0;s[i]!='\0';i++){
     if(s[i]==s[i+1]&&s[i+1]=='0'){
         sum++;
         s[i+1]='1';
     }
     else if(s[i]==s[i+1]&&s[i+1]=='1'){
         sum++;
         s[i+1]='0';
     }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
const int N = 2e5;
int ans[N+100];
set<pii>st;
map<int,vector<pii> >m;
int main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		int s,t,x;
		scanf("%d%d%d",&s,&t,&x);
		if(s==t)continue;
		m[x].push_back(mp(s,t-1));
	}
	for(int i=1;i<=q;i++){
		int d;
		scanf("%d",&d);
		st.insert(mp(d,i));
	}
	for(auto i:m)
	{
		for(auto j:m[i.first])
		{
			int l = j.first-i.first,r = j.second-i.first;
			auto it = st.lower_bound(mp(l,-1));
			while(it!=st.end()&&it->first<=r)
			{
				ans[it->second] = i.first;
				pii tmp = *it;
				it++;
				st.erase(tmp);
			}
		}
	}
	for(auto it:st)
	{
		ans[it.second] = -1;
	}
	for(int i=1;i<=q;i++){
		printf("%d\n",ans[i]);
	}
	printf("\n");
}


Measured memory_bytes: 33280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 200005;

struct Edge
{
	int to;
	int nxt;
}edge[MAXN << 1];

int n,id,ans;
int first[MAXN];
int depth[MAXN];

void addE(int u,int v)
{
	edge[++id] = (Edge){v,first[u]};
	first[u] = id;
}

void dfs(int u,int fa)
{
	int MAX1 = 0,MAX2 = 0;
	for (int i = first[u];i;i = edge[i].nxt)
		if (edge[i].to != fa)
		{
			dfs(edge[i].to,u);
			if (depth[edge[i].to] >= MAX1)
			{
				MAX2 = MAX1;
				MAX1 = depth[edge[i].to];
			}
			else if (depth[edge[i].to] > MAX2)
				MAX2 = depth[edge[i].to];
		}
	ans = max(ans,MAX1 + 1 + MAX2);
	depth[u] = MAX1 + 1;
}

int main()
{
	scanf("%d",&n);
	for (int u,v,i = 1;i < n;i++)
	{
		scanf("%d%d",&u,&v);
		addE(u,v);
		addE(v,u);
	}
	dfs(1,0);
	puts(ans % 3 == 2 ? "Second" : "First");
	return 0;
}

Measured memory_bytes: 16896
package main
import (
        "fmt"
)

func main() {
        var num int
        fmt.Scan(&num)

        for i := 0; i < num; i++ {
                s1 := 0
                s2 := 0
                s3 := 0
                var chk int = 0
                fmt.Scanf("%d %d %d", &s1, &s2, &s3)
                if s1 >= s2 {
                        if s1 > s3 {
                                chk = 1
                        } else {
                                chk = 3
                        }
                } else {
                        if s2 >= s3 {
                                chk = 2
                        } else {
                                chk = 3
                        }
                }

                if (chk == 1 && s1*s1 == s2*s2 + s3*s3) ||
                        (chk == 2 && s2*s2 == s3*s3 + s1*s1) ||
                        (chk == 3 && s3*s3 == s1*s1 + s2*s2) {
                        fmt.Printf("YES\n")
                } else {
                        fmt.Printf("NO\n")
                }
        }
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  bool approve = true;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    if(a.at(i) % 2 == 0){
      if(a.at(i) % 3 != 0 && a.at(i) % 5 != 0){
        approve = false;
        break;
      }
    }
  }
  if(approve){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

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

    lint res = 0;

    if(N == 7 || N == 5 || N == 3) PRINT("YES");
    else PRINT("NO");

    return 0;
}


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

using namespace std;

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

    int count = 0;

    stack<char> st;

    for(int i = 0 ; i < S.length() ; i++)
    {
        if(!st.empty())
        {
            if(st.top() != S[i])
            {
                st.pop();
            }
            else
            {
                st.push(S[i]);
            }
            
        }
        else
            st.push(S[i]);
    }

    cout << S.length() - st.size() << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = numeric_limits<int>::max() / 2;

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

struct edge {
	int src, dst, weight;
	edge(int src, int dst, int weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const edge &e, const edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

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

	int n, m;
	while (true) {
		cin >> n >> m;
		if (n == 0) break;
		vector<P> g[100];
		vector<edge> edges;
		for (int i = 0; i < m; i++) {
			int a, b, w; cin >> a >> b >> w;
			a--; b--;
			edge e(a, b, w);
			edges.push_back(e);
			g[a].push_back(P(b, w));
			g[b].push_back(P(a, w));
		}
		int res = INF;
		for (int i = 0; i < m; i++) {
			UF uf(n);
			edge e = edges[i];
			int a = e.src, b = e.dst;
			int ma = e.weight, mi = e.weight;
			priority_queue<P,vector<P>,greater<P>> q;
			uf.unite(a, b);
			for (int j = 0; j < (int)g[a].size(); j++){
				if (g[a][j].second >= mi) q.push(P(g[a][j].second, g[a][j].first));
			}
			for (int j = 0; j <(int) g[b].size();j++){
				if(g[b][j].second >= mi) q.push(P(g[b][j].second, g[b][j].first));
			}
			while (!q.empty()) {
				P p = q.top();q.pop();
				if (p.first < mi) continue;
				if (uf.find(a, p.second)) continue;
				ma = max(ma, p.first);
				uf.unite(a, p.second);
                
				for (int j = 0; j <(int) g[p.second].size(); j++) {
                   // cout<<p.second<<" "<<j<<endl;
					if (g[p.second][j].second >= mi) q.push(P(g[p.second][j].second, g[p.second][j].first));
				}
			}
			if (uf.size(a) < n) continue;
			else res = min(res,ma - mi);
		}
		if (res == INF) cout << -1 << endl;
		else cout << res << endl;
	}
}

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

int main(void)
{
  int a,b;
  cin>>a>>b;
  if(0<a&&a<=b)
    cout<<"Positive"<<endl;
  else if(a<=b&&b<0){
    if((b-a+1)%2==0)
      cout<<"Positive"<<endl;
    else
      cout<<"Negative"<<endl;
  }
  else if(a<=0&&0<=b)
    cout<<"Zero"<<endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(N,A):
    A.reverse()
    return A
    
N = I()
A = LI()
print(*main(N,A))


Measured memory_bytes: 6796
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

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

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

bool comp(int a,int b){
    return abs(a)>abs(b);
}
ll power(ll x,int b){
    ll res=1;
    while(b){
        if(b&1) res=res*x%mod;
        x=x*x%mod;
        b/=2;
    }
    return res;
}
signed main(){
    FastIO;
    int n,k;
    vector<ll>v;
    cin>>n>>k;
    bool ok=1;
    rep(i,1,n){
        int a;
        cin>>a;
        if(a>=0) ok=0;
        v.pb(a);
    }
    sort(all(v),comp);
    ll ans=1,cnt=0;
    rep(i,0,k-1){
        if(v[i]==0) return cout<<0,0;
        cnt+=(v[i]<0);
        ans=ans*abs(v[i])%mod;
    }
    if(cnt&1){
        if(ok or k==n){
            ans=1;
            repb(i,n-1,0) if(k){
                ans=(ans*v[i]%mod+mod)%mod;
                k--;
            }
            return cout<<ans,0;
        }
        ll lp=-1,ln=1,fp=-1,fn=1;
        rep(i,0,n-1){
            if(i<k){
                if(v[i]>0) lp=v[i];
                else ln=v[i];
            }
            else{
                if(v[i]>=0 and fp==-1) fp=v[i];
                if(v[i]<0 and fn==1) fn=v[i];
            }
        }
        if(lp==-1 or fn==1) ans=ans*power(abs(ln),mod-2)%mod*fp%mod;
        else if(ln==1 or fp==-1) ans=ans*power(lp,mod-2)%mod*abs(fn)%mod;
        else if(fp*lp>fn*ln) ans=ans*power(abs(ln),mod-2)%mod*fp%mod;
        else ans=ans*power(lp,mod-2)%mod*abs(fn)%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5316
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}


using namespace std;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(int argc, char *argv[]) {
    ld result = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    result = (ld)a[0];
    For(i, 1, n){
        result = lcm(result, a[i]);
    }
    ll x = 0;
    rep(i, n){
        x += result / a[i];
    }
 
    result = result / x;
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	string s;
	cin >> s;

	string t;
	cin >> t;

	for (int i = 0; i < N; i++)
	{
		if (s.substr(i, N - i) == t.substr(0, N - i))
		{
			cout << 2 * N - (N - i);
			return 0;
		}
	}

	cout << 2 * N;

	return 0;
}

Measured memory_bytes: 256
//ketadp_2.cpp
//Sun Jul 28 17:12:21 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
	}

	ll dp[51][2];
	dp[0][0] = 0;
	dp[0][1] = -1;

	for (int i=1;i<51;i++){
		fill(dp[i],dp[i]+2,-1);
		ll onenum=0;
		ll mask = 1LL<<(50-i);
		for (int j=0;j<n;j++){
			if (a[j]&mask){
				onenum++;
			}
		}
		ll zeronum = (n-onenum)*mask;
		onenum = onenum*mask;
		ll digit = k&mask;

		if (dp[i-1][1]!=-1){
			dp[i][1] = max(dp[i][1],dp[i-1][1]+max(onenum,zeronum));
		}

		if (dp[i-1][0]!=-1){
			if (digit){
				dp[i][0] = max(dp[i][0],dp[i-1][0]+zeronum);
				dp[i][1] = max(dp[i][1],dp[i-1][0]+onenum);
			}else {
				dp[i][0] = max(dp[i][0],dp[i-1][0]+onenum);
			}
		}
//		cout << digit << " " << onenum << " " << dp[i][0] << " " << dp[i][1] << endl;
	}

	cout << max(dp[50][0],dp[50][1])<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1024
ABVW = [map(int, input().split()) for _ in range(2)]
AB, VW = [list(i) for i in zip(*ABVW)]
T = int(input())
 
x = abs(AB[0] - AB[1])
y = (VW[0] - VW[1])*T
if x <= y:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9028
#include <stdio.h>
#include <string.h>
int main()
{
    int i;
    char O[51],E[51];
    scanf("%s %s",O,E);
    for(i=0;i<strlen(E);i++) printf("%c%c",O[i],E[i]);
    if(strlen(O)>i) printf("%c\n",O[strlen(O)-1]);
    else puts("");
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int v[3];
    
    cin >> v[0] >> v[1] >> v[2];
    for (int i = 0; i < 3; i++) {
        for (int j = i+1; j < 3; j++) {
            if (v[i] > v[j]) {
                int aux = v[i];
                v[i] = v[j];
                v[j] = aux; 
            }
        }
    }

    cout << v[0] + v[1] << endl;


    return 0;
}

Measured memory_bytes: 256
from sys import exit

N = int(input())
A = [int(x) for x in input().split()]

m1 = 0
m2 = 0
m4 = 0

for a in A:
	if a%4==0:
		m4 += 1
	elif a%2==0:
		m2 += 1
	else:
		m1 += 1


m1 = m1 + (m2>0)
if m4>=m1-1:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 14252
/* the greatest common divisor of two natural numbers a and b */
#include <stdio.h>

int main() {
  int a;
  int b;
  int r;

  // input the number
  scanf("%d %d",&a, &b);

  while(b != 0){
    r = a % b;
    a = b;
    b = r;
  }
  // print the greatest common divisor
  printf("%d\n", a);
  
  return 0;
}



Measured memory_bytes: 2072
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i/60 - h *60);
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl;

 

   
   return 0;
}


Measured memory_bytes: 3100
//与えられた長方形の面積と周長を算出するプログラム
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println( (a * b) + " " + ( (a + b) * 2) );
    }
}


Measured memory_bytes: 26104
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	long l = read.to!long;
	long r = read.to!long;
	
	long ans;
	if(r / 2019 > l / 2019) ans = 0;
	else{
		ans = 2018;
		foreach(i; l .. r + 1) foreach(j; l .. i) ans = min(ans, i * j % 2019);
	}
	
	ans.writeln;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int i,n,c=0;
	char tm[101]={0},a[101]={0};
	scanf("%s",tm);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a);
		strncat(a,a,9);
		if(strstr(a,tm)!=NULL)c++;
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 1992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = numeric_limits<long long>::max();

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

    ll sum = 0;
    REP(i, 1, N+1){
        if (i %3 != 0 && i %5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
bool ac[N];
int cnt[N];
int n, m;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x = 0, y = 0;
    cin >> n >> m;
    rep(i, 1, m) {
        int id;
        string s;
        cin >> id >> s;
        if(!ac[id]) {
            if(s == "AC") {
                ac[id] = true;
                x++;
                y += cnt[id];
            } else {
                cnt[id]++;
            }
        }
    }
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;

  for(int i = 0; i < N; i++){
    cout << S.at(i) << T.at(i);
  }
  
  cout << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		int ans = 0;
		if(N % 111 == 0) {
			ans = N;
		}else {
			ans = (N / 111 + 1) * 111;
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 5e2+5;
int n,pos,val[N*N];
pair<int,int> q[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i) read(pos),val[pos]=i,q[i]={pos,i-1};
	sort(q+1,q+1+n);
	for(ri i=1;i<=n;++i){
		int rest=q[i].second,k=q[i].second+1;
		for(ri j=1;j<=q[i].first-1&&rest;++j){
			if(val[j]) continue;
			val[j]=k,--rest;
		}
		if(rest) return puts("No"),0;
	}
	reverse(q+1,q+1+n);
	for(ri i=1;i<=n;++i){
		int rest=n-q[i].second-1,k=q[i].second+1;
		for(ri j=n*n;j>=q[i].first+1&&rest;--j){
			if(val[j]) continue;
			val[j]=k,--rest;
		}
		if(rest) return puts("No"),0;
	}
	puts("Yes");
	for(ri i=1;i<=n*n;++i) printf("%d ",val[i]);
	return 0;
}

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

using namespace std;

int H, W, D;

long long int A[303][303];

int Q;

int L[100005];
int R[100005];

int I[100000], J[100000];

vector< vector<long long int> >  V;

int main(void) {

	cin >> H >> W >> D;
	long long int tmp;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> tmp;
			A[i][j] = tmp;
		}
	}

	cin >> Q;

	for (int i = 1; i <= Q; i++) {
		cin >> tmp; L[i] = tmp;
		cin >> tmp; R[i] = tmp;
	}

	//=====================================//


	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			I[A[i][j]] = i;
			J[A[i][j]] = j;
		}
	}


	//===================//



	V.resize(D);

	// V[i][j]  <--- i+jD
	for (int i = 0; i <= D - 1; i++) {
		V[i].push_back(0);
		for (int j = 1; i + j*D <= H*W; j++) {
			V[i].push_back(abs(I[i + j*D] - I[i + (j - 1)*D]) + abs(J[i + j*D] - J[i + (j - 1)*D]) + V[i][j - 1]);
		}
	}

	for (int k = 1; k <= Q; k++) {
		int i = L[k] % D;
		int j1 = (L[k] - i) / D;
		int j2 = (R[k] - i) / D;
		cout << V[i][j2] - V[i][j1] << endl;
	}

	//system("pause");
	return 0;
};

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vi a(n), b(m);
  vl A(n+1), B(m+1);
  rep(i, 0, n)
    cin >> a[i];
  rep(i, 0, m)
    cin >> b[i];
  A[0] = 0;
  B[0] = 0;
  rep(i, 0, n){
    A[i+1] = A[i]+a[i];
  }
  rep(i, 0, m){
    B[i+1] = B[i]+b[i];
  }
  
  ll mx = 0;
  int best = m;
  
  rep(i, 0, n+1){
    if(A[i] > k)
      break;
    for(int j = best; j >= 0; j--){
      if(A[i]+B[j] <= k){
        best = j;
        llchmax(mx, i+j);
        break;
      }
    }
  }
  
  cout << mx << endl;
  
  return 0;
  
}

Measured memory_bytes: 8012
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int x;
        for(int i = 1; (x = stdIn.nextInt()) != 0; i++){
            System.out.println("Case " + i + ": " + x);
        }
    }
}

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

int main (){
  vector<int> v(3);
  rep(i,3) cin>>v.at(i);
  sort(v.begin(),v.end());
  int sum = v.at(2) - v.at(1);
  v.at(0)+= sum;
  if ((v.at(2) - v.at(0)) % 2 == 0){
    sum += (v.at(2) - v.at(0)) / 2;
  }
  else{
    sum = sum + (v.at(2) - v.at(0)+1) / 2 + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var colCount = int.Parse(Console.ReadLine());
        var array1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var array2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int max = array1[0] + array2.Sum();
        int tmp = max;
        for (int col = 1; col < colCount; ++col)
        {
            tmp += array1[col] - array2[col - 1];
            max = Math.Max(max, tmp);
        }
        Console.WriteLine(max);
    }
}


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

int main(){
    ll x,y;
    cin>>x>>y;
    for(ll i=0;i<=x;i++){
        if(2*i+4*(x-i)==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

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

int main(){
    int n; cin >> n;
    vector<int> a(4);
    vector<string> b={"AC","WA","TLE","RE"};
    rep(i,n){
        string x;
        cin >> x;
        rep(j,4){
            if(x==b[j]){
                a[j]++;
            }
        }
    }
    rep(i,4){
        cout << b[i] << " x " << a[i] << endl;
    }
}

Measured memory_bytes: 3628