akhauriyash/Code-Regression huggingface dataset:
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int N,W,w[110],v[110];
lint dp[100010];
int main(){
	std::cin>>N>>W;
	rep(i,N)std::cin>>w[i]>>v[i];
	rep(i,N){
		for(int j=W;j>=0;j--){
			if(j-w[i]>=0)chmax(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	std::cout<<*std::max_element(dp,dp+W+1)<<std::endl;
	return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

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

int main() {
    constexpr int C_MAX = 100000;
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    REP(i, R) {
        cin >> r[i];
        --r[i];
    }
    vector<vector<pii>> g(N);
    REP(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        --A; --B;
        g[A].push_back(pii(B, C));
        g[B].push_back(pii(A, C));
    }

    const ll INF = (N << R) * C_MAX;
    int result = INF;
    int mask = (1 << R) - 1;
    REP(start, R) {
        vector<int> dp(N << R, INF);
        priority_queue<pli, vector<pli>, greater<pli>> q;
        dp[(r[start] << R) ^ (1 << start)] = 0;
        q.push(pli(0, r[start] << R ^ 1 << start));
        while (!q.empty()) {
            ll d;
            int state;
            tie(d, state) = q.top();
            q.pop();
            if (d < dp[state]) {
                continue;
            }
            int u = state >> R;
            int visited = state & mask;
            for (const pii &edge: g[u]) {
                int v = edge.first;
                int cost = edge.second;
                int k = distance(r.begin(), find(all(r), v));
                int visited_next;
                if (k == R) {
                    visited_next = visited;
                } else {
                    visited_next = visited | 1 << k;
                }
                int state_next = v << R ^ visited_next;
                if (dp[state_next] > d + cost) {
                    dp[state_next] = d + cost;
                    q.push(pli(dp[state_next], state_next));
                }
            }
        }
        REP(u, N) {
            result = min(result, dp[u << R ^ mask]);
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 4188
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r)
  in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (f x; doit l; doit r)
  in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (doit l; f x; doit r)
  in
  doit t

let print t =
  let f e = print_string " "; print_int e in
  inorder f t;
  print_newline ();
  preorder f t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r
  in
  doit t

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | ["find"; n] -> (print_endline (if find (int_of_string n) t then "yes" else "no"); read (i + 1) t)
      | _ -> (print t; read (i + 1) t)
    end
  in
  read 0 (create ())

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  i64 s; cin >> s;
  i64 x2 = sqrt(s);
  i64 y3 = x2;
  int t = 0;
  while (x2 * y3 < s) {
    if (t == 0) x2++; else y3++;
    t = 1 - t;
  }
  i64 x3 = x2 * y3 - s;
  i64 y2 = 1;
  cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef string ST;
 
 
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
 
 
LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void func() {
  LL N ;
  cin >>N;
  string S;
  cin >> S;
  LL C =0;
  for(LL i=0;i<S.length()-1;++i){
    if(S[i]==S[i+1]){
      C++;
    }
  }
  cout << N-C;
    
}
 

int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 1024
x, n = list(map(int, input().split(" ")))
if n == 0:
    input()
    print(x)
else:
    p = list(map(int, input().split(" ")))
    i = 0
    while(True):
        if not(x - i in p):
            print(x-i)
            break
        elif not(x+ i in p):
            print(x+i)
            break
        else:
            i += 1


Measured memory_bytes: 9188
num = int(input())
string = str(input())

new_str = ''
for x in string:
    if (ord(x) + num) > ord('Z'):
        new_str = new_str + chr((ord(x) + num) - 26)
    else:
        new_str = new_str + chr(ord(x) + num)

print(new_str)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define mod 1000000009

ll n,c;
pair<ll,ll> arr[200];
ll dp[200][100005] = {};

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

    cin >> n >> c;
    ll tmp1,tmp2;
    for(ll i=1; i<=n; i++){
        cin >> tmp1 >> tmp2;
        arr[i] = {tmp1,tmp2};
    }

    ll sol = 0;
    for(ll i=1; i<=n; i++){
        for(ll w=1; w<=c; w++){

            if(w < arr[i].first){
                dp[i][w] = dp[i-1][w];
            }else{
                dp[i][w] = max( dp[i-1][w] , arr[i].second + dp[i-1][w-arr[i].first]);
            }
            sol = max(sol,dp[i][w]);
        }
    }




    cout << sol;








    return 0;
}

Measured memory_bytes: 79360
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
  name = input()
  if name[0]=='M':
    m+=1
  elif name[0]=='A':
    a+=1
  elif name[0]=='R':
    r+=1
  elif name[0]=='C':
    c+=1
  elif name[0]=='H':
    h+=1
  else:
    pass
  
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)

Measured memory_bytes: 49640
#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 * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#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 pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[200000];
vector<P> vec[2];
map<int,int> mp;
signed main(){
  int n;
  scanf("%lld", &n);
  rep(i,n)scanf("%lld", &a[i]);
  
  int ans = 0, cnt[2] = {}, mx = 0;
  mp.clear();
  for(int i = 0;i < n;i+=2){
    mp[a[i]]++;cnt[0]++;
  }
  for(auto it = mp.begin();it != mp.end();it++){
    vec[0].push_back(P(cnt[0]-it->se, it->fi));
  }
  
  mp.clear();
  for(int i = 1;i < n;i+=2){
    mp[a[i]]++;cnt[1]++;
  }
  for(auto it = mp.begin();it != mp.end();it++){
    vec[1].push_back(P(cnt[1]-it->se, it->fi));
  }
  
  rep(i,2)vec[i].push_back(P(cnt[i], -1));
  rep(i,2)sort(all(vec[i]));
  // rep(i,2){
  //   rep(j,vec[i].size())printf("%lld ", vec[i][j].fi);
  //   printf("\n");
  // }
  if(vec[0][0].se == vec[1][0].se)
  ans = min(vec[0][0].fi+vec[1][1].fi, vec[0][1].fi+vec[1][0].fi);
  else ans = vec[0][0].fi+vec[1][0].fi;
  
  printf("%lld\n", ans);
	return 0;
}








Measured memory_bytes: 6516
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N, L, i = 0;
	cin >> N >> L;
	vector<string> s(N);
	while (cin >> s[i] && i < N-1) {
		i++;
	}
	sort(s.begin(), s.end());
	string ans = "";
	for (i = 0; i < s.size(); ++i)
		ans += s[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i;
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  do{
    scanf("%c", &st);

    for(i=0;i<52;i++)
      if(al[i] == st){
        st = al[ (i+26)%52 ];
        break;
      }

    printf("%c", st);

  }while(st != '\n');

  return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define PB push_back
#define ALL(c) c.begin(),c.end()

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  sort(ALL(A));

  vector<int> v;
  int cnt = 1;
  REP(i, N - 1) {
    if (A[i] != A[i + 1]) {
      v.PB(cnt);
      cnt = 1;
    } else {
      cnt++;
    }
  }
  v.PB(cnt);
  sort(ALL(v));

  cnt = 0;
  REP(i, v.size()) {
    if (v[i] >= 3) v[i] = 2 - v[i]%2;
    if (v[i] == 2) cnt++;
  }
  if (cnt % 2 == 1) cout << v.size() - 1 << endl;
  else cout << v.size() << endl;


  return 0;
}

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

int a[1000010];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  int now = 0;
  int ans = 0;
  for (;;) {
    if (now == 1) {
      cout << ans << endl;
      return 0;
    }
    if (ans >= n) {
      cout << -1 << endl;
      return 0;
    }
    ans++;
    now = a[now];
  }
}

Measured memory_bytes: 3540
/*
 * Created by Dipta Das on 14-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    int n, m;
    cin >> n >> m;
    vector< pair<ll,ll> > ar(n);

    for (int i = 0, x, y; i < n; ++i) {
        cin >> x >> y;
        ar[i] = {x, y};
    }
    sort(ar.begin(), ar.end());



    ll cost = 0, idx = 0;
    while (m) {
        int amount = m > ar[idx].second ? ar[idx].second : m;
        m = m > ar[idx].second ? (m - ar[idx].second) : 0;
        cost += (amount * ar[idx].first);
        ++idx;
    }

    cout << cost << endl;



    return 0;
}



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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> g(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    g[A].push_back(B);
    g[B].push_back(A);
  }
  queue<int> que;
  que.push(0);
  vector<int> ans(N, -1);
  ans[0] = 0;
  while (!que.empty()) {
    int top = que.front();
    que.pop();
    for (int i = 0; i < g[top].size(); i++) {
      int next = g[top][i];
      if (ans[next] == -1) {
        ans[next] = top;
        que.push(next);
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) {
    cout << ans[i] + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 10132
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input =new Scanner(System.in);
		int n=input.nextInt();
		int[] arr=new int[n];
		int[] temp=new int[arr.length];
		int tem,c=0;;
		for(int i=0;i<arr.length;i++)
		{
			arr[i]=input.nextInt();
			temp[i]=arr[i];
		}
		input.close();
		Arrays.sort(temp);	
          
		for(int j=0;j<arr.length;j++)
		{
			if(arr[j] != temp[j]) 
			{
				c++;
			}
		
	   }

		if(c<3) 
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}	
		System.exit(0);
		
	}
}


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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    constexpr ll MAX = 3e3;

    vector<ll> fact, ifact;
    fact.assign(MAX+1, 1);
    for(ll i=1; i<=MAX; i++)
        (fact[i] = i * fact[i-1]) %= MOD;

    ifact.assign(MAX+1, 1);
    {
        ll a = fact[MAX], b = MOD-2;
        while(b) {
            if(b&1) (ifact[MAX] *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
    }
    for(ll i=MAX-1; i>=0; i--)
        (ifact[i] = ifact[i+1] * (i+1)) %= MOD;

    auto comb = [&](ll a, ll b) {
        if(a < b) return 0ll;
        return ((fact[a] * ifact[b]) % MOD * ifact[a-b]) % MOD;
    };

    ll s;
    cin >> s;
    ll r = 0;
    for(ll i=1; i<s; i++) {
        ll k = s - i*3;
        if(k < 0) break;
        (r += comb(k+i-1, k)) %= MOD;
    }
    cout <<r << endl;

}

Measured memory_bytes: 3704
n = int(input())
cnt = [0] * 11000

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            value = x*x + y*y + z*z + x*y + y*z + z*x
            if value <= n:
                cnt[value] += 1

for i in range(1,n+1):
    print(cnt[i])


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

int main(){
  string s,t;
  cin >> s >> t;
  int x = stoi(s+t);
  for(int i=1;i<1000;i++){
    if(i*i == x){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
b=[]
for i in range(n-1):
    if a[i]==a[i+1]:
        b.append(a[i])
b=sorted(b,reverse=True)
if len(b)<=1:
    print(0)
elif len(b)==2 and b[0]==b[1]:
    print(0)
elif b.count(b[0])>=3:
    print(b[0]*b[0])
else:
    b=list(set(b))
    b=sorted(b,reverse=True)
    print(b[0]*b[1])

Measured memory_bytes: 14804
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cstdlib>
using namespace std;
int main()
{
	vector<int> v;
	vector<int>::reverse_iterator it;
	int n, a, b, c, k, ans, cost,price;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		cin >> k;
		v.push_back(k);
	}
	sort(v.begin(), v.end());
	ans = c / a;
	cost = c;
	price = a;
	for (it = v.rbegin(); it != v.rend(); it++) {
		cost += *it;
		price += b;
		ans = max(ans, cost / price);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int N = 51;

ll C[N][N];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  for (int i = 0; i < N; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
    }
  }
  
  int n, k, s, t;
  cin >> n >> k >> s >> t;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  if (!((s & t) == s)) {
    cout << "0\n";
    return 0;
  }
  {
    vector <int> na;
    for (int i = 0; i < n; ++i) {
      if ((s & a[i]) == s && ((t | a[i]) == t)) {
        na.push_back(a[i]);
      }
    }
    a = na;
    n = a.size();
  }
  vector <int> bits;
  for (int i = 17; i >= 0; --i) {
    if ((s ^ t) & (1 << i)) {
      bits.push_back(i);
    }
  }
  int sz = (1 << (int)bits.size());
  for (int &x : a) {
    int y = 0;
    for (int i = 0; i < (int)bits.size(); ++i) {
      y = 2 * y + ((x >> bits[i]) & 1);
    }
    x = y;
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int mask = 0; mask < sz; ++mask) {
      int cnt = 0;
      for (int j = i + 1; j < n; ++j) {
        if (((a[i] ^ a[j]) & mask) == (a[i] ^ a[j])) ++cnt;
      }
      int s = (__builtin_popcount(mask) % 2 == __builtin_popcount(sz - 1) % 2 ? 1 : -1);
      for (int x = 0; x <= min(cnt, k - 1); ++x) {
        ans += s * C[cnt][x];
      }
    }
  } 
  cout << ans << '\n';
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int q = 0;
    for (int i = 0; i < n; i++){
        if (a[i] < 0) q += 1;
        else break;
    }
    if (q == 0) q = 1;
    else if (q == n) q = n - 1;

    vector<vector<int>> v(n - 1, vector<int>(2));
    int x = a[0];
    int k = 0;
    for (int i = q; i < n - 1; i++){
        v[k] = {x, a[i]};
        k += 1;
        x -= a[i];
    }
    v[k] = {a[n - 1], x};
    k += 1;
    x = a[n - 1] - x;
    for (int i = 1; i < q; i++){
        v[k] = {x, a[i]};
        k += 1;
        x -= a[i];
    }
    cout << x << endl;
    for (int i = 0; i < n - 1; i++){
        cout << v[i][0] << ' ' << v[i][1] << endl;
    }
}


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

int main(){
    int h,n;cin>>h>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    string ans="No";
    sort(a,a+n,std::greater<int>());
    for(int i=0;i<n;i++){
        h-=a[i];
        if(h<=0) {ans="Yes";
        break;}
    }
    cout<<ans<<endl;
}

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

int main()
{
  int N, X;
  cin >> N >> X;

  vector<int> M(N);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> M.at(i);
    sum += M.at(i);
  }

  int num = N;
  X -= sum;
  sort(M.begin(), M.end());

  for (auto m : M) {
    while ((X - m) >= 0) {
      X -= m;
      num++;
    }
  }

  cout << num << endl;
}


Measured memory_bytes: 256
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  int n, k;
  cin >> n >> k;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  sort(a, a+n);
  for(int i = 0; i < k; i++) ans+= a[i];
  cout << ans << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String S = scanner.next();
        String T = scanner.next();
        for (int i = 0; i < S.length(); i++) {
            String nS = S.substring(i,S.length()) + S.substring(0,i);
            if (T.equals(nS)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
int main()
{
	char a[3][5] = {0};
	int t = 0;
	cin >> a[0] >> a[1];
	for (int i = 0; i < 3; i++)
	{
		if (a[1][i] != a[0][2 - i])t++;
	}
	if (t==0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i32, i64, isize, u32, u64, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
#[fastout]
fn main() {
    input! {
        n: usize
    }

    let mut ans = 0usize;
    for i in 1..=n {
        if i % 5 != 0 && i % 3 != 0 {
            ans += i;
        }
    }

    println!("{}", ans);
}


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

int main(){
  int q=1;
  string str[]={"OK","Cannot pay some amount","Cannot use greedy algorithm"};
  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    int ans =0,c[51];
    for(int i=0;i<n;i++)cin >> c[i];
    if(c[0] !=1) ans=1;
    for(int i=2;i<n;i++){
      if(ans!=0) break;
      int t=0,j=i,sum=0;
      while(j>=0&&c[i]%c[j]==0)j--;
      if(j<0)continue;
      t=(c[i]/c[j]+1)*c[j];
      int k=n-1;
      while(t)sum+=t/c[k],t%=c[k--];
      if(c[i]/c[j]+1 <sum)ans=2;
    }
    cout << "Case #"<<q++<<": "<<str[ans]<<endl;
  }
return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n,d;
    cin>>n>>d;
    ll ans =0;
    for(ll i=1;i<=n;i++){
        ll x,y;
        cin>>x>>y;
        x=x*x;
        y=y*y;
        ld dd = sqrt(x+y);
        if(dd<=d)
            ans++;
    }
    cout <<ans<<"\n";
}

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  S.push_back('2');
  vector<int> A;
  if(S[0] == '0') A.push_back(0);
  int cnt = 1;
  rep(i, 1, S.size()) {
    if(S[i] == S[i-1]) cnt++;
    else {
      A.push_back(cnt);
      cnt = 1;
    }
  }
  if(S.back() == '0') A.push_back(0);
  int ans = 0;
  int r = 0;
  int sum = 0;
  for(int l = 0; l < A.size(); l++){
    while(r < A.size() && r - l < 2 * K + 1){
      sum += A[r];
      r++;
    }
    if(l % 2 == 0) ans = max(ans, sum);
    if(l == r) r++;
    else sum -= A[l];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> P;
ld cx[65]={0},cy[65]={0},kd[65]={0};
ll n,k;
const ld EPS=1e-14;
bool judge(ld T){
  ld cd[65];
  for(int i=0;i<n;i++) cd[i]=T/kd[i];
  vector<P> points;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ld x1=cx[i],x2=cx[j],y1=cy[i],y2=cy[j];
      ld dist=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
      ld d1=cd[i],d2=cd[j];
      if(d1+d2<dist+EPS) continue;
      if(dist<max(d1-d2,d2-d1)+EPS) continue;

      ld cos=(d1*d1+dist*dist-d2*d2)/(2*d1*dist);
      ld sin1=sqrt(abs(1-cos*cos));
      ld sin2=-sin1;
      ld dx=(x2-x1)*d1/dist,dy=(y2-y1)*d1/dist;
      ld vx1=dx*cos-dy*sin1,vx2=dx*cos-dy*sin2;
      ld vy1=dx*sin1+dy*cos,vy2=dx*sin2+dy*cos;

      points.push_back(P(x1+vx1,y1+vy1));
      points.push_back(P(x1+vx2,y1+vy2));
    }
    points.push_back(P(cx[i],cy[i]));
  }
  for(int i=0;i<points.size();i++){
    int cnt=0;
    ld px=points[i].first,py=points[i].second;
    for(int j=0;j<n;j++){
      ld ox=cx[j],oy=cy[j],d=cd[j];
      ld dist=sqrt((ox-px)*(ox-px)+(oy-py)*(oy-py));
      if(dist<=d+EPS) cnt++;
    }
    if(cnt>=k) return true;
  }
  return false;
}
int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>cx[i]>>cy[i]>>kd[i];
  ld lb=0,rb=1e6;
  for(int i=0;i<500;i++){
    ld mid=(lb+rb)/2;
    if(judge(mid)) rb=mid;
    else lb=mid;
  }
  cout<<fixed;
  cout<<setprecision(10)<<rb<<endl;
}


Measured memory_bytes: 512
<?php
list($K) = ints();
$sum6 = 0;
$sum1 = 0;
for($i = 1; $i <= $K; $i++)
for($j = 1; $j <= $K; $j++)
$memo[$i][$j] = $memo[$j][$i] = (int)gmp_gcd($i, $j);

for($i = 1; $i <= $K; $i++)
for($j = $i+1; $j <= $K; $j++)
for($k = $j+1; $k <= $K; ++$k)
    $sum6+=$memo[$memo[$i][$j]][$k];

for($i = 1; $i <= $K; $i++)
for($j = $i+1; $j <= $K; $j++)
    $sum6+=$memo[$i][$j];

for($i = 1; $i <= $K; $i++)
    $sum1+=$i;

echo $sum6*6+$sum1;


function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


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

vector<string> divide = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; i++) reverse(divide.at(i).begin(), divide.at(i).end());
    
    bool can = true;
    for (int i = 0; i < S.size(); )
    {
        bool can2 = false;
        for (int j = 0; j < 4; j++)
        {
            string d = divide.at(j);
            if(S.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }

        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 512
class UnionFind:
    def __init__(self, n):
        self.n = n
        # 各要素の親要素の番号を格納するリスト
        # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
        self.parents = [-1] * n

    def find(self, x):
        """要素xが属するグループの根を返す
        """
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        """要素xが属するグループと要素yが属するグループをくっつける
        """
        x = self.find(x)
        y = self.find(y)
        # すでにくっつてるのでそのまま返す
        if x == y:
            return
        # 大きい方(x)に小さい方(y)をくっつけたいので、
        # 大小が逆なら入れ替える
        if self.size(x) < self.size(y):
            x, y = y, x
        # xのサイズを更新する
        self.parents[x] += self.parents[y]
        # yの親をxに変更する
        self.parents[y] = x

    def size(self, x):
        """要素xが属するグループのサイズ（要素数）を返す
        """
        return -self.parents[self.find(x)]


N, M = map(int, input().split())
P = list(map(int, input().split()))

uf = UnionFind(N+1)

for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x, y)

ans = 0
for i in range(N):
    if uf.find(i+1) == uf.find(P[i]):
        ans += 1

print(ans)



Measured memory_bytes: 14452
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = str_inp()
a = n[-1]
if int(a) in {0, 1, 6, 8}:
    print("pon")
elif int(a) == 3:
    print("bon")
else:
    print("hon")


Measured memory_bytes: 68928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    int a = 0, b = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == '0') a++;
        else b++;
    }

    cout << 2*min(a,b) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

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

    vector<int> S(2);
    S.at(0) = s / 100;
    s = s % 100;
    S.at(1) = s;

    bool yymm = false;
    bool mmyy = false;

    if ((S.at(0) > 12 || S.at(0) == 0) && (S.at(1) > 12 || S.at(1) == 0))
        cout << "NA";
    else if ((S.at(0) > 12 || S.at(0) == 0) && (S.at(1) > 0 && S.at(1) < 13))
        cout << "YYMM";
    else if ((S.at(1) > 12 || S.at(1) == 0) && (S.at(0) > 0 && S.at(0) < 13))
        cout << "MMYY";
    else
        cout << "AMBIGUOUS";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
good = set(range(N))
for _ in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    if H[a] < H[b]:
        good -= {a}
    elif H[b] < H[a]:
        good -= {b}
    if H[a] == H[b]:
        good -= {a, b}
print(len(good))

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
//    while(true){
    long long int X, Y;
    cin >> X >> Y;
//    cout << int(log2(Y/X))+1 << endl;

    for(int i = 1;true;i++){
        if(X * 2 <= Y){
            X *= 2;
            continue;
        }
        else{
            cout << i << endl;
            break;
        }
    }
}//}


Measured memory_bytes: 256
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, x = inpl()
A = inpl()
A.sort()
tmp = 0
for i in range(N):
    tmp += A[i]
    if tmp > x:
        ans = i
        break
else:
    if tmp == x:
        ans = N
    else:
        ans = N - 1

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top(); S.pop();
    for ( int i = 0; i < G[u].size(); i++ ) {
      int v = G[u][i];
      if ( color[v] == NIL ) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for ( int i = 0; i < n; i++ ) color[i] = NIL;
  for ( int u = 0; u < n; u++ ) {
    if ( color[u] == NIL ) dfs(u, id++);
  }
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for ( int i = 0; i < m; i++ ) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for ( int i = 0; i < q; i++ ) {
    cin >> s >> t;
    if ( color[s] == color[t] ) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.12Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

const int N = 3e3 + 2 ;
ld p[N] , dp[N] ;

int n ;

void read ()
{
    cin >> n ;

    for ( int i = 1 ; i <= n ; i ++ )
    {
        ld t ; cin >> t ;
        p[i] = t ;
    }
}

void print_ans ()
{
    ld ans = 0 ;

    for ( int head = 1 ; head <= n ; head ++ )
    {
        int tail = n - head ;

        if ( head > tail )
            ans += dp[head] ;
    }

    pp ( ans ) ;
}

void solve ( int test_case )
{
    read () ;
    dp[0] = 1 ;

    for ( int c = 1 ; c <= n ; c ++ )
    {
        for ( int i = c ; i >= 0 ; i -- )
        {
            if ( i ) dp[i] = dp[i - 1] * p[c] + dp[i] * ( 1 - p[c] ) ;
            else dp[i] *= ( 1 - p[c] ) ;
        }
    }

    print_ans ( ) ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(int argc,const char *argv[]){
int a,b;
   scanf("%d %d",&a,&b);
   if(a > b){
        printf("a > b\n");
   }else if(a < b){
        printf("a < b\n");
   }else if(a == b){
        printf("a == b\n");
   } 
return 0;
}

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

long long k, ans;
string s;
int main() {
	cin>>s;
	for(int i=0; s[i]; i++) {
		if(s[i]=='A') k++;
		else if(s[i]=='B' && s[i+1]=='C') ans += k, i++;
		else k = 0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

int main ()
{
  std::string str;

  std::cin >> str;

  while (str!="0")
    {
      auto sum = 0;
      std::for_each(str.begin(), str.end(), [&](auto &c){ sum += static_cast<int>(c) - static_cast<int>('0');});
      std::cout << sum << std::endl;
      std::cin >> str;
    }
}



Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define sort_i sort((i).begin(),(i).end())

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	string a, b;
	cin >> a;
	cin >> b;
	if (a.size() > b.size()) {
		cout << "GREATER\n";
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS\n";
		return 0;
	}
	else {
		rep(i, 0, a.size()) {
			if (a[i] > b[i]) {
				cout << "GREATER\n";
				return 0;
			}
			else if (a[i] < b[i]) {
				cout << "LESS\n";
				return 0;
			}
		}
	}
	cout << "EQUAL\n";
	return 0;
}


Measured memory_bytes: 256