akhauriyash/Code-Regression huggingface dataset:
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}

func Solve() {
  var N int
  NextInt(&N)
  T := make([][]int, N)
  for i := range T {
    T[i] = make([]int, 0)
  }
  var a, b int
  for i := 1; i < N; i++ {
    NextInt(&a, &b)
    a--
    b--
    T[a] = append(T[a], b)
    T[b] = append(T[b], a)
  }
  D := make([]bool, N)
  D[0] = true
  Q := make([]int, N)
  pos := 1
  for _, q := range Q {
    for _, adj := range T[q] {
      if D[adj] { continue }
      D[adj] = true
      Q[pos] = adj
      pos++
    }
  }
  P := make([]int, N)
  ans := "Second"
  for i := N - 1; 0 <= i; i-- {
    p := Q[i]
    if 0 < P[p] { continue }
    P[p] = 1
    alone := true
    for _, q := range T[p] {
      if 0 < P[q] { continue }
      P[q] = 2
      alone = false
      break
    }
    if alone { ans = "First" }
  }
  Write(ans)
  return
}

func main() {
  Solve()
  Output()
}

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

int main(void){
    int a[5],k,b = 0;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    for(int i = 0;i < 4;i++){
        for(int j = i+1;j < 5;j++){
            if(abs(a[i]-a[j]) > k)++b;
        }
    }
    if(b == 0)cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{

  int n,k,i,l;
  ll x,res=0;
  vector<ll> V ;
  cin>>n>>k;
  for(int i=0 ; i<n ; i++){
    cin>>x;
    V.push_back(x);
  }
  sort(V.rbegin(),V.rend());
  l=V.size();
  if(k>=l){
    cout<<0;
  }else{
      for(i=k ; i<l;   i++){
        res+=V[i];
      }
      cout<<res;
  }

  return 0 ;
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 330
#define MOD 1000000007
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,m,f[MAX][MAX][MAX],ans;
struct Node{int l,x;};
vector<Node> e[MAX];
bool check(int a,int b,int c)
{
	int r=max(a,max(b,c));
	for(int i=0,t=e[r].size();i<t;++i)
	{
		int l=e[r][i].l,x=e[r][i].x,s=0;
		s=(a>=l)+(b>=l)+(c>=l);
		if(s!=x)return false;
	}
	return true;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		int l=read(),r=read(),x=read();
		e[r].push_back((Node){l,x});
	}
	f[0][0][0]=1;
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<=n;++k)
			{
				if(!f[i][j][k])continue;
				if((i&&k&&i==k)||(i&&j&&i==j)||(j&&k&&j==k))continue;
				if(!check(i,j,k)){f[i][j][k]=0;continue;}
				int r=max(i,max(j,k));
				add(f[r+1][j][k],f[i][j][k]);
				add(f[i][r+1][k],f[i][j][k]);
				add(f[i][j][r+1],f[i][j][k]);
				if(r==n)add(ans,f[i][j][k]);
			}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 129152
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

string C[N];
char B[N];
ll n;

bool dfs(ll i, V A){
    string s = C[i];
    ll p,q;
    p=A[s[0]-'A'];
    q=A[s[1]-'A'];
    if(i==n){
        return 1;
    }
    if(p==0 and q==0){
        return 0;
    }   
    if(p==1 and q==1){
        A[s[0]-'A']--;A[s[1]-'A']++;
        bool f1 = dfs(i+1, A);
        if(f1)  B[i] = s[1];
        if(f1){
            return 1;
        }
        A[s[0]-'A']++;A[s[1]-'A']--;
        A[s[0]-'A']++;A[s[1]-'A']--;
        bool f2 = dfs(i+1, A);
        if(f2)  B[i] = s[0];
        if(f2){
            return 1;
        }
        return 0;
    }
    if(p>q){
        A[s[0]-'A']--;A[s[1]-'A']++;
        B[i]=s[1];
    }
    else{
        A[s[0]-'A']++;A[s[1]-'A']--;
        B[i]=s[0];
    }
    return dfs(i+1, A);
}

void solve(){
    cin>>n;
    V A(3);
    rep(i,0,3)  cin>>A[i];
    rep(i,0,n)  cin>>C[i];
    bool f = dfs(0, A);
    if(f){
        cout<<"Yes"<<endl;
        rep(i,0,n)  cout<<B[i]<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll no;
    // cin>>no;
    no = 1;
    while(no--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 24068
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
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 gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;


//高速な素因数分解O(logN)
template<typename T>
vector<T> sieve(T n){//n以下の整数について最小の素因数を調べる
    vector<T>prime(n+1);
		for(int i=0;i<=n;++i)prime[i]=i;
    for(int i=2;i*i<=n;i++){
        if(prime[i]<i)continue;
				for(int j=i*i;j<=n;j+=i){
					if(prime[j]>=i)prime[j]=i;
				}
    }
    return prime;
}

template<typename T>
vector<pair<T,int>> osa_k(T n,const vector<T>& min_factor){//min_factorはsieveで求めた配列を使う
  vector<pair<T,int>> ret;
  while(n>1){
		int cnt=0;
		T value=min_factor[n];
		while(value==min_factor[n]){
			n/=min_factor[n];
			++cnt;
		}
		ret.emplace_back(value,cnt);
	}
  return ret;
}

void solve(){
	ll n;
	cin>>n;
	auto v=sieve(n+1);
	ll ans=0;
	for(int i=1;i<n;++i){
		if(i==1){
			ans++;
			continue;
		}
		ll add=1;
		for(auto x:osa_k<ll>(i,v)){
			add*=x.second+1;
		}
		ans+=add;
	}
	cout<<ans<<"\n";
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 11088
from bisect import bisect_left
from collections import defaultdict

n = int(input())

xysame, upright, downright = {},{},{}
u_list = ("U","R","D","L")
for u in u_list:
    xysame[u] = defaultdict(list)
    upright[u] = defaultdict(list)
    downright[u] = defaultdict(list)

for _ in range(n):
    x,y,u = input().split()
    x,y = int(x),int(y)
    if u == "U" or u == "D":
        xysame[u][x].append(y)
    else:
        xysame[u][y].append(x)
    upright[u][y-x].append(x)
    downright[u][y+x].append(x)
    
for u in u_list:
    for key in xysame[u].keys():
        xysame[u][key].sort()
    for key in upright[u].keys():
        upright[u][key].sort()
    for key in downright[u].keys():
        downright[u][key].sort()

INF = 10**6
ans = INF


def line(low,high,type_ = 1):
    ret = INF
    for k,v in low.items():
        if high[k] == []: continue

        for vi in v:
            index = bisect_left(high[k], vi)
            if index == len(high[k]): continue
            ret = min(ret,(high[k][index]-vi)/type_)
    return ret

ans = min(ans, line(xysame["U"],xysame["D"],2))
ans = min(ans, line(xysame["R"],xysame["L"],2))
ans = min(ans, line(upright["R"],upright["D"],1))
ans = min(ans, line(upright["U"],upright["L"],1))
ans = min(ans, line(downright["R"],downright["U"],1))
ans = min(ans, line(downright["D"],downright["L"],1))

ans = int(ans*10)
if ans ==INF*10: ans = "SAFE"
    
print(ans)

Measured memory_bytes: 154360
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int A = sc.nextInt();//白
		int B = sc.nextInt();//黒
		//白.
		//黒#
		boolean[][] black = new boolean[100][100];
		for (int i = 50; i < 100; ++i) {
			for (int j = 0; j < 100; ++j) {
				black[i][j] = true;
			}
		}
		--A;
		--B;
		for (int i = 1; i < 50; i += 2) {
			for (int j = i % 2; j < 100; j += 2) {
				if (B > 0) {
					black[i][j] = true;
					--B;
				}
			}
		}
		for (int i = 51; i < 100; i += 2) {
			for (int j = i % 2; j < 100; j += 2) {
				if (A > 0) {
					black[i][j] = false;
					--A;
				}
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(100 + " " + 100);
		for (int i = 0; i < 100; ++i) {
			for (int j = 0; j < 100; ++j) {
				pw.print(black[i][j] ? "#" : ".");
			}
			pw.println();
		}
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


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

const int inf=100007;
int n, m;
vector<int>g[inf];
int dp[inf];
int f(int r){
     int&ans=dp[r];
     if(ans!=-1) return ans;
     
     ans=0;
     for(int i=0;i<g[r].size();i++){
          int c=g[r][i];
          ans=max(ans, f(c));
     }
     ans++;
     return ans;
}

int main(){
     memset(dp, -1, sizeof(dp));
     cin>>n>>m;
     for(int i=0;i<m;i++){
          int a, b;
          cin>>a>>b;
          g[a].push_back(b);
     }
     int ans=0;
     for(int i=1;i<=n;i++)ans=max(ans, f(i));
     cout<<ans-1;
}

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

int main(){
	
    string input;
  	char stock[2];
    char err;
  	int count=0;	
  
  	cin>>input;
  
    stock[0]=input[0];
  	for(int i=1;i<4;i++){
      if(count==0){
        if(stock[0]==input[i]){
        	stock[0]='*';
            err=input[i];
        }else if(err!=input[i]){
        	stock[1]=input[i];
          	count++;
        }
      }else if(count==1){
      	if(stock[0]==input[i]){
        	stock[0]='*';
        }else if(stock[1]==input[i]){
        	stock[1]='*';
        }
      }
    }
  
  	if(stock[0]=='*'&&stock[1]=='*'){
		cout<<"Yes";
    }else{
        cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
lst=[0]
now=0
memo=0
town=[0]*n
town[0]=1
b=0
for i in range(k):
	now=a[now]
	if town[now]==1:
		memo=now
		b=1
		break
	lst.append(now)
	town[now]=1
if b==1:
	i=lst.index(memo)
	l=len(lst)
	if memo!=0:
		lst=lst[i:]
		l-=len(lst)
		print(lst[(k-l)%len(lst)]+1)
	else:
		print(lst[k%l]+1)
else:
	print(now+1)

Measured memory_bytes: 32328
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,m,w[105],v[105];

ll dp[105][100005],ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(j<w[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            ans=max(ans,dp[i][j]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 79360
s=input()
yn=0
if s[0]=="A" and ord(s[1])>95 and ord(s[len(s)-1])>95 and s.count("C")==1:
    for i in range(len(s)-3):
        if s[i+2]!="C" and ord(s[i+2])<92:
            yn=1
    if yn==1:
        print("WA")
    else:
        print("AC")
else:
    print("WA")


Measured memory_bytes: 9048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<char, char> CP;

string s;
int n, q;
char t, d;
vector<CP> query;

int go(int x){
  for(int i = 0;i < q;i++){
    if(s[x] != query[i].first)continue;
    if(query[i].second == 'R')x++;
    else x--;
    if(x < 0 || x >= n)break;
  }
  return x;
}

int main(){
  cin >> n >> q;
  cin >> s;
  for(int i = 0;i < q;i++){
    cin >> t >> d;
    query.push_back(CP(t,d));
  }
  int bottom = 0, top = n;
  while(top - bottom > 1){
    int mid = (top + bottom) / 2;
    if(go(mid) < 0)bottom = mid;
    else top = mid;
  }
  int l = top;
  if(go(0) >= 0){
    l = 0;
  }

  bottom = 0, top = n;
  if(go(0) >= n)top = -1, bottom = -1;
  while(top - bottom > 1){
    int mid = (top + bottom) / 2;
    if(go(mid) >= n)top = mid;
    else bottom = mid;
  }
  int r = bottom;
  cout << max(0,r - l + 1) << endl;
  return 0;
}

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

using namespace std;

int main() {
  long long N, M;
  cin >> N >> M;
  long long ans = min(N, M / 2LL);
  M -= (N * 2);
  if (M > 0) {
    ans += M / 4;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<algorithm>
using namespace std;
int main()
{
     int n,temp;
     string s;
     cin >> n >> s >> temp;
     char c;
     c = s[temp-1];
     for(int i=0;i<s.size();i++){
if(s[i] != c)s[i] = '*'; 
     }
     cout << s << endl;
     return 0;
}

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

l1 = l2 = length = 0

while l2 + length < n:
  if s[l1 : l2] in s[l2:]:
    length = l2 - l1
    l2 += 1
  else:
    l1 += 1
    l2 = l1 + length + 1

print(length)

Measured memory_bytes: 3060
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int get_id(char c){
	if(c>='a'&&c<='z')return c-'a';
	if(c>='A'&&c<='Z')return c-'A'+26;
	return c-'0'+52;
}
char rev(int x){
	if(x<26)return 'a'+x;
	if(x<52)return 'A'+x-26;
	return '0'+x-52;
}
int cnt[66],func[66],n,tot_ask;
string cmp="";
int dp[199][199];
int dist(string s){
	memset(dp,inf,sizeof dp);
	dp[0][0]=0;tot_ask++; 
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=cmp.size();j++){
			if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			if(i&&j)dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s[i-1]!=cmp[j-1]));
		}
	}
	return dp[s.size()][cmp.size()];
}
int ask(string s){
	#ifdef LOCAL
		return dist(s);
	#endif
	cout<<"? "<<s<<endl;
	fflush(stdout);int x;cin>>x;return x;
}
int Get(string ret,string s,int pos,char c){
	int tot=ret.size()+1+s.size()-pos;
	string ss=ret+c+getstr(s,pos,s.size()-1);
	tot=ss.size();
	#ifdef LOCAL
		return dist(ss)==n-tot;
	#endif
	return n-tot==ask(ss);
}
int id[66];
string merge_sort(int l,int r){
	if(l==r){
		string ret="";
		for(int i=0;i<cnt[id[l]];i++)ret.push_back(rev(id[l]));
		return ret;
	}
	int mid=(l+r)/2;
	string s1=merge_sort(l,mid);
	string s2=merge_sort(mid+1,r);
	int pos=0;
	string ret="";
	if(s1.size()<s2.size())swap(s1,s2);
	for(int i=0;i<s1.size();i++){
		while(pos<s2.size()&&Get(ret,s2,pos,s1[i])==0)
		ret.push_back(s2[pos]),pos++;
		ret.push_back(s1[i]);
	}
	while(pos<s2.size())ret.push_back(s2[pos++]);
	return ret;
}
int main(){
	cmp="fedweinfw";
	for(int i=0;i<62;i++){
		string s="";s.push_back(rev(i));
		for(int i=0;i<7;i++)s=s+s;
		int got=ask(s);
		cnt[i]=128-got;
	}
	for(int i=0;i<62;i++)n+=cnt[i];
	for(int i=0;i<62;i++)id[i]=i;
	random_shuffle(id,id+62);
	string s=merge_sort(0,61);
	cout<<"! "<<s<<endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3800
N, M = map(int, input().split())

H = list(map(int, input().split()))

View = [0] * N

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        View[B-1] += 1
    elif H[A-1] < H[B-1]:
        View[A-1] += 1
    else:
        View[A-1] += 1
        View[B-1] += 1

ans = 0
for i in range(N):
    if View[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 20120
{-# LANGUAGE ScopedTypeVariables #-}

import Data.Bits
import Control.Monad


rgl :: (Read a) => IO a
rgl = (liftM read) getLine

f :: Int -> Int -> Int
f x k = if x < k 
                then 0
                else if r == 0
                        then v
                        else f (y - r2 + r2 `mod` (v2 + 1)) k
                        where 
                                v = div x k
                                r = mod x k
                                y = x - v - 1
                                v2 = div y k
                                r2 = mod y k
                                                                

main = do
        n :: Int <- rgl
        xs :: [(Int, Int)] <- replicateM n $ do
                                        [a, b] <- (liftM words) getLine
                                        return (read a, read b)
        let     vals = map (uncurry f) xs
                ans  = foldl xor 0 vals

        putStrLn $ if ans == 0
                        then "Aoki"
                        else "Takahashi"


Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; 
  cin >> N;
  unsigned long ans = 0;
  vector<vector<unsigned long>> p(N,vector<unsigned long>(2));
  for(int i = 0; i <N; i++){
    for(int j = 0; j < 2; j++){
    cin >>p.at(i).at(j);
   }
  }
  for(int i = N-1 ; i>=0; i--){
    unsigned long q = (ans+p.at(i).at(0))%p.at(i).at(1);
    if(q != 0){
    ans+=  p.at(i).at(1)-q ;
  }
}
  cout << ans << endl;

}

Measured memory_bytes: 5760
n = int(input())
s = input().strip()
assert n == len(s)

maxlen = 0
for offset in range(1, n):
  t = s[offset:]
  d = 0
  for (a, b) in zip(s, t):
    if a == b:
      d += 1
    else:
      d = 0
    if maxlen < d and d <= offset:  # (d > offset) のとき共通部分文字列が重なってる
      maxlen = d

print(maxlen)

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

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

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,N0;
  cin >> N0;
  
  int R;
  int sum;
  
  N = N0;
  
  while(N){
    R = N % 10;
    sum += R;
    N /= 10;
  }
  
  if(N0 % sum == 0){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $h = explode(" ", trim(fgets(STDIN)));

  $sum = 0;
  for($i=$n-1; $i>0; $i--){
    $sa = $h[$i-1] - $h[$i];
    if($sa > 1){
      echo "No";
      exit;
    }
    if($sa == 1){
      $h[$i-1]--;
    }
  }
  echo "Yes";
  exit;



Measured memory_bytes: 14840
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
//#include "toollib.h"
#pragma warning (disable:4018)
#define INT_MAX 2147483647

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> c(m);
	vector<vector<int>> dp(m, vector<int>(n + 1, INT_MAX));
	for (int i = 0; i < m; i++) cin >> c[i];
	sort(c.begin(), c.end());
	for (int i = 0; i < m; i++) dp[i][0] = 0;
	for (int j = 1; j <= n; j++) dp[0][j] = j;
	for (int i = 1; i < m; i++) {
		for (int j = 1; j <= n; j++) {
			if (j - c[i] >= 0) dp[i][j] = min(dp[i][j - c[i]] + 1, dp[i - 1][j]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[m - 1][n] << endl;
	return 0;
}

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

int a[10];
int b[10][10];
int c[10][10][10];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char t;
		cin >> t;
		int x;
		x = t - '0';
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				if (b[j][k]==1 && c[j][k][x] == 0) {
					c[j][k][x] = 1;
				}
			}
		}
		for (int j = 0; j < 10; j++) {
			if (a[j]==1 && b[j][x] == 0) {
				b[j][x] = 1;
			}
		}
		if (a[x] == 0) {
			a[x] = 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				if (c[i][j][k] == 1) {
					ans++;
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

solve :: Int -> U.Vector Int -> U.Vector Int
solve !n v = U.create $ do
  result <- UM.replicate (n + 1) 0
  forM_ [n,n-1..1] $ \i -> do
    s <- sumM [ UM.read result j | j <- [2*i,3*i..n] ]
    UM.write result i ((s + v U.! (i-1)) `rem` 2)
  return result

main = do
  n <- readLn
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let result = U.filter (\(i,v) -> v > 0) $ U.indexed $ solve n xs
  print $ U.length result
  U.forM_ result $ \(i,_) -> print i

sumM :: (Monad m, Num a) => [m a] -> m a
sumM = foldM (\s a -> (s +) <$> a) 0


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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N;
vector<int> x;
int xi;
// *********************************************************
int main(){

    // 入力スタンダード
    cin >> N;
    
    rep(i,N){
        cin >> xi;
        x.emplace_back(xi);
    }
    sort(x.begin(), x.end());

    int sum = 0;
    ll minsum = INF;
    for(int i=x.at(0), mx = x.at(N-1); i<=mx; i++){
        for(auto j: x){
            sum += (i-j)*(i-j);
        }
        if(sum < minsum) minsum=sum;
        sum=0;
    }

    cout << minsum <<endl;


    return 0;
}

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

int main() {
	int A, B, C, a, b, c;
	cin >> A >> B;
	C = A + B;

	a = A % 3;
	b = B % 3;
	c = C % 3;

	if (a* b* c == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;

}

Measured memory_bytes: 256
N = int(input())
A = []
max_a = 0
max2_a = 0
for i in range(N):
	a = int(input())
	A.append(a)
	if a >= max_a:
		max2_a = max_a
		max_a = a
	elif a >= max2_a:
		max2_a = a

for i in range(N):
	a = A[i]
	if a == max_a:
		print(max2_a)
	else:
		print(max_a)


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

int q;

typedef struct{
  char suit;
  int num;
  int index;
} card;

int part(card *a, int p, int r){
  int i, j, x;
  card tmp;

  x = a[r].num;
  i = p-1;

  for(j = p; j < r; j++){
    if(a[j].num <= x){
      i++;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;

  return i+1;
}

void quick(card *a, int p, int r){
  if(p < r){
    q = part(a, p, r);
    quick(a, p, q-1);
    quick(a, q+1, r);
  }
}

int isStable(card *in, int n){
  int i;
  for(i = 0; i < n; i++)
    if(in[i].num == in[i+1].num)
      if(in[i].index > in[i+1].index)
        return 0;
  return 1;
}

int main(){
  int i, j, q, n, isstb;

  scanf("%d", &n);
  card *a;
  a = malloc(sizeof(card) * n);

  for(i = 0; i < n; i++){
    scanf(" %c%d", &a[i].suit, &a[i].num);
    a[i].index = i;
  }

  quick(a, 0, n-1);
  isstb = isStable(a, n);

  if(isstb == 0)
    printf("Not stable\n");
  else if(isstb == 1)
    printf("Stable\n");
  else
    printf("isstb is not 1 or 0\n");
  for(i = 0; i < n; i++)
    printf("%c %d\n", a[i].suit, a[i].num);

  free(a);

  return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int H, W;
    cin >> H >> W;
    vector<string> c(H);
    vector<pair<int, int>> pos;
    REP (i, H) {
        cin >> c[i];
        REP (j, W) if (c[i][j] == 'B') {
            pos.emplace_back(i, j);
            break;
        }
        for (int j = W - 1; j >= 0; --j) if (c[i][j] == 'B') {
            pos.emplace_back(i, j);
            break;
        }
    }
    sort(pos.begin(), pos.end());
    pos.erase(unique(pos.begin(), pos.end()), pos.end());
    int ans = 0;
    for (int i = 0; i < pos.size(); ++i) {
        for (int j = 0; j < pos.size(); ++j) {
            ans = max(ans, abs(pos[i].first - pos[j].first) + abs(pos[i].second - pos[j].second));
        }
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
LL INF=1001001001001001001;

LL n,x,d;

LL gcd(LL a,LL b)
{
	if(a<b)return gcd(b,a);
	if(b==0)return a;
	else return gcd(b,a%b);
}

LL sum(LL a,LL i)
{
	return a*i+d*i*(i-1)/2;
}

vector<PL> v[200010];
int main(){
	cin>>n>>x>>d;
    if(d==0)
	{
      if(x==0)cout<<1<<endl;
      else cout<<n+1<<endl;
		return 0;
	}
	LL g=gcd(abs(x),abs(d));
	x=x/g,d=d/g;
	if(d<0)x=x+(n-1)*d,d=-d;
	LL ans=0;
	
	
	for(LL i=0;i<=n;i++)
	{
		LL l=sum(x,i),r=sum(x+(n-i)*d,i);
		if(l>r)swap(l,r);
		v[i%d].push_back(PL(l,r));		
	}
	for(LL i=0;i<=min(n,d-1);i++)
	{
		sort(v[i].begin(),v[i].end());
		LL MAX=-INF;
        for(auto p:v[i])
		{
          LL l=p.first,r=p.second;
          l=max(l,MAX+d);
          ans+=max((r-l)/d+1,(LL)0);
          MAX=max(MAX,r);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int x = in.nextInt();
        in.close();
        int count = 0;
        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) ++count;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23892
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] s = line.split(" ");

		Deque<Integer> stack = new ArrayDeque<>();
		for(String op : s){
			if(isNumber(op)){
				stack.addLast(Integer.parseInt(op));
			}else{
				int b = stack.removeLast();
				int a = stack.removeLast();
				int c = 0;
				if(op.equals("+")){
					c = a + b;
				}else if(op.equals("-")){
					c = a - b;
				}else if(op.equals("*")){
					c = a * b;
				}
				stack.addLast(c);
			}	
		}
		System.out.println(stack.removeLast());
	}
	public static boolean isNumber(String num) {
    try {
        Integer.parseInt(num);
        return true;
        } catch (NumberFormatException e) {
        return false;
    }
}
}

Measured memory_bytes: 26148
#include <stdio.h>

#define N_MAX 100
#define Q_MAX (1 << 30)
int a[N_MAX][2]; /* 入力配列 */
int q[N_MAX][N_MAX]; /* 解配列 */

int
calc(int i, int j)
{
	int k, v, res = Q_MAX;

	for (k = i; k < j; k++) {
		v = q[i][k] + q[k + 1][j] + a[i][0] * a[k][1] * a[j][1];
		if (res > v)
			res = v;
	}

	return res;
}

int
main(void)
{
	int i, j, n, r;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &a[i][0], &a[i][1]);
	}

	/* r=0 行列1個の場合 乗算が発生しないのでコスト0 */
	for (i = 0; i <= n; i++)
		q[i][i] = 0;

	for (r = 1; r < n; r++) {
		for (i = 0; i + r < n; i++) {
			j = i + r;
			q[i][j] = calc(i, j);
		}
	}
	printf("%d\n", q[0][n - 1]);

	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 3.141592653589793238;
template<class T> bool chmax(T& a, const T& b){
  if(a < b){
    a = b;
    return true;
  }
  return false;
}


int main(){
  ll n;
  cin >> n;
  vector<pair<double, pair<ll, ll>>> a(n);
  for(auto& i : a){
    cin >> i.second.first >> i.second.second;
    i.first = atan2(i.second.first, i.second.second);
  }
  sort(a.begin(), a.end());
  for(ll i = 0; i < n * 2; i++) a.emplace_back(a[i].first + 2 * PI, a[i].second);
  double ans = 0;
  ll x = 0, y = 0, l = 0, r = 0;
  while(l < n){
    if(a[r].first - a[l].first < PI){
      x += a[r].second.first;
      y += a[r].second.second;
      r++;
    }
    else{
      x -= a[l].second.first;
      y -= a[l].second.second;
      l++;
    }
    chmax(ans, sqrt(x*x+y*y));
  }
  printf("%.20f", ans);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,year,month,day,sum,i,j,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    sum=0;
    scanf("%d%d%d",&year,&month,&day);
    for(j=1;j<=year;j++){
      if(j!=year){
	if(j%3==0)sum+=200;
	else sum+=195;
      }
      else if(j=year){
	if(j%3!=0){
	  for(k=1;k<=month;k++){
	    if(k!=month){
	      if(k%2==0)sum+=19;
	      else sum+=20;
	    }
	    else if(k==month){
	      sum+=day;
	    }
	  }
	}
	else {
	  sum+=20*(month-1);
	  sum+=day;
	}
      }
    }
	
    
    printf("%d\n",196471-sum);
  }

  return 0;
}    

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int a[10010];
bool cmp(int x,int y){return x>y;}
int main(){
	int n,k,cnt=0;
	cin>>n>>k;
	for(int i=0;i<n;++i)cin>>a[i];
	sort(a,a+n,cmp);
	for(int i=0;i<k;++i)cnt+=a[i];
	cout<<cnt<<endl;
	return 0;
}

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

int route[100][100];
int d[100], qe = 0, pc = 0;
int q[100];

void push(int);
int pop(void);
void bfs(int, int);

int main(){
  int i, j, n, u, k, v;

  scanf("%d", &n);
  if(n >= 1 && n <= 100){
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++) route[i][j] = 0;
    }

    for(i = 0; i < n; i++){
      scanf("%d %d", &u, &k);
      u--;
      for(j = 0; j < k; j++){
	scanf("%d", &v);
	v--;
	route[u][v] = 1;
      }
    }

    bfs(0, n);
  }
  return 0;
}

void push(int s){
  q[qe + pc] = s;
  qe++;
}

int pop(){
  int s;
  s = q[pc];
  pc++;
  qe--;
  return s;
}

void bfs(int s, int n){
  int i, u, v;
  push(s);
  for(i = 0; i < n; i++) d[i] = INF;
  d[s] = 0;
  while(qe != 0){
    u = pop();
    for(v = 0; v < n; v++){
      if(route[u][v] == 0) continue;
      if(d[v] != INF) continue;
      d[v] = d[u] + 1;
      push(v);
    }
  }
  for(i = 0; i < n; i++){
    if(d[i] != INF){
      printf("%d %d\n", i+1, d[i]);
    }else{
      printf("%d %d\n", i+1, -1);
    }
  }
}



Measured memory_bytes: 2032
fun main(args: Array<String>) {
  val (N, M) = readInts()
  val edges = Array(N) { mutableListOf<Int>() }
  val dp = Array(N) { 0 }

  for (i in 0 until M) {
    val (X, Y, Z) = readInts()
    edges[X - 1].add(Y - 1)
    edges[Y - 1].add(X - 1)
  }
//  println(edges.joinToString("\n"))

  fun mark(i: Int, n: Int) {
    if (dp[i] != 0) return
    dp[i] = n
    edges[i].forEach {
      mark(it, n)
    }
  }

  var cnt = 0
  for (i in 0 until N) {
    if (dp[i] != 0) continue
    cnt++
    mark(i, cnt)
  }

//  println(dp.joinToString())
  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 93548
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
int n,m;
while(true){
cin>>n>>m;
if(n==0&&m==0){break;}
int ans=-2147483646;
int sum[100001];
for(int i=0;i<n;i++)
{
cin>>sum[i];
if(i!=0){sum[i]+=sum[i-1];}
if(i==m-1){ans=max(ans,sum[i]);}
else if(i>m-1){ans=max(ans,sum[i]-sum[i-m]);}
}
cout<<ans<<endl;
/////////////
}
///////////
    return 0;
}


Measured memory_bytes: 3440
n=int(input())
a=list(map(int,input().split()))
ma=10**5
a2=[0]*ma
for ii in a:
  a2[ii-1]+=1

def func(a2):
  r=0
  for jj in range(len(a2)):
     r+= a2[jj]*(jj+1)
  return r

r=func(a2)
q=int(input())
for ii in range(q):
  b,c=map(int,input().split())
  r+=(c-b)*a2[b-1]
  a2[c-1]+=a2[b-1]
  a2[b-1]=0
  print(r)


Measured memory_bytes: 20636
// Problem : C - Welcome to AtCoder
// Contest : AtCoder Beginner Contest 151
// URL : https://atcoder.jp/contests/abc151/tasks/abc151_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
int n,m;
cin>>n>>m;
map<int,int> mp;
int c=0;
int w[n+1]={0};
for(int i=0;i<m;i++)
{
	int x;
	string s;
	cin>>x>>s;
	if(s=="AC")
	{
	if(mp[x]==0)
	{
		c++;mp[x]=1;}
	}
	else
	{
		if(mp[x]==0)
		w[x]++;
	}
}
int count2=0;
for(int i=1;i<=n;i++)
if(mp[i]==1)
count2+=w[i];
cout<<c<<" "<<count2;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  lli n,x,m;
  lli a[100001]={0};
  lli b[100001]={0};
  lli ans=0;
  cin>>n>>x>>m;
  lli xx=x;
  if(m==1){
      cout<<0<<endl;
      return 0;
  }
  if(n<1000000) {
      rep(i,n){
          ans+=xx;
          xx=(xx*xx)%m;
      }
      cout<<ans<<endl;
      return 0;
  }
  reps(i,1,m+1){
      //cout<<xx<<" ";
      if(i==n+1){
          cout<<ans<<endl;
          return 0;
      }
      if(a[xx]!=0) {
          lli j=i-a[xx];
          //cout<<"i"<<i<<a[xx];
          //cout<<"j"<<j<<" "<<(n-a[xx]+1)<<" "<<ans-b[a[xx]-1]<<" ";
          lli temp=((n-a[xx]+1)/j-1)*(ans-b[a[xx]-1]);
          ans+=temp;
          j=(n-a[xx]+1)%j;
          //cout<<j<<" ";
          rep(k,j){
              ans+=xx;
                xx=(xx*xx)%m;
          }
          cout<<ans<<endl;
          return 0;
      }
      a[xx]=i;
      ans+=xx;
      b[i]=ans;
      xx=(xx*xx)%m;
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2 scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%lld",n)
#define prln(n) printf("%lld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)


int a[50];
int main()
{
    string s;
    cin>>s;
    fo(i,0,sz(s))
    {
        a[s[i]-'a']++;
    }
    bool flag=true;
    fo(i,0,26)
    {
        if(a[i]%2 !=0)
        {
            flag=false;
            break;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

















Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.util.stream.*;

public class Main{
	private static BufferedReader in;
	private static BufferedWriter out;
	
	public static void main(String[] args) throws IOException {
		open();

		StringTokenizer st;
		StringBuilder sb;
		
		st=new StringTokenizer(readString());
		long N=Long.parseLong(st.nextToken());
		long A=Long.parseLong(st.nextToken());
		long B=Long.parseLong(st.nextToken());
		//int ans=0;
			out.write(((N/(A+B)*A+Math.min(N%(A+B),A)))+"\n");
		close();
	}
	
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}

	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}

	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}

	private static double[] readDoubles() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(in.readLine());
	}

	private static String readString() throws IOException {
		return in.readLine();
	}

	private static int setBit(int S, int j) {
		return S | (1 << j);
	}

	private static int isOn(int S, int j) {
		return S & (1 << j);
	}

	private static int clearBit(int S, int j) {
		return S & ~(1 << j);
	}

	private static int toggleBit(int S, int j) {
		return S ^ (1 << j);
	}

	private static int lowBit(int S) {
		return S & (-S);
	}

	private static int setAll(int n) {
		return (1 << n) - 1;
	}

	private static int modulo(int S, int N) {
		return ((S) & (N - 1));
	} // returns S % N, where N is a power of 2

	private static boolean isPowerOfTwo(int S) {
		return (S & (S - 1)) == 0 ? true : false;
	}

	private static int nearestPowerOfTwo(int S) {
		return ((int) Math.pow(2.0, (int) ((Math.log((double) S) / Math.log(2.0)) + 0.5)));
	}

	private static int turnOffLastBit(int S) {
		return ((S) & (S - 1));
	}

	private static int turnOnLastZero(int S) {
		return ((S) | (S + 1));
	}

	private static int turnOffLastConsecutiveBits(int S) {
		return ((S) & (S + 1));
	}

	private static int turnOnLastConsecutiveZeroes(int S) {
		return ((S) | (S - 1));
	}

	private static void open() {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new BufferedWriter(new OutputStreamWriter((System.out)));
	}

	private static void close() throws IOException {
		out.flush();
		out.close();
		in.close();
	}
}


Measured memory_bytes: 22868
#include <iostream>
using namespace std;
int main(void) {
  int i, l[10], acc[10];
  double v1, v2, pos;
  char c;
  while (cin >> l[0] && l[0]) {
    for (i = 1; i < 10; i++)
      cin >> c >> l[i];
    cin >> c >> v1 >> c >> v2;
    acc[0] = l[0];
    for (i = 1; i < 10; i++)
      acc[i] = acc[i - 1] + l[i];
    pos = v1 / (v1 + v2) * acc[9];
    for (i = 1; i <= 10; i++)
      if (pos <= acc[i - 1]) {
        cout << i << endl;
        break;
      }
  }
}

Measured memory_bytes: 1232