akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
const int maxn = 1010;
int x[maxn], y[maxn], n, d[maxn], m, flg[2];
 
void solve(int a, int b){
    for(int i=0; i<m-flg[0]; i++){
        if(abs(a)>abs(b)){
            if(a>0) putchar('R'),a-=d[i];
            else    putchar('L'),a+=d[i];
        }else{
            if(b>0) putchar('U'),b-=d[i];
            else    putchar('D'),b+=d[i];
        }
    }
    if(flg[0]) putchar('L');
    puts("");
}
int main(){
    cin >> n;
    for(int i = 0; i < n; i++) 
        cin >> x[i] >> y[i], flg[(abs(x[i])+abs(y[i]))%2]=1;
    if(flg[0]&&flg[1]) return puts("-1"),0;
    for(int j = 30; j >= 0; j--)  d[m++]=(1<<j);
    if(flg[0]) d[m++] = 1;
    printf("%d\n", m); 
    for(int i=0;i<m;i++)printf("%d%c",d[i]," \n"[i==m-1]);
    for(int i = 0; i < n; i++) solve(x[i]+flg[0],y[i]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
	int a, b, c;
	bool flag = false;
	while(cin >> a >> b >> c){
		flag = true;
		for(int i = 0; i < 100; i++){
			if((a * i) % b == c){
				cout << "YES" << endl;
				flag = false;
				break;
			}
		}
		if(flag) cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>

using namespace std; 

const long long mod=1e9+7;

int main(){

    long long h,w;
    cin>>h>>w;

    if(h==1 || w==1){
        cout<<1<<endl;
        return 0;
    }

    long long a=(h+1)/2, b=h-a;
    long long res=(w+1)/2LL*a + w/2LL*b;

    cout<<res<<endl;
    return 0;
}

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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

ll a, b, n;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> a >> b >> n;

  ll ans = min(b-1, n);
  cout << (a*ans)/b - a * (ans/b) << "\n";
}


Measured memory_bytes: 3636
a,b = map(int, input().split())
prob = list()
for i in range(a):
    n = i+1
    if n >= b:
        prob.append(1)
        continue
    for j in range(b):
        c = 2 ** j
        if (n * c >= b):
            prob.append(c)
            break

probability = 0
for d in prob:
    if (d == 1):
        probability += 1 / a
    else:
        probability += 1 / (a * d)
print(probability, end='')


Measured memory_bytes: 3864
PROGRAM ATCODER

implicit none
integer :: n,m,p,x,i,sum,j
integer,allocatable :: t(:)

read*, n
allocate(t(n))
read*, (t(i), i=1,n)
read*, m

do i = 1, m
  sum = 0
  read*, p,x
  do j = 1, n
    if ( p == j ) then
      sum = sum + x
    else
      sum = sum + t(j)
    end if
  end do
  print'(i0)', sum
end do

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER

Measured memory_bytes: 256
n = int(input())

nn=n
i=1
while nn > 26**i:
    nn-=26**i
    i+=1

an=['a']*i
j=0
while n:
    n-=1
    wk=n%26
    an[j]=(chr(ord('a')+wk))
    n = n//26
    j+=1
    
an.reverse()
print(''.join(an))

Measured memory_bytes: 9100
fun String.zenhan() = substring(0, length / 2)
fun String.kouhan() = substring((length / 2) + 1)
fun String.isKaibun(): Boolean {
    val center = length / 2
    return if (length % 2 != 0) {
        substring(0, center) == substring(center + 1).reversed()
    } else {
        substring(0, center) == substring(center).reversed()
    }
}
fun main(args: Array<String>) {
    val input = readLine()!!
    if (input.isKaibun() && input.zenhan().isKaibun() && input.kouhan().isKaibun()) {
        "Yes"
    } else {
        "No"
    }.let { println(it) }
}


Measured memory_bytes: 33808
def main():
    import sys
    import numpy as np
    n, k = map(int, input().split())
    h = list(map(int, sys.stdin.readline().split()))
    h = np.array(h, dtype=np.int32)
    ans = np.full(n, 10**9, dtype=np.int32)
    ans[0] = 0
    for i in range(n):
        ans[i:i+k+1] = np.minimum(ans[i:i+k+1], ans[i]+np.abs(h[i:i+k+1]-h[i]))

    print(ans[n-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 24616
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<int> f(1000000);

void Stworz()
{
    for (int i = 0; i < 1000000; ++i)
        f[i] = i;
}

int Find(int a)
{
    if (f[a] == a)
        return a;
    int fa = Find(f[a]);
    f[a] = fa;
    return fa;
}

void Union(int a, int b)
{
    int fa = Find(a);
    int fb = Find(b);
    if (fa != fb)
        f[fa] = fb;
}

struct pkt
{
    int x, y;
};

struct wyd
{
    int nr1, nr2, k;
};

bool porownanie(wyd a, wyd b)
{
    if (a.k < b.k)
        return true;
    if (a.k > b.k)
        return false;
    if (a.nr1 < b.nr1)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pkt> p(n);
    map<int, vector< pair<int, int> > > X;
    map<int, vector< pair<int, int> > > Y;
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i].x >> p[i].y;
        X[p[i].x].push_back(make_pair(p[i].y, i));
        Y[p[i].y].push_back(make_pair(p[i].x, i));
    }
    vector<wyd> w;
    for (map<int, vector< pair<int, int> > >::iterator it = X.begin(); it != X.end(); ++it)
    {
        vector< pair<int, int> > a = it->second;
        for (int i = 0; i < (int) a.size() - 1; ++i)
            w.push_back({a[i].second, a[i + 1].second, 0});
        map<int, vector< pair<int, int> > >::iterator it2 = it;
        ++it2;
        if (it2 != X.end())
        {
            vector< pair<int, int> > b = it2->second;
            w.push_back({a[0].second, b[0].second, (it2->first) - (it->first)});
        }
    }
    for (map<int, vector< pair<int, int> > >::iterator it = Y.begin(); it != Y.end(); ++it)
    {
        vector< pair<int, int> > a = it->second;
        for (int i = 0; i < (int) a.size() - 1; ++i)
            w.push_back({a[i].second, a[i + 1].second, 0});
        map<int, vector< pair<int, int> > >::iterator it2 = it;
        ++it2;
        if (it2 != Y.end())
        {
            vector< pair<int, int> > b = it2->second;
            w.push_back({a[0].second, b[0].second, (it2->first) - (it->first)});
        }
    }
    ll odp = 0;
    if (w.size() <= 1)
    {
        cout << "0";
        return 0;
    }
    sort(w.begin(), w.end(), porownanie);
    Stworz();
    for (int i = 0; i < w.size(); ++i)
    {
        if (Find(w[i].nr1) != Find(w[i].nr2))
        {
            Union(w[i].nr1, w[i].nr2);
            odp += w[i].k;
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 30964
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll q;
    cin >> q;
    ll l[q], r[q];
    rep(i, q) { cin >> l[i] >> r[i]; }

    ll max_size = 100001;
    vector<bool> prime_table(max_size, true);

    prime_table[1] = false;
    repd(i, 2, max_size) {
        if (prime_table[i]) {
            ll num = i * 2;
            while (num < max_size) {
                prime_table[num] = false;
                num += i;
            }
        }
    }

    vector<bool> resemble(max_size, false);
    repd(i, 1, max_size) {
        if (i % 2 == 0) {
            continue;
        }
        if (prime_table[i] && prime_table[(i + 1) / 2]) {
            resemble[i] = true;
        }
    }

    vector<int> sum(max_size);
    repd(i, 1, max_size) {
        if (resemble[i]) {
            sum[i] = sum[i - 1] + 1;
        } else {
            sum[i] = sum[i - 1];
        }
    }

    rep(i, q) {
        ll ans = sum[r[i]] - sum[l[i] - 1];
        cout << ans << endl;
    }
    return 0;
}



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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);

  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) ans += v[i] - c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;
int cnt;
string f(ll x, int k)
{
	if (x <= 1)
	{
		return "";
	}
	else if (x % 2 == 0)
	{
		cnt++;
		return f(x / 2, k - 1) + to_string(k) + " ";
	}
	else
	{
		cnt++;
		return to_string(k) + " " + f(x - 1, k - 1);
	}
}
int main(void)
{
	ll n;
	cin >> n;
	cnt = 0;
	string ans = f(n + 1, 100);
	cout << cnt + 100 << endl;
	cout << ans;
	FOR(i, 0, 100)
	{
		cout << i + 1 << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
a,l,$,=:+,:<,' '
puts [6484,a,0,1,3,l,2,3,3].join
[0,1].map{|x|puts [a,x,3,x].join
30.times{|t|v=x+4;u=x*60+9+t;puts [a,v,v,v,a,v,3,6,*[a,6,6,6]*(29-t),l,6,x,u,a,v,u,v]}}
60.times{|t|puts [a,2,2,2]+(0...t).map{|s|[a,8+t-s,69+s,5,l,3,5,6,a,2,6,2]}}

Measured memory_bytes: 14264
import collections
import bisect

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

s = [[int(_) for _ in input().split() ] for _ in range(m)]
a = collections.defaultdict(list)

for x,y in sorted(s):
    a[x]+=[y]
for x,y in s:
    z = bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	int dig;
	int digsum = 0;
	for (int i = 1; i <= n; i++) {
		dig = i;
		digsum = 0;
		while (dig > 0) {
			digsum += dig % 10;
			dig /= 10;
		}
		if (digsum >= a && digsum <= b) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):

    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        fac = self.fac
        finv = self.finv
        mod = self.MOD
        return fac[n] * (finv[k]*finv[n-k] % mod) % mod


def solve(N: int, C: "List[int]"):

    ans = 0
    C.sort(reverse=True)
    for i, c in enumerate(C, start=1):
        b = c*(pow(2, 2*N-2, MOD)*(i+1)) % MOD
        ans += b
        ans %= MOD
    print(ans % MOD)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29044
/*
	Name:
	Author: xiaruize
	Date:
*/

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

int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string t,s;
	cin>>s>>t;
	cout<<t<<s<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc() getchar()
#define pc(a) putchar(a)
#define int long long
#define inf (1ll<<60)
inline int read()
{
    int x=0,f=1;
    char c=gc();
    while(c>'9'||c<'0')
    {
        if(c=='-') f=-f;
        c=gc();
    }
    while(c>='0'&&c<='9') x=x*10+c-'0',c=gc();
    return x*f;
}
int Num[25];
inline void write(int x)
{
    if(!x) {pc('0');return;}
    if(x<0) x=-x,pc('-');
    int top=0;
    while(x) Num[++top]=x%10,x/=10;
    while(top) pc(Num[top--]+'0');
    return;
}
#define ma 300005
int su[ma];
const int mod=998244353;
inline int sum(int l,int r){return ((su[r]-su[l-1])%mod+mod)%mod;}
int dp[ma];
int L[ma],R[ma];
signed main()
{
    int n=read(),k=read();
    for(int i=1;i<=k;i++) L[i]=read(),R[i]=read();
    dp[1]=1;
    su[1]=1;
    for(int i=2;i<=n;i++)
    {
//    	cout<<"dp "<<i<<endl;
        for(int j=1;j<=k;j++)
        	if(i-L[j]>=0)
            	dp[i]=(dp[i]+sum(max(0ll,i-R[j]),i-L[j]))%mod;
        su[i]=(su[i-1]+dp[i])%mod;
    }
//    for(int i=1;i<=n;i++) cout<<dp[i]<<endl;
    write(dp[n]);
}









Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define PB push_back
#define FOR(i,k) for(int i=0; i<k; i++)
#define MAX3(i,j,k) max(i, max(j, k))
#define MIN3(i,j,k) min(i, min(j, k))
#define OUT(x) cout<<(x)<<endl

using namespace std;

int main() {
  int a, b, c, k;
  cin>>a>>b>>c>>k;
  vector<int> v;
  v.PB(a);
  v.PB(b);
  v.PB(c);

  FOR(i, k) {
    int maxInt = MAX3(v[0], v[1], v[2]);
    FOR(j, v.size()) {
      if(v[j] == maxInt) {
        v[j] = maxInt*2;
        break;
      }
    }
  }

  int res = v[0] + v[1] + v[2];
  OUT(res);
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w;
  while (cin >> h >> w) {
    char g[h][w];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }
    bool f = true;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (g[i][j] == '#') {
          int di[] = {0, 0, -1, +1};
          int dj[] = {-1, +1, 0, 0};
          int cnt = 0;
          for (int d = 0; d < 4; ++d) {
            int ni = i + di[d];
            int nj = j + dj[d];
            unless (0 <= ni && ni < h) continue;
            unless (0 <= nj && nj < w) continue;
            cnt += g[ni][nj] == '#';
          }
          f = f && cnt;
        }
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
<?php
while($line = fgets(STDIN)){
    $arr[] = trim($line);
}
$nk = explode(' ', $arr[0]);
$hi = explode(' ', $arr[1]);
$count = 0;
for ($i=0; $i<$nk[0]; $i++) { 
    if ($hi[$i] >= $nk[1]) {
        $count++;
    }
}
echo $count;

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}


#define N 2000004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}



int main(){fastio
    calc();
    ll n;cin>>n;
    ll c[n];rep(i,0,n-1)cin>>c[i];
    sort(c,c+n);
    ll ans=0;
    rep(i,0,n-1){
        ll res=mod(c[i]*po(2,i));
        ll t=n-i-1;
        ll r2;
        if(t-1>=0)r2=mod(t*po(2,t-1)+po(2,t));
        else r2=po(2,t);
        Add(ans,res*r2);
    }
    cout<<mod(ans*po(2,n))<<endl;
    
    return 0;
}



Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    if(N % 2 == 0) {
        vector<ll> a(N);
        for(int i = 0; i < N; i++) cin >> a[i];
        ll mindex = 0;
        for(int i = 1; i < N; i++) {
            if(a[mindex] > a[i]) {
                mindex = i;
            }
        }
        if(a[mindex] % 2 == 1) {
            cout << "First" << endl;
            return 0;
        }
        ll sum = 0;
        for(int i = 0; i < N; i++) {
            sum += a[i] - a[mindex];
        }
        if(sum % 2 == 1) {
            cout << "First" << endl;
            return 0;
        } else {
            cout << "Second" << endl;
            return 0;
        }
        return 0;
    }
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum % 2 == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 4356
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int h=s.nextInt();
		int w=s.nextInt();
		int n=s.nextInt();

		System.out.println(Math.min((n+h-1)/h,(n+w-1)/w));
	}
}


Measured memory_bytes: 21204
#include<stdio.h>
int main(){
  long long int h,count=0,num=1;
  int i;
  scanf("%lld",&h);
  while(h!=0){
    count++;
    h/=2;
  }
  for(i=0;i<count;i++)
    num*=2;
  printf("%lld\n",num-1);
  return 0;
}


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

const int Max_N = 101; // 3 <= N <= 100
const int Max_ans = 21; // 0 <= answer <= 20
bool memo[Max_N][Max_ans]; // memo for dp
long long int dp[Max_N][Max_ans] = {};
std::vector<int> seq;

void format(){
	for(u_int i = 0; i < Max_N; ++i){
		for(u_int j = 0; j < Max_ans; ++j){
			memo[i][j] = false;
		}
	}
	memo[0][seq[0]] = true;
	dp[0][seq[0]] = 1;
}

long long int calcEq(int term, int num){
	if(num < 0 || num > 20){
		return 0;
	}
	else if(term == 3){
		int count = 0;
		if(seq[0] + seq[1] == num){
			count += 1;
		}
		if(seq[0] - seq[1] == num){
			count += 1;
		}
		memo[1][num] = true;
		dp[1][num] = count;
		return dp[1][num];
	}
	else{ 
		if(!memo[term - 2][num]){
			dp[term - 2][num] = calcEq(term - 1, num - seq[term - 2]) + calcEq(term - 1, num + seq[term - 2]);
			memo[term - 2][num] = true;
		}
		return dp[term - 2][num];
	}
}
   
int main(void) {
    u_int N;    // the number of integer
    
	// input
    std::cin >> N;
    seq.reserve(N);
    for (u_int i = 0; i < N; ++i) {
        u_int tmp;
        std::cin >> tmp;
        seq.push_back(tmp);
    }
    
	// solve by dp
	format();
    std::cout << calcEq(N, seq[N - 1]) << std::endl;
	
    return 0;
}

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

int main() {
  int A, B, C, X, ans = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (i*500+j*100+k*50==X) {
          ans++;
        }
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
"""
最小公倍数
"""

import sys
sys.setrecursionlimit(4100000)

import math
import fractions
from functools import reduce

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def resolve():
    N, M = [int(x) for x in sys.stdin.readline().split()]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    L = lcm_list(a_list)
    if any([(L // a) % 2 == 0 for a in a_list]):
        print(0)
        return
    else:
        X = L // 2

        y = M - X
        if y < 0:
            print(0)
        else:
            print(y // (2 * X) + 1)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)


Measured memory_bytes: 99996
#include<stdio.h>

int main(){
	int i,j,k;
	int n;
	int b,f,r,v;
	int tenant[4][3][10];
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				tenant[i][j][k]=0;
			}
		}
	}
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d%d%d%d",&b,&f,&r,&v);
		tenant[b-1][f-1][r-1]+=v;
		
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",tenant[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3)printf("####################\n");
	}
	
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

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

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

int main() {
    int N, M, K; cin >> N >> M >> K;

    vector<vector<int> > F(N);
    UnionFind UF(N);
    repp(i,0,M) {
        int a, b; cin >> a >> b;
        a -= 1;
        b -= 1;
        F[a].push_back(b);
        F[b].push_back(a);
        UF.unionSet(a, b);
    }
    vector<vector<int> > B(N);
    repp(i,0,K) {
        int a, b; cin >> a >> b;
        a -= 1;
        b -= 1;
        B[a].push_back(b);
        B[b].push_back(a);
    }
    

    repp(i,0,N) {
        if (i > 0) cout << " ";
        int numB = 0;
        repp(j,0,B[i].size()) if (UF.findSet(i,B[i][j])) ++numB;
        cout << (UF.size(i) - F[i].size() - numB - 1);
    }
    cout << endl;
}



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

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

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

    vector<long> hp(N);
    rep(i, N) cin >> hp[i];

    sort(hp.begin(), hp.end());

    long sum = 0;
    for (int i = 0; i < (N - K); i++) {
        sum += hp[i];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector< pair<int,int> >vec;
	string s;
	cin>>s;
	int start;
	for(int i=0;i<n;)
	{
		if(s[i]=='0')
		{
			start=i+1;
			for(;i<n;i++)
			{
				if(s[i]!='0')
				{
					vec.push_back(make_pair(start,i));
					break;
				}
			}
		}
		else
		{
			i++;
		}
	}
	if(s[n-1]=='0')
	{
		vec.push_back(make_pair(start,n));
	}
	int size=vec.size();
	if(size<=k)
	{
		cout<<n<<endl;
		return 0;
	}/*
	cout<<size<<endl;
	for(int i=0;i<size;i++)
	{
		cout<<i<<" "<<vec[i].first<<" "<<vec[i].second<<endl;
	}*/
	int ans=0;
	for(int i=0;i<size;i++)
	{
		int j=min(i+k-1,size-1);
		int l=i == 0?0:vec[i-1].second;
		int r=j == size-1?n+1:vec[j+1].first;
//		cout<<r<<" "<<l<<endl;
		ans=max(ans,r-l-1);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	vector<string > hand(3);
	VI numhand(3);
	
	int a, b, h;
	rep(i, 3){
		cin >> hand[i];
		numhand[i] = 0;
	}
	int turn = 0;
	while (numhand[turn] != hand[turn].size()){
		numhand[turn]++;
		turn = hand[turn][numhand[turn] - 1] - 97;
	}


	cout << (turn == 0 ? "A" : (turn == 1 ? "B" : "C")) << endl;
}


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


	solve();
	system("PAUSE");
	return 0;
}

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

using namespace std;

int main(void) {
    string s;
    int q;
    cin >> s >> q;
    vector<char> ans;
    bool r = false;
    for (char c : s) ans.push_back(c);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            r = !r;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1 && !r) || f == 2 && r) {
                ans.insert(ans.begin(), c);
            } else {
                ans.push_back(c);
            }
        }
    }

    if (r) reverse(ans.begin(), ans.end());

    for (char c : ans) cout << c;
    cout << endl;

    return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;

int main(){
  int N, P, dis, ans = INT_MAX ;
  cin >> N ;
  int X[N] ;
  for(int i=0;i<N;i++){
    cin >> X[i] ;
  }  
  for(int i=1;i<=100;i++){
    P = 0 ;
    for(int j=0;j<N;j++){
      dis = X[j] - i ;
      P += dis * dis ;
    }  
    if(ans > P){
      ans = P ;
    }  
  }  
  
  cout << ans << endl ;
  return 0 ;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll abc(ll x)
{
  ll cnt_f=0,cnt_s=0;
  while(x)
  {
    ll dig=x%10;
    if(dig==4)cnt_f++;
    else cnt_s++;
    x/=10;
  }
  return (cnt_f==cnt_s);
}

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

ll n;cin>>n;
string s;cin>>s;
ll ans=0;
for(int i=0;i<n;i++)
  {
    vector<int>temp(26,0);
    ll cnt1=0;
    for(int j=0;j<i;j++)
    {
        int x=s[j]-'a';
        if(!temp[x])cnt1++;
        temp[x]++;
    }
//fill(temp.begin(),temp.end(),0);
    vector<int>lol(26);
ll cnt2=0;
    for(int k=i;k<n;k++)
    {
          int x=s[k]-'a';
          if(!lol[x])cnt2++;
          lol[x]++;
    }
    ll cnt=0;
    for(int k=0;k<26;k++)
    { 
if(lol[k]&&temp[k])cnt++;
    }
   // cout<<cnt1<<" "<<cnt2<<"\n";
    ans =max(ans,cnt);
  }

  cout<<ans<<"\n";

  return 0;



}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//下記に文字取得
		int n = sc.nextInt();//ひなあられ
		String kotei[] = {"P","W","G","Y"};//配列初期化
		String s[] = new String[n];
		int count = 0;
		for(int ii = 0;ii < n;ii++){//文字列取得
			s[ii] = sc.next();	
		}
		//System.out.println(s.length);
		for(int i = 0;i < 4;i++){
			for(int ii = 0;ii < n;ii++){
				if (kotei[i].equals(s[ii])){
					count++;
					break;
				}
			}
		}
		if(count == 4){
			System.out.println("Four");
		}else if(count == 3){
			System.out.println("Three");
		}

		
	
	}
}


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

using namespace std;

int main(){

	string s,t;
   cin>>s>>t;
   int n=s.size();
   int m=t.size();
   int dp[n+1][m+1];
   int x,y;
   memset(dp,0,sizeof(dp));
   int ans=0;

   for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
        else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        if(dp[i][j]>ans){
            ans=dp[i][j];
            x=i;
            y=j;
        }
   }
}   
    if(ans==0){
        cout<<""<<endl;
        return 0;
     
    }
     int count=1;
   string fin="";
   fin+=s[x-1];
   int i=x;
   int j=y;
   i-=1;
   j-=1;
   while(count!=ans){
        if(s[i-1]==t[j-1]){
            count++;
            fin=s[i-1]+fin;
            i--;
            j--;
        }
        else{
            if(i==0) j--;
            else if(j==0) i--;
            else{
                if(dp[i-1][j]>dp[i][j-1]) i--;
                else j--;
            }
        }
   }
   cout<<fin<<endl;
	return 0;
}

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

int Digit( long long N )
{
int i;

	if( N < 0 ) return - 1;

	i = 0;
	while( N > 0 )
	{
		i++;
		N /= 10;
	}

	return i;
}

int main()
{
long long i;
long long N;
double R;

	cin >> N;

	R = sqrt( N );
	for( i = (int) R; i >= 1; i-- )
	{
		if( N % i == 0 )
		{
			cout << Digit( N / i ) << endl;

			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <stdio.h>
using namespace std;
#define ll long long
int n;
ll mod = 1e9 + 7;
char sone[55];
char stwo[55];
vector<ll> v;
int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf(" %c", &sone[i]);
	}
	for (int i = 0; i < n; i++){
		scanf(" %c", &stwo[i]);
	}
	char prevchar = '#';
	for (int i = 0; i < n; i++){
		if (sone[i] == prevchar) continue;
		if (i != n - 1){
			if (sone[i + 1] == sone[i]){
				v.push_back(2);
			} else {
				v.push_back(1);
			}
		} else {
			v.push_back(1);
		}
		
		prevchar = sone[i];
	}
	ll ways = 1;
	for (int i = 0; i < v.size(); i++){
		if (i == 0){
			if (v[i] == 1){
				ways *= 3;
			} else {
				ways *= 6;
			}
		} else {
			if (v[i] == 1 && v[i - 1] == 1){
				ways *= 2;
			} else if (v[i] == 2 && v[i - 1] == 1){
				ways *= 2;
			} else if (v[i] == 1 && v[i - 1] == 2){
				ways *= 1;
			} else {
				ways *= 3;
			}
		}
		ways %= mod;
	}
	printf("%lld\n", ways);
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
	ll X, Y; cin >> X >> Y;
	if((X + Y) % 3 != 0 || (double)Y > 2 * (double)X || (double)Y < (double)X / 2)  {
		cout << 0 << endl;
		return 0;
	}
	ll l = max((2 * X - Y) / 3, (ll)0);
	ll s = max((2 * Y - X) / 3, (ll)0);
	
	ll fact = 1;
	for(int i = 2; i <= l + s; i++) fact = fact * i % mod;
	ll invfact1 = 1;
	for(int i = 1; i <= l; i++) invfact1 = invfact1 * modPow(i, mod - 2, mod) % mod;
	ll invfact2 = 1;
	for(int i = 1; i <= s; i++) invfact2 = invfact2 * modPow(i, mod - 2, mod) % mod;
	ll ans = fact * invfact1 % mod;
	ans = ans * invfact2 % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
p = []
x = []
for i in range(m):
    tmp = [int(i) for i in input().split()]
    p.append(tmp[0])
    x.append(tmp[1])

t_sum = sum(t)
for i in range(m):
    print(t_sum - t[p[i]-1] + x[i])


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int N, n, a[1000009];
multiset<int> s[1000009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> N;
	n = 1 << N;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s[i].insert(a[i]);
	}
	for (int i = 0; i < N; i++) {
		int cur = 1 << i;
		for (int j = 0; j < n; j++) {
			if ((cur & j) == 0) {
				for (auto x : s[j]) {
					s[cur | j].insert(x);
				}
				while (s[cur | j].size() > 2) {
					auto x = s[cur | j].begin();
					s[cur | j].erase(x);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i < n; i++) {
		auto x = s[i].begin();
		int tmp = *x;
		x++;
		tmp += *x;
		ans = max(tmp, ans);
		cout << ans << E;
	}
	//system("pause");
	return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m,k;
  cin >> n >> m >> k;
  vector<int32> a(n),b(m);
  REP(i,n)cin >> a[i];
  REP(i,m)cin >> b[i];
  vector<int64> asum(n+1,0), bsum(m+1,0);
  REP(i,n)asum[i+1] = asum[i] + a[i];
  REP(i,m)bsum[i+1] = bsum[i] + b[i];
  int32 ans = 0;
  REP(i,n+1){
    if(asum[i] > k)break;
    int32 bcnt = upper_bound(all(bsum),k-asum[i]) - bsum.begin();
    bcnt--;
    if(bcnt < 0)bcnt = 0;
    ans = max(ans, i + bcnt);
  }
  ANS(ans);
  return 0;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
typedef long long LL;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int wa[ N ], ac[ N ];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, m;
  cin >> n >> m;
  LL tot = 0;
  for (int i = 1; i <= m; i++) {
    int id;
    string s;
    cin >> id >> s;
    if (s == "WA") {
      wa[id]++;
    }
    else {
      ac[id]++;
      if (ac[id] == 1) tot += wa[id];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (ac[i]) ans++;
  }
  cout << ans << " " << tot << endl;
  return 0;
}



Measured memory_bytes: 1024
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

	using i8 = std::int_least8_t;
	using i32 = std::int_least32_t;
	using i64 = std::int_least64_t;
	using u8 = std::uint_least8_t;
	using u32 = std::uint_least32_t;
	using u64 = std::uint_least64_t;
	using isize = std::ptrdiff_t;
	using usize = std::size_t;

	class rep {
		const usize f, l;

	public:
		class itr {
			friend rep;
			usize i;
			constexpr itr(const usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { ++i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr rep(const usize first, const usize last) noexcept
			: f(first), l(last) {}
		constexpr itr begin() const noexcept { return itr(f); }
		constexpr itr end() const noexcept { return itr(l); }
	};
	class revrep {
		const usize f, l;

	public:
		class itr {
			friend revrep;
			usize i;
			constexpr itr(usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { --i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
		constexpr itr begin() const noexcept { return itr(l); }
		constexpr itr end() const noexcept { return itr(f); }
	};
	template <class T> using vec_alias = std::vector<T>;
	template <class T> auto md_vec(const usize n, const T &value) {
		return std::vector<T>(n, value);
	}
	template <class... Args> auto md_vec(const usize n, Args... args) {
		return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
	}
	template <class T> constexpr T difference(const T &a, const T &b) {
		return a < b ? b - a : a - b;
	}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

	void main_() {
		usize n;
		std::cin >> n;
		std::vector<usize> b(n);
		for (auto &e : b) {
			std::cin >> e;
			--e;
		}
		for (const auto i : rep(0, n)) {
			if (b[i] > i) {
				std::cout << "-1" << std::endl;
				return;
			}
		}
		std::vector<usize> ans;
		for (const auto len : revrep(0, n)) {
			for (const auto i : revrep(0, b.size())) {
				if (b[i] == i) {
					ans.emplace(ans.begin(), i);
					b.erase(b.begin() + i);
					break;
				}
			}
			if (b.size() != len) {
				std::cout << "-1" << std::endl;
				return;
			}
		}
		for (const auto e : ans) {
			std::cout << e + 1 << std::endl;
		}
	}

} // namespace n91

int main() {
	n91::main_();
	return 0;
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b,c = map(int,input().split())
    if b - a == c - b:
        print('YES')
    else:
        print("NO")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
data SegmentTree m = Leaf m  | Node m (SegmentTree m) (SegmentTree m) Int
    deriving (Eq, Show)

val :: SegmentTree m -> m
val (Leaf v)     = v
val (Node v _ _ _) = v

update :: (Monoid m) => SegmentTree m  -> Int -> m -> SegmentTree m
update (Leaf v) _ x = Leaf x
update (Node v l r size)  i x
    | i < n'   =   Node (val left `mappend` val r) left r size
    | otherwise =   Node (val l `mappend` val right) l right size
    where n' = size `div` 2
          left = update l  i x
          right = update r (i-n') x


query :: (Monoid m) => SegmentTree m -> Int -> Int -> m

query (Leaf v) 0 1 = v
query (Node v l r size) a b
    | a >= b    = mempty
    | a == 0 && b == size   = v
    | b <= n'             = query l  a b
    | a >= n'                = query r  (a-n') (b-n')
    | otherwise             = query l  a n' `mappend` query r 0 (b-n')
    where n' = size `div` 2

resize :: Int -> Int -> Int
resize n m
    | m < n = resize n (2*m)
    | otherwise  = m

fromList :: Monoid m => [m] -> SegmentTree m
fromList xs =
    let 
        fromList' _ 0 = Leaf mempty
        fromList' [x] 1 = Leaf x
        fromList' xs n = Node (val left `mappend` val right) left right n
          where n' = n `div` 2
                (xs1,xs2) = splitAt n' xs
                left = fromList'  xs1 n'
                right = fromList' xs2 (n-n')
        n = length xs
        m = resize n 1
        plus = replicate (m-n) mempty
        xs' = xs ++ plus
    in fromList' xs' m



get :: Monoid m => SegmentTree m -> Int -> m
get tree i= query tree i (i+1)

newtype Gcd = Gcd Int deriving (Eq,Ord,Read)

instance Show Gcd where
  show (Gcd x) = show x
instance Semigroup Gcd where
  Gcd x <> Gcd y = Gcd (gcd x y)

instance Monoid Gcd where
  mempty = Gcd 0

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- read <$> getLine
  a <- map Gcd <$> getIntList
  let seg = fromList a
  print $ maximum $ [query seg 0 i <> query seg (i+1) n | i <- [0..n]]

Measured memory_bytes: 36024
#include<iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	char str[10] = { }, ans[10] = { };
	int count = 0, i, j = 0;
	
	cin >> str;

	while (str[j]) {
		j++;
	}

	for (i = 0; i < j; i++) {
		if (str[i] == '0') 
			ans[count] = '0';
		
		else if (str[i] == '1') 
			ans[count] = '1';
		
		else {
			if (count != 0) {
				ans[count - 1] = ' ';
				count-=2;
			}
			else count--;
		}
		count++;
	}
	i = 0;
	while (count > i)
	{
		cout << ans[i];
		i++;
	}

	putchar('\n');

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque

S = input()

# スタックを用いた解法
# ()の整合性判定にも使える

que = deque()
res = 0
for d in S:
    if len(que) == 0:
        que.append(d)
    elif que[-1] != d:  # 01 or 10
        res += 2
        que.pop()   # ペアを作成
    else:
        que.append(d)

print(res)


Measured memory_bytes: 4212