akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
using namespace std;
const int C=1001, M=1000000007;

char k[C][C];
int n, m, dp[C][C], i, j;

int main(){
	scanf ("%d %d", &n, &m);
	getchar();
	dp[0][0]=1;
	
	for (i=0;i<n;i++){
		for (j=0;j<m;j++){
			k[i][j]=getchar();
			if (k[i][j]=='#')	continue;
			if (i>0&&j>0)	dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
			else if (i>0)	dp[i][j]=dp[i-1][j];
			else if (j>0)	dp[i][j]=dp[i][j-1];
		}
		getchar();
	}
	printf ("%d", dp[n-1][m-1]);
	
return 0;}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,ans=0; cin >> N;
  vv<int> c(10,v<int>(10,0));
  for(int i=1;i<=N;i++){
    string s=to_string(i);
    c[s[0]-'0'][s[s.size()-1]-'0']++;
  }
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      ans+=c[i][j]*c[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n;
int a[N];
multiset <int> ms;

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; i--) {
        ms.insert(a[i]);
        auto it = ms.upper_bound(a[i]);
        if (it != ms.end()) ms.erase(it);
    }
    cout << (int)ms.size();
}

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

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 131072;
int idx[2*MAXN];
int getv(int a, int b)
{
    a += MAXN; b += MAXN;
    int ans = 0;
    while (a<=b)
    {
        if (a%2==1) ans += idx[a++];
        if (b%2==0) ans += idx[b--];
        a /= 2; b /= 2;
    }
    return ans;
}
void addv(int a, int v)
{
    a += MAXN; idx[a] += v;
    while (a = a/2)
        idx[a] = idx[2*a]+idx[2*a+1];
}
vector<int> in[MAXN];
vector<int> factors[MAXN];
vector<int> out[MAXN];
int dans[MAXN];
int ans[MAXN];
int main()
{
    int N, M; scanf("%d%d", &N, &M);
    for(int i=1; i<=M; ++i)
        for(int j=i; j<=M; j+=i)
            factors[j].push_back(i);
    for(int i=0; i<N; ++i)
    {
        int L, R; scanf("%d%d", &L, &R);
        in[L].push_back(R-L+1);
        out[R].push_back(R-L+1);
        dans[R-L+1]++;
    }
    for(int i=M; i>=1; --i)
        ans[i] = ans[i+1]+dans[i];
    for(int i=1; i<=M; ++i)
    {
        for (auto x: in[i]) addv(x, 1);
        for (auto x: factors[i]) ans[x] += getv(1, x-1);
        for (auto x: out[i]) addv(x, -1);            
    }
    for(int i=1; i<=M; ++i)
        printf("%d\n", ans[i]);
    return 0;
}











Measured memory_bytes: 24192
# C
import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)

Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
int a[1010];

vector<int> ad;

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(a[i]);
	ll ans = -2e9;
	int Me = max_element(a+1, a+n+1) - a;
	ans = a[Me];
	for(int i=n; Me<i; --i) ad.pb(i);
	for(int i=1; i<Me; ++i) ad.pb(1);
	
	for(int s=1; s<=2; ++s){
		ll me = 0; int cnt = 0;
		for(int i=s; i<=n; i+=2) if(a[i]>0) me += a[i], ++cnt;
		if(ans < me && cnt){
			ans = me;
			ad.clear();
		
			vector<int> cur(n);
			for(int i=1; i<=n; ++i) cur[i-1]=i;
		
			for(;;){
				if(cur[0]%2==s%2 && a[cur[0]]>0) break;
				ad.pb(1); cur.erase(cur.begin());
			}
			for(;;){
				if(cur.back()%2==s%2 && a[cur.back()]>0) break;
				ad.pb(int(cur.size())); cur.pop_back();
			}
			
			while(cur.size() > 1u){
				if(cur[2]%2==s%2 && a[cur[2]]>0){
					ad.pb(2);
					cur.erase(cur.begin()+1);
					cur.erase(cur.begin()+1);
				} else {
					ad.pb(3);
					cur.erase(cur.begin()+2);
					cur.erase(cur.begin()+2);
				}
			}
		}
	}
	printf("%lld\n", ans);
	printf("%d\n", int(ad.size()));
	for(int x:ad) printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin>>x;
    if(x%7==1){
        cout<<"fri"<<endl;
    }
    if(x%7==2){
        cout<<"sat"<<endl;
    }
    if(x%7==3){
        cout<<"sun"<<endl;
    }
    if(x%7==4){
        cout<<"mon"<<endl;
    }
    if(x%7==5){
        cout<<"tue"<<endl;
    }
    if(x%7==6){
        cout<<"wed"<<endl;
    }
    if(x%7==0){
        cout<<"thu"<<endl;
    }
}


Measured memory_bytes: 3116
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n,k=MI()
	P=LI()
	for i in range(n):
		P[i]-=1
	C=LI()

	A=[[] for _ in range(n)]

	for i in range(n):
		A[i].append(C[i])
		now=P[i]
		while i!=now:
			A[i].append(A[i][-1]+C[now])
			now=P[now]
	#print(A)

	ans=-10**18

	for i in range(n):
		l=len(A[i])
		q,r=divmod(k-1,l)

		if q==0:
			ans=max(ans,max(A[i][:k]))
		else:
			if A[i][-1]<=0:
				ans=max(ans,max(A[i]))
			else:
				ans=max(ans,A[i][-1]*(q-1)+max(A[i]),A[i][-1]*(q)+max(A[i][:r+1]))

	print(ans)















if __name__ == "__main__":
	main()


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

using namespace std;

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

typedef long long ll;

int main()
{
	int n;
	string s;
	bool a[200010];
	cin >> n;
	cin >> s;
	rep(i, n)
	{
		if(s[i]=='.') a[i]=true;
		else a[i]=false;
	}
	int b[200010]={}, w[200010]={};
	rep(i, n)
	{
		b[i+1]=b[i];
		w[i+1]=w[i];
		if(a[i]) w[i+1]++;
		else b[i+1]++;
	}
	int ans=n;
	rep(i, n+1)
	{
		ans=min(ans, b[i]+(w[n]-w[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2308
import java.util.Scanner;

public class Main {

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

		int n = in.nextInt();
		int d = in.nextInt();

		int[][] x = new int[n][d];
		for ( int i = 0; i < n; i++ ) {
			for ( int j = 0; j < d; j++ ) {
				x[i][j] = in.nextInt();
				// System.out.println(x[i][j]);
			}
		}

		int cnt = 0;
		// i行目とj行目の比較
		for ( int i = 0; i < n; i++ ) {
			for ( int j = i + 1; j < n; j++ ) {

				int sanonijou = 0;
				for ( int k = 0; k < d; k++ ) {
					sanonijou += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
				}
				double rt = Math.sqrt(sanonijou);
				
				if(rt - (int)rt == 0) {
					cnt++;
				}
			}
		}

		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 21972
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint(), K = getint();
	int H[200000];
	rep(i, N) H[i] = getint();
	pakuri_sort(N, H);

	int kaisuu = max(0, N - K);

	ll kotae = 0;
	rep(i, kaisuu) kotae += H[i];

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
// input macro end
// https://atcoder.jp/contests/abc133/tasks/abc133_b
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
// input macro end

fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[i64;d];n],
    }

    let mut cnt = 0u64;
    for i in 0..n - 1 {
        for j in i + 1..n {
            let mut t = 0;
            for k in 0..d {
                t += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            let f = t as f64;
            if f.sqrt() == f.sqrt() as i64 as f64 {
                cnt += 1;
            }
        }
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
int hantei (vector<int> light,int N){
  int ans=0;
  rep(i,N){
    if(light[i]==N)ans++;
  }
  if(ans==N)return 1;
  return 0;
}
int main (){
  vector<int>A(5);
  rep(i,5){
    int x;
    cin>>x;
    if(x==0){
      cout<<i+1;
    }
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=500005;
const ll p=998244353ll;
ll fa[N],ia[N];
inline ll expo(ll a,int b=998244351){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%p;
		b>>=1; a=a*a%p;
	}
	return c;
}
int main(){
	int n,m,i;ll ans=0ll,tmp;
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	fa[0]=1ll;
	rep(i,1,m)fa[i  ]=fa[i-1]*i%p;
	ia[m]=expo(fa[m]);
	per(i,m,1)ia[i-1]=ia[i  ]*i%p;
	rep(i,0,n){
		tmp=ia[i];
		tmp=tmp*(fa[n]*ia[n-i]%p)%p;
		tmp=tmp*(fa[m]*ia[m-i]%p)%p;
		tmp=tmp*(expo(m+1,n-i)*expo(n+1,m-i)%p)%p;
		if(i&1)ans-=tmp;else ans+=tmp;
	}
	printf("%lld",(ans+p*p)%p);
	return 0;
}

Measured memory_bytes: 8064
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

int main(){
  char route[256][2];
  memset(route,0,sizeof(route));

  route['A'][0] = 'X';
  route['A'][1] = 'Y';

  route['X'][1] = 'Z';

  route['Y'][0] = 'X';

  route['Z'][0] = 'W';
  route['Z'][1] = 'B';

  route['W'][0] = 'B';
  route['W'][1] = 'Y';

  route['B'][0] = 'Y';  
  route['B'][1] = 'X';

  string str;
  while(cin >> str){
    if(str == "#") break;

    char current = 'A';
    for(int i=0;i<str.size();i++){
      current = route[current][str[i]-'0'];
    }
    if(current == 'B'){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1184
using System;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();

        // 一辺取って片方がサイズiの木
        // 残りはサイズN-iの木
        // 絶対にサイズ1は作れなきゃいけない
        // 絶対にサイズNは作れない
        int n = s.Length;
        var flag = new bool[n + 1];
        for (int i = 0; i < n; i++)
        {
            flag[i + 1] = s[i] == '1';
        }

        var sb = new StringBuilder();
        int c = 1;
        if (!flag[1])
        {
            Console.WriteLine(-1);
            return;
        }

        if (flag[n])
        {
            Console.WriteLine(-1);
            return;
        }

        for (int i = 1; i < n; i++)
        {
            if (flag[i] != flag[n - i])
            {
                Console.WriteLine(-1);
                return;
            }

            sb.AppendLine($"{c} {i + 1}");
            if (flag[i])
            {
                c = i + 1;
            }
        }

        Console.Write(sb.ToString());
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef long long ll;

int A[200010];
int B[200010];

int main() {
  int N; cin >> N;
  for ( int i = 1; i <= N; i++ ) {
    cin >> A[i];
    B[i] = A[i] - i;
  }

  sort(B+1,B+N+1);
  //for ( int i = 1; i <= N; i++ ) {
  //   cout << B[i] << " ";
  //}
  // cout << endl;
  int b;
  if ( N % 2 == 1 ) {
  b = B[N/2+1];
  } else {
    b = (B[N/2]+B[N/2+1]) /2;
  }
  ll ans = 0;
  for ( int i = 1; i <= N; i++ ) {
    ans += abs(B[i]-b);
  }
  cout << ans << endl;
  return 0;
}


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

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

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

#define INF 1e18
#define mod 1000000007

ll N;
vector<ll> X,Y,M;
ll res[20],dmin[(1<<16)];

ll calcd(const vector<ll>& st, bool dir, ll z){
  ll dsum=0;
  rep(i,st.size()){
    if(!dir){ // x
      dsum+=(ll)abs(z-Y[st[i]])*M[st[i]];
    }else{ // y
      dsum+=(ll)abs(z-X[st[i]])*M[st[i]];
    }
  }
  return dsum;
}

ll calcx(const vector<ll>& st){
  ll sz=st.size();
  ll mmid=0,msum=0;
  rep(i,sz)mmid+=M[st[i]];
  mmid/=2;

  vector<ll> ord(sz);
  rep(i,sz)ord[i]=i;
  sort(all(ord),[&](const ll& a,const ll& b){
    return X[st[a]] < X[st[b]];
  });

  rep(i,sz){
    msum+=M[st[ord[i]]];
    if(msum>=mmid){
      return X[st[ord[i]]];
    }
  }
  assert(false);
  return -1;
}

ll calcy(const vector<ll>& st){
  ll sz=st.size();
  ll mmid=0,msum=0;
  rep(i,sz)mmid+=M[st[i]];
  mmid/=2;

  vector<ll> ord(sz);
  rep(i,sz)ord[i]=i;
  sort(all(ord),[&](const ll& a,const ll& b){
    return Y[st[a]] < Y[st[b]];
  });

  rep(i,sz){
    msum+=M[st[ord[i]]];
    if(msum>=mmid){
      return Y[st[ord[i]]];
    }
  }
  assert(false);
  return -1;
}

int main(){
  cin>>N;
  X.resize(N),Y.resize(N),M.resize(N);
  rep(i,N)cin>>X[i]>>Y[i]>>M[i];

  rep(i,N+1)res[i]=INF;

  vector<vector<ll>> dp(1<<N,vector<ll>(N+1,INF));
  dp[0][0]=0;
  repl(S,1,1<<N){
    vector<ll> ids;
    rep(i,N){
      if((S>>i)&1){
        ids.push_back(i);
      }
    }
    ll cx=calcx(ids);
    ll cy=calcy(ids);
    dp[S][1]=min(calcd(ids,true,cx),calcd(ids,false,cy));
    dp[S][0]=min(calcd(ids,true,0),calcd(ids,false,0));
  }

  rep(S,1<<N){
    ll bsz=bcnt(S);
    for(ll T1=S-1;T1>0;T1--){
      T1&=S;
      ll T2=(S^T1);

      rep(i,bsz+1)rep(j,i+1)minch(dp[S][i],dp[T1][j]+dp[T2][i-j]);
    }
  }
  repl(i,1,N+1)minch(dp[(1<<N)-1][i],dp[(1<<N)-1][i-1]);

  rep(i,N+1)cout<<dp[(1<<N)-1][i]<<endl;

  return 0;
}


Measured memory_bytes: 8488
#include<bits/stdc++.h>
using namespace std;
int n,m;
string st[110];
int main()
{
	cin>>n>>m;
	for(int i=1; i<=n ;i++)
	cin>>st[i];
	sort(st+1,st+1+n);
	for(int i=1; i<=n; i++)
	cout<<st[i];
	cout<<endl;
	return 0;
}

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

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int A, B, C;

int main(void) {
    scanf("%d %d %d", &A, &B, &C);


    if (A+B>=C) Yes;
    else No;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    string a="ABC",b="ARC";
    string s;
    cin>>s;
    if(s==a){cout<<b;}
    else{cout<<a;}

    return (0);
}


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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

using namespace std;

int main(){
    int n,m;cin >> n >> m;
    priority_queue<int> a;

    REP(i,n){
        int b;cin >>b;
        a.push(b);
    }

    REP(i,m){
        int b = a.top();
        a.pop();
        a.push(b/2);
    }

    long long  ans = 0;
    REP(i,n){
        ans += a.top();
        a.pop();
    }

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

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vi used;
int n,m,out;
vvi G;
void dfs(int a,int b){
	if(b==n-1){
		out++;
		return;
	}
	rep(i,G[a].size())if(used[G[a][i]]==0){
		int to=G[a][i];
		used[to]=true;
		dfs(to,b+1);
		used[to]=false;
	}
}
int main(){
	cin>>n>>m;
	G=vvi(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	used=vi(n);
	used[0]=true;
	dfs(0,0);
	cout<<out<<endl;
}











Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//ティツゥツ陛、ツセツ。テゥツ鳴「テヲツ閉ーテッツシツ暗」ツ??」ツ?セテ」ツ?ッMINテッツシツ?
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//テヲツ個ソテ・ツ?・テゥツ鳴「テヲツ閉ー
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//テ・ツ渉姪」ツつ甘・ツ?コテ」ツ?凖ゥツ鳴「テヲツ閉ー
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,a[100010],b[100010],t;
  while(scanf("%d %d",&n,&m),n){
    R=C=1;
    int d[100010]={0,1};
    while(m--){
      scanf("%d %d %d",&t,&a[R],&b[R]);
      hin(t);
    }
    while(C-1){
      t=hout();//printf("%d %d %d\n",d[a[t]],d[b[t]],d[a[t]]|d[b[t]]);
      d[b[t]]|=d[a[t]];
    }
    for(m=t=0;m<n;m++)t+=d[m+1];
    printf("%d\n",t);
  }
  return 0;
}

Measured memory_bytes: 3288
using System;

namespace ALDS111A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] ans = new int[n, n];
            string outs;
            for (int i = 0; i < n; ++i) 
            {
                for (int j = 0; j < n; ++j) 
                    ans[i, j] = 0;

                string s = Console.ReadLine();
                string[] nums = s.Split(' ');
                int k = int.Parse(nums[1]);
                for (int v = 0; v < k; ++v) 
                {
                    ans[i, int.Parse(nums[v + 2]) - 1] = 1;
                }
            }
            for (int i = 0; i < n; ++i) 
            {
                outs = ans[i, 0].ToString();
                for (int j = 1; j < n; ++j)
                {
                    outs += " " + ans[i, j].ToString();
                }
                Console.WriteLine(outs);
            }
        }
    }
}

Measured memory_bytes: 6160
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll N;
ll bit[1000010];

void bit_init(vector<ll> v){
	if(!v.empty()){
		N=v.size();
		for(ll x=1; x <= N; ++x) bit[x] = v[x];
		for(ll x=1; x < N; ++x) bit[x+(x&-x)] += bit[x];
	}
}
void bit_add(ll a, ll w){
		for(ll x=a; x <= N; x+=x&-x)bit[x]+=w;
}
ll bit_sum(ll a){
	ll ret=0;
	for(ll x=a;x>0;x-=x&-x) ret+=bit[x];
	return ret;
}


int main(){
	ll n;cin>>n;
	vector<ll> a(n+1);

	rep(i,n){
	  cin>>a[i+1];
	}
	bit_init(a);

	ll index1=1,index2=2,b,c,d,e,max_num,min_num,ans=1e10;
	FOR(i,2,n-1){
		b=bit_sum(i)-bit_sum(index1);
		c=bit_sum(index1);
		while(abs(bit_sum(i)-2*bit_sum(index1+1))<abs(bit_sum(i)-2*bit_sum(index1))){
			index1++;
			b=bit_sum(i)-bit_sum(index1);
			c=bit_sum(index1);
		}

		d=bit_sum(n)-bit_sum(index2);
		e=bit_sum(index2)-bit_sum(i);
		while(abs(bit_sum(n)-2*bit_sum(index2+1)+bit_sum(i))<abs(bit_sum(n)-2*bit_sum(index2)+bit_sum(i))){
			index2++;
			d=bit_sum(n)-bit_sum(index2);
			e=bit_sum(index2)-bit_sum(i);
		}
		max_num=max(b,max(c,max(d,e)));
	  min_num=min(b,min(c,min(d,e)));
	  ans=min(ans,max_num-min_num);
	}
  cout<<ans<<endl;
}

Measured memory_bytes: 7040
#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;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const ll MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int>graph[MAX];
ll n,parent[MAX];
bool vis[MAX];
ll dfs(ll src)
{
    vis[src]=1;
    ll res=0;
    if(parent[src]<src)
        res=(src-parent[src])*(n-src+1);
    else
        res=src*(parent[src]-src);
    for(int i=0; i<graph[src].size(); i++)
    {
        int child=graph[src][i];
        if(!vis[child])
        {
            parent[child]=src;
            res+=dfs(child);
        }
    }
    return res;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=1; i<n; i++)
    {
        ll u,v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    cout<<dfs(1)<<endl;

    return 0;
}


Measured memory_bytes: 47600
#include<cstdio>
#include<cctype>
using namespace std;

int main(){

    char ch;

    while(1){
        
        scanf("%c",&ch);
        if(isalpha(ch)){
            if(islower(ch))printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
        }else printf("%c",ch);


        if(ch == '\n')break;
    }
   
    return 0;


}


Measured memory_bytes: 2688
#include<iostream>
#include<cstdlib>
main(){for(int n,a[20],S,s,m,i,j,t;std::cin>>n,n;printf("%d\n",m)){for(i=S=0;i<n;S+=a[i++])std::cin>>a[i];m=1<<30;for(i=(1<<n);i-->0;t=abs(S-s-s),m>t&&(m=t))for(j=s=0;j<n;j++)if(i&1<<j)s+=a[j];}}

Measured memory_bytes: 872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var sb = new StringBuilder();
        for(int i = 0; i < n[1] + 2; i++)
        {
            sb.Append('#');
        }
        sb.Append("\r\n");
        for(int i = 0; i < n[0]; i++)
        {
            sb.Append('#');
            sb.Append(ReadLine());
            sb.Append('#');
            sb.Append("\r\n");
        }
        for(int i = 0; i < n[1] + 2; i++)
        {
            sb.Append('#');
        }
        WriteLine(sb.ToString());
    }
}


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

using namespace std;

typedef struct {
    int x;
    int y;
} point;

int main() {
    int H, W, D;
    cin >> H >> W >> D;

    point a[H*W+1];
    for (int x = 0; x < H; x++) {
        for (int y = 0; y < W; y++) {
            int A;
            cin >> A;
            a[A].x = x;
            a[A].y = y;
        }
    }

    long long int cost[H*W+1];
    for(int i = 1; i <= D; i++) {
        long long int ans = 0;
        point p = a[i];
        for(int j = i; j <= H*W; j+=D) {
            point q = a[j];
            ans += abs(p.x-q.x) + abs(p.y-q.y);
            cost[j] = ans;
            p = q;
        }
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        cout << (cost[R] - cost[L]) << endl;
    }

    return 0;
}

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

a_s = ""
for i in range(b):
    a_s = a_s + str(a)

b_s = ""
for i in range(a):
    b_s = b_s + str(b)

tmp = [a_s,b_s]
ans = sorted(tmp)[0]

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  std::vector<std::string> A(N);

  for (auto& s : A)
    std::cin >> s;

  long long C = 0;

  for (int k = 0; k < N; k ++) {
    for (int i = 0; i < N; i ++)
      for (int j = i + 1; j < N; j ++)
        if (A[(i + k) % N][j] != A[(j + k) % N][i])
          goto endloop;

    C += N;
      
  endloop: ;
  }
  
  std::cout << C << std::endl;

  return 0;
}


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

int main() {
  int c=0,f=0,a;
  string n;
  cin >> n;
  vector<char> b(n.size());
  for(int i = 0; i < (int)n.size(); ++i){
    b.at(i) = n[i];
  }
  int i=0;
  
  while(i < (int)n.size()){
    c += (int)b.at(i) - 48;
    c = c % 9 ;
    i++;
  }
  if(c % 9 == 0) cout << "Yes" ;
  else cout << "No" ;


}


Measured memory_bytes: 3860
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0510 : Score **/
int main()
{
	int A=0, B=0;
	rep(i, 4) {
		int a;
		cin>>a;
		A+=a;
	}
	rep(i, 4) {
		int a;
		cin>>a;
		B+=a;
	}
	cout << max(A, B) << endl;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int n;
double x=1,y,a[105];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		x*=a[i];
	}
	for(int i=1;i<=n;i++) y+=x/a[i];
	cout<<x/y<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

flag = 0
cnt = 0
for i in s:
    if i == "A" and (flag == 0 or flag == 1):
        flag = 1
    
    elif i == "B" and flag == 1:
        flag = 2
    
    elif i == "C" and flag == 2:
        cnt += 1
        flag = 0
    
    else:
        flag = 0

print(cnt)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, q;
  cin >> n >> q;
  vector<list<ll>> st(n);

  REP(i,q){
    ll com;
    cin >> com;
    if(com == 0){
      ll t, x;
      cin >> t >> x;
      st[t].push_back(x);
    }
    else if(com == 1){
      ll t;
      cin >> t;
      IREP(j,st[t]){
        if(j != st[t].begin()) cout << " ";
        cout << (*j);
      }
      cout <<endl;
    }
    else{
      ll s, t;
      cin >> s >> t;
      st[t].splice(st[t].end(),move(st[s]));
    }
  }
    
  return 0;
}




Measured memory_bytes: 18784
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    println!(
        "{}{}{}",
        s.chars().nth(0).unwrap().to_string(),
        (s.len() - 2).to_string(),
        s.chars().nth(s.len() - 1).unwrap().to_string()
    );
}


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

std::vector<std::vector<int>> hen;
std::vector<int> parent,depth;


void dfs(int i,int prev){
	parent[i] = prev;
	for(auto j : hen[i]){
		if(j == prev)continue;
		depth[j] = depth[i] + 1;
		dfs(j,i);
	}
}


int main()
{
	int n,u,v;
	std::cin >> n >> u >> v;
	u--;v--;
	hen.resize(n);
	for(int i = 0; i < n -1 ;i++){
		int a,b;
		std::cin >> a >> b;
		a--; b--;
		hen[a].push_back(b);
		hen[b].push_back(a);
	}
	if(hen[v].size() == 1 && hen[v][0] == u){
		std::cout << 0 << std::endl;
		return 0;
	}
	parent.resize(n);
	depth.resize(n);
	dfs(v,-1);
	int dist = depth[u];
	int d2 = std::max(0, (dist - 1) / 2);
	int t = u;
	for(int i = 0 ; i < d2; i++)t = parent[t];
	int tmp = parent[t];
	parent.assign(n,-1);
	depth.assign(n,0);
	dfs(t,tmp);
	std::cout << (!(dist & 1)) + d2 + *std::max_element(depth.begin(),depth.end()) << std::endl;
	return 0;

}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;

int main(){
  
  int a; int b; int x;
  cin >> a >> b >> x;
  cout << fixed << setprecision(15);
  if(2*x >= a*a*b){
    cout << atan2((2*a*a*b-2*x),a*a*a)/PI*180 << endl;
  }else{
    cout << atan2(a*b*b,2*x)/PI*180 << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;



int main()
{
    int n;
    string s;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        if(s=="WA")
            wa++;
        if(s=="TLE")
            tle++;
        if(s=="RE")
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
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<ll> MARCH(5);
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='M')MARCH[0]++;
        if(s[0]=='A')MARCH[1]++;
        if(s[0]=='R')MARCH[2]++;
        if(s[0]=='C')MARCH[3]++;
        if(s[0]=='H')MARCH[4]++;
    }

    ll ans=0;
    for(int i=0;i<=2;i++){
        for(int j=i+1;j<=3;j++){
            for(int k=j+1;k<=4;k++){
                ans+=MARCH[i]*MARCH[j]*MARCH[k];
            }
        }
    }

    cout<<ans<<endl;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> c(25);
	c[0] = 1;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		c[x]++;
	}
	c[24] = c[0];
	int p = 0;
	for(int i = 1; i <= 11; i++){
		if(c[i] >= 1){
			c[24 - i] = (c[i] + 1 - p) / 2;
			c[i] = (c[i] + p) / 2;
			p = 1 - p;
		}
	}
	int t = 1, ans = 24;
	for(int i = 1; i <= 24; i++){
		if(c[i] >= 2){
			ans = 0;
			break;
		}else if(c[i] == 1){
			ans = min(ans, t);
			t = 1;
		}else{
			t++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func maxt(a ...int) int {
	t := a[0]
	for _, x := range a {
		t = max(t, x)
	}
	return t
}

const nax = 303

func main() {
	ans := 0
	n := ReadInt()
	cnt := make([]int, 4)
	for i := 0; i < n; i++ {
		a := ReadInt()
		ans += a
		cnt[a]++;
	}
	var dp, pr [nax][nax][nax]float64
	pr[cnt[1]][cnt[2]][cnt[3]] = 1
	for threes := n; threes >= 0; threes-- {
		for twos := n; twos >= 0; twos-- {
			for ones := n; ones >= 0; ones-- {
				if threes + twos + ones > n {
					continue
				}
				if threes == 0 && twos == 0 && ones == 0 {
					continue
				}
				var p, ps float64
				p = float64(n - (threes + twos + ones)) / float64(n)
				ps = p / (1 - p)
				dp[ones][twos][threes] += ps * pr[ones][twos][threes]
				if threes > 0 {
					p = float64(threes) / float64(threes + twos + ones)
					dp[ones][twos + 1][threes - 1] += dp[ones][twos][threes] * p
					pr[ones][twos + 1][threes - 1] +=  pr[ones][twos][threes] * p
					// fmt.Println(pr[ones][twos + 1][threes - 1])
				}

				if twos > 0 {
					p = float64(twos) / float64(threes + twos + ones)
					dp[ones + 1][twos - 1][threes] += dp[ones][twos][threes] * p
					pr[ones + 1][twos - 1][threes] +=  pr[ones][twos][threes] * p
					// fmt.Println(pr[ones + 1][twos - 1][threes])
				}

				if ones > 0 {
					p = float64(ones) / float64(threes + twos + ones)
					dp[ones - 1][twos][threes] += dp[ones][twos][threes] * p
					pr[ones - 1][twos][threes] +=  pr[ones][twos][threes] * p
					// fmt.Println(pr[ones - 1][twos][threes])
				}
				// fmt.Println(ones, twos, threes)
			}
		}
	}
	// fmt.Println(dp[0][0][0])
	fmt.Println(float64(ans) + dp[0][0][0])
}


var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)
 
	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)
 
	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()
 
		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

Measured memory_bytes: 447232
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;
	long int x[100000];
	//long int y[100000];
	long int b = 10000000000;
	cin >> N;
	bool flag = false;
	int a,ans = 0;
	for (int i = 0; i <= N;i++) {
		cin >> x[i];
	}
	sort(x, x + N+1);
	/*for (int i = 0; i <= N; i++) {
		cout << x[i] << endl;
	}*/
	//std::vector<long int> y(100000,1000000000);
	for (int i = 0; i < N; i++) {
		if (b >( x[i + 1] - x[i])) {
			b = (x[i + 1] - x[i]);
		}
		//y[i] = x[i + i] - x[i];
	}
	//sort(y, y + 100000 - 1);
	//a = x[1] - x[0];
	a = b;
	//cout << a << endl;
	if (N == 1) {
		cout << a << endl;
		return 0;
	}
	for (int j = a; j >= 1; j--) {
		flag = true;
		for (int k = 0; k < N; k++) {
			if ((x[k + 1] - x[k])%j !=0) {
				flag = false;
			}
		}
		if (flag) {
			ans = j;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int ask(int u, int v) {
    cout << "? " << u << " " << v << endl;
    int d;
    cin >> d;
    return d;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s, t;
    cin >> n >> s >> t;
    vector<int> d(n + 1);
    vector<P> v;
    for (int i = 1; i <= n; i++) {
        if (i != s) {
            d[i] = ask(s, i);
            v.push_back(P(d[i], i));
        }
    }
    sort(all(v));
    int b = s;
    vector<int> res;
    res.push_back(s);
    for (int i = 0; i < n - 1; i++) {
        int k = v[i].second;
        int dt = (k == t ? 0 : ask(k, t));
        int db = (b == s ? d[k] : ask(b, k));
        if (d[b] + db == d[k] && d[k] + dt == d[t]) {
            b = k;
            res.push_back(k);
        }
        if (b == t) {
            break;
        }
    }
    cout << "! ";
    cout << res;
}



Measured memory_bytes: 4660
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (c - (a - b) < 0 ? 0 : c - (a - b)) << '\n';

  return;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	int p,q,a,n, ans;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			p = sc.nextInt();
			q = sc.nextInt();
			a = sc.nextInt();
			n = sc.nextInt();
			if((p|q|a|n) == 0) break;
			ans = 0;
			dfs(0,0,1,1, 1);
			System.out.println(ans);
		}
	}
	
	private void dfs(int deep, int aa, int bb, int mul,int  prev) {
		if(p * bb == q * aa){
			ans++;
			return ;
		}
		if(deep == n) return;
		if(p * bb < q * aa)return;
		
		for(int i = prev; i * mul <= a; i++){
			dfs(deep + 1, bb * 1 + aa * i, bb * i, i * mul, i);
		}
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

int main() {
    
    while (true) {
        int h, w;
        cin >> h >> w;
        if(h==0 and w == 0){
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }

}


Measured memory_bytes: 3080