akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 

int main() 
{ 
     int n,k;
    cin>>n>>k;
    long long int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    long long int cnt=0;
    for(int i=n-1;i>=0;i--){
        if(k>0){
            //cnt++;
            k--;
        }
        else{
            cnt+=a[i];
        }
    }
    cout<<cnt;
	return 0; 
} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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;
    cin >> n;
    ll ans = 0;
    vector<char> s(2*n);
    map<pair<vector<char>, vector<char> >, int> mp;
    rep(i, 2*n){
        cin >> s.at(i);
    }
    // 後半
    for (int bit = 0; bit < (1<<n); ++bit) {
        bitset<18> tmp(bit);
        vector<char> red, blue;
        for(int i = 0; i < n; i++){
            if(tmp.test(i)) {
                red.push_back(s.at(n+i));
            }
        }
        for(int i = n-1; i >= 0; i--){
            if(!tmp.test(i)) {
                blue.push_back(s.at(n+i));
            }
        }
        mp[{red, blue}]++;
    }


    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        /* bit で表される集合の処理を書く */
        bitset<18> tmp(bit);
        vector<char> red, blue;
        /* bit で表される集合の処理を書く */
        for(int i = 0; i < n; i++){
            if(tmp.test(i)) {
                red.push_back(s.at(i));
            }
        }
        for(int i = n-1; i >= 0; i--){
            if(!tmp.test(i)){
                blue.push_back(s.at(i));
            }
        }
        if(mp.count({blue, red}) > 0) {
            ans+= mp[{blue, red}];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 44600
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)


























int main(){
    ll k;
    cin >> k;
    ll a = 0;
    REP(i, 10000000){
        a *= 10;
        a += 7;
        a %= k;
        if(a == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#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

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

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() {
  string s;
  cin >> s;
  int count = 0;
  if (s[1] == s[2] && s[1] == s[3]) {
    Yes;
  } else if (s[0] == s[1] && s[0] == s[2]) {
    Yes;
  } else {
    No;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    string a1="";
    string b1="";
    for(int i=0;i<n;i++){
        a1+= to_string(a[i]);
    }
    for(int i=0;i<n;i++){
        b1+=to_string(b[i]);
    }
    string aa=a1;
    string bb=b1;
    sort(aa.begin(),aa.end());
    sort(bb.begin(),bb.end());
    int rank1=1,rank2=1;
    do{
        if(a1==aa) {break;}
       rank1++; 
    }while(next_permutation(aa.begin(),aa.end()));
    
       do{
        if(b1==bb){ break;}
       rank2++; 
    }while(next_permutation(bb.begin(),bb.end()));
    
  
    if(rank1>=rank2){
        cout<<rank1-rank2;
    }
    else{
        cout<<rank2-rank1;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  int x,a,b;
  cin >> a >> b;
  x=(a+b)/2;
  if((a+b)%2!=0){
    cout << x+1 << endl;
  }
  else{
  cout << x <<endl;
  }
}


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

using ll = long long;
static const int MOD = 1e9 + 7;

// 組合せを素数で割った値を求める
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll s;
  cin >> s;
  
  COMinit();
  
  ll ans = 0;
  for (ll i = 1; i * 3 <= s; i++) {
    ll now = s - i * 3;
    ans += COM(i - 1 + now, now);
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 15576
////////////////////////////////////
///     Please Give Me AC!!!     ///
////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

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;
    cin>> N;

    int X = 0, Y = 0, Z = 0;
    vector<ll> a(N);
    rep(i, N){
        cin>> a[i];
        if(a[i] % 4 == 0) X++;
        else if(a[i] % 2 == 0) Y++;
        else Z++;
    }

    if(X >= Z){
        cout<< "Yes" << endl;
        return 0;
    }

    if(X >= Z - 1 && Y == 0){
        cout<< "Yes" << endl;
        return 0;
    }

    cout<< "No" << endl;
}

Measured memory_bytes: 3988
h, w = map(int, input().split())
s = [list(input().split()) for _ in range(h)]
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(h):
    for j in range(w):
        if s[i][j] == "snuke":
            print(a[j] + str(i+1))

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  n++;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

  vector<ll> b(a);
  reverse(ALL(b));
  for(int i = 1; i < n; ++i)
  {
    b[i] += b[i - 1];
  }
  reverse(ALL(b));

  ll next_branch = 1;  
  ll ans = 0;
  for(int i = 0; i < n; ++i)
  {
    b[i] = min(b[i], next_branch);
    next_branch = min((next_branch - a[i]) * 2, (1LL << 62));
    if (next_branch < 0) { ans = -1; break; }
    if (next_branch == 0 && i < n - 1) { ans = -1; break; }
    ans += b[i];
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  string s, t;cin>>s>>t;cout<<t<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxN 1<<20
#define BIG 1<<30
#define INF 1<<60
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define desLoop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
using namespace std;

typedef struct{int x,y;}point;

void Swap(ll*a,int x,int y){ll t=a[x];a[x]=a[y];a[y]=t;}
void Qsort(ll*n,int l,int r)
{
    if(l>=r)return;
    int i=l-1,j=r+1;ll m=n[(i+j)/2];
    while(1){while(n[++i]<m);while(n[--j]>m);
	if(i>=j)break;Swap(n,i,j);}
	Qsort(n,l,i-1);Qsort(n,j+1,r);
}

ll min4(ll a,ll b,ll c,ll d){return min(min(a,b),min(c,d));}
ll max4(ll a,ll b,ll c,ll d){return max(max(a,b),max(c,d));}



int main()
{
	int n, a, b;
	while ( cin >> n >> a >> b )
	{
		int easy = 0, normal = 0, hard = 0;
		int diff;
		Loop( i, 0, n-1)
		{
			cin >> diff;
			if ( diff <= a ) easy++ ;
			else if ( diff > a and diff <= b ) normal++ ;
			else if ( diff > b ) hard++ ;
		}
		
		printf("%d\n", min( easy, min( normal, hard)));
	}
	return 0;
}











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

int main() {
  int N, M;
  cin >> N >> M;
  int minval, maxval;
  cin >> minval >> maxval;
  for (int i=2; i<=M; i++) {
    int l, r;
    cin >> l >> r;

    if (minval < l) minval = l;
    if (maxval > r) maxval = r;
  }

  int ans = maxval - minval + 1;
  if (maxval - minval + 1 < 0) ans = 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int N,D,X;
  int choco = 0;
  cin >> N;
  int A[N];
  cin >> D >> X;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }
    for (size_t j = 0; j < N; j++) {
      for (size_t i = 0; i < 10000; i++) {
        if (1+i*A[j] > D) {
          break;
        } else {
          choco++;
        }
      }
    }
    cout << choco + X << endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdlib>
#include<list>
using namespace std;

int main(){
  int n;
  list<int> L;
  char str[15];
  cin >> n;
  for(int i=0,num;i<n;i++){
    cin >> str;
    if(str[0]=='i'){
      cin >> num;
      L.push_front(num);
    }
    else if(str[6]=='F'){
      L.pop_front();
    }
    else if(str[6]=='L'){
      L.pop_back();
    }
    else{
      cin >> num;
      for(list<int>::iterator it=L.begin();it!=L.end();it++){
	if(*it==num){
	  L.erase(it);
	  break;
	}
      }
    }
  }
  int i=0;
  for(list<int>::iterator it=L.begin();it!=L.end();it++){
    if(i++)cout << " ";
    cout << *it;
  }
  cout << "\n";
}


Measured memory_bytes: 34332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  int sum=0;
  for(int i=0;i<k;i++) sum+=a[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

typedef double real;
constexpr real EPS = 1e-8;

struct point {
	real x, y, z;
	explicit point(real x_ = 0, real y_ = 0, real z_ = 0):x(x_), y(y_), z(z_) {}

	point operator-(const point &p) const {
		return point(x - p.x, y - p.y, z - p.z);
	}
};

inline real dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

inline real norm(const point &p) {
	return p.x * p.x + p.y * p.y + p.z * p.z;
}

inline real abs(const point &p) {
	return sqrt(norm(p));
}

struct segment : array<point, 2> {
	segment(const point &a, const point &b) { at(0) = a; at(1) = b; }
};

struct sphere {
	point c;
	real r;
	sphere(const point &c_, real r_):c(c_), r(r_) {}
};

inline real dist2(const segment &s, const point &p) {
	const real a = norm(s[1] - s[0]);
	const real b = dot(s[1] - s[0], s[0] - p);
	const real c = norm(s[0] - p);
	const real t = -b / a;

	if(t < 0) return norm(s[0] - p);
	if(t > 1) return norm(s[1] - p);
	return a * t * t + 2 * b * t + c;
}

inline bool intersect(const sphere &sph, const segment &seg) {
	return dist2(seg, sph.c) < sph.r * sph.r + EPS;
}

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

	int n, q;
	cin >> n >> q;

	vector<long long> l(n);
	vector<sphere> obstacles;
	obstacles.reserve(n);

	for(int i = 0; i < n; ++i) {
		int x, y, z, r;
		cin >> x >> y >> z >> r >> l[i];
		obstacles.emplace_back(point(x, y, z), r);
	}

	while(q--) {
		int sx, sy, sz, dx, dy, dz;
		cin >> sx >> sy >> sz >> dx >> dy >> dz;

		segment bullet(point(sx, sy, sz), point(dx, dy, dz));

		long long ans = 0;
		for(int i = 0; i < n; ++i) {
			if(intersect(obstacles[i], bullet)) {
				ans += l[i];
			}
		}

		cout << ans << '\n';
	}

	return EXIT_SUCCESS;
}

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

int main(){
    int a, b, c, sum, ans=0;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &sum);
    for(int i=0; i<=a; i++)
        for(int j=0; j<=b; j++)
            for(int k=0; k<=c; k++)
                if(i*500 + j*100 + k*50 == sum)
                    ans++;

    printf("%d", ans);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int H ,W;
    int i, j;
    
    while(1){
        
    scanf("%d %d" ,&H ,&W);
    
    if(H == 0 && W == 0) break;
    
    for ( i = 0; i < H; i++ ){
        
    for ( j = 0; j < W; j++ ){
        
    printf("#");
                }
    printf("\n");
            }
    puts("");
        }
    return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, M;
int _E[707][707];
vector<int> E[707];
//---------------------------------------------------------------------------------------------------
int vis[707], col[707];
pair<int, int> dfs(int cu, int co = 0) {
    vis[cu] = 1;
    col[cu] = co;

    pair<int, int> res = { 0, 0 };

    if (co == 0) res.first++;
    else res.second++;

    fore(to, E[cu]) {
        if (vis[to]) {
            if (col[to] == co) return { -1, -1 };
        } else {
            auto p = dfs(to, 1 - co);
            if (p.first < 0) return { -1,-1 };
            res.first += p.first;
            res.second += p.second;
        }
    }

    return res;
}
//---------------------------------------------------------------------------------------------------
int dp[707][1007];
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        _E[a][b] = _E[b][a] = 1;
    }
    rep(i, 0, N) rep(j, 0, N) if (!_E[i][j] and i != j) E[i].push_back(j);

    vector<pair<int, int>> v;
    rep(i, 0, N) if (!vis[i]) {
        auto p = dfs(i);
        if (p.first < 0) {
            printf("-1\n");
            return;
        }
        v.push_back(p);
    }

    //rep(i, 0, N) printf("%d\n", col[i]);

    int n = v.size();
    dp[0][0] = 1;
    rep(i, 0, n) rep(cn, 0, 707) if(dp[i][cn]) {
        dp[i+1][cn + v[i].first] = 1;
        dp[i+1][cn + v[i].second] = 1;
    }

    int ans = inf;
    rep(cn, 0, 707) if(dp[n][cn]) {
        int a = cn * (cn - 1) / 2;
        int b = N - cn;
        int c = b * (b - 1) / 2;
        chmin(ans, a + c);
    }
    //if (ans == inf) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 5120
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(std::string C){
    // string alpha = "abcdefghijklmnopqrstuvwxyz";
    // print(alpha[C[0] - 'a' + 1]);
    printf("%c\n", C[0] + 1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from itertools import combinations as c
a,b=map(int, input().split())
a=[2*i for i in np.array(range(a))+1]
b=[i*2-1 for i in np.array(range(b))+1]
r=len(list(filter(lambda x:not x&1,np.sum(list(c(a+b, 2)),1)))) 
print(r)

Measured memory_bytes: 13832
#include<stdio.h>

int main()
{
int sum,i;
char x[1001];


for(;;){
        scanf("%s",x);
        if(x[0]=='0')break;

        sum=0;
        for(i=0;x[i]!='\0';i++)
                      sum+=x[i]-'0';
                      printf("%d\n",sum);
        }
 return 0;

}
 
  


Measured memory_bytes: 2044
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<utility>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define ll long long
#define mk make_pair
#define out freopen("out.txt", "w", stdout)
const int N = 2e5 + 10;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;

int f[10][10];
int ans[N];

int main()
{
	int ans = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		string s = to_string(i);
		int len = s.size();
		int x = s[0] - '0', y = s[len - 1] - '0';
		ans = ans + f[y][x] * 2;
		if (x == y)
			ans++;
		f[x][y]++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xmin=max(x)
ymin=min(y)
for i in range(X+1,Y+1):
    if xmin<i<=ymin:
        print("No War")
        quit()
print("War")


Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '-') {
        cout << a - b << endl;
    } else {
        cout << a + b << endl;
    }
    return 0;
}

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

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, m, d;
int main(){
    scanf("%lld%lld%lld", &n, &m, &d);
    double temp;
    if(d==0) temp=n;
    else temp=(n-d)*2;
    printf("%.10lf\n", (double)(m-1)/n*temp/n);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}
template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

struct edge{int to, dist;};
vector<edge> adj[100000];

signed main() {
  int n; cin >> n;
  rep(i,n-1) {
    int a,b,c; cin >> a >> b >> c; --a,--b;
    adj[a].push_back({b,c});
    adj[b].push_back({a,c});
  }
  int q,k; cin >> q >>  k; --k;

  vector<ll> d(n, -1);
  d[k] = 0;
  
  stack<int> st;
  st.push(k);
  while(st.size()) {
    int v = st.top(); st.pop();
    for(auto e : adj[v]) if(d[e.to]==-1) {
      d[e.to] = d[v] + e.dist;
      st.push(e.to);
    }
  }

  rep(i,q) {
    int x,y; cin >> x >> y; --x,--y;
    cout << d[x] + d[y] << endl;
  }
}


Measured memory_bytes: 10668
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		int i = 0;
		try {
			while ((buffer = reader.readLine())  != null) {
				Integer x = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer y = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
			if (x == 0 && y == 0) return;
			if (x < y) {
				System.out.println(x + " " + y);
			}
			else {
				System.out.println(y + " " + x);
			}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 27116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(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 PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll a;
    long double b;
    cin>>a>>b;
    ll f=a*b;
    cout<<f<<endl;
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
      		sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println((10*b+c) % 4 == 0 ? "YES" : "NO");
	}
}

Measured memory_bytes: 35572
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

int N;
stringstream ss;
vector<vi> C;

int main(void) {
	cin >> N;

	C.resize(10, vi(10, 0));
	for (int i = 0; i <= N; ++i) {
		ss.str("");
		ss.clear();
		ss << i;
		string str = ss.str();
		int sz = str.length();
		int l = (int)(str[0] - '0');
		int r = (int)(str[sz - 1] - '0');
		if (l != 0 && r != 0)
			++C[l][r];
	}

	ll ans = 0;
	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j)
			ans += (ll)C[i][j] * C[j][i];
	}

	cout << ans << '\n';
	return 0;
}


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

constexpr int MAX_N = 30;

int ans;
int n, m;
int cover[30];
int used;
vector<vector<int>> edges;

void dfs(int idx, int sum) {
	if(sum >= ans) return;
	if(used == (1 << n) - 1) {
		ans = sum;
	}
	if(idx == n) return;

	dfs(idx + 1, sum);
	const int tmp = used;
	used |= cover[idx];
	dfs(idx + 1, sum + 1);
	used = tmp;
}

int solve() {
	used = 0;
	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		if(edges[i].size() == 0) {
			used |= (1 << i);
			++cnt;
		}
		else if(!(used & (1 << i))) {
			for(int j = 0; j < static_cast<int>(edges[i].size()); ++j) {
				if(edges[edges[i][j]].size() == 1) {
					used |= cover[i];
					++cnt;
					break;
				}
			}
		}
	}

	ans = n - __builtin_popcount(used) + cnt;
	dfs(0, cnt);
	return ans;
}

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

	while(cin >> n >> m && n) {
		memset(cover, 0, sizeof(cover));
		for(int i = 0; i < n; ++i) {
			cover[i] = (1 << i);
		}

		edges.assign(n, vector<int>());
		for(int i = 0; i < m; ++i) {
			int a, b;
			cin >> a >> b;
			cover[a] |= (1 << b);
			cover[b] |= (1 << a);
			edges[a].emplace_back(b);
			edges[b].emplace_back(a);
		}

		cout << solve() << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int A, B;
  std::cin >> A >> B;
  std::vector<std::vector<char>> s(100, std::vector<char>(100, '.'));
  int w = 0;
  int h = 0;
  for (int i = 0; i < A - 1; ++i) {
    s[w][h] = '#';
    s[w + 1][h] = '#';
    s[w + 1][h + 1] = '#';
    s[w][h + 1] = '.';
    h += 2;
    if (h >= 100) {
      w += 2;
      h = 0;
    }
  }
  while (h < 100) {
    s[w][h] = '#';
    s[w + 1][h] = '#';
    ++h;
  }
  w += 2;
  h = 0;
  for (int i = 0; i < 100; ++i) { s[w][i] = '.'; }
  ++w;
  for (int i = 0; i < B - 1; ++i) {
    s[w][h] = '.';
    s[w + 1][h] = '.';
    s[w + 1][h + 1] = '.';
    s[w][h + 1] = '#';
    h += 2;
    if (h >= 100) {
      w += 2;
      h = 0;
    }
  }
  std::cout << 100 << " " << 100 << std::endl;
  for (const auto &i : s) {
    for (const auto &j : i) {
      std::cout << j;
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N, M;
    cin >> N >> M;
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;
    sort(ALL(A));

    ll ok = 0, ng = 1e10;
    ll cnt = 0;
    while(abs(ok - ng) > 1) {
        cnt = 0;
        ll mid = (ok + ng) / 2;
        for(ll e : A) cnt += distance(lower_bound(ALL(A), mid - e), A.end());
        (M <= cnt ? ok : ng) = mid;
    }

    ll ans = 0;
    cnt = 0;
    V<ll> sum(N + 1);
    for(ll i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
    for(ll e : A) {
        auto ite = lower_bound(ALL(A), ok - e);
        ll n = distance(ite, A.end());
        cnt += n;
        ans += e * n + sum[N] - sum[distance(A.begin(), ite)];
    }

    cout << ans - (cnt - M) * ok << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N,A,B;cin>>N>>A>>B;
    
	// 解法
	ll shou = N/(A+B);
	ll amari = N%(A+B);
	ll ans = shou * A + min(A, amari);

	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }
            int flag1 = 0, flag2 = 0;
            for (int i = 0; i < h; i++) {
                if (flag2 == 0) {
                    for (int j = 0; j < w; j++) {
                        if (flag1 == 0) {
                            System.out.printf("#");
                            flag1 = 1;
                        } else if (flag1 == 1) {
                            System.out.printf(".");
                            flag1 = 0;
                        }
                    }
                    System.out.println();
                    flag2 = 1;
                    flag1 = 1;
                    continue;
                } else if (flag2 == 1) {
                    for (int j = 0; j < w; j++) {
                        if (flag1 == 0) {
                            System.out.printf("#");
                            flag1 = 1;
                        } else if (flag1 == 1) {
                            System.out.printf(".");
                            flag1 = 0;
                        }
                    }
                    System.out.println();
                    flag2 = 0;
                    flag1 = 0;
                    continue;
                }
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 59144
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll delta1, delta2;
    delta1 = t1*(a1-b1);
    delta2 = t2*(a2-b2);
    ll delta = delta1 + delta2;
    ll ans;

    if (delta == 0 || delta1 == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    // if no reverse in position can be achieved
    if ((delta1 > 0 && delta > 0) || (delta1 < 0 && delta < 0)) {
        cout << 0 << endl;
        return 0;
    }
    ans = 2 * (abs(delta1) / abs(delta)) + 1;
    if (delta1 % delta == 0) ans -= 1;
    cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n,k=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  if k==arr[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  g=gcd(arr[0],arr[1])
  flag=False
  for i in range(n):
    g=gcd(g,arr[i])
  arr=sorted(arr,reverse=True)
  for i in range(n):
    if k>arr[i]:
      break
    if (arr[i]-k)%g==0:
      flag=True
  if flag:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14100
//created by missever

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

char s[111];
pair<int,int>p[111];
bool vis[111];

int main()
{
    int n,i,j,k;
    int len,t,x,y,w = 0;
    scanf("%d",&n);
    for(i = 0; i < n; i++)
    {
        scanf("%s",s);
        len = strlen(s);
        x = t = 0;
        for(j = 0; j < len; j++)
        {
            if(s[j] == '(') t++;
            else if(t)
            {
                t--;
                x++;
            }
        }
        p[i].second = t;
        p[i].first = len - 2 * x - t;
    }
    y = 0;
    for(i = 0; i < n; i++)
    {
        if(p[i].second == 0 && p[i].first > 0)
        {
            y += p[i].first;
            vis[i] = 1;
            w++;
        }
    }
    x = 0;
    while(w < n)
    {
        t = -1000;
        for(j = 0; j < n; j++)
        {
            if(!vis[j])
            {
                if((x - p[j].first >= 0) && (p[j].second - p[j].first > t))
                {
                    k = j;
                    t = p[j].second - p[j].first;
                }
            }
        }
        if(t != -1000)
        {
            vis[k] = 1;
            x += t;
        }
        else
        {
            printf("No\n");
            return 0;
        }
        w++;
        //cout<<x<<endl;
    }
    if(x != y) printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;
  map<int,ll> mp;
  for(int x=1;x*x<=N;x++){
    for(int y=1;y*y<=N;y++){
      for(int z=1;z*z<=N;z++){
        mp[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for(int n=1;n<=N;n++){
    cout << mp[n] << '\n';
  }
  return 0;
}


Measured memory_bytes: 6008
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main()
{
	int n, m;
	string s;
	unordered_map<string,int> a,b;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		if (a.find(s) == a.end())
		{
			a[s] = 1;
		}
		else
		{
			a[s]++;
		}
	}
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> s;
		if (b.find(s) == b.end())
		{
			b[s] = 1;
		}
		else
		{
			b[s]++;
		}
	}
	int v = 0;
	for (auto x : a)
	{
		int tmp;
		if (b.find(x.first) != b.end())
		{
			tmp=x.second - b[x.first];
		}
		else
		{
			tmp = x.second;
		}
		if (v < tmp)
		{
			v = tmp;
		}
	}
	cout << v << 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, k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n-k) {
        if (a[i] < a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) L(N);
    READVEC(L);
    sort(ALL(L));

    int ret = 0;
    FOR(i, 0, N)
        for (int j = i + 1;j < N - 1; j++) {
            int s = L[i] + L[j];
            // k > j + 1, L[k] < s
            int pos = lower_bound(ALL(L), s) - BEGIN(L);
            // j + 1 < k < pos
            if (pos >= j + 2)
                ret += pos - j - 1;
        }

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N, K, R, S, P, c = 0;
	string T, Z;
	cin >> N >> K >> R >> S >> P >> T;
	rep(i, 0, T.size()) {
		if (T[i] == 'r') {
			Z.push_back('p');
		}
		if (T[i] == 'p') {
			Z.push_back('s');
		}
		if (T[i] == 's') {
			Z.push_back('r');
		}
		if (i - K >= 0 && Z[i] == Z[i - K]) {
			Z[i] = 0;
		}
	}
	rep(i, 0, T.size()) {
		if (Z[i] == 'r') {
			c += R;
		}
		if (Z[i] == 'p') {
			c += P;
		}
		if (Z[i] == 's') {
			c += S;
		}
	}
	printf("%d\n", c);
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n, m;
const int maxn = 1e5 + 5;

bool vis[maxn];
int cnt[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        cnt[i] = 1;
        vis[i] = 0;
    }
    vis[1] = 1;
    for(int i = 1;i <= m;i++){
        int u, v;
        cin >> u >> v;
        if(vis[u]){
            vis[v] = 1;
        }
        cnt[u]--;
        cnt[v]++;
        if(cnt[u] == 0){
            vis[u] = 0;
        }
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(vis[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4008
from collections import deque
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def isprime(n):
  for i in range(2,int(n**0.5)+1):
    if n%i == 0:
      return False
  return True


def solve():
  n,k = (int(i) for i in input().split())
  h =  list(int(i) for i in input().split())
  ct = 0
  for i in h:
    if i >= k:
      ct += 1
  print(ct)
solve()


Measured memory_bytes: 12268
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	ll l;
	cin >> l;
	cout << fixed << setprecision(10) << l * l * l / (long double) 27 << '\n';
}


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() {
    int n;
    cin >> n;
    vector<ll> a;
    a.push_back(0);  // ダミーデータ
    ll in;
    rep(i, n) {
        cin >> in;
        a.push_back(in);
    }

	sort(a.begin(), a.end());

    ll ans = 0;
    for (int k = 1;k <= n - 1;k++) {
        ans += a[n - k / 2];
    }

    cout << ans << endl;

    return(0);
}


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

int main(){
    ll n;
    cin >> n;

    vector<ll> a(n, 0);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }

    stack<ll> ans;
    ll num = 1;
    for(ll i = 0; i < n; i++){
        if(a[i] == num){
            ans.push(a[i]);
            num++;
        }
    }


    
    if(ans.size() == 0){
        cout << -1 << endl;
    }else{
        cout << n - ans.size() << endl;
    }

    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll n;
    cin>>n;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        a[i]=a[i]*2;
    }
    ll x=0,f=0;
    for (int i = 0; i < n; ++i)
    {
        if(f==0)
        {
            x+=a[i];
            f=1;
        }
        else
        {
            x-=a[i];
            f=0;
        }
    }
    ll b[n];
    b[0]=x/2;
    for (int i = 1; i < n; ++i)
    {
        b[i]=a[i-1]-b[i-1];
    }
    for (int i = 0; i < n; ++i)
    {
        cout<<b[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int main(){
    int n;
    cin>>n;
    int a[n];
    ll sum=0;
    for(int i=0;i<n;i++)    cin>>a[i],sum+=a[i];
    ll ans=0;
    for(int i=0;i<n;i++){
        sum-=a[i];
        ans+=((a[i]%mod)*(sum%mod))%mod;
    }
    ans%=mod;
    cout<<ans;
}

Measured memory_bytes: 4400
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&a[i])
	}

	fmt.Println(logic(a))
}

func logic(nums []int) int {
	result := 1

	for _, n := range nums {
		result = lcm(result, n)
	}

	return result
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
#include <climits>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    int X, Y, Z; cin >> X >> Y >> Z;
    cout << (X - Z) / (Y + Z) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long N;
string s;
int main(){
	cin>>N;
	cin>>s;
	long long r=0,g=0,b=0;
	for(int i=0; i<N; i++){
		if(s[i]=='R'){
			r++;
		}else if(s[i]=='G'){
			g++;
		}else{
			b++;
		}
	}
	long long total=r*g*b;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			long long X=2*j-i;
			if(X<N){
				if(s[i]!=s[j]&&s[j]!=s[X]&&s[i]!=s[X]){
					total--;
				}
			}
		}
	}
	cout<<total<<'\n';
}

Measured memory_bytes: 3628