akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;
const int M = 305;

double dp[M][M][M];

int main()
{
	//fast;
	int n;
	scanf("%d", &n);
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x == 1) cnt1++;

		if (x == 2) cnt2++;

		if (x == 3) cnt3++;
	}
	for (int c = 0; c <= n; c++) {
		for (int b = 0; b <= n; b++) {
			for (int a = 0; a <= n; a++) {

				int k = a + b + c;

				if (k == 0) continue;
				if (k > n) continue;

				dp[a][b][c] += (1.0 * n) / k;

				if (a)
					dp[a][b][c] += (1.0 * a) / k * dp[a - 1][b][c];
				if (b)
					dp[a][b][c] += (1.0 * b) / k * dp[a + 1][b - 1][c];
				if (c)
					dp[a][b][c] += (1.0 * c) / k * dp[a][b + 1][c - 1];

			}
		}
	}
	printf("%.12lf\n", dp[cnt1][cnt2][cnt3]);
	return 0;
}


Measured memory_bytes: 112612
def team_sort(teams, n):
    for i in range(n - 1):
        #print(i)
        for j in range(n - i - 1):
            #print(i, j, teams[j][2], teams[j+1][2])
            if (teams[j][2] < teams[j + 1][2]):
                tmp = teams[j]
                teams[j] = teams[j+1]
                teams[j+1] = tmp
            elif (teams[j][2] == teams[j + 1][2]):
                if (teams[j][3] > teams[j + 1][3]):
                    tmp = teams[j]
                    teams[j] = teams[j+1]
                    teams[j+1] = tmp
                elif (teams[j][3] == teams[j + 1][3]) and (teams[j][0] > teams[j + 1][0]):
                    tmp = teams[j]
                    teams[j] = teams[j+1]
                    teams[j+1] = tmp

def select(teams):
    selection = []
    count = {}
    for t in teams:
        g = str(t[1])
        count.setdefault(g, 0)
        #print(t)
            
        if len(selection) < 10:
            if (count[g] < 3):
                selection.append(t)
                count[g] += 1
        
        elif len(selection) < 20:
            if (count[g] < 2):
                selection.append(t)
                count[g] += 1
        
        elif len(selection) < 26:
            if (count[g] < 1):
                selection.append(t)
                count[g] += 1
    #print('selection', selection)
    
    for t in selection:
        print(t[0])

while True:
    n = int(input())
    
    if (n == 0):
        break
    
    teams = []
    
    for i in range(n):
         t = [int(x) for x in input().split()]
         teams.append(t)
    #print(teams)
    team_sort(teams, n)
    #print('sorted', teams)
    select(teams)


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n, m; cin >> n >> m;
	string s; cin >> s;

	s[m - 1] = s[m - 1] - ('A' - 'a');

	cout << s << endl;

	return 0;
}

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

#define LL long long

LL n, a, b, c, d;
unordered_map < LL ,LL > m;
unordered_map < LL , bool > inStack;

LL calc(LL x){
	// cout << x << " " << inStack[x] << endl;
	// cout << x << endl;
	// if(inStack[x] == true) return 1e18;
	// inStack[x] = true;
	LL res = 1e18;
	if(x == 0) return 0;
	if(x == 1) {
		// cout << 1 << " " << d << endl;
		return d;
	}
	if(m[x] != 0){
		// cout << x << " " << m[x] << endl;
		return m[x];
	}
	
	LL two = x % 2, three = x % 3, five = x % 5;
	res = min(res, two * d + a + calc(x / 2));
	res = min(res, three * d + b + calc(x / 3));
	res = min(res, five * d + c + calc(x / 5));

	if(x * d > 0) res = min(res, x * d);
	if(two != 0) res = min(res, (2 - two) * d + a + calc((x + 2 - two) / 2));
	if(three != 0) res = min(res, (3 - three) * d + b + calc((x + 3 - three) / 3));
	if(five != 0) res = min(res, (5 - five) * d + c + calc((x + 5 - five) / 5));
	return m[x] = res;
}

void solve(){
	m.clear();
	cin >> n >> a >> b >> c >> d;
	LL res = calc(n);
	if(n * d > 0) res = min(res, n * d);
	cout << res << endl;
}

int main(){
	int tests;
	cin >> tests;
	while(tests--){
		solve();
	}

}

Measured memory_bytes: 4176
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string a,b;
	while(cin>>a>>b,a!="0"){
		int hit=0,blow=0;
		int i,j;
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(i==j&&a[i]==b[j])hit++;
				if(i!=j&&a[i]==b[j])blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333, inf = 0x3f3f3f3f;
int n,p[N],cnt0,cnt1,max0,max1,q;bool high[N];
int t,v[2][N];vector<pair<int*,int> >rec[N];//int*
inline int query(int *v, int p){
	int res=-inf;while(p<=n)res=max(res,v[p]),p+=p&-p;return res;//WA
}
inline void modify(int *v, int p, int x){
	while(p){
		if(x>v[p]){rec[t].pb(pair<int*,int>(v+p,v[p]));v[p]=x;}
		p-=p&-p;
	}
}
inline bool judge(int lim, int x){
	if(x<0)return 0;return query(v[x&1],lim+1)>=x;
}
inline bool ok(int max0, int max1, int cnt0, int cnt1){
	return judge(max1,cnt0-cnt1+q)|judge(max0,cnt1-cnt0+q);
}
int main() {
	read(n);for(int i=1,mx=0;i<=n;i++){
		read(p[i]);high[i]=p[i]>mx;mx=max(mx,p[i]);q+=high[i];
	}
	rep(i,0,1)rep(j,0,n)v[i][j]=-inf;modify(v[0],n,0);//WA
	per(i,n,1){
		int f[2];t=i;
		f[0]=query(v[0^(!high[i])],p[i])+(high[i]?2:1);
		f[1]=query(v[1^(!high[i])],p[i])+(high[i]?2:1);
		//printf("%d:%d %d\n",i,f[0],f[1]);
		if(f[0]>=0)modify(v[0],p[i],f[0]);if(f[1]>=0)modify(v[1],p[i],f[1]);
	}
	if(!ok(0,0,0,0)){puts("-1");return 0;}
	rep(i,1,n){
		q-=high[i];rep(j,0,SZ(rec[i])-1)*rec[i][j].fi=rec[i][j].se;
		if(ok(max(max0,p[i]),max1,cnt0+(p[i]>max0),cnt1)){
			putchar('0');cnt0=cnt0+(p[i]>max0);max0=max(max0,p[i]);
		}
		else {
			putchar('1');cnt1=cnt1+(p[i]>max1);max1=max(max1,p[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 49792
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[] a, b, c;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		N = sc.nextInt();
		a = new int[N+1];
		b = new int[N+1];
		c = new int[N];
		
		for (int i = 0; i < N; i++) a[i+1] = sc.nextInt();
		for (int i = 0; i < N; i++) b[i+1] = sc.nextInt();
		for (int i = 1; i < N; i++) c[i] = sc.nextInt();
		
		int s = 0;
		for (int i = 1; i <= N; i++) {
			s += b[a[i]];
			if (i < N && (a[i]+1) == a[i+1]) s += c[a[i]];
		}
		
		System.out.println(s);
	}

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

}

Measured memory_bytes: 21844
A, B, C = list(map(int, input().split()))

pattern = list()
i = 0
while True:
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        print(i)
        break
    tmp_A = A
    tmp_B = B
    A = (B + C) / 2
    B = (C + tmp_A) / 2
    C = (tmp_B + tmp_A) / 2

    i += 1

    if (A, B, C) in pattern:
        print(-1)
        break
    pattern.append((A, B, C))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const ll MAXN = 1e5 + 100;
ll n, a[MAXN], b[MAXN], ans;

int main(){

cin >> n;

for(int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
}

reverse(a + 1, a + 1 + n);
reverse(b + 1, b + 1 + n);


for(int i = 1; i <= n; ++i) {

    a[i] += ans;

    if(a[i] % b[i] != 0) {

        ll key = (a[i] / b[i] + 1) * b[i];

        ans += (key - a[i]);

    }

}

cout << ans;


return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

//  val n: Int = readInt()
//  val testimoniesPerPerson: Seq[Seq[(Int, Int)]] = (1 to n).map { _ =>
//    val numOfTestimonies = readInt()
//    val testimonies: Seq[(Int, Int)] = Seq.fill(numOfTestimonies) {
//      val testimony: Array[Int] = readLine().split(" ").map(_.toInt)
//      (testimony(0) - 1, testimony(1)) // Modify to 0 origin
//    }
//    testimonies
//  }
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val testimoniesPerPerson: Array[Map[Int, Boolean]] = Array.fill(n){
    Array.fill(sc.nextInt)(sc.nextInt - 1 -> (sc.nextInt == 1)).toMap
  }


  def solve(): Int = {
    val valids = (0 until (1 << n)).map{ i =>
      val valid = (0 until n)
        .filter{j => ((1 << j) & i) != 0}
        .forall{j => isHonestPerson(j, i)}
      if (valid) Integer.bitCount(i) else 0
    }
    valids.max
  }

  def isHonestPerson(personIndex: Int, bit: Int): Boolean =
    testimoniesPerPerson(personIndex).forall { case (x, y) =>
      y == isBitOn(bit, x)
    }

  def isBitOn(bit: Int, digit: Int): Boolean =
    ((bit >> digit) & 1) != 0

  def countHonest(bit: Int): Int=
    Integer.bitCount(bit)


  println(solve())

}


Measured memory_bytes: 42892
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int	a = Integer.parseInt(s.next()),
			b = Integer.parseInt(s.next());
		if(a>b)
			System.out.println("a > b");
		else if(a<b)
			System.out.println("a < b");
		else
			System.out.println("a == b");
	}
}

Measured memory_bytes: 26136
#include <bits/stdc++.h>
 
using namespace std;  
 
typedef long long ll;
typedef long double ld;
 
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rs resize
#define all(x) x.begin(), x.end()   
 
void pre(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void pudge(){
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < 1000; i++){
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int p = 0;
        for (int j = 0; j < n; j++){
            if (s[j] - '0' == c[p])
                p++;
        }
        if (p == 3)
            cnt++;
    }
    cout << cnt << '\n';
}
 
int main(){ 
    pre();
    pudge();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

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

  vector<vector<pair<int, int> > > pref(N + 1);
  int p, y;
  for (int i = 0; i < M; i++) {
    cin >> p >> y;
    pref[p].push_back(make_pair(y, i));
  }

  vector<string> id(M);
  for (int i = 0; i <= N; i++) {
    sort(pref[i].begin(), pref[i].end());
    string p = "";
    int ct = i;
    for (int j = 0; j < 6; j++) {
      p = (char) (ct % 10 + '0') + p;
      ct /= 10;
    }
    for (int j = 0; j < pref[i].size(); j++) {
      int index = pref[i][j].second;
      int year = j + 1;
      string s = "";
      for (int k = 0; k < 6; k++) {
        s = (char) (year % 10 + '0') + s;
        year /= 10;
      }
      s = p + s;
      id[index] = s;
    }
  }

  for (int i = 0; i < M; i++) {
    cout << id[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 12416
import java.util.Scanner;

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

			System.out.println(String.format("%s" + "%d" + "%s",
					s.charAt(0), s.substring(1, s.length() - 1).length(), s.charAt(s.length() - 1)));

		}
	}
}

Measured memory_bytes: 22868
n, m, c = map(int, input().split())
b = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for i in range(n)]
ans = 0
for i in range(n):
  sum = 0
  for j in range(m):
    sum += a[i][j]*b[j]
  sum += c
  if sum > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>

int main(){
    int n, S[10001], q, T[501];

    scanf("%d",&n);
    for (int i = 0; i < n; i++) scanf("%d",&S[i]);
    scanf("%d",&q);
    for (int i = 0; i < q; i++) scanf("%d",&T[i]);
    
    int count = 0;
    for (int i = 0; i < q; i++){
        for (int j = 0; j < n; j++){
            if (S[j] == T[i]) {
                count++;
                break;
            }
        }
    }

    printf("%d\n", count);
}


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

int main() {
  int N;
  cin >> N;
  int A = 0;
  for (int i = 0; i < N; i++) {
    int x, y;    
    cin >> x >> y;
    A += (y - x + 1);
  }  
  cout << A << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int H, N, mp[1005][10005];
int main() {
  scanf("%d %d", &H, &N);
  // mp := 総ダメージがH以上になるように魔法1-iを選択したときの、消費魔力の総和の最小値
  for(int dmg = 1; dmg <= H; ++dmg) mp[0][dmg] = 1e9;
  for(int i = 1, A, B; i <= N; ++i) {
    scanf("%d %d", &A, &B);
    for(int dmg = 1; dmg <= H; ++dmg) {
      if(dmg > A) mp[i][dmg] = min(mp[i-1][dmg], mp[i][dmg-A]+B);
      else mp[i][dmg] = min(mp[i-1][dmg], (dmg+A-1)/A*B);
    }
  }
  printf("%d\n", mp[N][H]);
}

Measured memory_bytes: 39296
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "No"; return;}

void solve() {
    int n, m, sum = 0;
    cin >> n >> m;
    vector <int> mns;
    loop(i, n) {
        int x; cin >> x;
        sum += x;
        while (x) {
            mns.pb(x - (x >> 1));
            x >>= 1;
        }
    }
    sort(all(mns), greater<int>());
    loop(i, min(m, (int)mns.size()))
        sum -= mns[i];
    cout << sum;
}

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

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

using namespace std;

int main(){
  
  int n;
  
  cin >> n ;
  
  n %= 10;
  
  if(n == 0 || n == 1 || n == 6 || n == 8){
    cout << "pon" << endl;
  }
  
  else if(n == 3){
    cout << "bon" << endl;
  }
  
  else{
    cout << "hon" << endl;
  }
  
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    map<string, int> a;
    rep(i, n)
    {
        string s;
        cin >> s;
        a[s]++;
    }

    int ans = 0;
    for (auto p : a)
    {
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    string S; cin >> S;
    if (S == "ABC") {
        print("ARC");
    } else {
        print("ABC");
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3652
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)

from collections import Counter
c = Counter()

for si in S:
    c[si] += 1

ca = []
for name, cnt in c.items():
    ca.append([name, cnt])

ca.sort(key=lambda x:x[0])
ca.sort(key=lambda x:x[1], reverse=True)

max_c = ca[0][1]
for name, cnt in ca:
    if cnt == max_c:
        print(name)


Measured memory_bytes: 55608
N, Q = map(int, input().split())
S = input()
isA = (S[0] == "A")
ruiseki = [0]
for s in S[1:]:
  if isA:
    if s == "C":
      ruiseki.append(ruiseki[-1]+1)
    else:
      ruiseki.append(ruiseki[-1])
  else:
    ruiseki.append(ruiseki[-1])
  isA = (s == "A")
for _ in range(Q):
  l, r = map(int, input().split())
  print(ruiseki[r-1]-ruiseki[l-1])



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

typedef long long ll;

int main () {
    int n;
    cin >> n;
    string l;
    cin >> l;
    int ok = 0;
    while (true) {
        int sign = 0;
        for (int i = 0; i < l.length(); i++) {
            if (l[i] == '(') {
                sign += 1;
            }
            else {
                sign -= 1;
            }
            
            if (sign < 0) {
                l = '(' + l;
                break;
            }
            if (sign > 0 && i == l.length() - 1) {
                l = l + ')';
                break;
            }
            if (sign == 0 && i == l.length() - 1) {
                ok = 1;
            }
        }
        if (ok == 1) {
            break;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll g = __gcd(c, d);
    ll n = c / g * d;
    ll ans = b / c - (a - 1) / c + b / d - (a - 1) / d - (b / n - (a - 1) / n);
    // debug(n);
    // debug(ans);
    cout << b - a + 1 - ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define n1 4
#define n2 16
#define LIMIT 45
struct puzzle{
  int row[n2];
  int x,y;
  int MD;
};
int MDS[n2][n2];
 int dx[4]={0,-1,0,1};
 int dy[4]={1,0,-1,0};
int limit,path[LIMIT];
puzzle pstate;
int getallmd(puzzle p){
  int sum=0;
  for(int i=0;i<n2;i++)
    if(p.row[i]!=n2)sum+=MDS[i][p.row[i]-1];
  return sum;
}

int dfs(int depth, int prev){
  int res;
  if(pstate.MD==0)return depth;
  if(depth+pstate.MD>limit)return false;
  int sx=pstate.x,sy=pstate.y;
  puzzle tmp;
  for(int i=0;i<4;i++){
    int tx=sx+dx[i];
    int ty=sy+dy[i];
    if(tx<0||ty<0||tx>=n1||ty>=n1)continue;
    if((int)(max(prev,i)-min(prev,i))==2)continue;
    tmp=pstate;
    pstate.MD-=MDS[tx*n1+ty][pstate.row[tx*n1+ty]-1];
    pstate.MD+=MDS[sx*n1+sy][pstate.row[tx*n1+ty]-1];
    swap(pstate.row[tx*n1+ty],pstate.row[sx*n1+sy]);
    pstate.x=tx;
    pstate.y=ty;
    //cout<<"finish; " <<i<<endl;
    if(res = dfs(depth+1,i))return res;
    pstate=tmp;
  }
  return false;
}
int findans(puzzle fp){
  int res;
  fp.MD=getallmd(fp);
  for(limit=fp.MD;limit<=LIMIT;limit++){
    pstate=fp;
    if(res = dfs(0,-100))return res;
  }
  return 0;
}

int main(){
  puzzle p;
  for(int i=0;i<n2;i++){
    cin>>p.row[i];
    if(p.row[i]==0){
      p.row[i]=n2;
      p.x=i/n1;
      p.y=i%n1;
    }
    for(int j=0;j<n2;j++)
      MDS[i][j]=abs(i/n1-j/n1)+abs(i%n1-j%n1);
  }
  ;
  cout<<findans(p)<<endl;


  return 0;
}




Measured memory_bytes: 3108
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();

        boolean isOK = x % 100 == 0;

        if (!isOK) {
            int amari = x % 100;
            int atari = x / 100;
            if (atari * 5 >= amari) {
                isOK = true;
            }
        }

        System.out.println(isOK ? 1 : 0);
    }
}

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


bool a[1000000005];
int main()
{
	int n,x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(a[x])
		{
			printf("NO");
			return 0;
		}
		a[x]++;
	}
	printf("YES");
	return 0;
 } 

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

using namespace std;

typedef long long ll;
const int MAXN = 1e5 + 1;
ll arr[MAXN];
ll ans;
int n, k;

int main() {
	
	ans = 1e17;

	cin >> n >> k;

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

	for (int i = 0; i <n; i++) {
		int a = i;
		int b = i + k - 1;
		if (b >=n) break;

		ans = min(ans, min(abs(arr[a]), abs(arr[b])) + arr[b] - arr[a]);
	}

	cout << ans << "\n";

	return 0;
}

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

using namespace std;

string str;
int a, b;

int main()
{
	cin >> a >> b;
	cin >> str;

	if (str[a] == '-')
	{
		int ok = 1;
		for (int i = 0; i < a; ++i)
			if (str[i] == '-')
			{
				ok = 0;
				break;
			}

		for (int i = a + 1; i < a + b + 1; ++i)
			if (str[i] == '-')
			{
				ok = 0;
				break;
			}

		if (ok)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const long double PI = acos(-1);

int main(void){
    long double a,b,x;
    cin >> a >> b >> x;
    long double ans=0;

    if(2*x<=a*a*b){
        ans=atan2(a*b*b,2*x);
    }
    else if(x<a*a*b){
        ans=atan(2*(a*a*b-x)/(a*a*a));
    }
    cout << fixed << setprecision(10) << ans*180/PI << endl;
    return 0;
}

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

int l;
string x;
char tmp[200001];

int main(){
	scanf("%s", tmp);
	x = tmp;
	l = x.size();

	int s = 0;;
	int ans = 0;
	for(int i=0; i<l; i++){
		if(x[i] == 'S'){
			s++;
		}else{
			if(s > 0){
				s--;
			}else{
				ans++;
			}
		}
	}
	printf("%d\n", ans * 2);
	return 0;
}

Measured memory_bytes: 640
N,K=map(int, input().split())
h=list(map(int, input().split()))
dp=[0]*N
hlist=[0]*N

for i in range(1,N):
  dp_l=[]
  for j in range(1,K+1):
    if i-j>=0:
      dp_l.append(dp[i-j]+abs(h[i]-h[i-j]))
  dp[i]=min(dp_l)
print(dp[-1])    

Measured memory_bytes: 52704
N,M = map(int, input().split())
pref = {}
city = [0] * M

for i in range(M):
    P,Y = map(int, input().split())
    if P not in pref.keys():
        pref[P] = []
    pref[P].append([i,Y])

for p in pref.keys():
    pref[p].sort(key=lambda e:e[1])
    for i,e in enumerate(pref[p]):
        city[e[0]] = '%06d%06d' % (p, i+1)

for c in city:
    print(c)


Measured memory_bytes: 47536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

int main(){
	string A,B;
	cin>>A>>B;

	if(A.length()>B.length()) {
		cout<<"GREATER"<<endl;
		return 0;
	}

	else if(A.length()<B.length()) {
		cout<<"LESS"<<endl;
		return 0;
	}

	else {
		REP(i,A.length()) {
			if(A.substr(i,1)>B.substr(i,1)) {
				cout<<"GREATER"<<endl;
				return 0;	
			}

			else if(A.substr(i,1)<B.substr(i,1)) {
				cout<<"LESS"<<endl;
				return 0;	
			}
		}
	}

	cout<<"EQUAL"<<endl;
	return 0;
}

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

void getInput(char *pstr, int size)
{
    fgets(pstr, size, stdin);
}

int main() {
    char str[100];
    char *pstr = &str[0];

    char S[100];
    unsigned long K = 0;
    int result = 0;
    
    /* Sの読み込み */
    getInput(S, sizeof(S));
    //printf("%s\n", S);
    
    /* Kの読み込み */
    getInput(pstr, sizeof(str));
    K = atoi(pstr);
    //printf("%lu\n", K);
    
    /* 10^18 < 2^60なので左から1以外を探す */
    int count = 0;
    while (1) {
        result = S[count] - 48;
        if (1 != result) {
            break;
        }
        
        if (K == (count + 1)) {
            result = 1;
            break;
        }
        count++;
    }
    printf("%d\n", result);
    
    return 0;
}


Measured memory_bytes: 128
/**
country:China
Author:JiaYang Lee
Language:c++
School:SCAU
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+500;
const int mod = 1e9+7;
const int inf = 1e9+7;
typedef long long ll;
int n,a,b;
char ch[N];
int id[N];


void solve()
{
    memset(id,0,sizeof id);
    scanf("%s",ch);
    int pass=0;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(ch[i]=='b')id[i]=++cnt;
    }
    for(int i=0;i<n;i++)
    {
        if(ch[i]=='c')
        {
            puts("No");
            continue;
        }
        if(ch[i]=='a')
        {
            if(pass<a+b)
            {
                puts("Yes");
                pass++;
                continue;
            }
            puts("No");
            continue;
        }

        if(pass<a+b&&id[i]<=b)
        {
            puts("Yes");
            pass++;
            continue;
        }
        puts("No");

    }
}

int main()
{
    while(scanf("%d%d%d",&n,&a,&b)!=EOF)
        solve();
    return 0;
}


Measured memory_bytes: 4608
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/

/+---test
3
#.#
---+/
/+---test
5
#.##.
---+/
/+---test
9
.........
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  const S = readln.chomp;

  const l = S.countUntil!(x => x != '.');
  const r = S.retro.countUntil!(x => x != '#');

  if (l < 0 || r < 0) {
    0.writeln;
    return;
  }

  auto dp1 = new long[](N);
  foreach_reverse (i; l..N) {
    if (i+1 < N) dp1[i] = dp1[i+1];
    if (S[i] == '.') ++dp1[i];
  }
  auto dp2 = new long[](N);
  foreach (i; 0..N-r) {
    if (i) dp2[i] = dp2[i-1];
    if (S[i] == '#') ++dp2[i];
  }

  dp1[0..l]   = dp1[l];
  dp2[$-r..$] = dp2[$-r-1];
  dp1 ~= 0;
  dp2  = 0 ~ dp2;

  zip(dp1, dp2).map!(x => x[0] + x[1]).minE.writeln;
}


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

using namespace std;

int main(void)
{
    int N, M;
    map<string, int> card;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        card[s];
        card[s]++;
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        string s;
        cin >> s;
        card[s];
        card[s]--;
    }
    int max = 0;
    for(auto itr = card.begin(); itr != card.end(); itr++){
        int value = itr->second;
        if(value > max)
            max = value;
    }

    cout << max << endl;
}

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

int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) cout << "GREATER" << endl;
	else if (A.size() < B.size()) cout << "LESS" << endl;
	else if (A == B) cout << "EQUAL" << endl;
	else {
		for (int i = 0; i < A.size(); i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				break;
			}
			if (A[i] < B[i]) {
				cout << "LESS" << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
// #include "ane.cpp"

#define INF (int)1e9
#define NMAX 10
#define MMAX 30
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;

int N,M,dp[NMAX][MMAX] = {};
int G[NMAX][NMAX]={};
std::vector<int> vec;

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

int ans = 0;

void solve(){
    // 解答アルゴリズム

    do
    {
        bool err = false;
        // for (int i = 0; i < N; ++i)
        // {
        //     cout << vec[i] << " ";
        // }
        // cout << endl;
        for (int i = 0; i < N-1; ++i)
        {
            if (!G[vec[i]][vec[i+1]])
            {
                err = true;
                break;
            }
        }
        if(!err)ans++;
    } while (next_permutation(vec.begin()+1, vec.end()));
}
void debug(){
    // デバッグ用出力
    cout << "G:\n";
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            cout << G[i+1][j+1];
        }
        cout << endl;
    }
}
void answer(){
    // 解答出力
    cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    Fill(dp, -1);

    cin >> N >> M;
    for (int i = 0; i < M; ++i)
    {
        int a,b;
        cin >> a >> b;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    for (int i = 1; i <= N; ++i)
    {
        vec.push_back(i);
    }
    solve();
    #ifdef DEBUG
    // debug();
    #endif
    answer();

    return 0;
}

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

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

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

	int w=0;
	int b=0;
	for(int i=0;i<N;i++){
		if(S.at(i)=='.')	w++;
		else	b++;
	}
	int now_w=0;
	int now_b=0;
	int ans=1e9;
	if(w==0 || b==0)	ans=0;
	ans=min(ans,w);
	for(int i=0;i<N;i++){
		if(S.at(i)=='.')	now_w++;
		else	now_b++;
		int x=(w-now_w)+now_b;
		ans=min(ans,x);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> v(N);
    rep(i, N) {
        cin >> v[i];
    }
    ll pos = 0;
    vector<bool> visited(N, false);
    ll cnt = 1;
    while(!visited[pos]) {
        if (v[pos] == 2) {
            print(cnt);
            return 0;
        } else {
            visited[pos] = true;
            cnt++;
            pos = v[pos]-1;
        }
    }
    print(-1);
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,max=-1,x,flg=0;
	char mise[6]={'A','B','C','D','E'};
	int s1[6],s2[6],sum[6];
	while(1) {
		scanf("%d %d",&s1[0],&s2[0]);
		if(s1[0]==0 && s2[0]==0) {
			break;
		}
		sum[0]=s1[0]+s2[0];
		max=sum[0];
		x=0;
		for(i=1;i<5;i++) {
			scanf("%d %d",&s1[i],&s2[i]);
			sum[i]=s1[i]+s2[i];
			if(max<sum[i]) {
				x=i;
				max=sum[i];
			}
		}
		printf("%c %d\n",mise[x],sum[x]);
		flg=0;
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;

  vi num(n, 1);
  vector<bool> red(n, false);
  red[0] = true;

  REP(i, m) {
    int x, y; cin >> x >> y;
    x--; y--;
    if(red[x]) {
      if(num[x] == 1) {
        red[x] = false;
      }
      red[y] = true;
    }
    num[x]--;
    num[y]++;

    // printv(num);
    // printv(red);
  }

  int ans = 0;
  REP(i, n) {
    ans += red[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
// Code By H~$~C

import std.stdio;
import std.math, std.uni, std.format, std.bigint;
import std.array, std.string, std.container, std.range, std.typecons;
import std.algorithm, std.conv, std.functional, std.random;

immutable Maxn = 200005;

int n;
int[Maxn] c;
int[][Maxn] g;
long[Maxn] ans;
int[Maxn] sz, num;

void dfs(int u, int fa) {
  int col = c[u];
  int bef = num[col];
  sz[u] = 1;
  foreach(v; g[u]) {
    if (v == fa) continue;
    int pre = num[col];
    dfs(v, u);
    int vcol = sz[v] - (num[col] - pre);
    ans[col] -= cast(long)(vcol + 1) * vcol / 2;
    sz[u] += sz[v];
  }
  num[col] = bef + sz[u];
}

void _Main() {
  read(n);
  foreach(i; 0 .. n)
    read(c[i]), c[i]--;
  foreach(i; 1 .. n) {
    int u, v;
    read(u, v);
    --u, --v;
    g[u] ~= v;
    g[v] ~= u;
  }
  foreach(i; 0 .. n)
    ans[i] = cast(long)(n + 1) * n / 2;
  dfs(0, -1);
  foreach(i; 0 .. n) {
    int rest = n - num[i];
    (ans[i] -= cast(long)(rest + 1) * rest / 2).writeln;
  }
}

class EOFException : Throwable {
  this() { super("------ EOF Error!"); }
}
string[] tokens;
string readToken() {
  for (; tokens.empty; ) {
    if (stdin.eof) { throw new EOFException; }
    tokens = readln.split;
  }
  auto token = tokens.front;
  tokens.popFront;
  return token;
}
void read(T...)(ref T x) {
  foreach(i, ref y; x)
    y = readToken.to!(T[i]);
}

void main(string[] args) {
  try {
    int tests = 1;
//    read(tests);
    foreach (test; 0 .. tests) _Main();
  } catch(EOFException e) {
  }
}


Measured memory_bytes: 76088
import math

a, b, h, m = map(int, input().split())

x = (60 * h + m) / 720 * 2 * math.pi
y = m / 60 * 2 * math.pi

k = abs(x - y)
if k == math.pi:
    print(a + b)
    exit()
if k > math.pi:
    k = 2 * math.pi - k

print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(k)))

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
string s,t,lcs;
int dp[3010][3010];

int main()
{
	cin>>s>>t;
	for(int i=1;i<=t.size();i++)
	{
		for(int j=1;j<=s.size();j++)
		{
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			if(t[i-1]==s[j-1])dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
		//	printf("%d ",dp[i][j]);
		}
	//	printf("\n");
	}
	int a=t.size(),b=s.size();
	while(a!=0 && b!=0)
	{
		if(t[a-1]==s[b-1])
		{
			lcs+=s[b-1];
			a-=1;
			b-=1;
		}
		else if (dp[a-1][b] > dp[a][b-1]) a--; 
      	else b--;
	}
	reverse(lcs.begin(),lcs.end());
	cout<<lcs<<endl;
	return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define INF 100000000
using namespace std;
int main(void){
  int timedish[6];
  for(int i=0;i<5;i++){
  cin>>timedish[i];
  }
  int min=10;
  int last=0;
  for(int i=0;i<5;i++){
    if(min>(timedish[i]%10)&&timedish[i]%10!=0){last=i; min=timedish[i]%10;}
  }
  int ans=0;
  for(int i=0;i<5;i++){
      if(i!=last&&timedish[i]%10!=0){ans+=timedish[i]/10*10+10;}
      else ans+=timedish[i];
  }
  cout<<ans;
  return 0;
}


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

int main(){
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A*B >= C*D){
    cout << A*B << endl;
    return 0;
  }
  cout << C*D << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace Atcoder_test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int output;
            int k = int.Parse(Console.ReadLine());
            if (k % 2 == 0) 
            {
                int K = k / 2;
                output = K * K;
            } else {
                int K = k / 2;
                output = K * (K + 1);
            }
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <map>
#include <functional>
#include <iostream>
#include <string>
#include <queue>
#include <vector>

using namespace std;
struct edge{
	int t,c;
	edge(int tt=0,int cc=0){
		t=tt;
		c=cc;
	}
	bool operator<(const edge& e1)const{
		return c<e1.c;
	}
	bool operator>(const edge& e1)const{
		return c>e1.c;
	}
};

typedef edge data;

int n,m,cap;

vector<edge> G[7001];
vector<edge> GG[7001];
map<string,int> city;
int dp[7000];
bool flag[7000];

void make_path(int v){
	fill(dp,dp+city.size(),cap+1);
	priority_queue<edge,vector<edge>,greater<edge> > que;
	que.push(data(v,0));
	dp[v]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.t]<q.c)continue;
		if(q.t!=v && flag[q.t]){
			GG[v].push_back(edge(q.t,q.c));
		}
		for(int i=0;i<G[q.t].size();i++){
			edge e=G[q.t][i];
			if(dp[e.t]>dp[q.t]+e.c){
				dp[e.t]=dp[q.t]+e.c;
				que.push(data(e.t,dp[e.t]));
			}
		}
	}
}

int dijk(int f,int t){
	memset(dp,-1,sizeof(dp));
	priority_queue<edge,vector<edge>,greater<edge> > que;
	que.push(data(f,0));
	dp[f]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.t]<q.c)continue;
		if(q.t==t)return dp[q.t];
		for(int i=0;i<GG[q.t].size();i++){
			edge e=GG[q.t][i];
			if(dp[e.t]==-1 || dp[e.t]>dp[q.t]+e.c){
				dp[e.t]=dp[q.t]+e.c;
				que.push(data(e.t,dp[e.t]));
			}
		}
	}
	return -1;
}

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&cap);
		if(n+m+cap==0)break;
		cap*=10;
		string s,g;
		cin >> s >> g;
		if(city.find(s)==city.end()){
			city.insert(map<string,int>::value_type(s,city.size()));
		}
		if(city.find(g)==city.end()){
			city.insert(map<string,int>::value_type(g,city.size()));
		}
		flag[city[s]]=true;
		flag[city[g]]=true;
		for(int i=0;i<n;i++){
			string f,t;
			int c;
			cin >> f >> t >> c;
			if(city.find(f)==city.end()){
				city.insert(map<string,int>::value_type(f,city.size()));
			}
			if(city.find(t)==city.end()){
				city.insert(map<string,int>::value_type(t,city.size()));
			}
			G[city[f]].push_back(edge(city[t],c));
			G[city[t]].push_back(edge(city[f],c));
		}
		for(int i=0;i<m;i++){
			string str;
			cin >> str;
			if(city.find(str)==city.end()){
				city.insert(map<string,int>::value_type(str,city.size()));
			}
			flag[city[str]]=true;

		}
		for(int i=0;i<=city.size();i++){
			if(flag[i])make_path(i);
		}
		printf("%d\n",dijk(city[s],city[g]));
		memset(flag,false,sizeof(flag));
		for(int i=0;i<=city.size();i++){
			G[i].clear();
			GG[i].clear();
		}
		city.clear();
	}
	return 0;
}

Measured memory_bytes: 4672
#include<stdio.h>
#define ll long long int 
int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	ll k=c-a-b;
	if(k<0){
		printf("No");
	}
	else{
		ll sum=4*a*b;
		if(k*k>sum)
			printf("Yes");
		else
			printf("No");
	} 
}

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

int main(){
  ll a, b, x, ans = 0;
  cin >> a >> b >> x;
  ll bet = b - a;
  if(bet >= x){
    ll ad = a / x;
    if(a % x == 0) ans++;
    ad = (ad+1) * x;
    ll bd = b / x;
    bd = bd * x;
    ans += (bd - ad) / x;
    ans++;
  }else{
    if(a % x == 0)ans++;
    else{
      ll temp = a / x;
      temp = (temp+1) * x;
      if(temp <= b) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#場合分けがつらい
def 解():
    N,K=[int(_) for _ in input().split()]
    aD =[0]*40
    aA=[int(_) for _ in input().split()]
    iL = 0
    for i in range(40):
        m = 2**i
        aD[i]=sum((_ & m) for _ in aA)
        if aD[i]:
            iL = i
    iLK = len(bin(K))-3
    iML = max(iL,iLK)
    dp = [[0]*2 for _ in range(2)]
    #[x][0] Kに沿う
    #[x][0] Kに沿わない最大
    for i in range(iML,-1,-1):
        ib = i%2 #桁%2 dp
        inb = 0 if ib else 1 #次のdp
        i0 = aD[i] #反転しない
        i1 = (2**i)*N-i0 #反転する
        iM = max(i0,i1) #選べるとき
        bL = i < iLK #Kより長い
        if (K>>i)&1:
            dp[inb][1] = dp[ib][1] + i1
            dp[inb][0] = max(dp[ib][1] + i0 ,dp[ib][0]+(iM if bL else i0))
        else:
            dp[inb][1] = dp[ib][1] + i0
            dp[inb][0] = dp[ib][0] + (iM if bL else i0)
    print(max(dp[inb]))
解()


Measured memory_bytes: 14748
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma warning (disable:4996)
#include"bits/stdc++.h"
#define int long long
#define MRE assert(0);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long mod = 1000000007;
const long long inf = 1e17;
typedef pair<int, int> P;
int in[200];
vector<int>G[200];

int popcnt(int a) {
	int res = 0;
	rep(i, 55) {
		if (a&(1ll << i))res++;
	}
	return res;
}

signed main() {
	vector<P>V;
	rep(i, 55) {
		V.push_back(P((1ll << i) - 1, i));
	}
	int n; cin >> n; int N = n;
	int cst = 0, flg = 0;
	for (int i = 54; i >= 0; i--) {
		if (n >= V[i].first) {
			n -= V[i].first;
			cst = V[i].second;
			break;
		}
	}
	int S = cst + popcnt(n);

	rep(i, S - 1) {
		G[i].push_back(i + 1);
		G[S + i].push_back(S + i + 1);
	}
	rep(i, cst) {
		G[i].push_back(S);
	}
	for (int i = 54; i >= 0; i--) {
		if (n >= (1ll << i)) {
			G[cst].push_back(cst + S - i);
			cst++;
			n -= (1ll << i);
		}
	}
	
	rep(i, 2 * S) {
		for (int e : G[i])in[e]++;
	}
	priority_queue<int>Q;
	rep(i, 2 * S)if (!in[i])Q.push(i);
	vector<int>V2;
	while (Q.size()) {
		int p = Q.top(); Q.pop();
		V2.push_back(p);
		for (int e : G[p]) {
			in[e]--;
			if (!in[e]) {
				Q.push(e);
			}
		}
	}
	rep(i, V2.size()) {
		V2[i] = V2[i] % S + 1;
	}
	cout << S + S << endl;
	rep(i, V2.size()) {
		if (i)cout << ' ';
		cout << V2[i];
	}cout << endl;
}

Measured memory_bytes: 256