akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAXN 100100
#define MOD 998244353
using namespace std;
typedef long long lli;
map<string,lli> dp;

string chk(string str , lli fre , lli sze){
   string ret;ret.clear();
   for(lli i=0; i<sze; i++){
        char c = '1';
        for(lli j=0; j<fre; j++)
            if(str[(j*sze) + i] == '0') c = '0';

        ret += c;
   }

   return ret;
}

lli solve(string S){
    map<string,lli>::iterator it = dp.find(S);

    //cout << S << endl;

    if (it != dp.end()) return dp.find(S)->second;
    if(S.size() == 0) return 1;
    if(S.size() == 1) return (S[0] == '0') ? 1 : 2;

    lli ans = ((1 + (lli)(S[0]-'0')) * (solve(S.substr(1))%MOD))%MOD;
    for(lli sz=1; sz<=S.size(); sz++)
        for(lli j=2; j<=(lli)((S.size())/sz); j++)
            ans = (ans + ( (solve(chk(S , j , sz))%MOD) * (solve(S.substr(j*sz))%MOD) ) )%MOD;

    dp[S] = ans;
    return (dp[S])%MOD;
}


int main(){
    string S; cin >> S;
    int N = S.size();
    //cout << S.substr(3) << endl;
    cout << solve(S) << endl;

    return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>

#define N 2000001

int n;
int B[N];

void conting(int A[], int k){
  int C[k],i,j;
  for(i=0; i<k; i++) C[i] = 0;
  for(j=1; j<=n; j++) C[A[j]]++;
  for(i=1; i<k; i++) C[i] += C[i-1];
  for(j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int main(){
  int k=0,i;
  int A[N];
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
  }
  k=A[1];
  for(i=2; i<=n; i++){
      if(k < A[i]) k = A[i];
  }
  conting(A, k+1);
  for(i=1; i<n; i++) {
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);
  return 0;
}

Measured memory_bytes: 16260
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

void solve() {
    int n, k, q;
    cin >> n;
    cin >> k;
    cin >> q;
    vector<int> scores(n);
    for(int i = 0; i < n; i++) {
        scores[i] = k-q;
    }
    for(int i = 0; i < q; i++){
        int tmp;
        cin >> tmp;
        scores[tmp-1] += 1;
    }
    for(int i = 0; i < n; i++){
        string msg = scores[i] <= 0 ? "No" : "Yes";
        cout << msg << endl;
    }
}


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

Measured memory_bytes: 1024
const Main = input => {
  input = input.split("\n")[0].split(' ').map(v => parseInt(v, 10))
  console.log(Math.max.apply(Math, [input[0]-input[1], input[0]+input[1], input[0]*input[1]]))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 11468
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto K = RD!long;
	auto A = RDR.split.to!(long[]);

	auto cnt = new long[](N+1);
	fill(cnt, long.max);

	long type;
	foreach (i; 0..N)
	{
		if (cnt[A[i]] == long.max)
		{
			cnt[A[i]] = 1;
			++type;
		}
		else
			++cnt[A[i]];
	}
	cnt.sort();

	long ans;
	foreach (i; 0..type-K)
	{
		ans += cnt[i];
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 11440
#define _CRT_SECURE_NO_WARNINGS
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <functional>
    #include <queue>
    #include <deque>
    #include <string>
    #include <stack>
    #include <unordered_set>
    #include <cmath>
    #include <climits>
    #include <cstdlib>
    #include <cstring>
    #include <map>
    #include <ctime>
    #define endl '\n'
    #define ll long long
    #define mod 1000000007
    #define NCONS 100001
    #define MACRO(a) for(int a = 1; a < 1001; a++)
     
    using namespace std;
     
    vector<ll> B;
    ll N;
     
    int main(void)
    {
    	cin.tie(NULL); ios_base::sync_with_stdio(false);
    	ll A; cin >> N;
     
    	for (ll i = 1; i <= N; i++)
    	{
    		cin >> A; A -= i;
    		B.push_back(A);
    	}
    	sort(B.begin(), B.end());
    	auto mid = B[B.size() / 2];
     
    	ll ret = 0;
    	for (ll i = 0; i < N; i++)
    		ret += abs(B[i] - mid);
    	cout << ret;
    	return 0;
    }

Measured memory_bytes: 2420
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=1e5+10;
char s[N];
int a[N];
int main()
{
	scanf("%s",s+1); int n=strlen(s+1);
	if(s[n]=='1' || s[1]=='0'){puts("-1"); return 0;}
	for(int i=1;i<=n/2;i++)
	{
		if(s[i]!=s[n-i])
		{
			puts("-1");
			return 0;
		}
	}
	int tot=1;
	for(int i=n/2;i>=1;i--)
	{
		if(s[i]=='1')
		{
			a[i]=n-tot-i;//废点 
			tot+=a[i]+1;		
		}
	}
	if(tot!=n){puts("-1"); return 0;}
	int fa=1,x=1;
	for(int i=n/2;i>=1;i--)
	{
		if(s[i]=='1')
		{
			for(int j=1;j<=a[i];j++)
			{
				x++;
				printf("%d %d\n",fa,x);
			}
			x++; printf("%d %d\n",fa,x);
			fa=x;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		try (Scanner sc = new Scanner(System.in)) {
			int N, K;
			N = sc.nextInt();
			K = sc.nextInt();
			
			double sum = 0;
			
			for (int i = 1; i <= N; i++) {
				int score = i;
				double tmpSum = 1;
//				System.out.println("K = " + i + ";");
				while (score < K) {
					score *= 2;
					tmpSum *=  0.5;
//				System.out.println(score);
					
				}
				sum += tmpSum;
			}
			
			sum = (double)(sum / N);
			
			System.out.println(String.format("%.9f", sum));
			
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}


Measured memory_bytes: 21716
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();
    		int d = sc.nextInt();
    		if(a*b > c*d) {
    			System.out.println(a*b);
    			System.exit(0);
    		}
    		else {
    			System.out.println(c*d);
    			System.exit(0);
    		}
    	}
    }

Measured memory_bytes: 23764
from decimal import Decimal
from decimal import *
a, b, c = map(str, input().split())

#getcontext().prec = 1000

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)

if a**Decimal("0.5")  + b**Decimal("0.5") < c**Decimal("0.5"):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 60012
#include<stdio.h>
#define MAX 500000
#define INFTY 1000000000
int cou=0;

 void merge(int A[],int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  int i,j,L[MAX/2+2],R[MAX/2+2],k; 
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=INFTY;

  i=j=0;

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

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


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

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

  mergeSort(S,0,n);

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

Measured memory_bytes: 4508
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i < n; i += 2)count++;
    for (int i = 1; i < n; i += 3) {
        for (int j = i % 2 + 1; j < n; j += 2)count++;
    }
    if (n % 3 == 1)
        for (int j = (n - 1) % 2 + 1; j < n; j += 2)count++;

    cout << count << endl;
    for (int i = 1; i < n; i += 2)cout << 0 << " " << i << endl;
    for (int i = 1; i < n; i += 3) {
        for (int j = i % 2 + 1; j < n; j += 2)cout << j << " " << i << endl;
    }
    if (n % 3 == 1)
        for (int j = (n - 1) % 2 + 1; j < n; j += 2)cout << j << " " << n - 1 << endl;

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a;
	string s;
	cin >> a >> s;
	cout << (3200 <= a ? s : "red");
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

const int Maxn = 3000 + 100, Mod = 1e9 + 7;

int N, A[Maxn];
char S[Maxn];

inline void Add (int &a, int b) { a += b; if (a >= Mod) a -= Mod; }

/*
namespace BIT
{
	int sum[Maxn];
	inline void add (int x, int val) { for (; x <= N; x += lowbit(x)) Add (sum[x], val); }
	inline int query (int x) { int ans = 0; for (; x; x -= lowbit(x)) Add (ans, sum[x]); return ans; }
}
*/
int Sum[Maxn], Dp[Maxn];

inline void Solve ()
{
	Dp[1] = Sum[1] = 1;
	for (int i = 2; i <= N; ++i)
	{
		for (int j = 1; j <= i; ++j)
		{
			if (S[i] == '<') Dp[j] = Sum[j - 1];
			else Dp[j] = (Sum[i - 1] - Sum[j - 1] + Mod) % Mod;
		}
		for (int j = 1; j <= i; ++j) Sum[j] = (Sum[j - 1] + Dp[j]) % Mod;
	}

	int ans = 0;
	for (int i = 1; i <= N; ++i)
		Add (ans, Dp[i]);
	cout<<ans<<endl;
}

inline void Input ()
{
	N = read<int>();
	scanf("%s", S + 2);
}

int main()
{
#ifdef hk_cnyali
	freopen("T.in", "r", stdin);
	freopen("T.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


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

typedef long long      ll;
typedef vector<int>    vi;
typedef vector<string> vs;

#define MAX          200000
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n)    FOR(i, 0, n)
#define pb           push_back
#define all(a)       (a).begin(), (a).end()
#define UNIQUE(v)    v.erase(unique(all(v)), v.end());
#define fill(a, x)   memset(a, x, sizeof(a))
#define zero(a)      fill(a, 0)
#define minus(a)     fill(a, -1)
#define dbg(x)       cout << #x "=" << x << endl

struct Process {
  string name;
  int    ms;
};

struct Result {
  string name;
  int    ms;
};

int charToInt(char c) {
  string tmp;
  tmp += c;
  int b = atoi(tmp.c_str());
  return b;
}

int stringToInt(string s) {
  return atoi(s.c_str());
}

int main() {
  int            n;
  int            c = 0;
  Process        q[MAX];
  vector<Result> rq;
  cin >> n;

  int k;
  cin >> k;

  while (c < n) {
    Process p;
    string  name;
    cin >> name;
    int ms;
    cin >> ms;
    p.name = name;
    p.ms = ms;
    q[c] = p;
    c++;
  }

  int total = 0;
  int i = 0;  // i is head
  int tail = n;

  while (1) {
    if (i == tail) break;

    int m = q[i].ms - k;
    if (m > 0) {
      Process l = {q[i].name, m};
      q[tail] = l;
      total += k;
      tail++;
    } else {
      total += q[i].ms;
      Result r = {q[i].name, total};
      rq.pb(r);
    }
    i++;
  }

  rep(i, n) {
    cout << rq[i].name << " " << rq[i].ms << endl;
  }
  return 0;
}



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

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

    int H, W;
    cin >> H >> W;
    int c[10][10];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int a;
            cin >> a;
            if(a == -1) continue;
            ans += c[a][1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    System.out.println(solve(a, b, c));
  }

  private static int solve(int a, int b, int c) {
    if (a > b) return solve(b, a, c);
    if (b > c) return solve(a, c, b);
    if ((c * 3 - (a + b + c)) % 2 == 1) return solve(a, b + 1, c + 1) + 1;

    return ((c * 3) - (a + b + c)) / 2;
  }
}


Measured memory_bytes: 22868
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     int i, j;
     cin >> n >> m;
     a[n]++;
     a[m]++;

     for (i = 1; i <= 3; i++)
     {
          if (!a[i])
          {
               cout << i;
               return ;
          }
     }

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 256
import java.util.*;

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();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		boolean flag = true;
		if(b -a >k){
			flag = false;
		}else if(c - a>k){
			flag = false;
		}else if(d - a>k){
			flag = false;
		}else if(e - a>k){
			flag = false;
		}else if(c - b>k){
			flag = false;
		}else if(d - b>k){
			flag = false;
		}else if(e - b >k){
			flag = false;
		}else if(d - c> k){
			flag = false;
		}else if(d - e > k){
			flag = false;
		}
		System.out.print(flag?"Yay!":":(");
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
struct tree
{
    int a,b,c,d;
    tree(int a,int b,int c,int d)
        :a(a), b(b), c(c), d(d) {}
};
int mat[501][501];
int row[]= {-1,0,1,0,1,-1,1,-1};
int colm[]= {0,1,0,-1,1,-1,-1,1};
int r,c;
vector<tree>ans;
void c1()
{
    for(int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
        {
            if(mat[i][j]%2==0)
                continue;
             if(j+1<c){
                mat[i][j]--;
                mat[i][j+1]++;
                ans.push_back({i,j,i,j+1});
             }
        }
    }
}
void c2()
{
    for(int i=0; i<r; i++)
    {
        if(mat[i][c-1]%2 && i+1<r){
            mat[i][c-1]--;
            mat[i+1][c-1]++;
            ans.push_back({i,c-1,i+1,c-1});
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    cin>>r>>c;
    for(int i=0; i<r; i++)
        for(int j=0; j<c; j++)
            cin>>mat[i][j];
    c1();
    c2();

    cout<<ans.size()<<endl;
    for(int i=0; i<ans.size(); i++)
    {
        tree it=ans[i];
        cout<<it.a+1<<" "<<it.b+1<<" "<<it.c+1<<" "<<it.d+1<<endl;
    }

    return 0;
}


Measured memory_bytes: 6280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int A,B;
  int res=0;
  cin >> A>>B;

  res = max(0,A-2*B);

  cout << res << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

public class AtCoder20171111D
{
  static void Main(string[] args)
  {
    var line = Console.ReadLine();
    var ret = Math.Pow(int.Parse(line), 3);
    
    System.Console.WriteLine(ret.ToString());    
  }
}



Measured memory_bytes: 11092
A, B, C, D = map(int, input().split())

def gcd(a, b):
  if a == 0:
    return b
  return gcd(b%a, a)

g = gcd(C, D) if C < D else gcd(D, C)
ansB = B-B//C-B//D+B//(C*D//g)
ansA = A - 1 - (A-1)//C - (A-1)//D + (A-1)//(C*D//g)
print(ansB-ansA)

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

int main(void) {
  //input
  double a, b, x;
  cin >> a >> b >> x;
  //calc
  double V = a * a * b;
  double tanv = -1;
  if ( x <= V/2.0 ) {
    tanv = (a*b*b)/(2.0*x);
  }
  else {
    tanv = (2.0*b/a)*(1.0-x/V);
  }
//  cout << tanv << endl;
  double answer = atan(tanv) * 180.0 / pai;
  //output
  printf("%.16f\n", answer);
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long int ll;
 
int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    double S = W * H / 2.0;

    int tmp;
    if (x == W / 2.0 && y == H / 2.0) tmp = 1;
    else tmp = 0;

    printf("%.9f %d\n", S, tmp);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  int k;
  int i;
  int ans = 0;
  int sa = 0;
  vector<int> a;

  cin >> n;
  for (i = 0; i < n; i++){
    cin >> k;
    a.push_back(k);
  }

  sort(a.begin(), a.end());
  sa = a.front() - a.back();
  ans = abs(sa);

  cout << ans;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
fac = [1 for k in range(200010)]
inv = [1 for k in range(200010)]
finv = [1 for k in range(200010)]
for k in range(2,200010):
    fac[k] = (fac[k-1]*k)%MOD
    inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD
    finv[k] = (finv[k - 1] * inv[k]) % MOD;

def nCr(n,r):
    return (fac[n]*finv[r]*finv[n-r])%MOD

n, k = map(int,input().split())
ans = 0
for z in range(min(n,k+1)):
    ans += nCr(n,z)*nCr(n-1,n-z-1)
    ans %= MOD
print(ans%MOD)


Measured memory_bytes: 58188
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	int n;
	cin>>n;
	vector<ll> v(n), sol(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		v[i]*=2;
	}
	sol[n-1]=v[n-1];
	int sign=-1;
	for(int i=0;i<n-1;i++){
		sol[n-1]+=sign*v[i];
		sign*=-1;
	}
	sol[n-1]/=2;
	for(int i=n-2;i>=0;i--)
		sol[i]=v[i]-sol[i+1];
	for(int i=0;i<n;i++)
		cout<<sol[i]<<" ";
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

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

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int s;
vector<int> dat, lazy;

void init(int n_) {
	s = 1;
	while (s < n_)s *= 2;
	dat.resize(2 * s - 1);
	dat[s - 1] = 0;
	for (int i = s; i < 2 * s - 1; i++)dat[i] = INF;
	for (int i = s - 2; i >= 0; i--)dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
	lazy.resize(2 * s - 1, INF);
}

void eval(int k, int l, int r) {
	if (lazy[k] != INF) {
		dat[k] = min(dat[k], lazy[k]);
		if (r - l > 1) {
			lazy[2 * k + 1] = min(lazy[k], lazy[2 * k + 1]);
			lazy[2 * k + 2] = min(lazy[k], lazy[2 * k + 2]);
		}
		lazy[k] = INF;
	}
}

void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = s;
	if (r <= a || b <= l)return;
	eval(k, l, r);
	if (a <= l && r <= b) {
		lazy[k] = min(lazy[k], x);
		eval(k, l, r);
	}
	else {
		add(a, b, x, 2 * k + 1, l, (l + r) / 2);
		add(a, b, x, 2 * k + 2, (l + r) / 2, r);
		dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
	}
}

int query(int a, int b, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = s;
	if (r <= a || b <= l)return INF;
	eval(k, l, r);
	if (a <= l && b <= r)return dat[k];
	int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
	return min(vl, vr);
}

int n, m;
vector<P> vec[100010];

int solve() {
	init(n);
	for (int i = 1; i < n; i++) {
		int k = query(i - 1, i);
		for (int j = 0; j < (int)vec[i].size(); j++) {
			add(i, vec[i][j].first, k + vec[i][j].second);
		}
	}
	int res = query(n - 1, n);
	if (res == INF)return -1;
	else return res;
}

signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		vec[a].push_back({ b,c });
	}
	cout << solve() << endl;
}

Measured memory_bytes: 9728
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1e9
#define EPS 10e-8

int N,V=1,A,c=0;

void dfs(ll k,int a3,int a5,int a7,int sum){
  if(k<=V){
    if(sum<=N && a3>0 && a5>0 && a7>0){
      c++;
    }
    dfs(k*10,a3+1,a5,a7,sum+k*3);
    dfs(k*10,a3,a5+1,a7,sum+k*5);
    dfs(k*10,a3,a5,a7+1,sum+k*7);
  }
}

int main(){
  cin >> N;
  A=N;
  while(A>0){
    V*=10;
    A/=10;
  }
  dfs(1,0,0,0,0); 
  cout << c << endl;
}

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

using namespace std;

void hawawa(){
	int a, b;
	cin >> a >> b;
	if (a * b % 2) cout << "Yes\n";
	else cout << "No\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int p;
    int count=0;
    REP(i,N){
        cin>>p;
        if(p!=i+1)count++;
    }
    if(count<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int K=10001;
int A[2000001],C[2000001];
int buck[K]={0};
main(){
	int n;scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",&A[i]);
		buck[A[i]]++;
	}
	for (int i=1;i<=K;i++) buck[i]+=buck[i-1];
	for (int i=n-1;i>=0;i--){
		C[buck[A[i]]]=A[i];
		buck[A[i]]--;
	}	
	for (int i=1;i<=n;i++){
		printf("%d",C[i]);
		if (i!=n) printf(" ");
		else printf("\n");
	}
}



Measured memory_bytes: 18868
n , m , q = map(int, input().split())
table = [[0]*n for i in range(n)]

for i in range(m):
    l , r = map(int, input().split())
    l-=1
    r-=1
    table[l][r]+=1

table_sum = table.copy()

for i in range(n):
    for j in range(1,n):
        table_sum[i][j]=table_sum[i][j]+table_sum[i][j-1]

for i in range(q):
    l , r = map(int, input().split())
    l-=1
    r-=1
    ans=0
    for j in range(l,r+1):
        if l!=0:
            ans+=table_sum[j][r]-table_sum[j][l-1]
        else:
            ans+=table_sum[j][r]
    print(ans)


Measured memory_bytes: 78480
N,A,B=map(int, input().split())
S=input()
ab,b=0,0
for s in S:
    res=False
    if s=="a":
        res=ab <A+B
        ab+=res
    if s=="b":
        res=ab <A+B and b<B
        ab+=res
        b+=res
    print("Yes" if res else "No")

Measured memory_bytes: 4016
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int A = sc.nextInt();
            int B = sc.nextInt();

            int x = A + B;
            int y = A - B;
            int z = A * B;

            int ans;
            if (x >= y && x >= z) {
                ans = x;
            } else if (y >= x && y >= z) {
                ans = y;
            } else {
                ans = z;
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 23764
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		sc.close();
		String[] s = S.split(" ");
		String a = "";
		Map<String, Integer> map = new HashMap<String, Integer>();
		for(String t : s) {
			if(a.length() < t.length()) {
				a = t;
			}
			map.merge(t, 1, (v1, v2) -> v1 + v2);
		}
		String b = "";
		int m = 0;
		for(String k : map.keySet()) {
			if(m < map.get(k)) {
				m = map.get(k);
				b = k;
			}
		}
		System.out.printf("%s %s\n", b, a);
	}
}


Measured memory_bytes: 31404
from copy import deepcopy


def main():
    n = int(input())
    x = list(map(int, input().split()))
    y = deepcopy(x)
    y.sort()
    median = y[n // 2]
    next_median = y[n // 2 - 1]
    for xx in x:
        if xx >= median:
            print(next_median)
        else:
            print(median)


if __name__ == '__main__':
    main()



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

vector<int> make_bit(int n){
  vector<int> tmp;
  for (int i = 0; i < 10; ++i)
  {
    tmp.emplace_back(n%2);
    n/=2;
  }
  reverse(tmp.begin(), tmp.end());
  return tmp;
}

int main()
{
  int n;
  cin>>n;
  vector<vector<int>> vec(n,vector<int>(10));
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < 10; ++j)
    {
      cin>>vec[i][j];
    }
  }
  vector<vector<int>> P(n,vector<int>(11));
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < 11; ++j)
    {
      cin>>P[i][j];
    }
  }
  priority_queue<int> ansv;
  for (int i = 1; i < 1024; ++i)
  {
    vector<int> tmp=make_bit(i);
    int ans=0;
    for (int j = 0; j < n; ++j)
    {
      int cnt=0;
      for (int k = 0; k < 10; ++k)
      {
        if(vec[j][k]+tmp[k]==2) cnt++;
      }
      ans+=P[j][cnt];
    }
    ansv.push(ans);
  }
  cout<<ansv.top();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
vector <pair<int, long long> > edges[100000];
int color[100000];
bool done[100000];
void dfs(int cur,  int cur_mod){
  if(cur_mod == 0){
    color[cur] = 0;
  } else {
    color[cur] = 1;
  }
  done[cur] = true;
  for(int i = 0; i < edges[cur].size(); i++){
    int next = edges[cur][i].first;
    int next_mod = (cur_mod + (edges[cur][i].second % 2)) % 2;
    if(!done[next]){
      dfs(next, next_mod);
    }
  }
}
int main(void){
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++){
    int a;
    int b;
    long long w;
    cin >> a >> b >> w;
    edges[a - 1].push_back(make_pair(b - 1, w));
    edges[b - 1].push_back(make_pair(a - 1, w));
  }

  dfs(0, 0);
  for(int i = 0; i < N; i++){
    cout << color[i] << endl;
  }
  return 0;
}


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

int main()
{
	long long L, R; cin >> L >> R;
	long long L_mod = L % 2019;
	long long R_mod = R % 2019;
	long long L_q = L / 2019;
	long long R_q = R / 2019;

	int ans = 2019;

	if (L_q == R_q) {
		for (long long i = L; i < R; i++)
		{
			for (long long j = i + 1; j <= R; j++)
			{
				long long chk = (i * j) % 2019;
				if (chk < ans) ans = chk;
			}
		}
	}
	else {
		ans = 0;
	}

	cout << ans << endl;
}

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

int main() {
	int n;
	while (cin >> n) {
		bool first = true;
		for (int i = 0; i < 10; i++) {
			if (n & (1<<i)) {
				if (first)
					first = false;
				else
					cout << " ";
				cout << (1<<i);
			}
		}
		cout << endl;
	}
	return 0;
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する



int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    ll ans=0;
    map<ll,ll>mp;
    
    for(ll i=0;i<n;i++){
      cin>>a[i];
      mp[i+1-a[i]]++;
    }
    for(ll i=0;i<n;i++){
      mp[i+1-a[i]]--;
      ans+=mp[i+1+a[i]];
    }

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

Measured memory_bytes: 27436
N,a,b,c = map(int,input().split())
S = []
D = [a,b,c]
# d = a+b+c
for _ in range(N):
    S.append(input())
# print(S)
Y = []

def f(s,ns):
    s0 = ord(s[0])-65
    s1 = ord(s[1])-65
    k = 0
    if D[s0] == D[s1]:
        ns0 = ord(ns[0])-65
        ns1 = ord(ns[1])-65
        
        if s0 == ns0 and s1 == ns1:
            k = 0
        elif s0 == 3 - ns0 - ns1:
            k = 0
        else:
            k = 1
    
    elif D[s0] > D[s1]:
        k = 0
    else:
        k = 1
        
    if k==0:
        D[s0] -= 1
        D[s1] += 1
        # print(s[1])
        Y.append(s[1])
    else:
        D[s0] += 1
        D[s1] -= 1
        # print(s[0])
        Y.append(s[0])
        

g = True
# print(D)
for i in range(N):
    s = S[i]
    if i == N-1:
        ns = s
    else:
        ns = S[i+1]
    # print(s,ns)
    f(s,ns)
    # print(D)
    if D[0] < 0 or D[1] < 0 or D[2] < 0:
        print("No")
        g = False
        break
    
if g:
    print("Yes")
    for y in Y:
        print(y)
    

Measured memory_bytes: 16932
MOD = 1000000007
MAX = 200000    # max n

fac = [0 for _ in range(MAX)]    # = n! (mod MOD)
finv = [0 for _ in range(MAX)]    # = 1/r! (mod MOD)
inv = [0 for _ in range(MAX)]    # = 1/r (mod MOD)


# init
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


# nCk, n < [0, MAX), k < [0, n]
def COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


COMinit()
n, k = map(int, input().split())
A = [int(a) for a in input().split()]
A.sort()
ans = 0
for i in range(n):
    if n - (i + 1) < k - 1:
        break
    ans += ((A[n - i - 1] - A[i]) * COM(n - i - 1, k - 1)) % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 37844
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    ll n;
    cin >> n;
    if(n < 1200)cout << "ABC" << endl;
    else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 1740
# ABC109D - Make Them Even
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    A = list(list(map(lambda x: int(x) % 2, input().split())) for _ in range(H))
    ans = []
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j] ^= 1
                A[i][j + 1] ^= 1
                ans += [(i + 1, j + 1, i + 1, j + 2)]

    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i][W - 1] ^= 1
            A[i + 1][W - 1] ^= 1
            ans += [(i + 1, W, i + 2, W)]
    print(len(ans))
    for i in ans:
        print(*i)


if __name__ == "__main__":
    main()

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

int main()
{
  int n;
  string s;

  cin >> n >> s;
  for (int i = 0; i < s.size(); i++)
    s[i] = (char)((((s[i] - 'A') + n) % 26) + 'A');
  cout << s << endl;
}

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

#define cp_io ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long int
#define oo 1000000010
#define MAX 1000000
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define nl "\n"

int main()
{
    cp_io;
    #ifndef ONLINE_JUDGE
    freopen("z_input.txt","rt",stdin);
    freopen("z_output.txt","wt",stdout);
    #endif
    ll n;
    cin >> n;
    string s = "";

    while(n)
    {
        n--;
        int temp = n%26;
        n = n/26;
        s += 'a'+temp;
    }
    reverse(s.begin(), s.end());
    cout << s << nl;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
  int H,W; cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){ 
    cin >> S[i];}
  
  queue<pair<int,int>> Q; vector<vector<int>> B(H,vector<int>(W,-1));
  
  for(int i = 0; i < H; i++){ 
    for(int j = 0; j < W; j++){
      if( S[i][j] == '#'){ Q.push(make_pair(i,j));B[i][j] = 0;}}}
  
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  int ans = 0;
  while(!Q.empty()){
    pair<int,int> p = Q.front(); Q.pop();
    int s = p.first; int t = p.second;
    
    for(int k = 0; k < 4; k++){
      if( s + dx[k] < 0 || s + dx[k] >= H || t + dy[k] < 0 || t + dy[k] >= W){
        continue;}
      if(B[s+dx[k]][t+dy[k]] != -1){ continue;}
      B[s+dx[k]][t+dy[k]] = B[s][t] + 1; 
      ans = max( ans, B[s+dx[k]][t+dy[k]]);
      Q.push(make_pair(s+dx[k],t+dy[k]));}}
    
    cout << ans << endl; return 0;}
    

Measured memory_bytes: 13456
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int diff = a.length() - b.length();
		String zero = "0";
		for (int i = 1; i < Math.abs(diff); i++) {
			zero.concat("0");
		}
		if (diff < 0) {
			a = zero.concat(a);
			//System.out.print(a);
		}else if(diff > 0) {
			b = zero.concat(b);
			//System.out.print(b);
		}
		if (a.compareTo(b) < 0) {
			System.out.print("LESS");
		} else if (a.compareTo(b) > 0) {
			System.out.print("GREATER");
		} else {
			System.out.print("EQUAL");
		}
	}
}


Measured memory_bytes: 23764
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String input = sc.nextLine();
		sc.close();

		Deque<Integer> s1 = new ArrayDeque<>();
		Deque<int[]> s2 = new ArrayDeque<>();

		int sum = 0;
		for (int i = 0; i < input.length(); i++) {
			switch (input.charAt(i)) {
			case '\\':
				s1.push(i);
				break;

			case '_':
				// Do Nothing
				break;

			case '/':
				if (!s1.isEmpty()) {
					int j = s1.pop();
					int menseki = i - j;

					sum += menseki;

					while (!s2.isEmpty() && s2.peek()[0] > j) {
						menseki += s2.pop()[1];
					}

					int[] val = {j, menseki};
					s2.push(val);
				}
				break;
			default:
				break;
			}
		}

		System.out.println(sum);
		System.out.print(s2.size());
		while (!s2.isEmpty()) {
			System.out.print(" " + s2.pollLast()[1]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 30004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  map<string, int> cnt;
  rep(i, N) {
    string S;
    cin >> S;
    cnt[S]++;
  }
  for (string s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << cnt[s] << '\n';
  }
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    int ans=0;
    rep(i,n){
        if (i+1==v[i]){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;  
}


Measured memory_bytes: 640
#include <algorithm>
    #include <cassert>
    #include <climits>
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <deque>
    #include <iomanip>
    #include <iostream>
    #include <limits>
    #include <map>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <string>
    #include <vector>
     
    #define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
    #define rep(i,n) FOR(i,0,n)
    #define pb push_back
    #define eb emplace_back
    #define mp make_pair
    #define fst first
    #define snd second
    #define all(v) begin(v), end(v)
    #define debug(x) cerr<< #x <<": "<<x<<endl
    #define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
     
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int, int> pii;
    typedef vector<int> vi;
    typedef vector<vector<int> > vvi;
    typedef vector<ll> vll;
    typedef vector<vector<ll> > vvll;
    template<class T> using vv=vector<vector< T > >;
     
    int main() {
      string s;
      cin >> s;
      int len = s.length();
      int cond0 = 0;
      int cond1 = 0;
      if (len % 2 == 1) {
        cond0 = 1;
      }
      if (s[0] == s[len-1]) {
        cond1 = 1;
      }
      if (cond0 + cond1 == 1) {
        printf("First\n");
        return 0;
      }
      printf("Second\n");
     
      return 0;
    }

Measured memory_bytes: 512
n = gets.to_i
hash = {}
gets.split.map(&:to_i).each do |num|
  hash[num] ||= 0
  hash[num] += 1
end

sum = 0
hash.each do |num, count|
  sum += num * count
end

q = gets.to_i
q.times do
  b, c = gets.split.map(&:to_i)
  num = hash[b].to_i
  sum += num * (c - b)

  hash[c] ||= 0
  hash[c] += hash[b].to_i
  hash[b] = 0

  puts sum
end


Measured memory_bytes: 25656
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 3010

int n;
double p;
double f[MAXN][MAXN];

int main() {
    scanf("%i", &n);
    f[0][0] = 1.0;
    for(int i = 1; i <= n; ++i) {
        scanf("%lf", &p);
        //cout << "*" << p << endl;
        for(int j = 0; j <= i - 1; ++j) {
            f[i][j + 1] += f[i - 1][j]*p;
            f[i][j] += f[i - 1][j]*(1 - p);
        }
    }

    //cout << f[1][1] << endl;

    printf("%.12f\n", accumulate(&f[n][n/2 + 1], &f[n][n + 1], 0.0));
    return 0;
}

Measured memory_bytes: 69120
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

fun divisors(x: Int): MutableList<Int> {
  val res = mutableListOf<Int>()
  var d = 1
  while (d * d <= x) {
    if (x % d == 0) {
      res += d
      if (d * d != x) res += x / d
    }
    ++d
  }
  return res
}
class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val A = na(N)
    val exists = IntArray(1_000_000 + 1)
    for (a in A) {
      exists[a]++
    }
    var cnt = 0
    for (a in A) {
      for (d in divisors(a)) {
        if ((d == a && exists[d] > 1) || (d != a && exists[d] > 0)) {
          cnt++
          break
        }
      }
    }
    out.println(N - cnt)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 62744
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define MAX 1000005
 
int main() 
{   
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll n,k,i;
	cin>>n>>k;
	ll a[n];
	rep(i,n)
	{
		cin>>a[i];
	}
	ll sum=0;
	rep(i,k)
	sum+=a[i];
	ll maxi=sum;
	REP(i,0,n-k)
	{
		sum+=a[k+i]-a[i];
		maxi=max(maxi,sum);
	}
	ld e=k;
	ld f=maxi;
	cout<<fixed<<setprecision(15)<<(e+f)/2;
	return 0;
	}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,x;
	scanf("%lld%lld%lld",&a,&b,&x);
	printf("%lld\n",a%x==0?b/x-a/x+1:b/x-a/x);
	return 0;
}

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

int a[1000005];
int vis1[1000005]={0};
int vis2[1000005]={0};
vector<int>pri;
void prime(){
	pri.push_back(1);
	for(int i=2;i<=1000;i++){
		if(vis2[i]==0){
			pri.push_back(i);
			for(int j=2;j*i<=1000;j++){
				vis2[i*j]=1;
			}
		}
	}
	return;
}

int main()
{
	prime();
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		vis1[a[i]]++;
	}
	int len=pri.size();
	int sum=0;
	for(int i=1;i<=n;i++){
		vis1[a[i]]--;
		bool flag=true;
		for(int j=1;j*j<=a[i]&&j<=1000;j++){
			if(a[i]%j==0){
				if(vis1[j]>0||vis1[a[i]/j]>0){
					flag=false;
					break;
				}
			}
		}
		vis1[a[i]]++;
		if(flag){
			sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 8112
#include<bits/stdc++.h>
#define mx 2000000000
using namespace std;
int main(void)
{
	int v,e;
	int a,b,c,d[101][101],i,j,k;
	
	cin>>v>>e;
	
	for(i=0;i<v;i++){
		for(j=0;j<v;j++){
			if(i==j) d[i][j]=0;
			else d[i][j]=mx;
		}
	}
	
	for(i=0;i<e;i++){
		cin>>a>>b>>c;
		d[a][b]=c;
	}	
		
	for(k=0;k<v;k++){
		for(i=0;i<v;i++){
			for(j=0;j<v;j++){
				if(d[i][k]==mx||d[k][j]==mx) continue;
				else d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	
	int flg=0;
	for(i=0;i<v;i++){
		for(j=0;j<v;j++){
			if(i==j&&d[i][j]<0) flg=1;
		}
	}
	
	if(flg==1) cout<<"NEGATIVE CYCLE"<<endl;
	
	if(flg==0){
		for(i=0;i<v;i++){
			for(j=0;j<v;j++){
				if(mx==d[i][j]&&j==0) cout<<"INF";
				else if(mx!=d[i][j]&&j==0) cout<<d[i][j];
				else if(mx==d[i][j]&&j!=0) cout<<" "<<"INF";
				else cout<<" "<<d[i][j];
			}
			cout<<endl;
		}	
	}
	
	return 0;
}	


Measured memory_bytes: 3156