akhauriyash/Code-Regression huggingface dataset:
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

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

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 3000 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000 * 1ll * 10000000 * 1ll * 1000;
const ld pi = acosl(-1.0);

ll n, k;
vector<ll> a;

void input() {
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

void solve(int testId) {
    ll l = 0, r = 1000000000;
    while (l < r - 1) {
        ll m = (l + r) / 2;
        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += ((a[i] - 1) / m);
        }
        if (cnt > k) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << r << endl;
}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


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

int main() {
    ll N, H; cin >> N >> H;
    vector<ll> a(N);
    vector<ll> b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }

    ll a_max = *max_element(a.begin(),a.end());
    sort(b.begin(),b.end(), greater<ll>());

    ll ans = 0;
    for (ll i : b)
    {
        if(i>a_max){
            H -= i;
            ans++;
            if(H<=0) break;
        } 
        else break;
    }
    if(H>0) {
        ans += (H + a_max -1) / a_max;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    dp = [[0] * (N * 50 + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, -1, -1):
            for k in range(N * 50 + 1):
                if k - X[i] >= 0 and j > 0:
                    dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 70268
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

bool thru[2510], work[2510];

void search(int now, vector<vector<int>> &G){
    work[now]=1;
    for(int i=0; i<G[now].size(); ++i){
        if(!work[G[now][i]]){
            search(G[now][i], G);
        }
    }
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g(N+1), rev(N+1);
	vector<vector<ll>> cost(N+1);
	for(int i=0; i<M; ++i){
	    int a, b;
	    ll c;
	    cin >> a >> b >> c;
	    g[a].push_back(b);
	    cost[a].push_back(-c);
	    rev[b].push_back(a);
	}
	search(1, g);
	for(int i=1; i<=N; ++i){
	    thru[i] |= work[i];
	    work[i]=0;
	}
	search(N, rev);
	int cnt=0;
	for(int i=1; i<=N; ++i){
	    thru[i] &= work[i];
	    if(thru[i]) ++cnt;
	}
	vector<ll> mn(N+1, 1e18);
	mn[1]=0;
	for(int i=1; i<cnt; ++i){
	    for(int p=1; p<=N; ++p){
	        if(thru[p]){
	            for(int q=0; q<g[p].size(); ++q){
	                if(thru[g[p][q]]){
	                    mn[g[p][q]]=min(mn[g[p][q]], mn[p]+cost[p][q]);
	                }
	            }
	        }
	    }
	}
	for(int p=1; p<=N; ++p){
	    if(thru[p]){
	        for(int q=0; q<g[p].size(); ++q){
	            if(thru[g[p][q]]){
	                if(mn[g[p][q]]>mn[p]+cost[p][q]){
	                    cout << "inf" << endl;
	                    return 0;
	                }
	            }
	        }
	    }
	}
	cout << -mn[N] << endl;
	return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> P(N), Q(N);
	IN(P); IN(Q);
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		A[i] = i + 1;
	}
	int a, b;
	int cnt = 0;
	do {
		if (A == P) {
			a = cnt;
		}
		if (A == Q) {
			b = cnt;
		}
		++cnt;
		
	} while (next_permutation(A.begin(), A.end()));

	cout << abs(a - b) << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
a, b, k = gets.split.map(&:to_i)
a_ar = []
b_ar = []
for i in 1..a do
  a_ar << i if a%i == 0
end
for i in 1..b do
  b_ar << i if b%i == 0
end
r = a_ar & b_ar
p r.sort.reverse[k-1]

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))


def main() -> None:
    """Entry point
    """
    # 求解処理
    # N個のボールから2個またはM個のボールから2個選んだ場合の数
    result = int(N*(N-1)/2 + M*(M-1)/2)

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


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

int main() {
  long long n, m;
  cin >> n >> m;
  priority_queue<long long> q;
  long long a;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    q.push(a);
  }
  long long b;
  for (long long i = 0; i < m; i++) {
    b = q.top() / 2;
    q.pop();
    q.push(b);
  }
  long long sum = 0;
  while (q.size() > 0 && q.top() > 0) {
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;
}


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

int main() {
  int n;
  cin >> n;
  if(n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	int N;
	get(N);
	vector<int>a(N);
	for(int i=0;i<N;i++)get(a[i]);
	int odd = 0;
	for(int i=0;i<N;i++)if(a[i]%2!=0)odd++;
	int ans = 1;
	for(int i=0;i<N;i++)ans*=3;
	int n = 1;
	for(int i=0;i<N-odd;i++)n*=2;
	cout << ans - n<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

a, b, n = map(int, input().split())
def f(x):
    return (a * x) // b - a * (x // b)

left, right = 0, n
# 答えが整数になる場合このrightとleftの幅を3未満にするとバグる
while abs(right - left) > 3:
    mid1 = (right * 2 + left) // 3 + 1
    mid2 = (right + left * 2) // 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid1
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid2
ans = 0
for i in range(left, right + 1):
    ans = max(ans, f(i))
# f(0), f(x)もジャッジしないとバグる
print(max(ans, f(0), f(n)))

Measured memory_bytes: 62160
/**
 * Copyright (c) 2014 Authors. All rights reserved.
 * 
 * FileName: A.cpp
 * Author: Beiyu Li <sysulby@gmail.com>
 * Date: 2014-09-15
 */
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,s,t) for (int i = (s); i <= (t); ++i)
#define FOREACH(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)

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

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

const double g = 9.8;
const double pi = acos(-1);
const double eps = 1e-6;
const int maxn = 50 + 5;

int n, v, x, y;
int l[maxn], b[maxn], r[maxn], t[maxn];

inline int sgn(double x)
{
        return x < -eps? -1: x > eps;
}

inline bool inside(double x, double l, double r)
{
        return sgn(l - x) <= 0 &&  sgn(x - r) <= 0;
}

double A, B;
inline double f(double x)
{
        return A * x * x + B * x;
}

bool hit(double h)
{
        if (sgn(h - y) < 0) return false;
        REP(i,n) if (inside(x, l[i], r[i])) {
                if (inside(b[i], y, h)) return false;
                if (inside(t[i], y, h)) return false;
        }
        return true;
}

bool hit(double h, int l, int r)
{
        double d = B * B + 4 * A * h;
        if (sgn(d) < 0) return false;
        d = sqrt(d);
        double p = (-B - d) / 2 / A;
        if (inside(p, l, r) && sgn(p - x) <= 0) return true;
        p = (-B + d) / 2 / A;
        if (inside(p, l, r) && sgn(p - x) <= 0) return true;
        return false;
}

bool check(double a)
{
        double T = v * sin(a) / g;
        double D = v * cos(a) * T, H = 0.5 * g * T * T;
        A = -H / D / D; B = 2 * H / D;
        double h = f(x);
        if (!hit(h)) return false;
        REP(i,n) {
                if (inside(f(l[i]), b[i], t[i])
                                && sgn(l[i] - x) <= 0) return false;
                if (inside(f(r[i]), b[i], t[i])
                                && sgn(r[i] - x) <= 0) return false;
                if (hit(b[i], l[i], r[i])) return false;
                if (hit(t[i], l[i], r[i])) return false;
        }
        return true;
}

const double deta = 1e-6;
int main()
{
        while (scanf("%d%d%d%d", &n, &v, &x, &y) != EOF) {
                REP(i,n) scanf("%d%d%d%d", &l[i], &b[i], &r[i], &t[i]);
                bool found = false;
                for (double a = deta; a < pi / 2; a += deta) {
                        if (check(a)) {
                                found = true;
                                break;
                        }
                }
                puts(found? "Yes": "No");
        }

        return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()


using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;


int main(){
    int N; cin >> N;
    vector<ll> A(N), sum(N+1, 0);
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum[i+1]=sum[i]+A[i];
    }
    ll res=LINF;
    int left_low=1, right_low=2;
    for(int i=2; i<=N-2; i++){
        while(sum[left_low] <= sum[i]-sum[left_low] && left_low < i){
            left_low++;
        }
        ll P1=sum[left_low], Q1=sum[i]-sum[left_low];
        ll P2=sum[left_low-1], Q2=sum[i]-sum[left_low-1];
        ll left_min=min(P1, Q1), left_max=max(P1, Q1);
        if(abs(P2-Q2) < abs(P1-Q1)) left_min=min(P2, Q2), left_max=max(P2, Q2);

        while(sum[right_low]-sum[i] <= sum[N]-sum[right_low] && right_low < N){
            right_low++;
        }
        if(right_low <= i) right_low=i+1;
        ll R1=sum[right_low]-sum[i], S1=sum[N]-sum[right_low];
        ll R2=sum[right_low-1]-sum[i], S2=sum[N]-sum[right_low-1];
        ll right_min=min(R1, S1), right_max=max(R1, S1);
        if(abs(R2-S2) < abs(R1-S1)) right_min=min(R2, S2), right_max=max(R2, S2);

        ll tmp=max(left_max, right_max)-min(left_min, right_min);
        res=min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6400
int main() {
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>=b&&c>=d){
        printf("%d\n",b+d);
    }else if(a>=b&&c<=d){
        printf("%d\n",b+c);
    }else if(a<=b&&c<=d){
        printf("%d\n",a+c);
    }else if(a<=b&&c>=d){
        printf("%d\n",a+d);
    }
	return 0;
}

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

using i64 = int64_t;

int main(){
    int t, d, l;
    while(cin >> t >> d >> l, t != 0){
        bool is_wet = false;
        int cnt = 0, ans = 0;
        for(int i=0;i<t;++i){
            if(is_wet)ans++;
            int x;
            cin >> x;
            if(x >= l){
                is_wet = true;
                cnt = 0;
            }else{
                cnt++;
            }
            if(cnt >= d)is_wet = false;
        }
        cout << ans << endl;
    }


    return 0;
}



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

class UnionFind {
  vector<int> par;
  public:
  UnionFind(int n) { for(int i=0; i<n; i++) par.push_back(i); }
  int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
  int same(int x, int y) { return root(x) == root(y); }
  void unite(int x, int y) { x = root(x); y = root(y); if (x != y) par[x] = y; }
};

struct pos { int ind, x, y; };

signed main() {
  int n; cin >> n;
  vector<pos> cities;
  vector<pair<int, pair<int, int>>> q;
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    cities.push_back(pos{i, x, y});
  }
  // sort by x
  sort(all(cities), [](auto a, auto b) { return a.x < b.x; });
  for(int i=1; i<n; i++) {
    int score = min(
      abs(cities[i-1].x - cities[i].x),
      abs(cities[i-1].y - cities[i].y)
    );
    q.push_back(make_pair(score, make_pair(cities[i-1].ind, cities[i].ind)));
  }
  // sort by y
  sort(all(cities), [](auto a, auto b) { return a.y < b.y; });
  for(int i=1; i<n; i++) {
    int score = min(
      abs(cities[i-1].x - cities[i].x),
      abs(cities[i-1].y - cities[i].y)
    );
    q.push_back(make_pair(score, make_pair(cities[i-1].ind, cities[i].ind)));
  }

  // sort by score
  sort(all(q), [](auto a, auto b) { return a.first < b.first; });

  UnionFind tree(n);
  int cost = 0;
  for(pair<int, pair<int, int>> cand : q) {
    int a = cand.second.first, b = cand.second.second;
    if (tree.same(a, b)) continue;
    tree.unite(a, b);
    cost += cand.first;
  }
  cout << cost << endl;
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
int main() {
    int n;
    cin >> n;
    int a,preva;
    cin >> preva;
    int inc=-1;
    int ans=1;
    rep(i,n-1) {
        cin >> a;
        if ((preva>a && inc==0) || (preva<a && inc==1)) {
            inc=-1;
            ++ans;
        } else if (preva!=a && inc==-1) inc=(preva>a)?1:0;
        preva=a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxn = 1e6+5;
struct stu{
    int data;
    int x;
};
int main(){
    //struct stu arr[maxn];
    int a=0,b=0,c=0,i,n;
    cin>>n;
    int s;
    for(i = 0;i < n;i++){
        cin>>s;
        if(s%4==0){
            a++;
        }
        else if(s%2==0){
            b++;
        }
        else{
            c++;
        }
    }
    if(a>=c){
        if(a==0&&b<=1){
            cout<<"No";
        }
        else{
            cout<<"Yes";
        }

    }
    else if(b==0&&c<=a+1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){

  string s;
  int appear_cnt[26][3]={0};
  int temp_half;
  int over_half;

  int char_num = 0;
  const int char_base = 'a';

  int a = 0, b = 0;

  cin >> s;

  int s_len=s.size();
  over_half = s_len / 2 + 1;

  for (int i = 0; i < s_len; i++)
  {
    char_num = (char)s[i] - char_base;
    
    if (appear_cnt[char_num][0]==0)
    {
      appear_cnt[char_num][1] = i;
      appear_cnt[char_num][2] = -3;
    }
    appear_cnt[char_num][0]++;
    temp_half = (i - appear_cnt[char_num][1]) / 2 + 1;

/*     if (appear_cnt[char_num][0]>temp_half && temp_half!=1)
    {
      a = appear_cnt[char_num][1] + 1;
      b = i + 1;
      appear_cnt[char_num][2] = i;      
      break;
    } else */ if (i-appear_cnt[char_num][2]<=2) {
      a = i - 1;
      b = i + 1;
      appear_cnt[char_num][2] = i;      
      break;
    }
    else
    {
      appear_cnt[char_num][2] = i;
    }
  }

  if (a==0 && b!=0)
  {
    a = 1;
    b = s_len;
  }

  if (a==0 || b==0)
  {
    cout << -1 << " " << " " << -1 << endl;
  } else 
  {
    //cout << s.substr(a, b-a+1) << endl;
    cout << a << " " << " " << b << endl;
  }

  return 0;
}

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

int main(){
	ll  d,x,y;
	int n; cin>>n>>d;
	int ans=0;
	rep(i,n){
		ll x,y; cin>>x>>y;
		if(d*d>=x*x+y*y){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
using namespace std;
bool point[100001];
int n,a[100001],b[100001],t[100001],d[100001],cnt,len1,len2,minn=1e9,ans;
struct node
{
  int d,num;
  bool operator < (const node &a)const
  {
    if (d!=a.d)
      return d<a.d;
    return num<a.num;
  }
};
node p[100001],p2[100001];
int main()
{
  cin>>n;
  for (int i=1;i<=n;++i)
    cin>>a[i];
  for (int i=1;i<=n;++i)
    cin>>b[i];
  for (int i=0;i<=(1<<n)-1;++i)
    {
      cnt=len1=len2=ans=0;
      for (int j=1;j<=n;++j)
	if (i&(1<<(j-1)))
	  cnt++;
      if (cnt!=n/2)
	continue;
      for (int j=1;j<=n;++j)
	{
	  if (i&(1<<(j-1)))
	    {
	      point[j]=0;
	      if (j%2==0)
	        p[++len1].d=a[j];
	      else
		p[++len1].d=b[j];
	      p[len1].num=j;
	    }
	  else
	    {
	      point[j]=1;
	      if (j%2==1)
	        p2[++len2].d=a[j];
	      else
		p2[++len2].d=b[j];
	      p2[len2].num=j;
	    }
	}
      sort(p+1,p+len1+1);
      sort(p2+1,p2+len2+1);
      for (int j=1;j<=n;++j)
	{
	  if (j%2==1)
	    {
	      t[j]=p2[(j+1)/2].num;
	      d[j]=p2[(j+1)/2].d;
	    }
	  else
	    {
	      t[j]=p[(j+1)/2].num;
	      d[j]=p[(j+1)/2].d;
	    }
	}
      bool op=0;
      for (int j=1;j<=n-1;++j)
	if (d[j]>d[j+1])
	  op=1;
      if (op)
	continue;
      for (int j=1;j<=n;++j)
	for (int k=j+1;k<=n;++k)
	    if (t[j]>t[k])
	     ans++;
      minn=min(minn,ans);
    }
  if (minn==1e9)
    cout<<-1<<endl;
  else
    cout<<minn<<endl;
  return 0;
}

Measured memory_bytes: 256
// Problem : B - An Odd Problem
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int ans = 0;
	RI(i, n) {
		int a; cin >> a;
		if (a % 2 == 1 && i % 2 == 1) ans++;
	}
	cout << ans;
	return 0;
}
 


Measured memory_bytes: 3608
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

sum1 = 0
sum2 = 0
for i in range(N):
    if a[i] > b[i]:
        sum1 += a[i] - b[i]
    else:
        sum2 += (b[i] - a[i])//2
if sum1 <= sum2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int n;
    cin >> n;
    int limit = 0;
    SegmentTree<int> seg(1e+5 + 5, [](int a, int b){return a+b;}, 0);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        seg.update(a, seg[a] + 1);
        chmax(limit, a);
    }
    int res = 0;
    for(int i = 1; i <= limit; ++i){
        chmax(res, seg.query(i - 1, i + 2));
    }
    chmax(res, seg.query(0, 2));
    cout << res << endl;
}

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

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

int main() {
    ios::sync_with_stdio(false);
    int n, m, x, y;
    cin >> n >> m >> x >> y;

    int res = min(m, n) * x;
    if ( n - m > 0 ) res += (n - m) * y;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int d, t, s;
	cin >> d >> t >> s;
	if (t*s >= d)cout << "Yes"; else cout << "No";
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

#define INF 1e9
#define llINF (long long)1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll ans=0;
  int n,m;cin>>n>>m;
  vector<ll>x(n),y(n),z(n);
  for(int i=0;i<n;i++)
    cin>>x[i]>>y[i]>>z[i];
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	vector<ll>sum(n);
	if(i==0){
	  for(int l=0;l<n;l++){
	    sum[l]+=x[l];
	  }
	}else{
	  for(int l=0;l<n;l++){
	    sum[l]-=x[l];
	  }
	}
	if(j==0){
	  for(int l=0;l<n;l++){
	    sum[l]+=y[l];
	  }
	}else{
	  for(int l=0;l<n;l++){
	    sum[l]-=y[l];
	  }
	}
	if(k==0){
	  for(int l=0;l<n;l++){
	    sum[l]+=z[l];
	  }
	}else{
	  for(int l=0;l<n;l++){
	    sum[l]-=z[l];
	  }
	}
	sort(sum.begin(),sum.end(),greater<ll>());
	ll cnt=0;
	for(int l=0;l<m;l++){
	  cnt+=sum[l];
	}
	ans=max(ans,cnt);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : 107abcc.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

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

	vector<long long> A;
	for(int i = 0; i < N; ++i){
		long long a;
		cin >> a;
		A.push_back(a);
	}

	long long minMove = 1ll << 60;

	--K;
	for(int i = 0; i < N - K; ++i){
		if(A[i] * A[i + K] < 0){
			minMove = min(minMove, min(A[i + K] + 2 * abs(A[i]), 2 * A[i + K] + abs(A[i])));
		}
		else if(0 <= A[i] * A[i + K]){
			minMove = min(minMove, max(abs(A[i]), abs(A[i + K])));
		}
	}
	cout << minMove << endl;
}


Measured memory_bytes: 1400
import sys
import math
from functools import reduce


def main():
    input = sys.stdin.readline
    K = int(input())
    assert 1 <= K <= 200
    total = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            a = euclidean_algorithm(i, j)
            for k in range(1, K+1):
                total += euclidean_algorithm(a, k)
    print(total)


def gcd_list(numbers):
    return reduce(euclidean_algorithm, numbers)


def euclidean_algorithm(a, b):
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b


if __name__ == "__main__":
    main()


Measured memory_bytes: 9480
#include<stdio.h>
int main()
{
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if((A*B)>=(C*D))
	printf("%d",A*B);
	else
	printf("%d",C*D);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int n; 
    cin>>n;
    ll sum = 0;
    fore(i,1,n+1)
        fore(j,1,n+1)
            fore(k,1,n+1)
                sum+=__gcd(i,__gcd(j,k));
    
    cout<<sum<<endl;

    return 0;
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b,min(a+c,b+c))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
const int N=1e5 + 5;
int a[N],b[N],c[N];
ll L[N],R[N];

int main(){

//	freopen("in.txt","r",stdin);

	ll ans=0,sum=0;
	int x,y,z,n;
	scanf("%d%d%d",&x,&y,&z);
	n=x + y + z;
	vector<pair<int, int> > v;
	for(int i=0;i < n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		ans+=c[i];
		a[i]-=c[i];
		b[i]-=c[i];
		v.push_back({ a[i] - b[i], i });
	}
	sort(v.begin(),v.end());
	priority_queue<ll> q;
	for(int i=0;i < y;i++){
		sum+=b[v[i].se];
		q.push(-b[v[i].se]);
	}
	L[y - 1]=sum;
	for(int i=y;i < n;i++){
		if(b[v[i].se] > -q.top()){
			sum-=-q.top();
			q.pop();
			q.push(-b[v[i].se]);
			sum+=b[v[i].se];
		}
		L[i]=sum;
	}
	while(q.size())
		q.pop();
	sum=0;
	for(int i=n - 1;i >= n - x;i--){
		sum+=a[v[i].se];
		q.push(-a[v[i].se]);
	}
	R[n - x]=sum;
	for(int i=n - x - 1;i >= 0;i--){
		if(a[v[i].se] > -q.top()){
			sum-=-q.top();
			q.pop();
			q.push(-a[v[i].se]);
			sum+=a[v[i].se];
		}
		R[i]=sum;
	}
	sum=-1e18;
	for(int i=y - 1;i < n - x;i++){
		sum=max(sum,L[i] + R[i + 1]);
	}
	cout << ans + sum << endl;

	return 0;
}


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

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

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

X,Y=map(int,input().split())

if (X+Y)%3!=0:
  print(0)
  exit()

n=(X+Y)//3
k=Y-(X+Y)//3

if k<0 or k>n:
  print(0)
  exit()
  
#print("n,k:",n,k)
print(cmb(n,k,mod))

Measured memory_bytes: 127612
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <tuple>
#include <functional>
#include <limits>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

// Print each element of a container.
template <typename Container>
void print(const Container& container)
{
    stringstream sstream;

    string delim("");
	for (const auto& element : container)
	{
		sstream << delim << element;
        delim = " ";
	}

    cout << sstream.str() << endl;
}

template <typename Container>
int selectionSort(Container& container)
{
    int count(0);

    for(auto it(begin(container)); it != end(container); ++it)
    {
        auto kt(it);

        for(auto jt(it); jt != end(container); ++jt)
        {
            if(*kt > *jt) kt = jt;
        }

        iter_swap(it, kt);
        
        if(it != kt) ++count;
    }

    return count;
}

int main()
{
    vector<int> v;

    int n;
    cin >> n;

    for(size_t i(0); i < n; ++i)
    {
        int x;
        cin >> x;

        v.push_back(x);
    }

    int count(selectionSort(v));

    print(v);

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3204
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	string s;
	while(getline(cin, s)) {
		REP(i, 26) {
			REP(j, s.length()) {
				if('a' <= s[j] && s[j] <= 'z') {
					s[j]++;
					if('z' < s[j]) {
						s[j] -= 26;
					}
				}
			}

			if(s.find("the") != string::npos) {
				cout << s << endl;
				goto next;
			} else if(s.find("this") != string::npos) {
				cout << s << endl;
				goto next;
			} else if(s.find("that") != string::npos) {
				cout << s << endl;
				goto next;
			}
		}

		next:;
	}

	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<int,int>> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i].first >> a[i].second;
		if (a[i].first > a[i].second) swap(a[i].first,a[i].second);
	}
	sort(a.begin(),a.end());
	int l = a[0].second,r = a[0].second;
	for (int i = 1;i < n;i++) {
		l = min(l,a[i].second);
		r = max(r,a[i].second);
	}
	long long ans = 1ll * (a[n-1].first - a[0].first) * (r - l);
	long long len = r - a[0].first;
	l = a[n-1].second;r = a[n-1].first;
	for (int i = 0;i <= n;i++) {
		ans = min(ans,len * (r - (i == n ? l : min(l,a[i].first))));
		if (i == n) break;
		l = min(l,a[i].second);
		r = max(r,a[i].second);
	}
	cout << ans;
}

Measured memory_bytes: 1792
n,m = map(int,input().split())
if n>=3 and m>=3:
        print((n-2)*(m-2))
elif n == 2 or m == 2:
        print(0)
elif n == 1 and m == 1:
        print(1)
elif n == 1:
        print(m-2)
else:
        print(n-2)

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

typedef long long int ll;

int main()
{

    string s;
    cin>>s;
    int lc=0,uc=0,c=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]>='A' && s[i]<='Z') uc++;
        else lc++;
    }
    for(int i=2;i<=s.size()-2;i++)
    {
        if(s[i]=='C') c++;
    }
    if(uc==2 && s[0]=='A' && c==1) cout<<"AC";
    else cout<<"WA";
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc088B(args)

    //abc105B(args)
    //abc087B(args)
    //abc081B(args)
    //abc095(args)
    //abc086(args)
    //tutorial(args)
}

/*
* N枚のカードがあります. i枚目のカードには, aiという数が書かれています.
* Alice と Bob は, これらのカードを使ってゲームを行います. ゲームでは, Alice と Bob が交互に 1 枚ずつカードを取っていきます. Alice が先にカードを取ります.
* n2 人がすべてのカードを取ったときゲームは終了し, 取ったカードの数の合計がその人の得点になります. 2 人とも自分の得点を最大化するように最適な戦略を取った時, Alice は Bob より何点多く取るか求めてください.
*/
fun abc088B(args: Array<String>) {
    val N = readLine()!!.toInt()
    val Ai = readLine()!!.split(" ").map(String::toInt).toMutableList()
    Ai.sortBy { it * -1 }
    var aliceCount = 0
    var bobCount = 0

    Ai.forEachIndexed { i, ai ->
        run {
            if (i % 2 == 0) {
                aliceCount += ai
            } else {
                bobCount += ai
            }
        }
    }

    println(aliceCount - bobCount)
}

Measured memory_bytes: 36628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; 
int main(){
	double a,b,x;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)){
		cout<<"B"<<endl;
	}else{
		cout<<"A"<<endl;
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int cnt = 0;
    for(int i = 0; i < n - 2; ++i){
        for(int j = i + 1; j < n - 1; ++j){
            if(l[i] == l[j]) continue;
            for(int k = j + 1; k < n; ++k){
                if(l[j] == l[k]) continue;
                if(l[i] + l[j] > l[k]) ++cnt;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	string s,t;
	cin>>s;
	cin>>t;
	int n=s.length(),ans=0;
	for(int i=0;i<n;i++){
	    if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
	//cout<<f(w,n);
	
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define N 200010
int par[N], Rank[N], SIZE[N];

void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        Rank[i] = 0;
        SIZE[i] = 1;
    }
}
int find(int x)
{
    if (par[x] == x)
        return x;
    else
        return par[x] = find(par[x]);
}
void unit(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        SIZE[y] += SIZE[x];
    }
    else
    {
        par[y] = x;
        SIZE[x] += SIZE[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}
bool same(int x, int y)
{
    return find(x) == find(y);
}

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

    int n, m;
    cin >> n >> m;
    init(n + m);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int l;
            cin >> l;
            l += (n - 1);
            unit(i, l);
        }
    }
    rep(i, n) if (!same(0, i))
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  ll ma = 0;
  ll ans = 1;
  int flag = 0;
  rep (i, n) {
    ll tmp;
    cin >> tmp;
    ma = max(ma, tmp);
    if (tmp == 0) {
      P(0);
      return 0;
    }
    ans *= tmp;
    if (ans < 0) flag = 1;
  }
  if (ans < ma || ans > 1000000000000000000 || flag == 1) {
    P(-1);
  } else {
    P(ans);
  }
  return 0;
}



Measured memory_bytes: 3608
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define F(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff < b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/

void solve()
{
	ll n;
	string s;
	cin>>n>>s;
	if(s.sz>n)
	{
		for(ll i=0;i<n;i++)cout<<s[i];
		s="...";
		cout<<s;
	}
	else cout<<s;
}
int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3552
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.util.Scanner;

public class Main
{
	public static void main(String[] args) {
	    Scanner s=new Scanner (System.in);
	  int n=s.nextInt();
	  int m=s.nextInt();
	if(n==m)
	{
	System.out.println("Yes");    
	}
	else
	{
	   System.out.println("No");
	}
	
	}
}


Measured memory_bytes: 21844
#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;
#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(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
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 main(){
    int N,X;
    cin >> N >> X;
    VI L(N);
    REP(i,N)cin >> L[i];

    int sum=0;
    REP(i,N+1){
        if(sum>X){
            cout << i << endl;
            return 0;
        }
        sum += L[i];
    }
    cout << N+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) for(long long i=0; i<a; i++)
 
using namespace std;

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


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::Chars;
use proconio::marker::Usize1;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       A:i32,B:i32
    }
    println!("{}", (B - 1 + A - 2) / (A - 1));
}


Measured memory_bytes: 2116
from copy import deepcopy

S = input()

dp = [0] * 13
dp_past = [1] + [0] * 13

tens_mod = [1, 10, 9, 12, 3, 4]
mod = int(10**9 + 7)

for i, s in enumerate(S[::-1]):
    if s == "?":
        for j in range(13):
            dp[j] = 0
            for k in range(10):
                dp[j] += dp_past[(j - k * tens_mod[i % 6]) % 13]
            dp[j] %= mod

    else:
        k = int(s)
        for j in range(13):
            dp[j] = dp_past[(j - k * tens_mod[i % 6]) % 13]
    dp_past = deepcopy(dp)

print(dp[5] % mod)


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll A,B; cin >> A >>B;
if(A==1&&B==2 || B==1&&A==2)cout << 3;
else if(A==1&&B==3 || B==1&&A==3) cout << 2;
else if(A==2&&B==3 || B==2&&A==3) cout << 1;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int a, b;
    cin>>a>>b;
    int start = ceil((double)(a/0.08));
    int end = ((a+1)/0.08);
    if((double)(end*0.08) != (double)a){
        end -= 1;
    }
    for(int i = start; i <= end; i++){
        if((int)(i*0.1) == b){
            cout<<i;
            return 0;
        }
    }
    cout<<"-1";
    return 0;
}

Measured memory_bytes: 3612