akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll  long long
//#define int long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
const int N=2e5+10;
const int mod=998244353;
using namespace std;


const double eps=1e-8;
inline int sgn(double x){return x<-eps?-1:(x>eps?1:0);}
inline double pf(double x){return x*x;}
struct Point
{
   double x,y;
   Point(){}
   Point(double x,double y):x(x),y(y){}
   Point(pair<double,double> p):x(p.first),y(p.second){}
   bool operator == (const Point& p)const {return sgn(x-p.x)==0&&sgn(y-p.y)==0;}
   bool operator != (const Point& p)const {return sgn(x-p.x)!=0||sgn(y-p.y)!=0;}
   inline double length()const {return sqrt(pf(x)+pf(y));}
   inline double angle()const{return atan2(y,x);}
};
typedef Point Vector;
Vector operator + (Vector a,Vector b){return Vector(a.x+b.x,a.y+b.y);}
Vector operator - (Vector a,Vector b){return Vector(a.x-b.x,a.y-b.y);}
Vector operator * (Vector a,double mul){return Vector(a.x*mul,a.y*mul);}
Vector operator / (Vector a,double div){return Vector(a.x/div,a.y/div);}
inline double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
inline double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
inline double dis(Vector a,Vector b){return sqrt(pf(a.x-b.x)+pf(a.y-b.y));}
inline double angle(Vector a,Vector b){return acos(dot(a,b)/a.length()/b.length());}
Vector rot(Vector a,double rad){return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));}//ni shi zhen
Vector unit(Vector v){return v/v.length();}// 单位向量
Vector normal(Vector a){return Vector(-a.y,a.x);} // 法向量
struct Line
{
   Point p1,p2;
   Vector v;
   Line(){}
   Line(Point p1,Point p2,Vector v): p1(p1),p2(p2),v(v){}
};
double x[5],y[5];
int jiao()
{
	 if(max(x[1],x[2])<min(x[3],x[4])||min(x[1],x[2])>max(x[3],x[4])||max(y[1],y[2])<min(y[3],y[4])||min(y[1],y[2])>max(y[3],y[4])) 
   	  {
   	  	 return 0;
   	  }	
   	  double p1=cross(Point(x[3]-x[1],y[3]-y[1]),Point(x[2]-x[1],y[2]-y[1])); 
   	  double p2=cross(Point(x[4]-x[1],y[4]-y[1]),Point(x[2]-x[1],y[2]-y[1]));
   	  double p3=cross(Point(x[1]-x[3],y[1]-y[3]),Point(x[4]-x[3],y[4]-y[3]));  
   	  double p4=cross(Point(x[2]-x[3],y[2]-y[3]),Point(x[4]-x[3],y[4]-y[3]));   
   	  if(p1*p2<=0&&p3*p4<=0) return 1;
   	  return 0;
}
double dispointline(Point p,Line l)
{
	return fabs(cross(p-l.p1,l.v)/l.v.length());
}
double dispointseg(Point p,Line s)
{
	double ans=min(dis(p,s.p1),dis(p,s.p2));
	if(dot(p-s.p1,s.p2-s.p1)<-eps||dot(p-s.p2,s.p1-s.p2)<-eps) return ans;
	return dispointline(p,s);
}
int32_t main()
{
   //ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
   int q; scanf("%d",&q);
   while(q--)
   {
   	  for(int i=1;i<=4;i++) scanf("%lf%lf",&x[i],&y[i]);
   	  if(jiao()) {puts("0"); continue; }
   	  Line l1=Line(Point(x[1],y[1]),Point(x[2],y[2]),Vector(x[2]-x[1],y[2]-y[1]));
   	  Line l2=Line(Point(x[3],y[3]),Point(x[4],y[4]),Vector(x[4]-x[3],y[4]-y[3]));
   	  double ans=min(dispointseg(l1.p1,l2),dispointseg(l1.p2,l2));
   	  ans=min(ans,min(dispointseg(l2.p1,l1),dispointseg(l2.p2,l1)));
   	  printf("%.10f\n",ans);
   }
return 0;
}
/*

*/


Measured memory_bytes: 3252
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int N;
vector<ll> a(410);
vector<vector<ll>> Wa(410, vector<ll>(410)), memo(410, vector<ll>(410, -1));
void init(int N){
    vector<ll> w(N, 0);
    for(int i = 1; i < N; i++) w.at(i) = w.at(i-1) + a.at(i);
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            Wa.at(i).at(j) = w.at(j) - w.at(i) + a.at(i);
        }
    }
}

ll dfs(int left, int right){
    if(memo.at(left).at(right) != -1) return memo[left][right];
    if(right == left)return 0;
    ll res = INFL;
    for(int i = left; i < right; i++){
        res = min(res, dfs(left, i) + dfs(i+1, right) + Wa.at(left).at(right));
    }
    return memo[left][right] = res;
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a.at(i);
    init(N);
    cout << dfs(0, N-1) << endl;
}

Measured memory_bytes: 2944
N, M = map(int,input().split())
H = list(map(int,input().split()))
ans = [0]*N
for _ in range(M):
    A, B = map(int,input().split())
    if H[A-1] >= H[B-1]:
        ans[B-1] = 1
    if H[A-1] <= H[B-1]:
        ans[A-1] = 1
print(ans.count(0))

Measured memory_bytes: 20028
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define f first
#define s second

int main(){
  int n, m;
  int Friend[501];
  while(cin >> n >> m){
    if(n == 0 && m == 0) break;
    memset(Friend, 0, sizeof(Friend));
    pair<int, int> contact[10001];
    for(int i = 0 ; i < m ; i++){
      cin >> contact[i].f >> contact[i].s;
      if(contact[i].f > contact[i].s) swap(contact[i].f, contact[i].s);
      if(contact[i].f == 1) Friend[contact[i].s] = 1;
    }

    for(int i = 0 ; i < m ; i++){
      if(Friend[contact[i].f] == 1 && Friend[contact[i].s] == 0){
	Friend[contact[i].s] = 2;
      }
      else if(Friend[contact[i].s] == 1 && Friend[contact[i].f] == 0){
	Friend[contact[i].f] = 2;
      }
    }
    int ans = 0;
    for(int i = 2 ; i <= n ; i++){
      if(Friend[i] == 1 || Friend[i] == 2) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
W,H,N = map(int,input().split())

maxx = W
minx = 0
maxy = H
miny = 0

for i in range(N):

    x,y,a = map(int,input().split())

    if a == 1:

        minx = max(minx,x)

    if a == 2:

        maxx = min(maxx,x)
        
    if a == 3:

        miny = max(miny,y)

    if a == 4:

        maxy = min(maxy,y)


print ( max (0,maxx-minx) * max (0,maxy-miny))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 100000000000000
class WarshallFloyed{
public:
	int V; //????????°
	ll D[256][256]; //i??????j???????????????D[i][j]
	WarshallFloyed(){}
	WarshallFloyed(int _V){
		V = _V;
	}
	void init(){
		for(int i = 0; i < V; ++i){
			for(int j = 0; j < V; ++j){
				if(i == j){
					D[i][j] = 0;
				}
				else{
					D[i][j] = INF;
				}
			}
		}
	}
	bool add_edge(int from,int to,ll cost){
		if(D[from][to] != INF)return false;
		D[from][to] = cost;
		return true;
	}
	bool getShortestPath(){
		for(int k = 0; k < V; ++k){
			for(int i = 0; i < V; ++i){
				for(int j = 0; j < V; ++j){
					D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
				}
			}
		}
		return true;
	}
	bool isNegativeCycle(){
		for(int i = 0; i < V; ++i){
			if(D[i][i] < 0){
				return true;
			}
		}
		return false;
	}

	void print(){
		for(int i = 0; i < V; ++i){
			for(int j = 0; j < V; ++j){
				if(D[i][j] >= 1e9*2) printf("INF%c",j==V-1?'\n':' ');
				else printf("%lld%c",D[i][j],j==V-1?'\n':' ');
			}
		}
	}
};


int main(){
	int V,E;
	scanf("%d%d",&V,&E);
	WarshallFloyed W = WarshallFloyed(V);
	W.init();
	for(int i = 0; i < E; ++i){
		int a,b;
		ll c;
		scanf("%d%d%lld",&a,&b,&c);
		W.add_edge(a,b,c);
	}
	W.getShortestPath();
	if(W.isNegativeCycle()){
		puts("NEGATIVE CYCLE");
	}
	else W.print();
	return 0;
}

Measured memory_bytes: 1396
h,w=map(int, input().split())
s=[list(input().split()) for i in range(h)]
alp="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(h):
  for j in range(w):
    if s[i][j]=="snuke":
      print(alp[j]+str(i+1))
      break


Measured memory_bytes: 9072
#include "iostream"
#include "cstdlib"
using namespace std;

int main(){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  if (abs(b-a)>=10E18){
    cout<<"Unfair\n";
  }else{
    if(k%2==0){
    cout<<(a-b);
  }else{
    cout<<(b-a);
  }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 62
int main(){
    ll a,b;cin>>a>>b;
    if(a==b){
	cout<<1<<endl;
	return 0;
    }
    ll i;
    for(i=(1LL<<N);i;i>>=1){
	if((a&i)!=(b&i))break;
	if(a&i)a-=i;
	if(b&i)b-=i;
    }
    ll j;
    for(j=i>>1;j;j>>=1){
	if(b&j)break;
    }
    if(j==0)j++;
    else j<<=1;
    ll ans=i-a;
    if(j<=a)ans=ans*2+j;
    else ans+=i;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int K;
  cin>>K;
  if(7%K==0) cout<<1<<endl;
  else{
    int i=2;
    long long ten=1;
    long long amari=7%K;
    int judge=0;
    while(i<=K){
      ten=(ten*10)%K;
      amari=(amari+ten*7)%K;
      if(amari==0){
        cout<<i<<endl;
        judge++;
        break;
      }
      i++;
    }
    if(judge==0) cout<<-1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3184
/*
 * ----------------------------------------------------------------------------
 *  (: Bismillahir Rahmanir Rahim :) 
 * File: /home/grim/Programming/Atcoder/Today/D_Friends.cpp
 * Project: /home/grim/Programming/Atcoder/Today
 * Created Date: Saturday, August 29th 2020, 6:37:06 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Sat Aug 29 2020
 * Modified By: Grim Firefly :)
 * -----
 *   ________        .__           ___________.__                  _____ .__          
 *  /  _____/_______ |__|  _____   \_   _____/|__|_______   ____ _/ ____\|  |  ___.__.
 * /   \  ___\_  __ \|  | /     \   |    __)  |  |\_  __ \_/ __ \\   __\ |  | <   |  |
 * \    \_\  \|  | \/|  ||  Y Y  \  |     \   |  | |  | \/\  ___/ |  |   |  |__\___  |
 *  \______  /|__|   |__||__|_|  /  \___  /   |__| |__|    \___  >|__|   |____// ____|
 *         \/                  \/       \/                     \/              \/     
 * 
 *           |\_|\
 *           | a_a\
 *           | | "]
 *       ____| '-\___
 *      /.----.___.-'\
 *     //        _    \
 *    //   .-. (GF)  /|
 *   |'|  /\:  .--  / \
 *  // |-/  \_/____/\/~|
 * |/  \ |  []_|_|_] \ |
 * | \  | \ |___   _\ ]_}
 * | |  '-' /   '.'  |
 * | |     /    /|:  | 
 * | |     |   / |:  /\
 * | |     /  /  |  /  \
 * | |    |  /  /  |    \
 * \ |    |/\/  |/|/\    \
 *  \|\ |\|  |  | / /\/\__\
 *   \ \| | /   | |__
 *        / |   |____)
 *        |_/
 * ----------------------------------------------------------------------------
 */

#include <bits/stdc++.h>
using namespace std;
#define sz 100
vector<int> parent;
void make_set(int n)
{
    parent[n] = n;
}
int find(int x)
{
    if (parent[x] == x)
        return x;
    parent[x] = find(parent[x]);
    return parent[x];
}
void Union(int a, int b)
{
    int u = find(a);
    int v = find(b);
    if (u != v)
        parent[u] = v;
}
int main()
{
    int n, k;
    cin >> n >> k;
    parent.resize(n + 1);
    for (int i = 1; i <= n; i++)
        make_set(i);
    int a, b;
    for (int i = 0; i < k; i++)
    {
        cin >> a >> b;
        Union(a, b);
    }
    int mx = 0;
    map<int, int> MP;
    for (int i = 1; i <= n; i++)
    {
        find(i);
        MP[parent[i]]++;
        mx = max(MP[parent[i]], mx);
    }

    // cout << endl;
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 13468
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const long long inf=1e18L;
int main(int argc, char const *argv[]) {

    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt","r",stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,w;
    cin>>n>>w;
    vector<int>weight(n),value(n);
    for(int i=0;i<n;i++) {
        cin>>weight[i]>>value[i];
    }
    long long max_profit=accumulate(value.begin(),value.end(),0);
    vector<vector<long long>>dp(n+1,vector<long long>(max_profit+1,inf));
    dp[0][0]=0;
    for(int i=1;i<=n;i++) {
        int val=value[i-1];
        int wt=weight[i-1];
        for(int j=0;j<=max_profit;j++) {
            if(j<val) {
                dp[i][j]=dp[i-1][j];
            }
            else {
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-val]+wt);
            }
        }
    }
    long long ans=0;
    for(long long val=0;val<=max_profit;val++) {
        if(dp[n][val]<=w) {
            ans=max(ans,val);
        }
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	string s;
	cin >> s;
	int n=s.length();
	int i=0;
	int count=0;
	int ans[n];
	FOR(j,n) ans[j]=0;
	
	
	for(int i=n-1;i >0;i--){

		if(s[i]=='C' && s[i-1]=='B') count++;
		else if(i < n-1 && s[i]=='B' && s[i+1]=='C') ;
		else if(s[i]!='A') count=0;
		else  ans[i]=count;
		
	}
	if(s[i]=='A') ans[0]=count;
	ll sum=0;
	FOR(i,n) sum+=ans[i];
	cout << sum;

	return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int r;
    cin >> r;
    cout << setprecision(12) << 2 * r * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node{
	int key;
	Node*left,*right,*parent;
};

Node *root, *NIL;

void insert(int k){
	Node *y=NIL;
	Node *x=root;
	Node *z;
	
	z=(Node*)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(z->key<x->key)
			x=x->left;
		else 
			x=x->right;
	}
	z->parent=y;
	if(y==NIL)
		root=z; //very important
	else{
		if(z->key<y->key)
			y->left=z;
		else
			y->right=z;
	}
}

Node* getMinimum(Node*x){
	while(x->left!=NIL) x=x->left;
	return x;
}

Node *successor(Node *x){
	if(x->right!=NIL) return getMinimum(x->right);
	Node *y=x->parent;
	while(y!=NIL && x==y->right){
		x=y;
		y=y->parent;
	}
	return y;
}

void treeDelete(Node*z){
	Node *y;
	Node *x;

	if(z->left==NIL || z->right==NIL) 
		y=z;
	else y=successor(z);

	if(y->left!=NIL) x=y->left;
	else x=y->right;

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

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

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

	free(y);
}




void inorder(Node *u){
	if(u==NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node*u){
	if(u==NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

Node* find(Node*u, int k){
	while(u!=NIL && k!=u->key){
		if(k<u->key) u=u->left;
		else u=u->right;
	}
	return u;
}

int main(){
	//freopen("data.in","r",stdin);
	int n,x;
	string com;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>com;
		if(com[0]=='f'){
			scanf("%d",&x);
			Node*t=find(root,x);
			if(t!=NIL) printf("yes\n");
			else printf("no\n");
		}else if(com=="insert"){
			scanf("%d",&x);
			insert(x);
		}
		else if(com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if(com=="delete"){
			scanf("%d",&x);
			treeDelete(find(root,x));
		}
	}
		return 0;
}

Measured memory_bytes: 21900
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N, M;
vector<int> link[100000];

int flg[100000];

signed main()
{
	cin >> N >> M;
	REP(i, M)
	{
		int a, b;
		cin >> a >> b;
		link[a - 1].push_back(b - 1);
		link[b - 1].push_back(a - 1);
	}

	stack<int> s;
	s.push(0);
	flg[0] = 1;
	bool is_bip = true;

	while (s.size() > 0)
	{
		int n = s.top();
		s.pop();
		int f = flg[n];
		for (int l : link[n])
		{
			if (flg[l] == 0)
			{
				flg[l] = -f;
				s.push(l);
			}
			else
			{
				if (flg[n] == flg[l])
				{
					is_bip = false;
					break;
				}
			}
		}
	}

	int all = 0;
	if (is_bip)
	{
		int cnt = 0;
		REP(i, N)
		{
			if (flg[i] == 1) cnt++;
		}
		all = cnt * (N - cnt);
	}
	else
	{
		for (int i = 0; i < N; i++)
		{
			all += N - (i + 1);
		}
	}
	cout << (all - M) << endl;
}



Measured memory_bytes: 7424
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int c[3][3];
    int b1,b2,b3;
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            cin>>c[i][j];
        }
    }
    bool ret = false;
    for(int a1=0;a1<=100;++a1){
        b1=c[0][0]-a1;
        b2=c[0][1]-a1;
        b3=c[0][2]-a1;
        if(b1<0 || b2<0 || b3<0)break;
        for(int a2=0;a2<=100;++a2){
            if(c[1][0]==a2+b1 && c[1][1]==a2+b2 && c[1][2]==a2+b3){
                for(int a3=0;a3<=100;++a3){
                    if(c[2][0]==a3+b1 && c[2][1]==a3+b2 && c[2][2]==a3+b3){
                        ret = true;
                        break;
                    }
                }
            }
            if(ret)break;
        }
        if(ret)break;
    }
    ret ==true ? cout<<"Yes"<<endl : cout << "No"<< endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n;
    cin >> n;
    vector<ll> mood(n);
    for(int i = 0; i<n; i++){
        cin >> mood[i];
    } 
    sort(mood.rbegin(), mood.rend());
    // pcont(mood);
    ll ans = mood[0];

    int ind = 1;
    n-=2;
    while(n > 1){
        ans += 2*mood[ind];
        ind++;
        n-=2;
    }

    if(n == 1){
        ans+=mood[ind];
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4748
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;

int w,h,s;
string g[50],ms[10][50];
bool f[1<<10][50][50];
int d[1<<10][2][50][50];
int sx,sy;
int dy[] = { -1,0,1,0}, dx[] = {0,1,0,-1};


int main(){
  cin >> w >> h;
  for(int i=0;i<h;i++){
    cin >> g[i];
    for(int j=0;j<w;j++){
      if(g[i][j] == '%'){
	sy = i;
	sx = j;
      }
    }
  }

  cin >> s;
  for(int i=0;i<s;i++)
    for(int j=0;j<h;j++)cin >> ms[i][j];

  for(int i=0;i<(1<<s);i++){
    for(int j=0;j<h;j++){
      for(int k=0;k<w;k++){
	d[i][0][j][k] = d[i][1][j][k] = -1;
	bool t = false;
	for(int l=0;l<s;l++){
	  if( (i>>l)&1 ){
	    if(ms[l][j][k] == '*')t = !t;
	  }
	}
	f[i][j][k] = t;
      }
    }
  }

  queue<P2> q;
  q.push(P2(P(0,0),P(sy,sx)));
  d[0][0][sy][sx] = 0;

  while(q.size()){
    P2 p = q.front(); q.pop();
    int s = p.fs.fs, fl = p.fs.sc, y = p.sc.fs, x = p.sc.sc;

    for(int i=0;i<4;i++){
      int ty = y + dy[i], tx = x + dx[i];
      if(g[ty][tx] == '#')continue;

      bool now = f[s][ty][tx];
      //cout << now << " " << ty << " " << tx << endl;
      if( (now == fl) && g[ty][tx] == '&'){
	cout << d[s][fl][y][x] + 1 << endl;
	return 0;
      }
      if( (now == fl) && g[ty][tx] == '^')continue;
      if( (now == fl) && 'A'<= g[ty][tx] && g[ty][tx] <= 'J')continue;
      if( (now != fl) && g[ty][tx] == '_')continue;
      if( (now != fl) && 'a'<= g[ty][tx] && g[ty][tx] <= 'j')continue;
      if( (now != fl) && (g[ty][tx] == '&' || g[ty][tx] == '%') )continue;

      if(d[s][fl][ty][tx]<0){
	d[s][fl][ty][tx] = d[s][fl][y][x] + 1;
	q.push(P2(P(s,fl),P(ty,tx)));
      }
    }

    if( (g[y][x] == '|') && (d[s][1-fl][y][x] < 0) ){
      d[s][1-fl][y][x] = d[s][fl][y][x] + 1;
      q.push(P2(P(s,1-fl),P(y,x)));
    }

    bool now = f[s][y][x];
    if( (now==fl) && 'a'<=g[y][x] && g[y][x]<='j'){
      int tmp = g[y][x] - 'a';
      int st = s ^ (1<<tmp);
      int tfl = fl;
      if(ms[tmp][y][x] == '*')tfl = 1-fl;
      if(d[st][tfl][y][x]<0){
	d[st][tfl][y][x] = d[s][fl][y][x] + 1;
	q.push(P2(P(st,tfl),P(y,x)));
      }
    }
    if( (now!=fl) && 'A'<=g[y][x] && g[y][x]<='J'){
      int tmp = g[y][x] - 'A';
      int st = s ^ (1<<tmp);
      int tfl = fl;
      if(ms[tmp][y][x] == '*')tfl = 1-fl;
      if(d[st][tfl][y][x]<0){
	d[st][tfl][y][x] = d[s][fl][y][x] + 1;
	q.push(P2(P(st,tfl),P(y,x)));
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 24480
module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Array
import           Data.Char
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

parseInt = fst . fromJust . BS.readInt
readInt = parseInt <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine

main = do
  [a, b] <- readIntList
  print $ leastCommonMultiple a b

leastCommonMultiple a b = (a * b) `div` greatestCommonDivisor a b
greatestCommonDivisor a b 
  | b == 0 = a
  | otherwise = greatestCommonDivisor b (a `mod` b)


Measured memory_bytes: 380
// 21
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
const int mod = 1e9 + 7;

// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}

template <class A, class B>
void addSelf(A &a, B &b) {
  a += b;
  if (a >= mod) a -= mod;
}

template <class A, class B>
void subSelf(A &a, B &b) {
  a -= b;
  if (a < 0) a += mod;
}

// 3
void _main(int tc) {
  int n, K;
  cin >> n >> K;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  /************* Recursive ************* O(N*K*K) too slow
  vector<vector<li>> mem(n, vector<li>(K + 1, -1));
  function<int(int, int)> f = [&](int i, int k) -> int {
    if (i == n && k != 0) return 0;
    if (k < 0) return 0;
    if (i == n && k == 0) return 1;
    if (mem[i][k] != -1) return mem[i][k];
    li limit = min(k, v[i]);
    li ans = f(i + 1, k - limit);
    rep(given, limit - 1, -1) { ans = (ans + f(i + 1, k - given)) % mod; }
    return mem[i][k] = ans;
  };
  cout << f(0, K) << endl;
  *********** End Recursive ***********/

  vector<vector<int>> mem(n + 1, vector<int>(K + 1));
  rep(i, n + 1) mem[i][K] = 1;

  rep(i, n - 1, -1) {
    vector<int> pref = mem[i + 1];

    rep(used, 1, K + 1) { addSelf(pref[used], pref[used - 1]); }

    rep(used, K, -1) {
      int Left = used;
      int Right = used + min(v[i], K - used);
      mem[i][used] = pref[Right];
      if (Left > 0) subSelf(mem[i][used], pref[Left - 1]);

      // mem[i][used] = sum(mem[i + 1][Left...Right]) <- key to solve this
      // problem rep(usedHere, Right, Left - 1) {
      //   if (usedHere <= K) ans = (ans + mem[i + 1][usedHere]) % mod;
      // }
    }
  }
  cout << mem[0][0] << endl;
}
// 7
int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 40192
#include <iostream>

static const int MAX_WEIGHT = 50;
static const int MAX_HEIGHT = 50;

static int num_of_cicadas[MAX_WEIGHT][MAX_HEIGHT];
static int total_cicada[MAX_WEIGHT][MAX_HEIGHT];

void set_total_cicada(int weight, int height)
{
	for (int h = 0; h < height; h++)
	{
		for (int w = 0; w < weight; w++)
		{
			if (w == 0 && h == 0)
			{
				total_cicada[w][h] = 0;
			}
			else if (w == 0)
			{
				total_cicada[w][h] = total_cicada[0][h - 1] + num_of_cicadas[w][h];
			}
			else if (h == 0)
			{
				total_cicada[w][h] = total_cicada[w - 1][0] + num_of_cicadas[w][h];
			}
			else
			{
				total_cicada[w][h] = std::min( total_cicada[w - 1][h], total_cicada[w][h - 1]) + num_of_cicadas[w][h];
			}
		}
	}

	return;
}

int main()
{
	using namespace std;

	int weight,height;
	string buf;
	
	cin >> height >> weight;
	
	for (int h = 0; h < height; h++)
	{
		cin >> buf;
		for (int w = 0; w < weight; w++)
		{
			num_of_cicadas[w][h] = buf[w] - '0';
		}
	}
	
	set_total_cicada(weight, height);
	
	cout << total_cicada[weight - 1][height - 1] << endl;
	
	return 0;
}

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

int main() {
	char c;
	while (1) {
		cin.get(c);
		if (c == '\n')break;
		else if ('A' <= c && c <= 'Z')c += 'a' - 'A';
		else if ('a' <= c && c <= 'z')c -= 'a' - 'A';
		cout.put(c);
	}
	cout << endl;
		return 0;
}

Measured memory_bytes: 1112
using System;
using System.Collections.Generic;

public class Hello
{
    public static int flag = 0;
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        Dictionary<int,int> d = new Dictionary<int,int>();
        string[] sa = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            int temp = int.Parse(sa[i]);
            if (d.ContainsKey(temp)) d[temp]++;
            else d[temp] = 1;
        }
        List<int> keylist = new List<int>(d.Keys);
        long output = 0;
        while (keylist.Count > 0)
        {
            int temp = keylist[0];
            if (d[temp] > temp)
            {
                output += d[temp] - temp;
            }
            else if (d[temp] < temp)
            {
                output += d[temp];
            }
            keylist.RemoveAt(0);
        }
        Console.WriteLine(output);
        ;
    }
}

Measured memory_bytes: 24924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
}

Measured memory_bytes: 256
// Problem : C - Scc Puzzle
// Contest : AtCoder - AtCoder Regular Contest 069
// URL : https://atcoder.jp/contests/arc069/tasks/arc069_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

LL n, m;

int main()
{
	//File("");
    n = gi <LL> (), m = gi <LL> ();
    if (n * 2 >= m) printf("%lld\n", m / 2);
    else printf("%lld\n", n + (m - n * 2) / 4);
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

int main() {
  long int N, D, x, y, count = 0;
  cin >> N >> D;
  for (int i = 0; i < N; i++){
    cin >> x >> y;
    if (x*x + y*y <= D*D) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<P> G[101010];

int main()
{
  int N;
  cin >> N;
  REP(i, N - 1)
  {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back(P(v, w % 2)); // 偶奇が分かればよい
    G[v].push_back(P(u, w % 2)); // 偶奇が分かればよい
  }
  vector<int> ans(N, 0);
  vector<bool> used(N, false);
  queue<P> que; // { 頂点の番号, 頂点の色 }を格納するキュー
  que.push(P(0, 0));
  used[0] = true;
  // 幅優先探索
  while (que.size())
  {
    P p = que.front();
    que.pop();
    int id = p.first, color = p.second; // 頂点pの番号，色
    REP(i, G[id].size())                // 頂点pと連結している頂点を調べる
    {
      int to = G[id][i].first, cost = G[id][i].second;
      if (used[to]) // 訪問済みの場合
        continue;
      used[to] = true; // 訪問済みにする
      que.push(P(to, color ^ cost));
      ans[to] = color ^ cost;
    }
  }
  REP(i, N)
  cout << ans[i] << endl;
  return 0;
}

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

int main() {
  int A ,B ; 
  cin >> A >> B ;
  
  if( A == 1){
    if (B == 2){
      cout << 3 << endl ; 
    }
  else {
      cout << 2 << endl ; 
  }
  }
    
  else if (A == 2){
    if (B==1){
      cout << 3 << endl ; 
    }
    else {
    cout << 1 << endl ; 
    }
  }
  
  else if (A == 3){
    if (B==2){
      cout << 1 << endl ; 
    }
    else {
      cout << 2 << endl ; 
    }
  }
  
  
  
  
}

Measured memory_bytes: 3640
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

from itertools import permutations

def ceil_base10(x):
    q,r = divmod(x, 10)
    return 10*(q + min(r, 1))

ans=10**12
for A,B,C,D,E in permutations([a,b,c,d,e], 5):
    s = sum([ceil_base10(x) for x in [A,B,C,D]]) + E
    ans = min(ans, s)

print(ans)


Measured memory_bytes: 9024
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

MOD = 1000000007

def mod_add(a, b):
  return (a+b)%MOD

def mod_sub(a, b):
  return (a+MOD-b)%MOD

def mod_mul(a, b):
  return a*b%MOD

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = (1,0,a)
    w = (0,1,b)
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return (w[0],w[1])

def mod_inv(a):
    x,_  = extgcd(a, MOD)
    return (MOD+x%MOD)%MOD

def mod_div(a, b):
    return a*mod_inv(b)%MOD

def mod_pow(a, b):
    res = 1
    while b > 0:
        if b & 1:
            res = res * a % MOD
        a = a * a % MOD
        b >>= 1
    return res

MAX = 2*10**5+1

fac  = [0]*MAX
finv = [0]*MAX
inv  = [0]*MAX

def cominit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;

def mod_com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

cominit()
    
n,k=l_in()
A=l_in()
A.sort()

res = 0

for i in range(n):
    res = mod_sub(res, mod_mul(A[i], mod_com(n-i-1, k-1)))
    res = mod_add(res, mod_mul(A[n-i-1], mod_com(n-i-1, k-1)))

print(res)
    
    


Measured memory_bytes: 37848
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int n, nu;
string strs[MAX_N], ustrs[MAX_N], dpstrs[1 << MAX_N][MAX_N];
int lens[MAX_N], ovws[MAX_N][MAX_N], dp[1 << MAX_N][MAX_N];

/* subroutines */

/* main */

int main() {
  string maxstr(MAX_N * 10 + 1, 'z');

  for (;;) {
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) cin >> strs[i];
    
    nu = 0;
    for (int i = 0; i < n; i++) {
      bool use = true;
      for (int j = 0; j < n; j++)
	if (i != j) {
	  if (strs[i] == strs[j]) {
	    if (i > j) {
	      use = false;
	      break;
	    }
	  }
	  else if (strs[j].find(strs[i]) != string::npos) {
	    use = false;
	    break;
	  }
	}

      if (use) {
	ustrs[nu] = strs[i];
	lens[nu] = strs[i].length();
	nu++;
      }
    }
    //cout << nu << endl;

    for (int i = 0; i < nu; i++) {
      for (int j = 0; j < nu; j++) {
	if (i != j) {
	  int len = (lens[i] < lens[j]) ? lens[i] : lens[j];
	  int k;
	  for (k = len; k > 0; k--)
	    if (ustrs[i].substr(lens[i] - k) == ustrs[j].substr(0, k)) break;
	  ovws[i][j] = k;
	}
	else ovws[i][j] = -1;
	//cout << ovws[i][j] << ' ';
      }
      //cout << endl;
    }	  

    int maxbits = (1 << nu) - 1;
    
    for (int bits = 0; bits <= maxbits; bits++)
      for (int i = 0; i < nu; i++)
	dp[bits][i] = INF, dpstrs[bits][i] = maxstr;

    for (int i = 0; i < nu; i++)
      dp[1 << i][i] = lens[i], dpstrs[1 << i][i] = ustrs[i];

    for (int bits = 1; bits < maxbits; bits++)
      for (int i = 0, bi = 1; i < nu; i++, bi <<= 1)
	if ((bits & bi) && dp[bits][i] < INF)
	  for (int j = 0, bj = 1; j < nu; j++, bj <<= 1)
	    if (! (bits & bj)) {
	      int bitsj = bits | bj;
	      int len = dp[bits][i] + lens[j] - ovws[i][j];
	      if (dp[bitsj][j] > len) {
		dp[bitsj][j] = len;
		dpstrs[bitsj][j] =
		  dpstrs[bits][i] + ustrs[j].substr(ovws[i][j]);
	      }
	      else if (dp[bitsj][j] == len) {
		string str = dpstrs[bits][i] + ustrs[j].substr(ovws[i][j]);
		if (dpstrs[bitsj][j] > str) dpstrs[bitsj][j] = str;
	      }
	    }

    int minlen = INF;
    string minstr;
    
    for (int i = 0; i < nu; i++) {
      if (minlen > dp[maxbits][i]) {
	minlen = dp[maxbits][i];
	minstr = dpstrs[maxbits][i];
      }
      else if (minlen == dp[maxbits][i]) {
	if (minstr > dpstrs[maxbits][i]) minstr = dpstrs[maxbits][i];
      }
    }
    
    cout << minstr << endl;
  }

  return 0;
}

Measured memory_bytes: 1824
package main

import (
	"fmt"
	"sort"
	"errors"
)

func f(d []int, k int) (int, int) {
	arc, abc := 0, 0
	for _, t := range d {
		if t >= k {
			arc += 1
		} else {
			abc += 1
		}
	}
	return arc, abc
}

func lower_bound(d []int) (int, error) {
	a, b := 0, 100001

	for a + 1 < b {
		t := (a + b) / 2
		arc, abc := f(d, t)
		if arc > abc {
			a = t
		} else {
			b = t
		}
	}
	arc, abc := f(d, b)
	if arc != abc {
		return 0, errors.New("")
	} else {
		return b, nil
	}
}

func upper_bound(d []int) (int, error) {
	a, b := 0, 100001

	for a + 1 < b {
		t := (a + b) / 2
		arc, abc := f(d, t)
		if arc >= abc {
			a = t
		} else {
			b = t
		}
	}
	arc, abc := f(d, a)
	if arc != abc {
		return 0, errors.New("")
	} else {
		return a, nil
	}
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &d[i])
	}
	sort.Ints(d)

	lower, err1 := lower_bound(d)
	upper, err2 := upper_bound(d)

	if err1 != nil || err2 != nil {
		fmt.Println(0)
	} else {
		fmt.Println(upper - lower + 1)
	}
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=200010;
int n;
string s[MAXN];
map<string,int> mp;
int maxn=0;
int tot=0;
string ans[MAXN];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i];
    for(int i=1;i<=n;i++)
    {
        mp[s[i]]++;
        if(mp[s[i]]>maxn) maxn=mp[s[i]];
    }
    for(int i=1;i<=n;i++)
    if(mp[s[i]]==maxn)
    {
        ans[++tot]=s[i];
        mp[s[i]]--;
    }
    sort(ans+1,ans+tot+1);
    for(int i=1;i<=tot;i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 27264
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5+100);
    static List<Integer>[] edges;
    static Long[][] dp;
    
	public static void main(String[] args) {
	
		    int n = sc.nextInt();
	        long k = sc.nextLong();
	        long[][] graph = new long[n][n];
	        
	        for(int i = 0; i<n; i++)
	            for(int j = 0; j<n; j++)
	                graph[i][j] = sc.nextLong();
            
	        long[][] res = mpow(graph,k);
	        
	        long ans = 0;
	        for(int i = 0; i<n; i++) {
	            for(int j = 0; j<n; j++)
	                ans = (ans+res[i][j])%mod;
	        }
	        out.println(ans);
	    
		out.close();
   }
	
	private static long[][] mpow(long[][] A, long k) {
	    int n = A.length;
	    long[][] res = new long[n][n];
        
        for(int i = 0; i<n; i++) res[i][i] = 1;
        
        while(k>0) {
            if((k&1)==1) res = multiply(res, A);
            A = multiply(A, A);
            k>>=1;
        }
	return res;
}
static long[][] multiply(long[][] a, long[][] b) {
    int n = a.length;
    long[][] res = new long[n][n];
    for(int i = 0; i<n; i++) {
        for(int j = 0; j<n; j++) {
            for(int k = 0; k<n; k++) {
                res[i][k] = (res[i][k] + (a[i][j]%mod * 1l * b[j][k]%mod)%mod)%mod;
            }
        }
    }
    return res;
}

    }



Measured memory_bytes: 24020
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int l, r, d; cin >> l >> r >> d;
	cout << (r / d) - (l - 1) / d << '\n';
	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());
		char[] sString = sc.next().toCharArray();


		int num = 0;
		int ans = 0;
		for (int i = 0; i < sString.length; i++) {
			if (sString[i] == 'I'){
				num ++;
				if (ans < num){
					ans = num;
				}
			}else {
				num --;
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll H,W; cin>>H>>W;
	vector<string> S(H);
	rep(i,H){
		cin>>S[i];
	}
	rep(i,W+2) cout<<"#";
	cout<<endl;

	rep(i,H){
		cout<<"#";
		cout<<S[i];
		cout<<"#";
		cout<<endl;
	}
	rep(i,W+2) cout<<"#";
}

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

    return 0;
}


Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

ll N, A, B;
ll arr[55];
	ll C[55][55];

int main()
{
	int i, j;

	scanf("%lld %lld %lld", &N, &A, &B);

	for(int i = 0; i < N; i++)
	{
		scanf("%lld", &arr[i]);
	}

	sort(arr, arr + N);
	reverse(arr, arr + N);

	ll sum  = 0;
	ll lastEle;
	for(int i = 0; i < A; i++)
	{
		sum += arr[i];
		lastEle = arr[i];
	}

	double mean = double(sum * 1.0) / double(A * 1.0);
	ll tot = 0, in = 0;
	for(int i = 0; i < N; i++)
	{
		if(arr[i] == lastEle)
			tot++;
		if(i < A && arr[i] == lastEle)
			in++;
	}

	C[0][0] = 1;
	for(int i = 1; i < 53; i++)
	{
		C[i][0] = 1;
		for(int j = 1; j <= i; j++)
		{
			C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
		}
	}

	// cout << C[50][49] << "\n";

	ll ways = 0;

	if(in == A)
	{
		// return 1;
		for(int i = A; i <= B ; i++)
		{
			ways += C[tot][i];
		}
	}
	else
		ways = C[tot][in];


	// ll ways = C[tot][in];

	printf("%0.9lf\n%lld", mean, ways);

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
 
    if(k == 0) {
        out(n*n);
    }
    else {
        ll ans = 0;
        exrep(b, k+1, n) {
            ll x = (n+1-b)/b;
            ll y = (n+1-b)%b;
            ans += (b-k)*(x+1) + max(0LL, y-k);
        }
        out(ans);
    }
 
    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long a = 0;
		for(int i=1;i<N+1;i++) {
			if(i%3==0||i%5==0) {
			continue;
			}
			a = a+i;
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 35700