akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

int main(){
    ll d, g;
    cin >> d >> g;
    vector<ll> p, c;
    p.resize(d), c.resize(d);
    for(ll i = 0; i < d; ++i) cin >> p[i] >> c[i];
    
    ll res = 1 << 29;
    for(ll bit = 0; bit < (1 << d); ++bit){
        ll n = 0;
        ll sum = 0;
        for(ll i = 0; i < d; ++i){
            if(bit & (1 << i)) sum += c[i] + p[i] * 100 * (i + 1), n += p[i];
        }
        if(sum >= g) res = min(res, n);
        else{
            for(ll i = d - 1; i >= 0; --i){
                if(bit & (1 << i)) continue;
                for(ll j = 0; j < p[i]; j++){
                    if(sum >= g) break;
                    sum += 100 * (i + 1);
                    ++n;
                }
            } 
            res = min(res, n);
        }
    }
    cout << res << endl;
    return 0;
}

                    


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define PB push_back;
#define F first;
#define S second;
#define REP(i,a,b) for (int i=a;i<b;i++)
#define all(x) x.begin(), x.end()
#define all_(x) x.rbegin(), x.rend()
#define mp make_pair



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s,w;
  cin>>s>>w;
  if (w>=s) cout<<"unsafe";
  else cout<<"safe";
  cout<<'\n';


  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int dp[8001][8001];

signed main() {
  string s;
  cin >> s;
  vector<int> ak, ao;
  rep(i, 0, s.length()) {
    if(s[i] == '0') {
      ak.pb(i);
      ak.pb(i);
    }else if(s[i] == '1') {
      ak.pb(i);
      ao.pb(i);
    }else {
      ao.pb(i);
      ao.pb(i);
    }
  }

  sort(ak.begin(), ak.end());
  sort(ao.begin(), ao.end());
  dp[0][0] = 1;
  rep(i, 0, ak.size() + 1) {
    rep(j, 0, ao.size() + 1) {
      if(i < ak.size() && i + j >= ak[i]) dp[i + 1][j] += dp[i][j], dp[i + 1][j] %= 998244353;
      if(j < ao.size() && i + j >= ao[j]) dp[i][j + 1] += dp[i][j], dp[i][j + 1] %= 998244353;
      else break;
    }
  }
  cout << dp[ak.size()][ao.size()] << endl;
}


Measured memory_bytes: 248448
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		double[] p = new double[N];
		for( int i=0; i<N; i++ ){
			p[i] = sc.nextDouble();
			p[i] = (p[i]+1)/2;
		}
		int count = 0;
		double[] ans = new double[N-K+1];
		for( int i=0; i<K; i++ ){
			ans[0] += p[i];
		}
		for( int i=K; i<N; i++ ){
			count++;
			ans[count] = ans[count-1]+p[i]-p[i-K];
		}
		Arrays.sort(ans);
		System.out.println(ans[N-K]);     
	}
}


Measured memory_bytes: 159412
def main():
    N, T = map(int, input().split())

    t_list = [int(t) for t in input().split()]
    sumv = T
    ti_1 = 0
    for ti in t_list[1:]:
        if ti_1 + T <= ti:
            sumv += T
        else:
            sumv += ti-ti_1
        ti_1 = ti
    print(sumv)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25200
n=int(input())
a=list(map(int,input().split()))
ans=list()
i=0
while i < n :
    ans.append(0)
    i=i+1

i=0
j=0
while i < n:
    j=int(a[i])
    ans[j-1]=i+1
    i=i+1
i=0
while i < n:
    print(ans[i],end=" ")
    i=i+1

Measured memory_bytes: 14004
n = int(input())
a,b,c=[],[],[]
for i in range(n):
    a_b = list(map(int, input().split()))
    a.append(a_b[0])
    b.append(a_b[1])
    c.append(a_b[0]+a_b[1])
d = sorted(enumerate(c), key=lambda x: x[1], reverse=True)
taka,aoki=0,0
for i in range(n):
    if i % 2 ==0:
        taka = taka + a[d[i][0]]
    else:
        aoki = aoki + b[d[i][0]]
print(taka-aoki)


Measured memory_bytes: 27148
K = int(input())

if K % 2 == 0:
  print(-1)
  exit()

if K % 7 == 0:
  K //= 7
k = 1
cnt = 1
for i in range(10 ** 8):
  if k % K == 0:
    break
  k = (k * 10 + 1) % K
  cnt += 1
else:
  print(-1)
  exit()

print(cnt)


Measured memory_bytes: 63252
N=gets.to_i
a=gets.split.map(&:to_i)
cnt_minus = 0
N.times do |i|
  cnt_minus += 1 if a[i] < 0
end
if cnt_minus.even?
  puts a.map(&:abs).inject(&:+)
else
  a_min = a.map(&:abs).min
  puts a.map(&:abs).inject(&:+) - 2*a_min
end

Measured memory_bytes: 10116
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    A = map(int, input().split())
    for a in A: 
        if a % 2 == 0:
            if not (a % 3 == 0 or a % 5 == 0):
                return "DENIED"
    return "APPROVED"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 5500
S = gets.chomp.to_i

v0 = [0, 0]
# v1 = (x1, y1)
# v2 = (x2, y2)
# S = x1*y2 - x2*y1
# S = 10**9 * y2 - x2

x1 = 10**9
y1 = 1
v1 = [x1, y1]

y2 = (S + 10**9 - 1) / (10 ** 9)
x2 = 10 ** 9 * y2 - S
v2 = [x2, y2]

# p x1*y2 - x2*y1

print (v0 + v1 + v2).join(" ")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て

int		main(void)
{
	int N;
	cin >> N;
	vpii S(N);
	for (int i = 0; i < N; i++)
	{
		cin >> S[i].first;
		S[i].second = i+1;
	}
	sort(all(S));
	for (int i = 0; i < N; i++)
	{
		cout << S[i].second;
		if (i != N-1)
			cout << " ";
	}
	cout << endl;
}



Measured memory_bytes: 1664
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 110;

int n, x;

int rowno(int a, int b)
{
	if (a == b)
		return 2*a;
	if (a < b) {
		if (b%a == 0)
			return 2*b;
		return (2*(b/a))*a + rowno(a, b%a);
	}
	if (a%b == 0)
		return a+(2*(a/b - 1)+1)*b;
	return a+(2*(a/b)*b)+a%b+rowno(a%b, b-a%b);
}

int licz(int n, int x)
{
	if (n-x == x)
		return 3*x;
	if (n-x > x)
		return n+x+rowno(x, n-2*x);
	if (x%(n-x) == 0)
		return 3*x;
	return n+(x/(n-x))*(n-x)*2+x%(n-x)+rowno(x%(n-x), n-x-(x%(n-x)));
}

signed main()
{
    init_ios();
    cin >> n >> x;
    cout<<licz(n, x)<<"\n";
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> S(N);
    for(int i = 0; i < K; ++i) {
        int d; cin >> d;
        for(int j = 0; j < d; ++j) {
            int a; cin >> a; a--;
            S[a]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; ++i) if(S[i] == 0) ans++;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<algorithm>
#include<sstream>
#include<bitset>
#define scand(a) scanf("%d",&a)
#define scandd(a,b) scanf("%d%d",&a,&b)
#define scanddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x&-x)
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fLL;
const int maxn=1e4+5;
const ll mod=1e9+7;

int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	int x;
	scand(x);
	if(x>=30)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll int MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    int a[200];
    rep(i,n){
        cin>>a[i];
    }
    int t=a[0],s=0,pos=0;
    int ans=0;
    while(pos<n){
        while(a[pos]==t){
            s++;
            pos++;
        }
        ans+=s/2;
        t=a[pos];
        s=0;
    }
    cout<<ans;
    return 0;
}



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

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key ) {
    cur = cur->next;
  }
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (int i = 0; i < n; i++) {
    scanf("%s%d", com, &key);

    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      size++;
    } else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) {
          deleteFirst();
        } else if ( com[6] == 'L' ) {
          deleteLast();
        }
      } else {
          deleteKey(key);
          nd++;
      }
      size--;
    }

  }

  printList();
}


Measured memory_bytes: 34460
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

long long calc(const vector<long long> &A, long long b)
{
	const int N = A.size();
	long long s = 0;
	for (int i = 0; i < N; ++i) {
		s += abs(A[i] - (b + i + 1));
	}
	return s;
}

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);

	for (auto &x : A) {
		cin >> x;
	}

	long long lo = -2000000000LL;
	long long hi = +2000000000LL;

	while (lo + 2 < hi) {
		long long x1 = lo + (hi - lo) * 1 / 3;
		long long x2 = lo + (hi - lo) * 2 / 3;
		long long y1 = calc(A, x1);
		long long y2 = calc(A, x2);

		if (y1 > y2) {
			lo = x1;
		}
		else {
			hi = x2;
		}
	}

	long long ans = numeric_limits<long long>::max();
	for (long long b = lo; b <= hi; ++b) {
		ans = min(ans, calc(A, b));
	}
	cout << ans << endl;
}


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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count=0;
    rep(i,n-2) {
        if ((s[i]=='A') && (s[i+1]=='B') && (s[i+2]=='C')){
            count += 1;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3620
/***************************************************
 * Problem Name : F - LCS.cpp
 * Problem Link : https://atcoder.jp/contests/dp/tasks/dp_f
 * OJ           : atCoder
 * Verdict      : Trying
 * Date         : 2019-01-26
 * Problem Type : easy dp
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FileRead freopen ("/home/saikat/Desktop/logN/input.txt", "r", stdin);
#define FileWrite freopen ("/home/saikat/Desktop/logN/output.txt", "w", stdout);
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 3005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
string A, B, ans = "";
int dp[MAX][MAX];
int LCS (int i, int j) {
    if (i == (int) A.size() || j == (int) B.size() ) {
        return 0;
    }

    if (dp[i][j] != -1) return dp[i][j];

    int cnt = 0;

    if (A[i] == B[j]) {
        cnt = 1 + LCS (i + 1, j + 1);

    } else {
        int val1 = LCS (i + 1, j);
        int val2 = LCS (i, j + 1);
        cnt =  max (val1, val2);
    }

    return dp[i][j] = cnt;
}
void printALCS (int i, int j) {
    if (i == (int) A.size() || j == (int) B.size() ) {
        cout << ans << "\n";
        return;
    }

    if (A[i] == B[j]) {
        ans += A[i];
        printALCS (i + 1, j + 1);

    } else {
        if (dp[i + 1][j] > dp[i][j + 1]) printALCS (i + 1, j);
        else {
            printALCS (i, j + 1);
        }
    }
}
int main () {
    __FastIO;
    cin >> A >> B;
    SET (dp, -1);
    LCS (0, 0);
    printALCS (0, 0);
    return 0;
}


Measured memory_bytes: 39256
# -*- coding: utf-8 -*-

from collections import Counter 

N = int(input())
AN = list(map(int, input().split()))

# 各数値ごとに数を集計
AN_dict = Counter(AN)
AN_list = sorted(AN_dict.items())

hen1 = 0
hen2 = 0
# 低い値から見ていって順次最大に更新していく
for AN in AN_list:
    # 正方形
    if AN[1] >= 4:
        hen1 = AN[0]
        hen2 = AN[0]
    # 長方形
    elif AN[1] >= 2:
        hen2 = hen1
        hen1 = AN[0]      

print(hen1 * hen2)

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

int main() {
    int N;
    cin >> N;
    int peopleCounter;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        peopleCounter = peopleCounter + (r - l + 1);
    }
    cout << peopleCounter << endl;
}


Measured memory_bytes: 256
INF = 10 ** 20

n = int(input())

dp = [INF for _ in range(n + 1)]
dp[0] = 0
lst = [1]
acc = 6
while acc <= n:
  lst.append(acc)
  acc *= 6
acc = 9
while acc <= n:
  lst.append(acc)
  acc *= 9
lst.sort()

for i in range(1, n + 1):
  for value in lst:
    if i - value >= 0:
      dp[i] = min(dp[i], dp[i - value] + 1)

print(dp[n])

Measured memory_bytes: 3864
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main(){
  int n;
  long long int a=1;
  scanf("%d",&n);

  for(long long int i=2;i<=n;i++){
    a=(a*i)%MOD;
  }

  cout << a << endl;
  return 0;
}


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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define pii pair <int, int>
#define sz(a) (int)a.size()
#define F first
#define S second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 1e5+500;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);	

int main()
{                   
	run_forrest_run;
	int n,l;
	cin >> n >> l;
	int a[n+1];
	int sum = 0;
	int mini = INT_MAX;
	int maxi = INT_MIN;
	for (int i = 1; i <= n; i++)
	{
		a[i] = l+i-1;
		sum+=a[i];
		if (a[i] >= 0)
			mini = min(mini, a[i]);
		else if (a[i] < 0)
			maxi = max(maxi, a[i]);
	}
	if (mini != INT_MAX && maxi != INT_MIN)
	{
		int res = min(abs(mini), abs(maxi));
		cout << sum-res;
	}
	else if (mini==INT_MAX)
		cout << sum - maxi;
	else cout << sum - mini;
	
}

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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  int t;
  if(A > C) t = A, A = C, C = t;
  if(B > C) t = B, B = C, C = t;
  if(A == 5 && B == 5 && C == 7) cout << "YES";
  else cout << "NO";
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000

//aのb乗
int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}

int main() {
	
	int N,K;
	cin>>N>>K;
	
	vector<int> cnt(K+1,0);
	
	for(int i=K;i>=1;i--){
		cnt[i] = beki(K/i,N);
		for(int j=2*i;j<=K;j+=i){
			cnt[i] = mod(cnt[i] - cnt[j]);
		}
	}
	
	int ans = 0;
	for(int i=1;i<=K;i++){
		ans = mod(ans + mod(i*cnt[i]));
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 3732
from sys import stdin

class Node:
    def __init__(self):
        self.parent = -1
        self.depth = -1
        self.children = []

class Tree:
    def __init__(self, nodes):
        self.nodes = nodes

        for i in range(self.size()):
            if not self.isLeaf(i):
                for c in self.nodes[i].children:
                    self.nodes[c].parent = i

        for i in range(self.size()):
            self.nodes[i].depth = self.depth(i)

    def depth(self, i):
        n = self.nodes[i]
        if self.isRoot(i):
            return 0
        else:
            return self.depth(n.parent)+1


    def size(self):
        return len(self.nodes)

    def isLeaf(self, i):
        return len(self.nodes[i].children) == 0

    def isRoot(self, i):
        return self.nodes[i].parent == -1

n = int(stdin.readline().rstrip())
nodes = [Node() for _ in range(n)]
for i in range(n):
    l = [int(x) for x in stdin.readline().rstrip().split()]
    if l[1] > 0:
        nodes[l[0]].children.extend(l[2:])

t = Tree(nodes)
for i in range(t.size()):
    l = ["node ", i, ": parent = ", t.nodes[i].parent, ", depth = ", t.nodes[i].depth, ", "]
    if t.isRoot(i):
        l.append("root, ")
    elif t.isLeaf(i):
        l.append("leaf, ")
    else:
        l.append("internal node, ")

    l.append(t.nodes[i].children)
    print(*l, sep="")


Measured memory_bytes: 40192
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <numeric>
using namespace std;

int main(){
    int n,m ;
    cin >> n >> m ;
    vector<vector<int> > list(n,vector<int>(0)) ;
    vector<int> h(n) ;
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i) ;
    }
    
    int a,b ;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b ;
        list.at(a-1).push_back(b-1) ;
        list.at(b-1).push_back(a-1) ;
    }
    int M = 0 ;
    int ans = 0 ;
    for (int i = 0; i < n; i++)
    {
        M = 0 ;
        for (int j = 0; j < list.at(i).size(); j++)
        {
            int num = list.at(i).at(j) ;
            M = max(M,h.at(num)) ;
        }
        if (h.at(i) > M)
        {
            ans ++ ;
        }
        
    }
    
    cout << ans << endl ;
}

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

int field[10][5];
int cnt;

void Connect_Num(int y,int x){
  
  cnt++;
  
  if( x+1 < 5 && field[y][x] == field[y][x+1]){
    Connect_Num(y,x+1);
  }
  
}
void Del(int y,int x,int n){
  
  rep(i,n){
    for(int j=y ; j > 0 ; j--){
      field[j][x+i]=field[j-1][x+i];
    }
    field[0][x+i]=0;
  }
  
}
int main(){
  
  int h;
  
  while(1){
    
    cin >>h;
    if(h==0)break;
    
    rep(i,h){
      rep(j,5){
	cin >>field[i][j];
      }
    }
    
    int score=0;
    
    while(1){
      bool flag=true;
      rep(i,h){
	rep(j,5){
	  if(field[i][j] != 0){
	    cnt=0;
	    Connect_Num(i,j);
	    if(cnt >=3){
	      score+=cnt*field[i][j];
	      Del(i,j,cnt);
	      j+=cnt;
	      flag=false;
	    }
	  }
	}
      }
      if(flag)break;
    }
    
    cout <<score<<endl;
  
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 aa, bb, cc;
	cin >> aa >> bb >> cc;
	int64 tmp = cc - aa - bb;
	if(tmp > 0 && tmp * tmp > 4 * aa * bb)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

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

   for(auto i:s)
   cout << "x" ;}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n+1][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    int p=max(dp[n][0],dp[n][1]);
    cout<<max(p,dp[n][2]);
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }
 
ll rec(int i, ll cur, ll sum, const string &S) {
	if(i == S.size()) {
		return sum;
	}
	int d = S[i] - '0';
	ll res = 0;
	if(i + 1 != S.size())
		res += rec(i + 1, cur * 10 + d, sum, S);
	res += rec(i + 1, 0, sum + cur * 10 + d, S);
	return res;
}
 
int main() {
	string S;
	while(cin >> S) {
		ll ans = rec(0, 0, 0, S);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, v, n) for (int i = v; i < int(n); ++i)
#define rep2(i, v, n) for (int i = v; i <= int(n); ++i)

void solve() {
    int r, c;
    cin >> r >> c;
    vector<vector<int>> t(r + 1, vector<int>(c + 1));
    rep(i, 0, r) rep(j, 0, c) cin >> t[i][j];
    rep(i, 0, r) t[i][c] = accumulate(t[i].begin(), t[i].begin() + c, 0);
    rep(j, 0, c + 1) rep(i, 0, r) t[r][j] += t[i][j];
    rep(i, 0, r + 1) {
        rep(j, 0, c + 1) {
            if (j) cout << " ";
            cout << t.at(i).at(j);
        }
        cout << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main()
{
    long long N,res=true,m=0;
    cin >> N;
    long long H[N];
    rep(i,N) cin >> H[i];
    rep(i,N) {
        if(i==N-1) break;
        m = max(H[i], m);
        if((H[i] <= H[i+1])) {
            continue;
        }
        if((m-1 == H[i+1])) {
            continue;
        }
        res=false;
        break;
    }
    if (res) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if(A >= 1 && A <= 9){ 
    if(B >= 1 && B <= 9) {
      cout << A*B << endl;
    }   
    else{cout << -1 << endl;}
  }
  else{cout << -1 << endl;}
}

Measured memory_bytes: 256
using System;

namespace ALDS1_10_A {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine(Fib(int.Parse(Console.ReadLine())));
        }

        static int Fib(int n) {
            if (n == 0 || n == 1)
                return 1;
            int[] fib = new int[n + 1];
            fib[0] = fib[1] = 1;
            for (int i = 2; i <= n; i++) {
                fib[i] = fib[i - 1] + fib[i - 2];
            }
            return fib[n];
        }
    }
}

Measured memory_bytes: 9220
#include <stdio.h>
#include <math.h>
int main(void) {
    double r, length, square, pi;
    pi = M_PI;
    scanf("%lf", &r);
    length = 2 * pi * r;
    square = pi * r * r;
    printf("%.6lf %.6lf\n", square, length);
    return 0;
}

Measured memory_bytes: 652
import java.util.Arrays;
import java.util.Scanner;

/* 参考:　貰う DP と配る DP、メモ化再帰、個数制限なしナップサック問題 @drken https://qiita.com/drken/items/ace3142967c4f01d42e9#%E8%A7%A3%E6%B3%95-1-1-%E3%83%88%E3%83%83%E3%83%97%E3%83%80%E3%82%A6%E3%83%B3%E3%81%AB-n-%E3%82%92%E9%99%8D%E4%B8%8B%E3%81%97%E3%81%A6%E3%81%84%E3%81%8F%E3%83%A1%E3%83%A2%E5%8C%96%E5%86%8D%E5%B8%B0 */

public class Main {
	static final int MAX_N = 110000;
	static int[] dp = new int[MAX_N];
	static {
		Arrays.fill(dp, MAX_N); // 初期化 Infinity
		dp[0] = 0;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		calc(N);
		System.out.println(dp[N]);
	}

	static void calc(int N) {
		for (int n = 0; n <=N; n++) {
			for (int pow6 = 1; n+pow6 <= N; pow6*=6) {
				dp[n+pow6] = Math.min(dp[n+pow6], dp[n] + 1);
			}
			for (int pow9 = 1; n+pow9 <= N; pow9*=9) {
				dp[n+pow9] = Math.min(dp[n+pow9], dp[n] + 1);
			}
		}
	}
}


Measured memory_bytes: 21844
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
    DX, DY = np.diff(X), np.diff(Y)
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B)
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F)
    return A, B, C, D, E, F, X, Y, DX, DY

@njit(cache=True)
def set_ng(A, B, C, D, E, F, H, W):
    ng = np.zeros((H * W, 4), np.bool_)

    for i in range(len(A)):
        for x in range(A[i], B[i]):
            v = x * W + C[i]
            ng[v][1] = 1
            ng[v - 1][0] = 1

    for i in range(len(D)):
        for y in range(E[i], F[i]):
            v = D[i] * W + y
            ng[v][3] = 1
            ng[v - W][2] = 1
    return ng

@njit(cache=True)
def solve(A, B, C, D, E, F, X, Y, DX, DY):
    H, W = len(X), len(Y)
    N = H * W
    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)

Measured memory_bytes: 180808
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
int n;
map<int,int> a;
int main() {
	int k, tm;
	unordered_set<int> st;
	unordered_map<int,int> mp;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> tm;
		st.insert(tm);
		mp[tm]++;
	}
	vector<int> vc;
	if (st.size() <= k) {
		cout << 0 << endl;
	}
	else {
		int res = 0;
		for (auto kv : mp) {
				vc.push_back(kv.second);
		}
		sort(vc.begin(), vc.end());
		for (int i = 0; i < st.size() - k; i++) {
			res += vc[i];
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 18576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
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;}

int main(){
    int n;cin >> n;
    ll sum = 0;
    vi a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        ans += a[i]/2;
        if(i+1<n && (a[i]&1) && a[i+1]>0) ++ans,--a[i+1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
    char a[100];
    scanf("%s",a);
    int t,i;
    t=strlen(a);
    for(i=0;i<t;i++)
        cout<<"x";
    cout<<"\n";
    return 0;
}


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

int main(void)
{
    string s, max_s = "", most_s = "";
    int most = 0;
    map<string, int> count;
    
    while(cin >> s) {
        if (max_s.size() < s.size()) {
            max_s = s;
        }
        if (count.find(s) == count.end()) {
            count[s] = 0;
        }
        count[s]++;
        if (most < count[s]) {
            most = count[s];
            most_s = s;
        }
    }
    
    cout << most_s << " " << max_s << endl;
    
    return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;
		if(s.equals("SUN"))
			ans = 7;
		else if(s.equals("MON"))
			ans = 6;
		else if(s.equals("TUE"))
			ans = 5;
		else if(s.equals("WED"))
			ans = 4;
		else if(s.equals("THU"))
			ans = 3;
		else if(s.equals("FRI"))
			ans = 2;
		else if(s.equals("SAT"))
			ans = 1;
		System.out.println(ans);
	}

}


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

int main() {
    int  d, n, ans;
    cin >> d >> n;

    if(d==0 && n==100) ans=101;
    else if(d==0) ans=n;
    else if(d==1 && n==100) ans=10100;
    else if(d==1) ans=n*100;
    else if(d==2 && n==100) ans=1010000;
    else if(d==2) ans=n*10000; 
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> p(N+1, 0);
    vector<int> a(N+1), b(N+1);

    for(int i=1; i<=N; ++i) cin >> p[i];
    for(int i=1; i<=N; ++i){
        a[i] = 50000 * i;
        b[i] = 50000 * (N+1-i);
    }

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

    for(int i=1; i<=N; ++i){
        if(i>1) cout << " ";
        cout << a[i];
    }
    cout << endl;
    for(int i=1; i<=N; ++i){
        if(i>1) cout << " ";
        cout << b[i];
    }
    cout << endl;

}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
int L,i,n=20,a[100],b[100],c[100],cnt;
auto ae=[](int u,int v,int w){return a[++cnt]=u,b[cnt]=v,c[cnt]=w;};
int solve (int L,int i){
    if(L==0) return i<n&&ae(i,n,0);
    if(L==1) return ae(i,n,0),ae(i,n,1);
    if(L&1) return ae(i,i+1,0),ae(i,i+1,L+1>>1),solve(L>>1,i+1);
    else return ae(i,i+1,0),ae(i,i+1,L>>1),ae(i,n,L),solve(L-1>>1,i+1);
}
int main(){
    scanf("%d",&L);
    solve(L-1,1);
    printf("%d %d\n",n,cnt);
    rep(i,1,cnt) printf("%d %d %d\n",a[i],b[i],c[i]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    int weight;
    while(cin >> weight)
{
        vector<int> vi;
        for(int i = 512; weight != 0; i = i / 2)
{
            if(weight >= i)
{
                weight -= i;
                vi.push_back(i);
            }
        }
        int size = vi.size();
        if(size > 0)
{
            cout << vi[size - 1];
            for(int i = size - 2; i >= 0; i--)
{
                cout << " " << vi[i];
            }
        }
        cout << endl;
    }
    return 0;
}

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

typedef long long ll;

ll N,ans=0;

ll rec(ll next, ll n){
    if(next>n){
        return 0;
    }

    ll res=0;
    string str=to_string(next);
    if(str.find('7')!=-1 && str.find('5')!=-1 && str.find('3')!=-1){
        res=1;
    }
    ans+=rec(next*10+7,n);
    ans+=rec(next*10+5,n);
    ans+=rec(next*10+3,n);
    
    return res;
}

int main(){
    cin >> N;
    rec(0,N);
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main () {

  ll H, W, N;

  cin >> H;
  cin >> W;
  cin >> N;

  ll ma;
  ma = max(H, W);

  ll ans;
  if (N % ma == 0) {
    ans = N / ma;
  }
  else {
    ans = N / ma + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<char> D(K);
  rep(i, K) cin >> D[i];

  repp(i, N, (int)1e+6) {
    string s = to_string(i);
    bool ok = true;
    rep(j, s.size()) {
      rep(k, K) {
        if (s[j] == D[k])
          ok = false;
      }
    }
    if (ok) {
      cout << s << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define NMAX 1009
using namespace std;
struct tip{int val; int t;};
priority_queue<tip>H;
bool operator <(tip a, tip b)
{
  return a.val<b.val;
}
int i,n,h;
int a[NMAX];
int main()
{cin>>n>>h;
 for(i=1;i<=h;i++)
    {
     int x;
     cin>>x;
     H.push({x,i});
    }
  while(H.size()>=2)
        {
         tip x,y;
         x=H.top();
         H.pop();
         y=H.top();
         H.pop();
         if(n<=2* y.val)
         {cout<<0;return 0;}
         else
         {n-=2*y.val;
          x.val-=y.val;
          if(x.val)
             H.push(x);
         }

        }
  if(H.size())
      cout<<H.top().val-1;
      else
        cout<<0;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
    long long n;
    cin >> n;

    if (n == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        long long a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}

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

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

	vector<int> v(N);
	int avg = 0;
	for (int i = 0; i < v.size(); i++) {
		cin >> v.at(i);
		avg += v.at(i);
	}

	int avg1, avg2;
	avg1 = ceil((double)avg / N);
	avg2 = floor((double)avg / N);
	//cout << "avg1:" << avg1 << endl;
	//cout << "avg2:" << avg2 << endl;

	int cost1 = 0,
		cost2 = 0;
	for (int i = 0; i < v.size(); i++) {
		int x1, x2;
		x1 = avg1 - v.at(i);
		x2 = avg2 - v.at(i);

		x1 *= x1;
		x2 *= x2;

		cost1 += x1;
		cost2 += x2;
	}

	int a;
	if (cost1 > cost2) {
		a = cost2;
	}
	else {
		a = cost1;
	}
	cout << a << endl;
}

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

using namespace std;

const int N = 100005;
int n, m;

int got_ac[N];
int cnt_wa[N];

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

	int ac = 0, pen = 0;
	for(int i = 0; i < m; i++) {
		int p; char s[5];
		scanf("%d %s", &p, s);
		if(s[0] == 'A') {
			if(!got_ac[p]) {
				got_ac[p] = 1;
				ac++;
				pen += cnt_wa[p];
			}
		}
		else if(!got_ac[p]) {
			cnt_wa[p]++;
		}
	}
	printf("%d %d\n", ac, pen);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    string S, T;
    cin >> S >> T;
    int ans = 1001;
    for (int i = 0; i <= S.length() - T.length(); i++) {
        int cnt = 0;
        for (int j = 0; j < T.length(); j++) {
            if (S[i+j] != T[j]) {
                cnt += 1;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}


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

int main(){
  int n,alice=0,Bob=0;
  cin>>n;
  int card[n];
  for(int i=0;i<n;i++)cin>>card[i];
  sort(card,card+n,greater<int>());
  for(int i=0;i<n;i++){
    if(i%2==0) alice+=card[i]; else Bob+=card[i];
  }

  cout<<alice-Bob<<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  const int MAX_V = 10000;
  int prime[MAX_V+1];
  int i, k, v, ans, dif;
  for(i = 2; i <= MAX_V; i++){
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++){
    if(prime[i]){
      for(k = 2 * i; k <= MAX_V; k += i){
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &v) != EOF){
    if(v == 0) break;
    for(k = v; k >= 2; k--){
      ans = prime[k];
      if(ans == 1){
        dif = prime[k - 2];
        if(dif == 1){
          printf("%d %d\n", k - 2, k);
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace BeginnerCont92
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var val = (a > b ? b : a) + (c > d ? d : c);
            Console.WriteLine(val.ToString());
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#define MAX 1000000
int partition(int *,int,int);

int n;
int main(){
  int i,r;
  int A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
   
 r=partition(A,0,n-1);

 for(i=0;i<n;i++){
   if(i)printf(" ");
   if(i==r)printf("[");
   printf("%d",A[i]);
   if(i==r)printf("]");
 }
 printf("\n");
 return 0;
}
int partition(int *A,int p,int r){
  int x,i,k,m,j;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      k= A[i];
      A[i]=A[j];
      A[j]=k;
    }
  }
    m=A[i+1];
    A[i+1]=A[r];
    A[r]=m;
  return i+1;
}


Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	double t,x;
	double a;

	std::cin >> t >> x;

	a=t/x;

	std::cout << a << '\n';

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Queue{
	String name="";
	int time;
	public Queue(String str,int t) {
		name=str;
		time=t;
	}
	public void Show() {
		System.out.println(name+" "+time);
	}
}

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int i,j,n,q,t,count=0;
        String str="";
        n=scan.nextInt();
        q=scan.nextInt();
        Queue[] queue=new Queue[n];
        for(i=0;i<n;i++) {
        	str=scan.next();
        	t=scan.nextInt();
        	queue[i]=new Queue(str,t);
        }
        i=0;
        t=0;
        while(n>=0) {
        	if(queue[i].time>q) {
        		queue[i].time-=q;
        		t+=q;
        	}
        	else {
        		t+=queue[i].time;
            	System.out.println(queue[i].name+" "+t);
        		for(j=i;j<n-1;j++) {
        			queue[j]=queue[j+1];
        		}
        		i--;
        		n--;
        	}
        	if(count==n)break;
        	i++;
        	if(i>=n) {
        		i=0;
        	}
        }
	}
}


Measured memory_bytes: 74608
n=gets.chomp.to_i
n1=n*(n-1)/2
i=0
count=[]
n.times do |i|
  count[i]=0
end
n1.times do |i|
  m =gets
  m=m.split.map(&:to_i)
  a=m[0]-1
  b=m[1]-1
  if m[2]>m[3]
    count[a]+=3
  elsif m[2]==m[3]
    count[a]+=1
    count[b]+=1
  else
    count[b]+=3
  end
end

count2=count.sort.reverse
n.times do |i|
  n.times do |j|
    if count[i]==count2[j]
      p j+1
      break
    end
  end
end

Measured memory_bytes: 6132
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

const int MAX_N = 3010;
//解説AC
//https://juppy.hatenablog.com/entry/2019/01/10/EDPC/DP%E3%82%B3%E3%83%B3-L-_C_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0
//dp[i][j]:= a[i]~a[j]まで残ってる状態からのX-Y;
ll dp[MAX_N][MAX_N];
ll a[MAX_N];

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

  int n;
  cin >> n;
  REP(i,n) cin >> a[i];

  ROF(i, n-1, 0){
    FOR(j, i, n){
      if((n-i-j-1)%2!=0){
	dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j]);
      }
      else{
	dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j]);	
      }
    }
  }
  cout << dp[0][n-1] << endl;
  
  return 0;
}



  /*
//貪欲はng
  REP(i, n) cin>>a, deque.push_back(a);
  ll first = 0LL, second = 0LL;
  bool sente = true;
  while(!deque.empty()){
    ll mae = deque.front();
    ll usiro = deque.back();
    if(mae > usiro) {
      if(sente) {
	first += mae;
	sente = false;
      }
      else {
	second += mae;
	sente = true;
      }
      deque.pop_front();
    }
    else {
      if(sente) {
	first += usiro;
	sente = false;
      }
      else {
	second += usiro;
	sente = true;
      }
      deque.pop_back();
    }
  }
  cout << first-second << endl;
  */



Measured memory_bytes: 70016