akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

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

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

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

ll A, B;

ll mask(int num) {
    if (num < 0) return 0;
    ll m = 0;
    rep(i, num+1) {
        m += 1LL << i;
    }
    return m;
}

int digit(int num) {
    int Anow = A >> num & 1LL;
    int Bnow = B >> num & 1LL;
    if (num == 0) {
        if (Anow) {
            if ((B - A + 1) % 2) {
                return ((B - A + 2) / 2) % 2;
            } else {
                return ((B - A + 1) / 2) % 2;
            }
        } else {
            if ((B - A + 1) % 2) {
                return ((B - A) / 2) % 2;
            } else {
                return ((B - A + 1) / 2) % 2;
            }
        }
    }

    if (Anow == 0 && Bnow == 0) return 0;

    ll base = 1LL << num;
    ll restA = base - 1 - (A & mask(num - 1));
    ll restB = B & mask(num-1);

    // printf("%lld, %lld, %lld,\n", base, restA, restB);

    if (restA + A >= B) {
        if (Anow) {
            return (B - A + 1) % 2;
        } else {
            return 0;
        }
    }

    int dA = 0, dB = 0;
    if (Anow) {
        dA = (restA + 1) % 2;
    }
    if (Bnow) {
        dB = (restB + 1) % 2;
    }

    return dA ^ dB;
}

ll naive() {
    ll ans = 0;
    for (ll i = A; i <= B; i++) {
        ans = ans ^ i;
    }
    return ans;
}

int main(int argc, const char * argv[]) {
    A = inputValue();
    B = inputValue();

    if (A == B) {
        output(A);
        return 0;
    }

    if (A == B - 1) {
        output(A^B);
        return 0;
    }

    ll ans = 0;
    rep(i, 60) {
        ll dig = digit(i);
        ans += dig << i;
        // output(dig);
    }

    output(ans);
    // output(naive());

    return 0;
}

Measured memory_bytes: 256
//16, 03, 2019, 09:03:04 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = int(1e5 + 100);
ll q[N];
const ll mod = ll(1e9) + 7;

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

    int n;

    cin >> n;

    string s;

    cin >> s;

    for(int i = 0 ; i < n ; i++){
        q[s[i] - 'a']++;
    }

    ll tot = 1LL;

    for(char a = 'a' ; a <= 'z' ; a++){
        q[a - 'a']++;

        tot = (tot * q[a - 'a']) % mod; 
    }

    cout << (tot - 1LL + mod) % mod << endl;
    
    return 0;
}

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

public class Prog
{
    public void run()
    {
        var input = Console.ReadLine().Split();
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int money = 0;
        if (A <= 5)
        {
            money = 0;
        }
        else if (A <= 12)
        {
            money = B / 2;
        }
        else
        {
            money = B;
        }
        Console.WriteLine(money);
    }
    public static void Main()
    {
        //var input = Console.ReadLine().Split();
        //int[] X = Array.ConvertAll(input, int.Parse);
        var prog = new Prog();
        prog.run();
    }
}

//Array.ConvertAll(int.Parse)

Measured memory_bytes: 13140
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    a, b = LI()

    return max(a + a - 1, b + b - 1, a + b)


print(main())


Measured memory_bytes: 3316
N,M,Q=map(int,input().split())
train=[[0]*(N+1) for _ in range(N+1)]#iから始まってjで終わる電車の本数
for i in range(M):
    l,r=map(int,input().split())
    train[l][r]+=1

#2次元累積和
for i in range(N):
    for j in range(N):
        train[i+1][j+1]+=train[i][j+1]+train[i+1][j]-train[i][j]
    
for i in range(Q):
    p,q=map(int,input().split())
    print(train[q][q]-train[p-1][q]-train[q][p-1]+train[p-1][p-1])

Measured memory_bytes: 56152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int n,k;
    double ans = 0;
    cin >> n >> k;
    double waru = 1.0/(double)n;
    for(int i=1; i<=n; i++) {
        int tmp_n = i, count=0;
        while (tmp_n < k) {
            tmp_n *= 2;
            count++;
        }
        ans += pow(0.5,count);
    }
  	ans *= waru;
    printf("%.16f\n",ans);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A.sort()

# n, rを求める
n = A[-1]
# Nの半分にもっとも近い数を探す
standard = n/2
dif = 1e+9
r = 1e+9  # 今のrの値
for i in range(N-1):
    if abs(A[i] - standard) < dif:
        r = A[i]
        dif = abs(A[i] - standard)

print(n, r)


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

// Description: ????????????
// Verifyed: various problem 
using namespace placeholders;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

auto& operator >> (istream& is,P& p){ R x,y; is >> x >> y,p=P(x,y); return is;}
auto& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline P vec(L l){return l.t-l.s;}
auto sdot = bind(sgn,bind(dot,_1,_2,_3));
auto sdet = bind(sgn,bind(det,_1,_2,_3));

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/vec(l)); return (1-u)*l.s+u*l.t;}

int main(void){
	P a,b,p;
	int n;
	cin >> a >> b >> n;
	L l={a,b};
	cout.precision(20);
	rep(i,n){
		cin >> p;
		P ans=proj(l,p);
		cout << fixed << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3248
#include <cstdio>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[100000+10];
int hist[30];

int main(void) {
  scanf("%s", buf);
  for(int i = 0; buf[i]; ++i) {
    hist[buf[i]-'a']++;
  }

  REP(i, 26) {
    if(hist[i] == 0) {
      printf("%c\n", 'a'+i);
      return 0;
    }
  }
  puts("None");

  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/perl
use Data::Dumper;
my ($n,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @h = map { $_ - 0 } split(/\s+/,<STDIN>);

my @sh = sort { $b - $a } @h;

#print &Dumper(\@sh);
if( $n <= $k ){
  print "0\n";
  exit(0);
}

my $t = 0;
for( my $i = $k ; $i < $n ; $i ++){
  $t += $sh[$i];
}
print "$t\n";



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

#define INF INT_MAX

using namespace std;

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

int main(void){
 	cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    
    cout << (a*3+b)/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main(){
  int n;
  cin>>n;
  for(int i=1;;i++){
    int p=0;
    for(int j=1;j*j<=i;j++){
      if(i%j==0){
        if(j*j==i)p++;
        else p+=2;
      }
    }
    if(p==n){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3124
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
    int n;
  char m;
  int f;
  int s[13] = {0};
  int h[13] = {0};
  int c[13] = {0};
  int d[13] = {0};
  cin >> n;
  for (int i=0;i<n;i++) {
      cin >> m >> f;
      switch (m)
      {
      case 'S':
          s[f-1] = 1;
          break;
      case 'H':
          h[f-1] = 1;
          break;
      case 'C':
          c[f-1] = 1;
          break;
      case 'D':
          d[f-1] = 1;
          break;
      default:
          break;
      }
  }
  for (int i=0;i<13;i++) {
    if (s[i]==0) {
        cout << "S " << i+1 <<endl; 
    }
  }
  for (int i=0;i<13;i++) {
    if (h[i]==0) {
        cout << "H " << i+1 <<endl; 
    }
  }
  for (int i=0;i<13;i++) {
    if (c[i]==0) {
        cout << "C " << i+1 <<endl; 
    }
  }
  for (int i=0;i<13;i++) {
    if (d[i]==0) {
        cout << "D " << i+1 <<endl; 
    }
  }
}


Measured memory_bytes: 3084
#include <stdio.h>

#define PUT(f, x, y) (0 <= x && x < 10 && 0 <= y && y < 10 ? f[y][x]++ : 0)
#define DISTANCE(x, y, x2, y2) (abs(x-x2)+abs(y-y2))
#define DIST_MAX(x, y, x2, y2) (abs(x-x2) > abs(y-y2) ? abs(x-x2) : abs(y-y2))

main(){
  int x, y, type, cnt, max, bx, by;
  int f[10][10];
  
  for (y = 0; y < 10; y++) {
    for (x = 0; x < 10; x++) {
      f[y][x] = 0;
    }
  }
  
  while (scanf("%d,%d,%d", &bx, &by, &type) > 0) {
    if (type == 3) {
      for (y = by - 2; y <= by + 2; y++) {
	for (x = bx - 2; x <= bx + 2; x++) {
	  if (DISTANCE(x, y, bx, by) <= 2) {
	    PUT(f, x, y);
	  }
	}
      }
    } else if (type == 2) {
      for (y = by-1; y <= by+1; y++) {
	for (x = bx-1; x <= bx+1; x++) {
	  if (DIST_MAX(x, y, bx, by) <= 1) {
	    PUT(f, x, y);
	  }
	}
      }
    } else {
      PUT(f, bx, by);
      PUT(f, bx, by-1);
      PUT(f, bx, by+1);
      PUT(f, bx-1, by);
      PUT(f, bx+1, by);
    }
  }

  max = 0;
  cnt = 0;
  for (y = 0; y < 10; y++) {
    for (x = 0; x < 10; x++) {
      if (f[y][x] == 0) cnt++;
      if (f[y][x] > max) max = f[y][x];
    }
  }
  printf("%d\n", cnt);
  printf("%d\n", max);
  
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>

template<class T>void fr(T &a) {
    T w=0,s=1;char c=getchar();
    while(c<'0'||c>'9') {if(c=='-')s=-1;c=getchar();}
    while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
    a=w*s;
}
template<class T>T fr() {T a;fr(a);return a;}
#define R() fr<int>()

int main() {
    int r=R();
    return !printf("%d\n",r*r);
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S) {
    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << 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() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll sum(ll a, ll b) {
  return (b + a) * (b - a + 1) / 2;
}

signed main() {
  ll N, K;
  cin >> N >> K;

  ll ans = 0;
  rep2(i, K, N + 2) {
    ll min = sum(0, i - 1);
    ll max = sum(N - i + 1, N);
    ans += (max - min + 1) % 1000000007;
    ans = ans % 1000000007;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3676
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def inverse(self, k):
        """kの逆元を求める O(1)"""
        return (self.inv_fact[k] * self.fact[k - 1]) % self.MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


n, m = map(int, input().split())
MOD = 998244353
comb = Combination(10 ** 7, MOD)


ans = 0
for odd_cnt in range(m + 1):
    if odd_cnt > n:
        continue
    if (3 * m - odd_cnt) % 2 == 1:
        continue
    ptn = 1
    box = n
    odd_ball = odd_cnt
    ptn *= comb.combination(box, odd_ball)

    even_pair_ball = (3 * m - odd_cnt) // 2
    ptn *= comb.combination(even_pair_ball + box - 1, even_pair_ball)

    ans += ptn
    ptn %= MOD

for i in range(1, m + 1):
    ball = m - i
    box = n - 1
    ans -= comb.combination(ball + box - 1, ball) * n
    ans %= MOD

print(ans)

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

int main(void){
    string s;
    cin >> s;
    set<char> s_set;
    for(int i=0; i<s.length(); i++){
        s_set.insert(s[i]);
    }

    if(s.length() == s_set.size()){
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> r, l;
    rep(i,n){
        cin >> a[i];
        r[i+a[i]]++;
        l[i-a[i]]++;
    }
    ll ans = 0;
    for(auto p : r){
        ans += p.second * l[p.first];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 38988
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    vector<vector<int>>x(h,vector<int>(w));
    for(int i=0;i<n;i++){
        int r,c,v;
        cin>>r>>c>>v;
        x[r-1][c-1]=v;
    }
    vector<vector<vector<long long>>>dp(h,vector<vector<long long>>(w,vector<long long>(4,-1000000000000000000)));
    dp[0][0][0]=0;
    dp[0][0][1]=x[0][0];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<4;k++){
                if(i<h-1){
                    dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
                    dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+x[i+1][j]);
                }
                if(j<w-1){
                    dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
                    if(k<3)dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+x[i][j+1]);
                }
            }
        }
    }
    cout<<max({dp[h-1][w-1][0],dp[h-1][w-1][1],dp[h-1][w-1][2],dp[h-1][w-1][3]})<<endl;
    return 0;
}

Measured memory_bytes: 671544
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int r;
const double PI = 3.14159;
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> r;
    cout << 2 * PI  * r;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, i, psum=0, pro;
    cin >> n;
    pro=n;
    for(i=1;i<=n;i++){
        psum+=i;
        if(psum>n){
            pro=i;
            break;
        }
    }
    for(i=1;i<=pro;i++){
        if(i!=psum-n) cout << i <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int main()
{
    int sum = 0, a;
    for(int i = 0; i < 4; i++) {
        cin >> a;
        sum += a;
    }
    cout << (sum / 60) << endl;
    cout << (sum % 60) << endl;
}

Measured memory_bytes: 0
//I love Nanami Chiaki
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
const int inf=1e9+7;
const int mod=1e9+7;
//const int maxn=;
string s,t;
int main(){
	cin>>s;cin>>t;
	for (int i=0;i<s.size();i++){
		if (s[i]!=t[i]){puts("No");return 0;}
	}
	puts("Yes");return 0;
	return 0;
}


Measured memory_bytes: 3636
#include <atcoder/math>
#include <cstdio>
 
using namespace std;
using namespace atcoder;
 
int main() {
    int t;
    scanf("%d", &t);

    for (int i = 0; i < t; ++i) {
        long n, m, a, b;
        scanf("%ld %ld %ld %ld", &n, &m, &a, &b);
        printf("%ld\n", floor_sum(n, m, a, b));
    }
 
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    int c[4][4];
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }
    
    if(c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[1][0] - c[1][1] == c[2][0] - c[2][1] &&
       c[0][1] - c[0][2] == c[1][1] - c[1][2] && c[1][1] - c[1][2] == c[2][1] - c[2][2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int[] ch = new int[4];
			String str = scan.nextLine();
			for(int i = 0;i < str.length();i++){
				switch(str.charAt(i)){
				case 'K':
					ch[0]++;
					break;
				case 'U':
					ch[1]++;
					break;
				case 'P':
					ch[2]++;
					break;
				case 'C':
					ch[3]++;
					break;
					default:
						break;
				}
			}
			Arrays.sort(ch);
			System.out.println(ch[0]);
		}
	}
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  int num;
  int ans=1000;
  rep(i,s.size()-2){
    int num=100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
    ans=min(abs(753-num),ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		int INF = 1_000_000_007;
		Scanner sc = new Scanner(System.in);
		//char[] A = sc.next().toCharArray();
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		boolean isAllZero = true;
		Set<Integer> set = new HashSet<>();
		for(int i=0; i<N; i++){
			A[i] = Integer.parseInt(sc.next());
			set.add(A[i]);
			if(A[i] != 0)isAllZero=false;
		}
		
		Arrays.sort(A);
		
		if(isAllZero){
			System.out.println("Yes");
		}else if(!(set.size() == 3 || set.size() == 2)){
			System.out.println("No");
		}else if(set.size() == 3){
			List<Integer> list = new ArrayList<>(set);
			boolean flag = false;
			if(((list.get(0)^list.get(1)) == list.get(2))
					&& ((list.get(1)^list.get(2)) == list.get(0))
					&& ((list.get(2)^list.get(0)) == list.get(1))){
				flag = true;
			}
			int count1 = 0;
			int count2 = 0;
			int count3 = 0;
			int number1=list.get(0);
			int number2=list.get(1);
			int number3=list.get(2);
			
			for(int c_ : A){
				if(c_ == number1)count1++;
				if(c_ == number2)count2++;
				if(c_ == number3)count3++;
			}
			
			if(!(count1==count2 && count2==count3))flag=false;
			
			if(flag){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else if(set.size() == 2){
			List<Integer> list = new ArrayList<>(set);
			boolean flag = false;
			//if(!(list.get(0)==0 || list.get(1)==0) )flag = false;
			int count1 = 0;
			int count2 = 0;
			//System.out.println(~1);
			int number1=list.get(0);
			int number2=list.get(1);

			
			for(int c_ : A){
				if(c_ == number1)count1++;
				if(c_ == number2)count2++;
			}
			
			//if(!(count1==count2*2 || count2==count1*2))flag=false;
			if(number1==0 && count2==count1*2){
				flag=true;
			}
			if(number2==0 && count1==count2*2){
				flag=true;
			}
			
			if(flag){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
		
	}
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (c/b);
	}
}



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

int gcd(int a, int b) {
	if (!b)return a;
	return gcd(b, a%b);
}
int a[1000], dat1[8000], dat2[8000], N;
void init(int n) {
	N = 1; while (N < n)N <<= 1;
	rep(i, 2 * N - 1)dat1[i] = INT_MAX, dat2[i] = 0;
}
void update(int k, int x) {
	k += N - 1;
	dat1[k] = x; dat2[k] = x;
	while (k) {
		k = (k - 1) / 2;
		dat1[k] = min(dat1[k * 2 + 1], dat1[k * 2 + 2]);
		dat2[k] = max(dat2[k * 2 + 1], dat2[k * 2 + 2]);
	}
}
P query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return P(INT_MAX, 0);
	if (a <= l&&r <= b)return P(dat1[k], dat2[k]);
	P vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
	P vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return P(min(vl.first, vr.first), max(vl.second, vr.second));
}
int main() {
	int n, m; scanf("%d%d", &n, &m);
	init(2 * n);
	rep(i, n)scanf("%d", &a[i]);
	rep(i, 2 * n)update(i, a[i%n]);
	int g = n / gcd(n, m);
	int sum = 0;
	rep(i, g) {
		int s = (m*i) % n;
		P p = query(s, s + m, 0, 0, N);
		sum += p.second - p.first;
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 3224
function main(input) {
  var r = input.split(" ")[0]-0;
  var d = input.split(" ")[1]-0;
  var x = input.split(" ")[2]-0;
  var map = [];
  map[0] = x;
  for(var i=1;i<=10;i++){
    map[i] = r*map[i-1]-d;
    console.log(map[i]);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7628
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define ii pair<int,int>

ll number_of_divisors(ll n)
{
    ll ans = 1;

	for (ll i=2; i*i <= n; i++){
		if (n%i != 0) continue;
		ll cnt = 0;
		while (n%i == 0){
			n /= i;
			cnt++;
		}
		ans *= (cnt+1);
	}
	if (n > 1){
		ans *= 2;
	}
	return ans;
}
ll aa[1000004]; ll bb[200004];
int main()
{
    io;
    ll a,b,c,d,m,n,i,j,k,l,t,x,y,z;
    ll ans=0;
    ll maxi=INT_MIN; ll mini=INT_MAX,sum=0,mul=1;

        vector<ll>vec;
        string st,ch;
        maxi=INT_MIN, mini=INT_MAX;
        sum=0,mul=1;
        cin>>st;
        a=st.length();
        if(st[a-1]=='s') st+='e',st+='s';
        else st+='s';
        cout<<st<<endl;

    return 0;
}






Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

vector<int> v[101010];
vector<pair<int, int>> l[101010];
int ans[101010];

int dfs(int x, int p) {
	l[x].push_back({ 0,-1 });
	l[x].push_back({ 0,-1 });
	for (auto to : v[x]) {
		if (to == p)continue;
		l[x].push_back({ dfs(to,x),to });
	}
	sort(l[x].rbegin(), l[x].rend());
	return l[x][0].first + 1;

}

void rdfs(int x, int p) {
	if (p != -1) {
		if (l[p][0].second == x) {
			l[x].push_back({ l[p][1].first + 1,l[p][1].second });
		}
		else l[x].push_back({ l[p][0].first + 1,l[p][0].second });
	}
	sort(l[x].rbegin(), l[x].rend());
	ans[x] = l[x][0].first;

	for (auto to : v[x]) {
		if (to == p)continue;
		rdfs(to, x);
	}
}


void solve() {
	int n;
	cin >> n;
	rep(i, n - 1) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(0, -1);
	rdfs(0, -1);
	rep(i, n) {
		cout << 2 * (n - 1) - ans[i] << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}



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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

int n;
vector<string> s;

void solve() {
  cin >> n;
  s.resize(n);
  rep(i, 0, n) cin >> s[i];

  vector<vector<int>> a(n, vector<int>(10, 0));
  rep(i, 0, n) {
    rep(j, 0, 10) { a[i][j] = s[i][j] - 'a'; }
    SORT(a[i]);
  }
  SORT(a);
  int ans = 0, l = 0;
  rep(i, 1, n) {
    bool flag = true;
    rep(j, 0, 10) {
      if (a[i][j] == a[i - 1][j])
        continue;
      else {
        flag = false;
        break;
      }
    }
    if (flag == false) {
      ans += l * (l + 1) / 2;
      l = 0;
    } else {
      l++;
    }
  }
  ans += l * (l + 1) / 2;
  cout << ans << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  map<string,int> a;
  for(i=0;i<n;i++)
  {
  	string s;
  	cin>>s;
  	a[s]++;
  }
  cout<<"AC x "<<a["AC"]<<endl;
  cout<<"WA x "<<a["WA"]<<endl;
 cout<<"TLE x "<<a["TLE"]<<endl;
 cout<<"RE x "<<a["RE"]<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
   ll n;cin>>n;
   vector<ll> a(n+1);
   rep(i,n+1) cin>>a[i];
   ll res=0,tmp=0;
   vector<ll> b(n+3,1);
   ll maxi=1;
   
   rep(i,n+1){
       maxi-=a[i];
       if(maxi<0||(i!=n&&maxi==0)){
           cout<<-1<<endl;
           return 0;
       }
       if(maxi*2<=1e+18)maxi*=2;
       b[i+1]=maxi;
       //cout<<b[i]<<" "<<i<<endl;
   }
   
   reverse(a.begin(),a.end());
   
   rep(i,n+1){
       //cout<<tmp<<" "<<b[n-i]<<endl;
        if(i==0){
            tmp+=a[0];
            if(tmp>b[n]){
                cout<<-1<<endl;
                return 0;
            }
            res+=tmp;
            continue;
        }
        
        if(tmp>b[n-i]*2){
        cout<<-1<<endl;
            return 0;
        }else if(b[n-i]<=tmp+a[i]){
            tmp=b[n-i];
        }else{
            tmp+=a[i];
        }
        res+=tmp;
        //cout<<tmp<<" "<<b[n-i]<<endl;
   }
   cout<<res<<endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll a,b,c;cin>>a>>b>>c;
    ll ma = max(a,max(b,c));
    ll sum = a+b+c;
    ll res = 0;
    ll ans = 3*(ma+1)-sum;
    if((3*ma-sum)%2 == 0)out((3*ma-sum)/2);
    else out(ans/2);
}



Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())
if s[k-1] == 'A':
  s[k-1] = 'a'
elif s[k-1] == 'B':
  s[k-1] = 'b'
elif s[k-1] == 'C':
  s[k-1] = 'c'
print(''.join(s))

Measured memory_bytes: 3060
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 0
for i in range(1, K+1):
    for h in range(1, K+1):
        for j in range(1, K+1):
            ans += gcd(i, h, j)

print(ans)

Measured memory_bytes: 69768
#define mod 1000000007
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=1e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
int t,cas;
int n,m;
int main()
{
	int a[N];
	int l,r,mid,v;
	ll ans;
	while(~scanf("%d",&n))
	{
		for(int i=0;i<n;i++)
			scanf("%d",&a[i]);
		sort(a,a+n);
		ans=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				int s=a[i]+a[j];
				l=j;r=n-1;
				while(l<=r)
				{
					mid=(l+r)>>1;
					if(a[mid]<s)
					{
						v=mid;
						l=mid+1;
					}
					else
					{
						r=mid-1;
					}
				}
				ans+=max(0,v-j);
			}
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n,x,m;
  cin >> n >> x >> m;
  ll ans=0;
  vector<ll> o(m);
  rep(i,m){
    ll h=i;
    o[i]=(h*h)%m;
  }
  rep(i,m)o[i]%=m;
  //rep(i,m)if(o[i]<=m)cout << i << endl;
  set<ll> s;
  while(true){
    n--;
    if(n==0){
      ans+=x;
      cout << ans << endl;
      return 0;
    }
    if(s.count(x))break;
    s.insert(x);
    ans+=x;
    //cout << x << endl;
    x=(o.at(x)%m);
  }
  int a=0;
  ll b=0;
  ll z=x;
  while(true){
    a++;
    b+=x;
    //if(o.at(x)>100000)cout << x << endl;
    x=o.at(x);
    if(x==z)break;
  }
  ans+=b*(n/a);
  n%=a;
  rep(i,n){
    ans+=x;
    //if(o.at(x)>100000)cout << x << endl;
    x=o.at(x);
  }
  ans+=x;
  cout << ans << endl;
}


Measured memory_bytes: 6212
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  // freopen("input.txt", "r", stdin);

  long long w, h; int x, y; cin >> w >> h >> x >> y;
  printf("%.10f %d\n", w * h * 0.5, (x == w * 0.5 && y == h * 0.5 ? 1 : 0));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const ll mod = 998244353;
const int N = 200050;
const ll inf = 1e18;
vector<vector<int>> g(N);

ll dfs(int s){
    if (g[s].empty()) return 2;
    ll tmp = 1;
    for (int v: g[s]){
        tmp *= dfs(v);
        tmp%= mod;
    }
    tmp++;
    tmp %= mod;
    return tmp;
}

int main()
{
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(all(p));
    set<P> s;
    repd(i, n){
        int x = p[i].first;
        int d = p[i].second;
        while (s.size() and s.begin()->first < x+d){
            g[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.emplace(x, i);
    }

    ll ans = 1;
    for (auto& u : s) {
        ans *= dfs(u.second);
        ans %= mod;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 24976
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 2e3 + 5;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
}

bool vis[MAXN];

inline void merge(vector<int> &a, const vector<int> &b)
{
    vector<int> ret;
    int p = 0, q = 0;
    while (p < SZ(a) || q < SZ(b)) {
        if (p < SZ(a) && (q == SZ(b) || a[p] > b[q]))
            ret.push_back(a[p++]);
        else
            ret.push_back(b[q++]);
    }
    a = ret;
}

vector<int> dfs(int u)
{
    vis[u] = true;
    vector<int> ret;
    for (int v = 1; v <= N; ++v) {
        if (vis[v] || std::__gcd(A[u], A[v]) == 1)
            continue;
        merge(ret, dfs(v));
    }
    ret.insert(ret.begin(), A[u]);
    return ret;
}

void solve()
{
    vector<int> ans;

    std::sort(A + 1, A + N + 1);
    for (int i = 1; i <= N; ++i) {
        if (!vis[i])
            merge(ans, dfs(i));
    }

    for (auto x : ans) {
        printf("%d ", x);
    }
    puts("");
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 三万里河东入海，五千仞岳上摩天。
//     -- 陆游《秋夜将晓出篱门迎凉有感》


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int N;
  cin >> N;
  cout << N / 3 << endl;
}

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

class Main {
    private static boolean[] calcPrimeTable(int n) {
        boolean[] table = new boolean[n + 1];
        Arrays.fill(table, true);
        table[0] = false;
        table[1] = false;
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = false;
                }
            }
        }
        return table;
    }
    
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);
        final boolean[] table = calcPrimeTable(123456 * 2);

        while (true) {
            final int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            int counter = 0;
            for (int i = n + 1; i <= 2 * n; i++) {
                if (table[i]) {
                    counter++;
                }
            }
            System.out.println(counter);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
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;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll n;cin>>n;
	bool rev=false;
	string l="",r="";
	rep(_,n){
		ll q;cin>>q;
		if(q==1){
			rev^=true;
		}else{
			ll t; string c; cin>>t>>c;
			if(rev)t=3-t;
			if(t==1){
				l+=c;
			}else r+=c;
		}
	}
	reverse(all(l));
	s=l+s+r;
	if(rev)reverse(all(s));
	puta(s);
	return 0;
}

Measured memory_bytes: 1200
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n;
cin>>n;
map<int,int> mp;
for(int i=0;i<n-1;i++) {
    int a;
    cin>>a;
    mp[a]++;
}
for(int i=1;i<=n;i++)
cout<<mp[i]<<endl;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 16168
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int rx,ry,n;
	cin>>rx>>ry>>n;
	
	int lx=0,ly=0,x,y,a;
	for (int i = 0; i < n; i++){
		cin>>x>>y>>a;
		switch(a){
			case 1:if(lx<x)lx=x;break;
			case 2:if(rx>x)rx=x;break;
			case 3:if(ly<y)ly=y;break;
			case 4:if(ry>y)ry=y;break;
		}
	}

	if(lx>rx||ly>ry)
		cout<<0<<endl;
	else
		cout<<(rx-lx)*(ry-ly)<<endl;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
  
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  char c;
  cin>>c;
  if('a'<=c&&c<='z')cout<<"a"<<endl;
  else cout<<"A"<<endl;
  return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = bf.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int M = Integer.parseInt(arr[1]);


        PriorityQueue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());
        String[] inputs = bf.readLine().split(" ");
        for(int i=0; i<inputs.length; i++) {
            q.add(Integer.parseInt(inputs[i]));
        }

        while(M>0) {
            q.add(q.poll() / 2);
            M--;
        }

        long answer = 0;
        while(!q.isEmpty()) {
            answer += q.poll();
        }
        System.out.println(answer);
    }

}

Measured memory_bytes: 48084
n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
b = []

for i in range(n):
    if i % 2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])

if n % 2 != 0:
    even.reverse()
    b = even + odd
else:
    odd.reverse()
    b = odd + even

print(*b, sep=' ')

Measured memory_bytes: 26356