akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<LL,LL>
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
typedef long long LL;
inline LL read(){
	LL x=0,g=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') g=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*g;
}

const LL MAXN=300005,Mo=1000000007;
struct list{
	LL l,lt[MAXN],nt[MAXN],x[MAXN],y[MAXN];
	void clear(){ l=0; memset(lt,0,sizeof(lt)); }
	void addedge(LL a,LL b){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; }
}E;
LL n,m,a[305][305],b[305],c[305],g[305],f[305][305],v[305][305];
LL cmp(LL i,LL j){ return b[i]<b[j]; }
int main(){
	n=read();
	if (n==1) { printf("0\n"); return 0; }
	FOR(i,1,n)
		FOR(j,1,n) f[i][j]=a[i][j]=read();
	FOR(k,1,n)
		FOR(i,1,n)
			FOR(j,1,n)
			if (i!=j&&i!=k&&j!=k&&f[i][j]>f[i][k]+f[k][j]) f[i][j]=f[i][k]+f[k][j];
	FOR(i,1,n)
		FOR(j,1,n)
		if (f[i][j]<a[i][j]) { printf("-1\n"); return 0; }
	memset(v,0,sizeof(v));
	FOR(x,1,n) {
		FOR(i,1,n) b[i]=Mo*Mo,g[i]=c[i]=0;
		b[x]=0,g[x]=x;
		FOR(i,1,n) {
			LL y,mx=Mo*Mo;
			FOR(j,1,n)
			if (!c[j]&&b[j]<mx) { mx=b[j]; y=j; }
			c[y]=1; b[y]=mx;
			FOR(j,1,n)
			if (!c[j]) {
				if (b[j]>b[y]+a[y][j]) { b[j]=b[y]+a[y][j]; g[j]=y; }
				else if (b[j]==b[y]+a[y][j]&&a[y][j]<a[g[j]][j]) { g[j]=y; }
			}
		}
		FOR(i,1,n) v[g[i]][i]=v[i][g[i]]=1;
		//printf("%lld\n",x);
		//FOR(i,1,n) printf("%lld%c",b[i]," \n"[i==n]);
		//FOR(i,1,n) printf("%lld%c",g[i]," \n"[i==n]);
	}
	LL ans=0;
	FOR(i,1,n-1)
		FOR(j,i+1,n)
		if (v[i][j]) ans+=a[i][j];
	cout<<ans<<endl;
	
	return 0;
}

/*
*/


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace _517_LongestSteps
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				//input
				int[] orderNumber = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();

				bool isEnd = orderNumber.All (item => item == 0);
				if (isEnd)
				{
					break;
				}

				int dealCardCount = orderNumber[1];
				int[] cardArray = new int[dealCardCount];
				for (int lp = 0; lp < cardArray.Length; lp++)
				{
					cardArray[lp] = int.Parse (Console.ReadLine ());
				}

				//process
				const int White = 0;

				cardArray = cardArray.OrderBy (item => item).ToArray ();

				int loop = 0;
				bool existWhiteCard = false;

				if (cardArray[0] == White)
				{
					existWhiteCard = true;
					loop = 1;
				}
			
				//?????¨??????????´?????????¨??????????????§?????????????±???????
				int maxLength = 1;

				while (loop + 1 < cardArray.Length)
				{
					//?????????
					int length = 1;

					bool instanceExistWhiteCard = existWhiteCard;
					int beginLoop = -1;

					//????´??????????????????????????´?????¶?????????????????????§
					while (loop + 1 < cardArray.Length)
					{
						//?¬????????´?????????¨??????????????°
						bool isChain = cardArray[loop] + 1 == cardArray[loop + 1];
						int space = cardArray[loop + 1] - cardArray[loop] - 1;

						//????????????????????????
						loop++;

						if (isChain)
						{
							length++;
						}
						else
						{
							//????´???§??£??¨??§???????????? ?????? ????´?????????¨??????????????°
							if (space <= 1 && instanceExistWhiteCard)
							{
								instanceExistWhiteCard = false;
								length += 2;

								if (beginLoop == -1)
								{
									beginLoop = loop;
								}
							}
							else
							{
								//??????????´?????????°????§???????
								if (beginLoop != -1)
								{
									loop = beginLoop;
								}

								//?????????
								break;
							}
						}
					}

					//????´?????????£???????????°
					if (instanceExistWhiteCard)
					{
						length += 1;
					}

					//??????
					if (maxLength < length)
					{
						maxLength = length;
					}
				}

				//output
				Console.WriteLine (maxLength);
			}
		}
	}
}

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

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

  int base[n+1];
  base[0] = 1;
  
  int tmp_a,tmp_b;

  for(int i = 1;i < n+1;i++){
    tmp_a = 2 * base[i-1];
    tmp_b = k + base[i-1];
    if(tmp_a < tmp_b)
      base[i] = tmp_a;
    else
      base[i] = tmp_b;
  }
  cout << base[n] << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}



//N_C_a を M で割った余り
ll my_combination(ll N, ll a, ll M) {
	ll answer = 1;

	rep(i, a) {
		answer *= (N - i);
		answer %= M;
	}

	rep(i, a) {
		answer *= my_pow(i + 1, M - 2, M);
		answer %= M;
	}

	return answer;
}



ll my_gcd(ll& a, ll& b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}



// long long型 n を、base 進法での、i 桁目の数が入った vector にする。
void ll_to_vector(ll base, ll n, vector<ll>& v) {
	ll tempo = n;

	ll n_digit = floor(log10(n) / log10(base)) + 1;
	v.assign(n_digit, 0);

	//ll n_digit = v.size();

	for (ll i = 0; i < n_digit; i++) {
		v.at(i) = tempo / pow(base, n_digit - 1 - i);
		tempo -= v.at(i) * pow(base, n_digit - 1 - i);
	}
}







signed main() {
	int N; cin >> N;
	vector<int> x(N), y(N);
	vector<pair<int, int>> pos(N);

	rep(i, N) {
		cin >> x.at(i) >> y.at(i);
		pos.at(i) = make_pair(x.at(i), y.at(i));
	}

	vector<int> turn(N);
	rep(i, N) turn.at(i) = i;

	int perm = 0;
	double sum = 0.0;

	do {
		rep(i, N-1) {
			double dist = pow(x.at(turn.at(i)) - x.at(turn.at(i+1)), 2);
			dist += pow(y.at(turn.at(i)) - y.at(turn.at(i + 1)), 2);
			dist = sqrt(dist);

			sum += dist;
		}

		perm++;
	} while (next_permutation(turn.begin(), turn.end()));


	double res = sum / ((double)perm);
	printf("%.12lf\n", res);
}

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

int main()
{
  string str;
  cin >> str;
  
  int length=0;
  while(str[length]!=0)
    length++;
  
  if(str[0]=='?')
    str[0]='D';
  
  rep(i,1,length)
  {
    if(str[i]=='?')
    {
      str[i]='D';
    }  
  }   
  cout <<str << endl;
}
    

Measured memory_bytes: 3748
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];


        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += (double) 1 / sc.nextInt();
        }

        // write your code
        System.out.println((double) 1 / sum);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 23124
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());
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = 1;
        int min = p[0];
        for (int i = 1; i < p.length; i++) {
            if (p[i] <= min) {
                result++;
            }
            min = Math.min(min, p[i]);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 49544
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 998244353;
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAX 200010
ll n, q;
ll p[MAX];
ll b[MAX];
ll tree[4 * MAX];
ll lazy[4 * MAX];

void build(int node, int start, int end)
{
    if (start == end)
        tree[node] = 1;
    else
    {
        int mid = (start + end) / 2;
        build(2 * node, start, mid);
        build(2 * node + 1, mid + 1, end);
        // cout << b[mid - start + 1] << " ";
        tree[node] = ((tree[2 * node] * b[end - mid]) % mod + (tree[2 * node + 1]) % mod) % mod;
        //cout << tree[node] << "\n";
    }
}
void updaterange(int node, int start, int end, int l, int r, int val)
{
    if (lazy[node] != 0)
    {
        tree[node] = ((p[end - start + 1]) * lazy[node]) % mod;
        if (start != end)
        {
            lazy[node * 2] = lazy[node];
            lazy[node * 2 + 1] = lazy[node];
        }
        lazy[node] = 0;
    }
    if (start > end || start > r || end < l)
        return;
    if (start >= l && end <= r)
    {
        // cout << (p[end - start + 1]) << " " << start << " " << end << "\n";

        tree[node] = (val * p[end - start + 1]) % mod;
        //cout << "d- " << end - start + 1 << "\n";
        if (start != end)
        {
            lazy[node * 2] = val;
            lazy[node * 2 + 1] = val;
        }
        return;
    }
    ll mid = (start + end) / 2;
    updaterange(2 * node, start, mid, l, r, val);
    updaterange(2 * node + 1, mid + 1, end, l, r, val);
    tree[node] = ((tree[2 * node] * b[end - mid]) % mod + (tree[2 * node + 1]) % mod) % mod;
    //cout << tree[node] << " " << b[mid - start + 1] << "\n";
    //cout << tree[node] << "\n";
}

void solve()
{
    cin >> n >> q;
    p[0] = 0;
    b[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        p[i] = (p[i - 1] + b[i - 1]) % mod;
        b[i] = (b[i - 1] * (ll)10) % mod;
        //cout << p[i] << " ";
    }
    build(1, 1, n);
    // cout << queryrange(1, 1, n, 1, n) % mod << "\n";
    //cout << tree[1] << "\n";
    while (q--)
    {
        int l, r, d;
        cin >> l >> r >> d;
        updaterange(1, 1, n, l, r, d);
        cout << tree[1] % mod << "\n";
    }
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 14996
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a) {
  a %= mod;
  if (a < 0) a += mod;
  ll b = mod, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += mod;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
ll fastmod(ll x)
{
    return x<mod?x:x%mod;
}
int32_t main()
{
    IOS

   
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 or i%5==0)
        {

        }
        else
        {
            ans+=i;
        }
    }
    cout<<ans<<endl;
}       

Measured memory_bytes: 3580
N,M = (int(i) for i in input().split())
a = set([int(input()) for i in range(M)])
hoge = [0] * N
if 1 not in a:
    hoge[0] = 1
if 2 not in a and N >= 2:
    hoge[1] = hoge[0] + 1

for i in range(2,N):
    if i + 1  not in a:
        hoge[i] += hoge[i - 1]
        hoge[i] += hoge[i - 2]

print(hoge[N-1] % (10**9 + 7))


Measured memory_bytes: 462708
// inputに入力データ全体が入る
function Main(input) {
  input = parseInt(input.split("\n"))
  var arg = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  console.log(arg[input - 1]);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

string s;

void read_input()
{
    cin >> s;
}

void solve()
{
    int sum = 0;
    for(int i = 0; i < sz(s); ++i)
        sum += s[i] - '0';
    cout << (sum % 9 == 0 ? "Yes" : "No");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3768
import java.util.*;

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

		int zeroCnt = 0;
		int oneCnt = 0;

		for (int i = 0; i < C.length; i++) {
			if (C[i] == '0') {
				zeroCnt++;
			} else {
				oneCnt++;
			}
		}

		System.out.println(Math.min(zeroCnt, oneCnt) * 2);
	}
}


Measured memory_bytes: 39600
##入力は以下の形式で標準入力から与えられる。
##N
n = gets.chomp.to_i

##2つの正の整数 Aと Bを持っています。それらの和が Nであると分かっているとき、 
##Aの各位の和と Bの各位の和の合計として考えられる最小の値を求めてください。
#a: 1   .. n-1
#b: n-1 .. 1

v_min = n
(1..(n-1)).each do |a|
  b = n - a
  
  sum = 0
  a_a = a.to_s.split("").map(&:to_i)
  a_a.each do |v|
    sum += v
  end
  a_b = b.to_s.split("").map(&:to_i)
  a_b.each do |v|
    sum += v
  end
  
  # puts "#{a},#{b}"
  
  v_min = sum if v_min > sum
  # p sum
end

##制約
##2 ≦ N ≦ 10^5
##Nは整数

##Aの各位の和と Bの各位の和の合計として考えられる最小の値を出力せよ。
p v_min

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

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

    string str;
    getline(cin, str);

    for (int i = 0; i < str.size(); i++) {
        if (isupper(str[i])) {
            str[i] = tolower(str[i]);
        } else if (islower(str[i])) {
            str[i] = toupper(str[i]);
        }
    }

    cout << str << '\n';
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int N, ans;
  cin >> N;
  ans = 0;
  for (int i=1,j=1; i <= N; i*=10, j++) {
    if (j%2) {
      if (i*10 <= N) {
        ans += i*10-i;
      } else {
        ans += N-i+1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
c = []
a = []
for _ in range(n):
  ca = list(map(int, input().split()))
  c.append(ca[0])
  a.append(ca[1:])
  
ans = 10**9
for cnt in range(2**n):
  costs = 0
  skills = [0 for _ in range(m)]
  cnt = ('{:0'+str(n)+'b}').format(cnt)
  for i in range(n):
    if cnt[i] == '1':
      costs += c[i]
      for j in range(m):
        skills[j] += a[i][j]
  if len(list(filter(lambda skill: skill>=x, skills))) == m:
    ans = min(ans, costs)
print(ans if ans != 10**9 else -1)

Measured memory_bytes: 9244
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	S := 0
	P := 0
	for i := 0; i < N; i++ {
		S += A[i]
		if i%2 == 1 {
			P += A[i]
		}
	}

	X := make([]int, N)

	X[0] = S - 2*P
	for i := 1; i < N; i++ {
		X[i] = 2*A[i-1] - X[i-1]
	}
	PrintI(X...)
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 11392
N, K = map(int, input().split())
S = input()

tmp = S[0]
S_lst = []
if S[0] == '0':
    S_lst.append(0)  # 逆立ちから始める

ct = 0
for s in S:
    if tmp == s:
        ct += 1
    else:
        S_lst.append(ct)
        tmp = s
        ct = 1
if ct:
    S_lst.append(ct)

if S[-1] == '0':
    S_lst.append(0)  # 逆立ちで終える

l, r = 0, K * 2

M = sum(S_lst[:K * 2 + 1])
ans = M
while r < len(S_lst) - 2:
    M += S_lst[r + 1] + S_lst[r + 2] - S_lst[l] - S_lst[l + 1]
    ans = max(ans, M)
    l += 2
    r += 2
print(ans)


Measured memory_bytes: 4476
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    int[string] cnt;
    foreach (_; 0 .. n) {
        auto s = readln.chomp;
        
        cnt[s] += 1;
    }
    
    string[] ans;
    int mx = cnt.values.sort().back;
    foreach (s; cnt.keys) {
        if (cnt[s] == mx) {
            ans ~= s;
        }
    }
    
    ans.sort();
    
    ans.each!writeln;
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ban(n + 2, vector<int>(n + 2));
    for (int i = 0; i < m; i++) {
        int a, b, x;
        cin >> a >> b >> x;
        a--;
        b--;
        ban[a][b]++;
        ban[a][b + 1]--;
        ban[a + x + 1][b]--;
        ban[a + x + 2][b + 1]++;
        ban[a + x + 1][b + x + 2]++;
        ban[a + x + 2][b + x + 2]--;
    }

    for (int i = 1; i < n + 2; i++) {
        for (int j = 0; j < n + 2; j++) {
            ban[i][j] += ban[i - 1][j];
        }
    }
    for (int i = 0; i < n + 2; i++) {
        for (int j = 1; j < n + 2; j++) {
            ban[i][j] += ban[i][j - 1];
        }
    }
    for (int i = 1; i < n + 2; i++) {
        for (int j = 1; j < n + 2; j++) {
            ban[i][j] += ban[i - 1][j - 1];
        }
    }

    int ret = 0;
    for (int i = 0; i < n + 2; i++) {
        for (int j = 0; j < n + 2; j++) {
            if (ban[i][j] > 0)ret++;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 100832
mod = 10**9 + 7

N = int(raw_input())
A = map(int, raw_input().split())
A.sort(reverse = True)

ans = 1
for i in xrange(N/2):
    if A[2*i] == A[2*i + 1] == abs((N - 1 - i) - i):
        pass
    else:
        ans = 0
if ans:
    ans = pow(2, N/2, mod)
print ans


Measured memory_bytes: 11304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	long long n, c, k;
	long long t[100000];
	long long co = 0, co1 = 0;
	long long ans = 0;
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t, t + n);
	for (int j = 0; j < n; j++) {
		if (co == 0) {
			co1 = t[j];
		}
		co++;
		if (co1 + k < t[j]) {
			ans++;
			co = 0;
			co1 = 0;
			j--;
			continue;
		}
		if (co == c) {
			if (j != n - 1) {
				ans++;
			}
			co = 0;
			co1 = 0;
			continue;
		}
		
	}
	cout << ans + 1<< endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int mod=998244353;
const int N=10000010;
typedef long long LL;
int n;
int ft[N+1],Ft[N+1],mi2[N+1];
int C(int n,int m){
	return (LL)ft[n]*Ft[m]%mod*Ft[n-m]%mod;
}
int mi(int a,int b){
	int s=1;
	for(;b;b>>=1,a=(LL)a*a%mod)
		if(b&1)s=(LL)s*a%mod;
	return s;
}
int main(){
	scanf("%d",&n);
	ft[0]=1;
	ref(i,1,n)ft[i]=(LL)ft[i-1]*i%mod;
	Ft[n]=mi(ft[n],mod-2);
	def(i,n,1)Ft[i-1]=(LL)Ft[i]*i%mod;
	mi2[0]=1;
	ref(i,1,n)mi2[i]=(LL)mi2[i-1]*2%mod;
	int ans=mi(3,n);
	int s=0,nn=n/2;
	ref(i,nn+1,n)s=((LL)C(n,i)*mi2[n-i+1]+s)%mod;
	ans=(ans+mod-s)%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 117376
#include<stdio.h>

int main(void){
    int i, j, k;

    int score = 0;//満足度

    int d;//何日開催するのか
    scanf("%d", &d);

    int c[26];//各コンテストのペナルティ値
    for(i=0;i<26;i++) scanf("%d", &c[i]);

    int s[d][26];//コンテストiをD日目に開催したときの得点
    for(i=0;i<d;i++) for(j=0;j<26;j++) scanf("%d", &s[i][j]);

    int last[26];//各コンテストを最後に開催したのは何日目か
    for(i=0;i<26;i++) last[i] = 0;

    //int holding[d];//D日目にコンテストiを開催する
    //初期解
    int max_i, max_sum, tmp;
    for(i=0;i<d;i++){//今日=i、今日の終わり=i+1
        max_i = 0;
        max_sum = 0;
        for(j=0;j<26;j++){
            tmp = s[i][j] - c[j] * ( i+1 - last[j] );
            if( max_sum < tmp ){
                max_sum = tmp;
                max_i = j;
            }
        }
        last[max_i] = i+1;
        //holding[i] = max_i + 1;
        printf("%d\n", max_i + 1 );
        //score += s[i][max_i];
        //for(j=0;j<26;j++) score -= c[j] * ( i+1 - last[j] );
    }

    //出力
    //for(i=0;i<d;i++) printf("%d\n", holding[i]);
    //printf("%d\n", score);

    return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  long long k;
  cin>>k;
  long long ans = 0;
  for(long long a = 1; a <= k; a++){
    for(long long b = 1; b <= k; b++){
      for(long long c = 1; c <= k; c++){
        ans += gcd_(gcd_(a, b), c);
      }
    } 
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define PI 3.14159265358979
	#define EPS 1e-8
	#define mod  1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
 
	const ll INF=1e18;	
	const int N=5e5+50;
 
	
	vector<ll> pref,v;
	ll dp[3005][3005];
	
	ll solve(ll l,ll r)
	{
		if(l>r)
			return 0;
		if(dp[l][r]!=-1)
			return dp[l][r];
		ll s=pref[r];
		if(l>0)
			s-=pref[l-1];
		ll ans=max(s-solve(l+1,r),s-solve(l,r-1));
		return dp[l][r]=ans;
	}
	
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);cout.tie(0);
		
		int n;
		cin>>n;
		v=vector<ll> (n);
		pref=vector<ll> (n);
		for(int i=0;i<n;i++)
		{
			cin>>v[i];
			pref[i]=v[i];
			if(i)
			{
				pref[i]+=pref[i-1];
			}
		}
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
				dp[i][j]=-1;
		}
		ll y=solve(0,n-1);
		ll x=pref[n-1]-y;
		cout<<y-x;
	}


Measured memory_bytes: 74136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int mx = 0, mx_i;
	rep(i, N) {
		cin >> A[i];
		if (mx < A[i]) {
			mx = A[i];
			mx_i = i;
		}
	}
	sort(A.begin(), A.end(), greater<int>());
	int mx2 = A[1];
	rep(i, N) {
		if (i == mx_i) {
			cout << mx2 << endl;
		}
		else {
			cout << mx << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        int[] inputs = ReadInts();
        int N = inputs[0];
        int M = inputs[1];
        List<int[]> drink = new List<int[]>();
        for(int i=0;i<N;i++)
        {
            drink.Add(ReadInts());
        }
        drink.Sort((a, b) => a[0] - b[0]);

        long ans = 0;
        int k = 0;
        while(M>=0)
        {
            if(M-drink[k][1]>0)
            {
                M -= drink[k][1];
                ans += (long)drink[k][0] * drink[k][1];
            }
            else
            {
                ans += (long)drink[k][0] * M;
                break;
            }
            k++;
        }

        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 22472
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   vi g,b,r;
   for(int i=0;i<s.length();++i)
   {
   	if(s[i]=='G')
   		g.pb(i+1);
   	else if(s[i]=='B')
   		b.pb(i+1);
   	else if(s[i]=='R')
   		r.pb(i+1);

   }
   vector<pair<int,int>>v;
  
   for(int i=0;i<g.size();++i)
   {
   	for(int j=0;j<b.size();++j)
   	{
   		if(g[i]>b[j])
   		{
          v.pb(mp(b[j],g[i]));
   		}
   		else
   			v.pb(mp(g[i],b[j]));
   	}
   }
   sort(all(r));
   // for(auto x:v)
   // {
   // 	cout<<x.ff<<" "<<x.ss<<endl;
   // }
   int sum=0;
   for(int i=0;i<v.size();++i)
   {
   //	cout<<v[i].ff<<" "<<v[i].ss<<endl;
   	
   	
   		int cnt=0;
   		int d1=(v[i].ff+v[i].ss)/2;
   		if(binary_search(all(r),d1)&&(v[i].ff%2==v[i].ss%2))
   		{
   			++cnt;
   		}
   		if(binary_search(all(r),v[i].ss+(v[i].ss-v[i].ff)))
   			++cnt;
   		if(binary_search(all(r),v[i].ff-(v[i].ss-v[i].ff)))
   			++cnt;
   		sum+=r.size()-cnt;

   	
   	//cout<<sum<<endl;
   }
   cout<<sum;

}

signed main()
{
		noob
		// #ifndef ONLINE_JUDGE
  //    	freopen("input.txt","r",stdin);
  //    	freopen("output.txt","w",stdout);
  //    	#endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 36180
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
 
ll count(ll num1,ll num2){
  if(num1>num2)swap(num1,num2);
  ll k1;
    if((num2-num1)%3==0){
      k1=(num2-num1)/3;
    }else{
      k1=(num2-num1)/3;
      for(ll dif=-2;dif<3;dif++){
        if(num2-2*(k1+dif)<=k1+dif+num1){
          k1+=dif;
          break;
        }
      }
    }
    if(k1<0)return -1;
    ll k2;
    if(k1+num1==num2-2*k1){
      k2=2*k1-2;
    }else{
      k2=num1+num2-k1-1;
    }
    //cout<<k1<<" "<<k2<<" "<<k1+k2<<" "<<num1+num2<<endl;
    return k1+k2;
}
int main(void){
	ll k;
  cin >> k ;
  //t-2*k1<=k1 t<=3*k1
  /* 
  if(t-k1 %2==1){
    k2=t-k1-1;

  }else{
    k2=t-k1-2;
  }
  
  */
  ll ans=k+500;
  ll ans1,ans2;
  int flag2=0;
 if(k<-1){
      rep(i,1000){
        ll c=count(0,ans-i);
        if(c<0)continue;
        if(c==k){
          ans-=i;
          //cout<<k1<<" "<<k2<<endl;
          break;
        }
        if(c<k){
          ll i2=i-1;
          flag2=1;

          rep(j,10000){
            ll num1=j;
            ll num2=ans-i-j;
            ll c2=count(num1,num2);
            if(c2==k){
              ans1=num1;
              ans2=num2;
              break;
            }
          }
          ans-=i;
          break;
        }
    }
  }else{
    ll odd =k%50;
    ll num3=k/50;
    vl a(50,num3-odd+50-1);
    rep(i,odd){
      a[i]+=51;
    }
    cout<<50<<endl;
    rep(i,50){
      cout<<a[i]<<" ";
    }
    return 0;
  }

  cout<<2<<endl;
  if(flag2==0){
    cout<<flag2<<" "<<ans<<endl;

  }else{
    cout<<ans1<<" "<<ans2<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	set<string> s;
	while(n--){
		string str; cin>>str;
		s.insert(str);
	}
	cout<<s.size();
}

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

int main(void){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n-8){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[1001];
		long sum=1;
		for(int i=2;i<=n;i++){
			int t = i;
			for(int j=2;j<=i;j++){
				while(t%j==0){
					x[j]++;
					t/=j;
				}
			}
		}
		long e=(int)1e9+7;
		for(int i=0;i<1001;i++){
			if(x[i]>0){
				sum*=(x[i]+1);
				sum%=e;
			}	
		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 21844
A , V =map(int,input().split())
B , W =map(int,input().split())
T =int(input())

ans = 0
if A < B:
        if A + T*V >= B + T*W:
            ans = 1
elif B < A:
        if A - T*V <= B - T*W:
            ans = 1
            
if ans ==1:
    print("YES")
else:
    print("NO")

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

int rel_l_l( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ) {
	int rel;

	rel = 0;
	if ( fabs( ( x1 - x2 ) * ( x3 - x4 ) + ( y1 - y2 ) * ( y3 - y4 ) ) < 1e-10 )
		rel = 1;
	else if ( fabs( ( x1 - x2 ) * ( y3 - y4 ) - ( y1 - y2 ) * ( x3 - x4 ) ) < 1e-10 ) {
		rel = 2;
		if ( fabs( ( x1 - x3 ) * ( y3 - y4 ) - ( y1 - y3 ) * ( x3 - x4 ) ) < 1e-10 )
			rel = 3;
	}

	return rel;
}

int main( void ) {
	double x1, y1, x2, y2, x3, y3, x4, y4;

	while ( scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4 ) != EOF )
		puts( rel_l_l( x1, y1, x2, y2, x3, y3, x4, y4 ) == 1 ? "YES" : "NO" );

	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<int>())
typedef long long ll;
#define len(s) s.length()

void solve() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>k)
      cout<<k;
    else if((a+b)>=k)
      cout<<a;
    else
      cout<<a-(k-a-b);

}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
      solve();

	  return 0;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
#https://atcoder.jp/contests/abc086/tasks/abc086_a
import sys

#n= int(input())
#s= input()
tmp = input().split()
a,b = list(map(lambda a: int(a), tmp))

if(a%2==0 or b%2==0):
    print("Even")
else:
    print("Odd")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define MAX 100010



int main(){
	int a[MAX], b[MAX], c[MAX], e[MAX], n;
	while(cin >> n, n){
		fill(a, a+MAX, 0);
		fill(b, b+MAX, 0);
		fill(e, e+MAX, 0);
		int x, w = 0, d = 0;
		
		int flag;
		for(int i = 1;i <= n;i++){
			cin >> x;c[i] = x;
			if(i == 1)flag = x;
			
			
			if(i%2 == 0){	//??¶??°
				if(x && !c[i-1]){
					a[w--] = 0;
					b[d--] = 0;
					if(w == -1)w = 0;
					if(d == -1)d = 0;
				}
				if(!x && c[i-1]){
					b[d--] = 0;
					a[w--] = 0;
					if(w == -1)w = 0;
					if(w == -1)d = 0;
				}
			}else {			//?\???°
				/*if(c[i-1] != x && i != 1){
					if(x)a[w++] = i-1;
					if(!x) b[d++] = i-1;
				}*/
			}
			if(x){if(flag)d++, flag = 0;b[d] = i;}
			if(!x){if(!flag)w++, flag = 1;a[w] = i;}
		}
		
		
		/*for(int i = 1;i <= w;i++)cout << a[i] << " ";
		cout << endl;
		for(int i = 1;i <= d;i++)cout << b[i] << " ";
		cout << endl;*/
		
		
		int ans = 0;
		if(a[1] < b[1]){
			//if(w < d)d--;
			ans = a[1];
			for(int i = 2;i <= w;i++){
				ans += a[i] - b[i-1];
			}
		}else{
			//if(w < d)a[w++] = n;
			for(int i = 1;i <= w;i++){
				ans += a[i] - b[i];
			}
		}
		cout << ans << endl;
		
		
	}
	
	return 0;
}

Measured memory_bytes: 4656
N,x = map(int,input().split())
li = list(map(int,input().split()))

newLi = sorted(li)
ans = 0

for i in range(len(newLi)):
  if x - newLi[i] < 0:
    break
   
  if i == (len(newLi) - 1) and x != newLi[i]:
    break
  
  x -= newLi[i]
  ans += 1

print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<int> A;
    static int num[2][200001];
    static vector<int> Apos[200001];
    for(int k=0; k<2; k++) for(int i=0; i<N; i++){
        int a;
        cin >> a;
        num[k][a]++;
        if(k == 0){
            Apos[a].push_back(i);
            A.push_back(a);
        }
    }
    vector<int> nums;
    for(int i=1; i<=N; i++) nums.push_back(i);
    // 前ほどBが多い
    sort(nums.begin(), nums.end(), [&](int i, int j){ return num[0][i]-num[1][i] < num[0][j]-num[1][j]; });

    int offset = 0, mx = 0;
    for(int i=1; i<=N; i++){
        mx = max(mx, num[0][i] + num[1][i]);
    }
    vector<int> V[2];
    for(int i : nums){
        int l0 = V[0].size(), l1 = V[1].size();
        int r0 = l0 + num[0][i], r1 = l1 + num[1][i];
        offset = max(offset, min(r0, r1) - max(l0, l1));
        for(int k=0; k<2; k++) for(int t=0; t<num[k][i]; t++) V[k].push_back(i);
    }

    // for(int k=0; k<2; k++) for(int i=0; i<N; i++) cerr << V[k][i] << " \n"[i==N-1];

    rotate(V[1].begin(), V[1].end()-offset, V[1].end());

    // for(int k=0; k<2; k++) for(int i=0; i<N; i++) cerr << V[k][i] << " \n"[i==N-1];

    vector<int> ans(N);
    for(int i=0; i<N; i++){
        int a = V[0][i];
        int pos = Apos[a].back();
        Apos[a].pop_back();
        ans[pos] = V[1][i];
        if(a == V[1][i]){
            cout << "No" << endl;
            // if(mx <= N){
            //     cerr << " ##### WA #####" << endl;
            //     exit(1);
            // }
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int a : ans) cout << a << " ";
    cout << endl;
    // for(int i=0; i<N; i++) if(A[i] == ans[i]){
    //     for(int i=0; i<N; i++) cerr << A[i] << " \n"[i==N-1];
    //     for(int i=0; i<N; i++) cerr << ans[i] << " \n"[i==N-1];
    //     cerr << "##### WA #####" << endl;
    //     exit(1);
    // }
    return 0;
}


Measured memory_bytes: 19880
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;
const int MAXS = 1000010;
const int MAXT = 2;
char str[MAXT][MAXS];

inline int countTwo(int n) {
    int ret = 0;

    while (n%2 == 0 && n) {
        n /= 2;
        ++ret;
    }

    return ret;
}

int main() {
    int N;

    scanf("%d", &N);
    scanf("%s", str[0]);

    int mulFactor = 2;

    for (int i = 1; i < MAXT && i < 2; ++i) {
        int len = N-i;

        for (int j = 0; j < len; j++) {
            int diff = abs(str[i-1][j+1] - str[i-1][j]);
            if (diff == 1) {
                mulFactor = 1;
            }
            str[i][j] = (diff + '0');
        }

        str[i][len] = '\0';

        // printf("%s\n", str[i]);
        // 12221121
        // 12201011, 122111

        // 12221121
        // 12021101
        // 10201121
        // 10221121
    }

    int len = N - 1;

    if (len == 1) {
        cout << str[1] << endl;
    } else {
        int result = 0;
        int twoCount = 0;

        // cout << "LEN " << len << endl;

        if (mulFactor == 2) {
            for (int i = 0; i < len; ++i) {
                str[1][i] = (str[1][i]/2) + '0';
            }
        }

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

            if (twoCount == 0) {
                result = (result + (str[1][i]-'0')%2)%2;
            }

            twoCount += countTwo(len-i-1);
            twoCount -= countTwo(i+1);
        }

        cout << result * mulFactor << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#define N 100
using namespace std;

void printv(int a[], int k){
	int i;
	for(i=0;i<k-1;i++)
		cout << a[i] << " ";
	cout << a[k-1] << endl;
}

void insertionsort(int a[], int k){
	int i,j;

	for(i=1;i<k;i++){
		printv(a,k);
		int v = a[i];
		j = i - 1;

		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
	}
	printv(a,k);

}

int main(){
	int i,n;
	int a[N];

	cin >> n;

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

	insertionsort(a,n);


}

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

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

  vector<int> x(N);
  for (int i = 0; i < N; i++)
    cin >> x[i];
  sort(x.begin(), x.end());

  int count;
  int ans = 1000000000;
  for (int i = x[0]; i <= x[N - 1]; i++)
  {
    count = 0;
    for (int j = 0; j < N; j++)
      count += (x[j] - i) * (x[j] - i);
    if (count < ans)
      ans = count;
  }
  cout << ans << endl;
}

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

#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
}

const int N = 4000 + 10, mod = 1e9 + 7, bas = 2e3 + 1;
int ans, fac[N << 1], inv[N << 1], f[N][N], tag[N][N];

inline int qpow(int a, int b) {
	static int res;
	for (res = 1; b; b >>= 1, a = 1ll * a * a % mod)
		if (b & 1) res = 1ll * a * res % mod;
	return res;
}

inline void Init(int n) {
	fac[0] = 1; For(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = qpow(fac[n], mod - 2);
	Forr(i, n - 1, 0) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod; 
}

inline int C(int n, int m) {
	if (n < m) return 0;
	return 1ll * fac[n] * inv[n - m] % mod * inv[m] % mod;
}

inline int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }

int main() {
    Init(N * 2 - 10);

	int n = read();
	For(i, 1, n) {
		int x = read(), y = read();
		ans = add(ans, mod - C(x + y << 1, y << 1));
		++ f[bas - x][bas - y]; ++ tag[bas + x][bas + y];
	}
	
	For(i, 1, N - 9) For(j, 1, N - 9) 
		f[i][j] = add(f[i][j], add(f[i - 1][j], f[i][j - 1]));

	For(i, bas, N - 9) For(j, bas, N - 9) 
		ans = add(ans, 1ll * tag[i][j] * f[i][j] % mod);
	
	ans = 1ll * ans * qpow(2, mod - 2) % mod;

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


Measured memory_bytes: 95104
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int n,m;
  vector<int> divisor;
  
  cin >> n >> m;
  
  for(int i = 1 ; i <= int(sqrt(m)) ; i++){
    if(m % i == 0){
      if(i <= m/n) divisor.emplace_back(i);
      if(n <= i) divisor.emplace_back(m/i);
    }
  }
  
  cout << *max_element(divisor.begin(), divisor.end()) << endl;
  
  return 0;
}

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

const int MAX_N = 100000, INF = 1000000000;
int n, k, w[MAX_N + 1], lb = 0, ub = INF, mid;

bool judge(int border){
	int sum = 0, i = 0;
	for(int count = k; count > 0 && i < n; count--){
		for(;sum + w[i] <= border && i < n; i++){
			sum += w[i];
		}
		sum = 0;
	}
	if(i < n){
		return 0;
	}
	return 1;
}

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}
	
	while(ub - lb > 1){
		mid = (ub + lb) / 2;
		
		if(judge(mid)){
			ub = mid;
		} else{
			lb = mid;
		}
	}
	
	printf("%d\n", ub);
	return 0;
}

Measured memory_bytes: 1412
#include <cstdio>

int cnt[10][10];

int main()
{
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cnt[i][j] = 0;
	for (int i = 1; i <= n; i++)
	{
		int h = i;
		while (h/10 > 0) h/=10;
		int l = i%10;
		cnt[h][l]++;
	}
	for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) ans += cnt[i][j]*cnt[j][i];
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	string a[505];
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	int c1[505][505], c2[505][505], d[505][505];
	int s[505][505];
	ll ans=0;
	for(int i=0; i<n; i++){
		bool b[505][505]={};
		for(int j=0; j<n; j++) if(a[i][j]=='#') b[i][j]=1;
		for(int k=i+1; k<n; k++){
			for(int j=0; j<n; j++){
				if(a[k][j]=='#'){
					b[k][j]=1; continue;
				}
				if(b[k-1][j] && (j==0 || b[k][j-1])) b[k][j]=1;
			}
		}
		for(int k=i; k<n; k++){
			s[k][0]=0;
			for(int j=0; j<n; j++){
				s[k][j+1]=s[k][j];
				if(!b[k][j]) s[k][j+1]+=(a[k][j]-'0');
			}
		}
		for(int k=i; k<n; k++){
			for(int j=0; j<n; j++){
				if(b[k][j]){
					if(j>0) c1[k][j]=c1[k][j-1];
					else c1[k][j]=-1;
				}else c1[k][j]=j;
			}
			for(int j=n-1; j>=0; j--){
				if(b[k][j]){
					if(j<n-1) c2[k][j]=c2[k][j+1];
					else c2[k][j]=n;
				}else c2[k][j]=j;
				if(!b[k][j]){
					if(j==n-1 || b[k][j+1]) d[k][j]=j;
					else d[k][j]=d[k][j+1];
				}
			}
		}
		for(int j=0; j<n; j++){
			if(a[i][j]=='#') continue;
			int l=j, r=d[i][j];
			ll sum=s[i][r+1]-s[i][l+1];
			for(int k=i+1; k<n; k++){
				if(b[k][l]){
					l=c2[k][l];
				}
				if(b[k][r]){
					r=c1[k][r];
				}else{
					r=d[k][r];
				}
				if(l>r) break;
				sum+=s[k][r+1]-s[k][l];
			}
			ans+=sum*(a[i][j]-'0');
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
 int main(){
   int n,m[100],x,min=1000;
   cin>>n>>x;
   for(int i=0;i<n;i++){
     cin>>m[i];
     x-=m[i];
     if(m[i]<min)min=m[i];
   }
  cout<<x/min+n<<endl;
  return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int sum=0;
  string u;
  cin>>u;
  rep(i,0,u.size()){
    rep(j,0,u.size()){
      if(u.at(i)==u.at(j))
        ++sum;
    }
    if(sum%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
    sum=0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256