akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int,input().split())
uf = UnionFind(n)

for _ in range(m):
    a , b = map(lambda x:int(x)-1,input().split())
    uf.union(a , b)
    
print(uf.group_count()-1)

Measured memory_bytes: 74404
S = input()
n = len(S)
ans = 0

if n == 1:
    print(S)
    exit()

for i in range(2**(n-1)):
    sum = 0
    start = 0
    for j in range(n-1):
        if ((i>>(n-j-2)) & 1):
            sum += int(S[start:j+1])
            start = j+1
    sum += int(S[start:])
    ans += sum
print(ans)


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

using namespace std;

int main(){
    long long int N;
    cin >> N;
    vector<long long int> A(N-1),buka(N,0);

    for(int i=0;i<N-1;i++){
        cin >> A[i];
        buka[A[i]-1]++;
    }

    for(int i=0;i<N;i++){
        cout << buka[i] << endl;
    }
}

Measured memory_bytes: 6428
import bisect
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
A = []
for q in Q:
    if P[(q+1)//2]==1:
        A.append(q)
B = {i:0 for i in range(1,INFTY,2)}

Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    indl = bisect.bisect_left(A,l)
    indr = bisect.bisect_right(A,r)
    print(indr-indl)
    

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

int main() {
    int N;
    while (cin >> N, N) {
        int M;
        cin >> M;
        string str;
        cin >> str;
        vector<string> vs;
        string v;
        for (int i = 0; i + 2 < M; i += 2) {
            if (str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I') {
                v += "IO";
            } else {
                i-=1;
                if (v.size()) {
                    vs.push_back(v + "I");
                }

                v = "";
            }
        }

        if (v.size()) {
            vs.push_back(v + "I");
        }

        int ans = 0;
        for (int i = 0; i < vs.size(); i++) {
            ans += max((int)vs[i].size()/2-(N-1), 0);
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  string s;
  cin >> s;
  vector<string> vec;
  vec.push_back("Sunny");
  vec.push_back("Cloudy");
  vec.push_back("Rainy");
  for(int i = 0;i < 3;i++) {
    if(vec[i] == s) {
      cout << vec[(i + 1) % 3] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size(), ans = 0;
  rep(i, n / 2) if(s[i] != s[n - 1 - i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;cin>>a>>b>>k;
    if(a+b<=k){
        cout<<0<<" "<<0<<endl;
        return 0;
    }else if(a-k>=0){
        cout<<a-k<<" "<<b<<endl;
        return 0;
    }
    long long res=b+a-k;
    cout<<0<<" "<<res<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  string s,str;
  char c;
  cin >> n >> k >> s;
  c=tolower(s[k-1]);
  for(int i=0; i<k-1; i++) {
    str.push_back(s[i]);
  }
  str.push_back(c);
  for(int i=k; i<n; i++) {
    str.push_back(s[i]);
  }
  cout << str << endl;
}

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

int main(){
  
  int a;
  bool f[31]={};

  for(int i=0;i<28;i++){
    cin>>a;
    f[a]=true;
  }

  for(int i=1;i<=30;i++){
    if(!f[i]) cout<<i<<endl;
  }

  
  
  return 0;
}

Measured memory_bytes: 3108
N = int(input())
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

cumsum = []
for i in range(2):
    c = []
    for j in range(N):
        c.append(A[i][j] + (c[j - 1] if j - 1 >= 0 else 0))
    cumsum.append(c)

res = 0
for j in range(N):
    row0 = cumsum[0][j];
    row1 = cumsum[1][N - 1] - (cumsum[1][j - 1] if j - 1 >= 0 else 0)
    res = max(res, row0 + row1)
print(res)


Measured memory_bytes: 3064
N = int(input())
count = []
for i in range(4):
    count.append(0)

for i in range(N):
    type = input()
    if type == 'AC':
        count[0] += 1
    elif type == 'WA':
        count[1] +=1    
    elif type == 'TLE':
        count[2] += 1
    elif type == 'RE':
        count[3] += 1

print("AC x", count[0])
print("WA x", count[1])
print("TLE x", count[2])
print("RE x", count[3])

Measured memory_bytes: 9212
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 

using namespace std;

int main()
{
	int r,D,x;
	cin >> r>> D>>x;
	int a = D / (r - 1);
	int y;
	y = x;
	for (int i = 0;i < 10;i++) {
		y = r * y - D;
		cout << y << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
 
#define lli long long int
#define pb push_back 
 
int main ()
{
    ios_base::sync_with_stdio(false) ; 
    cin.tie(NULL) ;
 
    int a , b ;
    cin >> a >> b ;
 
    int n = 1 ;
    n = 1 ;
 
    while (n <= 1000000)
    {
        double r = (double) n * 0.08 ;
        double r2 = (double) n * 0.1 ;
        int r3 = floor(r) ;
        int r4 = floor(r2);
     
        if (r3 == a && r4 == b)
        {
            cout << n << endl ;
            return 0 ;
        }
        
 
        n++ ;
    }
  
    cout << "-1\n" ; 
 
    
    return 0 ;
}

Measured memory_bytes: 256
s = list(map(int,input()))
ans = 0

for i in range(len(s)-1):
    if s[i]==0 and s[i]==s[i+1]:
        ans += 1
        s[i+1] = 1
    elif s[i]==1 and s[i]==s[i+1]:
        ans += 1
        s[i+1] = 0

print(ans)

Measured memory_bytes: 3956
// inputに入力データ全体が入る
function Main(input) {
//    input = input.split(' ');
    //文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(input, 10);
    
    if (1 <= n && n <= 999) {
        console.log('ABC');
    } else if (1000 <= n && n <= 1998) {
        console.log('ABD');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
//file_name:ABC82_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    int c = s.size();
    int d = t.size();
    int a[c];
    int b[d];
    rep(i,c){
        a[i]=s[i];
    }
    rep(i,d){
        b[i]=t[i];
    }
    sort(a,a+c);
    sort(b,b+d);
    rep(i,min(c,d)){
        if(a[i]<b[d-1-i]){
            puts("Yes");
            return 0;
        }
        if(b[i]<a[i]){
            puts("No");
            return 0;
        }
    }
    if(c<d)yn;


    return 0;
}



Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]

for x in range(101):
    for y in range(101):
        k=set(e+abs(x-q)+abs(w-y)  for q,w,e in l if e)
        for pre in k:
            for a,s ,d in l:

                if d!=max(0,pre-abs(x-a)-abs(s-y)):break
            else:print(x,y,pre);exit()

Measured memory_bytes: 3064
# AOJ 1111: Cyber Guardian
# Python3 2018.7.15 bal4u

import re

while True:
	n, m = map(int, input().split())
	if (n|m) == 0: break
	rule, ans = [], []
	for i in range(n):
		g, s, d = input().split()
		rule.append((g[0] == 'p', \
		             re.compile(s.replace("?", "[0-9]")), \
		             re.compile(d.replace("?", "[0-9]"))))
	for i in range(m):
		s, d, m = input().split()
		for G, S, D in rule[::-1]:
			if re.match(S, s) and re.match(D, d):
				if G: ans.append((s, d, m))
				break
	print(len(ans))
	for a in ans: print(*a)



Measured memory_bytes: 8228
import sys
from collections import deque
import copy
import math
import re

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    dp = [[[[0L for i in range(4)] for j in range(4)] for k in range(4)] for l in range(N + 1)]
    dp[0][3][3][3] = 1
    for i in range(N):
        for c1 in range(4):
            for c2 in range(4):
                for c3 in range(4):
                    for x in range(4):
                        if x == 2 and c2 == 1 and c3 == 0:
                            continue
                        if x == 2 and c1 == 1 and c3 == 0:
                            continue
                        if x == 2 and c2 == 0 and c1 == 1:
                            continue
                        if x == 2 and c2 == 1 and c1 == 0:
                            continue
                        if x == 1 and c2 == 0 and c1 == 2:
                            continue
                        dp[i + 1][c2][c1][x] = (dp[i + 1][c2][c1][x] + dp[i][c3][c2][c1] ) % 1000000007L
    count = 0L
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                    count = (count + dp[N][c1][c2][c3]) % 1000000007L

    print count

##    if N == 3:
##        print 61
##        return
##
##
##    X = N - 3
##    ans = 1L
##    for i in range(N):
##        ans = (ans * 4L) % 1000000007L
##    sub = 26L
##    for i in range(X -1):
##        sub = (sub * 4L) % 1000000007L
##
##    print (ans - sub) % 1000000007L


if __name__ == '__main__':
    main()


Measured memory_bytes: 3312
N = int(input())
L = list(map(int, input().split()))
v = 0
cnt = 0
while v == 0:
    cnt += 1
    for i in range(N):
        if L[i] % 2 == 0:
            L[i] = L[i] // 2
        else:
            v += 1
print(cnt-1)

Measured memory_bytes: 39408
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;
int main()
{
    string s;
    string ans = "";
    in s;
    rep(i,s.size())
    {
        if(s[i] == '0')ans += '0';
        else if(s[i] == '1')ans += '1';
        else if(!ans.empty())ans.erase(ans.end()-1);
    }
    cout <<ans<< endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

lint minus(vector<lint>lastdi, vector<lint>C) {
	lint ans = 0;
	rep(i, 26) {
		ans += C[i] * lastdi[i];
	}
	return ans;
}

int main() {
	lint D;
	cin >> D;
	vector<lint>C(26);
	rep(i, 26) {
		cin >> C[i];
	}
	vector<vector<lint>>S(D, vector<lint>(26));
	rep(i, D) {
		rep(j, 26) {
			cin >> S[i][j];
		}
	}
	vector<lint>T(D);
	rep(i, D) {
		cin >> T[i];
	}
	vector<lint>lastdi(26);
	lint ans = 0;
	rep(i, D) {
		lastdi[T[i] - 1] = i + 1;
		ans += S[i][T[i] - 1];
		lint minus = 0;
		rep(j, 26) {
			minus += C[j] * (i+1-lastdi[j]);
		}
		/*rep(j, 26) {
			cout << C[j] * (i + 1 - lastdi[j]) << ' ';
		}
		cout << endl;
		cout << minus << endl;
		rep(j, 26) {
			cout << lastdi[j] << ' ';
		}
		cout << enld;
		cout << ans << ' ';*/
		ans -= minus;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3720
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,a,b;
    cin>>n>>a>>b;
    int cnta=0,cntb=0;
    rep(i,n){
        char x;
        cin>>x;
        if(x=='a'){ 
            if(cnta+cntb<a+b){cout<<"Yes"<<endl;
                cnta++;
                continue;
            }
        }
        else if(x=='b'){
            
            if(cnta+cntb<a+b&&cntb<b){cout<<"Yes"<<endl;
                cntb++;
                continue;
            }
        }
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 640
n=int(input())
a=[0]*n
x=[[] for i in range(n)]
y=[[] for i in range(n)]
for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    tmp = list(map(int,input().split()))
    x[i].append(tmp[0])
    y[i].append(tmp[1])

# 事実をbitで表現する
res=0
for bit in range(2**n):
  p_cnt = 0
  fact = 1
  for i in range(n):
    if bit >> i & 1:
      p_cnt += 1
      for j in range(a[i]):
        if  y[i][j] ^ (bit >> x[i][j] -1) & 1:
          fact=0
          break
  if fact and res < p_cnt:
    res = p_cnt
print(res)

Measured memory_bytes: 44140
using System;

public class Program
{
    private int N, K, S;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        S = sc.NextInt();

        // sum[i] - sum[j] = S 

        /*
         * SをK個並べる
         *
         * のこり S+1並べる
         * S == 10^9
         * 1並べる
         */
        var ans = new int[N];
        if (S == 1000000000)
        {
            for (int i = 0; i < K; i++)
            {
                ans[i] = S;
            }

            for (int i = K; i < N; i++)
            {
                ans[i] = 1;
            }
        }
        else
        {
            for (int i = 0; i < K; i++)
            {
                ans[i] = S;
            }

            for (int i = K; i < N; i++)
            {
                ans[i] = S + 1;
            }
        }

        Console.WriteLine(string.Join(" ", ans));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 23132
# coding: utf-8
while True:
    count = int(input())
    if count == 0:
        break
    capacity = [0 for i in range(count)]
    data = sorted(list(map(lambda x: int(input()), capacity)))
    sum = 0
    for index in range(0,len(data)):
        sum += data[index] * (count - 1 - index)
    print(sum)

Measured memory_bytes: 7988
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

typedef unsigned long long ull;

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i =0; i < N; i++) cin >> A[i];
	sort(begin(A),end(A));
	int h =0, d =0;
	while(true) {
		if(d <= N-2 && A[N-2-d] > h+1) {
			d++;
			h++;
			continue;}
		int p =0, x =A[N-1-d]-h;
		for(int i =0; i < N-d; i++) if(A[i] > h) p++;
		if(p%2 == 0 || x%2 == 0) cout << "First\n";
		else cout << "Second\n";
		return 0;}
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int n,h,j,i;
cin>>n;
int number[3][n],sum[n];
for(i=0;i<n;i++){
for(j=0;j<3;j++){
cin>>number[j][i];
}
sum[i]=number[0][i]+number[1][i]+number[2][i];
}

for(i=0;i<n;i++){//?????°
for(j=0;j<3;j++){//?/3
for(h=0;h<n;h++){//??????????±?
if(number[j][i]==number[j][h]&&i!=h){
sum[i]-=number[j][i];
h=n;
}
}
}
cout<<sum[i]<<endl;
}
return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<int>a(n+1);
    rrep(i,n) cin>>a[i];
    int ans = 0;
    for(int i = 1; i <= n; i+=2){
        if(a[i]%2==1)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3592
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
#R = 10**9 + 7
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
l = []
r = []
for i in range(k):
    ll,rr = inm()
    l.append(ll)
    r.append(rr)
a = [0]*n
c = [0]*(n+1)
a[0] = c[0] = 1
for i in range(1,n):
    for j in range(k):
        if i-l[j]>=0:
            a[i] = (a[i]+c[i-l[j]]-c[max(0,i-r[j])-1])%R
    c[i] = (c[i-1]+a[i])%R
print(a[n-1])


Measured memory_bytes: 71156
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G

#BFS
from collections import deque
def bfs(v,p,color):
    q=deque()
    q.append((v,p,0))
    ans={}
    while q:
        #qの先頭を取り出す
        V,P,NUM=q.popleft()
        num=min(0,NUM)+1
        for new_v in G[V-1]:
            if new_v==P:continue
            if NUM==num:num+=1
            ans[(V,new_v)]=num
            q.append((new_v,V,num))
            num=num+1
    return ans

n=int(input())
ab=[tuple(map(int,input().split())) for i in range(n-1)]
G=Graph(ab)
#print(G)

color=0
for i in G:
    temp=len(i)
    if color<temp:color=temp
print(color)

ans=bfs(1,-1,color)
#print(ans)
for i in ab:
    print(ans[i])

Measured memory_bytes: 44588
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		String s_a=sc.next();
		String s_b=sc.next();
		String s_c=sc.next();
		int la=s_a.length();
		int lb=s_b.length();
		int lc=s_c.length();
		int a=la;
		int b=lb;
		int c=lc;
		char turn='a';
		String ans=null;
		boolean end=false;
		while(!end) {
			switch(turn) {
			case('a'):
				if(a==0) {
					end=true;
					ans="A";
					break;
				}
				turn=s_a.charAt(la-a);
				a--;
				
				break;
				
				
			case('b'):
				if(b==0) {
					end=true;
					ans="B";
					break;
				}
				turn=s_b.charAt(lb-b);
				b--;
				
				break;
			
			case('c'):
				if(c==0) {
					end=true;
					ans="C";
					break;
				}
				turn=s_c.charAt(lc-c);
				c--;
		
				break;
			}
		}
		
	
		System.out.println(ans);
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				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;
		}

	}
	

}





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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto&& e : s) cin >> e;
  vector<vector<pair<int, int>>> grid(h, vector<pair<int, int>>(w));

  for (int y = 0; y < h; y++) {
    int c = 1;
    for (int x = 0; x < w; x++) {
      grid[y][x].first = s[y][x] == '#' ? c = 0, c++ : c++;
    }
    for (int x = w - 2; x >= 0; x--) {
      if (grid[y][x].first == 0 || grid[y][x + 1].first == 0) continue;
      grid[y][x].first = grid[y][x + 1].first;
    }
  }
  for (int x = 0; x < w; x++) {
    int c = 1;
    for (int y = 0; y < h; y++) {
      grid[y][x].second = s[y][x] == '#' ? c = 0, c++ : c++;
    }
    for (int y = h - 2; y >= 0; y--) {
      if (grid[y][x].second == 0 || grid[y + 1][x].second == 0) continue;
      grid[y][x].second = grid[y + 1][x].second;
    }
  }
  int ans = 0;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      ans = max(ans, grid[y][x].first + grid[y][x].second - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 35712
n=int(input())
a_list=[list(map(int,input().split())) for _ in range(2)]

top_cnts=[]
beneath_cnts=[]

top_cnt = 0
beneath_cnt=sum(a_list[1])
for a,b in zip(a_list[0],a_list[1]):
	top_cnt += a
	top_cnts.append(top_cnt)
	beneath_cnts.append(beneath_cnt)
	beneath_cnt-=b
	
max_cnt = 0	
for i in range(n):
	cnt = top_cnts[i]+beneath_cnts[i]
	if cnt >max_cnt:
		max_cnt=cnt
		
print(max_cnt)

Measured memory_bytes: 38832
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
inline int maxm(const int &a,const int &b)
{
  if(a>b)return a;
  else return b;
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */

int main()
{
   VALHALLA
   string s;cin>>s;
   reverse(all(s));
   string s1="maerd";
   string s2="remaerd";
   string s3="esare";
   string s4="resare";
   int index=0;
   while(index<sz(s))
   {
    debug(index);
     string to_check1=s.substr(index,5);
     string to_check2=s.substr(index,6);
     string to_check3=s.substr(index,7);
     if(to_check1==s1||to_check1==s3)
      index+=5; 
     else if(to_check2==s4)
      index+=6;
     else if(to_check3==s2)
      index+=7;
     else
      {cout<<"NO"<<endl;return 0;}

   }
   cout<<"YES"<<endl;
}




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

int main(){
 int a, b;
 cin>>a>>b;
 if (a < b) cout<<"a < b"<<endl;
 if (a > b) cout<<"a > b"<<endl;
 if (a == b) cout<<"a == b"<<endl;
 return 0;
}



Measured memory_bytes: 3080
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn = 2e5 + 10;

char a[maxn]; 

map<int,int>maps;

int n,p;

LL res = 0;

int main(void) {
	scanf("%d%d",&n,&p);
//	getchar();
	scanf("%s",a + 1);
//	cout << a + 1 << endl;
	if(10 % p == 0) {
		for(int i = 1; i <= n; i ++) {
			if((a[i] - '0') % p == 0) {
				res += i;
			}
		}
	} else {
		LL ans = 0,t = 1;
		for(int i = n; i ; i -- ){
			maps[ans] ++;
			ans = (ans + (a[i] - '0') * t)  % p;
			t = t * 10 % p; 
			res += maps[ans];
		}
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

namespace tree {
struct union_find {
  vector<int> par, rank, size;
  int compnum;

  union_find(int N) {
    compnum = N;
    par.resize(N), rank.resize(N), size.resize(N);
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int main() {
  int N; cin >> N;
  vector<int> x(N), y(N);
  rep(i, N) cin >> x[i] >> y[i];
  map<pair<int, int>, int> mp;
  rep(i, N) {
    mp.emplace(make_pair(x[i], y[i]), i);
  }
  set<pair<int, int>> pqs;
  rep(i, N) REP(j, i + 1, N) {
    auto p = x[i] - x[j], q = y[i] - y[j];
    pqs.emplace(p, q);
    pqs.emplace(-p, -q);
  }
  int ans = inf;
  for (auto pq: pqs) {
    auto p = pq.first, q = pq.second;
    tree::union_find uf(N);
    rep(i, N) {
      auto s = make_pair(x[i], y[i]);
      auto t = make_pair(x[i] - p, y[i] - q);
      if (mp.find(t) == mp.end()) { continue; }
      uf.unite(mp[s], mp[t]);
    }
    ans = min(ans, uf.num_of_comps());
  }
  if (ans == inf) {
    cout << "1\n";
  } else {
    cout << ans << "\n";
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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() {
    string t;cin>>t;
    string a;
    if(t.size()!=1){rep(i,t.size()){
        if(t[i]=='?'){
            if(i>0&&i<t.size()-1){
                if(t[i+1]=='P'){t[i]='D';}
                else if(t[i-1]=='P'){
                    t[i]='D';
                }else{
                     t[i]='P';
                }
            }else if(i==0){
                if(t[i+1]=='P'){
                    t[i]='D';
                }else{
                    t[i]='P';
                }
            }else{
                t[i]='D';
            }
        }
        cout<<t[i];
    }}else{if(t=="?")cout<<"D";else{cout<<t;}}
    return 0;
}

Measured memory_bytes: 3728
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    vi b = A;
    sort(b.begin(), b.end(), greater<int>());

    REP(i,N) {
        int hi = b[0];
        if (hi == A[i]) {
            int hi2 = b[1];
            cout << hi2 << endl;
        } else {
            cout << hi << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
def partition(lst,start,last):
    x = lst[last]
    i = start
    for j in range(start,last):
        if lst[j] <= x:
            lst[i],lst[j] = lst[j],lst[i]
            i += 1
    lst[i],lst[last] = lst[last],lst[i]
    return i

n = int(input())
n_lst = list(map(int,input().split()))
p = partition(n_lst,0,n-1)
str_lst = list(map(str,n_lst))
str_lst[p] = '['+str_lst[p]+']'
print(' '.join(str_lst))


Measured memory_bytes: 16584
import java.math.*;
import java.text.*;
import java.lang.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int[] a = new int[5];
			for(int i=0; i<5; i++){
				a[i] = in.nextInt();
			}
			Arrays.sort(a);
			System.out.println(a[4]+" "+a[3]+" "+a[2]+" "+a[1]+" "+a[0]);
		}
	}

}

Measured memory_bytes: 12000
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let nm: Vec<u32> = read_vec();
    if nm[0] == nm[1] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int N, T;
int c, t;
int ans = 1001;

int main()
{
    cin >> N >> T;
    for(int i = 0; i < N; i++){
        cin >> c >> t;
        if(t <= T){
            ans = min(ans, c);
        }
    }
    if(ans == 1001){
        cout << "TLE" << endl;
        return 0;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int n, A[50];

// 入力値の M から選んだ要素を引いていく再帰関数
int solve(int i, int m)
{
    int res;

    if (m == 0) return 1;
    if (i >= n) return 0;
    res = solve(i + 1, m) || solve(i + 1, m - A[i]);

    return res;
}

int main()
{
    int q, M, i;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 2696
#include <iostream>
#include <string>                //???????????????
#include <queue>
#include <algorithm>
using namespace std;
queue<pair<string, int> > Q;
const int num = 100005;
int head, tail, t;
string name;
int main() {
	int n, q, sum = 0, mi;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> name >> t;
		Q.push(make_pair(name, t));
	}
	pair<string, int> pa;
	head = 0;
	tail = n;
	while (head != tail) {
		pa = Q.front(); Q.pop();
		head = (1 + head) % num;
		mi = min(q, pa.second);
		pa.second -= mi;
		sum += mi;
		if (pa.second > 0) {
			Q.push(pa);
			tail = (1 + tail) % num;
		}
		else {
			cout << pa.first << " " << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6212
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	int N=sc.nextInt();
	int M=sc.nextInt();
	int v=N*M;
	String sum;
	int wa=0;
	int ac=0;
	int s[]=new int[N+1];
	for(int i=0;i<M;i++) {
		int g=sc.nextInt();
		sum=sc.next();
		if(s[g]==-1000) {
		continue;	
		}
		if(sum.equals("AC")) {
			wa+=s[g];
			//p("sg"+s[g]);
		//	p("wa"+wa);
			s[g]=-1000;
			ac++;
		}else {
			s[g]++;
		}
	}
	p(ac+" "+wa);
 }
}


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

int main(){
        
	int n;
	cin>>n;
	bool cont = false;
	string ans = "No";
	int cnt = 0;
	while(n--){
		int f,s;
		cin>>f>>s;
		if(f==s){
			if(cont){
				cnt++;
				if(cnt==3){
					ans = "Yes";
				}	
			}	
			else{
				cont = true;
				cnt =1;
			}
		}else{
			cont = false;
		}
	}
	
	cout<<ans;
    
}

Measured memory_bytes: 3584
#include <stdio.h>
int main(void){
	int s,m,a[100000],n,k,i;
	while(1){
		scanf("%d %d",&n,&k);
		if(!k)
			break;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		s=0;
		for(i=0;i<k;i++){
			s+=a[i];
		}
		m=s;
		for(i=k;i<n;i++){
			s=s-a[i-k]+a[i];
			if(m<s){
				m=s;
			}
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s, s + n);
    vector<pair<int, string>> vote;
    int i = 0;
    while (i < n)
    {
        int a = upper_bound(s, s + n, s[i]) - s;
        vote.push_back(make_pair(a - i, s[i]));
        i = a;
    }
    sort(vote.begin(), vote.end());
    reverse(vote.begin(), vote.end());
    int max = vote[0].first;
    vector<string> ans;
    for (int i = 0; i < vote.size(); i++)
    {
        if(vote[i].first < max) break;
        ans.push_back(vote[i].second);
    }
    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[ans.size()-1-i] << endl;
    }



    return 0;
}

Measured memory_bytes: 21872
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
	int n, maxwt;
	cin>>n>>maxwt;
	vector<vector<long long int> >dp(n+1, vector<long long int>(maxwt+1));
	int wt[n], val[n];
	for(int i = 0; i<n; i++)
	cin>>wt[i]>>val[i];
	for(int i = 0; i<n+1; i++){
		for(int j = 0; j<maxwt+1; j++){
			if(i == 0|| j == 0){
				dp[i][j] = 0;
				continue;
			}
			if(j-wt[i-1]>=0){
				dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j-wt[i-1]]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][maxwt];
	return 0;
}

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

#define P pair<int, int>

using namespace std;

bool sort_func(P lhs, P rhs) {
  return lhs.second < rhs.second;
}

int main() {
  int n, m;
  cin >> n >> m;

  vector<P> req;
  for (int i = 0; i < m; i++) {
    int b, e;
    cin >> b >> e;
    req.push_back(make_pair(b, e));
  }

  sort(req.begin(), req.end(), sort_func);

  int ans = 0;
  int end = 1;
  for (int i = 0; i < m; i++) {
    if (end <= req[i].first) {
      ans++;
      end = req[i].second;
    }
  }

  cout << ans << "\n";
  return 0;
}


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

	

int main() {
	
	int N,M;
	cin >>N >>M;
	
	vector<int> A(M);
	
	for(int i=0; i<N; i++){
		
		int K; cin >>K;
		
		for(int j=0; j<K; j++){
			
			int As; cin >>As;
			
			A.at(As-1)++;
			
		}
		
		
	}
	
	int ans=0;
	
	for(int i=0; i<M; i++){
		
		if(A.at(i)==N){
			
			ans++;
			
		}
		
	}
	
	cout <<ans <<endl;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int n,k;
    cin>>n>>k;
    ll arr[n];
    loop(n,i,0)
        cin>>arr[i];
    sort(all(arr,n));
    ll res=0;
    loop(n-k,i,0)
        res+=arr[i];
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector<int> vec(N);

    for (int i=0; i<N-1; i++){
        int jousi;
        cin >> jousi;
        vec.at(jousi -1) += 1;
    }

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

Measured memory_bytes: 4052