akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T;
	cin >> N >> T;
	vector<pii> C;
	int dp[6010][3010] = { 0 };
	//int dp[1000][1000] = { 0 };
	//int dp[6010] = { 0 };
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		C.push_back(pii(a, b));
	}
	SORT(C);

	/*eREP(i, 6010) {
		int tmp=-1;
		REP(j, N) {
			int t = C[j].first, v = C[j].second;
			if (!F[j])continue;
			if (i - t >= 0&&i-t<=T) {
				if (dp[i] < dp[i - t] + v) {
					cout << i << " " << j << endl;
					cout << dp[i] << endl;
					tmp = j;
					dp[i] = max(dp[i], dp[i - t] + v);
				}
				//dp[i] = max(dp[i], dp[i - t] + v);
				//cout << i << " " << j << endl;
				//cout << dp[i] << endl;
				if (tmp != -1)F[tmp] = false;
			}
			else {
				if (i - 1 >= 0)dp[i] = max(dp[i],dp[i-1]);
			}
		}
	}
	*/

	eREP(i, 6008) {
		REP(j, N) {
			int t = C[j].first, v = C[j].second;
			if (i - t >= 0&&i-t<T) {
				dp[i][j+1] = max(dp[i][j+1], dp[i - t][j]+v);
				//cout << i << " " << j << endl;
				//cout << dp[i][j+1] << endl;
			}

			if(i-1>=0)dp[i][j+1] = max(dp[i][j+1],dp[i-1][j+1]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
		}
	}
	//REP(i, 11) {
		//cout << i<<" "<<dp[i][1] << " " << dp[i][2] << endl;
		//\cout << i<<" "<<dp[i] << endl;
	//}
	cout << dp[6008][N] << endl;
	return 0;
}



Measured memory_bytes: 141696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> ans;
  int sum = 0;
  rep2(i, 1, n+1){
    sum += i;
    ans.push_back(i);
    if(sum >= n) break;
  }
  int d = sum - n;
  rrep(i, ans.size()){
    if(ans.at(i) != d){
      cout << ans.at(i) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3676
s = input()
n = len(s)

def dfs(i, now, depth):
    ans = 0
    if depth == n - 1:
        elements = map(int, now.split('+'))
        return sum(elements)
    else:
        ans += dfs(i + 1, now, depth + 1)
        now = now[:i] + '+' + now[i:]
        ans += dfs(i + 2, now, depth + 1)
    return ans
print(dfs(1, s, 0))


Measured memory_bytes: 38768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		List<Integer> A1 = new ArrayList<Integer>();
		List<Integer> A2 = new ArrayList<Integer>();

		String[] inp = br.readLine().split(" ");
		String[] inp2 = br.readLine().split(" ");

		int sum = 0,sum1 = 0;
		for (int i = 0;i<inp.length;i++){
			sum += Integer.parseInt(inp[i]);
			sum1 += Integer.parseInt(inp2[i]);
			A1.add(sum);
			A2.add(sum1);
		}

		int maxCandy = A1.get(0) + A2.get(N-1);

		for(int i = 1;i<N;i++){
			int now = A1.get(i) + (A2.get(N-1) - A2.get(i-1));
			maxCandy = Math.max(now, maxCandy);
		}

		System.out.println(maxCandy);


	}
}

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

_n = int(input())


def chker(n):
    nontax1 = int(n / 1.08)
    nontax2 = nontax1 + 1

    if int(1.08 * nontax1) == n:
        print(nontax1)
    elif int(1.08 * nontax2) == n:
        print(nontax2)
    else:
        print(':(')


chker(_n)


Measured memory_bytes: 2940
n = int(input())
ans = 0
for i in range(1, n+1):
    count = 0
    if i % 2 == 0:
        continue
    for j in range(1, i+1):
        if i % j == 0:
            count += 1
    if count == 8:
        ans += 1
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	LL sum = 0;
	for (LL n = 1; n <= N; n++) {
		if (n % 3 != 0 && n % 5 != 0)sum += n;
	}
	cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
int main(void)
{
	int a,b;
	char c;
	while(1){
		scanf("%d %c %d", &a, &c, &b);
		if( c=='?')break;	
		else if( c=='-'){
			printf("%d\n",a-b);
		}else if( c=='*'){
			printf("%d\n",a*b);
		}else if( c=='/'){
			printf("%d\n",a/b);
		}else if( c=='+'){
			printf("%d\n",a+b);
		}
	}
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

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

  ll n; cin >> n;

  vll cnt(n+1);

  FOR(x, 1, n+1) {
    if(x * x > n) break;
    FOR(y, 1, n+1) {
      if(x * x + y * y > n) break;
      FOR(z, 1, n + 1) {
        if(x * x + y * y + z * z > n) break;
        ll idx = x * x + y * y + z * z + x * y + y * z + z * x;
        if(idx <= n) {
          cnt[idx]++;
        }
      }
    }
  }

  FOR(i, 1, n+1) {
    cout << cnt[i] << endl;
  }

}








Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main()
{
    int a;
    char s[11];
    scanf("%d",&a);
    scanf("%s",s);
    if(a<3200)
    {
        printf("red");
    }
    else
    {
        printf("%s",s);
    }
    return 0;
}

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

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second


int main() {
	string s;

	cin >> s;


	set<string> se = { "abc","acb","bca","bac","cab","cba" };

	cout << (se.count(s) ? "Yes" : "No") << endl;
	


}

Measured memory_bytes: 256
n,C = map(int,input().split())
imos = [0]*(10**5+2)
ch = [set() for _ in range(C)]
for i in range(n):
    s,t,c = map(int,input().split())
    c -= 1
    if s in ch[c]:
        ch[c].remove(s)
        imos[s+1] +=1
    else:
        ch[c].add(s)
        imos[s] += 1
    if t in ch[c]:
        ch[c].remove(t)
        imos[t] -= 1
    else:
        ch[c].add(t)
        imos[t+1] -= 1
ans = 0
cnt = 0
for i in imos:
    cnt += i
    ans = max(ans,cnt)
print(ans)


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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cerr << "[" << #x << " " << x << "]\n";
// #define int ll

ll power(ll x, ll y) {
     ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*================================================================*/




void solve() {
    ll n;
    cin >> n;
    ll a = n/3, b = n/5, c = n/15;
    deb(a);deb(b);deb(c);
    cout << (n*(n+1))/2 + (15*(c*(c+1)))/2 - (3*(a*(a+1)))/2 - (5*(b*(b+1)))/2;
}

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


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

typedef struct
{
  int v, w;
} Island;

class LessWeight
{
public:
  bool operator() (const Island& lhs, const Island& rhs) const
  {
    if (lhs.w == rhs.w)
      return lhs.v < rhs.v;
    return lhs.w < rhs.w;
  }
};

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

    vector<Island> is(n);
    for (int i = 0; i < n; ++i)
      cin >> is[i].v >> is[i].w;
    sort(is.begin(), is.end(), LessWeight());

    int weight = 0;
    bool yes = true;
    for (int i = 0; i < n && yes; ++i) {
      weight += is[i].v;
      if (weight > is[i].w)
	yes = false;
    }

    if (yes)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

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

int main()
{
  string s;
  int n;
  cin >> n >> s;
  if (n == 1 || n % 2){
    cout << "No" << endl;
    return 0;
  }
  rep(i,n/2){
    if(s[i] != s[n/2 + i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

//蟻本のコード

vector<ll> par(200001);	//要素の親
vector<ll> rnk(200001); //木の高さ(併合時に使う)
vector<ll> cnt(200001);	//ノードの数

ll find(ll x) {			//親ノードを求める
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);	//辺の縮約(rnkは高速化のため変えない)
	}
}

void unite(ll x , ll y) {	//ノードを併合
	x = find(x);
	y = find(y);
	if (x == y) return;
	else if (rnk[x] < rnk[y]) {
		par[x] = y;
		cnt[y] += cnt[x];
	} else {
		par[y] = x;
		cnt[x] += cnt[y];
		if (rnk[x] == rnk[y]) rnk[x]++;
	}
}

ll usize(ll x) {			//xが属するノードのサイズを求める
	return cnt[find(x)];
}

bool same(ll x, ll y) {		//xとyが同じノードか判定する
	return find(x) == find(y);
}

int main() {
	ll		i,j,m,n;

	cin >> n >> m;
	vector<ll> a(m),b(m),ans(m+1);

	//初期化
	for(i=1;i<=n;i++) {
		par[i] = i;
		rnk[i] = 0;
		cnt[i] = 1;
	}

	for(i=0;i<m;i++) {
		cin >> a[i] >> b[i];
	}

	ans[m] = n*(n-1)/2;
	for(i=m-1;i>0;i--) {
		ll t = usize(a[i]) * usize(b[i]);
		if (same(a[i],b[i])) t = 0;
		unite(a[i],b[i]);
		ans[i] = ans[i+1] - t;
	}

	for(i=1;i<=m;i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 10308
N = int(input())
X = []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    X.append((c, s, f))
for k in range(N):
    t = 0
    for i in range(k, N-1):
        c, s, f = X[i]
        t = -(-t//f) * f
        t = max(t, s)
        t += c
    print(t)

Measured memory_bytes: 3188
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <cstdio>
using namespace std;

const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°

//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
		int a = rand()%N;
		int b = rand()%N;
		swap(r[a],r[b]);
		double evaluate = Evaluate(r);
		if(evaluate <= mi){
			mi = evaluate;
		}else{
			if(Changes(cnt)){
				mi = evaluate;
			}else{
				swap(r[b],r[a]);
			}
		}

	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
	srand(time(NULL));
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

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

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

    int k, x;
    cin >> k >> x;
    for(int i = x - (k - 1); i <= x + (k - 1); i++){
        cout << i << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <vector>
#include <limits.h>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
#define FOR_M(i, s, e) for(int i = s; i >= e; --i)
typedef vector<long> vec;
void CountingSort(vec& vA, vec& vB, int k)
{
	vec vC(k + 1, 0);
	FOR(i, 0, vA.size()) 
		++vC[vA[i]];
	FOR(i, 1, k + 1) 
		vC[i] += vC[i - 1];
	FOR_M(i, vA.size() - 1, 0) 
		vB[--vC[vA[i]]] = vA[i];
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long n;
	cin >> n;
	vec vA(n, 0);
	vec vB(n, 0);
	long maxV = LONG_MIN;
	FOR(i, 0, n){
		cin >> vA[i];
		if (maxV < vA[i])
			maxV = vA[i];
	}
	CountingSort(vA, vB, maxV);

	FOR(i, 0, n){
		cout << vB[i];
		if (i < n - 1)
			cout << " ";
	}
	cout << "\n";	
	return 0;
}

Measured memory_bytes: 32476
#include <stdio.h>

int main()
{
    int n, i, j;
    long count[5] = {0, 0, 0, 0, 0};
    long ans=0, hal1=0, hal2=0;
    scanf("%d", &n);

    char s[11];
    for(i=0; i<n; i++)
    {
        scanf("%s", s);

        switch(s[0])
        {
            case 'M':
                count[0]++;
                break;
            case 'A':
                count[1]++;
                break;
            case 'R':
                count[2]++;
                break;
            case 'C':
                count[3]++;
                break;
            case 'H':
                count[4]++;
                break;
        }
    }
    hal1 = count[0] * count[1];
    hal2 = count[2] * count[3];

    ans = hal1 * count[2]
        + hal1 * count[3]
        + hal1 * count[4]
        + count[1] * hal2
        + count[1] * count[2] * count[4]
        + hal2 * count[4]
        + hal2 * count[0]
        + count[3] * count[4] * count[0]
        + count[3] * count[4] * count[1]
        + count[0] * count[2] * count[4];

    printf("%ld\n", ans);

    return 0;

}

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

int main() {
  int n; cin >> n;
  map<string, int> cnt;

  cnt["AC"] = 0;
  cnt["WA"] = 0;
  cnt["TLE"] = 0;
  cnt["RE"] = 0;
  
  rep(i, n) {
    string s; cin >> s;
    cnt[s]++;
  }

  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
}


Measured memory_bytes: 3636
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf

#define sf1(a)			scanf("%d",&a);
#define sf2(a,b)		scanf("%d%d",&a,&b);

#define ll				long long

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll int a,b;
	cin >> a >> b;
	cout << (a*b)/__gcd(a,b) << endl;
	return 0;
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N = int(input())
en = [[] for _ in range(N)]
on = [[] for _ in range(N)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    if w % 2:
        on[u - 1].append(v - 1)
        on[v - 1].append(u - 1)
    else:
        en[u - 1].append(v - 1)
        en[v - 1].append(u - 1)

color = [None] * N
stack = [(0, -1, 0)]
while stack:
    node, parent, col = stack.pop()
    if color[node] is not None:
        continue
    color[node] = col
    for k in en[node]:
        if k != parent:
            stack.append((k, node, col))
    for k in on[node]:
        if k != parent:
            stack.append((k, node, (col + 1) % 2))

print(*color, sep="\n")


Measured memory_bytes: 69136
import math

a, b, h, m = map(int, input().split())
a_r = math.tau * (h + m / 60) / 12
b_r = math.tau * m / 60

x_d = a * math.sin(a_r) - b * math.sin(b_r)
y_d = a * math.cos(a_r) - b * math.cos(b_r)
print(math.sqrt(x_d * x_d + y_d * y_d))


Measured memory_bytes: 9500
from collections import deque
n = int(input())
l = [-1]*n
dis = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    dis[a-1].append([b-1,c])
    dis[b-1].append([a-1,c])

q = deque([])
l[0] = 0
q.append((0,0))
while q:
    bef,di = q.popleft()
    for i,j in dis[bef]:
        if l[i] == -1:
            if (di+j)%2==0:
                l[i] = 0
            else:
                l[i] = 1
            q.append((i,(di+j)%2))
for i in l:
    print(i)

Measured memory_bytes: 45460
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X.sort()
if N >= M: print(0)
else:
    Xsub = [X[i+1] - X[i] for i in range(M-1)]
    Xsub.sort(reverse = True)
    total = 0
    for i in range(N-1):
        total += Xsub[i]
    print(X[M-1] - X[0] - total)


Measured memory_bytes: 13192
from math import ceil

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a = 1
b = 1
for x, y in TA:
    n = max(-(-a // x), -(-b // y))
    a = n * x
    b = n * y
print(a + b)

Measured memory_bytes: 3188
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
//#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
const ll mod=1000000007;
int findProductSum(int A[], int n) 
{ 
    // calculating array sum (a1 + a2  ... + an) 
    int array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = ((array_sum%mod) + (A[i]%mod))%mod; 
  
    // calcualting square of array sum 
    // (a1 + a2 + ... + an)^2 
    int array_sum_square = ((array_sum%mod) * (array_sum%mod))%mod; 
  
    // calcualting a1^2 + a2^2 + ... + an^2 
    int individual_square_sum = 0; 
    for (int i = 0; i < n; i++) 
        individual_square_sum = ((individual_square_sum)%mod + (A[i]*A[i])%mod)%mod; 
  
    // required sum is (array_sum_square - 
    // individual_square_sum) / 2 
    return ((array_sum_square%mod - individual_square_sum%mod + mod)%mod)/2; 
} 
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        rep(i,n)
        cin>>a[i];
        ll sum=0,sum1=0;
        for(int i=0;i<n;i++)
        {
            sum=((sum%mod)+(a[i]%mod))%mod;
            sum1=((sum1%mod) + ((a[i]%mod) *(a[i]%mod))%mod)%mod;
        }
        sum=((sum%mod)*(sum%mod))%mod;
        sum=((sum%mod)-(sum1%mod)+mod)%mod;
        sum=((sum)*(500000004))%mod;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4424
#include<iostream>
#include<cmath>
#include<complex>
#include<iomanip>
#include<cassert>

using namespace std;

typedef complex<double> point;
typedef pair<point,point> line;


bool makeable(int a, int b, int c){
  return a+b>c && b+c>a && c+a>b;
}

inline double my_pow(double a, double b){
  return pow(a, b);
}

double vofh(int a, int b, int c, int p, int q, int r)
{
  double s = -2.0 * my_pow(a, 2) * my_pow(b, 2) * my_pow(p, 2)+2 * my_pow(a, 2) * my_pow(c, 2) * my_pow(p, 2)+2 * my_pow(b, 2) * my_pow(c, 2) * my_pow(p, 2)-2 * my_pow(c, 4) * my_pow(p, 2)-2 * my_pow(c, 2) * my_pow(p, 4)+2 * my_pow(a, 2) * my_pow(b, 2) * my_pow(q, 2)-2 * my_pow(b, 4) * my_pow(q, 2)-2 * my_pow(a, 2) * my_pow(c, 2) * my_pow(q, 2)+2 * my_pow(b, 2) * my_pow(c, 2) * my_pow(q, 2)+2 * my_pow(b, 2) * my_pow(p, 2) * my_pow(q, 2)+2 * my_pow(c, 2) * my_pow(p, 2) * my_pow(q, 2)-2 * my_pow(b, 2) * my_pow(q, 4)-2 * my_pow(a, 4) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(b, 2) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(c, 2) * my_pow(r, 2)-2 * my_pow(b, 2) * my_pow(c, 2) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(p, 2) * my_pow(r, 2)+2 * my_pow(c, 2) * my_pow(p, 2) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(q, 2) * my_pow(r, 2)+2 * my_pow(b, 2) * my_pow(q, 2) * my_pow(r, 2)-2 * my_pow(p, 2) * my_pow(q, 2) * my_pow(r, 2)-2 * my_pow(a, 2) * my_pow(r, 4);
  return sqrt(s / 288);
}

const double pi = 2*acos(0.0);

int main()
{
  int N;
  while(cin>>N)
  {
    double res = 0;
    if( N == 0 ) break;
    int a[N];

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

    int comb = (1<<3) - 1;
    while(comb<(1<<N)){      
      int cnt = 0;
      int e[3];
      bool used[N];
      for(int b = 0; b < N; ++b){
        if( comb & (1<<b) ){
          // cout << 1;
          e[cnt++] = a[b];
          used[b] = true;
        }else{
          // cout << 0;
          used[b] = false;
        }
      }
      // cout << endl;
      assert(cnt==3);
      
      if( makeable( e[0], e[1], e[2] ) ){
        for(int i = 0; i < N; ++i){
          for(int j = i+1; j < N; ++j){
            if( !used[i] && !used[j] ){
              
              for(int k = 0; k < 3; ++k){
                int f0 = e[k];
                int f1 = e[(k+1)%3];
                int f2 = e[(k+2)%3];
                
                if( makeable(a[i], a[j], f0) ){
                  double f = f1;
                  double h = a[i];
                  
                  for(int l = 0; l < N; ++l){
                    if( l != i && l != j && !used[l] ){
                      int x = a[l];
                      double tcos = (x*x - f*f - h*h)/(2.*f*h);
                      double tsin = 1-tcos*tcos;
                      if( makeable(x,f1,a[i]) && tsin > 0 ){
                        res = max(res , vofh(a[i],a[j],a[l],f0,f1,f2));
                      }
                    }
                  }
                }
                

              }

            }
          }
        }
      }

      int x = comb & -comb;
      int y = comb + x;
      comb = ((comb & ~y) / x >> 1 ) | y;      
    }

    cout << fixed << setprecision(11) << res << endl;

    
  }
  return 0;
}

Measured memory_bytes: 964
from collections import deque

H, W = map(int, input().split())
cy, cx = map(int, input().split())
sy, sx = map(int, input().split())
tiles = [list(input()) for _ in range(H)]

# initialization
INF = 10**4
arrived = [[INF for _ in range(W)] for __ in range(H)]
paths = deque()
warps = deque()
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
moves = [-2, -1, 0, 1, 2]
arrived[cy-1][cx-1] = 0
paths.append([cx-1, cy-1])
count = 0

# BFS
while(len(paths) > 0):
  while(len(paths) > 0):
    nx, ny = paths.popleft()
    if ny == sy-1 and nx == sx-1:
      print(count)
      exit()
    for i in range(4):
      if 0 <= nx+dx[i] < W and 0 <= ny+dy[i] < H and arrived[ny+dy[i]][nx+dx[i]] > count and tiles[ny+dy[i]][nx+dx[i]] == '.':
        paths.append([nx+dx[i], ny+dy[i]])
        arrived[ny+dy[i]][nx+dx[i]] = count
    for x in moves:
      for y in moves:
        if 0 <= nx+x < W and 0 <= ny+y < H and arrived[ny+y][nx+x] == INF and tiles[ny+y][nx+x] == '.':
          warps.append([nx+x, ny+y])
  count += 1
  while(len(warps) > 0):
    nx, ny = warps.popleft()
    if arrived[ny][nx] == INF:
      arrived[ny][nx] = count
      paths.append([nx, ny])
print(-1)

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

int main() {
  int A, B;
  cin >> A >> B;
  if ((B - 1) % (A - 1) == 0) {
    cout << (B - 1) / (A - 1);
  }
  else {
    cout << (B - 1) / (A - 1) + 1;
  }
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define A_MAX 100000

vector<complex<double>> dft(vector<complex<double>> f, int n)
{
  if(n==1)return f;// value of f(1)=c_i
  else
  {
    vector<complex<double>> f0(n/2);
    vector<complex<double>> f1(n/2);
    int i;
    rep(i,n/2)
    {
      f0[i]=f[2*i];
      f1[i]=f[2*i+1];
    }
    f0 = dft(f0, n/2);
    f1 = dft(f1, n/2);
    complex<double> zeta = complex<double>(cos(2*M_PI/n), sin(2*M_PI/n));
    complex<double> pow_zeta = complex<double>(1.0, 0.0);
    rep(i,n)
    {
      f[i] = (f0[i%(n/2)] + pow_zeta * f1[i%(n/2)]);
      pow_zeta *= zeta;
    }
    return f;
  }
}

vector<complex<double>> inv_dft(vector<complex<double>> f, int n, int nf)
{
  if(n==1)return f;
  else
  {
    vector<complex<double>> f0(n/2);
    vector<complex<double>> f1(n/2);
    int i;
    rep(i,n/2)
    {
      f0[i]=f[2*i];
      f1[i]=f[2*i+1];
    }
    f0 = inv_dft(f0, n/2, nf);
    f1 = inv_dft(f1, n/2, nf);
    complex<double> zeta = complex<double>(cos(-2*M_PI/n), sin(-2*M_PI/n));
    complex<double> pow_zeta = complex<double>(1.0, 0.0);
    rep(i,n)
    {
      f[i] = (f0[i%(n/2)] + pow_zeta * f1[i%(n/2)]);
      pow_zeta *= zeta;
    }
    if(n==nf)
    {
      rep(i,n)f[i]/=n;
    }
    return f;
  }
}

int main()
{
  ll n,m;cin>>n>>m;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  vector<int> num(A_MAX+1,0);
  rep(i,n)num[a[i]]++;
  int n2 = 1;
  while(n2<=2*A_MAX)n2*=2;
  vector<complex<double>> gt(n2,(0.0,0.0));
  rep(i,A_MAX+1)gt[i]=complex<double>(num[i],0);
  gt = dft(gt, n2);
  vector<complex<double>> ght(n2,(0,0));
  rep(i,n2)ght[i]=gt[i]*gt[i];
  vector<complex<double>> ans(n2,0);
  ans = inv_dft(ght,n2,n2);
  vector<ll> pats(A_MAX*2+1);
  rep(i,A_MAX*2+1) pats[i]=(ll)round(ans[i].real())+0;
  ll count=0;
  ll total=0;
  ll now=A_MAX*2;
  while(count<m)
  {
    ll take=min(m-count,pats[now]);
    count+=take;
    total+=now*take;
    now--;
  }
  cout<<total<<endl;
}


Measured memory_bytes: 29764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vin maru;
    rep(i,n)if(s[i]=='o')maru.push_back(i+1);
    int m=maru.size();
    vin maximuml(m);//maru[i]の日に働くとしたとき最大で何回目の仕事になるか
    int l,r,mid;
    rep(i,m){
        l=-1;r=i;
        while(r-l>1){
            mid=(l+r)/2;
            if(maru[mid]+c<maru[i])l=mid;
            else r=mid;
        }
        if(l==-1)maximuml[i]=1;
        else maximuml[i]=maximuml[l]+1;
    }
    vin maximumr(m);//maru[i]の日に働くとしたときmaru[i]の日の仕事も含めてあと最大で何回働けるか
    for(int i=m-1;i>=0;i--){
        l=i;r=m;
        while(r-l>1){
            mid=(l+r)/2;
            if(maru[i]+c<maru[mid])r=mid;
            else l=mid;
        }
        if(r==m)maximumr[i]=1;
        else maximumr[i]=maximumr[r]+1;
    }
    vin maximum(m);//maru[i]の日に働くとしたとき次に働くことができる最も遅い日
    rep(i,m){
        if(maximuml[i]>=k){
            maximum[i]=inf;
            continue;
        }
        l=i;r=m;
        while(r-l>1){
            mid=(l+r)/2;
            if(maximuml[i]+maximumr[mid]>=k)l=mid;
            else r=mid;
        }
        if(maru[i]+c>=maru[l])maximum[i]=-inf;//maru[i]に働くことはできない
        else maximum[i]=l;
    }
    //各iに対してj<iなる任意のjに対してmaximum[j]<=iならばmaru[i]日目は必ず働かなければならない
    vin ans;int res;
    if(m==1||m>1&&maximumr[1]<k)ans.push_back(maru[0]);//i=0だけは別で考える
    rep(i,m){
        res=i-1;
        while(res>=0){
            if(maximum[res]!=-inf){
                if(maximum[res]<=i)ans.push_back(maru[i]);
                break;
            }
            res--;
        }
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
    //rep(i,m)cout<<maru[i]<<" "<<maximum[i]<<endl;
}

Measured memory_bytes: 8092
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  lll n;
  cin >> n;
  cout << 3*n*n << endl;
  return 0;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int now = 0;
  int count = 1;
  for(int i = 0; i < N; i++) {
    now += data.at(i);
    if(now <= X) {
      count++;
    }
  }
  cout << count << endl; 
}

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

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; }

using ll = long long;

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

ll pow(ll a, ll n) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a) {
		if (n % 2LL == 1LL) {
			ret = ret * a;
		}
	}
	return ret;
}

int main() {
  ll X;
  cin >> X;
  bool y = false;
  ll A = 0LL;
  ll ansa;
  ll ansb;
  while(!y){
    ll B = 0LL;
    ll a = pow(A,5LL);
    ll b = pow(B,5LL);
    while((a+pow(B,5LL)<=X)||(a-pow(B,5LL)>=X)){
      ll b = pow(B,5LL);
      if(a+b==X){
        y=true;
        ansa=A;
        ansb=-B;
        break;
      }
      if(a-b==X){
        y=true;
        ansa=A;
        ansb=B;
        break;
      }
      B++;
    }
    A++;
  }
  cout<<ansa<<" "<<ansb<<endl;
}
      

Measured memory_bytes: 3624
#include <string>
#include <vector>
#include <iostream>

using namespace std;

string put_nchar(int n, char c)
{
	string S(n, c);

	return S;
}

void print_rectangle(int W, int H, char c)
{
	for(int i = 0; i < H; i++)
	{
		cout << put_nchar(W, c) << endl;
	}
}

int main()
{
	vector<int> W, H;

	while(true)
	{
		int H1, W1;

		cin >> H1 >> W1;

		if(H1 == 0 && W1 == 0) { break; }

		H.push_back(H1);
		W.push_back(W1);
	}

	for(vector<int>::size_type i = 0; i < H.size(); i++)
	{
		print_rectangle(W[i], H[i], '#');

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
# B - Counting of Trees
import collections
N = int(input())
D = list(map(int, input().split()))

c = collections.Counter(D)
ans = 1
tmp = 1
if D[0] > 0:
    print(0)
    exit()
elif c[0] != 1:
    print(0)
    exit()
else:
    for i in range(1,max(D)+1):
        ans *= (tmp ** c[i])
        ans = ans % 998244353
        tmp = c[i]
print(ans)

Measured memory_bytes: 63540
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
// char a[810][810];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int h,w;
char maze[810][810];//迷路
int sx,sy;//スタート、ゴールの座標
int d[810][810];//最短距離の配列

void bfs(){
    queue<pair<int,int>> q;
    REP(i,h) REP(j,w) d[i][j] = INF;
    q.push(pair<int,int>(sx,sy));
    d[sx][sy] = 0;

    while(q.size()){
        pair<int,int> p = q.front();
        q.pop();
        

        REP(i,4){
            int nx = p.fi + dx[i],ny = p.se + dy[i];
            if(0<=nx && nx<h && 0<=ny && ny< w &&  maze[nx][ny] != '#' && d[nx][ny] == INF){
                q.push(pair<int,int>(nx,ny));
                d[nx][ny] = d[p.fi][p.se] + 1;
            }
        }
    }
    // REP(i,h){
    //     REP(j,w) cout << d[i][j] << " ";
    //     cout << endl;
    // }
    return;
}
signed main(){
    int k;
    cin >> h >> w >> k;
    rep(i,h){
        rep(j,w){
            cin >> maze[i][j];
            if(maze[i][j] == 'S'){
                sx = i;
                sy = j;
            }
        }
    }
    int mini = INF;
    bfs();
    rep(i,h){
        rep(j,w){
            if(d[i][j] <= k){
                mini = min({mini,i,j,h-1-i,w-1-j});
            }
        }
    }
    if(mini == 0)cout << 1 << endl;
    else cout << 1+(mini-1)/k+1 << endl;
    // rep(i,h){
    //     rep(j,w)cerr << d[i][j] << " ";
    //     cerr << endl;
    // }




    

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://agc014.contest.atcoder.jp/tasks/agc014_c

Measured memory_bytes: 6016
N = int(input())
D = dict()
for i in range(N):
    s = input()
    if s not in D:
        D[s] = 1
    else:
        D[s] += 1
# print(D)
# print(max(D))
m = max(D.values())
# print(m)
D = sorted(D.items(), key=lambda x:x[1], reverse=True)
# print(D)
Y = []
for i in D:
    if i[1] == m:
        Y.append(i[0])
        # print(Y)
Y.sort()
# print(Y)
for i in Y:
    print(i)

Measured memory_bytes: 43224
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

vector<vector<pair<int, int>>> graph;
vector<long long> d;

void path(int v, int prev, long long dist)
{
  d[v] = dist;
  for(auto itr=graph[v].begin(); itr != graph[v].end(); ++itr){
    pair<int, int> p;
    p = *itr;
    if(prev != p.first){
      path(p.first, v, dist + p.second);
    }
  }
  return;
}

int main() {
  int n, a, b, c, q, k, x, y;
  cin >> n;
  graph.resize(n+1);
  d.resize(n+1);
  for(int i=0; i<n-1; ++i){
    cin >> a >> b >> c;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
  }
  cin >> q >> k;
  // preprocessing
  path(k, 0, 0);
  // query
  for(int i=0; i<q; ++i){
    cin >> x >> y;
    cout << (d[x] + d[y]) << endl;
  }
}

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

using namespace std;

const int mod = (int) 1e9 + 7;

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

  vector<pair<int,int>> seg; // start, len
  for (int i = 1; i * i <= N; i++) {
    int l = N / (i + 1) + 1;
    int r = N / i;
    if ((long long) l * l > N) {
      seg.emplace_back(l, r - l + 1);
    }
    seg.emplace_back(i, 1);
  }
  sort(seg.begin(), seg.end());

  int n = seg.size();
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = seg[i].second;
    // cerr << seg[i].first << ' ' << seg[i].second << endl;
  }

  for (int t = 0; t < K - 1; t++) {
    vector<int> sum(n + 1);
    for (int i = 0; i < n; i++) {
      sum[i + 1] = (sum[i] + dp[i]) % mod;
    }
    for (int i = 0; i < n; i++) {
      dp[i] = (long long) sum[n - i] * seg[i].second % mod;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = (ans + dp[i]) % mod;
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 4320
import collections

N = int(input())
A = list(map(int, input().split()))

tmp = [0 for _ in range(N)]
for i in range(N):
  tmp[i] = (i + 1) + A[i]

c = collections.Counter(tmp)

ans = 0
for i in range(N):
  aj = (i+1) - A[i]
  ans += c[aj]

print(ans)
  
'''
i < jとする
A[i] + A[j] = j - i
A[i] + i = j - A[j]
K = j - A[j]
'''

Measured memory_bytes: 42596
K,N = map(int,input().split())
array = list(map(int,input().split()))
ans = 10**8
for i in range(N):
  if i == 0:
    ans1 = array[-1] - array[i]
  else:
    ans1 = array[i-1] + ( K - array[i] )
  if i == N-1:
    ans2 = array[-1] - array[0]
  else:
    ans2 = array[i] + ( K - array[i+1] )
  ans = min(ans,ans1,ans2)
print(ans)

Measured memory_bytes: 100880
#include <iostream>
#include <string>

class Baseball{
private:
	int runner; // 0~3: the number of runner
	int out_count; //0~2: out count
	int point;

public:
	Baseball(){
		runner = 0;
		out_count = 0;
		point = 0;
	}

	bool judge(std::string event){
		if(event == "HIT"){
			return single_hit();
		}else if(event == "HOMERUN"){
			return home_run();
		}else{
			return out();
		}
	}

	void display(){
		std::cout << point << std::endl;
	}

	bool single_hit(){
		(runner == 3) ? ++point : ++runner;
		return 1;
	}

	bool home_run(){
		point = point + runner + 1;
		runner = 0;
		return 1;
	}

	bool out(){
		if(out_count == 2){
			display();
			return 0;
		}else{
			++out_count;
			return 1;
		}
	}
};

int main(){
	int n; // the number of datasets
	std::cin >> n;

	for(int i = 0; i < n; ++i){
		Baseball inning;
		std::string eve;
		std::cin >> eve;
		while(inning.judge(eve) == 1){
			std::cin >> eve;
		}
	}
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> M(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j=0 ; j < W ; j++){
      cin >> M[i][j];
    }
  }

  //行のチェック
  vector<int> h(1,-1);
  for(int i = 0; i < H ; i++){
    int check = 0;
    for(int j = 0; j < W  ; j++){
      if(M[i][j] == '.'){
        check++;
      }
    }
    if(check == W){
      h.push_back(i);
    }
  }
  
  //for(x:h){
    //cout << x;
  //}
  //cout << endl;
  //列のチェック
  vector<int> w(1,-1);
  for(int i = 0; i < W ; i++){
    int check = 0;
    for(int j = 0; j < H ; j++){
      if(M[j][i] == '.'){
        check++;
      }
    }
    if(check == H){
      w.push_back(i);
    }
  }
  //for(x:w){
    //cout << x;
  //}
  //cout << endl;
  //cout << w.at(2) << endl;

  bool flag = true;
  for (int i = 0; i < H; i++) {
    flag = true;
    for(int k=0 ; k<h.size() ; k++){
      int x = h[k];
        if(i==x){
          flag = false;
          break;
        }
    }
    if(flag == false){
      continue;
    }
    
    for (int j=0 ; j < W ; j++){
      flag = true;
      for(int k=0 ; k <w.size() ; k++){
        int x = w[k];
        if(j==x){
          flag = false;
          break;
        }
      }      
      if(flag == true){
        cout << M[i][j];
      }
      
      /*
      if(j >= w.at(2)){
        cout << endl;
      }
      */
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
public static void main(String[] args){

 int a;
 int b;
Scanner s =new Scanner(System.in);
a=s.nextInt();
b=s.nextInt();
if(a<b){System.out.println("a"+" "+"<"+" "+"b");}
else if(a>b){System.out.println("a"+" "+">"+" "+"b");}
else if(a==b){System.out.println("a"+" "+"=="+" "+"b");}
}
}


Measured memory_bytes: 26316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  vector<char> ans;
  int N; ll A, B, C; cin >> N >> A >> B >> C;
  bool ichi = false; string T;
  rep(i, N){
      string S;
      if(!ichi){
          cin >> S;
      }
      else S = T;
      //cout << S << endl;
      //cout << T << endl;
      ichi = false;
      if(S=="AB"){
          if(A==1 && B==1){
              cin >> T; ichi=true; 
              if(T=="BC"){
                  ans.push_back('B'); B++; A--;
              }
              else{
                  ans.push_back('A'); A++; B--;
              }
          }
          else if(A>B) {
              ans.push_back('B'); A--; B++;
          }
          else if(A<=B){
              ans.push_back('A'); B--; A++;
          }
      }
      else if(S=="BC"){
          if(B==1 && C==1){
              cin >> T; ichi=true; 
              if(T=="AC"){
                  ans.push_back('C'); C++; B--;
              }
              else{
                  ans.push_back('B'); B++; C--;
              }
          }
          else if(B>C) {
              ans.push_back('C'); B--; C++;
          }
          else if(B<=C){
              ans.push_back('B'); B++; C--;
          }
      }
       else if(S=="AC"){
          if(A==1 && C==1){
              cin >> T; ichi = true; 
              if(T=="AB"){
                  ans.push_back('A'); A++; C--;
              }
              else{
                  ans.push_back('C'); C++; A--;
              }
          }
          else if(A>C) {
              ans.push_back('C'); A--; C++;
          }
          else if(A<=C){
              ans.push_back('A'); A++; C--;
          }
      }
      if(A<0 || B<0 || C<0){
          cout << "No" << endl; return 0;
      }
  }
  cout << "Yes" << endl;
  rep(i, ans.size()){
      cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3684
import java.util.Scanner;

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

        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n-1];

        for (int i = 0; i < n - 1; i++) {
            b[i] = in.nextInt();
        }

        a[n-1] = Integer.MAX_VALUE;
        for (int i = n-2; i >= 0; i--) {
            a[i+1] = Integer.min(a[i+1], b[i]);
            a[i] = b[i];
        }

        int out = 0;
        for (int i = 0; i < n; i++) {
            out += a[i];
        }

        System.out.println(out);
    }
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


int main(){
  int a,b,c;
  int w;

  scanf("%d%d%d\n",&a,&b,&c);

  w=a-b;

  if(w<c){
    printf("%d",c-w);
  }else{
    printf("0");
  }
}


Measured memory_bytes: 128
#include <iostream>

int main(){
	
	//double loop
	//?????????????????§??????
	for(int i = 1; i <= 9; ++i){
		for(int j = 1; j <= 9; ++j){
			std::cout << i << "x" << j << "=" << i*j << std::endl;
		}
	}
	return 0;
}

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

int main ()
{
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++)
  {
    cout << a[(n-1)-i];
    if(i < n - 1)
    {
      cout << " ";
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3020