akhauriyash/Code-Regression huggingface dataset:
N, X, T = map(int, input().split())
count = 1
check = X
if X > 1:
    while True:
        value = int(N / X)
        result = N % X
        if result == 0:
            count = value
            TotalTime = T * count
            break
        else:
            count += value
            TotalTime = T * count
            break
else:
    TotalTime = T * N

print(TotalTime)

Measured memory_bytes: 9024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {

  int x, n, p;
  int a[102] = {0};
  int res = 1000;   //適当な大きい初期値
  int ans = 0;      //適当な初期値
  cin >> x >> n;
  for(int i=0; i<n; ++i) {
    cin >> p;
    a[p] = 1;
  }

  /*res = x-0;  //最小のものが正に無いときは0が最小である
  ans = 0;
  res = min(res, abs(101-x)); //最小のものが100までにないときは101が最小である
  if(res!=x-0) ans = 101;

  for(int i=1; i<=100; ++i) {
    if(a[i]==0) {
      if(res>abs(i-x)) {
        res = abs(i-x);
        ans = i;
      }
    }
  }*/

  for(int i=0; i<=101; ++i) {
    if(a[i]==0) {
      if(res>abs(i-x)) {
        res = abs(i-x);
        ans = i;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

const int N = 100010;

int a[N];
int K;
int f[N];

int dp(int n) {
	if (n <= 0) return 0;
	if (n < K) return (f[n] = abs(a[n] - a[0]));
	if (f[n] != -1) {
		// cout << "f[" << n << "] = " << f[n] << "\n";
		return f[n];
	}
	int best = 2e9;
	for(int i = 1 ; i <= K ; i++) {
		best = min(best, dp(n - i) + abs(a[n] - a[n - i]));
	}
	// cout << "f[" << n << "] = " << best << "\n";
	return (f[n] = best);
}

int main() {
	for(int i = 0 ; i < N ; i++) {
		f[i] = -1;
	}
	int n; cin >> n >> K;
	for(int i = 0 ; i < n ; i++) {
		cin >> a[i];
	}
	cout << dp(n - 1) << "\n";
}


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

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

  REP(i, T.length())
  {
    if (T[i] == 'P')
      cout << "P";
    else
      cout << "D";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,y;
    cin>>n>>y;
    rep(i,n+1){
        if((y-1000*n-10000*i+1000*i)%4000==0){
            ll j=(y-1000*n-10000*i+1000*i)/4000;
            ll k=n-i-j;
            if(j>=0 && j<=n && k>=0 && k<=n && i+j+k==n){
                cout<<i<<' '<<j<<' '<<k<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 256
program prob2
    implicit none
    integer(8)::N,i,j,M,ans,P,X
    integer(8),allocatable::T(:)
    read(*,*) N
    allocate(T(N))
    read(*,*) T
    ans = sum(T)
    read(*,*) M
    do i = 1,M
        read(*,*) P,X
        write(*,*) ans - T(P) + X
    end do
    stop
end program

Measured memory_bytes: 2860
#define LOCAL

#undef _GLIBCXX_DEBUG

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

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

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 += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

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 << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	int n; cin >> n;
	for (int i = 0; i <= 50000; i++) {
		if (i * 108 / 100 == n) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << ":(";
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main () {
	long long x, y;
	cin >> x >> y;
	if (abs(x - y) >= 2) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Brown" << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>

using namespace std;

int main(void){
    int N,ans[10001]={};
    cin >> N;
    for(int i=1;i <= sqrt(N);i++){
        for(int j=1;j <= sqrt(N);j++){
            for(int k=1;k <= sqrt(N);k++){
                if(i*i + j*j + k*k + i*j + j*k + k*i <= 10000){
                    ans[i*i + j*j + k*k + i*j + j*k + k*i]++;
                }   
            }
        }
    }

    for(int i=0;i < N;i++){
        printf("%d\n",ans[i+1]);
    }
    return 0;
}

Measured memory_bytes: 3748
H=int(input())
import math
count=1
j=0
a=True

while a==True:
    if math.floor(H/2)!=0:
        H=math.floor(H/2)
        count=count+1
    else:
        a==False
        break

for i in range(count):
    j=j+2**(i)

print(j)


Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int N = Integer.parseInt(sc.next());
//		int S = Integer.parseInt(sc.next());
		String[] S = sc.next().split("");
		
		int x = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			x += S[i].equals("I") ? 1 : -1;
			max = x > max ? x : max;
		}
		
		System.out.println(max < 0 ? 0 : max);
	}
}


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

int main(){
    int N;
    cin >> N;
    long beast[N], value_cumulative_sum[N + 1];
    value_cumulative_sum[0] = 0;
    for(int i = 0; i < N; i++){
        long value;
        cin >> beast[i] >> value;
        value_cumulative_sum[i + 1] = value_cumulative_sum[i] + value;
    }
    long min_profits = 0, ans = 0;
    for(int i = 0; i < N; i++){
        min_profits = min(min_profits, value_cumulative_sum[i] - beast[i]);
        ans = max(ans, value_cumulative_sum[i + 1] - beast[i] - min_profits);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back

// D R U L
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int mx = 1e6 + 5;
const int INF = mod;

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}



// Check for number of Cases!!
void solve() {
    int x; cin >> x;
    cout << !x << '\n';
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("/ATOMCODES/input.txt", "r", stdin);
    freopen("/ATOMCODES/output.txt", "w", stdout);
    #endif

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

Measured memory_bytes: 3644
n= int(input())
card = input().split(' ')
card = [int(s) for s in card]
min_s = 20000000000
sum1 = sum(card[:1])
sum2 = sum(card[1:])
for i in range(n - 1):
    dif  = abs(sum1-sum2)

    if dif  < min_s:
        min_s = dif
    sum1 += card[i+1]
    sum2 = sum2 - card[i+1]
print(min_s)


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

A_i = []
for i in range(N):
    A_i.append(int(input()))

A_i_sord = sorted(A_i)
A_i_max_first = A_i_sord[N - 1]
A_i_max_second = A_i_sord[N - 2]

for i in range(N):
    if A_i_max_first == A_i[i]:
        print(A_i_max_second)
    else:
        print(A_i_max_first)


Measured memory_bytes: 14152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>
#include <set>

int main(){
    std::string S;
    std::cin >> S;
    if(S[S.length()-1]=='s'){
        std::cout << S << "es" << std::endl;
    }else{
        std::cout << S << 's' << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3136
class Node
    attr_accessor :val
    def initialize(v, p)
        @val = v
        @parent = p
    end
    def root
        @parent == nil ? self : @parent.root
    end
end


n,m= gets.split(" ").map(&:to_i)
f = []
(1..m).each do
    a,b = gets.chomp.split(" ").map(&:to_i)
    f << [a-1,b-1].sort
end

class UnionFind
    # n:個数
    def initialize(n)
        @count = Array.new(n){|i| 1}
        @parent = Array.new(n){|i| i}
    end

    def root(i)
        if @parent[i] == i
            return i
        else
            r = self.root(@parent[i])
            if @count[i] > 0
                @count[r] += @count[i]
                @count[i] = 0
            end
            @parent[i] = r
            return @parent[i]
        end
    end

    def unite(a,b)
        a = self.root(a)
        b = self.root(b)
        if a != b
            @parent[b] = a
            @count[a] += @count[b]
            @count[b]=0
        end 
    end

    def show
        puts "parents"
        puts @parent.join(",")
        puts "count"
        puts @count.join(",")
    end 

    def max
        return @count.max
    end
end

un = UnionFind.new(n)
f.each do |p|
    un.unite(p[0], p[1])
end
puts un.max
#puts un.show


Measured memory_bytes: 30216
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int r;
    cin >> r;
    printf("%.4lf\n",2*r*3.1415);
    return 0;
}



























Measured memory_bytes: 3748
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[100003];
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			x[a]++;
			x[a+1]++;
			x[a+2]++;
		}
		int ans = x[0];
		for(int i = 1; i < 100003; i++)
			ans = Math.max(ans, x[i]);
		System.out.println(ans);
	}

}

Measured memory_bytes: 49428
#include<stdio.h>
int main(){
	int a,b,j,x,y;
	while(scanf("%d%d",&a,&b)!=EOF){
		int i;
		if(a>b){i=a;a=b;b=i;}x=a;y=b;
		while(b-a){
			b=b-a;
			if(a>b){i=a;a=b;b=i;}}
		j=(x/b)*(y/b)*b;
		printf("%d %d\n",b,j);}
	return 0;}


Measured memory_bytes: 2592
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		100005									// 最大文字数
#define D_COLOR_CNT		2										// 色数
#define D_COLOR_BLACK	0										// 色 - 黒
#define D_COLOR_WHITE	1										// 色 - 白

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_CHAR_MAX];									// 文字列
static int siLen;												// 文字列長
static int si2Cnt[D_CHAR_MAX][D_COLOR_CNT];						// 変更数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 実行メイン
int
fMain(
)
{
	int i;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 文字列長
	siLen = fCutCrLf(sc1Str);

	// 変更数 - セット
	for (i = 0; i < siLen; i++) {
		if (sc1Str[i] == '0') {
			si2Cnt[i + 1][D_COLOR_BLACK] = si2Cnt[i][D_COLOR_WHITE];
			si2Cnt[i + 1][D_COLOR_WHITE] = si2Cnt[i][D_COLOR_BLACK] + 1;
		}
		else {
			si2Cnt[i + 1][D_COLOR_WHITE] = si2Cnt[i][D_COLOR_BLACK];
			si2Cnt[i + 1][D_COLOR_BLACK] = si2Cnt[i][D_COLOR_WHITE] + 1;
		}
	}

	if (si2Cnt[siLen][D_COLOR_BLACK] < si2Cnt[siLen][D_COLOR_WHITE]) {
		return si2Cnt[siLen][D_COLOR_BLACK];
	}
	else {
		return si2Cnt[siLen][D_COLOR_WHITE];
	}
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si2Cnt, 0, sizeof(si2Cnt));							// 変更数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a > b){cout << a - 1 << endl;}
    else{cout << a << endl;}
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
// use std::cmp::min;

fn main() {
    input! { x: i32, }
    for p in x.. {
        if (2..((p as f64).sqrt().ceil() as i32)).into_iter().all(|n| p % n != 0) {
            println!("{}", p);
            break;
        }
    }
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{
Scanner sc=new Scanner(System.in);void run(){
double max=0,min=Double.MAX_VALUE;
for(;sc.hasNextDouble();){
double t=sc.nextDouble();max=Math.max(t,max);min=Math.min(t,min);
}
System.out.println(max-min);}public static void main(String[] a){Main m = new Main();m.run();}}

Measured memory_bytes: 12000
D = gets.to_i
c = gets.split.map &:to_i
s = Array.new
D.times do
  s << gets.split.map(&:to_i)
end
# t = []
# D.times do
#   t << gets.to_i
# end
#
# last = Array.new(26){[0, false]}
#
#
#
# def cal_dec(c, last, day)
#   sum = 0
#   for i in 0..25
#     sum += c[i] * (day - last[i][0])
#   end
#   sum
# end
#
#
#
# point = 0
# for day in 1..D
#   point += s[day-1][t[day-1]-1]
#   last[t[day-1]-1][1] = true
#   last[t[day-1]-1][0] = day
#   point -= cal_dec(c, last, day)
#   puts point
# end


D.times do |i|
  puts (i+1) % 26 + 1
end


Measured memory_bytes: 14228
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
string s[11];
int h,w,k;



int main(){
    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int ans=1050;
    for(int tate=0;tate<(1<<(h-1));tate++){
        int n=__builtin_popcount(tate);
        //cout<<n<<endl;
        int sub=n;
        int j=0;
        bool f=true;
        vector<int> num(n+1,0);
        while(j<w){
            if(sub>ans){        //繰り返しを防ぐため
                break;
            }
            if(f){
                fill(num.begin(),num.end(),0);
                f=false;
            }
            int now=0;
            for(int i=0;i<h;i++){
                num[now]+=(int)(s[i][j]-'0');
                if(num[now]>k){    //もし超えたらその時点で
                    sub++;
                    f=true; 
                    break;
                }
                if(tate>>i & 1){   //切るならnow++
                    now++;
                }
            }
            //cout<<"j="<<j<<" : ";
            //for(auto O:num){
            //    cout<<O<<", ";
            //}
            //cout<<endl;

            if(!f) j++;
        }
        ans=min(ans,sub);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
 * 17-2-18_ARC069_B.cpp
 *
 *  Created on: 2017/02/18
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>
#include<string>
#include<memory.h>

using namespace std;

int N;
string S;
int s[100010];
int a[100010];

bool isok() {
	a[0] = a[N - 1] * a[1] * s[0];
	for (int i = 2; i < N - 1; i++) {
		a[i] = a[i - 1] * a[i - 2] * s[i - 1];
	}
	return a[N - 1] == a[N - 2] * a[N - 3] * s[N - 2] && a[0] == a[N - 1]
			* a[N - 2] * s[N - 1];
}

void output(int a[]) {
	string res;
	for (int i = 0; i < N; i++) {
		switch (a[i]) {
		case 1:
			res += 'S';
			break;
		case -1:
			res += 'W';
			break;
		}
	}
	cout << res << endl;
}

int main() {
	cin >> N;
	cin >> S;
	for (int i = 0; i < N; i++) {
		switch (S[i]) {
		case 'o':
			s[i] = 1;
			break;
		case 'x':
			s[i] = -1;
			break;
		}
	}
	a[1] = 1;
	a[N - 1] = 1;
	if (isok()) {
		output(a);
		return 0;
	}
	memset(a, 0, sizeof(a));
	a[1] = 1;
	a[N - 1] = -1;
	if (isok()) {
		output(a);
		return 0;
	}
	memset(a, 0, sizeof(a));
	a[1] = -1;
	a[N - 1] = 1;
	if (isok()) {
		output(a);
		return 0;
	}
	memset(a, 0, sizeof(a));
	a[1] = -1;
	a[N - 1] = -1;
	if (isok()) {
		output(a);
		return 0;
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 1408
using System;

class Test
{
    static void Main()
    {
        string[] ss = Console.ReadLine().Split(' ');
        int a = Convert.ToInt32(ss[0]);
        int b = Convert.ToInt32(ss[1]);
        string ans;

        if (a > b) ans = "a > b";
        else if (a < b) ans = "a < b";
        else ans = "a == b";

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 15968
#include <iostream>

using namespace std;

 bool check(string s){
 if(s[0]!='A') return false;

 int c=0;
 for(int i=2; i<s.size()-1; i++){
    if(s[i]=='C'){c++;}
    }
 if(c!=1) return false;

 int upper=0;
 for( int i=0; i<s.size(); i++){
    if(s[i]>='A'&&s[i]<='Z') { upper++;}
    }
 if(upper!=2) return false;
 return true;
 }


int main()
{
    string s;
    cin>>s;
    if (check(s)){
        cout<<"AC";
    }
    else {
        cout<<"WA";
    }
    return 0;
}


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

int main()
{
    int n;string s;cin>>n>>s;
    int cnt=0;
    for(int i=0;i<=n-3;i++)
    {

        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            cnt++;
        }

    }
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 3608
n,m,c = map(int,input().split())
b = list(map(int,input().split()))

r = 0

for i in range(n):
  sum = 0
  a = list(map(int,input().split()))
  for j in range(m):
    sum += a[j]*b[j]
  sum += c
  if sum > 0:
    r += 1

print(r)

Measured memory_bytes: 9096
## coding: UTF-8

N = int(input())
s = input()
l = []
AB = []
for i in range(N):
    l.append(s[i])
    if(s[i] == '('):
        AB.append('A')
    else:
        AB.append('B')


#print(AB)
first_A_lack_counter = 0
last_B_lack_counter = 0

mode = 'even' 
#even, A_lack, B_lack

index = 0
while True:
    #print()
    #print('index:{}, AB[index]:{}'.format(index, AB[index]))
    if(mode == 'even'):
        if(AB[index] == 'A'):
            mode = 'B_lack'
            last_B_lack_counter += 1
            #print('mode change even->B_lack')
        elif(AB[index] == 'B'):
            mode = 'A_lack'
            first_A_lack_counter += 1
            #print('mode change even->A_lack')
    elif(mode == 'A_lack'):
        if(AB[index] == 'A'):
            mode = 'B_lack'
            last_B_lack_counter = 1
            #print('mode change A_lack->B_lack')
        elif(AB[index] == 'B'):
            first_A_lack_counter += 1
            #print('first_A_lack_counter:{}'.format(first_A_lack_counter))
    elif(mode == 'B_lack'):
        if(AB[index] == 'A'):
            last_B_lack_counter+= 1
            #print('last_B_lack_counter:{}'.format(last_B_lack_counter))
        elif(AB[index] == 'B'):
            last_B_lack_counter -= 1
            #print('last_B_lack_counter:{}'.format(last_B_lack_counter))
        if(last_B_lack_counter == 0):
            mode = 'even'
            #print('mode change B_lack->even')
    #print()
    index += 1
    if(index == N):
        break
#print('first_A_lack:{}'.format(first_A_lack_counter))
#print('last_B_lack:{}'.format(last_B_lack_counter))

#print()
#print()
#print(l)

first_A = []
for i in range(first_A_lack_counter):
    first_A.append('(')
l = first_A + l

for i in range(last_B_lack_counter):
    l.append(')')

#print(l)
print('{}'.format(''.join(l)))

Measured memory_bytes: 3064
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long double LD;
typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, nfc = 0, fc = 0, ans = 0;
	cin >> n;
	vector<vector<int>> sum(30, vector<int>(30));
	vector<int> nt(n), nf(n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		LL x = 0;
		bool p = false;
		int cnt = 0;
		for (int i = 0; i < s.length(); ++i) {
			if (s[i] == '.') {
				p = true;
			} else {
				x = (x * 10) + s[i] - '0';
				if (p) {
					++cnt;
				}
			}
		}
		int two = -cnt;
		int five = -cnt;
		while (x % 2 == 0) {
			++two;
			x /= 2;
		}
		while (x % 5 == 0) {
			++five;
			x /= 5;
		}
		for (int i = -10; i <= 10; ++i) {
			for (int j = -10; j <= 10; ++j) {
				if (i + two >= 0 && j + five >= 0) {
					ans += sum[i + 10][j + 10];
				}
			}
		}
		sum[min(two, 10) + 10][min(five, 10) + 10] += 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4800
#include<iostream>
#include<cmath>

using namespace std;
int main(void)
{
    long long s, n, mn = 1e9;
    cin >> s;
    for(;s>=100;s/=10)
    {
        n=s%1000;
        mn = min(mn, (long long)abs(753-n));
    }
    cout << mn;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,l; cin >> n >> m >> l;
    ll a[n][m],b[m][l],c[n][l]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout << c[i][j] << (j<l-1?" ":"");
        }
        cout << endl;
    }
}


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

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


Measured memory_bytes: 384
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)
ans = 0
for j in range(n):
    check = uf.size(j)
    if ans < check:
        ans = check
print(ans)

Measured memory_bytes: 79784
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder1
{
    class MainClass
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
                        return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();

            if (n < 105)
                Console.WriteLine(0);
            else if (n < 135)
                Console.WriteLine(1);
            else if (n < 165)
                Console.WriteLine(2);
            else if (n < 189)
                Console.WriteLine(3);
            else if (n < 195)
                Console.WriteLine(4);
            else
                Console.WriteLine(5);


                Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char
import Data.Bits

modN = 1000000007


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

pow :: Int -> Int -> Int -> Int
pow base 1 modNum = base `mod` modNum
pow base time modNum
    | odd time = let 
        a = pow base (time `div` 2) modNum `mod` modNum
        in
        a * a * base `mod` modNum
    | otherwise = let
        a = pow base (time `div` 2) modNum `mod` modNum
        in
        a * a `mod` modNum



main = do
    r <- readInt
    print $ (fromIntegral r) * 2 * 3.1415926






Measured memory_bytes: 3832
def greatestc(a, b):
    if a < b:
        a, b = b, a

    c = a % b    
    while c != 0:
        a = b
        b = c
        c = a % b
    return b

if __name__ == '__main__':
    a, b = input().split(' ')

    print(greatestc(int(a), int(b)))


Measured memory_bytes: 5600
def main():
    s = input()
    stack = []#¥をためるstack
    stack_sum = []#現状できている池のstack
    for i in range(len(s)):
        
        if s[i] == "\\":
            stack.append(i)#池の左側をためる
        elif s[i] == "/":
            if len(stack) != 0:#対応する左側がなかったらskip
                sum_t = 0
                last = stack.pop(-1)#lastからiまでの池を下では考える
                sum_t += (i-last-1)+1#[last,i]の池の計算
                if len(stack_sum) != 0:
                    for j in reversed(range(len(stack_sum))):#後ろからみる
                        if stack_sum[j][0] > last:#[last,i]ではった池でマージできるところをマージ
                            sum_t += stack_sum[j][1]
                            stack_sum.pop(j)
                stack_sum.append((last, sum_t))
    sum_ans = 0#全ての池の合計
    ans = []
    for i in range(len(stack_sum)):
        sum_ans +=stack_sum[i][1]
        ans.append(stack_sum[i][1])#池の容量だけ取り出す

    #print(sum_ans)
    #print(ans)
    print(sum(ans))
    print(len(ans),*ans)

if __name__ == "__main__":
    main()
#O(n^2)なのでO(n)でやるべき



Measured memory_bytes: 6400
package main

import (
	"fmt"
	"os"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			fmt.Println("No")
			os.Exit(0)
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1836
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

x = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])


if abs(x-a) < abs(x-b):

    print("A")
    
else:
    
    print("B")



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int64_t n, m, d;
    cin >> n >> m >> d;

    int64_t po1 = min(2 * d, n);
    int64_t po2 = n - po1;
    if(d == 0){
        po1 = n;
        po2 = 0;
    }
    //int64_t po3 = po1 + po2 * 2;

    double ans = (double(m-1) * double(po1) + double(m-1) * (2 * po2)) / (n*n);
    printf("%.10lf\n", ans);
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll f(ll h)
{
    if(h==1)return 1;
    else if(h>1) return 2*f(h/2)+1;
}

int main()
{
    ll h;
    cin>>h;
    cout<<f(h)<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import itertools
perm = list(itertools.permutations(range(1,n+1), n))

a = 0
b = 0

for i in range(len(perm)):
    if p != list(perm[i]):
        a += 1
    else:
        break

for i in range(len(perm)):
    if q != list(perm[i]):
        b += 1
    else:
        break
        
print(abs(a-b))

Measured memory_bytes: 8052
S=input()
T=input()

def count(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 == c2:
            cnt += 1
    return cnt

max_ = 0
for i in range(0,(len(S)-len(T))+1):
    max_= max( count(S[i:len(T)+i],T) ,max_ )

print( len(T) - max_ )

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

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

  vector<int> a, odd;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;

    if (x & 1)
      odd.push_back(x);
    else
      a.push_back(x);
  }

  if ((n & 1) + odd.size() >= 3) {
    puts("Impossible");
    return 0;
  }

  for (int i = 0; i < odd.size(); ++i) {
    a.push_back(odd[i]);
    reverse(a.begin(), a.end());
  }

  for (int i = 0; i < m; ++i) {
    cout << a[i] << (i + 1 == m ? "\n" : " ");
  }

  if (m == 1) a.push_back(0);

  a[0]--;
  a.back()++;

  cout << (a.size() - (a[0] == 0)) << endl;
  for (int i = (a[0] ? 0 : 1); i < a.size(); ++i) {
    cout << a[i] << endl;
  }
}


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();
		String S = sc.next();
		String[] ss = S.split("", 0);
		String T = sc.next();
		String[] ts = T.split("", 0);
		StringBuilder sb = new StringBuilder();
		for (int n = 0; n < N; n++){
			sb.append(ss[n]);
			sb.append(ts[n]);
		}
		System.out.println(new String(sb));
	}}

Measured memory_bytes: 25044
# Maximum Difference
import sys

N = int(input())
A = list(map(int, input().split()))

res = [0 for _ in range(N*N)]
cnt = 0
for i in range(N) :
    for j in range(N) :
        res[cnt] = abs(A[i] - A[j])
        cnt += 1

print(max(res))


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ll N, Max, count = 0;

	cin >> N;
	vector<ll> L(N);
	rep(i, N)	cin >> L[i];
	
	set<ll> Lj;

	rep(i, N-2){
		ll len[3];
		len[0] = L[i];
		for (int j = i+1; j < N-1; j++){
			len[1] = L[j];
			if (L[i] != L[j]){
				for (int k = j+1; k < N; k++){
					len[2] = L[k];
					if ((L[k] != L[j]) && (L[i] != L[k])){
						sort(len, len+3);
						if (len[2] < len[0] + len[1]){
							count++;
						}
					}
					len[0] = L[i];
					len[1] = L[j];
				}
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>

using namespace std;

void print(char str[],int a,int b){
	for(int i = a; i <= b; i++)	printf("%c",str[i]);
	printf("\n");
}

void replace(char str[],char p[],int a,int b){
	int p_length = b-a+1;
	for(int i = 0; i < p_length;i++) str[a+i] = p[i];
}

void reverse(char str[],int a,int b){
	int left = a,right = b;
	while(left < right){
		swap(str[left++],str[right--]);
	}
}

int main(){
	char str[1001],p[1001],order[8];
	int q,a,b;
	scanf("%s",str);
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%s %d %d",order,&a,&b);
		switch(order[2]){
		case 'i':
			print(str,a,b);
			break;
		case 'v':
			reverse(str,a,b);
			break;
		case 'p':
			scanf("%s",p);
			replace(str,p,a,b);
			break;
		}
	}
}


Measured memory_bytes: 2688
def abc_150b():
    n = input()
    s = input()
    cnt = 0

    # python的にはstrに関数が準備されているので、それでもOK
    cnt = s.count('ABC')

    # for i in range(len(s) - 2):
    #     if s[i : i + 3] == 'ABC':
    #         cnt += 1

    print(cnt)

if __name__ == '__main__':
    abc_150b()

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

const int M=3e5+5;
int cnt[M],ccnt[M];

// f(x) the max length of the group if divided into x groups
// f(x) = sum(min(cnt[i],x)) / x
// f(x) = (sum_{1~x}(i*ccnt[i]) + x*sum_{x+1~n}(ccnt[i]))/x
int f[M];

int main()
{
	int n,a;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		cnt[a]++;
	}
	for(int i=1;i<=n;i++)
		ccnt[cnt[i]]++;
	int sumcnt=0;
	for(int i=1;i<=n;i++)
		sumcnt+=ccnt[i];
	//cout<<sumcnt<<endl;
	int ncnt=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=i*ccnt[i];
		ncnt+=ccnt[i];
		f[i]=(sum+i*(sumcnt-ncnt))/i;
		//cout<<i<<" "<<sum<<" "<<ncnt<<" "<<f[i]<<endl;
	}
	int j=n;
	for(int i=1;i<=n;i++)
	{
		while(j&&f[j]<i) j--;
		printf("%d\n",j);
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
const int N = 1000001;
using namespace std;


int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, m;
    cin >> n >> m;
    vector<int> a[n + 1];
    while (m--) {
        int u, v;
        cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }

    bool vis[n + 1];
    int ans = 0;
    memset(vis, false, sizeof vis);
    for (int i = 1; i < n + 1; i++) {
        if (!vis[i]) {
            int h = 0;
            queue<int> q;
            q.push(i);
            vis[i] = true;
            while (!q.empty()) {
                int f = q.front();
                q.pop();
                h++;
                for (int e : a[f]) {
                    if (!vis[e]) {
                        vis[e] = true;
                        q.push(e);
                    }
                }
            }
            ans = max(ans, h);
        }
    }

    cout << ans;

}

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

int main(){
    int n; cin >> n;
    vector<ll> a(n),A(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        A[i] = a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i] > a[n-1]/2) a[i] = a[n-1] - a[i];
    }
    sort(a.begin(),a.end());
    cout << a[n-1] << " ";
  
    for(int i=0;i<n;i++){
        if(a[n-2] == A[i]){
            cout << a[n-2] << endl;
            return 0;
        }
    }
    cout << a[n-1] - a[n-2] << endl;
    return 0;
}

Measured memory_bytes: 1792
S = list(input())

Wn = S.count("W")

if Wn == 0:
	print(0)
else:
	x = 0
	for i in range(len(S)):
		if S[i] == "W":
			x += i
	print(x - int(Wn * (Wn - 1) / 2))


Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 51;
typedef pair<int,int> P;
int main()
{
  int n,m,i,j,res=0;
  cin >> n >> m;
  P b[N_MAX]; // 枝データ
  int c[N_MAX]; // 頂点iの属する集合番号
  int nc[N_MAX]; // 集合jの要素数
  int pc[N_MAX]; // 集合jの先頭の要素番号
  int pi[N_MAX]; // 頂点iと同じ集合の要素へのポインタ
  int i1,i2,s1,s2,p,pt;
  int c1,c2;
  for(i=0;i<m;i++)
    cin >> b[i].first >> b[i].second;
  for(j=0;j<m;j++){
  for(i=1;i<=n;i++){
    c[i]=i;
    nc[i]=1;
    pc[i]=i;
    pi[i]=0;
  }
  for(i=0;i<m;i++){
    if(i==j)
      continue;
    i1=b[i].first;
    i2=b[i].second;
    if(c[i1]!=c[i2]){
// 集合のマージここから
      s1=c[i1]; s2=c[i2];
      if(nc[s1]<nc[s2]){// 小さい方を潰す【重要】
        s1=c[i2]; s2=c[i1];
      }
      pt=pc[s1];
      p=pc[s2];
      pc[s1]=p;
      nc[s1]+=nc[s2];
      pc[s2]=0;
      nc[s2]=0;
      while(true){
        c[p]=s1;
        if(pi[p]==0) break;
        p=pi[p];
      }
      pi[p]=pt;
// 集合のマージここまで
    }
  }
  if(nc[c[1]]<n)
    res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;

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

        int N = Integer.parseInt(sc.next());
        int[] A = new int[N+1];
        int[] B = new int[N];
        for (int i = 0; i < N + 1; i++) {
            A[i] = Integer.parseInt(sc.next());
        }
        for (int i = 0; i < N; i++) {
            B[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        long sum = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 2; j++) {
                if (A[i + j] <= B[i]) {
                    sum += A[i + j];
                    B[i] -= A[i + j];
                    A[i + j] = 0;
                } else {
                    sum += B[i];
                    A[i + j] -= B[i];
                    B[i] = 0;
                }
            }
        }

        out.printf("%d\n", sum);
        out.flush();
    }
}


Measured memory_bytes: 48448
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { 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; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve(){
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    vector<vector<int>> c(N, vector<int>(N));
    for (int i=0; i<C; i++) {
        for (int j=0; j<C; j++) {
            cin >> D.at(i).at(j);
        }
    }
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            cin >> c.at(i).at(j);
        }
    }
    vector<int> cnt1(C), cnt2(C), cnt3(C);
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            int mod = (i+j+2)%3;
            if (mod == 0) {
                cnt1.at(c.at(i).at(j)-1)++;
            } else if (mod == 1) {
                cnt2.at(c.at(i).at(j)-1)++;
            } else {
                cnt3.at(c.at(i).at(j)-1)++;
            }
        }
    }
    int ans = INF;
    for (int i=0; i<C; i++) {
        for (int j=0; j<C; j++) {
            for (int k=0; k<C; k++) {
                if (i == j || j == k || k == i) continue;
                int tmp = 0;
                for (int l=0; l<C; l++) {
                    tmp += D.at(l).at(i) * cnt1.at(l);
                }
                for (int l=0; l<C; l++) {
                    tmp += D.at(l).at(j) * cnt2.at(l);
                }
                for (int l=0; l<C; l++) {
                    tmp += D.at(l).at(k) * cnt3.at(l);
                }
                chmin(ans, tmp);
            }
        }
    }

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    double a,b,c,s;

    cin >> a >> b >> c;
    s=(a*b*sin(M_PI/(180/c)))/2;

    printf("%.6lf\n",s);
    printf("%.6lf\n", a+b+sqrt(a*a+b*b-2*a*b*cos(M_PI/(180/c))));
    printf("%.6lf\n", s*2/a);
    
    return 0;
}

Measured memory_bytes: 1288
int main(){
int a, b, i;
char op;
for(; ;){
scanf("%d %c %d", &a, &op, &b);
if(op == '+'){printf("%d\n", a+b);}
else if(op == '-'){printf("%d\n", a-b);}
else if(op == '*'){printf("%d\n", a*b);}
else if(op == '/'){printf("%d\n", a/b);}
else{break;}
}
return 0;
}

Measured memory_bytes: 600