akhauriyash/Code-Regression huggingface dataset:
#C
N = int(input())
S = [list(str(input())) for i in range(N)]

char = []
for i in range(N):
    if i == 0:
        Si = S[i]
        Si.sort()
        char = Si
    else:
        new = []
        Si = S[i]
        Si.sort()
        
        for c in char:
            if c in Si:
                new.append(c)
                Si.remove(c)
        char = new
    #print(char)
        
ans = ""
for c in char:
    ans+=c
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#define MIN(a,b) a>=b?b:a
int a[101][101];
int main()
{
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    int k=h*w-n;
    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++)
            if(i*j<=k)
                a[h-i][w-j]=1;
    int min=202;
    for(int i=0; i<=h; i++)
        for(int j=0; j<=w; j++)
            if((a[i][j])&&(min>=i+j))
                min=i+j;
                int min2=202;
                if(k<=MIN(h,w))
                    min2=MIN(w,h);
    printf("%d\n",MIN(min2,min));
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N+1];
		int[] gcd_order = new int[N+2];
		int[] gcd_reverse = new int[N+2];

		// 1~N
		gcd_order[0] = 0;
		int max_gcd = 0;
		for(int i=1;i<N+1;i++) {
			a[i] = sc.nextInt();
			gcd_order[i] = gcd(a[i],gcd_order[i-1]);
		}

		gcd_reverse[N+1] = 0;
		gcd_reverse[N] = gcd(a[N],0);
		max_gcd = gcd_order[N];

		for(int i=N-1;i>=0;i--) {
			gcd_reverse[i] = gcd(a[i],gcd_reverse[i+1]);
			int gcd = gcd(gcd_order[i], gcd_reverse[i+2]);
			max_gcd = Math.max(max_gcd, gcd);
		}

		System.out.println((int)max_gcd);
	}

	//整数a,bの最大公約数
	public static int gcd(int a,int b) {
		if(b == 0) return a;
		else return gcd(b,a%b);
	}

}


Measured memory_bytes: 60068
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = LLONG_MAX;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;


int main() {

	Int N, W; cin >> N >> W;
	Container w(N), v(N);
	rep(i, N)cin >> w[i] >> v[i];
	Grid<Int> dp(N + 1, vector<Int>(W + 1, -INF));
	rep(j, W + 1)dp[0][j] = 0;

	rep(i, N) {
		rep(j, W + 1) {
			if (j - w[i] >= 0)dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}

	cout << dp[N][W] << endl;

}

Measured memory_bytes: 80256
package main

import (
	"fmt"
)

func main() {
	var W, H, x, y float64
	fmt.Scan(&W, &H, &x, &y)
	fmt.Println(W * H / 2)
	if W/2 == x && H/2 == y {
		fmt.Println("1")
		return
	}
	fmt.Println("0")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int a[1001];
int main(){
	int n, k;
	cin >> n >> k;	
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + 1 + n);
	int ans = 0;
	for (int i = 1; i <= k; i++)
		ans += a[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}

int t,tot,a[505],b[505],s[505];
int la=201,ra=200,lb=201,rb=200;

void solve(ll n){
	if(n==1){
		++tot;
		a[--la]=tot;b[--lb]=tot;
		return;
	}
	if(n&1){
		solve(n/2);
		++tot;
		a[--la]=tot;b[--lb]=tot;
	}
	else{
		solve(n-1);
		++tot;
		a[--la]=tot;b[++rb]=tot;
	}
}

int main(){
	ll n;cin>>n;
	solve(n);
	printf("%d\n",ra-la+rb-lb+2);
	for(int i=la;i<=ra;i++)
		printf("%d ",a[i]);
	for(int i=lb;i<=rb;i++)
		printf("%d ",b[i]);
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input().rstrip())
    ans = [0 for _ in range(n)]
    for x in range(1, 101):
        for y in range(x, 101):
            for z in range(y, 101):
                tmp = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x
                if tmp > n:
                    break
                if x == y == z:
                    ans[tmp - 1] += 1
                elif x == y or y == z or z == x:
                    ans[tmp - 1] += 3
                else:
                    ans[tmp - 1] += 6
    for v in ans:
        print(v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int cnt = 1;
	rep(i, 0, s.size()-1) {
		if (s[i] != s[i + 1]) cnt++;
	}
	cout << cnt - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    requests = list(map(lambda x: string_to_int(x), inputs))
    requests = sorted(requests, key=lambda x: x[1])

    deleted = []
    last = 0

    for request in requests:
        if request[0] > last:
            deleted.append(request[1] - 1)
            last = deleted[-1]

    return len(deleted)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(M))
    print(ret)


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

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define endl '\n'
#define sorted(s)  sort(s.begin(),s.end())
#define reversed(s) reverse(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
#define ison(n,j) (n&(1LL<<j))
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
bool check[1000007]={false};
ll fact[109];
vector<ll>prime;
void sieve(ll n)
{
    ll i,j;
    check[0]=true,check[1]=true,check[2]=false;
    for(i=4;i<=n;i+=2)
        check[i]=true;
    for(i=3;i*i<=n;i+=2)
    {
        if(!check[i])
        for(j=i*i;j<=n;j+=2*i)
        {
            check[j]=true;
        }
    }
   prime.pb(2);
   for(i=3;i<=n;i+=2)
   {
       if(!check[i])
        prime.pb(i);
   }
}

int main()
{
    sieve(1000001);
    ll x;
    cin>>x;
    cout<<*lower_bound(prime.begin(),prime.end(),x)<<endl;

    return 0;
}






Measured memory_bytes: 2424
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String s1 = sc.next(); //元の文字列
    int n = s1.length();
    
    //sが回文であるかをチェック
    StringBuffer sb = new StringBuffer(s1);
    String s2 = sb.reverse().toString(); //反転した文字列
    
    
    //前半が回文かを確かめる
    String str2 = s1.substring(0,(n-1)/2);
    
    StringBuffer sb1 = new StringBuffer(str2);
    String s3 = sb1.reverse().toString();
    
    
    //後半が回文かを確かめる
    String str3 = s1.substring((n+3)/2-1,n);
    
    StringBuffer sb2 = new StringBuffer(str3);
    String s4 = sb2.reverse().toString();
    
    if((s1.equals(s2))&&(str2.equals(s3))&&(str3.equals(s4))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int ax[4]={1,0,-1,0},ay[4]={0,1,0,-1};
char ch[1000];
int i,j,n,m,f[1000][1000],x,y,ans;
bool b[1000][1000];
void search(int x,int y,int z){
	b[x][y]=true;
	int i,j,p,q;
	for(i=0;i<4;i++){
		p=x+ax[i];q=y+ay[i];
		if((p>0)&&(p<=n)&&(q>0)&&(q<=m)&&(!b[p][q])&&(f[p][q]==z)){
			search(p,q,z);
	    }
	}
}
int main(){
	scanf("%d %d",&n,&m);
	getchar();
	    while((m!=0)&&(n!=0)){
	    ans=0;
	    memset(b,0,sizeof(b));
	 	memset(f,0,sizeof(f));
	 	ans=0;
	 	for(i=1;i<=n;i++){
	 		gets(ch);
	 		for(j=0;j<m;j++)
	 		 if(ch[j]=='*') f[i][j+1]=1;
	 		  else if(ch[j]=='#') {
	 		  	   f[i][j+1]=2;
			   } else f[i][j+1]=3;
		}
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++){
	 	if(!b[i][j]){
	 		search(i,j,f[i][j]);
	 		ans++;
		 }
	 }
	 printf("%d\n",ans);
	 scanf("%d %d",&n,&m);
	 getchar();
    }
}

Measured memory_bytes: 6552
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<int,int>
#define S set<int>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n,x);VC1(n,a);
  vector<vector<V>> dp(n+1,vector<V>(n+1,V(n*50+1,0)));//dp[i][j][k]:i番目までからj枚取ってkになる
  dp[0][0][0]=1;
  REP(i,n)
    REP(j,n)
      REP(k,n*50+1){
        dp[i+1][j][k]+=dp[i][j][k];
        dp[i+1][j+1][k+a[i]]+=dp[i][j][k];
      }
  
  ll ans = 0;

  FOR(j,1,n+1)
    FOR(k,1,n*50+1)
      if(k/j==x&&k%j==0)
        ans+=dp[n][j][k];

  COUT(ans);

  return 0;
}


Measured memory_bytes: 52224
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
   ll res = 1;
   x = x % mod;
   while (y > 0)
   {
       if (y & 1)
            res = (res*x) %mod;
       y = y>>1;
       x = (x*x) %mod;
   }
   return res;
}
void solve()
{
    int n,k;
    cin>>n>>k;
    n++;
    int an=0;
    vector<int>v;
    rep0(i,n) v.pb(i);
    int mi=0;
    int mx=0;
    rep0(i,k) mi+=v[i];
    int ii=n-1;
    int k1=k;
    while(k1--){
        mx+=v[ii];
        ii--;
    }
    int cu=0;
    if(ii>=0) cu=v[ii];
    repp(i,k,n+1){
        //deb(mi,mx);
        an+=(mx-mi+1);
        an%=mod;
        mi+=v[i];
        mx+=cu;
        cu--;
    }
    pr(an);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //srand(time(0));
    //cin>>t;
    for(int _i=1;_i<=t;_i++){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 5300
N=int(input())
a=list(input().split())
for i in range(N):
    a[i]=int(a[i])
ans=0
for i in range(1,N-1):
    if (a[i-1]<a[i] and a[i]<a[i+1]) or  (a[i+1]<a[i] and a[i]<a[i-1]):
        ans+=1
print(ans)


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

int main(){
  int x;
  int a,b;
  cin >> x >> a >> b;
  
  if(b<=a)
    cout<<"delicious"<<endl;
  else if(b<=a+x)
    cout<<"safe"<<endl;
  else
    cout<<"dangerous"<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    long long A, B, K, i;

    cin >> A >> B >> K;

    if(K < A){
        A -= K;
    }

    else{
        if(B-(K-A) >= 0){
            B -= K-A;
        }
        else{
            B = 0;
        }

        A = 0;
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
string = ""
while True:
  try:
    string += input().lower()
  except EOFError:
    break
print("a : {}".format(string.count("a")))
print("b : {}".format(string.count("b")))
print("c : {}".format(string.count("c")))
print("d : {}".format(string.count("d")))
print("e : {}".format(string.count("e")))
print("f : {}".format(string.count("f")))
print("g : {}".format(string.count("g")))
print("h : {}".format(string.count("h")))
print("i : {}".format(string.count("i")))
print("j : {}".format(string.count("j")))
print("k : {}".format(string.count("k")))
print("l : {}".format(string.count("l")))
print("m : {}".format(string.count("m")))
print("n : {}".format(string.count("n")))
print("o : {}".format(string.count("o")))
print("p : {}".format(string.count("p")))
print("q : {}".format(string.count("q")))
print("r : {}".format(string.count("r")))
print("s : {}".format(string.count("s")))
print("t : {}".format(string.count("t")))
print("u : {}".format(string.count("u")))
print("v : {}".format(string.count("v")))
print("w : {}".format(string.count("w")))
print("x : {}".format(string.count("x")))
print("y : {}".format(string.count("y")))
print("z : {}".format(string.count("z")))


Measured memory_bytes: 5568
#include <iostream>

using namespace std;

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;

    if(u==s){
        a-=1;
        
    }
    if(u==t){
        b-=1;
        
    }
    
    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC") << endl;
  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;

string k;
int n;
int d;
ll dp[10004][101][2];

ll solve(int i,int r, int flag){
	if(i==n){
		if(r)
			return 0;
		return 1;	
	}
	if(dp[i][r][flag]!=-1)
		return dp[i][r][flag];
		
	int digit = k[i]-'0';
	ll ans = 0;
	if(flag){
		for(int j=0;j<digit;j++){
			ans = (ans + solve(i + 1,(r  + j) % d,0)) % mod;
		}	
		ans = (ans + solve(i + 1,(r + digit) % d,1)) % mod;
	}
	else{
		for(int j=0;j<10;j++){
			ans = (ans + solve(i + 1,(r + j) % d,0))%mod;
		}
	}
	return dp[i][r][flag] = ans;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>k;
	cin>>d;
	n = k.length();
	memset(dp,-1,sizeof(dp));
	cout<<(solve(0,0,1)-1+mod)%mod;
	return 0;
}









Measured memory_bytes: 16896
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<long long>v;
	long long a; cin >> a;
	for (int i = 1; i < n; i++) {
		long long b; cin >> b;
		v.push_back(b - a - 1);
		a = b;
	}
	sort(v.begin(), v.end());
	int ans = n;
	for (int i = 0; i < n - k; i++)ans += v[i];
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n,m,l; cin>>n>>m>>l;
  if (n+m+l>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
 
struct Node {
  int key;
  Node *parent, *left, *right;
};
 
Node *root, *NIL;
 
void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
 
  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
 
  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}
 
void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
 
void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}
 
int main() {
  int n;
  int key;
  string com;
 
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &key);
      insert(key);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 26680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long INF=1e18,MOD=1e9+7;
int main(){
    int n;
    cin>>n;
    vector<int>w(n);
    for(int i=0;i<n;i++)cin>>w[i];
    ll ans=INF;
    for(int i=0;i<n-1;i++){
        ll a=0,b=0;
        for(int j=0;j<=i;j++)a+=w[j];
        for(int k=i+1;k<n;k++)b+=w[k];
        ans=min(ans,abs(a-b));
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
const main = () => {
  const as = getParams();
  console.log(solve(as));
};

const getParams = () =>
  getStdin().split(/\s/).slice(1).map(Number);

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = as =>
  Math.min(...as.map(numTwos));

const numTwos = n => {
  if (odd(n))
    return 0;
  return 1 + numTwos(n/2);
};

const odd = n =>
  n % 2 === 1;

main();


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

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

using namespace std;

int main() {

    int N, M;
    cin >> N >> M;

    cout << (N*(N-1))/2 + (M*(M-1))/2 << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

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

  int a, b;
  cin >> a >> b;

  int heihou = a * b;

  heihou = heihou - a - b + 1;

  cout << heihou << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

int k;
char s[30];

int main()
{
	scanf("%s", s);
	
	//xoxoxoxoxoxox
	k = strlen(s);
	int wins = 0;
	int losts = 0;
	int total;
	for (int i = 0 ; i < k ; i++)
	{
		if (s[i] == 'o')
			wins++;
		else
			losts++;
	}
	
	total = wins + losts;
	int left = 15 - total;
	
	if ((left + wins) >= 8)
		printf("YES\n");
	else
		printf("NO\n");
	
	return 0;
}


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int dp[n];
  dp[0] = 0;
  for(int i = 1; i < n; ++i) {
    dp[i] = INT_MAX;
    for(int j = 1; j <= k; ++j) {
      if(i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
      }
    }
  }
  cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<vector>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>, greater<double>> q;
  double v;
  rep(i,0,N-1) {
    cin >> v;
    q.push(v);
  };
  while (1 < q.size()) {
    double a = q.top(); q.pop();
    double b = q.top(); q.pop();
    q.push((a+b)/2);
  }
  cout << q.top() << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int a;
	cin >> a;
	cout << 3 * a * a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main(void) {

    int i;
    char s[500000];
    char *w[] = {"dream", "dreamer", "erase", "eraser"};
    char *p, *q;
    bool bMatch;

    scanf("%s", s);

    if ( strlen(s) < 5 ) {
        printf("NO\n");
        return 0;
    }

    p = &s[strlen(s) - 1];

    while (p >= s) {
        bMatch = false;
        for (i = 0; i < 4; i++ ) {
            q = p - strlen(w[i]) + 1;
            if ( q < s ) {
                continue;
            } else if ( !strncmp(w[i], q, strlen(w[i])) ) {
                p -= strlen(w[i]);
                bMatch = true;
                break;
            }

        }
        if ( bMatch == false ) {
            printf("NO\n");
            return 0;
        }
    }

    printf("YES\n");

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int a,b;
    cin >> a >> b;
    int ans;
    ans = max(a + b, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
ll prime[1000005];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);
vector<ll>ft;

ll mul(ll a, ll b){
    ll ans= ((a%mod)*(b%mod))%mod;
    return ans%mod;
}
ll sub(ll a, ll b){
    ll ans = (a-b+mod)%mod;
    return ans;
}
ll add(ll a,ll b){
    ll ans = (a+b)%mod;
    return ans;
}


void solve() {
    ll n;
    cin >> n;
    ll c=0, ans = 0;
    rep(i,1,n){
        ll b=n/i;
        if(n%i==0)ans+=(b-1);
        else ans+=b;
    }
    cout<<ans<<endl;
}
int main()
{
    flash;
    ll t=1;
   // sieve(1000001);
    //ft.pb(1);
    //fact(10000001);
   // cin >> t;
    while(t--) { 
        solve();
    }
}

//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res%mod;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n)
{
    return floor(log10(n) + 1);
}

Measured memory_bytes: 3680
#include <cstdio>

int m[10][10] = { 0 };

bool inRange(int va) {
    return (0 <= va) && (va < 10);
}

void put(int x, int y, int s) {
    switch (s) {
    case 1:
        m[x][y]++;
        if (inRange(x - 1)) {
            m[x - 1][y]++;
        }
        if (inRange(x + 1)) {
            m[x + 1][y]++;
        }
        if (inRange(y - 1)) {
            m[x][y - 1]++;
        }
        if (inRange(y + 1)) {
            m[x][y + 1]++;
        }
        break;
    case 2:
        for (int i = x - 1; i <= x + 1; ++i) {
            for (int j = y - 1; j <= y + 1; ++j) {
                if (inRange(i) && inRange(j)) {
                    m[i][j]++;
                }
            }
        }
        break;
    case 3:
        put(x, y, 2);
        if (inRange(x - 2)) {
            m[x - 2][y]++;
        }
        if (inRange(x + 2)) {
            m[x + 2][y]++;
        }
        if (inRange(y - 2)) {
            m[x][y - 2]++;
        }
        if (inRange(y + 2)) {
            m[x][y + 2]++;
        }
        break;
    }
}

int main() {
    int inx[100] = { 0 };
    int iny[100] = { 0 };
    int ins[100] = { 0 };
    int c;

    for (c = 0; scanf("%d,%d,%d", &inx[c], &iny[c], &ins[c]) != EOF; ++c) {}

    for (int i = 0; i < c; ++i) {
        put(inx[i], iny[i], ins[i]);
    }

    int mx = 0;
    int counts = 0;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            int p = m[i][j];
            if (mx < p) {
                mx = p;
            }

            if (p == 0) {
                counts++;
            }
        }
    }

    printf("%d\n%d\n", counts, mx);

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string w[n];
    unordered_map<string,int> count;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        if(count.find(w[i]) != count.end()){
            ans = 1;
        }else{
            count[w[i]] = 1;
        }
        if(i != 0){
            if(w[i-1].back() != w[i].front()){
                ans = 1;
            }
        }
    }
    if(ans == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        int count=0;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String x=br.readLine();
        int sum=x.length();
        for(char c:x.toCharArray()){
            if(c=='S'){
                count++;
            }else if(c=='T'){
                if(count!=0){
                    count--;
                    sum-=2;
                }
            }
        }System.out.println(sum);
    }
}

Measured memory_bytes: 11988
# -*- coding: utf-8 -*-
n = int(input())
s = input()

def check(l):
    if s[0]=="o":
        if l[0]=="S":
            if l[-1]!=l[1]:
                return False
        else:
            if l[-1]==l[1]:
                return False
    else:
        if l[0]=="S":
            if l[-1]==l[1]:
                return False
        else:
            if l[-1]!=l[1]:
                return False
    for i in range(1,n-1):
        if s[i]=="o":
            if l[i]=="S":
                if l[i-1]!=l[i+1]:
                    return False
            else:
                if l[i-1]==l[i+1]:
                    return False
        else:
            if l[i]=="S":
                if l[i-1]==l[i+1]:
                    return False
            else:
                if l[i-1]!=l[i+1]:
                    return False
    if s[n-1]=="o":
        if l[n-1]=="S":
            if l[n-2]!=l[0]:
                return False
        else:
            if l[n-2]==l[0]:
                return False
    else:
        if l[n-1]=="S":
            if l[n-2]==l[0]:
                return False
        else:
            if l[n-2]!=l[0]:
                return False
    return True

def flip(x):
    if x=="S":
        return "W"
    else:
        return "S"

def fill(s0,s1):
    ret = [None for _ in range(n)]
    ret[0] = s0
    ret[1] = s1
    for i in range(1,n-1):
        if ret[i]=="S" and s[i]=="o":
            ret[i+1] = ret[i-1]
        elif ret[i]=="S" and s[i]=="x":
            ret[i+1] = flip(ret[i-1])
        elif ret[i]=="W" and s[i]=="o":
            ret[i+1] = flip(ret[i-1])
        elif ret[i]=="W" and s[i]=="x":
            ret[i+1] = ret[i-1]
    # print(ret)
    if check(ret):
        return ret
    else:
        return None

ret = fill("S","S")
if ret is not None:
    print("".join(ret))
    exit()

ret = fill("S","W")
if ret is not None:
    print("".join(ret))
    exit()

ret = fill("W","S")
if ret is not None:
    print("".join(ret))
    exit()

ret = fill("W","W")
if ret is not None:
    print("".join(ret))
    exit()
print(-1)


Measured memory_bytes: 4324
r,c = map(int, input().split())
I = []
for i in range(r):
    row = list(map(int, input().split()))
    I.append(row)

for i in range(r):
    s = sum(I[i])
    I[i].append(s)

new_i=[]
for j in range(c+1):
    s=0
    for i in range(r):
        s += I[i][j]
    new_i.append(s)
I.append(new_i)

for i in I:
    i = map(str, i)
    print(" ".join(i))

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int pre,X,Y,n;
int main(){
	cin>>n;
	rep(i,n){
		int t,x,y;
		cin>>t>>x>>y;
		int d = abs(x-X)+abs(y-Y);
		if(d > t-pre){
			puts("No"); return 0;
		}
		else if((t-pre)%2 != d%2){
			puts("No"); return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 384
n=int(input())
open=[]
for i in range(n):
    a=list(map(int,input().split()))
    open.append(a)
point=[]
for i in range(n):
    p=list(map(int,input().split()))
    point.append(p)

ans=-float("inf")
for i in range(1,2**10):
    tmp=0
    joi_open=[0]*10
    for j in range(10):
        if (i>>j)&1:
            joi_open[j]=1
    for j in range(n):
        cnt=0
        for k in range(10):
            if open[j][k]==joi_open[k]==1:
                cnt+=1
        tmp+=point[j][cnt]
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 74052
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
 
using namespace std;

bool to(int &x, int y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}

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

  deque<int> q;
  q.push_back(1);

  vector<int> dp(K, 1e9);
  dp[1] = 1;

  while (!q.empty()) {
    int u = q.front(); q.pop_front();
    int d = dp[u];
    if (to(dp[u * 10 % K], dp[u])) {
      q.push_front(u * 10 % K);
    }
    if (to(dp[(u + 1) % K], dp[u] + 1)) {
      q.push_back((u + 1) % K);
    }
  }

  cout << dp[0] << endl;
}


Measured memory_bytes: 896
//'z'+1 -> '}'
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX_N 105
using namespace std;

int is_good(int x){
    int i,y, t=1;

    y=x%10;
    x /=10;

    for(i=0;i<3;i++){
        if(x%10==y) t++;
        else t=1;
        y=x%10;
        x /=10;
        if(t>=3) return 1;
    }
    if(t>=3) return 1;
    return 0;


}
int main(){

    int n;

    scanf("%d",&n);
    if(is_good(n)==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double n;
	int count = 0;
	double prob;
	
	cin >> n;
	
	for(int i=1; i<=n; i++)
	{
		int temp = i;
		if(temp%2!=0)
		{
			count++;
		}
	}
	
	prob = count/n;
	
	cout << fixed << showpoint;
	cout << setprecision(10) << prob << endl;
	
return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int X[N], Y[N], H[N];
  
  for(int i=0; i<N; i++) {
    cin >> X[i] >> Y[i] >> H[i];
  }
  
  int t = 0;
  for(int i=0; i<N; i++) {
    if(H[i]!=0) {
      t = i;
    }
  }
  
  bool flag = false;
  for(int x=0; x<=100; x++) {
    for(int y=0; y<=100; y++) {
      int tmp = abs(X[t]-x) + abs(Y[t] - y) + H[t];
      for(int i=0; i<N; i++) {
        int h = abs(X[i]-x) + abs(Y[i] - y) + H[i];
        if(H[i] != 0) {
          if(tmp==h) {
            flag = true;
          } else {
            flag = false;
            break;
          }
        } else {
          if(tmp<=h) {
            flag = true;
          } else {
            flag = false;
            break;
          }
        }
      }
      if(flag==true) {
        cout << x << " " << y << " " << tmp << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  repp(i, 1, n){
    if((x[i]-x[i-1])*a <= b) ans += (x[i]-x[i-1])*a;
    else ans += b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c<<endl;
    
    return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long 
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length())cout<<"GREATER";
	else if(b.length()>a.length())cout<<"LESS";
	else{
		if(a>b)cout<<"GREATER";
		else if(b>a)cout<<"LESS";
		else cout<<"EQUAL";
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i, 0, N) cin >> S[i];
    VL ans(4);
    rep(i, 0, N){
        string s = S[i];
        if(s == "AC") ans[0]++;
        if(s == "WA") ans[1]++;
        if(s == "TLE") ans[2]++;
        if(s == "RE") ans[3]++;
    }

    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;

    return 0;
}


Measured memory_bytes: 6420
s = input()
c1,c2 = 0, 0

for x in range(len(s)):
    c1 += 1 if s[x] != ('0' if x%2 else '1') else 0
    c2 += 1 if s[x] != ('1' if x%2 else '0') else 0

print(min(c1,c2))


Measured memory_bytes: 3188
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200050;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

int cnt[1000010];
void solve() {
	ll ans = 1;
	int N; cin >> N;
	int cnt0 = 0;
	REP(i, N) {
		int a; cin >> a;
		cnt[a]++;
		if (a == 0)cnt0++;
		if (a > 0) {
			ans *= cnt[a - 1];
			cnt[a - 1]--;
		}
		ans %= MOD;
	}
	if (cnt0 == 0||cnt0>3)ans = 0;
	if (cnt0 == 1)ans *= 3;
	if (cnt0 >= 2&&cnt0<=3)ans *= 6;
	print(ans%MOD);
}


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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> p(m);
  vector<vector<int>> graph(n);
  for(int i=0; i<m; i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    p[i]=make_pair(a,b);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int cnt=0;
  for(auto pp : p){
    int skip_a=pp.first,skip_b=pp.second;
    queue<P> q;
    vector<int> check(n);
    q.push(P(0,-1));
    check[0]++;
    while(!q.empty()){
      int now=q.front().first,before=q.front().second;
      q.pop();
      for(int i=0; i<graph[now].size(); i++){
        if(now==skip_a&&graph[now][i]==skip_b) continue;
        if(now==skip_b&&graph[now][i]==skip_a) continue;
        if(check[graph[now][i]]!=0) continue;
        q.push(P(graph[now][i],now));
        check[graph[now][i]]++;
      }
    }
    //cout << "skip_aは" << skip_a << " " << "skip_bは" << skip_b << endl;
    for(int i=0; i<n; i++){
      if(check[i]==0){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
  ll n,t=0,flag=0;
  cin>>n;
  ll a[n],b[n];
  vector<pair<ll,ll> >v;
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i];
    v.pb(mp(b[i],a[i]));
  }
  sort(v.begin(),v.end());
  /*for(auto tt:v)
    {
      cerr<<tt.se<<" "<<tt.fi<<endl;
    }*/
  for(auto tt:v)
    {
      //cerr<<tt.fi<<" "<<tt.se<<endl;
      if(t+tt.se<=tt.fi)
      {
        t+=tt.se;
      }
      else
    {//cout<<"I = "<<i<<endl;
      flag=1;
      break;
    }
    }

  /*for(int i=0;i<n;i++)
  {
    if(t+a[i]<=b[i])
    {
      t+=a[i];
      cerr<<t<<" ";
    }
    else
    {cout<<"I = "<<i<<endl;
      flag=1;
      break;
    }
  }
  cerr<<endl;*/
  if(flag)
    No
  else
    Yes

    
}
return 0;
}

Measured memory_bytes: 8944
import math
N, M= list(map(int, input().split()))
'''
# 組み合わせ計算
print(math.factorial(N)//math.factorial(N-2)//2)
print(math.factorial(M)//math.factorial(max(M-2, 1))//2)
'''
num = math.factorial(N)//math.factorial(max(N-2, 1))//2 + math.factorial(M)//math.factorial(max(M-2, 1))//2
print(num)

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n,h;
	cin>>n>>h;
	vector<int> a(n);
	vector<int> b(n);
	REP(i,n)cin>>a[i]>>b[i];
	int maxa=a[0];
	int idx=0;
	REP(i,n){
		if(maxa<a[i]){
			maxa=a[i];
			idx=i;
		}
	}
	vector<int> select;
	REP(i,n){
		if(i!=idx && b[i]>=a[idx]){
			select.push_back(b[i]);
		}
	}
	sort(select.begin(),select.end(),greater<int>());
	int ans=0;
	REP(i,select.size()){
		if(h<=0){
			cout<<ans<<endl;
			return 0;
		}else if(h<=b[idx]){
			ans++;
			cout<<ans<<endl;
			return 0;
		}else{
			h-=select[i];
			ans++;
		}
	}

	if(h>b[idx]){
		ans+=ceil((double)(h-b[idx])/a[idx]);
	}
	ans+=1;

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


Measured memory_bytes: 1660
#include<bits/stdc++.h>  
using namespace std;
 int main(){
    int n;
    cin>>n;
    vector<int>k;
    vector<int>l;
    vector<int>m;
    int sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        k.push_back(x);
    }
    for(int j=0;j<n;j++){
        int y;
        cin>>y;
        
        l.push_back(y);
    }
    for(int j=0;j<n;j++){
        sum=sum+l[j];
    }
    for(int p=0;p<n-1;p++){
        int z;
        cin>>z;
        m.push_back(z);
    }
    for(int i=0;i<n-1;i++){
     if(k[i+1]==(k[i]+1)){
         sum=sum+m[k[i]-1];
     }
    }

    cout<<sum;
  }

Measured memory_bytes: 256
X, Y = map(int, input().split())

if Y > X:
    X, Y = Y, X

if (X + Y) % 3 != 0 or X > 2 * Y:
    print(0)
    exit()

n = 0
m = 0

for n in range(X + 1):
    if (X - n) % 2 != 0:
        continue
    else:
        m = (X - n) // 2
        if 2 * n + m == Y:
            break

if m > n:
    n, m = m, n

# print(n, m)

p = 1
q = 1
mod = 10 ** 9 + 7

for i in range(m):
    p *= (n + m - i)
    p %= mod
    q *= (m - i)
    q %= mod

ans = p * pow(q, mod - 2, mod)

print(ans % mod)


Measured memory_bytes: 3064