akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 300005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {out(x / 10);}
    putchar('0' + x % 10);
}
int N,tot,sta[MAXN],top;
int64 L,x[MAXN],t[MAXN],ans;
pii p[MAXN];
bool vis[MAXN];


void Solve() {
    read(N);read(L);
    for(int i = 1 ; i <= N ; ++i) read(x[i]);
    for(int i = 1 ; i <= N ; ++i) {
	read(t[i]);
	ans += t[i] / (2 * L);
	t[i] %= (2 * L);
	if(t[i] == 0) p[i] = mp(1,1);
	else p[i] = mp(t[i] > 2 * (L - x[i]),t[i] > 2 * x[i]);
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(p[i].fi == 1 && p[i].se == 1) {
	    vis[i] = 1;
	    if(t[i] != 0) ++ans;
	}
    }
    top = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(!vis[i]) {
	    if(p[i].fi == 1 && p[i].se == 0) {
		sta[++top] = i;
	    }
	    if(p[i].fi == 0 && p[i].se == 0) {
		if(top) {
		    vis[i] = 1;vis[sta[top]] = 1;
		    --top;++ans;
		}
	    }
	}
    }
    top = 0;
    for(int i = 1; i < N ; ++i) {
	if(!vis[i]) {
	    if(p[i].fi == 0 && p[i].se == 0) {
		sta[++top] = i;
	    }
	    if(p[i].fi == 0 && p[i].se == 1) {
		if(top) {
		    vis[i] = 1;vis[sta[top]] = 1;
		    --top;++ans;
		}
	    }
	}
    }
    top = 0;
    for(int i = 1 ; i < N ; ++i) {
	if(!vis[i]) {
	    if(p[i].fi == 0 && p[i].se == 0) {
		if(top) {
		    vis[i] = 1;vis[sta[top]] = 1;
		    --top;++ans;
		}
		else sta[++top] = i;
	    }
	}
    }
    if(!vis[N] && p[N].fi == 0) {
	for(int i = 1 ; i < N - 1 ; ++i) {
	    if(!vis[i] && p[i].se == 0) {
		vis[i] = 1;vis[N] = 1;++ans;break;
	    }
	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(!vis[i]) ++ans;
    }
    if(!vis[N]) {
	if(p[N].fi == 1 && p[N].se == 0) ++ans;
    }
    else ++ans;
    out(ans * 2 * L);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct times{
    int a;
    int b;
};

int main(){
	int n;
    vector<times> time;
    cin >> n;

    for(int i = 0; i < n; i++){
        times t;
        cin >> t.a >> t.b;
        time.push_back(t);
    }

    sort(time.begin(), time.end(), [](const times& x, const times& y) {return x.b < y.b;});

    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += time[i].a;
        if(sum > time[i].b){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
 
int main(){
    string s;
    cin >> s;

    int ans;
    if(s == "SUN") ans = 7;
    if(s == "SAT") ans = 1;
    if(s == "FRI") ans = 2;
    if(s == "THU") ans = 3;
    if(s == "WED") ans = 4;
    if(s == "TUE") ans = 5;
    if(s == "MON") ans = 6;

    

    cout << ans << endl;
}

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

int main() {
  char c[2][3];

  cin >> c[0][0] >> c[0][1] >> c[0][2];
  cin >> c[1][0] >> c[1][1] >> c[1][2];

  if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) {
    cout << "YES";
  } else {
    cout << "NO";
  }


  return 0;
}



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	c *= 2;
	if(x > y) {
		swap(x, y);
		swap(a, b);
	}
	int p1 = y * c;
	int p2 = x * c + (y - x) * b;
	int p3 = x * a + y * b;
	cout << min({p1, p2, p3}) << endl; 
	return 0;	
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

ll GCD(ll a, ll b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(GCD(b, a%b));
	}
}

ll LCM(ll a, ll b)
{
	return a * b / GCD(a, b);
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i, 0, n-1) {
		cin >> a[i];
	}
	vector<int> b = a;
	sort(ALL(a));
	int saidai = a[n - 1];
	FOR(i, 0, n - 1) {
		if (b[i] == saidai) {
			pv(a[n - 2]);
		}
		else {
			pv(saidai);
		}
	}
	return(0);
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
vector<pi> v[(int)1e5+5];
string ans[(int)1e5+5];
string solve(int i) {
    string t="";
    while (i>0) {
        t = (char)(i%10 + '0') + t;
        i /= 10;
    }
    while (t.size() <6) {
        t = '0' + t;
    }
    return t;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int p,y,n,m;
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        cin>>p>>y;
        v[p].push_back({y,i});
    }
    for (int i=1;i<=n;i++) {
        sort(v[i].begin(),v[i].end());
        string t=solve(i);
        for (int j=0;j<v[i].size();j++) {
            ans[v[i][j].second] = t + solve(j+1);
        }
    }
    for (int i=1;i<=m;i++) {
        cout<<ans[i]<<endl;
    }
}


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

int n;
void dfs(string A){
  if(A.size()==n){
    cout<<A<<endl;
    return;
  }
  int ma=0;
  rep(i,A.size()){
    ma=max(ma,A.at(i)-'a');
  }
  rep(i,ma+2){
    char c='a'+i;
    A=A+c;
    dfs(A);
    A.pop_back();
  }
}
int main() {
  cin >> n;
  dfs("a");
}



Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

// struct UnionFind
// {
//     vector<int> par;
//     vector<int> sizes;
//     vector<int> depth;
//     UnionFind(int n): par(n), sizes(n,1), depth(n,0){
//         for(int i = 0;i < n;i++){
//             par[i] = i;
//         }
//     }
    
//     int find(int x){
//         if(x == par[x]){
//             return x;
//         }
//         return par[x] = find(par[x]);
//     }

//     void unite(int x, int y){
//         x = find(x);
//         y = find(y);
//         //同じ集合に属している時
//         if(x==y) return;

//         if(sizes[x] < sizes[y]) swap(x,y);

//         depth[y] += sizes[x];

//         par[y] = x;
        
//         sizes[x] += sizes[y];
//     }    

//     bool same(int x, int y){
//         return find(x) == find(y);
//     }

//     //xが含まれている木の大きさ
//     int size(int x){
//         return sizes[find(x)];
//     }

//     int dep(int x){
//         return depth[x];
//     }

// };


int main(){
    int n,m; cin >> n >> m;
    vector<int> edges[n+1];
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

    int prev[n+1];
    for(int i = 0;i < n+1;i++) prev[i] = 0;
    queue<int> q;
    q.push(1);
    prev[1] = 1;
    while(!q.empty()){
        int c = q.front();
        q.pop();
        for(int i:edges[c]){
            if(prev[i]==0){
                prev[i] = c;
                q.push(i);
            }
        }
    }
    bool flag = true;
    for(int i = 2;i <= n;i++){
        if(prev[i]==0){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
        for(int i = 2;i <=n;i++){
            cout << prev[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }

    
}

Measured memory_bytes: 10356
#include <stdio.h>

#define N 500001

void maxHeapify(int *, int, int);
void buildMaxHeap(int *, int);

int main() {
  int h, i, data[N];

  scanf("%d", &h);

  for (i = 1; i <= h; i++) {
    scanf("%d", &data[i]);
  }

  buildMaxHeap(data, h);

  for (i = 1; i <= h; i++) {
    printf(" %d", data[i]);
  }
  printf("\n");

  return 0;
}


void maxHeapify(int *d, int i, int h) {
  int l, r, largest, temp;
  
  l = i * 2;
  r = i * 2 + 1;

  if (l <= h && d[l] > d[i]) largest = l;
  else largest = i;

  if (r <= h && d[r] > d[largest]) largest = r;

  if (largest != i) {
    temp = d[i];
    d[i] = d[largest];
    d[largest] = temp;
    maxHeapify(d, largest, h);
  }
}


void buildMaxHeap(int *d, int h) {
  int i ,n;

  n = h / 2;

  for (i = n; i > 0; i--) {
    maxHeapify(d, i, h);
  }
}



Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define INF 1000000000
using namespace std;
typedef pair<string,int>P;
typedef pair<P,int>Q;
vector<Q>vec;

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    int p;
    cin>>s>>p;
    vec.push_back(Q(P(s,INF-p),i+1));
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<n;i++){
    cout<<vec[i].second<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
array=[]
for i in sys.stdin:
    array.append(int(i))
m=max(array)
prime=[1]*(m+1)
prime[0]=prime[1]=0
for i in range(2,int(m**0.5)+1):
    if prime[i] ==1:
        for j in range(i*i,m+1,i):
            prime[j]=0
for i in range(len(array)):
    print(sum(prime[:array[i]+1]))

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

int main()
{
    int h,a,b,m=0;
    cin >> h >> a >> b;
    for(int i=a;i<=b;i++){
        if(h%i==0) m++;
    }
    cout << m << endl;
    return 0;
}



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

int main() {
    vector<int> a = {};

    for(int i(0); i < 3; ++i) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    int fiveCounter(0), sevenCounter(0);
    for(int i(0); i < a.size(); ++i) {
        if(a.at(i) == 5) fiveCounter += 1;
        if(a.at(i) == 7) sevenCounter += 1;
    }

    if(fiveCounter == 2 && sevenCounter ==1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    int t,ans;
    if(n%1000!=0){
        t=n/1000+1;
        ans=1000*t-n;
        cout<<ans<<endl;
    }
    else{
        cout<<0<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<math.h>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(i, a, b) for(int i = a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d, e;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
	V[a].push_back(temp);
}


//////////////////////////////////////////


void solve()
{
	cin >> a >> b >> c;
	if(c < a) cout << "NO";
	else
	{
		if(c > a + b) cout << "NO";
		else          cout << "YES";
	}
}
int main()
{
	int times = 1;
//	cin << times;
	loop(i, 1, times)
	{
		solve();
		printf("\n");
	}
	return 0;
}




Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    B.reverse()
    # ep(A)
    # ep(B)

    ng = []
    ngi = set()
    for i, (a, b) in enumerate(zip(A, B)):
        if a == b:
            ng.append((i, a, b))


    for i in range(N):
        if not ng:
            break
        if i != ng[-1][0] and B[i] != ng[-1][2] and A[i] != ng[-1][1]:
            j, a, b = ng.pop()
            B[i], B[j] = B[j], B[i]



    if all(map(lambda x: x[0] != x[1], zip(A, B))):
        print('Yes')
        print(*B)
    else:
        print('No')


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    (slv(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 129640
n = int(input())
if n < 3 or format(n - 1, "b").count("0") == 0:
    print("No")
    exit()
else:
    print("Yes")
for i in range(1, 3):
    print(i, i + 1)
    print(i + n, i + 1 + n)
print(1, 3 + n)

for i in range(5, n + 1, 2):
    print(1, i - 1)
    print(i - 1, i)
    print(1, i + n)
    print(i + n, i - 1 + n)

if not n % 2:
    a = 1 << (len(format(n + 1, "b")) - 1)
    b = (n + 1) ^ a
    a = a + n if a % 2 else a
    b = b + n if b % 2 else b
    print(a, n)
    print(b, 2 * n)


Measured memory_bytes: 5464
#include <iostream>

using namespace std;

typedef long long lli;

lli data[21], n;

main(){
  data[0] = 1LL;
  for(int i=1;i<21;i++) data[i] = data[i-1] * 3LL;
  cin >> n;
  for(int i=0;i<21;i++){
    if(n <= data[i]){
      cout << i << endl;
      break;
    }
  }
}

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

int main() {
  int N, K, X, Y, ans;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  ans = X*min(N,K) + Y*max(N-K,0);
  cout << ans << endl;
}


Measured memory_bytes: 3552
import math
import collections
import sys
 
#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
 
AS=LI()
AS=sorted(AS)
ans=AS[2]-AS[0]
print(ans)

Measured memory_bytes: 3316
//失敗するからこそそこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;
 
#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n, m;cin >> n >> m;
	priority_queue<int> pq;
	for(int i = 0; i < n; i++){
		int a;cin >> a;
		pq.push(a);
	}
	for(int i = 0; i < m; i++){
		auto u = pq.top();
		pq.pop();
		u /= 2;
		pq.push(u);
	}
	long long ans = 0;
	while(!pq.empty()){
		ans += (1LL * pq.top());
		pq.pop();
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	public static boolean solve(long r, long g, long b, long w) {
		 if((r%2+g%2+b%2+w%2)>1)return false;
		 else return true;
	}
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		String str= s.next();
		int n = str.length(); 
        int sum = 0; 
        for (int i=0; i<n; i++) 
            sum += (str.charAt(i)-'0');  
		if(sum%9==0)System.out.println("Yes");
		else System.out.println("No");
	}
	
}


Measured memory_bytes: 36060
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef complex < double > P;
typedef pair < double, int > Pi;
typedef pair < P, P >      L;
typedef pair < P, P >      Ls;
const double EPS = 1e-10;
const double INF = 1e8;
double cross( P a,  P b){ //OK
  return imag( conj(a) * b);
}
double dot( P a, P b){ //OK
  return real( conj(a) * b);
}
int ccw( P a, P b, P c){  //OK
  b -= a, c -= a;
  if(cross(b,c) > 0)    return +1;  // a → b で 反時計方向におれて c
  if(cross(b,c) < 0)    return -1; // a → b で 時計方向におれて c
  if(dot(b,c) < 0)      return +2;  // c -- a -- b
  if(norm(b) < norm(c)) return -2; // a -- b -- c
                        return 0;  // a -- c -- b
}
P projection( L l, P p) { //OK
  double t = dot( p - l.fr, l.fr - l.sc) / norm( l.fr - l.sc);
  return l.fr + t * ( l.fr - l.sc);
}
bool intersect( L a, P p){ //OK
   return abs( a.fr - p) + abs( a.sc - p) - abs( a.fr - a.sc) < EPS;
}
bool intersect( L a, L b){ //OK
  return ccw( a.fr, a.sc, b.fr) * ccw( a.fr, a.sc, b.sc) <= 0 &&
    ccw( b.fr, b.sc, a.fr) * ccw( b.fr, b.sc, a.sc) <= 0;
}
double distance( L s, P p){ //OK
  P r = projection(s, p);
  if ( intersect( s, r)) return abs( r - p);
  return min( abs( s.fr - p), abs( s.sc - p));
}
double distancion( L a, L b){ //OK
  if(intersect( a, b)) return 0;
  return min( min( distance( a, b.fr), distance( a, b.sc)),
              min( distance( b, a.fr), distance( b, a.sc)));
}
double Degree_to_Radian(double n){
  return n * M_PI / 180.0;
}
double Radian_to_Degree(double n){
  return n * 180.0 / M_PI;
}
/* ここまでテンプレート */
double info[100][100];
bool used[100];
int n, m, l;
L stars[100][5];
int table[][5] = {{0,0,1,1,2},{2,3,3,4,4}};
P hosi[5];
void add( double x, double y, double a, double r, int z){
  for(int i = 0 ; i < 5 ; i++ ){
    double theta = Degree_to_Radian(a + 72 * i);
    double nx = r * sin( theta ), ny = r * cos( theta );
    hosi[i] = P( x - nx, y + ny);
  }
  for(int i = 0 ; i < 5 ; i++ ){
    stars[z][i] = L( hosi[table[0][i]], hosi[table[1][i]]);
  }
}
double Dijkstra(){
  priority_queue< Pi , vector< Pi > , greater< Pi > > que;
  fill_n( used, 100, false);
  que.push( Pi( 0.0, m));
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.sc == l) return p.fr;
    if(used[p.sc]++) continue;
    for(int i = 0 ; i < n ; i++ )
      que.push( Pi( info[p.sc][i] + p.fr, i));
  }
}
int main(){ //vectorが重いかも
  while(scanf("%d%d%d", &n, &m, &l), n|m|l){
    m--, l--;
    for(int i = 0 ; i < n ; i++ ){
      double x, y, a, r;
      scanf("%lf%lf%lf%lf", &x, &y, &a, &r);
      add( x, y, a, r, i);
    }
    for(int i = 0 ; i < n ; i++ ){
      for(int j = i + 1 ; j < n ; j++ ){
        double dist = INF;
        for(int a = 0 ; a < 5 ; a++ ){
          for(int b = 0 ; b < 5 ; b++ ){
            dist = min( dist, distancion( stars[i][a], stars[j][b]));
          }
        }
        info[i][j] = info[j][i] = dist;
      }
    }
    printf("%.10f\n", Dijkstra());
  }
}

Measured memory_bytes: 1608
H = []
W = []
for _ in range(300):
  _h, _w = map(int, input().split())
  if _h == 0 and _w == 0:
    break
  else:
    H.append(_h)
    W.append(_w)

for i in range(len(H)):
    for j in range(H[i]):
        dash = ""
        for k in range(W[i]):
            if j == 0 or j == H[i]-1 or k == 0 or k == W[i]-1:
                dash = dash + '#'
            else:
                dash = dash + "."
        print(dash)
    print('')



Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
string s;
int solve1(){
	int a=0;
	rep(i,s.size()){
		int t=s[i]-'0';
		while(!(i==s.size()-1||s[i+1]=='+')){
			i+=2;
			t*=s[i]-'0';
		}
		i++;
		a+=t;
	}
	return a;
}
int solve2(){
	int a=s[0]-'0';
	loop(i,1,s.size()){
		if(s[i++]=='+')a+=s[i]-'0';
		else a*=s[i]-'0';
	}
	return a;
}
int main(){
	int a;
	cin>>s>>a;
	bool h1=false,h2=false;
	if(solve1()==a)h1=true;
	if(solve2()==a)h2=true;
	if(h1+h2==2)cout<<"U"<<endl;
	else if(h1)cout<<"M"<<endl;
	else if(h2)cout<<"L"<<endl;
	else cout<<"I"<<endl;
}

Measured memory_bytes: 3204
(H,N) = map(int,input().split())
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])


dp = [10**10 for i in range(H+10**4+1)]
dp[0] = 0

for i in range(H+10**4+1):
    for j in range(N):
        if l[j][0] <= i:
            dp[i] = min(dp[i],dp[i-l[j][0]]+l[j][1])

ans = dp[H]
for i in range(1,10**4+1):
    ans = min(ans,dp[H+i])

print(ans)

Measured memory_bytes: 68628
N = int(input())
W = list(map(int, input().split()))
sum_W = sum(W)

s1 = 0

sub = sum_W

for i in range(N):
  s1 += W[i]
  s2 = sum_W -s1
  sub = min(sub, abs(s2-s1))

print(sub)
  

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static String call(int n) {
		StringBuilder answer = new StringBuilder();
		for (int i = 3; i <= n; i++) {
			if (i % 3 == 0) {
				answer.append(" ").append(String.valueOf(i));
			} else {
				int tmp = i;
				while (tmp != 0) {
					if (tmp % 10 == 3) {
						answer.append(" ").append(String.valueOf(i));
						break;
					}
					tmp /= 10;
				}
			}
		}
		return answer.toString();
	}
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		int n = Integer.parseInt((new BufferedReader(new InputStreamReader(System.in))).readLine());
		System.out.println(call(n));
	}
}

Measured memory_bytes: 21120
<?php
fscanf(STDIN,"%d %d %d",$a,$b,$c);
  if((1 <= $a)&&(9 >= $a)){
    if((1 <= $b)&&(9 >= $b)){
      $c = $a * $b;
      echo $c;
    }else{
      $d = -1;
      echo $d;
    }
  }else{
      $e = -1;
      echo $e;
    }
    


?>


Measured memory_bytes: 3700
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.nextString().toCharArray();
            int sum1 = 0;
            for (char ss : s) sum1 += ss - '0';
            int sum = s[0] - '0' - 1;
            ArrayUtils.fill(s, '9');
            sum = Math.max(0, sum);
            sum += (s.length - 1) * 9;
            out.println(Math.max(sum1, sum));
        }

    }

    static class ArrayUtils {
        public static void fill(char[] array, char value) {
            Arrays.fill(array, value);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,ans;
int main()
{
    cin>>a>>b>>c>>n;
    for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
	      	if(n-i*500-j*100>=0 && n-i*500-j*100<=c*50) ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <bitset>
using namespace std;

int pownum;

int main(){

    int S;

    cin >>S;

    uint64_t DpN[2001] = {};
    uint64_t sumDpN[2001] ={};


    DpN[0]=0;
    sumDpN[0]=0;
    DpN[1]=0;
    sumDpN[1]=0;
    DpN[2]=0;
    sumDpN[2]=0;

    for(int i=3;i<=S;++i){
        DpN[i] = 1;
    }

    for(int i=3;i<=S;++i){
        DpN[i] += sumDpN[i-3];
        sumDpN[i] = sumDpN[i-1] + DpN[i]; 
        sumDpN[i] %= (int)( 1 * pow(10,9) + 7);
    }

    DpN[S] %= (int)( 1 * pow(10,9) + 7);
    cout<< DpN[S] << endl;

}



Measured memory_bytes: 3580
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LS()
    if a == b:
        print("H")
    else:
        print("D")
    return

#B
def B():
    w, a, b = LI()
    a, b = min(a, b), max(a, b)
    if w + a >= b:
        print(0)
        return
    print(b-a-w)
    return

#C
def C():
    n = II()
    x = 0
    for i in range(1, 10 ** 5):
        x += i
        if n <= x:
            print(i)
            return
    return

#D
def D():
    n, k = LI()
    a = LI()
    a.sort()
    ok = n
    ng = -1
    def f(x):
        dp = [False] * (k)
        dp[0] = True
        kx = k - a[x]
        for i in range(n):
            if i == x: continue
            ai = a[i]
            for j in range(k - 1, ai - 1, -1):
                if dp[j - ai]:
                    dp[j] = True
                    if kx <= j:
                        return True
        for j in range(max(0, k - a[x]), k):
            if dp[j]:
                return True
        return False
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if f(mid):
            ok = mid
        else:
            ng = mid
    print(ng + 1)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40688
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;

int gcd(int a, int b){
	if(a<b) swap(a,b);
	while(b){
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

int main(){
	long long a,b,c,d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	long long g = c / gcd(c,d) * d;
	long long x = b/c-(a-1)/c + b/d-(a-1)/d - b/g + (a-1)/g;
	printf("%lld\n", b-a+1-x);
	return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << t * int(ceil(n * 1.0 / x)) << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, M: int, x: "List[int]", y: "List[int]", z: "List[int]"):
    value = [[x[i]*cx + y[i]*cy + z[i]*cz for i in range(N)] for cx, cy, cz in itertools.product([1, -1], repeat=3)]
    res = 0
    for v in value:
        total = sum(sorted(v, reverse=True)[:M])
        if total > res:
            res = total
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    z = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        z[i] = int(next(tokens))
    solve(N, M, x, y, z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
n = int(input())
a = [int(i) for i in input().split()]
flag = True
cnt = 0
while flag:
    flag = False
    for i in range(1,n)[::-1]:
        if a[i] < a[i-1]:
            a[i], a[i-1] = a[i-1], a[i]
            cnt += 1
            flag = True
print(' '.join([str(i) for i in a]))
print(cnt)



Measured memory_bytes: 5604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
         
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			//x, y ,z は100以下全通り試す
			var count = Enumerable.Repeat(0, 1000000).ToArray();

			for (int x = 1; x <= 100; x++) {

				for (int y = 1; y <=100 ; y++) {

					for (int z = 1; z <= 100; z++) {

						var fn = x * x + y * y + z* z + x * y + y * z + z * x;
						count[fn]++;

					}

				}
			}

			for (int i = 1; i <= N; i++) {
				Console.WriteLine(count[i]);
			}

			

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

int dp[200100][5];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N;
    cin >> N;
    vi a(N);
    rep(i, 0, N) cin >> a[i];

    rep(i, 0, N + 100) rep(j, 0, 4) dp[i][j] = -inf;
    dp[0][0] = 0;

    rep(i, 0, N) rep(j, 0, 3) {
        chmax(dp[i + 1][j + 1], dp[i][j]);
        int now = dp[i][j];
        if ((i + j) % 2 == 0) now += a[i];
        chmax(dp[i + 1][j], now);
    }

    cout << dp[N][1 + N % 2] << endl;
    return 0;
}


Measured memory_bytes: 12680
(* unihernandez22
 * https://atcoder.jp/contests/abc162/tasks/abc162_b
 * implementation
 * *)

Printf.printf "%d\n" @@
Scanf.scanf "%d\n" @@ fun n ->
    let ans = ref 0 in
    for i = 1 to n do
        if (i mod 3 != 0) && (i mod 5 != 0) then
            ans := !ans + i;
    done;
    !ans


Measured memory_bytes: 3736
# python template for atcoder1
from itertools import accumulate
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)
ansL = -1
ansR = -1

if N == 2:
    if S[0] == S[1]:
        ansL = 1
        ansR = 2

else:
    for l in range(N-2):
        if S[l] == S[l+1]:
            ansL = l+1
            ansR = l+2
            break
        elif S[l] == S[l+2]:
            ansL = l+1
            ansR = l+3
            break
print(ansL, ansR)


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

int main() {
  long N,P;
  cin >> N >> P;
  long a=pow(P,1.0/N);
  a=a+1;
  for(long i=a;i>0;i--){
    long b=pow(i,N);
    if(P%b==0){
      cout << i;
      break;
    }
  }
}

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


int main()
{
    std::cout<<std::fixed<<std::setprecision(10);
    
    int A, B, C;
    cin >> A >> B >> C;
    
    if ((A == B && A != C)
        || (B == C && B != A)
        || (C == A && C != B)) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    
    return 0;
}

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

int n;
int *A;

void maxHeapify(int);
void build();
void swap(int *, int *);

int main(){
  int i;

  scanf("%d",&n);

  A = (int *)malloc((n+1) * sizeof(int));

  for(i=1; i<=n; i++)
    scanf("%d",&A[i]);

  build();

  for(i=1; i<=n; i++)
    printf(" %d",A[i]);

  printf("\n");

  free(A);
  return 0;
}

void maxHeapify(int i){
  int l = 2*i;
  int r = 2*i + 1;
  int largest;

  if(l <= n && A[l] > A[i])
    largest = l;

  else
    largest = i;

  if(r <= n && A[r] > A[largest])
    largest = r;

  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(largest);
  }
}

void build(){
  int i;

  for(i=n/2; i>0; i--)
    maxHeapify(i);
}

void swap(int *a, int *b){
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}



Measured memory_bytes: 3348
#include <iostream>
#include<cctype>
using namespace std;
int main(){
	char mozi;
	int cou[30] = {},i=0;
	while (cin >> mozi){
		if (islower(mozi)){ cou[mozi - 'a']++; }
		if (isupper(mozi)){ cou[mozi - 'A']++; }
		i++;
	}
	for (i = 0; i < 26; i++){
		char last = 0;
		last = 'a' + i;
		cout << last << " : " << cou[i] << endl;
	}
}

Measured memory_bytes: 3056
#include <stdio.h>
int main()
{
  int count=0,x,tray[10000];
  for(x=0;x<10000;x++)
  {
    count++;
    scanf("%d",&tray[x]);
    if(tray[x]==0)break;
    else printf("Case %d: %d\n",count,tray[x]);
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#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 A; cin >> A;
    lint B; cin >> B;
    lint C; cin >> C;
    lint X; cin >> X;
    lint Y; cin >> Y;

    lint res = 0;
    
    if(A+B < C*2) {
      res = A*X + B*Y;
    } else {
      if(X==Y) {
        res = C*2*X;
      }
      else if (X > Y) {
        res = C*2*Y;
        res += min(C*2*(X-Y), A*(X-Y));
      }
      else {
        res = C*2*X;
        res += min(C*2*(Y-X), B*(Y-X));
      }
    }

    
    
    cout << res << "\n";

    return 0;
}


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

int n,m;
map<int,int> a; 

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		if(a[x]) a[x]--;
		else{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
# dpに最大桁数を持たせる
N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed

# dp[i]: マッチi本数で作れる最大の桁数(int)
dp = [-float('inf')]*(N+1)
dp[0] = 0
for i in range(N+1):
    nxt = dp[i]
    for aj in A:
        if i-f[aj]<0: continue
        nxt = max(nxt, 
                  dp[i-f[aj]] + 1)
    dp[i] = nxt
    #print(dp)
#print(dp[N])
keta = dp[N]
ans = ""
matchs = N
# 上位の桁から貪欲に
while keta>0:
    for aj in A:
        if matchs-f[aj] < 0: continue
        if dp[matchs-f[aj]] == keta-1:
            ans += str(aj)
            matchs -= f[aj]
            keta -= 1
            break
print(ans)


Measured memory_bytes: 3356
n,m=map(int,input().split())
l=[0]*n
s=set([])
for i in range(m):
  p,q=map(str,input().split())
  if int(p) in s:
    continue
  elif q=='AC':
    s.add(int(p))
  else:
    l[(int(p))-1]+=1
s_l=list(s)
an=len(s_l)
c=0
for i in range(an):
  c+=l[s_l[i]-1]
print(an,c)

Measured memory_bytes: 12780
#include<bits/stdc++.h>
#define maxn 55
#define ll long long
using namespace std;
ll a[maxn],b[maxn],n,MAX;
ll dis[maxn][maxn],dist[maxn][maxn];
ll ans;
ll read()
{
	ll x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
bool check(ll x)
{
	memset(dis,0,sizeof(dis));
	for(int i=0;i<=MAX;i++)for(int j=0;j<=MAX;j++)if(dist[i][j])dis[i][j]=1;
	for(int j=0;j<=MAX;j++)
		for(int i=1;i<=x;i++)dis[j][j%i]=1;
	for(int k=0;k<=MAX;k++)
		for(int i=0;i<=MAX;i++)
			for(int j=0;j<=MAX;j++)
				if(dis[i][k]&&dis[k][j])dis[i][j]=1;
	for(int i=1;i<=n;i++)if(!dis[a[i]][b[i]])return 0;
	return 1;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),MAX=max(a[i],MAX);
	for(int i=1;i<=n;i++)b[i]=read();
	ll tmp=MAX;
	for(int i=0;i<=MAX;i++)dist[i][i]=1;
	while(tmp)
	{
		if(!check(tmp-1))
		{
			ans+=1ll<<tmp;
			for(int i=0;i<=MAX;i++)dist[i][i%tmp]=1;
		}
		tmp--; 
	}
	if(check(0))printf("%lld",ans);else printf("-1");
	return 0;	
}

Measured memory_bytes: 256
#if 0
????????£????????????15m
queue??¨????????§extract??????front????????????????????¨?????£??????????????§?°?????????£??????
cppreference??????????§£?¶?(http://en.cppreference.com/w/cpp/container/priority_queue)???
#endif

#include <queue>
#include <string>
#include <iostream>
using namespace std;

int main(){
	string cmd;
	int n;
	priority_queue<int> Q;
	while(cin>>cmd &&cmd!="end"){ //command
		if(cmd=="insert"){
			cin>>n;
			Q.push(n);
		}
		else if(cmd=="extract"){
			int M=Q.top();
			Q.pop();
			cout << M <<endl;
		}
	}
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum;

char s[N],c[N];

int main()
{
	fast;
	cin>>n>>m;
	ll x=1;
	while(x<m)
	{
		sum++;
		x+=(n-1);

	}
	// cout<<x<<endl;
	cout<<sum;


}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	numbers := make([]int, N)
	for i := 1; i <= N; i++ {
		numbers[i-1] = i
	}
	p := make([]string, N)
	q := make([]string, N)
	for i := 0; i < N; i++ {
		var pi int
		fmt.Scan(&pi)
		p[i] = fmt.Sprint(pi)
	}
	for i := 0; i < N; i++ {
		var pi int
		fmt.Scan(&pi)
		q[i] = fmt.Sprint(pi)
	}
	ps, qs := strings.Join(p, ""), strings.Join(q, "")
	dfs([]string{}, numbers)

	var a, b int
	for i, v := range an {
		if ps == v {
			a = i + 1
		}
		if qs == v {
			b = i + 1
		}
	}
	r := a - b
	if r < 0 {
		r = -r
	}
	fmt.Println(r)

}

var an = []string{}

func dfs(r []string, numbers []int) {
	if len(numbers) == 0 {
		an = append(an, strings.Join(r, ""))
		return
	}
	for i := 0; i < len(numbers); i++ {
		r := append(append([]string{}, r...), fmt.Sprint(numbers[i]))
		numbers := append(append([]int{}, numbers[:i]...), numbers[i+1:]...)
		dfs(r, numbers)
	}
}


Measured memory_bytes: 6272
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    
    int count =(B-1)/(A-1);
    if((B-1)%(A-1)!=0){
      count++;
    }
  
    System.out.println(count);
  
  }
 
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	  	int a,b,c;
     	cin>>a;
     	c = 0;
     	for (int i = 1; i <= a; ++i)
     	{
     		b = 0;
     		for(int j = i; j > 0; j = j/10)
     			b++;
     		if(b%2==1)
     			c++;
     	}
     	cout<<c<<endl;
     	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int A,B;
	int a;
	scanf("%d %d",&A,&B);
	if(A<=5)a=0;
	else if(A>=6&&A<=12)a=(int)(B/2);
	else a=B;
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 128
// Rafael Saddatimov
#include <bits/stdc++.h>
#define MAX 305
using namespace std;

int a[MAX][MAX], no[MAX][MAX];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            scanf("%d", &a[i][j]);
        }
    }
    int ok = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                if (a[i][k] + a[k][j] < a[i][j]) {
                    ok = 0; break;
                }
                if (k != i && k != j && a[i][k] + a[k][j] == a[i][j]) {
                    no[i][j] = 1;
                }
            }
        }
    }
    if (ok == 0) {
        return 0 * puts("-1");
    }
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            res += !no[i][j] * a[i][j];
        }
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 1024
n,m = [int(i) for i in input().split()]

A = [[int(i) for i in input().split()] for j in range(n)]
B = [int(input()) for i in range(m)]

for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j]*B[j]
    print(c)


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
ll x,k,d,posx,need,rest,temp;
int main() {
	scanf("%lld%lld%lld",&x,&k,&d);
	posx=abs(x);
	need=posx/d;
	rest=posx%d;
	if(need>k){
		cout<<posx-k*d;
		return 0; 
	}else{
		need=k-need;
	}
	temp=abs(rest-d);
	if(rest==0){
		if(need&1){//奇数
			printf("%lld",d);
		} else{
			printf("0");
		}
	}else {
		if(need&1){//奇数
			printf("%lld",temp);
		}else{
			printf("%lld",rest);
		}
	}
	
} 

Measured memory_bytes: 3740