akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	int N = ni();
    	int K = ni();

    	String[] P = nsa(N);

    	int[] cnt = new int[26];

    	for (int i=0; i<N; i++) {
			cnt[P[i].charAt(0) - 'A']++;
		}

    	int ans = 0;
    	boolean flg = true;
    	while (flg) {
    		Arrays.sort(cnt);
    		for (int i=0; i<K; i++) {
    			if (cnt[25 - i] == 0) {
    				flg = false;
    				break;
    			}
    			cnt[25 - i]--;
    		}
    		if (!flg) break;
    		ans++;
    	}

    	out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


Measured memory_bytes: 12880
n,x=map(int,raw_input().split())
ans=[0]*(2*n-1)
if x-1>=1 and x+1<=2*n-1:
    print("Yes")
    ans[(2*n-1)/2]=x
    ans[(2*n-1)/2+1]=x+1
    ans[(2*n-1)/2-1]=x-1
    j=1
    i=0
    while i<2*n-1:
        if j==x or j==x-1 or j==x+1:
            j+=1
            continue
        if ans[i]!=0:
            i+=1
            continue
        else:
            ans[i]=j
            j+=1
            i+=1
    for i in xrange(2*n-1):
        print(ans[i])
else:
    print("No")

Measured memory_bytes: 10244
// C - Colorful Leaderboard
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n), e(8, 0);
  rep(i, 0, n)
  {
    cin >> d[i];
    if (d[i] <= 399)
    {
      e[0]++;
    }
    else if (d[i] >= 400 && d[i] <= 799)
    {
      e[1]++;
    }
    else if (d[i] >= 800 && d[i] <= 1199)
    {
      e[2]++;
    }
    else if (d[i] >= 1200 && d[i] <= 1599)
    {
      e[3]++;
    }
    else if (d[i] >= 1600 && d[i] <= 1999)
    {
      e[4]++;
    }
    else if (d[i] >= 2000 && d[i] <= 2399)
    {
      e[5]++;
    }
    else if (d[i] >= 2400 && d[i] <= 2799)
    {
      e[6]++;
    }
    else if (d[i] >= 2800 && d[i] <= 3199)
    {
      e[7]++;
    }
    else
    {
      count++;
    }
  }
  rep(i, 0, 8)
  {
    if (e[i] >= 1)
    {
      ans++;
    }
  }
  if (n == count)
  {
    std::cout << 1 << " " << count << endl;
  }
  else
  {
    std::cout << ans << " " << ans + count << endl;
  }
}

Measured memory_bytes: 3612
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


n,k=map(int,input().split())
for i in range(1,k+1):
  print((cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod))%mod)

Measured memory_bytes: 122284
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e15+100))
#define MX ((ll)(4e9+100))
#define ARRS ((ll)(2e6+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21

ll n,m;
ll a[ARRS];
string s;
ll f[ARRS];



int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba")
		cout<<-1;
	if(s.size()!=26){
		for(int i=0; i<s.size(); i++)f[s[i]]=1;
		for(char c='a'; c<='z'; c++)
			if(!f[c]){s+=c;break;}
		cout<<s;
		return 0;
	}
	
	for(int i=s.size()-1; i>=0; i--){
		char mn='z'+1;
		for(int j=i+1; j<s.size(); j++){
			if(s[i]<s[j])
				mn=min(s[j],mn);
		}
		//cout<<mn<<endl;
		if(mn!='z'+1){
			s[i]=mn;
			for(int j=0; j<=i; j++)
				cout<<s[j];
			return 0;
		}
	}
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = 0;
    for (int a = 1; a < N; ++a) {
        ans += (N - 1) / a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (sizeOf(x) < sizeOf(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int sizeOf(int x) { return -parent[root(x)]; }
};


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N, Q; cin >> N >> Q&&N;) {
		vector<int> p(N); rep(i, 1, N) {
			cin >> p[i]; p[i]--;
		}
		vector<char> c(Q);
		vector<int> a(Q);
		vector<int> mark(N, -1);
		mark[0] = true;
		rep(i, 0, Q) {
			cin >> c[i] >> a[i];
			a[i]--;
			if (c[i] == 'M'&&mark[a[i]] == -1) {
				mark[a[i]] = i;
			}
		}
		UnionFind uf(N);
		vector<int> anc(N);
		iota(all(anc), 0);
		rep(i, 0, N) {
			if (mark[i] == -1) {
				int t = anc[uf.root(p[i])];
				uf.unite(i, p[i]);
				anc[uf.root(i)] = t;
			}
		}
		int ans = 0;
		rrep(i, 0, Q) {
			if (c[i] == 'Q')
				ans += anc[uf.root(a[i])] + 1;
			else {
				if (mark[a[i]] != i)continue;
				int t = anc[uf.root(p[a[i]])];
				uf.unite(a[i], p[a[i]]);
				anc[uf.root(a[i])] = t;
			}
		}
		cout << ans << endl;
	}
	return 0;

}

Measured memory_bytes: 6924
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
 
int main(){
    int N;
    int K;
    cin >> N >> K;
    int64_t H[N];
    for (int i = 0; i < N; ++i){
        cin >> H[i];
    } 
    vector<int64_t> Hv(H,H+sizeof(H)/sizeof(H[0]));
    sort(Hv.begin(),Hv.end(),greater<int64_t>());
    int64_t sum=0;
    sum=accumulate(Hv.begin()+min(K,N),Hv.end(),0LL);
    cout << sum << endl;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cmath>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
typedef long long ll;

int A, B;

int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

int main() {
	S2(A, B);
	printf("%lld", (ll)A * B / gcd(A, B));
}



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	if (a.size() != n) cout << "NO";
	else cout << "YES";

	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	n := readInt()
	d := make([]int, n)
	for i := range d {
		d[i] = readInt()
	}

	sort.Ints(d)

	if d[n/2] == d[n/2-1] {
		fmt.Println(0)
	} else {
		fmt.Println(d[n/2] - d[n/2-1])
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vi s(m), c(m);
    rep(i,m) cin >> s.at(i) >> c.at(i);
    // 先に数字を準備して並び変えておけばよい
    vi candidate;
    vi filteredCandidate;
    if(n==1){
        for(int64_t i=0; i<10; i++) candidate.push_back(i);
        for(int64_t can :candidate){
            bool res = true;
            for(int64_t j=0; j<m; j++){
                if(to_string(can).at(s.at(j)-1)!=c.at(j)+48) res = false;
            }
            if(res) filteredCandidate.push_back(can);
        }
    }
    if(n==2){
        for(int64_t i=10; i<100; i++) candidate.push_back(i);
        for(int64_t can :candidate){
            bool res = true;
            for(int64_t j=0; j<m; j++){
                if(to_string(can).at(s.at(j)-1)!=c.at(j)+48) res = false;
            }
            if(res) filteredCandidate.push_back(can);
        }
    }
    if(n==3){
        for(int64_t i=100; i<1000; i++) candidate.push_back(i);
        for(int64_t can :candidate){
            bool res = true;
            for(int64_t j=0; j<m; j++){
                if(to_string(can).at(s.at(j)-1)!=c.at(j)+48) res = false;
            }
            if(res) filteredCandidate.push_back(can);
        }
    }
    cout << (filteredCandidate.empty() ? (-1) : filteredCandidate.at(0)) << endl;
}

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

using namespace std;
int x[10];
int y[10];

double dist(int i, int j)
{
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy , 0.5);
}

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

	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> x[i] >> y[i];
	vector <int> v(n);
	for(int i=0; i<n; i++) v[i] = i+1;
	double sum = 0;
	do{
		for(int i=0; i<n-1; i++){
			sum += dist(v[i],v[i+1]);
		}
	} while (next_permutation(v.begin(),v.end()));

	int permut = 1;
	for(int i=2; i<=n; i++)
		permut *= i;

	cout << fixed << setprecision(10) << sum / permut << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        x=(e*c-b*f)/(e*a-b*d);
        y=(c-a*x)/b;
        x+=0.0004;
y+=0.0004;
        
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
    
}


Measured memory_bytes: 2056
r_num, c_num = gets.split.map(&:to_i)

row_sum = Array.new(r_num) { 0 }
col_sum = Array.new(c_num) { 0 }

r_num.times do |i|
  row = gets.split.map(&:to_i)
  row_sum[i] = row.inject(&:+)

  print "#{row.join(' ')} #{row_sum[i]}"

  row.each_with_index do |col, index|
    col_sum[index] += col
  end
  puts
end

puts "#{col_sum.join(' ')} #{row_sum.inject(&:+)}"

Measured memory_bytes: 8792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

class BGoldenApple {
public:
	void solve(std::istream& in, std::ostream& out){
	    int N,D;
	    in >> N >> D;
	    out << (int)ceil((double)N/(2*D+1));
	}
};


int main() {
	BGoldenApple solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
#define inf 2e9
using namespace std;

int main(int argc, char **argv){
    int n,d,c=0;
    cin>>n>>d;
    d = d*2+1;
    for(;;){
        n -= d;
        c++;
        if(n<=0){
            cout<<c<<endl;
            return 0;
        }
    }
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n;
    string s;
    cin >> n;
    cin >> s;

    static int cnt[200001];
    for(int i=1;i<=n;i++) cnt[i] = cnt[i-1] + (s[i-1]=='.' ? 1 : 0);
    int ans = n;
    for(int i=0;i<=n;i++){
        ans = min(ans, i-cnt[i] + cnt[n]-cnt[i]);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    priority_queue<ll> P, Q, pool;
    rep(a,A){
        ll p;
        cin >> p;
        P.push(p);
    }
    rep(b,B){
        ll q;
        cin >> q;
        Q.push(q);
    }
    rep(c,C){
        ll r;
        cin >> r;
        pool.push(r);
    }

    rep(x,X) {
        pool.push(P.top());
        P.pop();
    }
    rep(y,Y){
        pool.push(Q.top());
        Q.pop();
    }
    ll sum = 0;
    rep(i,X+Y){
        sum += pool.top();
        pool.pop();
    }
    cout << sum << endl;
    return 0;
} 

Measured memory_bytes: 7920
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

map<pair<int,int>,ll> ma;

ll a[N];

int n;

ll solve(int ind,int left)
{
  	if(left==0)
     return 0;
		
	if(left>(ind+1)/2)
	return -1e18; 

	if(ma.find({ind,left})!=ma.end())
	return ma[{ind,left}];

	ll x,y;

	x=a[ind]+solve(ind-2,left-1);

	y=solve(ind-1,left);

	//if(ind==n)
	//cout<<x<<" "<<y<<endl;

	ma[{ind,left}]=max(x,y);

	return max(x,y);
}

int main()
{
	scn(n);

	rep(i,1,n+1)
	lscn(a[i]);

	ll ans=solve(n,n/2);

	lpri(ans);

    return 0;
}


Measured memory_bytes: 31904
import math
N = int(input())
prime = []
kako = []

def hantei(n):
    for i in range(2,int(math.sqrt(n)+2)):
        if n % i == 0:
            return False
    return True

for i in range(3,55555):
    if hantei(i) and i % 5 == 1:
        prime.append(i)
    if len(prime) >= 55:
        ans = ""
        for s in range(N):
            if s != N-1:
                ans += str(prime[s]) + " "
            else:
                ans += str(prime[s])
        print(ans)
        quit()    

Measured memory_bytes: 3064
#define _DEBUG 1

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve(ll N, std::string S) {

  int leftStack = 0; // '('

  int len = N;
  int i = 0;
  while (i < len) {
    if (S.at(i) == '(') {
      leftStack++;
    } else { // ')'
      if (leftStack == 0) {
        S.insert(0, "("); // 先頭に(を挿入
        i++;
        len++;
      } else {
        leftStack--;
      }
    }
    i++;
  }
  if (leftStack != 0) {
    rep(i, leftStack) { S.append(")"); }
  }

  cout << S << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


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

using namespace std;

int main(){
    int n,ans = 0;
    string s;
    cin >> n >> s;

    for(int i = 0;i < n;i++){
        int count = 0;
        for(char c='a';c <='z';c++){
            bool l = false,r = false;
            for(int j = 0;j < i;j++)
                if(s[j] == c)
                    l = true;
            for(int j  = i;j < n;j++)
                if(s[j] == c)
                    r = true;
            
            if(l&&r)count++;
        }
        ans = max(ans,count);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

int fun(int a,int b,int c){
    int f,l;
    f=a/2; l = (a/2)+(a%2);
    return  (abs(f-l)*b*c);
}

inline void solve(){
    int  a,b,c; 
    cin >> a >> b >> c ; 
    if (a%2==0 or b%2==0 or c%2==0) cout << 0 << endl ,exit(0);
    int ans=a*b*c;
    ans = min(ans,fun(a,b,c));
    ans = min(ans,fun(b,a,c));
    ans = min(ans,fun(c,a,b));
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
 
int main(void)
{
  int x = 0, a = 0;
  cin >> x >> a;
  
  if(x < a)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 10 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF LONG_LONG_MAX
#define pb push_back
#define mp make_pair
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define left(x) x<<1
#define right(x) (x<<1)|1
#define PI acos(-1.0)
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef map<string,ll> msi;
typedef set<ll> si;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 
ordered_set;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> 
ordered_multiset;

ll solve(){
    int a,b;
    cin>>a>>b;
    if(a+b==15)
        cout<<"+";
    else if(a*b==15)
        cout<<"*";
    else
        cout<<"x";
    return 0;
}

int main(){
   
    int T=1;
    //scanf("%d",&T);
    for(int i=1;i<=T;++i){
        solve();
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n][3];
    for(int i=0;i<n;i++){
        cin >> a[i][0]>>a[i][1]>>a[i][2];
    }
    int dp[n][3]; dp[0][0]=a[0][0]; dp[0][1]=a[0][1]; dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
    }
    cout<<max(dp[n-1][1],max(dp[n-1][2],dp[n-1][0]));
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define for0(i,n) for(long long i=0;i<n;i++)
#define sp <<" "<<
#define ll long long int
#define pb(v,i) v.push_back(i)
#define er(v,i) v.erase(v.begin()+i)
#define MOD 1000000007
#define tin 1000000000
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main() 
{
    ios
    ll j,i,n,t,l,c,h,k,da,m,maxi,d,s,x,y;
    cin>>n>>k;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
     }
     ll dp[n]={0};
     for(i=1;i<n;i++)
     {
     	x=999999999;
     	// y=999999999;
     	// if(i>=1)
     	// 	x=dp[i-1]+abs(arr[i]-arr[i-1]);
     	// if(i>=2)
     	// 	y=dp[i-2]+abs(arr[i]-arr[i-2]);
     	for(j=1;j<=k;j++)
     	{
     		if(i>=j)
     		{
     			x=min(x,dp[i-j]+abs(arr[i]-arr[i-j]));
     		}
     	}
     	dp[i]=x;

     }
     cout<<dp[n-1];
     

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)v.size()
#define endl "\n"
#define ff first
#define ss second
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll INF=1e29;
const ll MOD=1e9+7;
const ll nxm=2e7+5;
bool c(pair<ll,ll> a,pair<ll,ll> b){    return a.ss>b.ss;    }
bool sgn(ll a){ if(a>=0) return 1 ;return 0;}
void solve()
{
ll x,n;
cin>>x>>n;
bool ok=1;
ll a[n];
REP(i,n) {cin>>a[i];
if(a[i]==x)
ok=0;}
if(ok)
{
    cout<<x;return;
}
sort(a,a+n);
for(ll i=1;i<=x;i++)
{
    ll target=x-i;
    ll l=0,h=n-1;
    bool found=0;
    while(l<=h)
    {
        ll mid=l+(h-l)/2;
        if(a[mid]==target)
        {
            found=1;
            break;
        }
        if(a[mid]>target)
        {
            h=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    if(!found)
    {
        cout<<target;
        return;
    }
    target=x+i;
    l=0,h=n-1;
    found=0;
    while(l<=h)
    {
        ll mid=l+(h-l)/2;
        if(a[mid]==target)
        {
            found=1;
            break;
        }
        if(a[mid]>target)
        {
            h=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    if(!found)
    {
        cout<<target;
        return;
    }
}

}
int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3656
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()

    cnt = 0
    for i in range(N):
        if (i + 1)%3 == 0 or (i + 1)%5 == 0: continue
        cnt += i + 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10048
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  	int n;
  	cin >> n;
  	int i=9;
  	int ans;
  	bool flag =false;
  	while(i>=1){
      	ans = n%i;
     	 if((ans == 0) && (flag == false)){
           n /= i;
           flag = true;
         }
      	else if((ans == 0) && (flag == true)){
          n /= i;
          break;
        }
      	else{
         	i--; 
        }
    }
  if(n ==1)cout << "Yes";
  else cout << "No";
  
  return 0;
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++) {
        cin >> a.at(i);
    }
    int count = 0;
    int i = 0;
    while(true) {
        i = a.at(i) - 1;
        count++;
        if(i == 1) {
            cout << count << endl;
            break;
        }
        if(count > n) {
            cout << -1 << endl;
            break;
        }
    }
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c - a) <= d) return !printf("Yes");
    if(abs(c - b) <= d and abs(a - b) <= d) return !printf("Yes");
    printf("No\n");
}

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

int N;
int store[100007];

int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &store[i]);
    }

    sort(store+1, store+N+1);

    if (N % 2) cout << 0 << "\n";
    else cout << store[ (N/2)+1 ] - store[N/2] << "\n";
}


Measured memory_bytes: 640
from sys import stdin
import math
import fractions
from collections import deque
import sys

# 再起の上限を変更
sys.setrecursionlimit(100000)

INF = 10 ** 10

# 深さ優先探索
def dfs(i):
    global is_visited
    global tsort_res

    if is_visited[i]:
        return 

    is_visited[i] = True
    for j in nextl[i]:
        dfs(j)
    
    # 帰りがけ順で追加
    # 追加は先頭に行う
    tsort_res.appendleft(i)


# トポロジカルソート
def tsort():
    for i in range(1, N+1):
        dfs(i)

if __name__ == "__main__":

    N, M = [int(x) for x in stdin.readline().rstrip().split()]

    # 頂点iにたどり着くまでの最大長
    dp = [0] * (N+1)

    # 頂点xから頂点vへの有向辺
    nextl = [[] for _ in range(N+1)]
    for _ in range(M):
        x, v = list(map(int, stdin.readline().rstrip().split()))
        nextl[x].append(v)
    
    # トポロジカルソートされた結果の入るリスト
    tsort_res = deque([])

    is_visited = [False] * (N+1)

    # トポロジカルソートの実行
    tsort()


    for x in tsort_res:
        for v in nextl[x]:
            dp[v] = max(dp[v], dp[x] + 1)

    # for DEBUG
    #print(dp)
    print(max(dp))

Measured memory_bytes: 149176
function f()
    input = map(x -> parse(Int, x), split(chomp(readline()), " "))
    a = input[1]
    b = input[2]
    c = input[3]

    d = floor(b / a)


    if b < a
        print("0")
    elseif d >= c
        print(c)
    else
        print(Int(d))
    end
end
f()


Measured memory_bytes: 167048
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {

    char S[4];
    scanf("%s", S);

    int n = 0;
    REP(0, i, 4) {
        if (S[i] == '+') n++;
        else n--;
    }

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

    return 0;
}


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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

int main(){
    double a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f){
        double x,y;
        y=(f-d*c/a)/(e-d*b/a);
        x=(c-b*y)/a;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 3056
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define Spa putchar(32)
const int maxn=111111;
int stk[maxn],top;
char ss[maxn];
int read()
{
	int s=0,c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
} 
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	scanf("%s",ss+1);
	int ans=0;
	int len=strlen(ss+1);
	for(int i=1;i<=len;++i)
	{
		if(top&&ss[i]!=stk[top])
		{
			--top;
			ans+=2;
		}
		else stk[++top]=ss[i];
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; long long m; cin >> n >> m;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (i != 0) v[i] += v[i-1];
    v[i] %= m;
  }
  map<long long, long long> c; c[0]++;
  for (int i = 0; i < n; i++) {
    c[v[i]]++;
  }
  long long ans = 0;
  for (auto it = c.begin(); it != c.end(); it++) {
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n; cin >> n;
  vector<int> p(n*n);
  rep(i,n*n) {
    cin >> p[i];
  }

  vector<vector<int>> c(n+1, vector<int>(n+1));
  rep1(i,n) rep1(j,n) {
    c[i][j] = min({i-1, n-i, j-1, n-j});
  }

  auto show = [&]()-> void{
		rep1(i,n) {
		  rep1(j,n) cout << c[i][j] << " ";
		  cout << "\n";
		}  
	      };
  
  vector<vector<bool>> f(n+1, vector<bool>(n+1, true));
  using pi = pair<int,int>;
  vector<int> dx = {1, 0, -1, 0};
  vector<int> dy = {0, 1, 0, -1};
  int res = 0;
  rep(i,n*n) {
    int x = (p[i] + n - 1)/n;
    int y = (p[i] % n == 0 ? n : p[i] % n);
    res += c[x][y];
    f[x][y] = false;
    queue<pi> q;
    q.push({x, y});
    while( !q.empty() ) {
      pi pp = q.front(); q.pop();
      int xx = pp.first, yy = pp.second;
      vector<pi> buf;
      rep(j,4) {
	int nx = xx + dx[j];
	int ny = yy + dy[j];
	if(0 < nx && nx <= n && 0 < ny && ny <= n) {
	  buf.push_back({nx, ny});
	}
      }
      rep(j,buf.size()) {
	int nx = buf[j].first;
	int ny = buf[j].second;	
	if(chmin(c[nx][ny], c[xx][yy] + f[xx][yy])) {
	  q.push({nx, ny});
	}
      }
    }
  }
  cout << res << "\n";
  return 0;
}


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

typedef long long ll;
typedef pair <int , int> pii;
typedef long double ld;

const int N = 3e5+10 , mod = 1e9+7;

int cntr[N] , cntc[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , m , k;
   cin >> n >> m >> k;
   map <pii , bool> mp;
   for(int i = 0 ; i < k ; i++){
      int x , y;
      cin >> x >> y;
      x--; y--;
      cntr[x]++;
      cntc[y]++;
      mp[{x , y}] = true;
   }
   int mxr = -1 , mxc = -1;
   vector <int> rid , cid;
   for(int i = 0 ; i < n ; i++){
      if(cntr[i] > mxr){
         mxr = cntr[i];
         rid.clear();
         rid.push_back(i);
      }
      else if(cntr[i] == mxr){
         rid.push_back(i);
      }
   }
   for(int i = 0 ; i < n ; i++){
      if(cntr[i] > mxr){
         mxr = cntr[i];
         rid.clear();
         rid.push_back(i);
      }
      else if(cntr[i] == mxr){
         rid.push_back(i);
      }
   }
   for(int i = 0 ; i < m ; i++){
      if(cntc[i] > mxc){
         mxc = cntc[i];
         cid.clear();
         cid.push_back(i);
      }
      else if(cntc[i] == mxc){
         cid.push_back(i);
      }
   }
   for(int x : rid){
      for(int y : cid){
         if(!mp[{x , y}])
            return cout << mxr + mxc , 0;
      }
   }
   cout << mxr + mxc - 1;
   return 0;
}


Measured memory_bytes: 29776
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

int ctoi(char c) {
	return c - '0';
}


int main()
{
	string s;
	bool b = true;

	cin >> s;

	int len = s.length();

	vector<int> cnt(len);
	vector<int> first_L;
	vector<int> first_R;

	for (int i = 0; i < len - 1; i++) {
		int j = 0;
		if (s[i] == 'R' && s[i + 1] == 'L') {
			first_R.push_back(i);
			first_L.push_back(i + 1);
		}
	}

	int fL_ptr = 0;
	for (int i = 0; i < len; i++) {
		if (s[i] == 'R') {
			for (; fL_ptr < first_L.size(); fL_ptr++) {
				if (i < first_L[fL_ptr])
					break;
			}
			cnt[first_L[fL_ptr] - ((first_L[fL_ptr] - i) % 2)]++;
		}
	}

	int fR_ptr = first_R.size() - 1;
	for (int i = len - 1; i >= 0; i--) {
		if (s[i] == 'L') {
			for (; fR_ptr >= 0; fR_ptr--) {
				if (first_R[fR_ptr] < i)
					break;
			}
			cnt[first_R[fR_ptr] + ((i - first_R[fR_ptr]) % 2)]++;
		}
	}

	for (int i = 0; i < len; i++) {
		cout << cnt[i] << " ";
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    int sum=0,x;
    rep(i,n){
        cin>>x;
        sum+=x-1;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  vector<double> VD;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
#define POW2(a) pow(a, 2.0)
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b;
	printf("%.8f\n", ((double)a*(double)b) / 3.305785);

#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

  string s; cin >> s;

  string tmps = s;
  reverse(tmps.begin(), tmps.end());
  if(s != tmps) {
    cout << "No" << endl;
    return 0;
  }

  int range = (s.size() - 1) / 2;
  tmps = "";
  rep(i, range) {
    tmps += s[i];
  }

  string bef = tmps;
  reverse(tmps.begin(), tmps.end());
  if(bef != tmps) {
    cout << "No" << endl;
    return 0;
  }

  tmps = "";
  for(int i = ((s.size() + 3) / 2) - 1; i < s.size(); ++i) {
    tmps += s[i];
  }

  bef = tmps;
  reverse(tmps.begin(), tmps.end());
  if(bef != tmps) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
  {
    cin >> l[i];
  }
  sort(l.begin(), l.end());

  int sum = 0;
  for (int i = 0; i < n - 1; i++)
  {
    sum += l[i];
  }

  if (l[n - 1] < sum)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<=(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int a, b;
  int ans = 0;
  int now = 1;
  cin >> a >> b;

  for(;;){
      if(now >= b){break;}
      ans++;
      now += a - 1; 
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(N-1) << endl;
}

int j(string S, int a, int b){
  for(int i=0; i<=b-a; i++){
    if(S.at(i+a)!=S.at(b-i)) return 0;
  }
  return 1;
}

int main(){
  string S; cin >> S;
  int N = S.size();
  int res = j(S,0,N-1)*j(S,0,(N-1)/2-1)*j(S,(N+3)/2-1,N-1);
  if(res==1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int[] a = new int[7];
		for (int i=0; i<7; i++) {
			a[i] = in.nextInt();
		}
		long ans1 = a[1]*2;
		long ans2 = ans1;

		ans1 += a[0]/2*4;
		ans1 += a[3]/2*4;
		ans1 += a[4]/2*4;

		if (a[0] > 0 && a[3] > 0 && a[4] > 0) {
			a[0]--;
			a[3]--;
			a[4]--;
			ans2 += a[0]/2*4;
			ans2 += a[3]/2*4;
			ans2 += a[4]/2*4;
			ans2 += 6;
		}

		out.println(Math.max(ans1, ans2)/2);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 9812
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> cnt(n_max);
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    ll q; cin >> q;
    rep(i,0,q){
        ll b,c; cin >> b >> c;
        ll t = cnt[b];
        sum -= b * cnt[b];
        sum += c * cnt[b];
        cnt[b] = 0;
        cnt[c] += t;
        cout << sum << "\n";
    }

}

Measured memory_bytes: 5572
w = int(input())
ans = ""
while w:
  if w % 3 == 0:
    ans += "0"
    w //= 3
  elif w % 3 == 1:
    ans += "+"
    w //= 3
  elif w % 3 == 2:
    ans += "-"
    w = (w + 1) // 3
print(ans[::-1])


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

#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for (int i=0; i<n; ++i)

int main() {
//  std::cout<<std::fixed<<std::setprecision(10);
  int a, b; cin >> a >> b;
  string aa="";
  rep(i, b){
    aa += to_string(a);
  }
  string bb="";
  rep(i, a){
    bb += to_string(b);
  }
  string ans = aa > bb? bb : aa;
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	int i, sum[ 4 ][ 2 ] = {};
	double sight[ 2 ];

	while ( scanf( "%lf %lf", sight, sight + 1 ) == 2 )
		for ( i = 2; i--;  )
			if ( sight[ i ] < 0.2 )
				sum[ 0 ][ i ]++;
			else if ( sight[ i ] < 0.6 )
				sum[ 1 ][ i ]++;
			else if ( sight[ i ] < 1.1 )
				sum[ 2 ][ i ]++;
			else
				sum[ 3 ][ i ]++;

	for ( i = 4; i--;  )
		printf( "%d %d\n", sum[ i ][ 0 ], sum[ i ][ 1 ] );

	return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //input
    int x;
    cin >> x;
    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    [[maybe_unused]] const int LIMIT = 1000000256;
    [[maybe_unused]] const int tenfive = 100000;
    
    
}

using namespace atcoder;

int main(void){
    int x;
    cin >> x;
    int ans = 1;
    int stk;
    for(int i=1;i<40;i++){
        stk = i;
        for(int j = 1;j<11;j++){
            stk*=i;
            if(stk <= x){
                //cerr << stk << endl;
                ans = max(ans,stk);
            }
        }
        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256