akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int h,w;cin>>h>>w;
    char hw[1050][1050];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>hw[i][j];
        }
    }
    ll ans=0;
    ll dp[1050][1050];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<h;i++){
        if(hw[i][0]=='#'){
            break;
        }
        else{
            dp[i][0]=1;
        }
    }
    for(int j=1;j<w;j++){
        if(hw[0][j]=='#'){
            break;
        }
        else{
            dp[0][j]=1;
        }
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(hw[i][j]=='.'){
                chmax(dp[i][j],dp[i-1][j]+dp[i][j-1]);
                dp[i][j]%=MOD;
            }
            else
                continue;
        }
    }
    cout<<dp[h-1][w-1]%MOD<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 9984
(function (input) {
    var decodeMCXI = function() {
        var cache = {},
            table = {
                "m": 1000,
                "c": 100,
                "x": 10,
                "i": 1
            };
        return function(str) {
            // 文字列はこの順番で来ると仮定
            var keyword = ["m", "c", "x", "i"],
                sum = 0;
            keyword.forEach(function(k) {
                var index = str.indexOf(k),
                    s;
                if ( index >= 0 ) {
                    // 先頭から一致したキーワードまで取り出す
                    // 前置数に関係なくまとまりが取れる
                    s = str.slice(0, index + 1);
                    // キャッシュがあれば利用
                    if ( !cache[s] ) {
                        // 前置詞付きなら
                        if ( s.length == 2 ) {
                            var placeholder = parseInt(s[0]),
                                n = table[s[1]];
                        } else {
                            var placeholder = 1,
                                n = table[s[0]];
                        }
                        cache[s] = placeholder * n;
                    }
                    sum += cache[s];
                    str = str.replace(s, '');   // 取得した文を削除
                }
            });
            return sum;
        };
    }();
    function encodeMCXI(num) {
        var placeholder, n, result = '';
        if ( num >= 1000 ) {
            placeholder = ~~(num / 1000);
            result += ( placeholder > 1 ? placeholder : '' ) + 'm';
            num %= 1000;
        }
        if ( num >= 100 ) {
            placeholder = ~~(num / 100);
            result += ( placeholder > 1 ? placeholder : '' ) + 'c';
            num %= 100;
        }
        if ( num >= 10 ) {
            placeholder = ~~(num / 10);
            result += ( placeholder > 1 ? placeholder : '' ) + 'x';
            num %= 10;
        }
        if ( num > 0 ) {
            result += ( num > 1 ? num : '' ) + 'i';
        }
        return result;
    }

    var inputs = input.replace(/\r/g, '').split("\n"),
        n;

    n = parseInt(inputs.shift());

    for ( var i = 0; i < n; i++ ) {
        var line = inputs.shift().split(' '),
            a = decodeMCXI(line[0]),
            b = decodeMCXI(line[1]);
        console.log(encodeMCXI(a+b));
    }
})(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;
int x[maxn];
int y[maxn];
int z[maxn];
ll num[maxn];
ll sum[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(int i=0;i<n;i++)
        scanf("%d",&y[i]);
    for(int i=0;i<n;i++)
        scanf("%d",&z[i]);
    sort(z,z+n);
    sort(y,y+n);
    int xx;
    for(int i=0;i<n;i++)
    {
        xx=upper_bound(z,z+n,y[i])-z;
        num[i]=n-xx;
    }
    sum[n-1]=num[n-1];
    for(int i=n-2;i>=0;i--)
        sum[i]=sum[i+1]+num[i];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        xx=upper_bound(y,y+n,x[i])-y;
        ans+=sum[xx];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2944
A,B,K=map(int,input().split())
answers=[]
for a in range(K):
    if A+a<=B and not A+a in answers:
        answers.append(A+a)
for b in range(K):
    if B-b>=A and not B-b in answers:
        answers.append(B-b)
answers=sorted(answers)
for a in answers:
    print(a)
    

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int cnt[100000];
int n,k;

void add(int x,int t){//(x+??)/k%2=t
	if((x_div_k[x]&1)==0){
		if(t==0){//たさない
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{//たす
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
signed main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	rep(i,k){
		memset(cnt,0,sizeof(cnt));
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){//(y[j]+t)/K%2=0
					add(j,0);
				}
				else{
					add(j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){//(y[j]+t)/K%2=1
					add(j,1);
				}
				else{
					add(j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			Max=max({Max,cnt[j],n-cnt[j]});
		}
	}
	cout<<Max<<endl;
}

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

int main(){
    int N,X;
    cin >> N >> X;
    int num,tmp;
    rep(i,N){
        cin >> tmp;
        if(i==0) num=abs(X-tmp);
        else num = __gcd(num,abs(X-tmp));
    }

    cout << num << endl;
        
}

Measured memory_bytes: 384
def factorize(n):
  i = 2
  m = n
  factors = []
  
  while i*i <= m:
    if m%i==0:
      m //= i
      factors.append(i)
    else:
      i += 1

  if m > 1:
    factors.append(m)

  return factors

n = int(input())
primes = factorize(n)
print("{0}: {1}".format(n, " ".join(list(map(str,primes)))))


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

typedef long long ll;

const int N = 3e5 + 10;

int n;
ll ans, ans2, ans3, a[N];

int main(){
	cin >> n;
	for(int i = 1; i <= 3 * n; ++ i){
		cin >> a[i];
	}
	sort(a + 1, a + n * 3 + 1);
	for(int i = n + 1; i <= n * 2; ++ i){
		ans += a[i];
	}
	for(int i = 2; i <= n * 3; i += 3){
		ans2 += a[i];
	}
	for(int i = n * 3 - 1; i > n; i -= 2){
		ans3 += a[i];
	}
	cout << max(max(ans, ans2), ans3);
	return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
int main()
{
	int a, b, c;
	int temp;

	scanf("%d %d %d", &a, &b, &c);
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b>c)
	{
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
		printf("%d %d %d\n",a,b,c);
	
	return 0;
}



Measured memory_bytes: 2760
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int ans = 0;
	int k, s;
	cin >> k >> s;
	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (s - i - j >= 0 && s - i - j <= k)
				ans++;
		}

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

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

int main() {
  int k,a,b=0;
  cin>>k>>a>>b;
  int sum=0;
  
  while(sum<=b){
    sum+=k;
    if(sum>=a&&sum<=b){
      cout<<"OK";
      return 0;
    }
  }
  cout<<"NG";
  return 0;
}

Measured memory_bytes: 3620
m,a,r,c,h = 0,0,0,0,0
for i in range(int(input())):
    s=input()
    if s[0] == 'M': m+=1
    if s[0] == 'A': a += 1
    if s[0] == 'R': r += 1
    if s[0] == 'C': c += 1
    if s[0] == 'H': h += 1

l=[m,a,r,c,h]
res=0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            res+=l[i]*l[j]*l[k]

print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s;
	cin >> s;
	int ans = MOD, coun = 0;
	for (int i = 0; i < s.length(); i++){
		if (i%2){
			if (s[i] == '0') coun++;
		}else{
			if (s[i] == '1') coun++;
		}
	}
	ans = min(ans, coun);
	coun = 0;
	for (int i = 0; i < s.length(); i++){
		if (i%2){
			if (s[i] == '1') coun++;
		}else{
			if (s[i] == '0') coun++;
		}
	}
	ans = min(ans, coun);
	cout << ans << endl;
 	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}


//入力
int r, d;
int x[20];


int main(){

    cin >> r >> d;
    cin >> x[0];

    for(int i = 1; i <= 10; i++){
        x[i] = r * x[i-1] - d;
    }

    for(int i = 1; i <= 10; i++) cout << x[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long

int main() {
	ll a, b, m = 0;
	cin >> a >> b;
	if (a > b) {
		m += a;
		a--;
	}
	else {
		m += b;
		b--;
	}
	if (a > b) {
		m += a;
		a--;
	}
	else {
		m += b;
		b--;
	}
	cout << m << endl;
}

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

using namespace std;

const double inf = 1e8;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

int main(){
    int T, D, tA, tB, dA, dB;
    cin >> T >> D >> tA >> tB >> dA >> dB;
    double ans = inf;
    for(int vA=0; vA<=D; vA+=dA){
        for(int vB=0; vA+vB<=D; vB+=dB){
            if(vA + vB == 0)continue;
            chmin(ans, abs(T - 1.0 * (tA * vA + tB * vB) / (vA + vB)));
        }
    }
    cout << fixed << setprecision(12) << ans << '\n';
    return 0;
}

Measured memory_bytes: 1240
"""Range Minimum Query (RMQ)"""
# 丁寧に実装する


# 配列のidx番目の要素の値をxに変更する, 1点更新
def update(idx, x):
    idx += size-1  # 配列のidx番目の要素に対応するseg木のノードのindex
    seg[idx] += x  # 対象のノードの値を更新する
    # 親のノードの値も更新する
    while idx > 0:
        idx = (idx-1)//2  # ノードidxの親のindex, いつか0になる
        seg[idx] = seg[2*idx+1] + seg[2*idx+2]  # 左右の子を見てminを計算する
    # 根ノードであるノード0まで修正したのでreturnする
    return


# この関数は半開区間[a, b)に対するクエリについて最小値を答えるもの
def query(a, b, k, l, r):  # 半開区間[a, b)に対するクエリについて、ノードk(担当している半開区間[l, r))が答える
    # 最初は根に質問を飛ばしている
    if r <= a or b <= l:  # ノードkの担当区間は[l, r)であり、この条件を満たすときは求めたい区間[a, b)と範囲が全く被っていない
        return INF  # 区間が被らない場合は単位元(minの単位元はINF)
    if a <= l and r <= b:
        return seg[k]  # ノードkの担当範囲が求めたい区間[a, b)に完全に含まれる場合はそのノードも持っている値をそのまま返す
    else:
        # 一部だけ範囲が被るような場合は左右の子に委託する
        c1 = query(a, b, 2*k+1, l, (l+r)//2)  # 左の子に値を聞く
        c2 = query(a, b, 2*k+2, (l+r)//2, r)  # 右の子に値を聞く
        return c1 + c2  # 左右の子のminを取る


N, Q = map(int, input().split())  # 配列のサイズ(管理したい要素の数), クエリの個数
size = 1  # seg木の葉の個数
while N > size:
    size *= 2  # seg木の葉の個数を計算する, N以上の最小の2冪数, 末端に来る葉の数が2の冪数でないと、seg木の構造がおかしくなる

# 単位元
# INF = float('inf')
INF = 0  # 今回の問題設定
# seg木を単位元で初期化する
seg = [INF]*(2*size-1)

for _ in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        x -= 1
        update(x, y)
    else:
        x -= 1
        y -= 1
        print(query(x, y+1, 0, 0, size))  # ノード0(担当している半開区間[0, size))にクエリを投げる
        # y+1としているのは、半開区間とかの関係



Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  bool flag = true;
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for (int64_t i = 0LL; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int64_t i = 0LL; i < N - 1; i++) {
    if (vec.at(i) == vec.at(i + 1)) {
      cout << "NO" << endl;
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    string s, t;cin >> s >> t;
    for(int i=n;i>=0;i--){
        if(s.substr(n-i, i) == t.substr(0, i)){
            cout << i + 2*(n-i) << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
   int H, W;
   cin >> H >> W;
   string s[50];
   int dx[8] = {1,0,-1,0,1,-1,-1,1};
   int dy[8] = {0,1,0,-1,1,1,-1,-1};

   //入力
   for(int i=0; i<H; i++) {
      cin >> s[i];
   }

   for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
         int count = 0;
         if(s[i][j] == '#') {
            cout << '#';
            continue;
         }
         for(int k=0; k<8; k++) {
            int ni = i + dy[k];
            int nj = j + dx[k];
            if (ni < 0 or H <= ni) continue;
            if (nj < 0 or W <= nj) continue;
            if(s[ni][nj] == '#') {
               count++;
            }
         }
         cout << count;
      }
      cout << endl;
   }
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, m;
    cin >>n>>m;

    vector<ll> a(m), b(m);

    rep(i,0,m)
        cin >> a[i] >> b[i], a[i]--, b[i]--;

    vector<ll> r(n, 0);

    rep(i,0,m)
        r[a[i]]++, r[b[i]]++;
       
    rep(i,0,n)
        cout << r[i] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;



public class Main {
    public static int[] ints;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        final int N=scanner.nextInt();
        ints=new int[N];
        for(int i=0;i<N;i++){
            ints[i]=scanner.nextInt();
        }
        if(ints[0]!=0){
            System.out.println(-1);
            return;
        }
        for(int i=0;i<N-1;i++){
            if(ints[i+1]-ints[i]>=2){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(func(N-1,0));
    }
    public static long func(int endIndex,long val){
        if(endIndex==0){
            return val;
        }else{
            if(ints[endIndex]==0) return func(endIndex-1,val);
            int endVal=ints[endIndex];
            val+=endVal;
            while(ints[endIndex]==endVal){
                endIndex--;
                endVal--;
                if(endIndex==0) break;
            }
            return func(endIndex,val);
        }
    }

}

Measured memory_bytes: 87372
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC141A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            if (S == "Sunny") Console.WriteLine("Cloudy");
            else if (S == "Cloudy") Console.WriteLine("Rainy");
            else Console.WriteLine("Sunny");


            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 11092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CVacation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            int[][] ar = new int[n][3];
            int[][] dp = new int[n][3];
            for (int i = 0; i < n; ++i) {
                ar[i][0] = in.ni();
                ar[i][1] = in.ni();
                ar[i][2] = in.ni();
            }
            dp[0][0] = ar[0][0];
            dp[0][1] = ar[0][1];
            dp[0][2] = ar[0][2];
            for (int i = 1; i < n; ++i) {
                for (int j = 0; j < 3; ++j) {
                    for (int j1 = 0; j1 < 3; ++j1) {
                        if (j1 != j)
                            dp[i][j] = Math.max(dp[i][j], dp[i - 1][j1] + ar[i][j]);
                    }
                }
            }
            int ans = 0;
            for (int i = 0; i < 3; ++i) {
                ans = Math.max(ans, dp[n - 1][i]);
            }
            out.print(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 52580
def solve(string):
    x1, y1, x2, y2 = map(int, string.split(" "))
    x3 = x2 - y2 + y1
    y3 = y2 + x2 - x1
    x4 = x1 - y2 + y1
    y4 = y1 + x2 - x1
    return str("{} {} {} {}".format(x3, y3, x4, y4))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using Vl = vector<ull>;
#define rep(i, ns, ne) for (ull i = ns; i < ne; ++i)

int N;
Vl v;

void input() {
  cin >> N;
  v.resize(N);
  for (auto &e : v) cin >> e;
  sort(v.begin(), v.end());
}

void solve() {
  unsigned ans = 0;
  for (ull i = 0; i < N; ++i) {
    for (ull j = 0; j < i; ++j) {
      for (ull k = 0; k < j; ++k) {
        if ((v[i] != v[j]) && (v[j] != v[k]) && (v[i] < v[j] + v[k])) ans++;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  solve();
  getchar();
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  bool t[25][25];
  while(true){
    int n,m,x,y;
    cin>>n;
    if(n==0) break;    
    rep(i,25) rep(j,25) t[i][j]=false;
    rep(i,n){
      cin>>x>>y;
      t[x][y]=true;
    }
    cin>>m;
    x=10,y=10;
    t[10][10]=false;
    rep(i,m){
      char c;
      int d;
      cin>>c>>d;
      if(c=='N'){
        for(int j=y+1;j<=y+d;j++) t[x][j]=false;
        y+=d;
      }
      if(c=='S'){
        for(int j=y-1;j>=y-d;j--) t[x][j]=false;
        y-=d;
      }
      if(c=='E'){
        for(int i=x+1;i<=x+d;i++) t[i][y]=false;
        x+=d;
      }
      if(c=='W'){
        for(int i=x-1;i>=x-d;i--) t[i][y]=false;
        x-=d;
      }
      //cout<<x<<" "<<y<<endl;
    }
    bool ans=false;
    rep(x,25) rep(y,25) ans|=t[x][y];
    if(ans) puts("No");
    else puts("Yes");
  }
  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
typedef unsigned long long ull;

int n;
int d[MAXN][3];
ull m[MAXN][3];
bool v[MAXN][3];

ull dp(int a, int p){
	if(p==n)
		return 0;
	if(v[p][a])
		return m[p][a];
	ull tmp;
	if(a==0)
		tmp=max(d[p][a]+dp(1,p+1),d[p][a]+dp(2,p+1));
	else if(a==1)
		tmp=max(d[p][a]+dp(0,p+1),d[p][a]+dp(2,p+1));
	if(a==2)
		tmp=max(d[p][a]+dp(0,p+1),d[p][a]+dp(1,p+1));
	m[p][a]=tmp;
	v[p][a]=1;
	return tmp;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>d[i][0]>>d[i][1]>>d[i][2];
	ull d1=dp(0,0);
	ull d2=dp(1,0);
	ull d3=dp(2,0);
	cout<<max(max(d1,d2),d3);
}

Measured memory_bytes: 8704
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int G = 5;
const int MAX_M = 27;

/* typedef */

/* global variables */

int n, m1, m2;
int grids[2][G][G][G];
int as[MAX_M], bs[MAX_M];

/* main */

int main() {
  for (int cn = 1;; cn++) {
    cin >> n;
    if (n == 0) break;

    memset(grids, 0, sizeof(grids));
    
    for (int z = 0; z < G; z++) {
      string s;
      for (int y = 0; y < G; y++) {
	cin >> s;
	//cout << s << endl;
	for (int x = 0; x < G; x++)
	  grids[0][z][y][x] = s[x] - '0';
      }
    }

    cin >> m1;
    for (int i = 0; i < m1; i++) cin >> as[i];
    cin >> m2;
    for (int i = 0; i < m2; i++) cin >> bs[i];

    sort(as, as + m1);
    sort(bs, bs + m2);

    for (int d = 0; d < n; d++) {
      int cur = d & 1;
      int nxt = cur ^ 1;

      for (int z = 0; z < G; z++)
	for (int y = 0; y < G; y++)
	  for (int x = 0; x < G; x++) {
	    int c = 0;
	    for (int dz = -1; dz <= 1; dz++) {
	      int z0 = z + dz;
	      if (z0 < 0 || z0 >= G) continue;
	      for (int dy = -1; dy <= 1; dy++) {
		int y0 = y + dy;
		if (y0 < 0 || y0 >= G) continue;
		for (int dx = -1; dx <= 1; dx++) {
		  int x0 = x + dx;
		  if (x0 < 0 || x0 >= G) continue;
		  if (dx == 0 && dy == 0 && dz == 0) continue;
		  c += grids[cur][z0][y0][x0];
		}
	      }
	    }

	    if (grids[cur][z][y][x] == 0) {
	      int i = lower_bound(as, as + m1, c) - as;
	      grids[nxt][z][y][x] = (i < m1 && as[i] == c) ? 1 : 0;
	    }
	    else {
	      int i = lower_bound(bs, bs + m2, c) - bs;
	      grids[nxt][z][y][x] = (i < m2 && bs[i] == c) ? 1 : 0;
	    }
	  }
    }

    if (cn > 1) cout << endl;
    printf("Case %d:\n", cn);

    for (int z = 0; z < G; z++) {
      if (z > 0) cout << endl;
      for (int y = 0; y < G; y++) {
	for (int x = 0; x < G; x++) cout << grids[n & 1][z][y][x];
	cout << endl;
      }
    }
  }

  return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int m,n,x,ans=0;
    string s;
    set<int>st;
    map<int,bool>mp;
    MII cnt;
    cin >> n >> m;
    while(m--)
    {
        cin >> x >> s;
        if(s[0] == 'A')
        {
            st.insert(x);
            if(mp.find(x) == mp.E)ans+=cnt[x];
            mp[x]=1;
        }
        else ++cnt[x];
    }
    cout << (int)st.SZ << ' ' << ans;
    return 0;
}


Measured memory_bytes: 14336
N = int(input())
A = list(map(int, input().split()))
ttl1, ttl2, ttl3 = 0, 0, 0
avarage1 = -(-sum(A) // N)
avarage2 = sum(A) // N
for i in A:
    ttl1 += (i - avarage1) ** 2
    ttl2 += (i - avarage2) ** 2
print(min(ttl1, ttl2))


Measured memory_bytes: 3060
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
from itertools import permutations
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
sw = []
count = 0
d = defaultdict(int)

for i in range(m):
    p = readl()
    sw.append(p[1:])
p = readl()
count = 0
for i in range(2 ** n):
    den = defaultdict(int)
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                if j + 1 in sw[k]:
                    den[k] += 1
    flg = True
    for j in range(m):
        if den[j] % 2 != p[j]:
            flg = False
    if flg:
        count += 1
print(count)

Measured memory_bytes: 6096
import math
k,a,b = map(int,input().split())

t = k
cnt = 1

#ビスケットと1円を交換したほうがいい時
if a+1<b:
    #1回1円と交換できるようになるまでビスケットを増やす
    cnt += a-1
    t -= a-1
    #print(cnt)
    #print(t)
    #ビスケットと1円を交換→1円とビスケットを交換を限界まで繰り返す
    cnt += b*math.floor(t/2)
    cnt -= a*math.floor(t/2)
    t -= 2 * math.floor(t/2)
    #print(cnt)
    #print(t)
    #ビスケットをたたいて増やす
    cnt += t
else:
    cnt +=k
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  string s;
  s = to_string(a) + to_string(b);
  int num = atoi(s.c_str());
  int k = pow(num, 0.5);
  if(k * k == num){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
import heapq

N, M = map(int,input().split())
J = [[] for k in range(M+1)]
for k in range(N):
    A, B = map(int,input().split())
    if A <= M:
        J[A].append(B)

Q = []
ans = 0
for d in range(1,M+1):
    for e in J[d]:
        heapq.heappush(Q,-e)
    if len(Q) > 0:
        ans += -heapq.heappop(Q)
print(ans)


Measured memory_bytes: 72608
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    int A = a + b;
    int B = a - b;
    int C = a * b;

    if (A > B) {
        if (A > C) cout << A << endl;
        else cout << C << endl;
    } else if (B > A) {
        if (B > C) cout << B << endl;
        else cout << C << endl;
    } else if (C > A) {
        if (C > B) cout << C << endl;
        else cout << B << endl;
    } else cout << A << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int K;
  cin >> K;
  ll ans = 0;
  for(int i = 1; i <= K; i++){
    for(int j = 1; j <= K; j++){
      for(int k = 1; k <= K; k++){

        ans += gcd(gcd(i, j), k);
        
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

    int n = S.size();
    int64_t sum = 0;
    for(int bit=0; bit<(1 << n-1); bit++){
        int64_t tmp = 0;
        for(int i=0; i<n; i++){
            tmp = tmp * 10 + S.at(i) - '0';
            if(bit & (1 << i)){
                sum += tmp;
                tmp = 0;
            }
        }
        sum += tmp;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

bool startsWith(const std::string &S, unsigned pos, const std::string &T)
{
  if (pos + T.size() > S.size()) return false;
  
  for (std::string::size_type i = 0; i < T.size(); ++i) {
    if (S[pos + i] != T[i]) return false;
  }

  return true;
}

const std::string Dream   = "dream";
const std::string Dreamer = "dreamer";
const std::string Erase   = "erase";
const std::string Eraser  = "eraser";

bool judge(const std::string &S)
{
  std::vector<unsigned> dp(200010, 0);
  dp[0] = 1;
  
  for (unsigned i = 0; i < S.size(); ++i) {
    if (startsWith(S, i, Dream)) {
      dp[i + Dream.size()] += dp[i];
    }
    
    if (startsWith(S, i, Dreamer)) {
      dp[i + Dreamer.size()] += dp[i];
    }
    
    if (startsWith(S, i, Erase)) {
      dp[i + Erase.size()] += dp[i];
    }
    
    if (startsWith(S, i, Eraser)) {
      dp[i + Eraser.size()] += dp[i];
    }
  }
  
  return dp[S.size()] > 0;
}

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

  std::cout << (judge(S) ? "YES" : "NO") << std::endl;
  
  return 0;
}

Measured memory_bytes: 1280
using System;
using System.Text;


namespace ABC126
{
    class Program
    {
        static int Main(string[] args)
        {
            ProblemC();
            return 0;
        }

        static void ProblemC()
        {
            string[] input = System.Console.ReadLine().Split(' ');
            double N = int.Parse(input[0]);
            double K = int.Parse(input[1]);
            double victory;
            victory = 0;

            for(int i = 1; i < N +1; i++)
            {
                //コインを振らずとも勝てる
                if (i > K)
                {
                    double a = 1 / N;
                    victory += a;
                }
                //コインで数回連続で勝つ必要がある
                else
                {
                    int tmp;
                    tmp = (int)Math.Ceiling(Math.Log(K/i, 2));
                    double a, b;
                    a = (double)(1 / N);
                    b = (double)((1 / (Math.Pow(2, tmp))));
                    victory += a*b;
                }
            }

            Console.WriteLine(victory);
        }
    }
}

Measured memory_bytes: 11476
import Foundation

/*
// 1
let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let S = Int(split[1])!

// 1 2 3 4 5
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
*/

let S = readLine()!
let length = S.characters.count
let front = S.endIndex.advancedBy(-length / 2 - 1)
let back = S.startIndex.advancedBy(length / 2 + 1)

if S.substringToIndex(front) == S.substringFromIndex(back) {
  print("Yes")
} else {
  print("No")
}

Measured memory_bytes: 7524
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	map<char, int> c;
	REP(i, n)
		c[s[i]]++;
	ll res = 1;
	for (auto x : c) {
		res *= x.second + 1;
		res %= MOD;
	}
	cout << res - 1 << '\n';
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define MOD 1000000007LL
#define INF 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,cap,rev,ng;
	edge(){}
	edge(int tt,int cc,int rr,int nng){
		to=tt;
		cap=cc;
		rev=rr;
		ng=nng;
	}
};

vector<edge> G[10000];
vector<int> id[10001];
int level[10000];
int iter[10000];
bool used[10001];

void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size(),cap));
	if(cap==1)id[from].push_back(G[from].size()-1);
	G[to].push_back(edge(from,cap,G[from].size()-1,cap));
	if(cap==1)id[to].push_back(G[to].size()-1);
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(que.size()){
		int v=que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f){
	if(v==t)return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e=G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
			int d=dfs(e.to,t,min(e.cap,f));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,INF))>0){
			flow+=f;
		}
	}
}

bool get_path(int v,int t,int p){
	if(v==t)return true;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i].cap>0 && p!=G[v][i].to && !used[G[v][i].to]){
			if(get_path(G[v][i].to,t,v))return true;
		}
	}
	return false;
}


int n,m;

int s[5005],t[5005],c[5005];
int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&s[i],&t[i],&c[i]);
		add_edge(s[i],t[i],c[i]);
	}
	int val=max_flow(0,n-1);
	/*
	for(int i=0;i<n;i++){
		G[i].clear();
	}
	for(int i=0;i<m;i++){
		if(c[i]>=2)add_edge(s[i],t[i],c[i]);
		else add_edge(s[i],t[i],0);
	}
	int val2=max_flow(0,n-1);
	if(val!=val2)val--;
	*/
	bool flag2=false;
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<id[i].size();j++){
			cnt++;
			if(G[i][id[i][j]].cap==0){
				memset(used,false,sizeof(used));
				if(!flag2 && !get_path(i,G[i][id[i][j]].to,-1)){
					flag2=true;
					val--;
				}
			}
		}
	}
	printf("%d\n",val<=10000?val:-1);
	return 0;
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  cout << v[0] + v[1] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int len = 0;
		while(x  <= y) {
			len++;
			x *= 2;
		}
		System.out.println(len);
	}

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  double d = 0, m = 900000000.0;
  cin >> n >> k;
  vector<int> p(n);
  vector<double> t(n);
  for(int i = 0; i < n; i++) {
    cin >> p.at(i);
    t.at(i) = (p[i] + 1) / 2.0;
    if(i < k) {
      d += t[i];
      m = d;
    } else {
      d += t[i];
      d -= t[i - k];
      m = max(d, m);
    }
  }
  cout << setprecision(8) << m << "\n";
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define vb vector<bool>
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }

const int maxn=100005;
vi G[maxn];
bool visited[maxn];
ll dp[maxn];

int dfs(int src)
{
    if(dp[src]) return dp[src];
    if(G[src].empty()) return dp[src]= 0;

    int len=0;

    for(auto v: G[src])
    {
        len = max( len , 1 + dfs(v) );
    }
    return dp [src] = len;
}

int main()
{
    fast_cin
    int n,m;

    cin>>n>>m;
    for(int i = 1 ; i <= m ; i++)
    {
        int u,v;
        cin >> u >> v;
        G[u].pb(v);
    }

    for(int i=n;i>=1;i--)
   {
       if(G[i].size())//there is an edge leading from this to v.
           dfs(i);
   }
   cout << *max_element(dp,dp+n+1)<<endl;
}


Measured memory_bytes: 7936
#include <iostream>
using namespace std;
int main(){
  int k,t;cin>>k>>t;
  int a[t];
  for(int i = 0; t > i; i++){
    cin>>a[i];
  }
  int prev = -1;
  for(int i = 0; k > i; i++){
    int mx = 0;
    int nwp = 0;
    for(int j = 0; t > j; j++){
      if(prev != j){
        if(a[j] > mx){
          mx = a[j];
          nwp = j;
        }
      }
    }
    if(mx == 0){
      cout << k-i << endl;
      return 0;
    }
    a[nwp]--;
    prev = nwp;
  }
  cout << 0 << endl;
}
        
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i,m) cin >> p[i] >> s[i];
  vector<int> wa(n);
  vector<int> ac(n);
  rep(i,m) {
    if (ac[p[i]-1]) continue;
    if (s[i] == "WA") wa[p[i]-1]++;
    else ac[p[i]-1]++;
  }
  int cwa = 0;
  int cac = 0;
  rep(i,n) {
    if (ac[i]) {
      cac++;
      cwa += wa[i];
    }
  }
  cout << cac << " " << cwa << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 7460
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {

		str := sc.Text()

		if str == "END OF INPUT" {
			break
		}

		strs := strings.Split(sc.Text(), " ")

		for _, s := range strs {
			fmt.Print(len(s))
		}

		fmt.Println()
	}

}


Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    long long counter = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0  && i % 5 != 0)
            counter += i;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3636
N, K = map(int, input().split())
A = list(map(int, input().split()))
x = len(set(A))
if x <= K:
    print(0)
    exit()
import collections
C = collections.Counter(A)
x -= K
result = 0
for c in C.most_common()[::-1]:
    if x == 0:
        print(result)
        exit()
    result += c[1]
    x -= 1

Measured memory_bytes: 49980
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(b>c){
		cout<<"0"<<endl;
		return 0;
	}
	if(a==1){
		if(b==c){
		cout<<"1"<<endl;
		}
		else cout<<"0"<<endl;
		return 0;
	}
	a-=2;
	cout<<a*(c-b)+1<<endl;
	return 0;
}

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

template<class RandomAccessIterator>
void merge_sort(RandomAccessIterator first, RandomAccessIterator last, size_t& ans){
    auto n = last - first;
    if(n <= 1)return;
    merge_sort(first, first + n / 2, ans);
    merge_sort(first + n / 2, last, ans);
    auto f = first, m1 = first + n / 2, m2 = first + n / 2, l = last;
    while(m1 != f){
        while(m2 != l && *f > *m2)++m2;
        ans += m2 - m1;
        ++f;
    }
    std::inplace_merge(first, first + n / 2, last);
}

int main(){
    using namespace std;
    size_t n;
    cin >> n;
    vector<size_t> a(n);
    for(auto& i : a)cin >> i;
    size_t ans{0};
    merge_sort(a.begin(), a.end(), ans);
    cout << ans << endl;
}


Measured memory_bytes: 5572
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int R[6][6] = {
    { 4, 0, 2, 1, 3, 5 },
    { 2, 1, 3, 5, 4, 0 },
    { 5, 1, 0, 2, 4, 3 },
    { 1, 3, 2, 4, 0, 5 },
    { 0, 5, 1, 3, 2, 4 },
    { 0, 2, 4, 3, 5, 1 }
  };
  map<string, int> T;
  T["North"] = 0;
  T["East"] = 1;
  T["West"] = 2;
  T["South"] = 3;
  T["Right"] = 4;
  T["Left"] = 5;
  for (;;) {
    int n, r = 1, t[6], d[6];
    cin >> n;
    if (!n) return 0;
    d[0] = 1;
    d[1] = 2;
    d[2] = 3;
    d[3] = 6;
    d[4] = 5;
    d[5] = 4;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      for (int i = 0; i < 6; i++)
        t[R[T[s]][i]] = d[i];
      for (int i = 0; i < 6; i++)
        d[i] = t[i];
      r += d[0];
    }
    cout << r << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val x = sc.nextInt()

  val ans = (1 :: (2 to x).toStream
    .flatMap(n => (2 to x).map(math.pow(n, _).toInt).takeWhile(_ <= x)).toList)
    .max


  println(ans)
}


Measured memory_bytes: 40148
def insertionSort(*args):
    l = list(args)
    print ' '.join(map(str, l))
    for i in range(1, n):
        v = l[i]
        j = i - 1
        while j >= 0 and l[j] > v:
            l[j + 1] = l[j]
            j -= 1
            l[j + 1] = v
        print ' '.join(map(str, l))

n = input()
l = map(int, raw_input().split())
insertionSort(*l)

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

int main() {
    int N;
    cin >> N;
    FOR(i, N, 1000) {
        if (i % 10 == (i/10) % 10 && (i/10) % 10 == (i/100) % 10) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)


#define INF (1e9)
typedef long long unsigned int ll;


int main()
{

    int A,B;
    cin >> A>>B;

    if(B%A==0){
        cout << A + B;
    }else{
        cout << B - A;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int*)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    /*for(int i=0;i<n;i++){
        printf("%d ",a[i]);
    }printf("\n");
    */

    int arr[n],flag=0,l=1,r=n-1;
    for(int i=0;i<n;i++)arr[i]=0;
    arr[0]=a[(n-1)/2];
    a[(n-1)/2]=0;
    qsort(a,n,sizeof(int),compare);
    
    for(int i=1;i<n;i++){
        
        if(i%2==0){
            
            arr[i]=a[l];
            l++;
        }else{
            
            arr[i]=a[r];
            r--;
        }
    }/*
    for(int i=0;i<n;i++){
            printf("%d ",arr[i]);
        }
        printf("\n");
    */
    long long ans1=0;
    l=1;r=n-1;
    for(int i=0;i<n-1;i++){
        ans1+=abs(arr[i]-arr[i+1]);
    }
    for(int i=1;i<n;i++){
        if(i%2==0){
            
            arr[i]=a[r];
            r--;
        }else{
            
            arr[i]=a[l];
            l++;
        }
    }
    
    /*for(int i=0;i<n;i++){
            printf("%d ",arr[i]);
        }
        printf("\n");*/
        long long ans2=0;
    for(int i=0;i<n-1;i++){
        ans2+=abs(arr[i]-arr[i+1]);
    }
    
    printf("%lld",ans1>ans2?ans1:ans2);

    return 0;
}


Measured memory_bytes: 1268
#include <stdio.h>

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

  scanf("%d%d%d",&a,&b,&c);
  if(a == b && b == c)
    puts("No");
  else if(a != b && a != c && b != c)
    puts("No");
  else
    puts("Yes");

  return 0;
}


Measured memory_bytes: 1644
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    counter = collections.Counter(A)
    q = int(readline().rstrip())
    BCList = [list(map(int, readline().rstrip().split())) for _ in range(q)]
    aList = [0] * (10**5 + 10)
    sumA = sum(A)
    for i in range(n):
        aList[A[i] - 1] += 1

    for i in range(q):
        b, c = BCList[i][0], BCList[i][1]
        if aList[b - 1] == 0:
            print(sumA)
            continue
        sumA += (c - b) * aList[b - 1]
        aList[c - 1] += aList[b - 1]
        aList[b - 1] = 0
        print(sumA)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34508
#include <bits/stdc++.h>
using namespace std;
int main(void){
    while(true){
        map<char, char> mp;
        int n, m;
        cin >> n;
        if(n==0) break;
        while(n--){
            char before, after;
            cin >> before >> after;
            mp[before]=after;
        }
        cin >> m;
        vector<char> v;
        while(m--){
            char c;
            cin >> c;
            if(mp.count(c)>0){
                v.push_back(mp[c]);
            }
            else{
                v.push_back(c);
            }
        }
        for(int i=0; i<v.size(); i++){
            cout << v[i];
        }
        cout << "\n";
    
    
    }
    return 0;
}



Measured memory_bytes: 3196