akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>

int main() {
	long long N;
	long long count = 0;
	scanf("%lld", &N) + 1;
	long long tmp;

	if (N == 0) {
		printf("0\n");
		return 0;
	}
	if (N % 2 == 1) {
		printf("0\n");
		return 0;
	}
	
	for (int i = 0; i < 25; i++) {
		long long tmp = 10 * (long long)pow(5, i);
		count += N / tmp;
	}

	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main { 

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int line = Integer.parseInt(sc.nextLine());
    	int result = 0;
    	for(int i = 1;i<=line;i++) {
    		int numberLength = String.valueOf(i).length();
    		if(numberLength%2 == 1) {
    			result++;
    		}
    	}
    	System.out.println(result);
    	
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

const int M=256;

int n;
int l[333];
int r[333];
double f[333];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,n)cin>>l[i];
		double minh=INF;
		int ress=0,resa=0,resc=0;
		rep(s,16)rep(a,16)rep(c,16){
			r[0]=s;
			repl(i,1,n+1){
				r[i]=(a*r[i-1]+c)%M;
			}
			memset(f,0,sizeof(f));
			repl(i,1,n+1)f[(l[i-1]+r[i])%M]++;
			double h=0;
			rep(i,M){
				if(f[i]!=0)h-=(f[i]/n)*log(f[i]/n);
			}
			if(h+1e-8<minh){
				minh=h;
				ress=s;
				resa=a;
				resc=c;
			}
		}
		printf("%d %d %d\n",ress,resa,resc);
	}
	return 0;
}

Measured memory_bytes: 3464
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      int sz = i * j + (N - i) * (M - j);
      if (sz == K) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  if (K == 0) {
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int N = sc.nextInt();
    int count = 0;
    while(count < N){
      if(count %2 == 0){
        if(A %2 != 0){
          A = A - 1;
        }
        int halfA = A / 2;
        A -= halfA;
        B += halfA;
        count++;
      }else{
        if(B %2 != 0){
          B = B - 1;
        }
        int halfB = B / 2;
        B -= halfB;
        A += halfB;
        count++;
      }
    }
    System.out.println(A + " " + B);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
//			re%=mod;
		}
		a=(a*a);
//		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		ll a,b,c;
		cin>>a>>b>>c;
		char ans[n];
		string p[n];
		FOR(i,0,n)
		{
			cin>>p[i];
		}
		FOR(i,0,n)
		{
			if(p[i]=="AB")
			{
				if(a<b)
				{
					a++;
					b--;
					ans[i]='A';
				}
				else if(b<a)
				{
					a--;
					b++;
					ans[i]='B';
				}
				else
				{
					if(i<(n-1))
					{
						if(p[i+1]=="AC")
						{
							a++;
							b--;
							ans[i]='A';
						}
						else
						{
							a--;
							b++;
							ans[i]='B';
						}
					}
					else
					{
						a++;
						b--;
						ans[i]='A';
					}
				}
			}
			else if(p[i]=="AC")
			{
				if(a<c)
				{
					a++;
					c--;
					ans[i]='A';
				}
				else if(a>c)
				{
					a--;
					c++;
					ans[i]='C';
				}
				else
				{
					if(i<(n-1))
					{
						if(p[i+1]=="AB")
						{
							a++;
							c--;
							ans[i]='A';
						}
						else
						{
							a--;
							c++;
							ans[i]='C';
						}
					}
					else
					{
						a++;
						c--;
						ans[i]='A';
					}
				}
			}
			else 
			{
				if(c<b)
				{
					c++;
					b--;
					ans[i]='C';
				}
				else if(b<c)
				{
					c--;
					b++;
					ans[i]='B';
				}
				else
				{
					if(i<(n-1))
					{
						if(p[i+1]=="AC")
						{
							c++;
							b--;
							ans[i]='C';
						}
						else
						{
							c--;
							b++;
							ans[i]='B';
						}
					}
					else
					{
						c++;
						b--;
						ans[i]='C';
					}
				}
			}
			if(a<0 || b<0 || c<0)
			{
//				cout<<a<<' '<<b<<' '<<c<<' ';
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes\n";
		FOR(i,0,n)
		cout<<ans[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 6876
#include <stdio.h>     
int main(){
     char number[1001];
     int i, sum;
     while(1){
         scanf("%s", number);
         if(number[0]=='0')break;
         sum=0;
         for(i=0;number[i]!='\0';i++){
             sum+=number[i]-'0';
         }
         printf("%d\n", sum);
     }
     return 0;
}


Measured memory_bytes: 2108
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

lli k;

void clear() {
}

void read() {
}

void solve() {
	const int n = 50;
	vli res(n, 49);
	for (int i = 0; i < res.size(); i++)
		res[i] += k / n;

	while (k % n) {
		int mini = -1;
		for (int i = 0; i < res.size(); i++)
			if (mini == -1 || res[i] < res[mini])
				mini = i;
		res[mini] += n;
		for (int i = 0; i < res.size(); i++) {
			if (i == mini) continue;
			res[i] -= 1;
		}
		k--;
	}

	printf("%d\n", res.size());
	for (auto &x : res) printf("%lld ", x);
	printf("\n");
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%lld", &k) == 1) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

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

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for(int i =0;i<N;i++){
    cin >> x[i];
  }
  for(int i = 0;i<M;i++){
    cin >> y[i];
  }
  sort(x.begin(),x.end(),greater<int>());//x[0]=max
  sort(y.begin(),y.end());//y[0]=min
  
  if(x[0] < y[0] && X < y[0] && Y > x[0]){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

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

int main()
{
  int n,max,min,A[N];
  long long sum=0;
  cin >> n;
  cin >> A[0];
  max=min=A[0];
  sum+=A[0];
  for(int i=1;i<n;i++)
    {
      cin >> A[i];
      if(max<A[i]) max=A[i];
      if(min>A[i]) min=A[i];
      sum+=A[i];
    }
  cout << min << ' ' << max << ' ' << sum << endl;
  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define LL long long

int k, dig = 0;
bool flag = false;
int ans[20] = {0};
void dfs (int x, int num) {
	if (k < 0) return;
	if (!flag) ans[x] = num;
	if (x == dig) {
		k --;
		if (k < 0) return;
		if (k == 0) flag = true;
		return;
	}
	for (int i = num - 1; i <= num + 1; i ++) {
		if (i >= 0 && i <= 9) dfs (x + 1, i);
	}
}
int main () {
    cin >> k;
    while (k > 0) {
        dig ++;
        for (int i = 1; i <= 9; i ++) {
            dfs (1, i);
            if (k <= 0 || flag) break;
        }
    }
    for (int j = 1; j <= dig; j ++) cout << ans[j];
	return 0;
}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let V = readIntSplit(by: " ")
let C = readIntSplit(by: " ")
var ans = 0
for i in 0..<N {
    ans += max(V[i]-C[i], 0)
}
print(ans)


Measured memory_bytes: 7908
#include <iostream>

using namespace std;

int main() {

	int x[10001], y[10001];
	int endOfInput;

	for (int i = 0; i < 10001; i++) {
		cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0) {
			endOfInput = i;
			break;
		}
	}

	for (int i = 0; i < endOfInput; i++) {
		if (x[i] < y[i]) {
			cout << x[i] << " " << y[i] << endl;
		}
		else {
			cout << y[i] << " " << x[i] << endl;
		}
	}

	return 0;

}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
Node treeMinimum(Node x){
  while(x->right != NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x=x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else
    return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else
    y=treeSuccessor(z);
  
  if(y->left != NIL){
    x=y->left;
  }
  else x=y->right;

  if(x != NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    x=root;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else y->parent->right=x;

  if(y != z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct 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){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25116
from itertools import groupby, accumulate, product, permutations, combinations
N = int(input())
dics = [[0]*N for _ in range(26)]
for i in range(N):
    S = input()
    for s in S:
        dics[ord(s)-ord('a')][i]+=1
ans = ''
for i in range(26):
    ans += chr(i+ord('a'))*min(dics[i])
print(ans)

Measured memory_bytes: 3060
//Author: master19
#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 ll long long int
#define ff first 
#define ss second 
#define pb push_back
#define endl "\n"
#define PI acos(-1.0)
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define ccy cout << "YES\n"
#define ccn cout << "NO\n"
#define cfy cout << "Yes\n"
#define cfn cout << "No\n"
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define vil vector < ll > 
#define vis vector < string > 
#define vip vector < pair < ll, ll > > 
#define pi pair < ll , ll > 
#define pii pair < pair < ll, ll >, ll >
#define Sort(arr) sort(arr.begin(), arr.end())
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds; 
ll lets_do_it();
// pi xy[] = {{-1, 0}, {1, 0} , {0, -1}, {0, 1}};
// pi dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
// bool isValid(ll x, ll y, ll row, ll col){
//     return ((x>=0) && (y >=0)  && (x < row) && (y < col));
// }
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": "; 
        lets_do_it();
    }
    return 0;
}
ll lets_do_it(){
    // Your code goes by here !!
    ll num;
    cin >> num;
    if(num <= 999){
        ll val = num%10;
        if(val == 2 || val == 4 || val == 5 || val == 7 || val == 9)
            cout << "hon" << endl;
        else if(val == 0 || val == 1 || val == 8 || val == 6)
            cout << "pon\n";
        else
            cout << "bon\n";
    }






    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


struct info{
  ll cnt,bit,len;
};

info op(info a,info b){
  ll cnt = a.cnt+b.cnt;
  cnt += (b.len-b.bit)*a.bit;
  return info{cnt,a.bit+b.bit,a.len+b.len};
}
info e(){
  return {0,0,0};
}

info mapping(bool b,info a){
  if(b){
    a.bit = a.len-a.bit;
    a.cnt = (a.len-a.bit)*a.bit-a.cnt;
  }
  return a;
}
bool composition(bool a,bool b){return ((a && b) ? false : (a || b));}
bool id(){return 0;}

int main(){
  
  int n,Q;
  cin >> n >> Q;
  vector<info> v(n,info{0,0,1});
  rep(i,n)cin >> v[i].bit;
  lazy_segtree<info,op,e,bool,mapping,composition,id> seg(v);
  while(Q--){
    int t,l,r;cin >> t >> l >> r;
    if(t == 1){
      seg.apply(--l,r,true);
    }else{
      cout << seg.prod(--l,r).cnt << "\n";
    }
  }


  return 0;
}

Measured memory_bytes: 20436
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let f i =
    let int_l = List.init i (fun i -> i + 1) in
    List.map (fun j -> if i mod j = 0 then true else false) int_l |>
    List.filter (fun tf -> tf = true) |>
    List.length 
  in

  let int_l = List.init n (fun i -> i + 1) in
  let res = 
    List.filter (fun i -> i mod 2 <> 0) int_l |>
    List.map (fun i -> f i) |>
    List.filter (fun i -> i = 8) |>
    List.length 
  in

  Printf.printf "%d\n" res


Measured memory_bytes: 3584
icase=0
if icase==0:
    s=set(input())
    abc=list("abcdefghijklmnopqrstuvwxyz")
#    abc.sort(reverse=True)
    yn=""
    for i in range(len(abc)):
        if not abc[i] in s:
            print(abc[i])
            yn="OK"
            break
    if yn=="":
        print("None")
    

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

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

Measured memory_bytes: 256
#!/usr/bin/python3

import os
import sys


def main():
    X = read_int()
    print('1' if solve(X) else '0')


def solve(X):
    c = X // 100
    for d in range(6):
        n = c - d
        if n < 0:
            break
        r = X - 100 * n
        if 0 <= r <= n * 5:
            return True
    return False


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  long long int count=0;
  cin >> N;
  
  long long int S[5]={0};
  for(int i=0 ; i<N ; i++){
    string name;
    cin >> name;
    switch(name.at(0)){
      case 'M':
        S[0]++;
        break;
      case 'A':
        S[1]++;
        break;
      case 'R':
        S[2]++;
        break;
      case 'C':
        S[3]++;
        break;
      case 'H':
        S[4]++;
        break;
      default:
        break;
    }
   
  }
  
  for(int i=0 ; i<4 ; i++)
    for(int j=i+1 ; j<5 ; j++)
      for(int k=j+1 ; k<5 ; k++)
        count+=S[i]*S[j]*S[k];
      //cout << x << " " << y << " " << z << endl;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3600
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

void main() {
    int n;
    scan(n);

    int ans = 1;

    while (ans <= n / 2) {
        ans *= 2;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
/*
AizuOnline A0241
Title:Quaternion Multiplication
@kankichi573
*/
#include <stdio.h>
int n;
int x1,y11,z1,w1,x2,y2,z2,w2;
//
main()
{
        int i;

        while(EOF!=scanf("%d",&n) && n)
        {
                for(i=0;i<n;i++)
                {
                        scanf("%d %d %d %d ",&x1,&y11,&z1,&w1);
                        scanf("%d %d %d %d",&x2,&y2,&z2,&w2);
                 
                        printf("%d " ,x1*x2-y11*y2-z1*z2-w1*w2);
                        printf("%d " ,x1*y2+y11*x2+z1*w2-w1*z2);
                        printf("%d " ,x1*z2-y11*w2+z1*x2+w1*y2);
                        printf("%d\n",x1*w2+y11*z2-z1*y2+w1*x2);
                }
        }
        return(0);
}

Measured memory_bytes: 600
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B=mi()
    print(max(0,A-2*B))




if __name__ == "__main__":
    main()

Measured memory_bytes: 61756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll mod=1000000007;

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

    if(S.back() == 's') {
        S += "es";
    }
    else {
        S += 's';
    }
    cout << S << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

void printM(vector<vector<long> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
        cout << endl;
    }
}

#define TST 0
int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    long n;
    cin >> n;
    // dp table has score of the test
    // for convenience, allocate more memory than actually is
    vl dp(n+1);
    dp[0] = 1;
    dp[1] = 1;
    FE(i, 2, n){
        dp[i] = dp[i-1]+dp[i-2];
    }
    cout << dp[n] << endl;
#if TST==1

#endif
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans=0,mod=1000000007,x=0,ziyu=1;
  cin >> n;
  vector<long> xx(n+100);
  for(long i=0;i<n-1;i++) {
    xx[i+2]=ziyu;
    ans=(ans+ziyu*min(n-1,i+2))%mod;
    ans=(ans+(ziyu*(n-1))%mod*(n-1))%mod;
    x=(x+xx[i])%mod;
    ziyu=(ziyu+x)%mod;
  }
  ans=(ans+(ziyu*n))%mod;
  cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<ld> a(n);
	rep(i, n) cin >> a[i];
	ld ans = 0;
	rep(i, n) ans += 1.0 / a[i];
	ans = 1.0 / ans;
	cout << ans << endl;

}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var min = (int?)null;

            for (int i = 0; i < s.Length-2; i++)
            {
                var str = s.Substring(i);
                if (str.Length != 3)
                {
                    str = str.Remove(3);
                }
                var val = Math.Abs(int.Parse(str) - 753);
                if (min == null || min > val)
                {
                    min = val;
                }
            }

            Console.WriteLine(min);
        }
    }
}


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

int main(void) {
  long long A, B;
  cin >> A >> B;
  
  if((A+B)%2 != 0)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << (A+B)/2 << endl;

  return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, D);
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  int sat = 0;
  vector<int> last(26);
  rep(i, D) {
    in(int, t);
    --t;
    int d = i + 1;
    last[t] = d;
    sat += s[i][t];
    rep(k, 26) { sat -= c[k] * (d - last[k]); }
    out(sat);
  }
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

k = int(input())
a, b = map(int, input().split())

# b以下の最大のKの倍数を求める
largest = (b // k) * k # 切り捨ての商をk倍することで、最大のkの倍数が求められる
if largest >= a:
    print('OK')
else:
    print('NG')

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

using namespace std;

const int N = 10;
string grid[N];

int main () {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> grid[i];
    }
    int ans = 0;
    for (int maskRow = 0; maskRow < (1 << n); maskRow++) {
        for (int maskCol = 0; maskCol < (1 << m); maskCol++) {
            int black = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (((maskRow & (1 << i)) == 0) && ((maskCol & (1 << j)) == 0) && grid[i][j] == '#')
                        black++;
                }
            }
            if (black == k) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
 
using namespace std;
int main(void){
     
    int n,i,a[100];
    cin >> n;
     
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    
    for(i=n-1;i>=0;i--){
        cout << a[i];
        if(i!=0) cout << " ";
        else cout << endl;
    }
     
}


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

int main() {
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for(ll i=0; i<n; i++){
    cin>>a[i];
  }
  
  ll result=0;
  ll shinchomax=a[0];
  for(ll i=1; i<n; i++){
    ll diff=shinchomax-a[i];
    if(diff>0) result+=diff;
    else shinchomax=a[i];
  }
  
  cout << result << endl;
}

Measured memory_bytes: 4772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0003
{
    class Program
    {
        static int _NumOfData;
        static List<double> _sides = new List<double>();
        static double _longestSide;
        static double _shortSide1;
        static double _shortSide2;

        static void Main(string[] args)
        {
            _NumOfData = int.Parse(Console.ReadLine());
            for (int i = 0; i < _NumOfData; ++i)
            {
                _sides = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
                _sides.Sort();
                _longestSide = Math.Pow(_sides[2], 2);
                _shortSide1 = Math.Pow(_sides[1], 2);
                _shortSide2 = Math.Pow(_sides[0], 2);
                if (_longestSide == _shortSide1 + _shortSide2)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }

        }
    }
}



Measured memory_bytes: 16336
from collections import Counter

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

v1 = v[0::2]
v2 = v[1::2]
c1 = Counter(v1).most_common()
c2 = Counter(v2).most_common()
c1.append((0, 0))
c2.append((0, 0))

if c1[0][0] != c2[0][0]:
    ans = n // 2 - c1[0][1] + n // 2 - c2[0][1]
else:
    ans = min(n // 2 - c1[0][1] + n // 2 - c2[1][1], n // 2 - c1[1][1] + n // 2 - c2[0][1])

print(ans)



Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, X; cin >> N >> X;
    vec b(N), l(N), u(N);

    int dif = 0;
    pairs p(N);
    REP(i, N){
        cin >> b[i] >> l[i] >> u[i];
        dif += b[i] * l[i];
        p[i] = Pii(u[i] * (X - b[i]) + l[i] * b[i], i);
    }
    Sort(p); Reverse(p);

    vec S(N + 1);
    S[0] = 0;
    REP(i, N) S[i + 1] = S[i] + p[i].f;
    
    int a0 = -1, a1 = N * X;
    while(a1 - a0 > 1){
        int a = (a0 + a1) / 2;
        int n = a / X, k = a % X;
        int D = 0;
        if(k == 0){
            D = S[n];
        }else{
            REP(i, N){
                int tmp = 0;
                int i0 = p[i].s;
                if(k >= b[i0]) tmp = u[i0] * (k - b[i0]) + l[i0] * b[i0];
                else tmp = l[i0] * k;
                if(i < n) tmp += S[n + 1] - p[i].f;
                else tmp += S[n];
                Max(D, tmp);
            }
        }
        if(D >= dif) a1 = a;
        else a0 = a;
    }
    Out(a1);

    return 0;
}


Measured memory_bytes: 4992
n = int(input())
for i in range(n) :
    list_m = list(input())
    list_large_m = sorted(list_m, reverse = True)
    list_small_m = sorted(list_m)
    large_m = "".join(list_large_m)
    small_m = "".join(list_small_m)
    print(int(large_m) - int(small_m))


Measured memory_bytes: 5588
#include <iostream>
#include <cstring>
using namespace std;
const int MAX = 36;

struct Card {
  char suit;
  char value;
};

void Print(Card* C, int N) {
  for (int i = 0; i < N - 1; i++)
    cout << C[i].suit << C[i].value << " ";
  cout << C[N - 1].suit << C[N - 1].value << endl;
}

void BubbleSort(Card* C, int N) {
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j >= i + 1; j--) {
      if (C[j].value < C[j - 1].value)
        swap(C[j], C[j - 1]);
    }
  }
}

void SelectionSort(Card* C, int N) {
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (C[j].value < C[minj].value)
        minj = j;
    }
    swap(C[i], C[minj]);
  }
}

bool IsStable(Card* C1, Card* C2, int N) {
  for (int i = 0; i < N; i++) {
    if (C1[i].suit != C2[i].suit)
      return false;
  }
  return true;
}

int main() {
  int N;
  Card C1[MAX], C2[MAX];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> C1[i].suit >> C1[i].value;
  }

  memcpy(C2, C1, sizeof(Card) * MAX);

  BubbleSort(C1, N);
  Print(C1, N);
  cout << "Stable\n";

  SelectionSort(C2, N);
  Print(C2, N);
  if (IsStable(C1, C2, N)) {
    cout << "Stable\n";
  } else {
    cout << "Not stable\n";
  }

  return 0;
}


Measured memory_bytes: 3092
H,W=map(int,input().split())
M=[0]*H
for i in range(H):
    M[i]=input()
H_cnt=[0]*H
W_cnt=[0]*W
for i in range(H):
    for j in range(W):
        if M[i][j]=='#':
            H_cnt[i]=1
            W_cnt[j]=1
for i in range(H):
    for j in range(W):
        if W_cnt[j]==1 and H_cnt[i]==1:
            print(M[i][j],end='')
    if H_cnt[i]==1:
        print()

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

int main()
{
	int a,b,d,r;
	double f;
	cin>>a>>b;
	d = a/b;
	r = a%b;
	f = double(a)/double(b);
	cout<<d<<" "<<r<<" "<<setprecision(9)<<fixed<<f<<endl;
	return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(b-a)<=d && abs(c-b)<=d)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

string gf(int ctr,long long n){
    string s(ctr,'a');
    for(int i=s.size()-1;i>=0;i--){
        s[i]=char('a'+n%26);
        n/=26;
    }
    return s;
}

void solve(){
    long long n;
    cin>>n;
    int ctr=1;
    long long mul=1,tot=0;
    while(tot+mul*26<n){
        mul*=26;
        tot+=mul;
        ctr++;
    }
    n-=tot;
    cout<<gf(ctr,n-1)<<"\n";
}

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

    solve();
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=105;i<=N;i+=2){
    int yaku = 0;
    for(int j=1;j<=i;j++){
      if(i % j == 0) yaku++;
    }
    if(yaku == 8) ans++;
  }
  cout << ans << endl;
}

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


bool ok(vector<int> &v,int g){
	bitset<32000> cur;
	cur[16000] = 1;
	//cout << cur <<endl;
	for(int i=0;i<v.size();++i){
		cur = ((cur << v[i]) | (cur >> v[i]));
	}
//	cout << cur <<endl;
//	cout << cur[8000+g] <<endl;
	return cur[16000+g];
}

int main(){
	string s;
	int gx,gy;
	cin >> s;
	cin >> gx >> gy;
	
	
	int cnt  = 0;
	int fn = 0;
	vector<int> vy,vx;
	for(int i=0;i<s.size();++i){
		if(s[i] == 'F'){
			fn++;
		}
		if(s[i] == 'T' || i == s.size()-1){
			if(cnt%2==0){
				if(cnt == 0){
					gx -= fn;
				}else{
					vx.push_back(fn);
				}
			}else{
				vy.push_back(fn);
			}
			fn = 0;
			cnt++;
		}
	}
	
	if(ok(vx,gx) && ok(vy,gy)){
		cout << "Yes" <<endl;
	}else{
		cout << "No" <<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x) { int k, m = 0; *x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { *x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; *x = (*x) * 10 + k - '0'; }if (m)(*x) = -(*x); }
void reader(int *x, int *y) { reader(x); reader(y); }
void reader(int *x, int *y, int *z) { reader(x); reader(y); reader(z); }
void writer(int x, char c) { int i, sz = 0, m = 0; char buf[10]; if (x<0)m = 1, x = -x; while (x)buf[sz++] = x % 10, x /= 10; if (!sz)buf[sz++] = 0; if (m)mypc('-'); while (sz--)mypc(buf[sz] + '0'); mypc(c); }

int a[1000][1000], dp[1000][1000];
int main() {
	int h, w, n;
	while (reader(&h, &w, &n), h) {
		rep(i, h)rep(j, w)reader(&a[i][j]);
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		rep(i, h)rep(j, w) {
			if (i) {
				if (a[i - 1][j])dp[i][j] += dp[i - 1][j] / 2;
				else dp[i][j] += (dp[i - 1][j] + 1) / 2;
			}
			if (j) {
				if (a[i][j - 1])dp[i][j] += (dp[i][j - 1] + 1) / 2;
				else dp[i][j] += dp[i][j - 1] / 2;
			}
		}
		rep(i, h)rep(j, w) {
			if (dp[i][j] & 1)a[i][j] = !a[i][j];
		}
		int x = 0, y = 0;
		while (x < h&&y < w) {
			if (a[x][y])y++;
			else x++;
		}
		writer(x + 1, ' '); writer(y + 1, '\n');
	}
}

Measured memory_bytes: 10808
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

// 入力
string s,t;

// DP テーブル
long long dp[3010][3010] = {}; //共通文字列の長さ、初期値も初期条件も0

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

  // ループ
  FOR(i,0,s.size()) {
    FOR(j,0,t.size()) {
      if (s[i] == t[j]) { //共通部分文字列を増やせる時
        chmax(dp[i+1][j+1], dp[i][j] + 1);
      }
      chmax(dp[i+1][j+1], dp[i+1][j]);
      chmax(dp[i+1][j+1], dp[i][j+1]);
    }
  }
  
  // 答え(復元)
  string ans = "";
  int i = s.size();
  int j = t.size();
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i-1][j]) { //上から来てた時
      i--; //ansには何も付け加えず、遷移元を探る
    }
    else if (dp[i][j] == dp[i][j-1]) { //左から来てた時
      j--;
    }
    else {
      ans = s[i-1] + ans; //t[j-1]でもOK
      i--; j--;
    }
  }
  cout << ans << endl;
 
}

Measured memory_bytes: 74236
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin >> s;
	int w;
	scanf("%d", &w);
	int len = s.size();
	for(int i=0;i<len;i+=w){
		putchar(s[i]);
	}
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int h[N];
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    int ans = 0;
    while (accumulate(h, h + N, 0) > 0)
    // for (int a = 0; a < 3; a++)
    {
        int start_idx = -1;
        int end_idx = N;
        int minimum = 100;
        for (int i = 0; i < N; i++)
        {
            if (h[i] > 0 && start_idx == -1)
            {
                start_idx = i;
            }
            if (h[i] == 0 && start_idx != -1)
            {
                end_idx = i;
                break;
            }
            if (h[i] != 0)
            {
                minimum = min(minimum, h[i]);
            }
        }
        ans += minimum;
        for (int i = start_idx; i < end_idx; i++)
        {
            h[i] -= minimum;
        }
    }
    cout << ans << endl;
}


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

int main() {
	long long N;
	cin >> N;
	long long max_height = 0;
	long long sum_height = 0;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		if (A < max_height) {
			sum_height += max_height - A;
		}
		else {
			max_height = A;
		}
	}
	cout << sum_height << endl;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string str; cin >> str;
    int n = str.size();
    ll dp0[n+1], dp1[n+1];
    dp0[1] = 1, dp1[1] = 2;
    for(int i=2;i<=n;i++){
        if(str[i-1] == '0'){
            dp0[i] = (3LL*dp0[i-1]) %MOD;
            dp1[i] = dp1[i-1]; // (0, 0)
        }else{
            dp0[i] = ((3LL*dp0[i-1]) %MOD + dp1[i-1]) %MOD; // (0, 0)
            dp1[i] = (2LL*dp1[i-1]) %MOD; // (1, 0), (0, 1)
        }
    }
    cout << (dp0[n] + dp1[n]) % MOD << endl;
}

Measured memory_bytes: 2000
n,m = map(int,input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int,input().split()))
switch = [ [0] * m for i in range(n)]
ans = 0
for i in range(m):
         for j in range(1,len(ks[i])):
                  switch[ks[i][j]-1][i] += 1
for i in range(2 ** n):
         lampcount = [ 0 ] * m
         for j in range(n):
                  if ((i >> j) & 1):
                           for k in range(m):
                                    if switch[j][k] == 1:
                                             lampcount[k] += 1
         for l in range(m):
                  lampcount[l] = lampcount[l] % 2
         if lampcount == p:
                  ans += 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919810
typedef pair<int, int> P;
int a[200];
signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		a[i] = s[i] - '0';
	}
	for (int i = 0; i < 8; i++) {
		int ans = a[0];
		for (int j = 0; j < 3; j++) {
			if (i&(1 << j))ans += a[j + 1];
			else ans -= a[j + 1];
		}
		if (ans == 7) {
			string as;
			for (int j = 0; j < 3; j++) {
				if (i&(1 << j))as.push_back('+');
				else as.push_back('-');
			}
			as.push_back('=');
			for (int j = 0; j < 4; j++) {
				cout << a[j] << as[j];
			}
			cout << 7 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: u64, k: u64
    }
    let m = 1000000007;
    let fact = fact_table(n as usize, m);

    for i in 1..=k {
        let comb1 = mod_comb(n-k+1, i, m, &fact);
        let comb2 = mod_comb(k-1, i-1, m, &fact);
        let ans = comb1 * comb2 % m;
        println!("{}", ans);
    }
}

#[allow(dead_code)]
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
#[allow(dead_code)]
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
/// x ^ n % m
pub fn mod_pow(x: u64, n: u64, m: u64) -> u64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
#[allow(dead_code)]
pub fn mod_inverse(a: u64, m: u64) -> u64 {
    let (_, x, _) = extgcd(a as i64, m as i64);
    ((m as i64 + x) as u64 % m) % m
}
#[allow(dead_code)]
pub fn fact_table(len: usize, m: u64) -> Vec<u64> {
    let mut res = vec![1; len + 1];
    for i in 1..len + 1 {
        res[i] = (i as u64 * res[i - 1]) % m;
    }
    res
}
#[allow(dead_code)]
/// Factorial and Inverse factorial table
pub fn fact_inv_table(size: usize, m: u64) -> (Vec<u64>, Vec<u64>) {
    let mut fact = vec![1; size];
    let mut fact_inv = vec![1; size];
    for i in 2..size {
        fact[i] = fact[i - 1] * i as u64 % m;
        fact_inv[i] = m - ((m / i as u64) * fact_inv[(m % i as u64) as usize] % m);
    }
    for i in 1..size {
        fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m;
    }
    (fact, fact_inv)
}
#[allow(dead_code)]
/// (a mod p, e when n! = a p\^e)
pub fn mod_fact(n: u64, p: u64, fact: &[u64]) -> (u64, u64) {
    if n == 0 {
        (1, 0)
    } else {
        let (a, b) = mod_fact(n / p, p, fact);
        let pow = b + n / p;
        if n / p % 2 != 0 {
            (a * (p - fact[(n % p) as usize]) % p, pow)
        } else {
            (a * fact[(n % p) as usize] % p, pow)
        }
    }
}
#[allow(dead_code)]
/// C(n, k) % p
pub fn mod_comb(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    if n < k {
        0
    } else {
        let (a1, e1) = mod_fact(n, p, fact);
        let (a2, e2) = mod_fact(k, p, fact);
        let (a3, e3) = mod_fact(n - k, p, fact);
        if e1 > e2 + e3 {
            0
        } else {
            a1 * mod_inverse(a2 * a3 % p, p) % p
        }
    }
}
#[allow(dead_code)]
/// H(n, k) % p
pub fn mod_comb_repetition(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    mod_comb(n - 1 + k, n - 1, p, fact)
}

Measured memory_bytes: 2220