akhauriyash/Code-Regression huggingface dataset:
ip=input().split()
ipstr = str(ip[0])+str(ip[1])
ipint = int(ipstr)
i=0
ans=False
while i*i <= ipint:
    i+=1
    if i*i==ipint:
        ans=True
        break
if ans:
    print("Yes")
else:
    print("No")

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

const int M = 3e3;
int mat[M][M], n, m;
long long memo[M][M][4];

long long solve(int i, int j, int cnt) {
    if (i == n || j == m)
        return 0;

    long long &result = memo[i][j][cnt];
    if (result == -1) {
        result = max(solve(i + 1, j, 0), solve(i, j + 1, cnt));
        if (cnt < 3)
            result = max(result, mat[i][j] + max(solve(i + 1, j, 0), solve(i, j + 1, cnt + 1)));
    }
    return result;
}

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

    memset(memo, -1, sizeof memo);
    int k;
    cin >> n >> m >> k;

    while (k--) {
        int x, y, val;
        cin >> x >> y >> val;
        x--;
        y--;
        mat[x][y] = val;
    }
    cout << solve(0, 0, 0) << '\n';
}

Measured memory_bytes: 320484
#include<stdio.h>
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return (2*i)+1;}

int main(){
  int i,n,a[MAX+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&a[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(parent(i)>=1)printf("parent key = %d, ",a[parent(i)]);
    if(left(i)<=n)printf("left key = %d, ",a[left(i)]);
    if(right(i)<=n)printf("right key = %d, ",a[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PF pop_front
#define PP pop_back
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
int LCM(int a, int b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n, m;
	cin >> n >> m;
	PQ<int>pq;
	LL ans = 0;
	for (int i = 0; i < n; i++)
	{
		LL a;
		cin >> a;
		pq.push(a);
	}
	while (m > 0)
	{
		LL v = pq.top();
		pq.pop();
		v /= 2;
		pq.push(v);
		m--;
	}
	while (!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2;
int a[200010] = {};
int b[200010] = {};
VVI g(100010);
queue<int> que2;
int dp[3001][3001]={};
string s;

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>n>>s;
	rep(i,0,n){
		dp[0][i] = 1;
	}
	rep(i,1,n){
		char c = s[i-1];
		rep(j,0,n-i+1){
			if (c == '<'){
				dp[i-1][j] %mod;
				dp[i][j] += dp[i-1][j]%mod;
				dp[i][j] %mod;
			}
			else{
				if (j) {
					dp[i-1][j] %mod;
					dp[i][j-1] += dp[i-1][j]%mod;
				dp[i][j-1]%mod;}
			}
		}
		if (c == '<'){
			rep(j,0,n-i-1){
				dp[i][j+1] += dp[i][j]%mod;
				dp[i][j+1] %mod;
			}
		}
		else{
			per(j,1,n-i){
				dp[i][j-1] += dp[i][j]%mod;
				dp[i][j-1] %mod;
			}
		}
	}
	res = dp[n-1][0];
//	rep(i,0,n){
//		rep(j,0,n){
//			cout<< dp[i][j];
//		}
//		cout<<endl;
//	}
	cout<< res%mod<<endl;
}

Measured memory_bytes: 74240
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a>b)
	a=b;
	if(c>d)
	c=d;
	printf("%d\n", a+c);
	
	return 0;
}

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

int main(){
  int n;
  long mx=0;
  long mn=10e9;
  cin>>n;

  for (int i = 0; i < n; ++i) {
    long a;
    cin >> a;
    if (a>mx) mx=a;
    if(a<mn) mn =a;
  }
  cout<<abs(mx-mn)<<endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n; cin >> n;
  Vi a(n), b(n), c(200010), d(200010);
  rep(i,n) {
    cin >> a[i];
  }
  rep(i,n) {
    cin >> b[i];
  }
  rep(i,n) {
    c[a[i]]++;
    d[b[i]]++;
  }
  rep(i,n+1) {
    if(c[i]+d[i]>n) plexit("No")
  }
  reps(i,n) {
    c[i] += c[i-1];
    d[i] += d[i-1];
  }

  int x = 0;
  reps(i,n) {
    x = max(x, c[i]-d[i-1]);
  }
  pl("Yes")
  rep(i,n) {
    if (i) cout << " ";
    cout << b[(i+n-x)%n];
  }
  cout << "\n";
  return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


//マッチングに使う
bool dfs(int v, vii &G, vi &match, vi &used) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i], w = match[u];
    if (w < 0 || !used[w] && dfs(w, G, match, used)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

//二部グラフの最大マッチングを求める
//二部グラフの最大マッチング = 最小点カバー = n-最小辺カバー = n-最大安定集合
int bipartite_matching(vii &G) {
  int res = 0;
  vi match(G.size(), -1);
  vi used(G.size());
  for (int v = 0; v < G.size(); v++) {
    if (match[v] < 0) {
      fill(used.begin(), used.end(), 0);
      if (dfs(v, G, match, used)) {
        res++;
      }
    }
  }
  return res;
}


int main() {
  while (true) {
    int m, n;
    cin >> m >> n;
    if (m == 0) return 0;
    vi b(m), r(n);
    rep (i, m) {
      cin >> b[i];
    }
    rep (i, n) {
      cin >> r[i];
    }
    vii G(n + m);
    rep (i, m) {
      rep (j, n) {
        if (__gcd(b[i], r[j]) > 1) {
          G[i].push_back(m + j);
          G[m + j].push_back(i);
        }
      }
    }
    
    int res = bipartite_matching(G);
    cout << res << endl;
  }
}



Measured memory_bytes: 4456
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=-10000000000, s=0, h, f=0;
    cin>>n;
    vpll v;
    for(i=0; i<n; i++){
        cin>>x>>y;
        v.pb(mp(x+y, x-y));
    }
    sort(v.begin(), v.end());

    for(i=0; i<v.size(); i++){
        if(p<=v[i].ss){
            s++;
            p=v[i].ff;
        }
    }
    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 5236
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    ll N;
    cin >> N;
    string ans = "";

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    while(N){
        if(abs(N) % 2 == 0){
            N /= -2;
            ans += '0';
        }else{
            N -= 1;
            N /= -2;
            ans += '1';
        }
    }

    reverse(all(ans));
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 888
#input one int
#a = int(input())

#input some val
#a, b, c = (int(i) for i in input().split())
#val = [[int(i) for i in input().split()] for i in range(N)]

#input matrix
#a = [input().split() for i in range()]

N = int(input())
val = [[int(i) for i in input().split()] for i in range(N)]
val.insert(0, [0, 0, 0])

def abs(a):
    if(a < 0):
        return (-a)
    else:
        return a

dist = 0
t = 0
flag = 1
j = 0
for j in range(N):
    t = val[j+1][0] - val[j][0]
    dist = abs(val[j+1][1] - val[j][1]) + abs(val[j+1][2] - val[j][2])
    if(flag==1 and dist<=t and t%2==dist%2):
        flag = 1
    else:
        flag = 0

if(flag == 1):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 21156
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import numpy as np

N = int(input())
A = np.array(input().split())

rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1, N+1)%N])
mat = csr_matrix(([1]*(2*N), (rows, cols)), (N, N))
answer = (spsolve(mat,A) * 2 + .5).astype(int)
print(*answer)

Measured memory_bytes: 65968
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

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

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

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

using namespace std;

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

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

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

    // Actual program code starts here.
    string S;
    cin >> S;
    const int n = S.size();
    lint ret = 0;
    FOR(mask, 0, 1 << (n - 1)) {
        lint total = 0, last = S[0] - '0';
        FOR(i, 0, n - 1)
            if (mask & (1 << i)) {
                total += last;
                last = S[i + 1] - '0';
            } else {
                last = 10 * last + S[i + 1] - '0';
            }

        total += last;
        ret += total;
    }

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


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int main() {
    long double a, b, c; cin >> a >> b >> c;
    if (a + b + 2 * sqrt(a) * sqrt(b) < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            int[] cnt = new int[26];
            for (int i = 0; i < w.Length; i++)
            {
                cnt[w[i] - 'a']++;
            }
            for (int i = 0; i < cnt.Length; i++)
            {
                if(cnt[i]%2>0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<int> c(n-1);
    rep(i,n-1) cin >> c[i];
    int sum = b[a[0]-1];
    for(int i = 1;i < n;i++){
        sum  += b[a[i]-1];
        if(a[i] == a[i-1]+1) sum += c[a[i-1]-1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
res = 1
max = 0
for i in range(1, N+1):
    cnt = 0
    n = i
    while True:
        if n%2 != 0:
            break
        else:
            n = n//2
            cnt += 1
    if cnt > max:
        res = i
        max = cnt
print(res)

Measured memory_bytes: 2940
#include<stdio.h>

int main(){
	int N;
  	int num;
  	int i;
  	scanf("%d",&N);
  	int min = 0;
  	int min_num = 1e+6;
  	for(i = 0; i < N; i++){
    	scanf("%d",&num);
      	if(min_num >= num){
        	min_num = num;
            min++;
        }
    }
  	printf("%d\n",min);
  
  	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;

typedef pair<double, int> P;

int main()
{
	int n, rest;
	
	while (cin >> n)
	{
		rest = n % 39;
		if (rest == 0)
		{
			cout << "3C39" << endl;
		} else {
			printf("3C%02d\n", rest);
		}
		//cout << n % 39 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
a = $stdin.gets.chomp.to_i
b = $stdin.gets.chomp.to_i
c = $stdin.gets.chomp.to_i
d = $stdin.gets.chomp.to_i
e = $stdin.gets.chomp.to_i
k = $stdin.gets.chomp.to_i

cond = (e - a <= k)

if cond
 puts "Yay!"
else
 puts ":("
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int[][] area = new int[12][12];
		
		while(sc.hasNextLine()) {
			int count = 0;

			for(int i = 0;i < area.length; i++) {
				char[] nums = sc.nextLine().toCharArray();
				for(int j = 0;j < area.length; j++) {
					area[i][j] = Character.getNumericValue(nums[j]);
				}

			}

			for(int i = 0;i < area.length; i++) {
				for(int j = 0;j < area.length; j++) {
					if(area[i][j] == 1) {
						count++;
						area = checkIsland(area,i,j);
					}
				}
			}
			System.out.println(count);
			if(sc.hasNextLine()) {
				sc.nextLine();
			}
		}
		
		
	}
	
	public static int[][] checkIsland(int[][] area,int i,int j) {
		area[i][j] = 0;
		if(j < 11) {
			if(area[i][j + 1] == 1) {
				area = checkIsland(area,i,j + 1);
				
			}
		}
		if(i < 11) {
			if(area[i + 1][j] == 1) {
				area = checkIsland(area,i + 1,j);
				
			}
		}
		if(j > 0) {
			if(area[i][j - 1] == 1) {
				area = checkIsland(area,i, j - 1);
				
			}
		}
		if(i > 0) {
			if(area[i - 1][j] == 1) {
				area = checkIsland(area,i - 1,j);
				
			}
		}
		
		return area;
	}

}

Measured memory_bytes: 26268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    map<char,int>m;
    string W; cin >> W;
    rep(i,SZ(W)){
        m[W[i]]++;
    }
    bool frag = true;
    for(auto p:m){
        if(p.se%2) frag=false;
    }
    cout << (frag?"Yes":"No") << endl;
}

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

using namespace std;

typedef long long ll;

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

	string s, t;
	cin >> s >> t;

	cout << t << s << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    s = set(LI())
    l = len(s)
    if l % 2 == 1:
        return l
    return l - 1


print(main())


Measured memory_bytes: 16788
#include <iostream>
#include <vector>

using namespace std;

int p;
vector<int> num, pos, mnum;

pair<int, int> length(int ps){
	int v = num[ps];
	
	int l = ps, r = ps;
	
	bool found = false;
	while(l%p != 0){
		l--;
		if(num[l] < v){
			found = true;
			break;
		}
	}
	if(!found){
		l--;
		while(mnum[l/p] > v && l >= 0) l -= p;
		while(l >= 0 && num[l] > v) l--;
	}
	
	found = false;
	while(r%p != p-1){
		r++;
		if(num[r] < v || r == num.size()){
			found = true;
			break;
		}
	}
	if(!found){
		r++;
		while(mnum[r/p] > v && r+1 <= num.size()) r += p;
		while(r+1 <= num.size() && num[r] > v) r++;
	}
	
	return pair<int, int>(l, r);
}

int main(){
	int n;
	cin >> n;
	
	num.resize(n);
	pos.resize(n);
	for(int i = 0;i < n;i++){
		cin >> num[i];
		pos[num[i]-1] = i;
	}
	
	for(p = 1;p*p <= n;p++){
	}
	p--;
	
	mnum.resize(p);
	int v = n+1;
	for(int i = 0;i < n;i++){
		v = min(v, num[i]);
		if((i+1)%p == 0){
			mnum[(i+1)/p-1] = v;
			v = n+1;
		}
	}
	
	long long res = 0;
	for(int i = 0;i < n;i++){
		pair<int, int> x = length(pos[i]);
		
		int l = pos[i]-x.first, r = x.second-pos[i];
		
		res += ((long long)(i+1))*l*r;
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a,sum=0;
	scanf("%d",&a);
	int i,j,b;
	for(i=0;i<a;i++)
	{
	    scanf("%d",&b);
		for(j=2;j*j<=b;j+=1)
		{
			if(b%j==0)
			break;
		}
		if(j*j>b)
		{
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 1960
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [S, T] = input[0].split(' ')
  const [A, B] = input[1].split(' ').map(x => parseInt(x))
  const U = input[2]

  const balls = {
    [S]: A,
    [T]: B
  }

  balls[U]--

  console.log(balls[S], balls[T])
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n;
map<int,int> m[55];
string ans = "";
int main() {
  int n;
  cin >> n;
  rep(i,n){
    string s;
    cin >> s;
    rep(j,s.size()) m[i][s[j]-'a']++;
  };
  map<int,int> x;
  rep(c,26){
    int v = 1e9;
    rep(i,n) v = min(v,m[i][c]);
    x[c] = v;
  }
  string ans = "";
  rep(c,26)rep(i,x[c]) ans += (c+'a');
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

prepre_L = 2
pre_L = 1
now_L = 0
if N == 0:
    now_L =2
elif N == 1:
    now_L = 1
else:
    for n in range(N - 1):
        now_L = pre_L + prepre_L
        prepre_L = pre_L
        pre_L = now_L

print(now_L)


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

int main(){
  string S,T="";
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0'){
      T.push_back('0');
    }
    else if(S.at(i)=='1'){
      T.push_back('1');
    }
    else if(T.size()!=0){
      T.pop_back();
    }
  }
  cout << T << endl;
}

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

using namespace std;

int main(){
	int m, d;
	cin >> m >> d;

	int ans = 0;
	int d1, d10;

	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= d; j++){
			d1 = j % 10;
			d10 = (j / 10) % 10;
			
			if(d1 >= 2 && d10 >= 2 && d1 * d10 == i){
				// cout << d1 << " " << d10 << " " << i << endl;
				ans++;
			}
		}
	}

	cout << ans;

	return 0;
}

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

int gcd(int x,int y){
    if(y==0)
        return x;
    return gcd(y,x%y);
}

int main(){
    int x,y;
    cin>>x>>y;
    int g=gcd(x,y);
    cout<< (x+1)+(y+1)-(g+1) <<endl;
	return 0;	
}


Measured memory_bytes: 3096
n = int(input())
a = list(map(int,input().rstrip().split(" ")))
q = 0
ans = 0
ans2 = 0
for i in range(n):
    q += a[i]
    if i % 2 == 0:
        if q <= 0:
            ans += 1 - q
            q = 1
    else:
        if q >= 0:
            ans += 1 + q
            q = -1
q = 0
for i in range(n):
    q += a[i]
    if i % 2 == 1:
        if q <= 0:
            ans2 += 1 - q
            q = 1
    else:
        if q >= 0:
            ans2 += 1 + q
            q = -1
print(min(ans,ans2))

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

using namespace std;

int main() {
    int n, x, res = 0;
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) return 0;

        for (int i = 1; i <= n; ++i) {
            for (int j = i+1 ; j <= n; ++j) {
                for (int k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) res += 1;
                }
            }
        }
        cout << res << endl;
        res = 0;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S; long long K;
    cin >> S >> K;
    //Sの先頭からmin(S.size(), K)個が1なら、ans = 1
    //そうでなければ、初めて出てきた1以外の数がans
    char ans = '1';
    long long s = S.size();
    for(long long i = 0; i < min(s, K); i++) {
        if(S.at(i)!='1') {
            ans = S.at(i);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String str=sc.next();
			String a,b;
			ArrayList<String> list = new ArrayList<String>();
			for(int j=0;j<str.length()-1;j++){
				a=str.substring(0,j+1);
				b=str.substring(j+1);
				StringBuilder rev_a=new StringBuilder(a);
				StringBuilder rev_b=new StringBuilder(b);
				String r_a=new String(rev_a.reverse());
				String r_b=new String(rev_b.reverse());

				list.add(a+b);
				list.add(r_a+b);
				list.add(a+r_b);
				list.add(r_a+r_b);
				list.add(b+a);
				list.add(r_b+a);
				list.add(b+r_a);
				list.add(r_b+r_a);
			}	
			Collections.sort(list);
			String tmp="";int ans=0;
			for (int j=0;j<list.size();j++) {
				if(!list.get(j).equals(tmp)){
					ans++;
					tmp=list.get(j);
				}
				//System.out.println(string);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 86936
#include<iostream>
#include<queue>
using namespace std;
int main(){
  priority_queue<int> mlist;
  int i;
  for(i=0;i<10;i++){
    int dt;
    cin>>dt;
    mlist.push(dt);
  }
  for(i=0;i<3;i++){
    cout <<mlist.top()<<endl;
    mlist.pop();
  }

  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN

    ll a,b,n;cin>>a>>b>>n;
    ll ans;
    ll c = min(b,n);
    if (n<=b) {
        ll a1 = a*n / b - a*(n/b);
        ll a2 = a*(n-1) / b - a*((n-1)/b);
        ans = max(a1,a2);
        // cout<<a1<<a2<<endl;
    }
    else{
        
        ans = a*(b-1) / b - a*((b-1)/b);

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

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

#define ll long long
#define mod 1000000007

int main(){
	int a[13],b[13];
	string s;
	cin>>s;
	int n=s.size(),x;
	for(int i=1;i<13;i++){
		a[i]=0;
	}
	a[0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<13;j++){
			b[j]=0;
		}
		if(s[i]=='?'){
			for(int j=0;j<10;j++){
				for(int k=0;k<13;k++){
					b[(10*k+j)%13]+=a[k];
					b[(10*k+j)%13]%=mod;
				}
			}
		}
		else{
			x=s[i]-'0';
			for(int k=0;k<13;k++){
				b[(10*k+x)%13]+=a[k];
				b[(10*k+x)%13]%=mod;
			}
		}
		for(int j=0;j<13;j++){
			a[j]=b[j];
		}
	}
	cout<<a[5]<<"\n";
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            while(s.Length >= 5)
            {
                int pos = s.Length;

                string ss = s.Substring(pos - 5, 5);

                if ( ss.CompareTo("erase") == 0 ||
                    ss.CompareTo("dream") == 0 )
                {
                    s = s.Substring(0, pos - 5);
                    continue;
                }

                if (pos >= 7)
                {
                    ss = s.Substring(pos - 7, 7);
                    if (ss.CompareTo("dreamer") == 0)
                    {
                        s = s.Substring(0, pos - 7);
                        continue;
                    }
                }

                if (pos >= 6)
                {
                    ss = s.Substring(pos - 6, 6);
                    if (ss.CompareTo("eraser") == 0)
                    {
                        s = s.Substring(0, pos - 6);
                        continue;
                    }
                }


                Console.WriteLine("NO");
                return;
            }

            if ( s.Length != 0)
            {
                Console.WriteLine("NO");
                return;
            }

            Console.WriteLine("YES");
        }
    }
}


Measured memory_bytes: 31784
#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() {
  int n;
  while (cin >> n) {
    int ans = 0;
    repc(a, 9) repc(b, 9) repc(c, 9) repc(d, 9) {
      if (a + b + c + d == n) ans++;
    }
    cout << ans << '\n';
  }
}



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

using namespace std;

int a, b, c;

int main(){
    //ifstream fin; fin.open("input.txt");
    //ofstream fout; fout.open("output.txt");
    cin >> a >> b >> c;
    if(a == b){
        if(b != c)cout << "Yes";else cout << "No";
    }else
    if(a == c) cout << "Yes";
    else
    if(c == b) cout << "Yes";
    else
    cout << "No";
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

template<class T> class BIT {
private:
    vector<T> bit;
public:
    BIT(int n) : bit(vector<T>(n+1, 0)) {}
    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }
    void add(int i, int x) {
        if (i > size()) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
    int size() const { return bit.size()-1; }
};

int main()
{
    int N, K; cin >>N>>K;
    vi A(N);
    BIT<ll> bit(2000);
    ll inv_num = 0;
    rep(i, N) {
        cin >> A[i];
        bit.add(A[i], 1);
        inv_num += bit.sum(2000)-bit.sum(A[i]);
    }
    ll d = 0;
    sort(all(A));
    rep(i, N) {
        bit.add(A[i], 1);
        d += bit.sum(2000)-bit.sum(A[i]);
    }

    inv_num = inv_num * K % MOD;
    inv_num = inv_num + d * (K&1?(K-1)/2:(K-1)) % MOD * (K&1?K:K/2) % MOD;
    inv_num %= MOD;

    cout << inv_num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int INF = 1e9;

int main() {
	int n;

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

	int max_a = *max_element(a.begin(), a.end());
	int min_a = *min_element(a.begin(), a.end());

	int ans = INF;
	for (int i = min_a; i <= max_a; i++) {
		int cost = 0;
		for (auto e : a) {
			cost += (e - i) * (e - i);
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;


int N,M,Q,K;
string S;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> K;
	vct<int> bt(1);
	int k = K;
	rep(i,30){
		if(0 < i && k & 1) bt.pub(i);
		k /= 2;
	}
	vct<pii> prd(N);
	rep(i,N){
		int a,b;
		cin >> a >> b;
		prd[i] = {a,b};
	}
	ll ans = 0;
	for(int d : bt){
		int tmp = K;
		if(d) tmp = (K - (1 << d)) | ((1 << d) - 1);
		ll t = 0;
		rep(i,N){
			int a = prd[i].fir;
			int b = prd[i].sec;
			if(a == (tmp & a)) t += b;
		}
		ans = max(ans,t);
	}
	esc(ans);
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n; cin>>n;
    vector<ll> x(64,0);
    for(int i=0;i<n;i++){
        int64_t a; cin>>a;
        stringstream ss;
        ss<<bitset<64>(a);
        string s=ss.str();
        //cout<<s<<endl;
        for(int j=0;j<s.size();j++){
            if(s[j]=='1') x[j]++;
        } 
    }
    //for(int i=0;i<64;i++) x[i]*=(n-1);
    ll ans=0;
    ll mod=1e9+7;
    for(int i=0;i<64;i++){
        //cout<<i<<":"<<x[i]<<":"<<n-x[i]<<endl;
        ll tmp=x[i];
        tmp%=mod;
        tmp*=(n-x[i]);
        tmp%=mod;
        for(int k=0;k<63-i;k++){
            tmp*=2;
            tmp%=mod;
        }
        //tmp*=pow(2,63-i);
        tmp%=mod;
        ans+=tmp;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//C - Bugged: 8Min;
//Assunto: DP;
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int n, ans = 0;
bool dp[105][10005];
void solve(int idx, int soma, vector<int> &points) {
    if(idx >= n) {
        if(soma % 10 != 0) ans = max(ans, soma);
        return;
    }
    if(dp[idx][soma]) return;
    solve(idx+1, soma, points);
    solve(idx+1, soma+points[idx], points);
    dp[idx][soma] = true;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    vector<int> points(n);
    loop(i, 0, n) cin >> points[i];
    solve(0, 0, points);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
k, s = map(int, input().split())
count = 0
temp = s-2*k if (s-2*k)>0 else 0
for x in range(temp, k-1):
    for y in range(x+1, k):
        if y<(s-x-y)<=k:
            count += 6
for x in range(temp, k+1):
    for z in range(temp, k+1):
        if x*2 + z == s:
            if x == z:
                count += 1
            else:
                count += 3
print(count)

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 59;
const int mod = 1e9 + 7;


int N;
bool memo[301][301][301];
double dp[301][301][301];


double rec(int a, int b, int c) {
  if(exchange(memo[a][b][c], true)) return dp[a][b][c];
  double ret = 0;

  int64 rest = N - (a + b + c);
  if(rest == N) return 0;

  if(a) ret += rec(a - 1, b, c) * a / N;
  if(b) ret += rec(a + 1, b - 1, c) * b / N;
  if(c) ret += rec(a, b + 1, c - 1) * c / N;

  return dp[a][b][c] = (ret + 1) / ((1.0 - ((double) rest / N)));
}

int main() {
  cin >> N;
  int a = 0, b = 0, c = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if(x == 1) ++a;
    else if(x == 2) ++b;
    else ++c;
  }
  cout << fixed << setprecision(10) << rec(a, b, c) << endl;
}




Measured memory_bytes: 239872
#include <iostream>
#include <queue>

using namespace std;

int main(){
    int k;
    cin >> k;
    long long tmp = 0 ;
    queue<long long > q ;
    if(k <= 9 )
        cout << k;
    for (int i =1;i<=9;i++)
        q.push(i);
    int cnt = 9;
    while(cnt < k){
        long long res = q.front();
        q.pop();
        if(res % 10 != 0){
            q.push(10*res + res%10-1);
            cnt++;
            if(cnt == k){
                cout << (10*res + res%10-1)<<endl;
                break;
            }
        }
        q.push(10*res+res%10);
        cnt ++ ;
         if(cnt == k){
                cout << (10*res+res%10)<<endl;
                break;
            }

        if(res%10!=9){
            q.push(10*res+res%10+1);
            cnt++;
             if(cnt == k){
                cout << (10*res+res%10+1)<<endl;
                break;
            }

        }
    }

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 100003;

ll n,m,djs[MAXN],sz[MAXN];
vector<pii> edge;
void init() {
    REP (i,MAXN) {
        djs[i] = i;
        sz[i] = 1;
    }
}

ll fnd(ll x) {
    return x == djs[x] ? x : (djs[x] = fnd(djs[x]));
}

ll ans = 0;
void uni(ll x,ll y) {
    if (sz[x=fnd(x)] > sz[y=fnd(y)]) {
        swap(x,y);
    }
    if (x == y) {
        return;
    }
    djs[x] = y;
    ans -= sz[x] * sz[y];
    sz[y] += sz[x];
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> m;
    REP (i,m) {
        ll u,v;
        cin >> u >> v;
        edge.emplace_back(u,v);
    }
    init();
    ans = n * (n-1) / 2;
    vector<ll> opt;
    opt.emplace_back(ans);
    RREP (i,m-1) {
        uni(edge[i].X,edge[i].Y);
        opt.emplace_back(ans);
    }

    RREP (i,m-1) {
        cout << opt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6256
import bisect

N = int(input())

L = list(map(int,input().split()))


L.sort()


ans = 0
for i in range(N):

    for j in range(i):

        mid = L[i]
        mini = L[j]

        ind = bisect.bisect_left(L,mid+mini)
        #print (mini,mid,ind)

        ans += ind - i - 1

print (ans)


Measured memory_bytes: 44572