akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<int> R;
    vector<int> G;
    for (int i = 0; i < N; ++i){
        if(S[i] == 'R') {
            R.push_back(i);
        } else if (S[i] == 'G') {
            G.push_back(i);
        }
    }
    int b_num = N - R.size() - G.size();
    long ans = 0;
    for (int r : R){
        for (int g : G){
            ans += b_num;
            int x = r;
            int y = g;
            if (x > y) {
                swap(x, y);
            }
            if ((x + y) % 2 == 0) {
                // cout << "middle:" << (x + y) / 2 << endl;
                if (S.at((x + y) / 2) == 'B') {
                    ans--;
                }   
            }
            if (2 * x - y >= 0) {
                // cout << "left:" << 2 * r - g << endl;
                if (S.at(2 * x - y) == 'B') {
                    ans--;
                }
            }
            if (2 * y - x < N) {
                // cout << "right:" << 2 * y - x << endl;
                if (S.at(2 * y - x) == 'B') {
                    ans--;
                }
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3664
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

using namespace std;

int main(void) {
    int n;
    int i;
    
    double mean, var, sigma;
    double tmp;
    
    cin >> n;
    
    while( n != 0 ) {
        double s[n];
        
        for(i=0; i<n; i++) {
            cin >> s[i];
        }
        
        //calc. mean
        tmp = 0;
        for(i=0; i<n; i++) {
            tmp += s[i];
        }
        mean = tmp / n;
        
        //calc. var.
        tmp = 0;
        for(i=0; i<n; i++) {
            tmp += pow( (s[i] - mean), 2 );
        }
        var = tmp / n;
        
        //calc. sigma
        sigma = sqrt(var);
        
        cout << fixed << setprecision(10) << sigma << endl;
        
        cin >> n;
    }
    
    return 0;
    
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  cout << ceil(N / 2.0) / N << endl;
  return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3868
n=int(input())
abc=[list(map(int,input().split())) for i in range(n-1)]
q,k=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(q)]
lst=[0]*(n+1)
data=[[] for i in range(n+1)]
flag=[0]*(n+1)
for u in abc:
    a,b,c=u
    data[a].append([b,c])
    data[b].append([a,c])
que=[k]
flag[k]=1
while que:
    h=que.pop()
    for u in data[h]:
        d,c=u
        if flag[d]==0:
            lst[d]=lst[h]+c
            que.append(d)
            flag[d]=1
for u in xy:
    x,y=u
    print(lst[x]+lst[y])

Measured memory_bytes: 83732
# coding: utf-8
# Your code here!

D = int(input())
# with open("sample1.in") as f:

#c = [0 for i in range(26)]
s = [[0 for j in range(27)] for i in range(D)]
c = list(map(int, input().split(" ")))
result=[]
# for i in range(26):
#    c[i] = int(input())
for i in range(D):
    a = list(map(int, input().split(" ")))
    for j, k in enumerate(a):
        #print(i, j, k)
        s[i][j] = int(k)
    result.append(a.index(max(a))+1)
    #print(a.index(max(a)))

for i in range(D):
    # print(s.index(max(s[i])))
    print(result[i])



Measured memory_bytes: 9464
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n, lft = 0, mn = 1000;
    string s;
    cin >> n >> s;
    for(int i=0;i<n;i++){
        if(s[i] == '(') lft++;
        else lft--;
        mn = min(mn, lft);
    }
    if(mn < 0){
        cout << string(-mn, '(');
        lft -= mn;
    }
    cout <<  s;
    if(lft > 0)cout << string(lft, ')');
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cmath>
#include <cstdlib>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

using namespace std;
typedef long long ll;

ll N;
ll n;
std::vector<ll> data;

ll tt = 0;
ll k = 0;
ll temp;

int main() {
  scanf("%lld", &N);
  REP(i,N) {
    scanf("%lld", &temp);
    data.push_back(temp - (i+1));
  }

  sort(data.begin(), data.end());

  ll mid = N/2;
  temp = data[mid];

  for (auto itr = data.begin(); itr != data.end(); itr++) {
    tt += abs(*itr - temp);
  }

  printf("%lld\n", tt);
}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

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

    set<string> st;
    for(int i = 1; i <= min((int)s.length(),k); i++){
        for(int j = 0; j <= s.length() - i; j++){
            st.insert(s.substr(j,i));
        }
    }

    //for(auto x : st) cout << x << endl;

    auto itr = st.begin();
    for(int i = 1; i < k; i++) itr++;
    cout << *itr << endl;
 
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<stdlib.h>

using namespace std;

int main(){
  int n,m;
  int *p,*q;
  bool data;
  int flag;
  int data2,data3;
  while(1){
    cin >> n >> m;
    if(n == 0) break;
    p = (int*)malloc(sizeof(int) * m);
    q = (int*)malloc(sizeof(int) * m);
    for(int i = 0; i< m; i++){
      p[i] = 0;
      q[i] = i+1;
    }
  
    for(int i = 0; i<n; i++){
      for(int j = 0; j< m; j++){
	cin >>data;
	if(data) p[j]++;
      }
    }
  
    /*for(int i = 0; i<m; i++){
      cout << i <<" "<<p[i] <<endl;
      //    printf("%d = %d", i,p[i]);
      }*/

    flag = 1;
    while(1){
      if(flag == 0) break;
      flag = 0;
      for(int i = 0; i<m-1; i++){
	if(p[i] < p[i+1]){
	  data2 = p[i+1];
	  p[i+1] = p[i];
	  p[i] = data2;
	  data3 = q[i+1];
	  q[i+1] = q[i];
	  q[i] = data3;
	  flag = 1;
	}
      }
    }
  
    for(int i = 0; i<m; i++){
      cout << q[i];
      if(i ==m-1) continue;
      cout << " ";
    }
    // cout << endl;
    /*for(int i = 0; i<m; i++){
      cout << p[i];
      }*/
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			250
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
  fastio;
	ll t,n,i,j,k,ans;
	ans = 0;
	cin>>n>>k;
	
	ll a[n];
	for(ll &x : a)
	cin>>x;
	
	sort(a,a+n);
	
	for(i = 0;i<n-k;i++)
	ans += a[i];
	
	cout<<ans;
	
	
	
	
	
	
	
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;


int main(){
ll n;
cin>>n;
vector<double> a(n);
for(ll i=0;i<n;i++){
  cin>>a[i];
}

double j=1;
double ans=0;
for(ll i=0;i<n;i++){
  ans += j/a[i];
}

cout<<1/ans<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    double n,d,x[50][50];

    scanf("%lf %lf",&n,&d);
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            scanf("%lf",&x[i][j]);
        }
    }
    
    int cnt=0;
    double sum=0;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=i+1;j<n;j++){
            sum=0;
            for(int k=0;k<d;k++){
                sum+=pow(x[i][k]-x[j][k],2.0);
            }
            //printf("sum:%lf\n",sum);
            if(sqrt(sum)-(int)(sqrt(sum))==0)cnt++;
        }
    }

    printf("%d\n",cnt);

    return 0;

    
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
zero_flag = 0
for a in A:
    if a == 0:
        zero_flag = 1
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = 0
if flag == 1 and zero_flag != 1:
    print(-1)
else:
    print(result)



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

int main(){
  int N;
  string S;
  int K;
  cin >> N >> S >> K;
  for (int i = 0; i < N; i++){
    if (S.at(i) == S.at(K - 1)) continue;
    else S.at(i) = '*';
  }
  cout << S << endl;
}

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

int main(){
  int a,b;
  vector<int> vec(3);
  cin>>a>>b;
  vec.at(a-1)++;
  vec.at(b-1)++;
  for(int i=0;i<3;i++){
    if(vec.at(i)==0){
      cout<<i+1<<endl;
      return 0;
      }
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	for i := 1; i <= 5; i++ {
		n, err := strconv.Atoi(input())
		if err != nil {
			log.Fatalln(err)
		}

		if n == 0 {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 1816
list = list(map(int,input().split()))
a = list[0]
p = list[1]
b = list[2]
c = 0
d = 0
tax = [int(i) for i in input().split()]
for i in range(p):
	t=tax[i]
	if t<b:
		c=c+1
	if t>b:
		d=d+1
if c>d:
	print(d)
else:
	print(c)

Measured memory_bytes: 3064
n = int(input())
m = list(map(int, input().split()))

count = 0
flag = 1
while flag:
    flag = 0
    for j in range(n-1, 0, -1):
        if m[j] < m[j-1]:
            m[j], m[j-1] = m[j-1], m[j]
            count += 1
            flag = 1

print(" ".join(str(x) for x in m))
print(count)

Measured memory_bytes: 7716
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

const int INF = 10000;

int main()
{
  int N, M;
  cin >> N >> M;
  //ダイクストラのアルゴリズム

  int d[N + 2][N + 2]; //iからjの最短経路

  //行列表現
  int V[N + 2][N + 2]; //iとjの結ぶ重さ　初期値はINF

  for (int i = 1; i <= N; i++)
  {
    for (int j = 1; j <= N; j++)
    {
      V[i][j] = INF;
      d[i][j] = INF;
    }
  }

  int a, b, w;

  for (int i = 0; i < M; i++)
  {

    //aとbの辺の重さはw
    cin >> a >> b >> w;
    V[a][b] = w;
    V[b][a] = w;
  }

  for (int s = 1; s <= N; s++)
  {
    //iからの最短距

    vector<bool> explored(N + 1, false);

    d[s][s] = 0;
    while (1)
    {
      int u = 0;      //最小のやつ
      int minv = INF; //最小の変の重さ
      for (int i = 1; i <= N; i++)
      {
        if (explored[i] == false && d[s][i] < minv)
        {
          u = i;
          minv = d[s][i];
        }
      }

      if (u == 0)
        break;

      //最小の物を探索済みにする
      explored[u] = true;

      for (int i = 1; i <= N; i++)
      {
        if (d[s][u] + V[u][i] < d[s][i])
          d[s][i] = d[s][u] + V[u][i];
      }
    }
  }
  int ans = 0;
  //辺i,jが最短距離s,tに含まれるかどうか
  for (int i = 1; i < N; i++)
  {
    for (int j = i+1; j <= N; j++)
    {
      //変の確定
      bool shortest = false;
      if(V[i][j]==INF)
        continue;
      for (int s = 1; s < N; s++)
      {
        for (int t = s+1; t <= N; t++)
        {
          if (d[s][i] + V[i][j] + d[j][t] == d[s][t])
            shortest=true;
        }
      }
      if(shortest)
        ans++;
    }
  }

  cout << M - ans<< endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

	int result = 0;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;

		if(i % 2 == 0 && a % 2 == 1) {
			result++;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        char c;
        cin >> c;
        set<char> s = {'a', 'i', 'u', 'e', 'o'};
        if (s.count(c) == 0) cout << "consonant" << endl;
        else cout << "vowel" << endl;


        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>

using namespace std;

const long long MOD = 1000000007;

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int cnt_a=0,cnt_b=0;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='c'){
			cout << "No" << endl;
		}
		if(s[i]=='a'){
			cnt_a++;
			if(cnt_a + cnt_b <= a + b){
				cout << "Yes" << endl;
			}else{
				cnt_a--;
				cout << "No" << endl;
			}
		}
		if(s[i]=='b'){
			cnt_b++;
			if(cnt_a + cnt_b <= a+b && cnt_b <= b ){
				cout << "Yes" << endl;
			}else{
				cnt_b--;
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define ll long long 
#define ull unsigned ll
#define db double
#define pii pair<int, int>

const int N = 2e5+5;
int n;
int a[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	ll ans = 0;
	ll lp = 1, rp = 1, xor_sum = a[1], plus_sum = a[1];
	while (lp <= n) {
		while ((xor_sum ^ a[rp+1]) == plus_sum + a[rp+1] && rp < n) {
			rp++;
			xor_sum ^= a[rp];
			plus_sum += a[rp];
		}
		if (xor_sum == plus_sum) {
			ans += rp - lp + 1;
		}
		xor_sum ^= a[lp]; 
		plus_sum -= a[lp];
		lp++;
	}
	printf("%lld\n", ans);
    return 0;
}

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

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

	ll ans = 1e18;
	for(ll i = 1; i*i <= n; i++){
		if(n%i != 0) continue;
		ll j = n/i;
		ans = min(ans, i+j-2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct name
{
	int a,b,c,d;
}M[15];
int n,m,k;
int ans=0;
int num[15];
int counter()
{
	int sum=0;
	for(int i=1;i<=k;++i)
	if(num[M[i].b]-num[M[i].a]==M[i].c)  sum+=M[i].d;
	return sum;
}
void dfs(int len,int pre)
{
	if(len==n)
	{
		ans=max(ans,counter());
		return ;
	}
	else
	{
		for(int i=pre;i<=m;++i)
			num[len+1]=i,dfs(len+1,i);
	}
}
int main()
{

	cin>>n>>m>>k;
	for(int i=1;i<=k;++i)
		scanf("%d%d%d%d",&M[i].a,&M[i].b,&M[i].c,&M[i].d);
	dfs(0,1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cmath>
using namespace std;
long long max_(long long a,long long b)
{
    return a>b?a:b;
}
long long ceil_(long long a,long long b)
{
    return a/b+(a%b!=0);
}
int main() {
    int n;
    cin>>n;
    long long a=1,b=1;
    while(n--)
    {
        long long t1,t2;
        cin>>t1>>t2;
        long long p=max_(ceil_(a,t1),ceil_(b,t2));
        a=t1*p;
        b=t2*p;
    }
    cout<<a+b<<endl;
}

Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

    int n,k;

    cin >> n >> k;

    if(n == 2){
        if(k == 0){
            cout << 1 << endl;
            cout << 1 << " " << 2 << endl;
        }else cout << -1 << endl;
    }else if(n == 3){
        if(k == 1){
            cout << 2 << endl;
            cout << 1 << " " << 2 << endl;
            cout << 2 << " " << 3 << endl;

        }else if(k == 0){
            cout << 3 << endl;
            cout << 1 << " " << 2 << endl;
            cout << 2 << " " << 3 << endl;
            cout << 1 << " " << 3 << endl;
        }else{
            cout << -1 << endl;
        }
    }else{
        if(k > (n - 2) * (n - 1) / 2){
            cout << -1 << endl;
        }else{

            cout << n - 1 + (n - 2) * (n - 1) / 2 - k << endl;

            for(int i = 2; i <= n; i++){
                cout << 1 << " " << i << endl;
            }   

            int c = 0;
            bool d = false;

            for(int i = 2; i <= n - 1; i++){
                for(int j = i + 1; j <= n; j++){
                    if(c == (n - 2) * (n - 1) / 2 - k){
                        d = true;
                        break;
                    }    

                    cout << i << " " << j << endl;
                    c++;
                }
                if(d) break;
            }

        }
    }

    return 0;
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> cnt(N);
  REP(i, N) {
    lint A;
    cin >> A;
    cnt[A-1]++;
  }
  sort(ALL(cnt));
  vector<lint> Scnt(N+1);
  REP(i, N) Scnt[i+1] = Scnt[i] + cnt[i];
  vector<lint> ans(N);
  lint pool = 0;
  REP(i, N) {
    lint l = -1;
    lint r = N*N + 1;
    while(r-l > 1) {
      lint m = (l+r) / 2;
      lint ll = -1;
      lint rr = N;
      while(rr-ll > 1) {
        lint mm = (ll+rr) / 2;
        if(cnt[mm] <= m) ll = mm;
        else rr = mm;
      }
      if(ll >= i && Scnt[ll+1] - Scnt[i] + pool < m * (ll + 1 - i)) r = m;
      else l = m;
    }
    ans[N-1-i] = l;
    pool += cnt[i];
  }
  REP(i, N) cout << ans[i] << "\n";
}

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

void insert(vector<int> &v, int N) {
    for (int i = 1; i <= (N - 1); ++i) {
        int k = v[i];
        int j = i - 1;
        while (j >= 0 && v[j] > k) {
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = k;
        for (int k = 0; k < (N - 1); ++k){
                cout << v[k] << " ";
        }
        cout << v[N-1] << endl;
    }
}

int main() {
    int N; cin >> N;
    vector<int> a(N);

    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < (N - 1); ++i) {
        cout << a[i] << " ";
    }
    cout << a[N-1] << endl;
    insert(a, N);
    return 0;
}


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

using namespace std;
using ll = long long;

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

  bool flg = true;
  for (int i = 0; i < s.size(); ++i)
    if ((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R')) flg = false;

  cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
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 = int(input())
ans = 0
for i in range(1, N+1):
    k = N // i
    ans += i * k * (k + 1) // 2
print(ans)

Measured memory_bytes: 8932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if(n == 1)
    {
        if(a != b) cout << 0 << endl;
        else cout << 1 << endl;
    }
    else
    {
        if(a > b) cout << 0 << endl;
        else
        {
            ll low = (n-1) * a + b;
            ll high = (n-1) * b + a;
            cout << high - low + 1 << endl;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int X = sc.nextInt();
        System.out.println( ( X - A >= 0 && B > X - A) ? "YES" : "NO" );
    }
}


Measured memory_bytes: 35748
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

bool f(int n, vi a) {
    if(n == 1)return true;
    ll s = accumulate(all(a), 0ll);
    ll b = n*(n + 1ll) / 2;

    if(s%b != 0)return false;
    
    ll t = s / b;
    vll c(n);
    rep(i, n) {
        c[i] = a[(i + 1) % n] - a[i];
    }
    rep(i, n)c[i] -= t;

    ll d = t;
    rep(i, n) {
        if(c[i] > 0 || c[i]%n!=0)return false;
        d += c[i] / n;
    }
    return d == 0;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n) {
        vi a(n); rep(i, n)cin >> a[i];
        cout << (f(n, a) ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 1920
s=str(input())
t=str(input())
len_s=len(s)
len_t=len(t)
ans=""
dp=[[0 for i in range(len_t+1)] for j in range(len_s+1)]
for i in range(len_s):
    for j in range(len_t):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])

while len_s>0 and len_t>0:
    if dp[len_s][len_t]==dp[len_s-1][len_t]:
        len_s-=1
    elif dp[len_s][len_t]==dp[len_s][len_t-1]:
        len_t-=1
    else:
        ans=s[len_s-1]+ans
        len_s-=1
        len_t-=1
print(ans)


Measured memory_bytes: 121308
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] head = br.readLine().split(" ");
    String[] p_line = br.readLine().split(" ");
    String[] c_line = br.readLine().split(" ");
    br.close();
    int n = Integer.parseInt(head[0]);
    int k = Integer.parseInt(head[1]);

    int[] p = new int[n];
    long[] c = new long[n];
    for (int i = 0; i < n; i++) {
      p[i] = Integer.parseInt(p_line[i]) - 1;
    }
    for (int i = 0; i < n; i++) {
      c[i] = Long.parseLong(c_line[i]);
    }
    long answer = Long.MIN_VALUE;
    long[] c_total = new long[n];
    boolean[] isVisit = new boolean[n];
    Arrays.fill(isVisit, false);
    for (int i = 0; i < n; i++) {
      int idx = i;
      int size = 0;
      if (isVisit[idx] == true) {
        continue;
      } else {
        size = 0;
        while (true) {
          if (isVisit[idx] == true) {
            break;
          }
          c_total[size] = c[p[idx]];
          if (size != 0) {
            c_total[size] += c_total[size - 1];
          }
          isVisit[idx] = true;
          idx = p[idx];
          size++;
        }

        if(c_total[size - 1] > 0) {
          answer = Math.max(answer, c_total[size - 1] * (k / size));
        }
        
        for (int start = 0; start < size; start++) {
          for (int count = 1; count < size; count++) {
            long val;
            if (count > k) {
              continue;
            }
            int to = (start + count - 1) % size;
            if (start <= to) {
              val = c_total[to];
              if (start != 0) {
                val -= c_total[start - 1];
              }
            } else {
              val = c_total[size - 1] - c_total[start - 1] + c_total[to];
            }
            if (c_total[size - 1] > 0) {
              val += (c_total[size - 1] * ((k - count) / size));
            }
            answer = Long.max(answer, val);
          }
        }
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 36256
import numpy as np

x1,y1,x2,y2 = map(int,input().split())

a=np.array([x1,y1])
b=np.array([x2,y2])

T = np.array([[0,-1],[1,0]])

c = b + np.dot(T,b-a)
d = c + np.dot(T,c-b)
print(*c, end=' ')
print(*d)

Measured memory_bytes: 12424
N = int(input())
H = tuple(int(x) for x in input().split())

count = 0
count_max = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    count_max = max(count, count_max)
    count = 0
print(max(count, count_max))

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

long long N,A,B;

int main()
{
	ios::sync_with_stdio(false);
	long long less;
	long long ans;
	cin>>N>>A>>B;
	A+B>0;
	if(A==0){
		cout<<"0\n";
		return 0;
	}else if(B==0){
		cout<<N<<"\n";
		return 0;
	}else{
		less=N%(A+B);
		ans=N/(A+B)*A;
		if(less>=A)
		ans+=A;
		else if(less>0)
		ans+=less;
		cout<<ans<<"\n";
		return 0;
	}
}

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

int main() {
	int N; long x[110], y[110], h[110];
	cin >> N;
	for(int i=0; i<N; ++i) cin >> x[i] >> y[i] >> h[i];
	for(int X=0; X<=100; ++X){
	    for(int Y=0; Y<=100; ++Y){
	        long mx=1e16, H=-1;
	        bool flag=true;
	        for(int i=0; i<N; ++i){
	            if(h[i]>0){
	                if(H<0) H=h[i]+abs(x[i]-X)+abs(y[i]-Y);
	                else if(h[i]+abs(x[i]-X)+abs(y[i]-Y)!=H){
	                    flag=false;
	                    break;
	                }
	            }
	            else mx=min(mx, abs(x[i]-X)+abs(y[i]-Y));
	        }
	        if(flag && H<=mx){
	            cout << X << " " << Y << " " << H << endl;
	            return 0;
	        }
	    }
	}
	return 0;
}


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

int main(){
  string S;
  cin>>S;
  for(int i=0;i<S.size();i++)
    if((i%2==0 && S[i]=='L') || (i%2==1 && S[i]=='R')){
      cout<<"No"<<endl;
      return 0;
    }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = int(input())

AB = []

for _ in range(N):
    AB.append(list(map(int, input().split())))

A_idx = [(AB[i][0], i) for i in range(N)]
B_idx = [(AB[i][1], i) for i in range(N)]

A_idx.sort(key=lambda e:e[0])
B_idx.sort(key=lambda e:e[0])

if N % 2 == 1:
    diff = B_idx[N//2][0]-A_idx[N//2][0]
    print(diff+1)
else:
    l = N//2-1
    u = N//2
    diff = (B_idx[l][0]+B_idx[u][0])-(A_idx[l][0]+A_idx[u][0])
    print(diff+1)

Measured memory_bytes: 89616
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;typedef vector<int> vi;typedef vector<ll> vll;
typedef pair<int,int> ii;typedef map<int,int> mii;
inline void rvi(vi &v, int n){int temp; rep(i,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll &v, int n){ll temp;rep(i,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll &a){rep(i,sz(a)){cout<<a[i]<<" ";}cout<<endl;}
inline vll prefixsum(vi &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-1;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll &a){vll b;b.pb(a[0]);for(int i=1;i<sz(a);i++){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll &a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];for(int i=sz(a)-1;i>=0;i--){b[i]=a[i]+b[i+1];}return b;}
void solve();int main(){ios;solve();return 0;}
//--------SOLVE--------------------------------------------------------------------
void solve()
{
	int n,k;cin>>n>>k;
	vi a;
	rvi(a,n);
	int dp[100005];
	rep(i,100005) dp[i]=INT_MAX;
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)
				dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
		// dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define ll long long
#define P ((ll)(1e9+7))
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

ll n, k;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P;
        n >>= 1;
    }
    return res;
}

ll fac[MAX], inv[MAX];
void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i-1]*i%P;
    }
    inv[MAX-1] = qpow(fac[MAX-1], P-2);
    for(int i = MAX-2; i >= 0; i--){
        inv[i] = inv[i+1]*(i+1)%P;
    }
}

ll C(ll n, ll m){
    return fac[n]*inv[m]%P*inv[n-m]%P;
}

ll calc(ll n, ll m){
    return C(n+m-1, m-1);
}

int main()
{
    init();
    cin >> n >> k;
    ll x = min(n, k);
    ll ans = 0;
    for(int i = 1; i <= x; i++){
        ans = (ans + C(n, i)*calc(i, n-i)%P)%P;
    }
    if(k > 1) ans = (ans+1)%P;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,limit=1000000000000000000,ans=1;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     ll a;
     cin>>a;
     if(a==0||ans==0)
     {
         ans=0;
     }
     else if((limit/ans)<a)
     {
         ans=-1;
     }
     else if(ans!=-1)
        ans*=a;
 }
 cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const double PI = 3.14159265358979323846;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double ng=0.0,ok=PI/2.0;
  for(int i=0; i<100000; i++){
    double mid = (ng+ok)/2.0;
    double ret;
    if(mid > PI/2.0 - 0.000000001){
      ret = 0.0;
    }else if(a*tan(mid) <= b){
      ret = a*a*b - a*a*a*tan(mid)/2.0;
    }else{
      ret = a*b*b/tan(mid)/2.0;
    }
    if(ret < x){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << fixed << setprecision(10) << ok/PI*180 << endl;
  return 0;
}


Measured memory_bytes: 512
W,H,N=map(int,input().split())
List = []
for i in range (N):
  List.append(list(map(int, input().split())))
WRange = [0,W]
HRange = [0,H]
for i in range(N):
  if List[i][2] == 1:
    WRange[0] = max(WRange[0],List[i][0])
  elif List[i][2] == 2:
    WRange[1] = min(WRange[1],List[i][0])
  elif List[i][2] == 3:
    HRange[0] = max(HRange[0],List[i][1])
  else:
    HRange[1] = min(HRange[1],List[i][1])
if WRange[1]-WRange[0] >0:
  W = WRange[1]-WRange[0]
else:
  W = 0
if HRange[1]-HRange[0] >0:
  H = HRange[1]-HRange[0]
else:
  H = 0
res = H * W
print(res)

Measured memory_bytes: 9224
#include <vector>
#include <iostream>
using namespace std;
#define MAX 100000

struct edge{
    int s,t,d;
};

vector<edge> edges;
int d[MAX];

void BellmanFord(int startVertex,int vNum,int eNum){
	fill(d,d + MAX,__INT_MAX__);
	d[startVertex] = 0;
	
	for(int i=0;i < vNum;++i){
		bool update = false;
		for(int j = 0;j < eNum;++j){
			edge e = edges[j];
			if(d[e.s] != __INT_MAX__ && d[e.t] > d[e.s] + e.d){
				d[e.t] = d[e.s] + e.d;
				update = true;
				if(i == vNum - 1){
					cout<<"NEGATIVE CYCLE"<<endl;
					return;
				}
			}
		}
		if(!update)break;
	}
	for(int i = 0;i < vNum;++i){
		if(d[i]==__INT_MAX__){
		    cout << "INF"<< endl;
		}
		else cout<< d[i] << endl;
	}
}

int main(){
    int v,e,r;
	cin >> v >> e >> r;
	for(int i = 0;i < e;++i){
		int s,t,d;
		cin >> s >> t >> d;
		edges.push_back({s,t,d});
	}
	BellmanFord(r,v,e);
}




Measured memory_bytes: 3592
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    
    int a[100001];

    REP(i,n){
        cin >> a[i];
    }

    int b[100001];

    int l = 0;    
    REP(i,n){
        REP(j, a[i]){
            b[l] = i+1;
            l++;
        }        
    }


    int i = 0;
    while(i != h*w){
        if((i/w)%2 == 0){
            cout << b[i]<< " ";
            i++;
        }
        else if((i/w)%2 == 1){
           cout << b[(i/w)*w+w-(i%w)-1] <<" ";
           i++;
        }
        if(i%w == 0) cout << endl;
    }


    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, m;
void solve(){
	cin >> n >> m;
	
	cout << n*(n-1)/2+m*(m-1)/2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
let x1, y1, x2, y2 = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d
let dx, dy = x2 - x1, y2 - y1
let _ = Printf.printf "%d %d %d %d\n" (x2 - dy) (y2 + dx) (x1 - dy) (y1 + dx)

Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std;
int ans;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d[10001];
    for(int i=1;i<=a;++i){
    cin>>d[i];
    if(d[i]<b||d[i]>=c){
        ans++;
    }
}
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int A,B;
    string ans;
    cin >> A >> B;
    if(A != 2 && B !=2){
        ans = "Yes";
    }else{
        ans = "No";
    }

  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<string> A(N);
  vector<int> B(N);
  map<string, int> m{};
  for (auto& a : A) {
    cin >> a;
    ++m[a];
  }
  for (int i = 0; i < N; ++i) {
    B[i] = m[A[i]];
  }
  auto cnt = *boost::max_element(B);
  set<string> res{};
  for (int i = 0; i < N; ++i) {
    if (B[i] == cnt) {
      res.emplace(A[i]);
    }
  }
  vector<string> ans(res.begin(), res.end());
  boost::for_each(ans, [](const auto& s){
    cout << s << CRLF;
  });
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 37120
N,P=[int(s) for s in input().split()]
S=list(input())
if P!=2 and P!=5:
  ls=[0 for _ in range(N)]
  mod=[0 for _ in range(P)]
  d=10
  ls[0]=int(S[-1])%P
  mod[ls[0]]+=1
  for i in range(1,N):
    ls[i]=(ls[i-1]+d*int(S[-1-i]))%P
    d=(d*10)%P
    mod[ls[i]]+=1
  #print(ls)
  #print(mod)  
  ans=mod[0]
  for i in range(N):
    m=ls[i]
    mod[ls[i]]-=1
    ans+=mod[ls[i]]
else:
  ans=0
  for i in range(N):
    if int(S[i])%P==0:
      ans+=i+1
print(ans)
   


Measured memory_bytes: 12576
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int a[55][30],b[30];
int main()
{
    int n,f=0;
    scanf("%d",&n);
    char s[55];
    for(int i=0;i<30;i++) b[i]=55;
    for(int i=0;i<55;i++)
        for(int j=0;j<30;j++)
        a[i][j]=0;
    for(int i=0;i<n;i++)
    {
        scanf("%s",s);
        int len=strlen(s);
        for(int j=0;j<len;j++)
            a[i][s[j]-97]++;
    }
    for(int i=0;i<26;i++)
        for(int j=0;j<n;j++)
        if(a[j][i]<b[i])
            b[i]=a[j][i];
    for(int i=0;i<26;i++)
        for(int j=0;j<b[i];j++)
        {
            printf("%c",i+97);
            f=1;
        }
     if(f) printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int n = 0;
	int m = 0;
	int	A[100][100], B[100], C[100]{ 0 };
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)cin >> A[i][j];
	for (int i = 0; i < m; i++)cin >> B[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)C[i] += A[i][j] * B[j];
		cout << C[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3132
import heapq
Q = int(input())

# 中央値の左側の値、右側の値を管理する
# heapqとする。rightは最小が興味あるが、leftは最大なので、-1をかけて扱う
left, right = [], []
# 両方のSUMも管理する必要がある。毎回SUMしてたら間に合わん
Lsum, Rsum = 0,0
Lcnt, Rcnt = 0,0
B = 0
for _ in range(Q):
  q = list(map(int, input().split()))
  if len(q) == 1:
    # 2
    # heapqってPeakできないの・・・？
    l = (-1) *left[0]
    #l = (-1) * heapq.heappop(left)
    #heapq.heappush(left,(-1)*l)
    # (l-l1) + (l-l2) + ... + (l-l) + (r-l) + ... + (r1 - l)
    print(l, Rsum//2 - Lsum//2 + B)
    #print(left,right, Lsum, Rsum)
  else:
    # 1
    _,a,b = q
    B += b
    # まず双方にaを突っ込む
    heapq.heappush(left,(-1)*a)
    heapq.heappush(right,a)
    Lsum += a
    Lcnt += 1
    Rsum += a
    Rcnt += 1
    # leftの最大値と、rightの最小値の関係が崩れていたら、交換する
    l = (-1)*left[0]
    r = right[0]
    #l = (-1) * heapq.heappop(left)
    #r = heapq.heappop(right)
    if l>=r:
      Lsum = Lsum - l + r
      Rsum = Rsum - r + l
      l,r = r,l
    _ = heapq.heappop(left)
    _ = heapq.heappop(right)
    heapq.heappush(left,(-1)*l)
    heapq.heappush(right,r)


Measured memory_bytes: 104248
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
S=sys.stdin.readline().strip()

def isok(d):    #長さdの文字列で重ならない2つの文字列が存在するかを判定
    D={}    #出てきた文字列:スタート位置
    for i in range(N-d+1):
        x=S[i:i+d]
        if x not in D:  #前に文字列が出てきていない場合
            D[x]=i
        else:  #既に文字列が出てきている場合
            if d<=i-D[x]:   #文字列が重なっていない場合
                return True
            else:           #文字列が重なっていた場合
                pass        #更に右側の文字列を探すために処理を継続する
    else:
        return False

h=N
l=0
while h-l!=1:
    m=(h+l)/2
    if isok(m):
        l=m
    else:
        h=m
print l


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

long long N;
long long A[200005];
long long B[200005];


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

	long long ans = 0;
	for(long long bit = 0; bit <= 28; bit++){
		long long MOD = (1<<(bit + 1));
		vector<long long> modB;
		for(long long i = 0; i < N; i++){
			modB.push_back(B[i]%MOD);
		}
		sort(modB.begin(), modB.end());

		long long num = 0;
		for(long long i = 0; i < N; i++){
			long long a = lower_bound(modB.begin(), modB.end(), (1 * (1<<bit) - A[i]%MOD)) - modB.begin();
			long long b = lower_bound(modB.begin(), modB.end(), (2 * (1<<bit) - A[i]%MOD)) - modB.begin();
			long long c = lower_bound(modB.begin(), modB.end(), (3 * (1<<bit) - A[i]%MOD)) - modB.begin();
			long long d = lower_bound(modB.begin(), modB.end(), (4 * (1<<bit) - A[i]%MOD)) - modB.begin();
			//if(modB[b] == 2 * (1<<bit) - A[i]%MOD)
			//	b--;
			//if(modB[d] == 4 * (1<<bit) - A[i]%MOD)
			//	d--;
			num += (b - a) + (d - c);
		}
		if(num%2 == 1){
			ans += (1<<bit);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8980
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    vector<long double> x(n);
    vector<string> u(n);

    rep(i, n) cin >> x.at(i) >> u.at(i);
    long double res = 0.0;
    rep(i, n){
        if(u.at(i)=="JPY"){
            res += (long double)x.at(i);
        }
        else{
            res += (long double)(x.at(i)*380000);
        }
    }

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  ll n, a;
  cin >> n >> a;
  vector<ll> x(n);
  ll ma = a;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    ma = max(ma, x[i]);
    x[i] -= a;
  }
  ll dp[51][5010] = {};
  ll nx = ma*n;
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= 2*nx; j++) {
      if (i == 0 && j == nx) dp[i][j] = 1;
      else if ((j >= 0 && j-x[i-1] < 0) || (j-x[i-1] > 2*nx)) dp[i][j] = dp[i-1][j];
      else if (j >= 1 && 0 <= j-x[i-1] && j-x[i-1] <= 2*nx) dp[i][j] = dp[i-1][j]+dp[i-1][j-x[i-1]];
      else dp[i][j] = 0;
    }
  }
  dump(dp[n][nx]-1);
  return 0;
}


Measured memory_bytes: 2304