akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    
    if (N == 1) {
        cout << "Hello World" << endl;
    }
    else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int n;
	cin >> n;
	int w[n];
	int sum = 0;
	for(int i=0; i<n; i++){
		cin >> w[i];
		sum += w[i];
	}
	int sum1 = w[0]; int sum2 = sum-w[0];
	int mn = abs(sum1-sum2);
	int i=1;
	while(i<n){
		sum1 += w[i]; sum2 -= w[i];
		if(abs(sum1-sum2) < mn) mn = abs(sum1-sum2);
		i++;
	} 
	cout << mn;
	return 0;
}

Measured memory_bytes: 3636
a=[0,0,0,0,0,0]
for i in range(0,6):
    a[i]=int(input())

b=[]
b.append(abs(a[0]-a[1]))
b.append(abs(a[0]-a[2]))
b.append(abs(a[0]-a[3]))
b.append(abs(a[0]-a[4]))
b.append(abs(a[2]-a[3]))
b.append(abs(a[2]-a[1]))
b.append(abs(a[3]-a[1]))
b.append(abs(a[4]-a[1]))
b.append(abs(a[2]-a[4]))
b.append(abs(a[3]-a[4]))

for i in range(0,10):
    if a[5]<b[i]:
        print(':(')
        break
    else:
        if i==9:
            print('Yay!')
        else:
            continue

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int n;
    cin >> n;
    
    vector<int> a(n+1);
    vector<int> b(n+1);
    
    rep(i,n) cin >> a[i+1];
    
    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i + i; j <= n; j += i){
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
    
    vector<int> ans;
    
    for(int i = 1; i <= n; i++){
        if(b[i]) ans.push_back(i);
    }
    
    cout << (int)ans.size() << endl;
    
    rep(i,(int)ans.size()){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, q;
    cin >> n >> q;
    vector<PP> v;
    rep(i, n)
    {
        int s, t, x;
        cin >> s >> t >> x;
        v.push_back(PP(s - x, P(1, x)));
        v.push_back(PP(t - x, P(-1, x)));
    }
    v.push_back(PP(INF, P(1, 1)));
    sort(all(v));
    vector<int> d(q);
    rep(i, q) cin >> d[i];
    multiset<int> st;
    int pos = 0;
    rep(i, v.size())
    {
        PP pp = v[i];
        P p = pp.second;
        int t = pp.first, f = p.first, x = p.second;
        while (d[pos] < t && pos < q)
        {
            if (st.size() == 0)
                cout << -1 << endl;
            else
            {
                auto ite = st.upper_bound(-INF);
                cout << *ite << endl;
            }
            pos++;
        }
        if (f == 1)
            st.insert(x);
        else
            st.erase(x);
    }
}

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

int main() 
{
	int n;
	cin >> n;
	vector<string> s(n);
	map<string ,int> mp;
	mp["AC"] = 0;
	mp["WA"] = 0;
	mp["TLE"] = 0;
	mp["RE"] = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		mp[s[i]]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 6456
N=input()
lenN=len(N)
N=int(N)




if N%2==1 or N<10:
    print(0)
else:
    count=0
    loop=0
    while(1):
        if N<(10*5**loop):
            break
        else:
            count+=N//(10*5**loop)
            loop+=1
    print(count)

Measured memory_bytes: 3060
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	inf = 10000000071000000
	sc = bufio.NewScanner(os.Stdin)
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


func main() {
	n := goint()
	t := make([]int,n);k := make([]int,n)
	for i:=0;i<n;i++{
		t[i] = goint()
	}
	for i:=0;i<n;i++{
		k[i] = goint()
	}
	//存在判定
	tt := 0;kk := 0;check := true
	checkls := make([]int,n)
	for i:=0;i<n;i++ {
		if t[i] > tt{
			if t[i] > k[i]{
				check = false
				break
			}
			tt = t[i]
			checkls[i] = 1
		}
		if k[len(k)-i-1] > kk{
			if k[len(k)-i-1] > t[len(k)-i-1]{
				check = false
				break
			}
			kk = k[len(k)-i-1]
			checkls[len(k)-i-1] = 1
		}
	}
	if check == false {
		fmt.Println(0)
		os.Exit(0)
	}
	count := 1
	tmax := 0;kmin := k[0]
	for i:=0;i<n;i++{
		if tmax < t[i]{
			tmax = t[i]
		} else if kmin > k[i] {
			kmin = k[i]
		}
		if checkls[i] != 1{
			count *= min(tmax,kmin)
			count %= mod
		}
	}
	fmt.Println(count)
}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

Measured memory_bytes: 6912
#include <stdio.h>

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0;

int main(){
  int S[1000000];
  int n,i;

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

  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    if(i != n-1){
      printf("%d ",S[i]);
    }
    else{
      printf("%d\n%d\n",S[i],count);
    }
  }

  return 0;

}

void merge(int *A,int left,int mid,int right){


  
  int n1,n2,i,j,k;

  n1=mid-left;
  n2=right-mid;

  int L[n1+1],R[n2+1];

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  L[n1]=1000000000;
  R[n2]=1000000000;

  i=0;
  j=0;

  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }



}


void mergeSort(int *A,int left,int right){

  int mid;

  if(left+1 < right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define x first
#define y second
typedef long long int ll;
vector<pair<ll,ll> > v;
bool cmp(pair<ll,ll> &a,pair<ll,ll> &b){
	return a.x+a.y>b.x+b.y;
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;
	ll lol=0;
	v.resize(n);
	for(int i=0; i<n; i++) {
		cin>>v[i].x>>v[i].y;
		lol+=v[i].y;
	}

	sort(v.begin(),v.end(),cmp);
	ll ans=0;
	for(int i=0; i<n; i+=2) {
		ans+=v[i].x+v[i].y;
	}
	ll anss=ans-lol;
	cout<<anss<<endl;
	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> a(n);
    // hi + hj = j - i
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[i - a[i]]++;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += mp[i + a[i]];
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

int counter(int bit) {
  if(bit == 0){
    return 0;
  }else{
    return (bit & 1) + counter(bit >> 1);
  }
}

int main(int argc, const char *argv[]) {
  int N;
  int ans = 0;
  cin >> N;
  vector<int> A(N);
  vector<vector<int> > x(N, vector<int>(N));
  vector<vector<int> > y(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  for (int bit = 0; bit < (1 << N); bit++) {
    bool status = true;
    for (int i = 0; i < N; i++) {
       if(!(bit & (1 << i))) continue;
      for (int j = 0; j < A[i]; j++) {
        if (((bit >> (x[i][j])) & 1) ^ y[i][j]){
          status = false;
        }
      }
    }
    if(status){
      ans = max(ans, counter(bit));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,d,cmp,cmpp,m,h,w,x[ohara],v[ohara],y,sum=0,pos,c;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll ans1=0,ans2=0,ans3=0,ans4=0;
ll access3[ohara];
ll access4[ohara];
ll cou3=0,cou4=0;
ll tmp3,tmp4;

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>c;
    rep(i,n)cin>>x[i]>>v[i];
    rep(i,n){
        cnt+=v[i];
        if(i!=n-1){
        access4[cou4++]=cnt-x[i];
        }
        ans1=max(ans1,cnt-x[i]);
    }
    cnt=0;
    rrrep(i,n-1,0){
        cnt+=v[i];
        if(i!=0){
        access3[cou3++]=cnt-c+x[i];
        }
        ans2=max(ans2,cnt-c+x[i]);
    }
    rrep(i,1,cou3){
        access3[i]=max(access3[i],access3[i-1]);
    }
    rrep(i,1,cou4){
        access4[i]=max(access4[i],access4[i-1]);
    }
    reverse(access3,access3+cou3);
    //reverse(access4,access4+cou4);
    cnt=0;
    rep(i,n-1){
        cnt+=v[i];
        tmp3=cnt-x[i];
        tmp3+=access3[i];
        tmp3-=x[i];
        ans3=max(ans3,tmp3);
    }
    cnt=0;
    rrrep(i,n-1,1){
        cnt+=v[i];
        tmp4=cnt-c+x[i];
        tmp4-=c-x[i];
        tmp4+=access4[i-1];
        ans4=max(ans4,tmp4);
    }
    Cout(max({ans1,ans2,ans3,ans4}));
    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
    ll x=(a/gcd(a,b))*b; 
    return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;        
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;
    
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
 //  void generate() {
//     memset(div, 0, sizeof div);
//     for (int i = 1; i <= N; i++) {
//         for (int j = i; j <= N; j += i) {
//             divisors[j] += 1;
//         }
//     }
// }

// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int ){
//     if(){

//         return 0;
//     }

//     return ;
// }
 
int solve() {fastio
       int x;
       cin>>x;
       if(x<1200)cout<<"ABC";
       else cout<<"ARC";

    return 0;
}
    
//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio

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

    int t=1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3612
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	vs := make([]int, 0)

	MOD := 26
	for N != 0 {
		N--
		m := N % MOD
		vs = append(vs, m)
		N -= m
		N /= MOD
	}
	res := make([]rune, 0)
	for i := len(vs) - 1; i >= 0; i-- {
		res = append(res, getDog(vs[i]))
	}
	fmt.Println(string(res))
}

// 0 -> a, 1 -> b
func getDog(x int) rune {
	return 'a' + rune(x)
}


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

signed main () {
    string s, t;
    cin >> s;
    int64_t ans = 0;
    int cur = 0;
    for (int i = 0; i < int(s.size()); ++i) {
        if (i + 1 < int(s.size()) && s.substr(i, 2) == "BC") {
            t += 'D';
            ++i;
        }
        else 
            t += s[i];
        if (t.back() == 'D')
            ans += cur;
        else if (t.back() == 'A')
            ++cur;
        else
            cur = 0;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 776
/*
 * Author: ylx
 * LANG: c++
 * PROG: 
 */
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline ll read()
{
	char s;ll k=0;
	while ((s=getchar())!=EOF&&!(isdigit(s)));
	if (s==EOF) exit(0);
	while (isdigit(s)) k=k*10+(s^'0'),s=getchar();
	return k;
}
inline void write(int x)
{
	static char cnt,num[15];cnt=0;
	if (!x)
	{
		putchar('0');
		return;
	}
	for (;x;x/=10) num[++cnt]=x%10;
	for (;cnt;putchar(num[cnt--]+48));
}
const int maxn=1e5+100;
int n,m;
ll b,ans[maxn],t[maxn],S;
ll top,s[maxn];
int solve(ll x,int r)
{
	int l=1,res=0;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (s[mid]<=x) res=mid,l=mid+1;
		else r=mid-1;
	}
	return res;
}
signed main()
{
#ifdef ylx
	freopen("agc003e.in","r",stdin);
	freopen("agc003e.out","w",stdout);
#endif
	n=read();m=read();
	s[++top]=n;
	while (m--)
	{
		b=read();
		while (s[top]>=b&&top>=1) top--;
		top++;
		s[top]=b;
	}
	m=top;
	t[m]=1;
	for (int i=m,p;i>=1;i--)
	{
		ll k=s[i];
		p=solve(k,i-1);
		while (p)
		{
			t[p]+=(k/s[p])*t[i];
			k%=s[p];
			p=solve(k,p-1);
		}
		ans[1]+=t[i];
		ans[k+1]-=t[i];
	}
	for (int i=1;i<=n;i++)
	{
		S+=ans[i];
		printf("%lld\n",S);
	}
	return 0;
}
//2018年 08月 16日 星期四 14:14:17 CST


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
vector<int>g[MAX];
int N,K;
bool vis[MAX];
ll ans=1;
ll mod(ll x,ll y){
    x = x%MOD;
    y = y%MOD;
    return (x*y)%MOD;
}
void dfs(int u,int p)
{
    int c=K-1;
    if(p>0)c=K-2;
    //if(vis[u])c=1;
    //vis[u]=1;
    for(int i=0;i<g[u].size();i++){
            int x = g[u][i];
            if(x==p)continue;
            if(c<0){c=0;ans=0;return;}
            ans = mod(ans,c);
            //vis[x]=1;
            c--;
            dfs(x,u);
    }
}
int main()
{
    cin >> N >> K;
    for(int i=1;i<N;i++){
        int u,v;cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ans = K;
    dfs(1,0);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    long w, h, x, y;
    cin >> w >> h >> x >> y;
    long s = w * h;
    cout << (double) s / 2 << " ";
    if (2 * x == w && 2 * y == h) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3764
import math
import sys
input = sys.stdin.readline


def main():
    a, b, x = map(int, input().split())
    if x == a**2 * b:
        print(0)
    elif x > a**2 * b / 2:
        h = (2*x)/a**2 - b
        theta = math.atan((b-h)/a)
        print(math.degrees(theta))
        # print(h)
    else:
        w = a - (2*x)/(a*b)
        theta = math.atan(b/(a-w))
        print(math.degrees(theta))
        # print(w)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
def main():  
  import sys
  input = sys.stdin.readline
  import numpy as np #pypy不可
  n,k = map(int,input().split())
  p = np.array(input().split(),np.int32)
  np.cumsum(p,out=p)
  chk = p[k-1]
  for i in range(n-k):
    c = p[i+k]-p[i]
    chk = max(c,chk)
  print((chk+k)/2)
if __name__ == '__main__':
    main()

Measured memory_bytes: 30196
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  
  int n;
  cin>>n;
  
  int S[n];
  rep(i,n) cin>>S[i];
  
  int q;
  cin>>q;
  
  int ans=0;
  rep(i,q){
    int a;
    cin>>a;
    bool b=false;
    rep(j,n){
      if(S[j]==a) b=true;
    }
    if(b) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3116
N = input()
L=list(N)
ans =0
if int(N)<1000:
    ans = 1000-int(N)
elif int(N)%1000==0:
    ans = 0   
elif int(N)>1000:
    N2 = L[1]+L[2]+L[3]
    ans = 1000-int(N2)
print(ans)

Measured memory_bytes: 9176
/*
ID: hursh171
LANG: C++
TASK: test
*/
// Sat Sep 19 20:03:13 IST 2020   
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int64 ii = (int64)a ; ii < (int64)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const int weird_mod = 998244353;
const double pi = 3.141592653589793238;
const int INF = 2e9+7;
const int64 big = 1e18;

const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}     
vector <int> g[N];
void dfs(int node, vector <bool>& vis){
    if(vis[node])
        return;
    vis[node] = true;
    for(auto child : g[node])
        if(!vis[child])
            dfs(child, vis);
}
int tests(){
    int n,m;
    cin >> n >> m;
    int u,v;
    while(m--){
        cin >> u  >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = 0;
    vector <bool> vis(n+1);
    forn(i,1,n+1)
        if(!vis[i])
            dfs(i,vis),ans++;
    cout << ans-1 << '\n';
    return 0;
}    
int main(){
    I__O ;     
    int cases = 1;
    // cin >> cases; 
    while(cases--)
        tests(); 
    return 0 ; 
}
 


Measured memory_bytes: 12368
#include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, K; cin >> A >> B >> K;
	for (int i = min(A, B); i >= 1; --i) 
    {
      if (A % i == 0 && B % i == 0)
      {
        --K;
        if (K == 0)
        {
          cout << i << endl;
          return 0;
        }
      }
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;

int a[N], bit[N], vis[N], ans[N];

struct P{
	int l, r, pos;
}p[N];

void add(int pos, int val) {
	for (int i = pos; i <= N; i += i & (-i)) {
		bit[i] += val;
	}
}

int sum(int pos) {
	int ans = 0;
	for (int i = pos; i != 0; i -= i & (-i)) {
		ans += bit[i];
	}
	return ans;
}

int main() {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= m; i++) {
		cin >> p[i].l >> p[i].r;
		p[i].pos = i;
	}
	sort(p + 1, p + 1 + m, [&] (P x, P y) {
		return x.r < y.r;
	});
	int r = 1;
	for (int i = 1; i <= m; i++) {
		for (int j = r; j <= p[i].r; j++) {
			if (vis[a[j]])
				add(vis[a[j]], -1);
			add(j, 1);
			vis[a[j]] = j;
		}
		r = p[i].r + 1;
		ans[p[i].pos] = sum(p[i].r) - sum(p[i].l - 1);
	}
	for (int i = 1; i <= m; i++) {
		cout << ans[i] << "\n";
	}
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

const int MAXN = 2e5;

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

    ll suma = 0LL;
    int brojevi[MAXN+1];
    memset(brojevi, 0, sizeof(brojevi));

    int n;
    cin >> n;
    vi v(n);

    for(auto &z : v)
    {
        cin >> z;
        suma += z;
        ++brojevi[z];
    }

    int q;
    cin >> q;

    while(q--)
    {
        int b, c;
        cin >> b >> c;
        suma -= brojevi[b] * 1LL * b;
        suma += brojevi[b] * 1LL * c;
        brojevi[c] += brojevi[b];
        brojevi[b] = 0;
        cout << suma << '\n';
    }

    return 0;
}



Measured memory_bytes: 4480
import Math._
object Main extends App {
  val n = readLine.toInt
  val xs = readLine.split(' ').map(_.toDouble).take(n)
  val ys = readLine.split(' ').map(_.toDouble).take(n)

  val diff = xs.zip(ys).map(t => abs(t._1 - t._2))

  for (p <- 1 to 3) {
    println(pow(diff.map(pow(_,p)).sum, 1.0/p))
  }
  println(diff.max)
}


Measured memory_bytes: 44396
#include <bits/stdc++.h>
using namespace std;
//const int maxn=1e5+100;

int main()
{
    long long d,n;
    while(cin>>d>>n)
    {
        if(d==0)
        {
            if(n==100)
                cout<<101<<endl;
            else
                cout<<1*n<<endl;
        }

        else if(d==1)
        {
            if(n==100)
                cout<<10100<<endl;
            else
                cout<<100*n<<endl;
        }

        else if(d==2)
        {
            if(n==100)
                cout<<101*10000<<endl;
            else
                cout<<10000*n<<endl;

        }


    }
    return 0;
}


Measured memory_bytes: 256
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
vec primes;


int main()
{
    vector<int>v;
  set<int>s;
  int n;
   cin >> n;
  for(int i=0;i<n;i++)
  {
    int a;
    cin >> a;
    v.push_back(a);
    s.insert(a);
  }
  if(s.size()==v.size())cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;


}



Measured memory_bytes: 10356
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*切り上げの計算！*/
int maxtime(int x) {
	return(x + 9) / 10 * 10;

}
int main() {
	string s;
	string line;
	line = "ATCG";
	cin >> s;
	if (s[0] == line[0]) {
		cout << line[1];
		return 0;
	}
	if (s[0] == line[1]) {
		cout << line[0];
		return 0;
	}
	if (s[0] == line[2]) {
		cout << line[3];
		return 0;
	}
	if (s[0] == line[3]) {
		cout << line[2];
		return 0;
	}
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int maxn=100005;
int n,A[maxn],oc,ec,op;bool one;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
inline int gcd(int x,int y){return !y?x:gcd(y,x%y);}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		A[i]=read();
		(A[i]&1)?oc++:ec++;
		if(A[i]&1) op=i;
		if(A[i]==1) one=true;
	}
	if(one){printf("%s\n",(ec&1)?"First":"Second");return 0;}
	if(ec&1){printf("First\n");return 0;}
	if(n-ec>1&&!(ec&1)){printf("Second\n");return 0;}
	bool f=1;
	while(true)
	{
		A[op]--;
		int d=A[1];
		for(int i=2;i<=n;i++) d=gcd(d,A[i]);
		oc=ec=0;
		for(int i=1;i<=n;i++)
		{
			A[i]/=d;
			(A[i]&1)?oc++:ec++;
			if(A[i]&1) op=i;
			if(A[i]==1) one=true;
		}
		if(one){printf("%s\n",((ec&1)^f)?"First":"Second");return 0;}
		if(ec&1){printf("%s\n",f?"Second":"First");return 0;}
		if(n-ec>1&&!(ec&1)){printf("%s\n",f?"First":"Second");return 0;}
		f=!f;
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int>data(3);
	for (int i = 0; i < 3; i++){
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	int ans = data[0] * data[1] / 2;
	cout << ans << endl;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		boolean good=false;
		for(int i=0;i<=1;i++)
		{
			char c3=s.charAt(i);
			char c1=s.charAt(i+1);
			char c2=s.charAt(i+2);
			if(c3==c1 && c2==c3 && c1==c2)
				good=true;
				
		}
		
		System.out.println((good)?"Yes":"No");

	}
	
	
	
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(S[2]==S[3] && S[4]==S[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



Measured memory_bytes: 764
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def top(self):
        return self.s1

s1, s2, s3, s4, s5, s6 = map(int, input().split())
dice = Dice(s1, s2, s3, s4, s5, s6)
order = input()
for c in order:
    if c == 'N':
        dice.north()
    elif c == 'W':
        dice.west()
    elif c == 'E':
        dice.east()
    elif c == 'S':
        dice.south()
print(dice.top())

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i, X)
  cin >> A[i];
  REP(i, Y)
  cin >> B[i];
  REP(i, Z)
  cin >> C[i];
  vector<ll> vc1;
  REP(i, X)
  REP(j, Y)
  vc1.push_back(A[i] + B[j]);
  sort(ALL(vc1));
  reverse(ALL(vc1));
  vector<ll> vc2;
  REP(i, min(K, X * Y))
  vc2.push_back(vc1[i]);
  vector<ll> vc3;
  REP(i, min(K, X * Y))
  {
    REP(j, min(K, Z))
    vc3.push_back(vc2[i] + C[j]);
  }
  sort(ALL(vc3));
  reverse(ALL(vc3));
  REP(i, K)
  cout << vc3[i] << endl;
  return 0;
}

Measured memory_bytes: 43016
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int L = scan.nextInt();
                int R = scan.nextInt();
                int d = scan.nextInt();
                int cnt = 0;
                for(int i=L;i<=R;i++){
                    if(i%d==0){
                        cnt++;
                    }
                }
                
                System.out.println(cnt);
        }               
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < S.size(); i++)
        if (S[i] != T[i])
            ans++;
    cout << ans;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		for(;;) {
			int n = sc.nextInt();
			if(n == 0) {
				break;
			}
			
			String o = Integer.toOctalString(n);    //8進数に変換
			int ol = o.length();

			for(int i = 0; i < ol; i++) {


				char a = o.charAt(i);    //各桁を出す
				int aa = Character.getNumericValue(a);    //aをint型に変換

				if(aa == 4) {
					aa = 5;
				}
				else if(aa >= 5) {
					aa = aa + 2;
				}
				System.out.print(aa);
			}
			System.out.println();
		}
		sc.close();
	}
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N, A, B; cin >> N >> A >> B;
  int result = min(N*A, B);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
  $stdin = fopen('php://stdin', "r");

  while(true) {
      fscanf($stdin, "%d %d", $inH, $inW);
      if($inH === 0 && $inW === 0) {
          break;
      }

      for ($i=0; $i<$inH; $i++) {
        for ($j=0; $j<$inW; $j++ ) {
          echo '#';
        }
        echo PHP_EOL;
      }
      echo PHP_EOL;
  }



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

int main(void){
    
    int r,d,x[11] = {};
    cin >> r >> d >> 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 <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


typedef ll Flow;
struct Edge {
	int dest, back;
	Flow f, c;
};

struct PushRelabel {
	vector<vector<Edge>> g;
	vector<Flow> ec;
	vector<Edge*> cur;
	vector<vi> hs; vi H;
	PushRelabel(int n) : g(n), ec(n), cur(n), hs(2*n), H(n) {}

	void add_edge(int s, int t, Flow cap, Flow rcap=0) {
		if (s == t) return;
		Edge a = {t, sz(g[t]), 0, cap};
		Edge b = {s, sz(g[s]), 0, rcap};
		g[s].push_back(a);
		g[t].push_back(b);
	}

	void add_flow(Edge& e, Flow f) {
		Edge &back = g[e.dest][e.back];
		if (!ec[e.dest] && f) hs[H[e.dest]].push_back(e.dest);
		e.f += f; e.c -= f; ec[e.dest] += f;
		back.f -= f; back.c += f; ec[back.dest] -= f;
	}
	Flow maxflow(int s, int t) {
		int v = sz(g); H[s] = v; ec[t] = 1;
		vi co(2*v); co[0] = v-1;
		rep(i,0,v) cur[i] = g[i].data();
		trav(e, g[s]) add_flow(e, e.c);

		for (int hi = 0;;) {
			while (hs[hi].empty()) if (!hi--) return -ec[s];
			int u = hs[hi].back(); hs[hi].pop_back();
			while (ec[u] > 0)  // discharge u
				if (cur[u] == g[u].data() + sz(g[u])) {
					H[u] = 1e9;
					trav(e, g[u]) if (e.c && H[u] > H[e.dest]+1)
						H[u] = H[e.dest]+1, cur[u] = &e;
					if (++co[H[u]], !--co[hi] && hi < v)
						rep(i,0,v) if (hi < H[i] && H[i] < v)
							--co[H[i]], H[i] = v + 1;
					hi = H[u];
				} else if (cur[u]->c && H[u] == H[cur[u]->dest]+1)
					add_flow(*cur[u], min(ec[u], cur[u]->c));
				else ++cur[u];
		}
	}
};


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	for(int i = 0; i < n; i++) cin >> q[i];
	vector<int> pcmp(n, -1);
	int np = 0;
	vector<int> qcmp(n, -1);
	int nq = 0;
	for(int i = 0; i < n; i++){
		if(pcmp[i] >= 0) continue;
		int a = i;
		while(pcmp[a] == -1){
			pcmp[a] = np;
			a = p[a];
		}
		np++;
	}
	for(int i = 0; i < n; i++){
		if(qcmp[i] >= 0) continue;
		int a = i;
		while(qcmp[a] == -1){
			qcmp[a] = nq;
			a = q[a];
		}
		nq++;
	}
	vector<int> pcost(np, 0);
	vector<int> qcost(nq, 0);
	map<pair<int,int>, int> cost;

	for(int i = 0; i < n; i++){
		if(p[i] == i && q[i] == i) continue;
		if(p[i] == i){
			qcost[qcmp[i]]++;
		} else if(q[i] == i){
			pcost[pcmp[i]]++;
		} else if(p[i] == q[i]){
			pcost[pcmp[i]]++;
			qcost[qcmp[i]]++;
			cost[{pcmp[i], qcmp[i]}] += 2;
		} else {
			pcost[pcmp[i]]++;
			qcost[qcmp[i]]++;			
			cost[{pcmp[i], qcmp[i]}] += 1;
		}
	}
	PushRelabel mf(np + nq + 2);
	int ans = 0;
	for(int i = 0; i < np; i++){
		mf.add_edge(np + nq, i, pcost[i]);
		ans += pcost[i];
	}
	for(int i = 0; i < nq; i++){
		mf.add_edge(np + i, np + nq + 1, qcost[i]);
		ans += qcost[i];
	}
	for(auto g : cost){
		mf.add_edge(g.first.first, np + g.first.second, g.second);
	}
	cout << ans - mf.maxflow(np + nq, np + nq + 1) << '\n';
}

Measured memory_bytes: 22452
import sys

def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    Q=[list(input().rstrip().split()) for _ in range(M)]

    c=[0 for _ in range(N)]
    flag=[0 for _ in range(N)]

    for i in range(M):
        if Q[i][1]=="WA" and flag[int(Q[i][0])-1]==0:
            c[int(Q[i][0])-1]+=1
        if Q[i][1]=="AC":
            flag[int(Q[i][0])-1]=1
    
    #ans=sum(c)
    #ansAC=sum(flag)
    
    ans=0
    ansAC=0
    for i in range(N):
        if flag[i]==1:
           ans+=c[i]
        ansAC+=flag[i]
    #print(int(ansAC), int(ans))
    print('{:.15g}'.format(ansAC),'{:.15g}'.format(ans))


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 5
1 WA
1 AC
2 WA
2 AC
2 WA"""
        output = """2 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """100000 3
7777 AC
7777 AC
7777 AC"""
        output = """1 0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6 0"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 77784
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main()
{
   IOS;
   //freopen("inputfile.txt","r",stdin);
 double a,b;cin>>a>>b;
 double ma1 = 10000.0;
 double ma2 = 10000.0;
 double ans1 = (a)/(0.08);
 //cout<<ans1<<endl;
 if(floor(ans1*(0.1))== b)ma1 = ans1;
 double ans2 = b/(0.1);
 if(floor(ans2*(0.08))==a)ma2 = ans2;
 if(min(ma1,ma2)==10000.0)cout<<"-1"<<endl;
 else cout<<ceil(min(ma1,ma2))<<endl;
    return 0;
}
//<!...........ALHAMDULILLAH.............!!>>


Measured memory_bytes: 3840
N = int(input())
S = [input() for x in range(N)]

a = b = ab = t = 0
for s in S:
	if s[0] == "B" and s[-1] == "A":
		ab += 1
	elif s[0] == "B":
		b += 1
	elif s[-1] == "A":
		a += 1
	t += s.count("AB")
	#3
t += max(0,ab - 1)
if ab > 0:
	#2
	if a > 0:
		t += 1
		a -= 1
	if b > 0:
		t += 1
		b -= 1
#1
t += min(a,b)
print(t)

Measured memory_bytes: 3700
import numpy as np

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
INF = 10 ** 18
V_MAX = 10 ** 3 * N

dp = np.full(V_MAX + 1, INF)
dp[0] = 0

for w, v in wv:
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)

ans = np.where(dp <= W)[0].max()
print(ans)


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

int main(){
  int dp[100005];
  int N, W;
  memset(dp,63,sizeof(dp));
  cin >> N >> W;
  dp[0] = 0;
  for(int i = 0; i < N; i++){
	int w, v;
    cin >> v >> w;
	for(int j = 100000; j >= w; j--) dp[j] = min(dp[j],dp[j-w]+v);
  }
  int ans;
  for(int i = 0; i <= 100000; i++) if(dp[i]<=W) ans=i;
  cout << ans << endl;
}

Measured memory_bytes: 640
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1 10
2"# => r#"4"#,

r#"2 9
3 6"# => r#"12"#,

r#"5 20
11 12 9 17 12"# => r#"74"#,
}


fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize, k: isize,
        x: [isize; n],
    }

    let mut ans = 0;
    for i in 0..n {
        ans += std::cmp::min(isize::abs(0 - x[i]) * 2, isize::abs(k - x[i]) * 2);
    }
    ans.to_string()
}

Measured memory_bytes: 4352
// Maze Master

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

const int INF = 1 << 29;

int main ()
{
    int H,W;
    cin >> H >> W;
    char S[20][20];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    
    int dp[20][20][20][20];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {

            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {

                    dp[i][j][k][l] = INF;

                    
                    if (i == k && j == l) {
                        dp[i][j][k][l] = 0;
                    }
                    
                }
            }
        }
    }

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

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                continue;
            }


            for (int k = 0; k < 4; k++) {
                int nx = dx[k] + j;
                int ny = dy[k] + i;
                if (nx < 0 || ny < 0 || nx >= W || ny >= H) {
                    continue;
                }
                if (S[ny][nx] == '#') {
                    continue;
                }
                dp[ny][nx][i][j] = dp[i][j][ny][nx] = 1;
            }
        }
    }

    int cost = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {

            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {

                    for (int m = 0; m < H; m++) {
                        for (int n = 0; n < W; n++) {

                            dp[k][l][m][n] = min(dp[k][l][m][n], dp[k][l][i][j] + dp[i][j][m][n]);
                        }
                    }

                }
            }

        }
    }

    /*
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {
                    cout << dp[i][j][k][l] << " ";
                }
            }
            cout << endl;
        }
    }
    */
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {

            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {
                    if (dp[i][j][k][l] < INF) {
                        cost = max(cost, dp[i][j][k][l]);
                    }
                }
            }

        }
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
struct TRAMP{
    char mark;
    int number;
};
 
int main(){
    int n,min;
    char buf[3];
    scanf("%d",&n);
 
    TRAMP selectArray[n],bubbleArray[n];
 
    for(int i = 0; i < n; i++){
        scanf("%s",buf);
        selectArray[i].mark = buf[0];
        selectArray[i].number = buf[1] - '0';
        bubbleArray[i] = selectArray[i];
    }
 
    for(int i = n-1; i >= 0; i--){
        for(int j = 0; j < i; j++){
            if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
        }
    }
 
    for(int i = 0; i < n-1; i++){
        min = i;
        for(int j = i+1; j < n; j++){
            if(selectArray[j].number < selectArray[min].number){
                min = j;
            }
        }
        if(i != min){
            swap(selectArray[i],selectArray[min]);
        }
    }
 
    for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
    printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
    printf("Stable\n");
    for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
    printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);
 
    int p;
    for(p=0; p < n; p++){
        if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
            break;
    }
    if(p == n){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
 
    return 0;
}


Measured memory_bytes: 2756