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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e2 + 10;
const int maxK = 1e5 + 10;

int n, k;
int a[maxN];

bool dp[maxK];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for1(i, n)
    {
        cin >> a[i];
    }
    for0(i, k)
    {
        for1(j, n)
        {
            if (i + a[j] <= k)
            {
                dp[i + a[j]] |= !dp[i];
            }
        }
    }
    if (dp[k])
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
    return 0;
}


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

using namespace std;

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

    for(int i = 0;i < s.size();i++){
        if(s[i] == '1'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '1';
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

using namespace std;

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

  int l, r;
  cin >> l >> r;

  if (r - l + 1 >= 2019) {
    cout << 0 << endl;
  } else {
    ll ans = 2019;
    for (ll li = l; li <= r; li++) {
      for (ll ri = li + 1; ri <= r; ri++) {
        ans = min(li * ri % 2019, ans);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace sample1
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			var mountainHight = new List<int>();
			for (int i = 0; i < 10; i++)
			{
				mountainHight.Add(int.Parse(Console.ReadLine()));
			}
			mountainHight.Sort((a, b) => b - a);
			for (int i = 0; i < 3; i++)
			{
				Console.WriteLine(mountainHight[i]);
			}
		}
	}
}



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


int main() {
 string s,a;
	cin >> s;
	if (s.find("C") != std::string::npos 
			&& s.rfind("F") != std::string::npos  
			&& s.find("C") < s.rfind("F")) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

long long solve(const std::vector<std::pair<long long, long long>>& v, std::vector<bool>& m, long long p, long long q)
{
  long long ans = 0;
  for (int i = 0; i < v.size(); ++i)
  {
    if (m[i])
      continue;
    m[i] = true;
    long long x = v[i].first;
    long long y = v[i].second;
    while (true)
    {
      auto it = std::find(v.begin(), v.end(), std::make_pair(x + p, y + q));
      if (it == v.end())
        break;
      m[it - v.begin()] = true;
      x = it->first;
      y = it->second;
    }
    x = v[i].first;
    y = v[i].second;
    while (true)
    {
      auto it = std::find(v.begin(), v.end(), std::make_pair(x - p, y - q));
      if (it == v.end())
        break;
      m[it - v.begin()] = true;
      x = it->first;
      y = it->second;
    }
    ++ans;
  }
  return ans;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<std::pair<long long, long long>> v(N);
  for (auto& p: v)
    std::cin >> p.first >> p.second;
  if (N == 1)
  {
    std::cout << 1 << std::endl;
    return 0;
  }
  long long ans = INT_MAX;
  std::vector<bool> m(N, false);
  for (int i = 0; i < N; ++i)
  {
    for (int j = i + 1; j < N; ++j)
    {
      long long p = v[i].first - v[j].first;
      long long q = v[i].second - v[j].second;
      if (p == 0 && q == 0)
        continue;
      std::fill(m.begin(), m.end(), false);
      ans = std::min(ans, solve(v, m, p, q));
//      std::fill(m.begin(), m.end(), false);
//      ans = std::min(ans, solve(v, m, -p, -q));
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>

// https://umbccd.io/challenges


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

using namespace std;


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

	while(n > 0) {
		if (n % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;



 	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


int a[100];
int lcm(int a, int b){
  return a/__gcd(a, b)*b;
}
signed main(){
  int n, ans = 0;
  cin >> n;
  rep(i,n)cin >> a[i];

  rep(bit,1<<n){
    if(bit == 0)continue;
    vector<int> vec;
    int x = 1;
    bool flag = false;
    rep(j,n){
      if((bit>>j) & 1)x = lcm(x, a[j]);
      else vec.push_back(a[j]);
    }
    rep(j,vec.size())if(x%vec[j] == 0)flag = true;
    if(flag == false)ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3144
from decimal import Decimal
from decimal import *
a, b, c = map(str, input().split())

#getcontext().prec = 1000

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)

if a**Decimal("0.5")  + b**Decimal("0.5") < c**Decimal("0.5"):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5076
n = int(input())
x = [float(i) for i in input().split()]
y = [float(i) for i in input().split()]
num = 1000
print(sum([abs(a - b) for a, b in zip(x, y)]))
print((sum([abs(a - b) ** 2 for a, b in zip(x, y)])) ** (1 / 2))
print((sum([abs(a - b) ** 3 for a, b in zip(x, y)])) ** (1 / 3))
print(max([abs(a - b) for a, b in zip(x, y)]))


Measured memory_bytes: 5672
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	stack<int> stk;
	int a;
	
	while(cin>>a){
		if(a){
			stk.push(a);
		}else{
			cout<<stk.top()<<endl;
			stk.pop();
		}
	}

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(5);
	solve();

	return 0;
}

 

Measured memory_bytes: 1200
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int par[100500];

void init(int x){
  rep(i,x) par[i]=i;
}

int root(int x){
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool 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) return;
  par[x]=y;
}
 
int main(void){
  int N,M,ans=0;
  cin >> N >> M;
  init(N);
  rep(i,M){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    unite(X-1,Y-1);
  }
  rep(i,N) if(par[i]==i) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


const int max_comb=220000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

int main(int argc, char* argv[])
{
    int h,w,n;
    scanf("%d%d%d", &h, &w, &n);

    vector<pair<int,int> > z;     // 壁のマスと、ゴールのマスの (r,c) を登録して、ペアの形でソートする
    int i, j;
    for(i=0; i<n; i++) {
        int r,c;
        scanf("%d%d", &r, &c);
        z.push_back(make_pair(r,c));
    }
    z.push_back(make_pair(h,w));
    sort(z.begin(), z.end());

    pre_comb();

    vector<ll> dp(n+1);      // dp[i]: (1,1)から(z[i].first, z[i].second) までの経路の数。ただし途中で壁を経由するものは除外。
    for(i=0; i<=n; i++) {
        int r=z[i].first, c=z[i].second;
        dp[i] = comb((r-1)+(c-1), r-1);
        for(j=0; j<i; j++) {
            int r0=z[j].first, c0=z[j].second;
            if(r0<=r && c0<=c) {
                dp[i] = (dp[i] - (dp[j]*comb((r-r0)+(c-c0),r-r0)%MOD) + MOD)%MOD;
            }
        }
    }
    printf("%lld\n", dp[n]);

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    pii c1, c2;
    cin >> c1.ff >> c1.ss >> c2.ff >> c2.ss;

    cout << c2.ff + (c1.ss - c2.ss) << " " << c2.ss  + (c2.ff - c1.ff) << " ";
    cout << c1.ff + (c1.ss - c2.ss) << " " << c1.ss + (c2.ff - c1.ff) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,d,x;
  cin >> r;
  cin >> d;
  cin >> x;
  for(int i=0; i<10; i++){
    x = ((r*x) - d);
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = list(input())
sl = list(map(int,s))

l1 = []
for i in range(len(sl)):
  l1.append(i%2)

d1 = 0
for i in range(len(sl)):
  if sl[i] != l1[i]:
    d1 += 1

print(min(d1,len(sl)-d1))

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

using namespace std;

int main()
{
  int A[2002];
  int N, K, Q;
  
  scanf("%d %d %d", &N, &K, &Q);
  
  A[0] = A[N + 1] = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d", A + i);
  }
  
  int ans = 1000000000;
  for (int i = 1; i <= N; i++) {
    priority_queue<int, vector<int>, greater<int>> pq;
    priority_queue<int, vector<int>, greater<int>> pq2;
    for (int j = 0; j <= N + 1; j++) {
      if (A[j] < A[i]) {
        while (pq.size() >= K) {
          pq2.push(pq.top());
          pq.pop();
        }
        pq = decltype(pq)();
      }
      else {
        pq.push(A[j]);
      }
    }
    if (pq2.size() >= Q) {
      for (int j = 0; j < Q - 1; j++) {
        pq2.pop();
      }
      ans = min(ans, pq2.top() - A[i]);
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int h, w, c, f[8][8], p[8][8], dy[] = {-1,0,1,0}, dx[] = {0,-1,0,1};

void count(int y, int x){
  //  fprintf(stderr, "%d %d\n", y, x);
  f[y][x] = 1;
  rep(d, 4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny < 0 || nx < 0 || ny >= h || nx >= w || p[ny][nx] != c || f[ny][nx]) continue;
    count(ny, nx);
  }
}

void change(int y, int x, int to, int from){
  //  printf("%d %d %d %d\n", y, x, to, from);
  f[y][x] = 1;
  p[y][x] = to;
  rep(d, 4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny < 0 || nx < 0 || ny >= h || nx >= w || p[ny][nx] != from || f[ny][nx]) continue;
    change(ny, nx, to, from);
  }
}

int dfs(int n){
  //  fprintf(stderr, "%d\n", n);
  int res = 0;
  if(n == 4){
    //    rep(i, 8) printf("%d", p[i][0]); puts("");
    //    fprintf(stderr, "change\n");
    memset(f, 0, sizeof(f));
    change(0, 0, c, p[0][0]);
    memset(f, 0, sizeof(f));
    //    fprintf(stderr, "count\n");
    count(0, 0);
    rep(y, h) rep(x, w) if(f[y][x]) res++;
    //    fprintf(stderr, "%d\n", res);
    return res;
  }
  int tmp[8][8];
  rep(i, 6){
    //    fprintf(stderr, "i %d\n", i);
    rep(y, h) rep(x, w) tmp[y][x] = p[y][x];

    memset(f, 0, sizeof(f));
    change(0, 0, i, p[0][0]);
    //    fprintf(stderr, "change\n");
    res = max(res, dfs(n+1));
    //    fprintf(stderr, "%d\n", res);
    rep(y, h) rep(x, w) p[y][x] = tmp[y][x];
  }
  //  printf("%d\n", res);
  return res;
}

int main(){
  while(scanf("%d%d%d", &h, &w, &c) && h+w+c){
    c--;
    rep(i, h) rep(j, w){
      scanf("%d", &p[i][j]);
      p[i][j]--;
    }
    printf("%d\n", dfs(0));
  }
  return 0;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
typedef pair<char, long long> P;
int main() {
	int N; cin >> N;
	N %= 10;
	if (N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
	else if (N == 3) cout << "bon" << endl;
	else cout << "hon" << endl;
}

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

int div(int n);

int main(){
	int num;
	cin >> num;
	cout << num << ":";

	while(num!=1){
		cout << " " << div(num);
		num = num / div(num);
	}
	cout << endl;
}

int div(int n){
	if(n%2 == 0) return 2;
	int s=sqrt(n);
	for(int i=3; i<=s; i+=2){
		if(n%i == 0) return i;
	}

	return n;
}

Measured memory_bytes: 3096
import math
primes = [True]*(10**5+1)
primes[0],primes[1] = False,False
cumsum = [0]*(10**5+1)

for i in range(2, int(math.sqrt(10**5)+1)):
  if primes[i]:
    j = 2
    while i*j <= 10**5:
      primes[i*j] = False
      j += 1

for i in range(2, 10**5+1):
  if primes[i] and primes[(i+1)//2]:
    cumsum[i] = cumsum[i-1]+1
  else:
    cumsum[i] = cumsum[i-1]

Q = int(input())
for _ in range(Q):
  l,r = map(int,input().split())
  print(cumsum[r]-cumsum[l-1])

Measured memory_bytes: 51416
# ITP1_1_D
# Watch
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D
# encode : utf-8
S = int(input())
h = S // 3600
m = (S % 3600) // 60
s = S % 60
print("{}:{}:{}".format(h,m,s))


Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int a,b,c;
    cin >> a >> b >> c ;
    if(a+b>= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,x,m;cin>>n>>x>>m;
    map<ll,ll> mp;
    ll tmp=1;
    vector<ll> t;t.push_back(0);
    ll buf3=0,buf4=0;
    while(true){
        if(mp[x]!=0){
            buf4=mp[x]-1;
            buf3=tmp-mp[x];
            break;
        }
        t.push_back(x);
        mp[x]=tmp;
        x=(x*x)%m;
        tmp++;
    }
    
    ll buf=(n-buf4)/buf3,buf2=(n-buf4)%buf3;
    rep(i,tmp-1)t[i+1]+=t[i];
    ll res=t[buf4];
    if(x==0){
        cout<<t[tmp-1]<<endl;
        return 0;
    }
    res+=buf*(t[tmp-1]-t[buf4]);
    if(buf2!=0)res+=(t[buf2+buf4]-t[buf4]);
    cout<<res<<endl;
}

Measured memory_bytes: 6740
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long nam = sc.nextLong();
		long ans = Long.MAX_VALUE;
		
		long j = 0;
		for(long i = 1; i*i <= nam; i++){
		    if(nam % i != 0){continue;}
		    j = nam/i;
		    ans = Math.min(ans,i + j -2);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N,M;
    cin>>N>>M;
    int H[100001];

    for(int i=1;i<=N;i++){
        cin>>H[i];
    }

    vector<int> v[100001];
    for(int i=0;i<M;i++){
        int A,B;
        cin>>A>>B;
        v[A].push_back(B);
        v[B].push_back(A);
    }

    int ans=0;
    for(int i=1;i<=N;i++){
        bool f=true;
        for(int j=0;j<v[i].size();j++){
            if(H[i]<=H[v[i][j]]) f=false;
        }
        if(f) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9820
#include<iostream>
#include<deque>

using namespace std;
/*
deque<int> card(201);
deque<int> sub1(201);
deque<int> sub2(201);
*/

int card[201];
int sub1[201];
int sub2[201];
int n, m;

void cut(int k);
void suffle(void);

int main()
{
	cin >> n;
	cin >> m;
	
	deque<int> step(m);
	
	for(int i = 0; i < m; i++){
		cin >> step[i];
	}
	
	for(int i = 0; i < 2*n; i++){		//ツカツーツドツ渉可甘コツ可サ
		card[i] = i+1;
	}
	
	for(int i = 0; i < m; i++){
		if(step[i] == 0){
			suffle();
		}
		else{
			cut(step[i]);
		}
	}
	
	for(int i = 0; i < 2*n; i++){
		cout << card[i] << endl;
	}
}

void cut(int k){
	int i;
	int temp;
	
	for(i = 0; i < k; i++){
		sub1[i] = card[i];
	}
	temp = i;
	
	for(int j = 0;j < 2*n; j++){
		sub2[j] = card[temp];
		temp++;
	}
	
	for(i = 0;i < 2*n-k; i++){
		card[i] = sub2[i];
	}
	for(int j = 0; i < 2*n; i++){
		card[i] = sub1[j];
		j++;
	}
}

void suffle(void){
	int i, j = 0;
	
	for(i = 0; i < n; i++){
		sub1[i] = card[i];
	}
	
	for(;i < 2*n; i++){
		sub2[j] = card[i];
		j++;
	}
	j = 0;
	for(int i = 0; i < 2*n; i+=2){
		card[i] = sub1[j];
		j++;
	}
	j = 0;
	for(int i = 1; i < 2*n; i+=2){
		card[i] = sub2[j];
		j++;
	}
}

Measured memory_bytes: 0
N = int(input())
vA = list(map(int, input().split()))

mO = [0,] * 100010
mE = [0,] * 100010

for a in vA[0::2]:
  mO[a] += 1
for a in vA[1::2]:
  mE[a] += 1

modeO = mO.index(max(mO))
modeE = mE.index(max(mE))
if modeO == modeE:
  O1 = mO.pop(modeO)
  E1 = mE.pop(modeE)
  print(min(N - O1 - max(mE), N - max(mO) - E1))
else:
  print(N - max(mO) - max(mE))


Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	int a[n+1][d+1];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++){
			cin>>a[i][j];
		}
	}
	int s=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			int ans=0;
			for(int k=1;k<=d;k++){
				ans+=pow(fabs(a[i][k]-a[j][k]),2);
			}
			if(int(sqrt(ans))==sqrt(ans)){
				s++;
			}
		}
	}
	cout<<(s-n)/2<<endl;
	return 0;
	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  
  if(A < B) {
    int tmp = A;
    A = B;
    B = tmp;
  }
  
  ans += A;
  A--;
  
   if(A < B) {
    int tmp = A;
    A = B;
    B = tmp;
  }
  
   ans += A;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  vector<ll>v(n+2);
  v[0] = 0;
  for(int i=0; i<n; i++) {cin >> v[i+1];}
  v[n+1] = 0;
  ll sum=0;
  for(int i=1; i<n+2; i++){
    sum += abs(v[i]-v[i-1]);
  }
  for(int i=1; i<n+1; i++){
    cout << sum - abs(v[i]-v[i-1]) - abs(v[i+1]-v[i]) + abs(v[i+1]-v[i-1]) << endl;
  }
return 0;
}




Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	ll k;
	cin >> k;

	ll kk = k / 50;
	ll j = k % 50;

	V<ll> a(50, 49 + kk);

	rep(i, j)a[i] += 51 - j;
	rep(i, 50 - j)a[j + i] -= j;

	cout << 50 << endl;
	rep(i, 50) {
		cout << a[i];
		if (i < 49)cout << " ";
		else cout << endl;
	}

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <assert.h>
using namespace std;
#define LL long long
#define pii pair < int , int >
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	string s;
	cin >> s;
	if ( n >= 3200 ) cout << s << endl;
	else cout << "red" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <atcoder/all>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
using namespace atcoder;
using mint = modint998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const int MODD = 998244353;
const ll LLINF = 1e18;


int main(){
	int n, m;
	cin >> n >> m;
	dsu d(n);
	for (int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		d.merge(a-1, b-1);
	}
	cout << d.groups().size() - 1 << endl;
	return 0;
}


Measured memory_bytes: 9000
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
    return 0;
}


Measured memory_bytes: 256
// Problem : C - Welcome to AtCoder
// Contest : AtCoder Beginner Contest 151
// URL : https://atcoder.jp/contests/abc151/tasks/abc151_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
//    #ifdef _soumik
//        freopen("input.txt", "r", stdin);
//    #endif
    int n,s,ac=0,pt=0;
    cin>>n>>s;
    bool check[n+1]={};
    vi pn(n+1);
    for(int i=0;i<s;i++)
    {
        int no;
        string v;
        cin>>no>>v;
        if(check[no]==false)
        {
            if(v[0]=='W')
                pn[no]++;
            else
            {
                ac++;
                pt+=pn[no];
                check[no]=true;
            }
        }
    }
    cout<<ac<< " "<<pt<<endl;
    return 0;
}



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

int main() {
  int x,a,b; cin >>x >>a >>b;
  if (abs(a-x)<abs(b-x)) {
    cout <<'A' <<endl;
  } else {
    cout <<'B' <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> L(N);
  for (auto& v : L)cin >> v;
  sort(begin(L), end(L));
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      auto itr = lower_bound(begin(L), begin(L) + i, L[i] + L[j]);
      if (itr == end(L))continue;
      auto itr2 = upper_bound(begin(L), begin(L) + i, L[j] - L[i]);
      if (itr2 == end(L))continue;
      ans += distance(itr2, itr);
    }
  }
  cout << ans << endl;
}


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

using namespace std;
map< long long, int > mp;
int main()
{
    int n, m;
    cin >> n >> m;
    for( int i = 1; i <= n; ++ i )
    {
        int num;
        cin >> num;
        for( int j = 1; j <= num; ++ j )
        {
            int t;
            cin >> t;
            mp[t] ++;
        }
    }
    int ans = 0;
    for( auto i : mp )
        if( i.second == n ) ans ++;
    cout << ans << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>>a(h+2,vector<char>(w+2,'#'));
	for (int i = 1; i < h+1; i++) {
		for(int j=1;j<w+1;j++)
		cin >> a[i][j];
	}

	for (int i = 0; i < h+2; i++) {
		for (int j = 0; j < w+2; j++) {
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 1e6 + 7;
bool ar[N] = {};

int main()
{
	fastio;

	int k;
	int add = 7;
	cin >> k;

	if (k % 7 == 0)
		k /= 7, add /= 7;

	int rem = 0;
	int res = 0;
	do
	{
		res++;
		rem = (rem * 10 + add) % k;

		if (ar[rem])
		{
			res = -1;
			break;
		}

		ar[rem] = true;
	} while (rem != 0);

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


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <string>

const int MAXN = 1e6 + 1;
int f[MAXN][2];

int solve(const std::string& s) {
  int n = s.length();
  f[0][0] = s[n - 1] - '0';
  f[0][1] = 11 - (s[n - 1] - '0');
  for (int i = 1; i < n; ++i) {
    int cur = s[n - 1 - i] - '0';
    f[i][0] = std::min(f[i - 1][0], f[i - 1][1]) + cur;
    f[i][1] = std::min(f[i - 1][0] + 11 - cur, f[i - 1][1] + 9 - cur);
  }
  return std::min(f[n - 1][0], f[n - 1][1]);
}

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


Measured memory_bytes: 9220
#include <iostream>

int main(void)
{
	using namespace std;

	int n,x;
	while(1){
		cin >> n;
		cin >> x;
	
		if(n == 0 && x == 0)	break;
		
		int count_comb = 0;
		for(int large1 = 3; large1 <= n; large1++){
			int temp = x - large1;
			for(int large2 = 2; large2 < temp; large2++){
				if((temp - large2 < large2) &&(large2 < large1)) count_comb++;
			} 
		}
		cout << count_comb << endl;
	}	

	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    vector<ll> a;
    ll mini = LONG_LONG_MAX;
    cin >> N;
    a.resize(N);
    rep(i, N) cin >> a[i];
    repi2(i, -100, 100) {
        ll cost = 0;
        rep(j, N) {
            ll temp = a[j] - i;
            cost += temp * temp;
        }
        mini = min(mini, cost);
    }
    cout << mini << endl;
    return 0;
}


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

int main(){
    unsigned long long X, Y, res, ans;
    cin >> X >> Y;
    ans = 0;
    res = X;
    while(res <= Y){
        res *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
using namespace std;
int main(){
    for(;;){
        int n;
        std::cin >> n;
        if(n==0)exit(0);
        std::vector<double> a(n);
        rep(i,n)std::cin >> a[i];
        double av=sum(all(a),0.0)/n;
        double v=0;
        rep(i,n){
            v+=(a[i]-av)*(a[i]-av);
        }
        v/=n;
        std::cout <<keta(10)<< sqrt(v) << std::endl;
    }
}


Measured memory_bytes: 3300
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    int n=s.size();
    s ='0'+s;
    
    bool exist = false;
    if(s[1]=='0'||s[n]=='1') exist=true;
    
    for(int i=1;i<n;i++){
        if(s[i]!=s[n-i]){
            exist=true;
            break;
        }
    }
    
    if(exist){
        cout1(-1);
        return 0;
    }
    
    s[n] = '1';
    queue<int> ones;
    rep1(i,n) if(s[i]=='1') ones.push(i);
    
    rep1(i,n-1){
        if(i==ones.front()) ones.pop();
        cout2(i,ones.front());
    }
}

Measured memory_bytes: 1900
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    long H;
    cin >> H;
    long count = 0;
    long bai = 1;
    queue<int> que;
    while(true){
        if(H == 1){
            count += bai;
            break;
        }else{
            H /= 2;
            count += bai;
            bai *= 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
if b-a==e-d and b-a==h-g and c-b==f-e and c-b==i-h:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    // init();
    run();
    return 0;
}

void run(){
    int a,b,t;
    cin>>a>>b>>t;
    cout<<t/a*b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 998244353
using namespace std;


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

    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(v < w){
        cout << "NO";
    }else{
        ll d = abs(a - b);
        v = v - w;
        ld tt = (ld)d / v;
        if(tt <= t){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
const int N = 1e6 + 2;
int primes[N];
map<int,int> mp;
void sieve(){
    FOR(i,0,N)
        primes[i] = i;
    FOR(i,2,N)
        if(primes[i] == i)
            for(int j = i+i; j < N; j += i)
                primes[j] = min(primes[j],primes[i]);
}
void pf(int n){
    while(n != 1)
    {
        int d = primes[n];
        mp[d]++;
        while(n % d == 0)
            n /= d;
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        sieve();
        int n; cin >> n;
        vector<int> a(n);
        FOR(i,0,n) cin >> a[i];
        int gcd = 0;
        for(auto x:a)
            gcd = __gcd(x,gcd);
        for(auto x:a)
            pf(x);
        bool ok = 1;
        for(auto x:mp)
            if(x.S >= 2)
            {
                ok = 0; break;
            }
        if(ok)
            cout << "pairwise coprime";
        else if(gcd == 1) cout << "setwise coprime";
        else cout << "not coprime";
    }    
}

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

int main()
{
	//freopen("6.in","r",stdin);
	//freopen("6.ans","w",stdout);
	int k;
	cin>>k;
	string s;
	cin>>s;
	int w=0,r=0;
	for(int i=0;i<k;i++){
		if(s[i]=='W') w++;
		else r++;
	}
	int ans = 0;
	for(int i=0;i<r;i++) if(s[i]=='W') ans++;
	cout<<ans<<"\n";
	
	return 0;
}


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

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);

    rep(i, n)
        cin >> a.at(i);
    
    sort(a.begin(), a.end());

    int ans = 0;
    int i;
    for (i = 0; i < n; i++) {
        if (x - a.at(i) >= 0) {
            x -= a.at(i);
            ans++;
        }
        else {
            break;
        }
    }
    if (x != 0 && (i == n) && !(ans == 0))
        ans--;
    cout << ans << endl;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, M;
    scan(N, M);
    if (M <= N * 2)
    {
        writeln(M / 2);
        return;
    }
    writeln(N + ((M - N * 2) / 4));
}


Measured memory_bytes: 256
import sys
from collections import deque
n,m=map(int,input().split())
s=input()
if n<=m:
    print(n)
    sys.exit()
lst=[0]*(n+1)
for i in range(1,m+1):
    if s[i]=="0":
        lst[i]=i
left=1
right=m+1
k=0
while left<n:
    if s[left]=="0":
        while right-left<=m:
            if s[right]=="0":
                lst[right]=right-left
            right+=1
            if right==n+1:
                k=n
                break
    left+=1
    if left==right or k==n:
        break
if lst[n]==0:
    print(-1)
else:
    ans=deque([])
    while k>0:
        c=lst[k]
        ans.appendleft(c)
        k-=c
    print(*ans)

Measured memory_bytes: 48204
A, B = map(int, input().split())

def check_palindromic(i):
  if i[0] == i[-1] and i[1] == i[-2]:
    return True
  else:
    return False

count = 0
for i in range(A, B + 1):
  if check_palindromic(str(i)):
    count += 1
print(count)

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

int main()
{
  int n;
  cin >> n;
  
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if( (a[i] % 2) == 1){
      ans++;
    }
  }
  
  if( (ans % 2) == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

VI edge[N];

int n, bit[N], f[N];

void dfs(int u, int fa)
{
	int l = 0;
	for (auto v : edge[u])
	{
		if (v == fa) continue;
		dfs(v, u);
		l |= bit[u] & bit[v];
		bit[u] |= bit[v];
	}
	if (!bit[u]) bit[u] = 1;
	else
	{
		while ((1 << f[u]) < l || ((1 << f[u]) & bit[u])) ++f[u];
		bit[u] = ((bit[u] >> f[u]) << f[u]) | (1 << f[u]);
	}
	f[0] = max(f[0], f[u]);
}

int main()
{
	gi(n);
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1, 0);
	printf("%d\n", f[0]);
	return 0;
}

Measured memory_bytes: 12160
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    h, w = gets.chomp.split.map(&:to_i)

    puts '#' * (w + 2)

    h.times do
      puts "##{gets.chomp}#"
    end

    puts '#' * (w + 2)
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

int main(){
  int N, K;cin>>N>>K;
  string S;cin>>S;

  char beg=S[0], en=S[N-1];

  vi C0, C1;

  int l=0;

  for (int i=0;i<=N;++i){
    if(i==0) l++;

    else if(i==N){
      if(S[i-1]=='0') C0.push_back(l);
      else C1.push_back(l);
    }

    else{
      if(S[i]!=S[i-1]){
        if(S[i-1]=='0') {C0.push_back(l);l=1;}
        else{C1.push_back(l);l=1;}
      }
      else l++;
    }
  }

  int L=C0.size();
  if(L<=K){cout << N << endl; return 0;}

  C1.push_back(0);

  int tmp=0;
  int ans=0;

  if(beg=='0'){
    for (int i=0;i<K;++i){
      tmp+=C0[i]+C1[i];
    }
    ans=tmp;

    for (int i=K;i<L;++i){
      if(i==K){
        tmp+=C0[i]+C1[i]-C0[0];
        ans=max(tmp, ans);
      }
      else{
        tmp+=C0[i]+C1[i]-C0[i-K]-C1[i-K-1];
        ans=max(ans, tmp);
      }
    }
  }

  else{
    tmp+=C1[0];
    for (int i=0;i<K;++i){
      tmp+=C0[i]+C1[i+1];
    }
    ans=tmp;

    for (int i=K;i<L;++i){

      tmp+=C0[i]+C1[i+1]-C0[i-K]-C1[i-K];
      ans=max(ans, tmp);
    }
  }


  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 1055050

ll n,m,k,l;
ll a[N];
ll r[N];
ll suf[N],pre[N];
ll dp[N][5];
main(){
    n=in();
    rep2(i,1,n)a[i]=in();
    rep2(i,1,n+1){
        dp[i][0]=dp[i-1][0]+a[i];
        m=min(dp[i-1][0],dp[i-1][1]);
        dp[i][1]=m+(a[i]?(a[i]%2):2);
        m=min(m,dp[i-1][2]);
        dp[i][2]=m+1-(a[i]%2);
        m=min(m,dp[i-1][3]);
        dp[i][3]=m+(a[i]?(a[i]%2):2);
        m=min(m,dp[i-1][4]);
        dp[i][4]=m+a[i];
        if(i==n+1)cout<<m;
    }
}   

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

typedef long long ll;

static const int MAX = 2e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<int> x(n);
    for(int i=0;i<n;i++) {
        cin >> x.at(i);
    }

    int ans=MAX, tmp;
    for(int i=1;i<=100;i++) {
        tmp=0;
        for(int j=0;j<n;j++) {
            tmp+=(x.at(j)-i)*(x.at(j)-i);
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256