akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define REP(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

const int maxn=200005;
struct camels {
	int l,r,k;
}a[maxn];
bool cmp(camels x,camels y) {return x.k<y.k;}
bool cmp1(camels x,camels y) {return x.k>y.k;}

int n;
vector<camels> v1,v2;
priority_queue<int,vector<int>,greater<int> > q; 

void solve() {
	ll ans=0;
	v1.clear(),v2.clear();
	while(!q.empty()) q.pop();
	scanf("%d",&n);
	rep(i,1,n) {
		scanf("%d%d%d",&a[i].k,&a[i].l,&a[i].r);
		if(a[i].l<a[i].r) v2.pb(a[i]);
		else v1.pb(a[i]);
	}
	sort(all(v1),cmp);
	sort(all(v2),cmp1);
	REP(i,0,sz(v1)) {
		ans+=v1[i].r;
		int num=abs(v1[i].l-v1[i].r);
		if(v1[i].k>sz(q)) q.push(num);
		else if(!q.empty()&&q.top()<num) q.pop(),q.push(num);
	}
	while(!q.empty()) ans+=q.top(),q.pop();	
	REP(i,0,sz(v2)) {
		ans+=v2[i].l;
		int num=abs(v2[i].l-v2[i].r);
		if(n-v2[i].k>sz(q)) q.push(num);
		else if(!q.empty()&&q.top()<num) q.pop(),q.push(num);
	}
	while(!q.empty()) ans+=q.top(),q.pop();
	printf("%lld\n",ans);
	return;
}

int main() {
	int T;
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 8976
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string S; cin >> S;
	cout << S.substr(0, S.length() - 8) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
#define limit 1000005
#define lol (ll) sqrt((double)limit)
#define pb push_back
#define sci(x) scanf("%d",&x)
#define scl(y) scanf("%lld",&y)

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];

    sort(v.begin(),v.end());
    auto pos=lower_bound(v.begin(),v.end(),k);
    if( pos==v.end()) cout<<0<<endl;
     else
   cout<<v.end()-pos<<endl;
}


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

#define MAX 100


int main() 
{
	int i, j, n, x, y, z;
	int M[MAX][MAX] = {{0}};
	
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%d %d",&x, &y);
		x--;
		for (j = 0; j < y; j++) {
			scanf("%d",&z);
			z--;
			M[x][z] = 1;
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (j > 0) {
				printf(" ");
			}
			printf("%d",M[i][j]);
		}
		printf("\n");
	}
	
	
    return 0;
}


Measured memory_bytes: 2060
N, Y = map(int, input().split())
found = False
for k10 in range(N+1):
    if 10000 * k10 > Y:
        continue
    for k5 in range(N+1 - k10):
        k1 = N - k10 - k5
        if Y == 1000 * k1 + 5000 * k5 + 10000 * k10:
            found = True
            break
    if found:
        print(k10, k5, k1)
        break
else:
    print(-1, -1 ,-1)



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

int main(){
    using namespace std;
    string str;
    getline(cin,str);
    //cin >> str;
    for(int i{0}; i<str.size(); i++){
        if(str[i]>='a'&&str[i]<='z') {str[i] += 'A'-'a';}
        else if(str[i]>='A'&&str[i]<='Z') {str[i] += 'a'-'A';}
    }
    cout << str << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define FOR(i, FN) for(int i = 0; i < ( FN ); i++)
 
 
int main() {
    int n;
    vector<pair<int, int> > r, b;
    cin >> n;
    FOR(i, n){
        int x, y;
        cin >> x >> y;
        P temp = make_pair(x, y);
        r.push_back(temp);
    }
    FOR(i, n){
        int x, y;
        cin >> x >> y;
        P temp = make_pair(x, y);
        b.push_back(temp);
    }
    sort(b.begin(), b.end());
    int ans = 0;
    FOR(i, n){
        int ymax = -1, jmax = -1;
        for(unsigned j = 0; j < r.size(); j++) {
            if(r[j].first < b[i].first && r[j].second < b[i].second) {
                if(r[j].second > ymax) {
                    ymax = r[j].second;
                    jmax = j;
                }
            }
        }
        if(ymax != -1) {
            ans++;
            r.erase(r.begin() + jmax);
        }
    }
    cout << ans << endl;
 
 
    return 0;
}

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

int main() {
  int A, B, X;
  cin >> A;  
  cin >> B;
  if (A < B ){
     X = 2*B-1;
  }
  if (A == B ){
     X = 2*A;
  }
  if (A > B ){
     X = 2*A-1;
  }
  cout << X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_NT = 3005;
P d[MAX_NT];
int dp[MAX_NT][MAX_NT];

int main()
{
	int N,T;
	cin >> N >> T;
	rep(i,N)
	{
		int a,b;
		cin >> a >> b;
		d[i].first = a;
		d[i].second = b;
	}

	sort(d,d+N);
	int ans = d[0].second;
	for (int i = 0; i <= N-2; ++i)
	{
		rep(j,T)
		{
			if (j >= d[i].first)
			{
				dp[i+1][j] = max(dp[i][j-d[i].first] + d[i].second, dp[i][j]); 
			}
			else
			{
				dp[i+1][j] = dp[i][j];
			}
		}
		ans = max(ans, dp[i+1][T-1] + d[i+1].second);
	}

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

Measured memory_bytes: 35456
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}Point;

void koch(int n,Point a,Point b){
  if(n==0)return;
  Point s,t,u;
  double th = (M_PI*60.0)/180.0;

  s.x=((2.0*a.x)+(1.0*b.x))/3.0;
  s.y=((2.0*a.y)+(1.0*b.y))/3.0;

  t.x=((1.0*a.x)+(2.0*b.x))/3.0;
  t.y=((1.0*a.y)+(2.0*b.y))/3.0;

  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;


  koch(n-1,a,s);

  printf("%.8lf %.8lf\n",s.x,s.y);

  koch(n-1,s,u);
  printf("%.8lf %.8lf\n",u.x,u.y);

  koch(n-1,u,t);
  printf("%.8lf %.8lf\n",t.x,t.y);

  koch(n-1,t,b);
}

int main(){

  Point a,b;
  int n;
  scanf("%d",&n);
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8lf %.8lf\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8lf %.8lf\n",b.x,b.y);

  return 0;
}


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

int main(){
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];

	vector<int> dpa(n), dpb(n), dpc(n);
	dpa[0] = a[0]; dpb[0] = b[0]; dpc[0] = c[0];
	rep(i,n-1) {
		dpa[i+1] = max(dpb[i] + a[i+1], dpc[i] + a[i+1]);
		dpb[i+1] = max(dpa[i] + b[i+1], dpc[i] + b[i+1]);
		dpc[i+1] = max(dpb[i] + c[i+1], dpa[i] + c[i+1]);
	}
	int ans = max(dpa[n - 1], max(dpb[n - 1], dpc[n - 1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  ll X;
  cin >> X;

  if( X <= 6 ) {
    cout << 1 << "\n";
    return 0;
  } else if( X <= 11 ) {
    cout << 2 << "\n";
    return 0;
  } else if ( X % 11 == 0 ) {
    cout << 2 * (X / 11) << "\n";
    return 0;
  } else if ( X % 11 <= 6 ) {
    cout << 2 * (X / 11) + 1 << "\n"; 
    return 0;
  } else {
    cout << 2 * (X / 11) + 2 << "\n"; 
    return 0;
  }

  

  return 0;
}


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

int main(){
  
  char X,Y; cin >> X >> Y;
  
  if(X < Y){
    cout << '<' << endl;
  }
  
  else if(X > Y){
	cout << '>' << endl;
  }
  
  else{
    cout << '=' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		int []N = new int[str.length()];
		int sum=0;
		for(int i=0; i<str.length(); i++) {
			if(i==0) {
				N[0]=Integer.parseInt(str.substring(0,1));
			}
			else{
				String n = str.substring(i,i+1);
				N[i] = Integer.parseInt(n);
				if(N[i] == N[i-1]){
					if(N[i]==1) {
						N[i]=0;
						sum++;
					}
					else if(N[i]==0){
						N[i]=1;
						sum++;
					}
				}
			}
		}
		System.out.print(sum);
	}
}

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

const ll INF = (1LL << 60);

int chmin(ll x,int y){
    if (x > y) return y;
    return x;
}

int main(){
    int N;
    cin >> N;
    vector<int>v;
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    vector<ll>dp(100010,INF);
    dp.at(0) = 0;
    for (int i = 1; i < N; i++){
        dp.at(i) = chmin(dp.at(i),dp.at(i-1) + abs(v.at(i)-v.at(i-1)));
        if (i != 1) dp.at(i) = chmin(dp.at(i),dp.at(i-2) + abs(v.at(i)-v.at(i-2)));
    }
    cout << dp.at(N-1) << "\n";
}

Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
int a[100010];
void solve(){
  std::sort(a,a+n);
  int max=a[n-1];
  int def=INF,j;
  rep(i,n-1){
    if(std::abs(max/2-a[i])<=def){
      j=i;
      def=std::abs(max/2-a[i]);
    }
  }
  prin2(max,a[j]);
}
int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  solve();
  return 0;
}


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

int main() {
  int m = 999;
  string S;
  cin >> S;

  for (int i = 0; i < S.length() - 2; i++) {
    int num;
    istringstream ss;
    ss = istringstream(S.substr(i, 3));
    ss >> num;
    int res = num - 753;
    int diff = res < 0 ? -res : res;
    m = min(diff, m);
  }

  cout << m << endl;
}

Measured memory_bytes: 3620
let a, b = Scanf.scanf " %d %d" @@ fun a b -> a, b
let s = Scanf.scanf " %s" @@ fun s -> s
let is_digit c = 48 <= Char.code c && Char.code c <= 57
let c = Array.fold_left (+) 0 @@ Array.init (a + b + 1) @@ fun i -> if is_digit s.[i] then 1 else 0
let _ = print_endline @@ if c = a + b && s.[a] = '-' then "Yes" else "No"

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

int main() {
  int a,b; cin >> a >> b;
  int t[1001];
  t[1] = 1;
  for ( int i = 2; i <= 1000; i++ ) {
    t[i] = t[i-1] +i;
  }
  for ( int i = 1; i <= 1000; i++ ) {
    //  cout << t[i] << endl;
  }
  int ans1,ans2;
  for ( int i = 1; i <= 1000; i++ ) {
    if ( t[i] > a  && t[i]-a == t[i+1]-b ) {
      ans1 = t[i]-a;
      
    }
  }
   cout << ans1 << endl;
  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
s=[input() for _  in range(H)]
G=[["#"]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        G[i+1][j+1]=s[i][j]

def search(y,x):
    q=[(y,x)]
    d=[[-1]*(W+2) for _ in range(H+2)]
    d[y][x]=0
    while q:
        y1,x1=q.pop(0)
        for y2,x2 in ((y1+1,x1),(y1,x1+1),(y1-1,x1),(y1,x1-1)):
            if G[y2][x2]=="." and d[y2][x2]==-1:
                d[y2][x2]=d[y1][x1]+1
                q.append((y2,x2))
    return max(max(_) for _ in d)

ans=0
for i in range(H):
    for j in range(W):
        if G[i+1][j+1]==".":
            ans=max(search(i+1,j+1),ans)

print(ans)

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

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, a[3], l[8];
ll d[8];

ll solve(ll i) {
	if (i >= n) {
		vector<ll> b[3];
		REP(j, n) if (d[j] >= 0) b[d[j]].push_back(j);
		REP(j, 3) if (b[j].size() == 0) return INF;
		ll res = 0;
		REP(j, 3) {
			res += (b[j].size() - 1) * 10;
			ll s = 0;
			REP(k, b[j].size()) s += l[b[j][k]];
			res += abs(s - a[j]);
		}
		return res;
	} else {
		ll res = INF;
		REP(j, 4) {
			d[i] = j-1;
			res = min(res, solve(i+1));
		}
		return res;
	}
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, 3) cin >> a[i];
	REP(i, n) cin >> l[i];
	cout << solve(0) << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4;
const double eps = 1e-8;
const double inf = 1e20;
inline double sqr (double k) {return k * k;}
inline int sgn (double p) {
    if (fabs (p) < eps) return 0;
    if (p < 0) return -1;
    return 1;
}
struct point {
    double x, y;
    point (){}
    point (double _x, double _y) {
        x = _x, y = _y;
    }
    void input () {
        scanf ("%lf %lf", &x, &y);
    }
    bool operator == (point b) const {
        return sgn (x - b.x) == 0 && sgn (y - b.y) == 0;
    }
    point operator - (const point &b) const {
        return point (x - b.x, y - b.y);
    }
    double operator * (const point &b) const {
        return x * b.x + y * b.y;
    }
    double operator ^ (const point &b) const {
        return x * b.y - y * b.x;
    }
    double len () {
        return hypot (x, y);
    }
    double len2 () {
        return x * x + y * y;
    }
    double distance (point p) {
        return hypot (x - p.x, y - p.y);
    }
    point operator + (const point &b) const{
        return point (x + b.x, y + b.y);
    }
    point operator * (const double &b) const {
        return point (x * b, y * b);
    }
    point operator / (const double &b) const {
        return point (x / b, y / b);
    }
    double cross (point a, point b) {///叉积
        return (a - *this) ^ (b - *this);
    }
    double dot (point a, point b) {///点积
        return (a - *this) * (b - *this);
    }
    bool on_seg (point a, point b) {///点是否在线段ab上
        return sgn (cross (a, b)) == 0 && dot (a, b) <= 0;
    }
} ps[N];
///两线段是否相交
bool seg (point a, point b, point c, point d) {
    if (a.on_seg (c, d) || b.on_seg (c, d) || c.on_seg (a, b) || d.on_seg (a, b)) return true;
    if (a.cross (b, d) * a.cross (b, c) < 0 && c.cross (d, b) * c.cross (d, a) < 0) return true;
    return false;
}
/// 点的投影是否在线段ab上
bool check (point p, point a, point b) {
    point x = b - a;
    double k = x.len ();
    double u = a.dot (p, b) / k;
    x = (x / k) * u;
    x = x + a;
    if (x.on_seg (a, b)) return true;
    return false;
}
int cmp (point a, point b) {
    if ((a ^ b) < 0) return 1;
    return 0;
}
int main () {
//    freopen ("in.txt", "r", stdin);
    int n;
    double ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) ps[i].input ();
//    sort (ps, ps + n, cmp);
    ps[n] = ps[0];
    for (int i = 1; i <= n; i++) {
        ans += (ps[i] ^ ps[i - 1]);
//        cout << ps[i].x << ' ' << ps[i].y << endl;
    }
    printf ("%.1f\n", fabs (ans / 2));
    return 0;
}



Measured memory_bytes: 3236
(defun main ()
  (let ((n (read))
        (a (make-array 0 :element-type 'integer
                         :adjustable t
                         :fill-pointer 0))
        (c (make-array 0 :element-type 'integer
                         :adjustable t
                         :fill-pointer 0))
        (ans 0))
    (dotimes (i n)
      (vector-push-extend (read) a))
    (dotimes (i n)
      (incf ans (read)))
    (dotimes (i (1- n))
      (vector-push-extend (read) c))
    (loop for i from 0 upto (- n 2)
          do (if (= (aref a i) (1- (aref a (1+ i)))) (incf ans (aref c (1- (aref a i))))))
    (format t "~A~%" ans)))

(main)


Measured memory_bytes: 30440
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() + [i + 1] for i in range(n)]

n = i()
sp = ms(n)
ansli = [0] * n
for i in range(n):
    tmp = 1
    for j in range(n):
        if i != j:
            if sp[j][0] < sp[i][0]:
                tmp += 1
            elif sp[j][0] > sp[i][0]:
                tmp += 0
            else:
                if int(sp[j][1]) < int(sp[i][1]):
                    tmp += 0
                else:
                    tmp += 1
    ansli[i] = [tmp, i + 1]
ansli.sort()
for i in range(n):
    print(ansli[i][1])

Measured memory_bytes: 6484
#include<stdio.h>
int main()
{
    int a, b, target;

    // read line
    scanf("%d %d", &a, &b);
    if ( b > 9 && b < 100 ) {
        target = a*100 + b;
    }else if ( b < 10 ) {
        target = (a*10) + b;
    } else {
        target = (a*1000) + b;
    }
    for (int i=1;i<316;i++){
        if ( target == i*i ){
            printf("Yes\n");
             return 0;
        }
        if ( target < i*i) {
          break;
        }
    }
    printf("No\n"); 
    return 0;
}



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

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

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

#define INF INT_MAX/3

int n,m;
double p[22][22];
double sum[17][17][1<<16];
double dp[17][1<<16];

int main(){
  cin>>n>>m;
  rep(i,n)rep(j,m){
    cin>>p[j][i];
  }
  rep(S,1<<n){
    dp[m][S]=1.0;
    rep(i,n)sum[m][i][S]=1.0;
  }
  for(int i=m-1;i>=0;i--)for(int S=(1<<n)-1;S>=0;S--){
      rep(j,n){
        if(((S>>j)&1))continue;
        maxch(dp[i][S],(1.0-p[i][j])*dp[i][S|(1<<j)]+sum[i+1][j][S]*p[i][j]);
      }
      rep(j,n){
        if(!((S>>j)&1))continue;
        int T=S^(1<<j);
        sum[i][j][T]+=sum[i+1][j][T]*p[i][j]+(1.0-p[i][j])*dp[i][S];
      }
  }
  double res=0;
  rep(i,n)maxch(res,sum[0][i][0]);
  printf("%.10f\n", res);
  return 0;
}



Measured memory_bytes: 130640
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


n,m=map(int,input().split())
for i in make_divisors(m)[::-1]:
    if n*i<=m:print(i);break

Measured memory_bytes: 3060
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], i8[:], i8[:], i8[:]), cache=True)
def f(X1, Y1, X2, Y2):
    # x1,y1 から y が増える側に移動 vs x2,y2 から y が減る側に移動
    ret = 10**18
    key1 = (X1 << 32) + Y1
    key2 = (X2 << 32) + Y2
    ind = key1.argsort()
    X1, Y1, key1 = X1[ind], Y1[ind], key1[ind]
    ind = key2.argsort()
    X2, Y2, key2 = X2[ind], Y2[ind], key2[ind]
    js = np.searchsorted(key2, key1)
    for i in range(len(key1)):
        j = js[i]
        if j == len(key2):
            continue
        if X1[i] != X2[j]:
            continue
        ret = min(ret, Y2[j] - Y1[i])
    return ret

N = int(readline())
X = []
Y = []
U = []
for _ in range(N):
    x, y, u = readline().split()
    X.append(int(x))
    Y.append(int(y))
    U.append(u)

X = np.array(X, np.int64)
Y = np.array(Y, np.int64)
U = np.array(U, 'S1')

i_u = U == b'U'
i_r = U == b'R'
i_d = U == b'D'
i_l = U == b'L'

Xu, Yu = X[i_u], Y[i_u]
Xr, Yr = X[i_r], Y[i_r]
Xd, Yd = X[i_d], Y[i_d]
Xl, Yl = X[i_l], Y[i_l]

INF = 10**18
ans = INF
ans = min(ans, f(Xu, Yu, Xd, Yd))  # 上、下
ans = min(ans, f(Yr, Xr, Yl, Xl))  # 右、左
ans = min(ans, f(Xr + Yr, Xr - Yr, Xu + Yu, Xu - Yu))  # 右、上
ans = min(ans, f(Xu - Yu, Xu + Yu, Xl - Yl, Xl + Yl))  # 上、左
ans = min(ans, f(Xr - Yr, Xr + Yr, Xd - Yd, Xd + Yd))  # 右、下
ans = min(ans, f(Xd + Yd, Xd - Yd, Xl + Yl, Xl - Yl))  # 下、左
print('SAFE' if ans == INF else 5 * ans)

Measured memory_bytes: 125584
#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;
#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));



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

	string N,H,K;
	cin >> N>>H>>K;
	
	if (N[N.size() - 1] == H[0] && H[H.size() - 1] == K[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vlong a(n);
  int sum=0,sum2=0,sum4=0;
  ll tmp=1;
  rep(i,n){
    cin>>a[i];
    if(a[i]%4==0){
      sum4++;
    }
    else if(a[i]%2==0){ 
      sum2++;
    }
    else{
      sum++;
    }
  }
  if(sum2==0){
    if(sum<=sum4+1){
      cout<<"Yes"<<'\n';
    }
    else{
      cout<<"No"<<'\n';
    }
  }
  else{
    sum++;
    if(sum<=sum4+1){
      cout<<"Yes"<<'\n';
    }
    else{
      cout<<"No"<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
long long int Max( long long int a, long long int b ){
    return a > b ? a : b ;
}

long long int sol( long long int w[] , long long int v[] , long long int N , long long int W ){
    long long int dp[W+1] ;
    for( long long int i = 0 ; i < W + 1 ; i++ ) dp[i] = 0 ;
    for( long long int i = 0 ; i < N ; i++ ){
        long long int pick_w = w[i], pick_v = v[i] ;
        for( long long int j = W ; j >= pick_w ; j-- ){
            dp[j] = Max( dp[j] , dp[j-pick_w] + pick_v ) ;
        }

    }
    return dp[W] ;
}


int main(){
    long long int N , W ;
    cin >> N >> W ;
    long long int w[N], v[N] ;
    for( long long int i = 0 ; i < N ; i++ ){
        cin >> w[i] >> v[i] ;
    }
    cout << sol( w , v , N , W )  << "\n" ;
    return 0 ;
}

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

int main(){
    long long N, A, B;
    cin >> N >> A >> B;
    long long ans = 0, rep = A+B;
    long long resident = N-rep*(long long)(N/rep);
    ans += A*(long long)(N/rep);
    if(resident<=A){
        ans += resident;
    }
    else{
        ans += A;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    string s; cin >> s;

    string ans = "";
    rep(i, s.size()){
        char tmp = s[i] + n;
        if(tmp - '0' > 42){
            int r = 43 - (s[i] - '0');
            tmp = 'A' + (n - r);
        }
        ans += tmp;
    }
    OP(ans);
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    REP(i, n+1) cin >> a[i];

    if(a[0] >= 1) {
        if(a[0] == 1) {
            REPN(i, 1, n+1) {
                if(a[i] != 0) {
                    cout << -1 << endl;
                    return 0;
                }
            }
            cout << 1 << endl;
            return 0;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    REPN(i, 1, n) {
        if(a[i] > pow(2, i) - 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    if(a[n] > pow(2, n)) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> ruiseki(n+2, 0);
    REP(i, n+1) ruiseki[i+1] = ruiseki[i] + a[i];

    ll ans = 1;
    ll pre = 1;

    REPN(i, 1, n+1) {
        ll tmp = ruiseki[n+1] - ruiseki[i];
        //cout << pre << " " << a[i] << " " << tmp << endl;
        pre = min(pre*2, tmp);
        ans += pre;
        pre -= a[i];
        if(pre <= 0 && (i != n)) {
            cout << -1 << endl;
            return 0;
        }
        //cout << pre << endl;
    }

    if(pre != 0) {
        cout << -1 << endl;
        return 0;
    }

    if(ans <= 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;



}

Measured memory_bytes: 5352
import collections
n,m = list(map(int,input().split()))
tower_high = list(map(int,input().split()))
good_tower = [1]*n

def check_tower(a,b):
    if tower_high[a]<tower_high[b]:
        good_tower[a]=0
    elif tower_high[a] > tower_high[b]:
        good_tower[b]=0
    else:
        good_tower[a]=0
        good_tower[b]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    check_tower(a-1,b-1)
print(good_tower.count(1))


Measured memory_bytes: 20648
//AtCoder ABC113 C - ID
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
struct Dat {
    ll p; //県no
    ll y; //年
    ostringstream ss;
    void make_id(ll no){
        ss << std::setw(6) << std::setfill('0') << p;
        ss << std::setw(6) << std::setfill('0') << no;
    }
};
int main() {
    ll N,M; cin>>N>>M;
    vector<Dat> pym(M);;
    for(auto && py:pym){
        cin>>py.p>>py.y;
    }
    unordered_map<ll,vector<ll>> kentbl; //p県,市のindex
    for(ll i=0;i<pym.size();++i){
        ll pno=pym[i].p;
        kentbl[pno].push_back(i);
    }
    for(auto&& m:kentbl){
        auto& vec=m.second;
        sort(vec.begin(),vec.end(), [&](const auto&a,const auto&b){
            return (pym[a].y < pym[b].y);
        });
        //idつくる
        for(ll i=0;i<vec.size();++i){
            ll no=i+1;
            pym[vec[i]].make_id(no);
        }
    }
    //output
    for(auto && py:pym){
        cout<<py.ss.str()<<endl;
    }
    return 0;
}

Measured memory_bytes: 100772
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto str = sread();
    long cnt;
    foreach(c;str){
        cnt += (c == '2')? 1:0;
    }
    cnt.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define us unordered_set
#define f first
#define s second
#define pb push_back
#define MOD 1000000007
#define MOD2 1000000009
#define BASE 29
#define BASE2 31
#define eps 1e-9
#define INF 1000000002

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<pii,pii> piiii;
const int N = 200002;
const int BIT = 30;

int main() {
    ll n;
    cin>>n;
    ll mini = 1e18;
    for(ll i = 1;i*i<=n;i++) {
        if(n % i)
            continue;
        ll j = n/i;
        mini = min(mini, i-1 + j - 1);
    }
    cout<<mini;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
int main() {
    int  x;
    I(x);
    if(x>=30)PC("Yes");
    else PC("No");
    NL;
    return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char O[50],E[50],ori[100];
    memset(ori,0,sizeof(ori));
    scanf("%s",O);
    scanf("%s",E);
    int len=strlen(O);
    int len1=strlen(E);
    for(i=0; i<len; i++)
        ori[(i+1)*2-1]=O[i];
    for(i=0; i<len1; i++)
        ori[(i+1)*2]=E[i];
    for(i=1; i<len+len1+1; i++)
        printf("%c",ori[i]);
    return 0;
}


Measured memory_bytes: 128
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 100005;
int fa[maxn];
int ind[maxn];
vector<int> G[maxn];
int n,m;
typedef pair<int,int> P;
void solve(int x) {
	fa[x]=0;
	queue<int> q;
	q.push(x);
	while(!q.empty()) {
		int u=q.front(); q.pop();
		for(int i=0;i<G[u].size();i++) {
			int s=G[u][i];
			if(ind[s]>1) ind[s]--;
			else if(ind[s]==1) {
				ind[s]--;
				fa[s]=u;
				q.push(s);
			}
		}
	}
}

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<=n-1+m;i++) {
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		ind[v]++;
	}
	for(int i=1;i<=n;i++) {
		if(ind[i]==0) {
			solve(i);
			break;
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",fa[i]);
	return 0;
}














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

int f(int n){
	int sum = 0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int ans = 0;
	for(int i=1;i<=n;++i){
		int x = f(i);
		if(x >= a && x <= b) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2) 
#include<iostream>
 
using namespace std;
const int mod=998244353;
long long a[100010];
long long n,x;
long long ksm(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1){
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
 
int main(){
	scanf("%lld",&n);
	int flag=0;
	scanf("%lld",&x);
	int ans=x;
	if(x!=0) flag=1;
	for(int i=1;i<n;i++){
		scanf("%lld",&x);
		a[x]++;
		if(x==0) flag=1;
		if(x>ans){
			ans=x;
		}
	}
	
	if(flag){
		printf("0\n");
	}
	else{
	long long sum=1;
		for(int i=1;i<ans;i++){
			if(a[i]==0){
				flag=1;
				break;
			}
			sum*=ksm(a[i],a[i+1]);
			sum%=mod;
		}
		if(flag) printf("0\n");
		else printf("%lld\n",sum);
	}
	return 0;
} 

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
// 大きい順
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vl vector<ll>
const  long long INF = 1LL << 60;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

int main(){
int N; cin >> N;
map<ll,ll> A;
rep(i,N) {
    ll a; cin >> a;
    if(!A.count(a)){
        A[a] = 1;
    }
    else{
        A[a] += 1;
    }
}
vl x;
for(auto u:A){
    if(u.second >= 2){
        x.push_back(u.first);
    }
    if(u.second >= 4){
        x.push_back(u.first);
    }
}
if(x.size() >= 2){
sort(rall(x));
cout << x[0] * x[1] << endl;
}
else{
    cout << 0 << endl;
}
}

Measured memory_bytes: 6528
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
  int n;
  cin >> n;

  map<string, int> m;
  int max_count = 0;

  Rep(i, n) {
    string s;
    cin >> s;
    max_count = max(max_count, ++m[s]);
  }

  for (auto s : m) {
    if (s.second == max_count) {
      cout << s.first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int H, W, K; 
  cin >> H >> W >> K;

  

  vector<vector<int>> dp(H+1, vector<int>(W, 0));
  dp[0][0] = 1;
  
  REP(i, H) REP(j, W) REP(k, (1<<(W-1))){
    bool ok = true;
    REP(l, W-2){
      if(((k >> l)&1) && ((k >> (l+1))&1)) ok = false;
    }
    if(ok){
      if(j >= 1 && ((k >> (j-1))&1)){
        dp[i+1][j-1] += dp[i][j];
        dp[i+1][j-1] %= MOD;
      }else if(j <= W-2 && ((k >> j)&1)){
        dp[i+1][j+1] += dp[i][j];
        dp[i+1][j+1] %= MOD;
      }else{
        dp[i+1][j] += dp[i][j];
        dp[i+1][j] %= MOD;
      }
    }
  }

  cout << dp[H][K-1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100


int main(){

  int M[N][N];
  int i,j,n,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }



  return 0;
}

Measured memory_bytes: 636
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
from functools import reduce
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    M = max(A)

    if reduce(gcd, A) != 1:
        print("not coprime")
        return

    # linear sieve
    sieve = list(range(M + 1))
    primes = []
    for i in range(2, M + 1):
        if sieve[i] == i:
            primes.append(i)
        for p in primes:
            if sieve[i] < p or i * p > M:
                break
            sieve[i * p] = p

    # remove prime duplicates
    f = list(range(M + 1))
    g = [1] * (M + 1)
    for i in range(2, M + 1):
        j = 0
        for j in range(i * i, M + 1, i * i):
            g[j] = i
        f[i] = f[i // g[i]]

    # prime factorization
    used = [False] * (M + 1)
    for a in map(lambda a : f[a], A):
        while a != 1:
            p = sieve[a]
            if used[p]:
                print("setwise coprime")
                return
            used[p] = True
            a //= p
    print("pairwise coprime")
resolve()

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

d = lambda a, b, n: sum([abs(x - y) ** n for x, y in zip(a, b)]) ** (1/n)
print(d(a, b, 1))
print(d(a, b, 2))
print(d(a, b, 3))
print(max([abs(x - y) for x, y in zip(a, b)]))



Measured memory_bytes: 5648
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
typedef long long ll;

int N,M,L,K,A,H;
int dist[101][101];

struct State {
	int pos, time;
};

bool operator<(const State& l, const State& r) {
	return l.time > r.time;
}

int main() {
	while(true) {
		cin >> N >> M >> L >> K >> A >> H;
		if (N == 0) break;
		memset(dist, -1, sizeof(dist));
		vector<int> freezer;
		for (int i = 0; i < L; ++i) {
			int l;
			cin >> l;
			freezer.push_back(l);
		}
		freezer.push_back(H);
		for (int i = 0; i < K; ++i) {
			int X, Y, T;
			cin >> X >> Y >> T;
			dist[X][Y] = dist[Y][X] = T;
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (dist[i][j] == -1) continue;
				for (int k = 0; k < N; ++k) {
					if (dist[i][k] == -1) continue;
					if (dist[j][k] == -1 || dist[j][k] > dist[j][i] + dist[i][k]) {
						dist[j][k] = dist[k][j] = dist[j][i] + dist[i][k];
					}
				}
			}
		}
		priority_queue<State> q;
		q.push({A, 0});
		vector<int> mi(N, 1 << 30);
		int ans = -1;
		while(!q.empty()) {
			State cur = q.top();
			q.pop();
			if (cur.pos == H) {
				ans = cur.time;
				if (ans > M) ans += ans - M;
				break;
			}
			mi[cur.pos] = cur.time;
			for (int n : freezer) {
				int len = dist[cur.pos][n];
				if (len == -1 || len > M) continue;
				if (cur.time + len >= mi[n]) continue;
				q.push({n, cur.time + len});
				mi[n] = cur.time + len;
			}
		}
		if (ans == -1) {
			cout << "Help!" << endl;
		} else {
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1268
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}


int main() {
    ll fib[31];
    fib[1] = 1;
    fib[2] = 2;
    fib[3] = 4;
    for (int i = 4; i <= 30; i++) {
        fib[i] = fib[i-1]+fib[i-2]+fib[i-3];
    }
    while (true) {
        int t; cin >> t;
        if (!t) break;
        cout << ((fib[t]+9)/10+364)/365 << endl;
    }
    return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

int main() {
    ll N,M;
    cin >> N >> M;
    vector<Pll> A(M);
    rep(i,M){
        ll a,b;
        cin >> a >> b;
        A[i]=Pll(b,a);
    }
    sort(A.begin(),A.end());
    ll now=0,ans=0;
    rep(i,M){
        if (now<=A[i].second){
            ans++;
            now=A[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
a = []
for i in range(5):
  a.append(int(input()))

b = [[i, i%10] for i in a]

b.sort(key=lambda x:x[1])
s=0
flag = 0
for i in range(5):
    if b[i][1] == 0:
        s += b[i][0]
    else:
        if flag == 0:
            s += b[i][0]
            flag = 1
        else :
            s += (b[i][0]+10)//10*10
print(s)

Measured memory_bytes: 3064
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int n; cin >> n;
  int l = n % 10;
  if (l == 3) {
    cout << "bon" << '\n';
  } else if (l == 0 || l == 1 || l == 6 || l == 8) {
    cout << "pon" << '\n';
    return 0;
  } else {
    cout << "hon" << endl;
  }
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && c == a) cout << 1 << endl;
    else if(a == b || b == c || c == a) cout << 2 << endl; 
    else cout << 3  << endl;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s;
    cin >> s;
    int a = 0;
    for(int i=0; i<4; i++){
        if(s[i] == '+') a++;
        else a--;
    }
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a1(n);
  vector<int> a2(n);
  REP(i,n){
    cin >> a1[i];
  }
  REP(i,n){
    cin >> a2[i];
  }
  
  int ans = 0;
  REP(i,n){
    int sum = 0;
    REP(j,i+1){
      sum += a1[j];
    }
    REP(j,n-i){
      sum += a2[n-j-1];
    }
    ans = max(ans,sum);
  }
  

  cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>


using std::string;

int main()
{
    string target;
    std::cin >> target;

    int cnt = 0;

    string in;
    while (true) {
        std::cin >> in;

        if (in == "END_OF_TEXT") {
            break;
        }

        transform(in.begin(), in.end(), in.begin(), tolower);

        if (in == target) {
            cnt++;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 1192