akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using ll = long long;

/*
ある積XがK番目の値⇔「x未満の積がK個未満」であるxの最大値X

proof:
XがK番目の値のときx = X未満の積はK個未満である.
一方でx > Xの場合, K番目の値より大きく少なくともK個以上のx未満の積が存在
よってx = Xがその最大値となる.

次に「x未満の積がK個未満」であるxの最大値をXとしたとき,
x > Xではx未満の積がK個以上存在することになるからこれはK番目の値ではない.
逆にx < XではxはK番目の値ではない. なぜならもしこれがK番目の値であれば,
X未満の積がK個未満にはならないからである. よってx = XがK番目の値
(証明終)

つまり「x未満の積がK個未満である」というクエリに対してTrueを返すときからFalseを返すように
切り替わる瞬間のギリギリのTrueのときを二分探索で調べればよい.

このクエリを実行するにはx未満の積をいくつあるかを調べる必要がある.
例えば次の場合
数列：1 2 3 4
クエリ：x = 6
基本的には積の片方を固定していくつ他方が考えられるかというので数え上げる.
1...1, 2, 3, 4
2...1, 2
3...1
4...1
で8個ですね. ただしペアのうち掛け算として同じ(1, 2), (2, 1)などは重複しないように数え上げる必要がある.
そこで重複して数え上げた数mから(y, y)という同じ数nを除外して(m - n)/2 + n = (m + n) / 2とすればよいのです.
上の例ならば(8 - 2) / 2 + 2 = 5個となります. 実際(1, 1), (1, 2), (1, 3), (1, 4), (2, 2)です.


しかしここで注意点があります. それは今回の数列は負の値や0の値を含むということです.
例えば次の場合
数列：-4, -2, 3, 3
クエリ：x = -5
-4...3, 3
-2...3, 3
 3...-2, -4
 3...-2, -4
で8個ですね. 注意するべきことは負の場合は数列の小さい方からどれが満たすのかを探索するのではなく
数列の大きい値から順に探索しなければならないという点です. 
-4に対して3, 3, -2, -4と数字を舐めていかなければなりません. この点だけ注意です.


最後に今回はペアを求めるために数字を順に舐めていきましたが, これでは非常に遅いです.
おこでここでも二分探索を用いてlogNにしておく必要があります.
*/



// 注意------
// 1e18と単に書くとdoubleだと認識されてしまいオーバーフローする
// そのため最初からlong long型だと認識させるために
// ll(1e18)と書く必要がある
const ll INF = ll(1e18)+1; //積の絶対値の上限

int main(){
    ll N, K;
    std::cin >> N >> K;
    std::vector<ll> A(N);
    for(ll i = 0; i < N; i++) std::cin >> A[i];
    std::sort(A.begin(), A.end());

    ll l = -INF, r = INF; // 探索の開始に使用
    while(l + 1 < r){ // lとrが隣り合ったらダメ
        ll x =(l + r) / 2; // クエリ
        auto ok = [&]() -> bool{
            ll num = 0;
            for(ll i = 0; i < N; i++){
                // A[i]のペアを二分探索で調査する
                if(A[i] < 0){
                    // 負の数の場合
                    ll left = -1, right = N;
                    while(left + 1 < right){
                        ll c = (left + right) / 2;
                        if(A[c] * A[i] < x){
                            right = c;
                        }else{
                            left = c;
                        }
                    }
                    num += N - right; // 負の場合は右からの個数
                }else{
                    // 0以上の場合
                    ll left = -1, right = N;
                    while(left + 1 < right){
                        ll c = (left + right) / 2;
                        if(A[c] * A[i] < x){
                            left = c;
                        }else{
                            right = c;
                        }
                    }
                    num += right; // 正の場合は左からの個数
                }

                // 同じペアについての処理
                if(A[i] * A[i] < x) num--;
            }
            // 探索終了
            num /= 2;
            return num < K;
        };


        if(ok()){
            // まだxを上げられる
            l = x;
        }else{
            // もっとxを下げて
            r = x;
        }
    }

    std::cout << l << std::endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d",&n);b=n%100;a=n-b;a=a/100;
       if((a>=1&&a<=12)&&(b<=12&&b>=1))
       {
           printf("AMBIGUOUS");
       }else if((a>=1&&a<=12)&&((b==0)||(b>12)))
       {
           printf("MMYY");
       }else if((b>=1&&b<=12)&&((a==0)||(a>12)))
       {
           printf("YYMM");
       }else
        {
            printf("NA");
        }
       return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int,input().split()))for i in range(n)]
b = [int(input()) for i in range(m)]

for i in range(n):
    tmp = 0
    for j in range(m):
        tmp+=a[i][j] * b[j]
        pass
    print(tmp)


Measured memory_bytes: 6016
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<pll> x(n);
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        x[i] = {a+b, a-b};
    }
    sort(x.begin(), x.end());

    int cnt = 0;
    int now = -2000000000;
    REP(i, n){
        auto next = x[i];
        if(next.second < now)
            continue;
        cnt++;
        now = next.first;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int A[200000];
long long s[200001];
map<int,int> mp;
int main(){
  int i;
  long long res = 0;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
    }
  }
  for(i=(0);i<(N);i++){
    s[i+1] = (s[i] + A[i]) % K;
  }
  for(i=(0);i<(N+1);i++){
    if(i>=K){
      mp[s[i-K]]--;
    }
    res += mp[s[i]]++;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int N, K, A[2d5];
// ll s[200001];
// map<int,int> mp;
// {
//   ll res = 0;
//   rd(N,K,(A--)(N));
//   rep(i,N) s[i+1] = (s[i] + A[i]) % K;
//   rep(i,N+1){
//     if(i>=K) mp[s[i-K]]--;
//     res += mp[s[i]]++;
//   }
//   wt(res);
// }


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

lli solve(long long K, long long A, long long B)
{
  // A+2回でB
  // 1回で1
  // B/(A+2)<=1/1
  lli ret = K + 1;

  // 1/0 -> A/0 -> 0/1 -> B/0 -> B-A/1 -> 2B-A/0

  K -= (A - 1);
  // A/0/A-1

  if (K <= 0)
    return ret;

  K--;
  // 0/1/A;
  if (K <= 0)
    return ret;

  K--;
  // B/0/A+1

  if (K == 0)
    return max(ret, B);

  // 残りK回できる. 2回でB-Aずつ増えていく
  return max(ret, B + (K / 2) * (B - A) + K % 2);
}

signed main()
{
  long long K;
  scanf("%lld", &K);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  cout << solve(K, A, B) << endl;
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region sieve
struct sieve
{
    int n;
    vector<int> f, primes;

    sieve(int n = 1) : n(n), f(n + 1)
    {
        for (ll i = 2; i <= n; i++)
        {
            if (f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = (ll)i * i; j <= n; j += i)
            {
                if (!f[j])
                {
                    f[j] = i;
                }
            }
        }
    }

    bool isPrime(int x)
    {
        return f[x] == x;
    }

    set<int> factors(int x)
    {
        set<int> s;
        while (x != 1)
        {
            s.emplace(f[x]);
            x /= f[x];
        }
        return s;
    }

    vector<int> factorList(int x)
    {
        vector<int> res;
        while (x != 1)
        {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x)
    {
        auto fl = factorList(x);
        if (fl.size() == 0)
        {
            return {};
        }
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl)
        {
            if (res.back().first == p)
            {
                res.back().second++;
            }
            else
            {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};
#pragma endregion

const int INF = 1e6 + 5;

int main()
{
    int n;
    cin >> n;
    vint a(n);
    int big = 0;
    rep(i, n)
    {
        cin >> a[i];
        big = max(big, a[i]);
    }
    bool pwcp = true;
    map<int, int> f;
    sieve s(INF);

    rep(i, n)
    {
        set<int> st = s.factors(a[i]);
        for (int x : st)
        {
            f[x]++;
        }
    }

    int gcd = 1;
    for (P p : f)
    {
        pwcp = pwcp && p.second == 1;
        if (p.second == n)
        {
            gcd = p.first;
        }
    }

    if (gcd != 1)
    {
        cout << "not coprime" << endl;
    }
    else if (pwcp)
    {
        cout << "pairwise coprime" << endl;
    }
    else
    {
        cout << "setwise coprime" << endl;
    }

    return 0;
}

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int main(){
sp;
int a,b,c,k;
cin>>a>>b>>k;
c=__gcd(a,b);
int x=0;
for(int i=c;i>0; --i)
    if(c%i==0){
        ++x;
        if(x==k){
            cout<<i;
            return 0;
        }
}
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;
typedef complex<double> C;

int n;
C t[102];
bool flg[5000];

namespace std
{
    bool operator < (const C a, const C b) {
        return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
    }
}

struct L : public vector<C>
{
    L(){}
    L(const C a, const C b) {
        push_back(a); push_back(b);
    }
};

//??????
double cross(const C a, const C b)
{
    return imag(conj(a)*b);
}

//??´???????????????????????????
C crosspointLL(const L& l, const L& m)
{
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    //????????´????????¨???
    if(abs(A) < EPS && abs(B) < EPS){
        return m[0];
    }
    return m[0] + B / A * (m[1] - m[0]);
}

vector<double> get(double y){
    vector<double> v;
    L l = L(C(-2001,y),C(2001,y));
    rep(i,n){
        L lll = L(t[i],t[(i+1)%n]);
        if(t[i].imag() < y && y < t[(i+1)%n].imag() || t[(i+1)%n].imag() < y && y < t[i].imag()){
            C p = crosspointLL(l,lll);
            v.push_back(p.real());
        }
    }
    sort(v.begin(),v.end());
    return v;
}

int main(){
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        int hy = -2001, ly = 2001;
        rep(i,n){
            int a,b;
            scanf("%d%d",&a,&b);
            t[i] = C(a+2000,b+2000);
            hy = max(hy,(int)t[i].imag());
            ly = min(ly,(int)t[i].imag());
        }
        int res = 0;
        srep(i,ly,hy){
            memset(flg,0,sizeof(flg));
            vector<double> v1 = get(i+EPS);
            vector<double> v2 = get(i+1-EPS);
            for(int i=0;i<v1.size();i+=2){
                int from = floor(min(v1[i],v2[i]));
                int to = ceil(max(v1[i+1],v2[i+1]));
                for(int j=from;j<to;j++){
                    if(!flg[j]){
                        res++;
                        flg[j] = true;
                    }
                }
            }
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 3220
#include <stdio.h>
int main(void){
    long long A, B, C, X, Y, c;
    scanf("%lld %lld %lld %lld %lld", &A, &B, &C, &X, &Y);
    c=0;
    
    if (A+B>2*C) {
        if (X>Y) c+=2*C*Y;
        else c+=2*C*X;
    }
    else {
        if (X>Y) c+=(A+B)*Y;
        else c+=(A+B)*X;
    }
    
    if (X>Y) {
        if (A>2*C) c+=2*C*(X-Y);
        else c+=A*(X-Y);
    }
    else {
        if (B>2*C) c+=2*C*(Y-X);
        else c+=B*(Y-X);
    }
    
    printf ("%lld", c);
    return 0;
}


Measured memory_bytes: 128
def binary_search(quantity, budget, aizu_chicken_price, chicken_price, aizu_chicken_limit):
    if budget < (quantity - 1) * chicken_price + aizu_chicken_price:
        return None

    if aizu_chicken_price * quantity <= budget:
        aizu_chicken_count = budget // aizu_chicken_price

        if aizu_chicken_limit < aizu_chicken_count:
            aizu_chicken_count = aizu_chicken_limit

        rest = budget - aizu_chicken_price * aizu_chicken_count
        chicken_count = rest // chicken_price
        return aizu_chicken_count, chicken_count

    if aizu_chicken_price * aizu_chicken_limit + chicken_price * (quantity - aizu_chicken_limit) < budget:
        rest = budget - aizu_chicken_price * aizu_chicken_limit
        chicken_count = rest // chicken_price
        return aizu_chicken_limit, chicken_count

    # 二分探索
    aizu_chicken_count = aizu_chicken_limit // 2
    chicken_count = quantity - aizu_chicken_count
    update_count = aizu_chicken_count // 2 + 1

    max_pair = (0, quantity)

    while 0 < update_count:

        if aizu_chicken_count * aizu_chicken_price + chicken_count * chicken_price <= budget:
            max_pair = (aizu_chicken_count, chicken_count)
            aizu_chicken_count += update_count + 1
            chicken_count -= (update_count + 1)

        else:
            aizu_chicken_count -= (update_count + 1)
            chicken_count += update_count + 1

        update_count //= 2

    return max_pair


while True:

    input_data = input()

    if input_data == "0":
        break

    quantity, budget, aizu_chicken_price, chicken_price, aizu_chicken_limit = [int(item) for item in
                                                                               input_data.split(" ")]

    result = binary_search(quantity, budget, aizu_chicken_price, chicken_price, aizu_chicken_limit)

    if result is not None:
        print(result[0], result[1])
    else:
        print("NA")



Measured memory_bytes: 5604
function main(input) {
  const N = parseInt(input.split(" ")[0], 10);
  const A = parseInt(input.split("\n")[1], 10);
  const B = parseInt(input.split("\n")[2], 10);
  if(N==1){
    console.log("Hello World");
  }else{
    console.log(A+B);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
using namespace std;
int main(){
	string s;
	int n;
	while(cin>>n){
		cin>>s;
		if(n<s.size()){
			for(int i=0;i<n;i++){	
			cout<<s[i];	
		}
			cout<<"..."<<endl;
	}
		else	
			cout<<s<<endl;	
	}
	return 0;
}

Measured memory_bytes: 3592
package main

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

func main() {
  //fmt.Print("Input : ")
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var n int
  var buf int

  if sc.Scan() { n, _ = strconv.Atoi(sc.Text()) }

  var reversed []int16 = make([]int16, n)
  for i := n-1; i >= 0; i--{
    if sc.Scan() {
      buf, _ = strconv.Atoi(sc.Text())
      reversed[i] = int16(buf)
    }
  }
  for i := 0; i < n-1; i++ {
    fmt.Printf("%d ", reversed[i])
  }
  fmt.Printf("%d\n", reversed[n-1])
}



Measured memory_bytes: 1060
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = input()
    if N % 2 == 1:
        print('No')
    elif S[:N // 2] == S[N // 2:]:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


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

int N,M,K;
vector<int> ans(111111,0);

vector<int> u_f;
vector<int> siz;
vector<vector<int>> graph(111111);
set<pair<int,int>> block_list;

void init_unionfind(int N){
	for(int i=0;i<N;i++){
		u_f.push_back(i);
		siz.push_back(1);
	}
}

int root(int a){
	if(u_f[a]==a)return a;
	else return u_f[a]=root(u_f[a]);
}

void unite(int a,int b){
	a=root(a);
	b=root(b);
	if(a==b)return;
	siz[a]+=siz[b];
	siz[b]=siz[a];
	u_f[a]=b;
}

bool query(int a,int b){
	return root(a)==root(b);
}

int main(){
	cin >> N >> M >> K;
	
	init_unionfind(N);
	
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		unite(a,b);
	}
	for(int i=0;i<K;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		if(query(a,b)){
			ans[a]--;
			ans[b]--;
		}
	}
	
	for(int i=0;i<N;i++){
		ans[i]+=siz[root(i)]-graph[i].size()-1;
		
		cout << ans[i];
		if(i<N-1)cout << " ";
		else cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 8820
use proconio::input;

fn main() {
    input! {
        n: i64,
    }

    for a in -119..=120 {
        for b in -119..=120 {
            if (a as i64).pow(5) - (b as i64).pow(5) == n {
                println!("{} {}", a, b);
                return
            }
        }
    }
}

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

int main()
{
    int max, object;
    int count = 0;
    while(1){
        count = 0;
        cin >> max >> object;
        if(max == 0 && object == 0){
            break;
        }
        for(int i = 1; i < max-1; i++){
            for(int j = i+1; j < max; j++){
                if(object-i-j <= max && object-i-j > j){
                    count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(int argc, char **argv)
{
	int n, d[50], i, j;
	long long int ans = 0;

	scanf("%d", &n);
	
	for (i = 0; i < n; i++)
		scanf("%d", &d[i]);
	
	for(i = 0; i < n; i++)
		for( j = i + 1; j < n; j++)
			ans = ans + d[i] * d[j];

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include<queue>
#include<cstdio>
using namespace std;
deque<int>q;
int main()
{
	int n;
	scanf("%d",&n);
	int flag=1;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(flag){
			q.push_back(x);
		}else{
			q.push_front(x);
		}
		flag=!flag;
	}
	for(int i=1;i<=n;i++){
		if(flag){
			printf("%d ",q.front());
			q.pop_front();
		}else{
			printf("%d ",q.back());
			q.pop_back();
		}
	}	
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int ans = a*b;
  if(ans>c)
  {
      cout<<c<<endl;
  }
  else
  {
      cout<<ans<<endl;
  }
}

Measured memory_bytes: 3608
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    print(N)
    dist = [0] * (N + 1)

    for i in range(N):
        for j in range(i + 1, N):
            d = min(j - i, abs(i - X) + abs(j - Y) + 1)
            dist[d] += 1

    for k in range(2, N):
        print(dist[k])


main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	// Your code here!
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int b;
	cin >> b;
	cout << a[b - 1];
}


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

#define ll long long
#define ld double
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const int INF=0x3f3f3f3f;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

bool cmp(pair<ll,ll> a, pair<ll,ll> b)
{
	if(a.ss != b.ss)
		return a.ss<b.ss;
	else
		return a.ff>b.ff;
}

int main()
{
	vivek_ghosh;
	
	cin>>n>>k;
	
	vector<pair<ll,ll> > vec;
	
	ll maxPossible = ((n-2)*(n-1))/2;
	ll minPossible = (n - 2);
	
	if(k > maxPossible)
	{
		cout<<-1<<endl;
		return 0;
	}
	else
	{
        ll adjMatrix[n+1][n+1];
        for(i=0;i<=n;i++)
        {
            for(j=0;j<=n;j++)
                adjMatrix[i][j] = 1;
        }
        
        cnt = 0;
        ans = (n*(n-1))/2;
        for(i=2;i<=n && cnt<k;i++)
        {
            for(j=i+1;j<=n && cnt<k;j++)
            {
                adjMatrix[i][j] = 0;
                adjMatrix[j][i] = 0;
                cnt++;
                ans--;
            }
        }
        cout<<ans<<endl;
    	for(i=1;i<=n;i++)
    	{
    	    for(j=i+1;j<=n;j++)
    	    {
    	        if(adjMatrix[i][j])
    	            cout<<i<<" "<<j<<endl;
    	    }
    	}
	
	    
	}
	
	
	return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,s[101];
	int n;
	gets(s);
	n=strlen(s);
	for(int i=0;i<n;i++)
	{
		if(i==0) a=s[i];
		if(i==n-1) b=s[i];
	}
	cout<<a<<n-2<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())

count = 0
total = 1

if total >= b:
    print(count)
else:
    total = a
    count = 1
    if total >= b:
        print(count)
        exit()
    while True:
        total += (a-1)
        count += 1
        if total >= b:
            print(count)
            break


Measured memory_bytes: 9120
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        if(a==b && a!=c) out.println("Yes");
        else if(a==c && a!=b)out.println("Yes");
        else if(b==c && a!=b)out.println("Yes");
        else out.println("No");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21076
# 解説PDFは読んだ
def dfs(b, ans)
#  puts "b:" + b.inspect + " ans:" + ans.inspect
  if b.empty?
    ans.reverse_each { |v| puts v }
    return true
  end
  done = false
  (b.length - 1).downto(0) do |i|
    if b[i] == i + 1
      b.delete_at(i)
      ans.push(i + 1)
      done = dfs(b, ans)
#      ans.pop
#      b.insert(i, i + 1)
      break
    end
  end
  return done
end

n = gets.to_i
b = gets.split.map(&:to_i)
done = dfs(b, [])
puts "-1" unless done


Measured memory_bytes: 14252
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int i,v;
		for(;;){
			int h = scan.nextInt();
			int w = scan.nextInt();
			if(h == 0 && w == 0)
				break;
			for(i = 1; i <= h; ++i){
				for(v = 1; v <= w; ++v){
					if(i % 2 == 0){
					if(v % 2 == 0){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
					}
					else{
						if(v % 2 == 0){
							System.out.print(".");
						}
						else{
							System.out.print("#");
						}
					}
			}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 34852
N=int(input())
m=10**9+7
max_n=10**4
fac=[1]*(max_n+1)
inv=[1]*(max_n+1)
ifac=[1]*(max_n+1)
for n in range(2,max_n+1):
    fac[n]=(fac[n-1]*n)%m
    inv[n]=m-inv[m%n]*(m//n)%m
    ifac[n]=(ifac[n-1]*inv[n])%m
def comb(n,k):
    if n<k or n<0 or k<0:
        return 0
    return (fac[n]*ifac[k]*ifac[n-k])%m
a=0
m=10**9+7
for i in range(N):
    if N-3*(i+1)+i<0:break
    a=(a+comb(N-3*(i+1)+i,i))%m
print(a)

Measured memory_bytes: 10188
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
map<int ,int> mp;
vi vr;
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
int a=RD(),b=RD();
string s=RS();
if(s[a]!='-'){
cout<<"No";
return 0;
}
for(int i=0;i<s.size();++i){
 if(i==a)
  continue;

else{
 if(s[i]=='-'){
 cout<<"No";
 return 0;}
 }
}
cout<<"Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> Q;

ll mod = 1000000007;
const ll INF = 100000000000000;
map<ll, ll> mp;
ll N, K, a[200010],b[200010], sum[200010], ans;
vector<ll> vec[200010];
bool flag[200010];
map<P, ll> M;
ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;

	if (y % 2 == 0)
	{

	}
	else
	{

	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	return po(x, y - 1) * x;
}

void dfs(ll x, ll y)
{
	flag[x] = true;
	ll color = 1;
	for (int i = 0; i < vec[x].size(); i++)
	{
		if (flag[vec[x][i]]) continue;

		if (color == y)
		{
			color++;
		}
		M[P(x, vec[x][i])] = color;
		dfs(vec[x][i], color);
		color++;
	}
}

int main()
{
	ll n;
	map<ll, ll> mp;
	
	cin >> n;

	for (int i = 0; i < n - 1; i++)
	{
		
		cin >> a[i] >> b[i];
		vec[a[i]].push_back(b[i]);
		vec[b[i]].push_back(a[i]);
		mp[a[i]]++, mp[b[i]]++;
	}

	for (auto itr = mp.begin(); itr != mp.end(); ++itr)
	{
		ans = max(ans, itr->second);
	}

	cout << ans << endl;
	
	dfs(1, 0);

	for (int i = 0; i < n - 1; i++)
	{
		cout << max(M[P(a[i], b[i])], M[P(b[i], a[i])]) << endl;
	}

	int www;
	cin >> www;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

void solve()
{
 
  int n,m;
  cin >> n >> m;
  cout << max(0ll,(n*(n-1))/2)+max(0ll,(m*(m-1))/2) << '\n';
  return;
}

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

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

int N;
int Hs[100005];

int main() {
  cin >> N;
  rep(i, N) {
    cin >> Hs[i];
  }
  int st = Hs[0];
  int mx = 0;
  int now = 0;
  for(int i=1; i<N; i++) {
    if(Hs[i] <= Hs[i-1]) {
      now++;
    } else {
      mx = max(mx, now);
      now = 0;
    }
  }
  mx = max(mx, now);
  cout << mx << endl;
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int h, w, d, a, q, l, r;
    int X[90010], Y[90010], dist[90010] = {};
    cin >> h >> w >> d;
    rep(i, h) {
        rep(j, w) {
            cin >> a;
            X[a] = i;
            Y[a] = j;
        }    
    }

    for(int i = d+1; i <= h*w; i++) {
        dist[i] = dist[i-d] + abs(X[i] - X[i-d]) + abs(Y[i] - Y[i-d]);
    }

    cin >> q;
    while(q--) {
        cin >> l >> r;
        cout << dist[r] - dist[l] << "\n";
    }

    return 0;
}

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

int main(){
    int N,M;
    int A[1000];
    cin >> N >> M;
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    int count=0;
    double sum=0;
    for (int i=0; i<N; i++){
        sum = sum + A[i];
    }
    
    for (int i=0; i<N; i++){
        if (A[i]>=sum/(4*M)){
            count++;

        }
    }
    if (count < M){
        cout << "No" <<endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
n=int(input())
t=[int(input()) for i in range(n)]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
ans=1
for x in t:
    ans=lcm(ans,x)
print(ans)

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

int main() {
  int n,m;
  vector<int> p(51,0);
  cin >> n >> m;
  int i,a,b;
  for(i=0;i<m;i++){
    cin >> a >> b;
    p[a-1]++;
    p[b-1]++;
  }
  for(i=0;i<n;i++){
    cout << p[i] << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(K: int):
    cur = 0
    for i in range(K):
        cur += pow(10, i, K) * 7
        cur %= K
        if cur == 0:
            print(i + 1)
            return i + 1
    ret = -1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63372
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    ll sum_a[n+1] = {}, sum_b[m+1] = {};
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        sum_a[i] = sum_a[i-1]+a;
    }
    for(int i = 1; i <= m; i++){
        int b;
        cin >> b;
        sum_b[i] = sum_b[i-1]+b;
    }
    ll ans = 0;
    ll b_idx = m;
    for(int i = 0; i <= n; i++){
        if(sum_a[i] > k) break;
        while(sum_a[i]+sum_b[b_idx] > k && b_idx >= 0){
            b_idx--;
        }
        ans = max(ans, i+b_idx);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  string S[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(int i=0;i<7;i++){
    if(s==S[6-i]) cout<<i+1<<endl;
  }
}
    

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dictionary dict = new Dictionary();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			String cmd = sc.next();
			if(cmd.equals("insert")) {
				String value = sc.next();
				dict.insert(value);
			}else if(cmd.equals("find")) {
				String value = sc.next();
				dict.find(value);
			}
		}
		sc.close();
	}
}

class Dictionary{
	private Map<Integer, String> hm = new HashMap<Integer,String>();

	int getChar(char ch) {
		if(ch == 'A') {
			return 1;
		}else if(ch == 'C') {
			return 2;
		}else if(ch == 'G') {
			return 3;
		}else {
			return 4;
		}
	}

	int getKey(String str) {  // ハッシュ関数
		int sum = 0, p = 1;
		for(int i = 0; i < str.length(); i++) {
			sum += p * getChar(str.charAt(i));
			p *= 5;
		}
		return sum;
	}

	void find(String str) {
		int key = getKey(str);
		if(hm.get(key) != null) {
			System.out.println("yes");
		}else {
			System.out.println("no");
		}
	}

	void insert(String str) {
		int key = getKey(str);
		hm.put(key, str);
	}
}


Measured memory_bytes: 268072
import java.util.*;
import java.lang.*;
import java.util.Scanner;

public class Main
{
	public static void main (String[] arg)
	{
		int[] a=new int[10];
		Scanner in = new Scanner(System.in);
		for(int i=0 ; i<10 ;i++)
		{
			a[i] = in.nextInt();
			
		}
		Arrays.sort(a);
		for(int i=9 ; i>6 ;i--)
		{
		System.out.println(a[i]);
		}
	}
}

Measured memory_bytes: 17168
#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>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline 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 int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> like(n, vector<int>(m));
    for (int i=0; i<n; ++i) {
        for (int j=0; j<m; ++j) {
            cin >> like.at(i).at(j);
            --like.at(i).at(j);
        }
    }

    vector<bool> hold(m, true);
    vector<int> attend(n);
    int res = INF;
    for (int i=0; i<m; ++i) {
        vector<int> cnt(m);
        for (int j=0; j<n; ++j) ++cnt.at(like.at(j).at(attend.at(j)));
        int maxi = -1, ind = -1;
        for (int j=0; j<m; ++j) if (chmax(maxi, cnt.at(j))) ind = j;
        chmin(res, maxi);
        hold.at(ind) = false;
        for (int j=0; j<n; ++j) while (attend.at(j) < m && !hold.at(like.at(j).at(attend.at(j)))) ++attend.at(j);
    }

    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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(){
    int N,M; cin >> N >> M;
        priority_queue <int> q;
        rep(i,N){
            int a; cin >> a;
            q.push(a);
        }
        
        rep(i,M){
            int a=q.top(); q.pop();
            q.push(a/2);
        }
        
        ll ans=0;
        rep(i,N){
            ans+=q.top(); q.pop();
        }
        cout << ans << endl;
        return 0;    
}

Measured memory_bytes: 892
#include <stdio.h>

int main(){
  
  int cards[4][14];
  int n,k,i,j,m,num;  
  char mark,dummy;
  
  
  for(i=0;i<4;i++)
    {
      for(j=0;j<14;j++)
	{
	  cards[i][j] = 0;
	}
    }


scanf("%d",&n);
  
  for(k=0;k<n;k++)
    {
      scanf("%c",&dummy);
      scanf("%c %d",&mark,&num);
      
      if(mark == 'S')
	{
	  cards[0][num] = 1;
	}
      else if(mark == 'H')
	{
	  cards[1][num] = 1;
	}
      else if(mark == 'C')
	{
	  cards[2][num] = 1;
	}
      else if(mark == 'D')
	{
	  cards[3][num] = 1;
	}
    }
  for(i=0;i<4;i++)
    {
      for(j=1;j<14;j++)
	{
	  if(cards[i][j] == 0){
	    if(i == 0){printf("S %d\n",j);
	    }else if(i == 1){printf("H %d\n",j);
	    }else if(i == 2){printf("C %d\n",j);
	    }else if(i == 3){printf("D %d\n",j);
	    }
	  }
	}
    }  
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int n;
	cin >> n;
	int a, b;
	for (int i = 0; i <= n / 4; ++ i) {
		int nn = n - 4 * i;
		if (nn % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool done[2222];
ll memo[2222];

ll solve(int n){
	int i;
	if(done[n]){
		return memo[n];
	}
	done[n] = true;
	if(!n){
		return memo[n] = 1ll;
	}
	for(i=3; i<=n; ++i){
		add_mod(memo[n],solve(n-i));
	}
	return memo[n];
}

int main(void){
	int s;
	std::cin >> s;
	std::cout << solve(s) << std::endl;
	return 0;
}


Measured memory_bytes: 3580
n = int(input())
li = list(map(int, input().split()))

li.sort(reverse=True)

check = -1
flag = 0
ans = []

for i in li:
    if len(ans) == 2:
        break
    
    if flag == 0:
        check = i
        flag = 1
        continue
    
    if check == i:
        ans.append(i)
        flag = 0
    else:
        check = i

if len(ans) < 2:
    print(0)
else:
    print(ans[0] * ans[1])

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int h, m, s;

  while(cin >> h >> m >> s) {
    if(h == -1 && m == -1 && s == -1) break;

    int stand = 2*3600 - (h*3600 + m*60 + s);
    int hispeed = stand * 3;

    printf("%02d:%02d:%02d\n", stand/3600, stand%3600/60, stand%60);
    printf("%02d:%02d:%02d\n", hispeed/3600, hispeed%3600/60, hispeed%60);
  }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);
const int MAX_N = (int)(50 + 5);

int n;
ll x;

ll putty[MAX_N];
ll burger[MAX_N];

ll ans;

ll eat_layer_burger(int layer, ll remain) {
  if (remain == 1) return 0;

  remain -= 1;

  if (remain < burger[layer - 1]) {
    return eat_layer_burger(layer - 1, remain);
  }
  else if (remain == burger[layer - 1]) {
    return putty[layer - 1];
  }
  else if (remain == burger[layer - 1] + 1) {
    return putty[layer - 1] + 1;
  }
  else if (remain < 2 * burger[layer - 1] + 1) {
    ll upper = eat_layer_burger(layer - 1, remain - burger[layer - 1] - 1);
    return putty[layer - 1] + 1 + upper;
  } else {
    return putty[layer];
  }

}


int main(void) {
    // Here your code !
    scanf("%d %lld", &n, &x);

    putty[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        putty[i] = putty[i - 1] * 2 + 1;
    }

    burger[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        burger[i] = burger[i - 1] * 2 + 3;
    }
    
    ans = eat_layer_burger(n, x);

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256