akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("ALL.txt","r",stdin)
#define write freopen("YY.txt","w",stdout)
#define fr first
#define sc second
#include <sstream>
#define ii pair < int , int >
using namespace std;
ll Mod(ll x)
{
    ll M = 1e9+7;
    return (x%M + M)%M;
}
ll gcd(ll a,ll b)
{
    return (b==0 ? a : gcd(b,a%b));
}
ll lcm(ll a,ll b)
{
    return(a*(b/gcd(a,b)));
}
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
int main()
{
 string s;
 cin>>s;
 int sum = s.length();
 int a = 0 ;
 for(int i=0;i<s.length();i++)
 {
     if(s[i] == 'T')
        {
            if(a > 0)
              {
                  a--;
                  sum-=2;
              }
        }
     else if(s[i] == 'S')
        a++;

 }
 cout<<sum;
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int S = 1010;
signed main() {
    int N, K; cin >> N >> K;
    if(N > K) cout << 0 << endl;
    else {
        int ans = 1, rem = K;
        for(int i=0; i<N; i++) {
            (ans *= rem) %= MOD;
            rem--;
        }
        cout << ans << endl;
    }
    return 0;
}



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

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

using namespace std;

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

	int ans=700;
	rep(i,3) if(s[i]=='o') ans+=100;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c[3][3];
  int i,j;
  for(i=0;i<3;i++){
    cin >> c[i][0] >> c[i][1] >> c[i][2];
  }
  int tmp;
  int chk = 1;
  for(i=0;i<2;i++){
    for(j=i+1;j<3;j++){
      if(!(c[0][i]-c[0][j]==c[1][i]-c[1][j]&&c[1][i]-c[1][j]==c[2][i]-c[2][j])) chk = 0;
    }
  }
  for(i=0;i<2;i++){
    for(j=i+1;j<3;j++){
      if(!(c[i][0]-c[j][0]==c[i][1]-c[j][1]&&c[i][1]-c[j][1]==c[i][2]-c[j][2])) chk = 0;
    }
  }
  if(chk==1)cout << "Yes";
  else cout << "No";

  
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)      

Measured memory_bytes: 36372
n=int(input())
alist=list(map(int,input().split()))

kane=1000
kabu=0

for i in range(n-1):
    if alist[i] > alist[i+1]:
        kane += kabu * alist[i]
        kabu = 0
    else:
        kaerukabu = kane // alist[i]
        kabu += kaerukabu
        kane -= kaerukabu * alist[i]

print(kane + kabu * alist[n-1])


Measured memory_bytes: 9180
import math
fact=math.factorial
mod=10**9+7


N,M=map(int,input().split())

if abs(N-M)>1:
    print(0)
    exit()

if N==M+1 or N==M-1:
    ans=(math.factorial(N)*math.factorial(M))%mod
elif N==M:
    ans=((math.factorial(N)**2)*2)%mod


print(ans)

Measured memory_bytes: 5164
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1005;
int a[N],n,ans,m;
int main(){
	scanf("%d%d",&n,&m);
	printf("%d\n",n<10&&m<10?n*m:-1);
	return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 302;

int n;
int a[N];
int cnt[4];
double dp[N * 3][N * 2][N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int k = 0; k <= n; k++) {
		for (int j = 0; j <= n; j++) {
			for (int i = 0; i <= n; i++) {
				int c = n - i - j - k;
				if (c >= n || c < 0)
					continue;
				double x = 0;
				if (i > 0)
					x += (dp[i - 1][j][k] + 1) * (double(i) / n);
				if (j > 0)
					x += (dp[i + 1][j - 1][k] + 1) * (double(j) / n);
				if (k > 0)
					x += (dp[i][j + 1][k - 1] + 1) * (double(k) / n);
				x *= n;
				dp[i][j][k] = (c + x) / (n - c);
			}
		}
	}
	cout << fixed << setprecision(10) << dp[cnt[1]][cnt[2]][cnt[3]] << endl;
	return 0;
}


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

int main()
{string S;
 cin >> S;
 ll a, b;
 bool can = false;
 ll N = S.size();
 rep(i, N-1){
   if(S[i] == S[i+1]) {
     can = true;
     a = i+1; b = i+2;
     break;
   }
 }
 if(!can){
   rep(i, N-2){
     if(S[i] == S[i+2]){
       can = true;
       a = i+1; b = i+3;
       break;
     }
   }
 }
 if(can) cout << a << " " << b << endl;
 else cout << -1 << " " << -1 << endl;
}

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

using namespace std;

#define ll long long int 

void max_Self(ll& a, ll b)
{
    a = max(a,b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main()
{

    int n,W;
    cin>>n>>W;
vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> a(N);
    vector<int> b(M);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < M; i++) cin >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    bool flg = false;
    if(X >= Y){
        cout << "War" << endl;
        return 0;
    }
    for(int i = X+1; i <=Y; i++){
        if((a[N-1] < i) && (b[0] >= i)) flg = true;

    }

    if(flg) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a, b, k, i, ans=1;
int main(){
    scanf("%d%d%d", &k, &a, &b);
    for(i=a; i<=b; i++){
        if(i%k==0){
            ans = 0;
            break;
        }
    }
    if(ans == 0) printf("OK\n");
    else printf("NG\n");
    return 0;
}

Measured memory_bytes: 1644
n,B[1001],X[1001],Y[1001],P[1001],f[1001],S,G,T,U;R(p){p-S&&R(P[p]);printf("%d%c",B[p],p-G?32:10);}main(i,m,s,g){for(;~scanf("%d",&n);){for(m=n;m;m--)scanf("%d%d%d",B+m,X+m,Y+m);for(scanf("%d",&m);m--;P[G]?R(G):puts("NA")){double c[1001],t;scanf("%d%d",&s,&g);for(i=n;~i;c[i--]=1e9)S=B[i]-s?S:i,G=B[i]-g?G:i,P[i]=f[i]=0;for(c[U=S]=0;T=U;)for(f[T]=1,U=i=0;++i<=n;U=f[i]|c[i]>c[U]?U:i)t=hypot(X[T]-X[i],Y[T]-Y[i]),t>50||(t+=c[T],t<c[i]?P[c[i]=t,i]=T:0);}}}

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

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

	vector<int> d(n + 1);

	for (int i = 0; i < n; i++) { cin >> d[i + 1]; }

	sort(d.begin(), d.end());
	
	if (d[n / 2] == d[n / 2 + 1]) {
		cout << 0 << endl;
	}
	else {
		cout << d[n / 2 + 1] - d[n / 2] << endl;
	}
	
	return 0;
}

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


int main() {
  
  int N,M;
  cin  >> N >> M;
  
  vector<int> road_a(M),road_b(M);
  
  int num;
  
  rep(j,M){
    cin >> road_a.at(j) >> road_b.at(j);
  }
  
  for(int i=1; i<N+1; i++){
    num = 0;
    rep(j,M){
      if( road_a.at(j)==i || road_b.at(j)==i)
        num++;
    }
    cout << num << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        sc.close();

        int min = Math.min(a + b, Math.min(b + c, c + a));

        System.out.println(min);

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int a, b;
            cin >> a >> b;
                if((a+b)%2==0){
                    cout << (a+b)/2 << endl;
                }else{
                    cout << (a+b)/2 + 1 << endl;
                }
    return 0;}

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

int main(){
  int H,W;
  cin >> H >> W;
  string A[1010];
  for(int i=0; i<H; i++) cin >> A[i];
  
  int dist[1010][1010]={};
  queue<pair<int,int>> q;
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(A[i][j]=='#'){
        dist[i][j]=0;
        q.push(make_pair(i,j));
      }else{
        dist[i][j]=-1;
      }
    }
  }
  
  int di[4]={0,0,1,-1};
  int dj[4]={1,-1,0,0};
  while(!q.empty()){
    int i=q.front().first,j=q.front().second;
    for(int k=0; k<4; k++){
      if(0<=i+di[k]&&i+di[k]<H&&0<=j+dj[k]&&j+dj[k]<W&&dist[i+di[k]][j+dj[k]]<0){
        dist[i+di[k]][j+dj[k]]=dist[i][j]+1;
        q.push(make_pair(i+di[k],j+dj[k]));
      }
    }
    q.pop();
  }
  
  int result=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      result=max(result,dist[i][j]);
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 13456
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for i in range(1, N):
        if A[i - 1] > A[i]:
            diff = A[i - 1] - A[i]
            ans += diff
            A[i] += diff

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 32196
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    n = int(input())
    if n == 0:
        break
    gem = [tuple(map(int,input().split(" "))) for i in range(0,n)]
    robot = (10,10)
    direct = {'N' : 0,'E' : 1,'W' : 2, 'S' : 3}
    dxdy = [(0,1),(1,0),(-1,0),(0,-1)]
    for i in range(int(input())):
        head,step = input().split()
        for j in range(int(step)):
            robot = (robot[0] + dxdy[direct[head]][0],robot[1] + dxdy[direct[head]][1])
            if robot in gem:
                gem.remove(robot)
    if gem == []:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6780
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int cnt1, cnt2;
	foreach (line; stdin.byLine) {
		auto e = line.split(",").map!(to!int);
		if (e[0] == e[1]) cnt2++;
		else if (e[0]^^2 + e[1]^^2 == e[2]^^2) cnt1++;
	}
	cnt1.writeln;
	cnt2.writeln;
}

Measured memory_bytes: 1084
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	xy := make([]grid, n)

	for i := 0; i < n; i++ {
		xy[i] = grid{scanInt(),scanInt(),scanInt()}
	}

	for i := 0; i < 101; i++ {
		for j := 0; j < 101; j++ {
			cx,cy := i, j
			f := true
			h := make([]int, 0)
			h0 := make([]int, 0)
			for _, e := range xy {
				if e.h!=0 {
					h = append(h,e.h+abs(e.x-cx)+abs(e.y-cy))
				} else {
					h0 = append(h0,abs(e.x-cx)+abs(e.y-cy))
				}
			}

			sort.Ints(h)
			sort.Ints(h0)

			var ch int
			if len(h)!=0 {
				ch = h[0]
			} else {
				ch = h0[0]
			}
			
			for _, e := range h {
				if e!=ch {
					f = false
				}
			}

			for _, e := range h0 {
				if e < ch {
					f = false
				}
			}



			if f {
				fmt.Println(cx,cy,ch)
				return
			}
		}
	}

}

type grid struct {
	x int
	y int
	h int
}

func abs(a int) int {
	if a<0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll N;
int a[100000], b[100001], l, r, k, c[222222];

void add(int x) {
	while (x < 222222) {
		++c[x];
		x += x&-x;
	}
}

int calc(int x) {
	int a = 0;
	while (x) {
		a += c[x];
		x -= x&-x;
	}
	return a;
}

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		cin >> a[i];
	r = intmax;
	while (l + 1 != r) {
		k = (l + r) / 2;
		for (int i = 0; i != N; ++i) {
			if (a[i] > k)
				b[i + 1] = 1;
			else
				b[i + 1] = -1;
		}
		for (int i = 0; i != 222222; ++i)
			c[i] = 0;
		b[0] = 111111;
		add(111111);
		ll c = 0;
		for (int i = 0; i != N; ++i) {
			b[i + 1] += b[i];
			c += calc(b[i + 1]);
			add(b[i + 1]);
		}
		if (c >= (N*(N + 1) / 2 + 1) / 2)
			l = k;
		else
			r = k;
	}
	cout << r << endl;
}

Measured memory_bytes: 1920
#include <cstdlib>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <stack>

using namespace std;

vector<string> get_split_string()
{
	string input, buffer;
	getline(cin, input);
	stringstream ss(input);
	vector<string> result;
	while (getline(ss, buffer, ' '))
		result.push_back(buffer);
	return result;
}

int main()
{
	stack<int> value_stack;
	vector<string> list = get_split_string();
	int left_operand, right_operand;

	for (vector<string>::iterator it = list.begin();
		it != list.end(); it++) {
		switch (it->at(0))
		{
		case '+': // operator +
			right_operand = value_stack.top(); value_stack.pop();
			left_operand = value_stack.top(); value_stack.pop();
			value_stack.push(left_operand + right_operand);
			break;
		case '-': // operator -
			right_operand = value_stack.top(); value_stack.pop();
			left_operand = value_stack.top(); value_stack.pop();
			value_stack.push(left_operand - right_operand);
			break;
		case '*': // operator *
			right_operand = value_stack.top(); value_stack.pop();
			left_operand = value_stack.top(); value_stack.pop();
			value_stack.push(left_operand * right_operand);
			break;
		default: // operands
			value_stack.push(atoi(it->c_str()));
		}
	}
	
	cout << value_stack.top() << endl;
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        int length = scanner.nextInt();
        int[] nums = new int[length];
        
        for (int i=0; i<length; i++) {

            int num = scanner.nextInt();
            nums[length-i-1] = num;
            
            
        }
        
        for(int i=0; i<nums.length; i++) {
            System.out.print(nums[i]);
            if (i!=nums.length-1) System.out.print(" ");
        }
        System.out.println();
        
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;

int main() {
    int A, B;
    cin >> A >> B;

    int plugs = 1;
    int taps = 0;

    while (plugs < B) {
        plugs += A - 1;
        taps++;
    }

    cout << taps << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
long x = sc.nextLong();
long cnt = b / x - a / x;
if(a % x ==0){
     cnt++;
}
        
        System.out.println(cnt);
    }
}


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

int main(){
	int n, temp;
	cin >> n;
	int* data = new int[n];
	for (int i=0; i<n; i++) {
		cin >> data[i];
	}
	for (int i=0; i<n; i++){
		int j=i;
		while (j>0 && data[i] < data[j-1]){
			j--;
		}
		temp = data[i];
		for (int m=i; m>j; m--) {
			data[m] = data[m-1];
		}
		data[j] = temp;
		
		for (int m=0; m<n-1; m++){
			cout << data[m] << " ";
		}
		cout << data[n-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cmath>

#include <vector>
#include <algorithm>
#include <limits>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <queue>

typedef long long ll;

using namespace std;


int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            cnt += 1;
        } else {
            cnt = 0;
        }
        if (cnt == 3) {
            break;
        }
    }
    if (cnt == 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3624
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, Q;
int calc_depth(int x) {
    int ret = 0, mul = 1;

    while(1) {
        if(x <= mul) return ret;
        x -= mul;
        mul *= N;
        ret++;
    }
}

int climb(int v, int depth) {
    if(depth == 1) return 1;
    // printf("climb %lld (depth: %lld) = ", v, depth);

    int prev = 0, ini = 0, mul = 1;
    rep(i,0,depth) {
        prev += mul;
        if(i != depth-1) ini += mul;
        mul *= N;
    }
    
    v -= prev;
    int div = (v + N - 1) / N;

    // printf("%lld\n", ini + div);
    return ini + div;
}
 
signed main() {
    cin >> N >> Q;

    while(Q--) {
        int u, v; cin >> u >> v;
        if(N == 1) {
            cout << min(u, v) << endl;
        }
        else {
            int depth_u = calc_depth(u);
            int depth_v = calc_depth(v);
            // printf("depth: u = %lld, v = %lld\n", depth_u, depth_v);
            if(depth_u > depth_v) {
                swap(u, v);
                swap(depth_u, depth_v);
            }
            while(depth_u != depth_v) {
                v = climb(v, depth_v);
                depth_v--;
            }

            if(u == v) cout << u << endl;
            else {
                while(u != v) {
                    u = climb(u, depth_u);
                    v = climb(v, depth_v);
                    depth_u--;
                    depth_v--;
                }
                cout << u << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
 fastio;
  string s,t;
 int a,b,c,n,m;
 cin>>s;
 if(s=="Sunny")cout<<"Cloudy"<<endl;
 else if(s=="Cloudy")cout<<"Rainy"<<endl;
 else cout<<"Sunny"<<endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main(){

int A,B;
cin>>A>>B;
if(A>8||B>8){
  cout<<":("<<endl;
}else{
  cout<<"Yay!"<<endl;
}
return 0;
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())

res = a*b*c
res = min(res, abs(a*b*(c//2) - a*b*(c-c//2)))
res = min(res, abs(a*(b//2)*c - a*(b-b//2)*c))
res = min(res, abs((a//2)*b*c - (a-a//2)*b*c))
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  ll mx = 0;
  ll sum = 0;
  REP(i,n) {
    ll a;
    cin>>a;
    if (a < mx) {
      sum += mx - a;
    }
    mx = max(mx, a);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3644
/*
 ABC148 C
 auther: takeheroaf
 created at 2020-1-10 10:10:19
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vc vector
#define a first
#define b second
#define pb push_back
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

/////////////////////////////////////////////////////////

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

/////////////////////////////////////////////////////////

void Main(){
  ll a, b; cin >> a >> b;
  cout << (a * b) / euclid(a, b) << endl;
  return;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();

  return 0;
}


Measured memory_bytes: 256
#C
import numpy as np
from itertools import combinations
N, M, X=map(int,input().split())
Book = []
for i in range(N):
    Book.append(list(map(int,input().split())))
Comb=[]
for i in range(N+1):
    Comb+=combinations(Book,i)
Sums=[]
for i in Comb[1:]:
    Sum=np.sum(np.array(i),axis=0)
    if all([j >= X for j in Sum[1:]]):
        Sums.append(Sum[0])
if len(Sums)==0:
    print(-1)
else:
    print(sorted(Sums)[0])

Measured memory_bytes: 27416
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

d = Counter(a)
#print(d)
n_even = 0
for k, v in d.items():
    if v % 2 == 0:
        n_even += 1

#print(n_even)
n_unique = len(d)
print(n_unique if n_even%2 == 0 else n_unique-1)

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll Q,A,B;

int main(){
  cin>>Q;
  while(Q--){
    cin>>A>>B;
    if(A==B){
      cout<<(A-1)*2<<endl;
      continue;
    }
    ll p=A*B;
    ll lb=1,ub=1e9;
    while(ub-lb>1){
      ll mid=(lb+ub)/2;
      if(mid*mid<p)lb=mid;
      else ub=mid;
    }
    ll c=lb;
    if(c*(c+1)>=p){
      cout<<c*2-2<<endl;
    }else{
      cout<<c*2-1<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long

using namespace std;

signed main()
{
    ios::sync_with_stdio(false);

    int ans = 1;
    int n;
    cin >> n;
    for (size_t i = 1; i <= n; i++)
    {
        ans *= i;
        ans %= NUM;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }

static const ll mod = 1000000007LL;

const int MAX = 4030;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

  COMinit();

  reps(i, k){
    if(n - k < i - 1){
      cout << 0 << endl;
      continue;
    }

    ll ans = 0;
    ans = com(k - 1, i-1);
    ans = (ans * com(n-k+1, i))%mod;

    cout << ans << endl;
  }
}


Measured memory_bytes: 3720
n, k, q = tuple(map(int, input().split()))
answereds = [0]*n
for i in range(q):
    answered = int(input()) - 1
    answereds[answered] += 1
for i in range(n):
    result = "Yes" if q-answereds[i] < k else "No"
    print(result)

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

int main() {
    string s, t;
    cin >> s >> t;
    bool flg = false;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s.size(); j++) {
            int a = (i + j) % s.size();
            if (s[a] != t[j]) break;
            if (j == s.size() - 1) flg = true; 
        }
    }
    if (flg) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
n, k, s = map(int, input().split())
sub = []
if s == 10**9:
    for i in range(n):
        if i < k:
            sub.append(s)
        else:
            sub.append(1)
else:
    for i in range(n):
        if i < k:
            sub.append(s)
        else:
            sub.append(s+1)
print(*sub)


Measured memory_bytes: 9584
#include <iostream>

using namespace std;
void normal(int len, char limit = 'a', int index = 0, string str = ""){
   
    if(index == len){
        cout<<str<<endl;
        return;
    }
  
    for(char ch = 'a' ;  ch <= limit; ++ch){
        if(ch == limit)
            normal(len, limit+1, index+1, str+ch);
        else
            normal(len, limit, index+1, str+ch);
        
    }  
  
}


int main()
{
    
    int n;
    cin >> n;
    if(n>=0)
    normal(n);

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    reverse(v.begin(), v.end());
    for(int i = 0; i < n-1; i++){
        if(v[i] < v[i+1]){
            if(v[i] >= v[i+1] - 1){
                v[i+1]--;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
a = 3.times.map{gets.split.map(&:to_i)}.flatten
v=[]
gets.to_i.times do
  x=gets.to_i
  idx=a.find_index(x)
  v[idx]=true if idx
end
puts [[0,3,6],[1,4,7],[2,5,8],[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6]].any?{|u|u.all?{|i| v[i]}} ? :Yes : :No



Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iomanip>

using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); i++)
#define ford(i,n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i,l,r) for (int i = int(l); i <= int(r); i++)
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define x first
#define y second

template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

const int N = 2000 + 13;
int n, k;
vector<int> g[N];

inline bool read()
{
	if (scanf ("%d%d", &n, &k) != 2)
		return false;
		
	forn(i, n - 1)
	{
		int x, y;
		assert(scanf ("%d%d", &x, &y) == 2);
		
		x--, y--;
		
		g[x].pb(y);
		g[y].pb(x);
	}

	return true;
}

pair<pt, int> d[N];

void dfs (int v, int pr, int deep)
{
	d[v] = mp(mp(0, 0), 0);
	if (deep == k / 2)
		d[v].ft.ft++;
	if (deep == k / 2 + 1)
		d[v].ft.sc++;
	if (deep > k / 2 + 1)
		d[v].sc++;
		
	forn (i, sz(g[v]))
	{
		int to = g[v][i];
		
		if (to == pr)
			continue;
			
		dfs(to, v, deep + 1);
		
		d[v].ft.ft += d[to].ft.ft;
		d[v].ft.sc += d[to].ft.sc;		
		d[v].sc += d[to].sc;
	}
}

inline int calc (int v)
{
	dfs(v, -1, 0);
	
	if (k & 1)
	{
		int ans = INF;
		
		int sum1 = 0, sum2 = 0, sum3 = 0;

		forn (i, sz(g[v]))
		{
			int to = g[v][i];
			
			sum1 += d[to].ft.ft, sum2 += d[to].ft.sc, sum3 += d[to].sc;
		}
		
		forn (i, sz(g[v]))
		{
			int to = g[v][i];
			
			int cur = sum3 + sum2 - d[to].ft.sc;
			ans = min(ans, cur);
		}
		
		return ans;
	}
	else
		return d[v].ft.sc + d[v].sc;
}

inline void solve()
{
	int ans = INF;
	forn (i, n)
		ans = min(ans, calc(i));
		
	cout << ans << endl;
}

int main()
{
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;

	srand(int(time(NULL)));

	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif

	return 0;
}


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

int main() {
	int a[3];
    for (int i = 0; i < 3; i++) cin >> a[i];
    sort(a, a + 3);
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
}



Measured memory_bytes: 3152
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
int dp[100010][13];
int MOD=1000000007;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin>>s;
	dp[0][0]=1;
	rep(i,s.size())rep(j,13)rep(x,10)if(s[i]=='?'||s[i]-'0'==x){
		(dp[i+1][(j*10+x)%13]+=dp[i][j])%=MOD;
	}
	cout<<dp[s.size()][5]<<endl;
}












Measured memory_bytes: 10704
// HEADERS //
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <stack>
#include <unordered_map>
#include <bitset>
 
// MISCELLANEOUS //
#define fast_IO() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define gcd __gcd
#define cnt_1 __buitlin_popcount
#define ll long long
#define endl "\n"
#define scn_I(x) scanf("%d",&x)
#define scn_L(x) scanf("%lld",&x) 
#define test(t) cin>>t; while(t--)
#define mem(v,x) memset(v,x,sizeof(v))
 
// LOOPS //
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define irep(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define srep(i,v) for(decltype(v.begin())i=v.begin();i!=v.end();i++)
 
// CONTAINERS //
// #define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define msi map<string,int>
#define mll map<ll,ll>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(v) (v).begin(),(v).end()
#define present(v,x) (v).find(x)!=(v).end()
 
// DEBUGGING //
#define dbg() printf("\n**DEBUG**\n") 
#define chk(a) cerr<<endl<<#a<<":"<<a<<endl
#define chk2(a,b) cerr<<endl<<#a<<":"<<a<<"\t"<<#b<<":"<<b<<endl
 
// CONSTANTS //
#define PI acos(-1)
#define M 1000000007
#define N 100005
 
// MAIN //
// using namespace __gnu_pbds; 
using namespace std;
int main()
{
  fast_IO();
  int n; cin>>n; vi v(n);
  rep(i,0,n) cin>>v[i];
  ll dp[n]={0}; dp[1]=abs(v[1]-v[0]);
  rep(i,2,n) dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  cout<<dp[n-1];
}

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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string s;
    cin >> s;
    cout << s.at(0) << s.at(1) << s.at(2) << endl;
}

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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;

int ar[N];



integer main() {
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    set<int> ac;
    int p = 0;
    int a[m];
    string s[m];
    set<int> t;
    for (int i = 0; i < m; i++){
        cin >>a[i] >> s[i];
        if (s[i] == "AC") {
            t.insert(a[i]);
        }
    }
    for (int i = 0; i < m; i++){
        if (s[i] == "AC"){
            ac.insert(a[i]);
        } else {
            if (!ac.count(a[i]) && t.count(a[i])) {
                p++;
            }
        }
    }
    cout << (int) ac.size() << ' ' << p << endl;
}



Measured memory_bytes: 15872
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        int N = sc.nextInt();
        long sum = 0;
        for (int i=1; i<N; i++) {
            sum += i;
        }
        out.println(sum);
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    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 static 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());}
}


Measured memory_bytes: 22740
#include <iostream>

using namespace std;

int solve(int D, int N)
{
	int t = 1;
	for (int i = 0; i < D; ++i) {
		t *= 100;
	}

	if (N == 100) {
		return 101 * t;
	}
	else {
		return N * t;
	}
}

int main()
{
	int D, N;
	cin >> D >> N;
	cout << solve(D, N) << endl;
}


Measured memory_bytes: 256
def main():
    from builtins import int,map,list,print
    import sys

    input = sys.stdin.readline
    input_number = (lambda: int(input()))
    
    D = input_number()
    ans = 'Christmas'
    r = 25 - D
    for i in range(r):
        ans+=' Eve'
    print(ans)

def resolve():
    main()

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,M; cin >> N >> M;
	priority_queue<int> q;
	rep(i,N){
		int x; cin >> x;
		q.push(x);
	}
	while(M--){
		int x = q.top(); q.pop();
		q.push(x/2);
	}
	ll ans = 0;
	while(!q.empty()){
		int x = q.top(); q.pop();
		ans += x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 892
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,k,d,ans,dp[4005][4005];
void add(int &x,int y){
    x+=y;
    if(x>=orz)x-=orz;
}
int main(){
    scanf("%d%d%d",&n,&m,&k);
    d=(n+m-1)/(k-1);
    dp[0][1]=1;
    for(int i=1;i<=d;++i){
        for(int j=0;j<=n;++j){
            for(int _=0;_<k;++_)add(dp[i][j+_],dp[i-1][j]);
        }
        add(ans,dp[i][n]);
    }
    if(n>1&&(n-1)%(k-1)==0)add(ans,orz-1);
    printf("%d\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 62080
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod

main = do
 [n] <- readLnInt
 print $ solve n

solve n
 | n<10 = n
 | n<1000 = 9+f[n,100]
 | n<100000 = 909+f[n,10000]
 | otherwise = 90909
 
f :: [Int] -> Int
f[n,p]= (n<p)?(0,n-p+1)


Measured memory_bytes: 380
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    p2 = [0]*(n+1)
    for i in range(n,0,-1):
        sm = 0
        for j in range(i,n+1,i):
            sm += p2[j]
        p2[i] = (a[i-1]-sm)%2

    sm = sum(p2)
    print(sm)
    ans = []
    for i,pi in enumerate(p2):
        if pi:
            ans.append(str(i))

    print(" ".join(ans))
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 23216