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

using ll = long long;
const int MOD = 1000000007;
#ifdef LOCAL_ENV
    #define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
    #define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) {
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


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

	string a={S[5],S[6]};
  	int i=atoi(a.c_str());
  
  	if(i>4)p("TBD");
  	else p("Heisei");
  
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10, LOG = 20;
int a[N], qz[N][LOG + 1];

bool check(int l, int r) {
  for(int i = 0; i <= LOG; ++i) {
    if(qz[r][i] - qz[l - 1][i] >= 2) return false;
  }
  return true;
}

int n;
int get(int s) {
  int l = s, r = n, ans = s;
  while(l <= r) {
    int mid = (l + r) >> 1;
    if(check(s, mid)) ans = mid, l = mid + 1;
    else r = mid - 1;
  }
  return ans;
}

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    for(int j = 0; j <= LOG; ++j) {
      qz[i][j] = qz[i - 1][j];
      if((a[i] >> j) & 1) qz[i][j]++;
    }
  }
  ll ans = 0;
  for(int i = 1; i <= n; ++i) {
    int r = get(i);
//    printf("%d %d\n", i, r);
    ans += (r - i + 1);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 17408
from collections import defaultdict, deque
def main():
  N, M, *L = map(int, open(0).read().split())
  dic = defaultdict(list)
  par =  [0]*N
  cnt = [0]*N
  for a,b in zip(*[iter(L)]*2):
    dic[a-1] += [b-1]
    cnt[b-1] += 1

  for i in range(N):
    if not cnt[i]:
      q = deque([i])
      par[i] = '0'
      break
  
  while q:
    m = q.popleft()
    for c in dic[m]:
      cnt[c] -= 1
      if not cnt[c]:
        par[c] = str(m+1)
        q += [c]

  ans = '\n'.join(par)
  print(ans)
  
if __name__== '__main__':
  main()

Measured memory_bytes: 43484
#include <bits/stdc++.h>
using namespace std;
 
int w=50,h=50;
vector<vector<int>>data(h,vector<int>(w));


void dfs(int x,int y){
	data[x][y]=0;
	for(int dx=-1;dx<=1;dx++){
    	for(int dy=-1;dy<=1;dy++){
        //四方の移動先を考え、陸を探す。
          int nx=x+dx, ny=y+dy;
        	if( 0<=nx && nx<h && 0<=ny && ny<w &&data[nx][ny]==1){
              dfs(nx,ny);
        	}
        }
    }     
}

int main() {
 while(1){w=0;h=0;
  cin >>w>>h;
  if(w==0&&h==0)return 0;
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
    cin>>data.at(i).at(j);
    } 
  }
  
  int ans=0;
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
   		if(data[i][j]==1){
        	dfs(i,j);
        	ans++;
        }
    } 
  }
 	cout <<ans <<endl; 
 }  
}
 


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

int pow (int x) {

	int i=0,ans=1;

	while (i<x) {

		ans=ans*10;
		


		i++;
	}


	return ans;
}


int main () {

	int a,b;	
	int count=0;
	cin>>a>>b;
	vector<int> n(5);//切り捨て値
	vector<int> z(5);
	int sub=a;
	while (sub<=b) {

		
		//s 桁ずらし
		int i=0;
		while (i<5) {

			n.at(i)=sub/pow(i);
			i++;
		}
		//g

		//s 10^i桁目の値取得
		i=0;
		while (i<4){

			z.at(i)=n.at(i)-10*n.at(i+1);

	
			i++;

		}
		z.at(4)=n.at(4);
		//g

		if (z.at(0)==z.at(4)&&z.at(1)==z.at(3)) {

			count++;


		}

		sub++;
	}

	cout<<count<<endl;

}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()

    ans = sum([i - 1 for i in a])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10236
#include <stdio.h>

#define MAX_SIZE 100002

#define OK  0
#define NG  1

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))


int Col[MAX_SIZE];
int Row[MAX_SIZE];

int main(){
    int n,w,h;
    int xi,yi,wi;
    int i,ans;

    /* 初期化 */
    for(i=0;i<MAX_SIZE;i++){
        Col[i]=0;
        Row[i]=0;
    }

    /* いもす準備 */
    scanf("%d %d %d",&n,&w,&h);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&xi,&yi,&wi);
        Col[MAX(xi-wi,0)]++;
        Col[MIN(xi+wi,w)]--;
        Row[MAX(yi-wi,0)]++;
        Row[MIN(yi+wi,h)]--;
    }

    /* いもす展開 ＆ 判定 */
    /* 縦か横のどちらかが全範囲を網羅できていればよい */
    ans = OK;

    /* 横チェック */
    for(i=0;i<w;i++){
        if(Col[i]<=0){
            ans = NG;
            break;
        }
        Col[i+1]+=Col[i];
    }

    /* 横NGならば縦チェック */
    if(ans != OK){
        ans = OK;
        for(i=0;i<h;i++){
            if(Row[i]<=0){
                ans = NG;
                break;
            }
            Row[i+1]+=Row[i];
        }
    }

    printf((ans==OK)?"Yes\n":"No\n");

#ifdef DEBUG
    for(i=0;i<w+1;i++)printf("%d ",Col[i]);
    printf("\n");
    for(i=0;i<h+1;i++)printf("%d ",Row[i]);
    printf("\n");
#endif

    return 0;

}



Measured memory_bytes: 2632
import java.util.Scanner;

/**
 * Created by DELL on 2017/7/1.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String a=in.next();
        for (int i = 1; i <a.length() ; i++) {
            if (a.substring(0,a.length()/2-i).equals(a.substring(a.length()/2-i,a.length()-2*i))) {
                System.out.println(a.length()-2*i);
                break;
            }
        }
    }

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000000LL
int main(){
  int n;
  long long a[100009];
  long long t=INF;
  cin>>n;
  long long sum=0,cnt=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<0){
      cnt++;
    }
    t=min(t,llabs(a[i]));
    sum+=llabs(a[i]);
  }
  if(cnt%2==0){
    cout<<sum<<endl;
  }
  else{
    cout<<sum-t*2<<endl;
  }
  return(0);
}


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

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

  vector<int> posr;
  for ( int i = 0; i < n; i++ ) {
    if ( c[i] == 'R' ) { posr.push_back(i); }
  }

  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( c[i] == 'W' ) {
      if ( posr.size() > 0 && i < posr[posr.size()-1] ) {
        c[posr[posr.size()-1]] = 'W';
        c[i] = 'R';
        posr.pop_back();
        ans++;
      }
    }
  }

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


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

ll cst[1 << 16];
ll dp[1 << 16];

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

  for(int msk = 0; msk < (1 << N); msk++){
    for(int i = 0; i < N; i++){
      for(int j = i; j < N; j++){
        if(msk & (1 << i)){
          if(msk & (1 << j)){
            cst[msk] += a[i][j];
          }
        }
      }
    }
  }

  for(int msk = 0; msk < (1 << N); msk++){
    for(int msk2 = msk; msk2 > 0; msk2 = (msk2 - 1) & msk){
      dp[msk] = max(dp[msk], dp[msk - msk2] + cst[msk2]);
    }
  }

  /*for(int msk = 0; msk < (1 << N); msk++){
    cout << "msk: " << msk << " " << cst[msk] << endl;
  }*/

  cout << dp[(1 << N) - 1] << endl;
  return 0;
}


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

def kaibun(num) :
    num_str = str(num)
    for i in range((len(num_str)+1)//2) :
        if num_str[i] != num_str[-(i+1)] :
            return False
    return True

ans = 0

for i in range(A,B+1) :
    if kaibun(i) == True :
        ans += 1

print(ans)


Measured memory_bytes: 3064
def main():
    N = int(input())
    lst = [0] + list(map(int,input().split()))
    counter = 0
    for i in range(1,N+1):
        if i % 2 == 1:
            if lst[i] % 2 == 1:
                counter += 1

    print(counter)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(a<=8&&b<=8)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	int a = 1;
	rep(i, n)
	{
		int x; cin >> x;
		if (x % 2 == 0)a *= 2;
	}
	cout << pow(3, n) - a << endl;
}

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

int main() {
	int r;
	cin >> r;
	if (r < 1200)cout << "ABC" << endl;
	else if (r < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;

  int MIN  = min(min(8*Q, 4*H), min(2*S, D));
  int MIN1 = min(min(4*Q, 2*H), S);
  if(N == 1){
    cout << MIN1 << endl;
  }else{
    if(N%2 == 0) cout << N/2*MIN << endl;
    else cout << N/2*MIN+MIN1 << endl;
  }

  return 0;
}

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

int main(){
  set<int> kk;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      kk.insert(i*j);
    }
  }
  int N;
  cin >> N;
  if(kk.count(N)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

const int MAX_N = 100000;

vector<pair<int, ll>> graph[MAX_N];
vector<int> used(MAX_N, 0);

pair<int, ll> dfs(int node, ll dist) {
    used[node] = 1;
    pair<int, ll> ret = {node, dist};
    for(pair<int, ll> p: graph[node]) {
        if(used[p.first]) continue;
        pair<int, ll> q = dfs(p.first, dist+p.second);
        if(ret.second < q.second) {
            ret = q;
        }
    }
    return ret;
}

ll calc_diameter() {
    pair<int, ll> u = dfs(0, 0);
    used = vector<int>(MAX_N, 0);
    return dfs(u.first, 0).second;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b; ll c;
    cin >> n;

    for(int i=0;i<n-1;++i) {
        cin >> a >> b >> c;
        graph[a].emplace_back(b, c);
        graph[b].emplace_back(a, c);
    }
    cout << calc_diameter() << endl;
}



Measured memory_bytes: 15156
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;

vl ch[1005];
ll dp[1005];
ll a[1005];
bool poss;
const ll mx = 10006;

void dfs(ll v) {
  if (ch[v].size() == 0) {
    dp[v] = 0;
    return;
  } 

  dp[v] = mx / 2 + 1;
  ll s = 0;
  bool pos[mx + 3];
  ms(pos, 0);
  pos[0] = 1;

  for (ll x: ch[v]) {
    dfs(x);
    s += dp[x] + a[x];
    bool npos[mx + 3];
    ms(npos, 0);
    f0rd(i, mx) {
      if (pos[i]) {
        ll ni = i + dp[x];
        if (ni <= mx + 1) npos[ni] = 1;
        ni = i + a[x];
        if (ni <= mx + 1) npos[ni] = 1;
      }
    }
    f0r(i, mx + 2) pos[i] = npos[i];
  }

  bool can = 0;
  f0r(i, mx + 1) {
    if (pos[i]) {
      ll v1 = i, v2 = s - i;
      if (v1 >= 0 && v2 >= 0) {
        if (v2 <= a[v]) {
          dp[v] = min(dp[v], v1);
          can = 1;
        }
        if (v1 <= a[v]) {
          dp[v] = min(dp[v], v2);
          can = 1;
        }
      }
    }
  }

  poss &= can;
}

void solve() {
  ll n; cin >> n;

  ms(dp, 0);

  f0r(i, n - 1) {
    ll p; cin >> p;

    ch[--p].pb(i + 1);
  }

  f0r(i, n) cin >> a[i];

  poss = 1;
  dfs(0);

  if (!poss) cout << "IM";
  cout << "POSSIBLE\n";
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

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

int n, m, q;
vector<long long> a, b, c, d;
long long answer = 0;

long long ans(vector<int> A) {
  long long res = 0;
  for (int i = 0; i < q; i++) {
    if (A[b[i]] - A[a[i]] == c[i]) {
      res += d[i];
    }
  }

  return res;
}

long long dfs(vector<int> &A) {
  if ((int)A.size() == n) {
    ans(A);
    return ans(A);
  }
  long long res = 0;
  int pre_value = (A.empty() ? 0 : A.back());

  for (int i = pre_value; i < m; i++) {
    A.push_back(i);
    res = max(res, dfs(A));
    A.pop_back();
  }
  return res;
}
int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i];
    --b[i];
  }
  vector<int> A;

  cout << dfs(A) << endl;

  return 0;
}

Measured memory_bytes: 3584
<?php
fscanf(STDIN, "%d%d%d", $N, $M, $Q);
for($i = 0; $i <= $N; $i++){
  for($j = 0; $j <= $N; $j++){
    $map[$i][$j] = 0;
  }
}
for($i = 0; $i < $M; $i++){
  fscanf(STDIN, "%d%d", $L, $R);
  $map[$L][$R] += 1;
}
for($i = 1; $i <= $N; $i++){
  for($j = 1; $j <= $N; $j++){
    $map[$i][$j] = $map[$i][$j] + @$map[$i][$j-1];
  }
}
for($i = 1; $i <= $Q; $i++){
  fscanf(STDIN, "%d%d", $L, $R);
  if(!isset($q[$L][$R])){
    $sum = 0;
    for($j = $L; $j <= $R; $j++){
      $sum += $map[$j][$R] - @$map[$j][$L-1];
    }
    $q[$L][$R] = $sum;
  }
  echo $q[$L][$R],"\n";
}

Measured memory_bytes: 21624
import sys

def calc_hash_bool(Len, hash):
    bools = [False] * Len
    for i in range(Len-1, -1, -1):
        remainder = hash %2
        if(remainder==1):
            bools[i] = True
        hash //= 2
    return bools

def calc_combinations(height, width, boards, demand_black):
    """
    縦: 2^6 = 64
    横: 2^6 = 64
    64^2 = 4096通り
    """
    combinations = 0
    #hashを2進数で考えて000000-> どれも選ばない, 111111->全て選択(色を染める)、というように
    for hash_h in range(2**height):
        bool_h = calc_hash_bool(height, hash_h)
        for hash_v in range(2**width):
            bool_v = calc_hash_bool(width, hash_v)
            N_black = 0
            for i in range(height):
                for j in range(width):
                    if(bool_h[i]==False and bool_v[j]==False and boards[i][j]=="#"):
                        N_black += 1
            if(N_black==demand_black):
                combinations += 1
    return combinations



if(__name__ == "__main__"):

    height, width, demand_black = map( int, input().strip().split() )

    boards = [ [] for i in range(height) ]
    N_black_total = 0
    for i in range(height):
        Str = input().strip()
        for j in Str:
            boards[i].append(j)
            if(j=="#"):
                N_black_total += 1
    if(N_black_total < demand_black):
        print("0")
    else:
        combinations = calc_combinations(height, width, boards, demand_black)
        print(combinations)


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

const int MAXN = 100 + 10;

int n, arr[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < i; ++j) {
			for (int k = 1; k < j; ++k) {
				if (arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k]) continue;
				int sum = arr[i] + arr[j] + arr[k];
				if (sum - max(arr[i], max(arr[j], arr[k])) > max(arr[i], max(arr[j], arr[k]))) ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define eps (1e-10)
using namespace std;
class Point
{
	public:
	double x,y;
	Point(double _x=0,double _y=0):x(_x),y(_y){}
	Point operator + (Point p){ return Point(x+p.x,y+p.y);} 
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);} 
	Point operator / (double a){return Point(x/a,y/a);}
	double norm(){return x*x+y*y;}
	double ABS(){return sqrt(norm());} //俩点间的距离 
};
struct Segment
{
	Point p1,p2;	
};

double dot(Point a,Point b)//求内积 
{
	return a.x*b.x+a.y*b.y;
}
//外积的值为a与b向量构成的平行四边形面积的值 
double cross(Point a,Point b)//求外积 
{
	return a.x*b.y-a.y*b.x;
} 


//判断是否正交 向量内积：a*b=|a||b|*cos(Y) 当cos为0时正交(90,-90垂直) 
//a*b=a.x*b.x+a.y*b.y;
bool solve1(Point a,Point b)//是否正交 
{
	double f=a.x*b.x+a.y*b.y; 
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
//判断是否平行  向量外积：|a*b|=|a||b|sin(Y) 当sin为0时平行(180,0平行)
//|a*b|=|a|*|b|*sin(Y) 
bool solve2(Point a,Point b)//是否平行 
{
	double f=a.x*b.y-a.y*b.x;
	if(fabs(f-0.0)<eps) return true;
	else return false;
}

/*
求垂足x：对于给定的三点p1,p2,p从点p向通过p1,p2的直线引一条垂线
base=p2-p1;
hypo=p-p1;
 x=s.p1+base*(hypo*base/|base|^2); hypo*base 可以用向量内积求 
*/
Point solve3(Segment s,Point p)//求投影点 
{
	Point base=s.p2-s.p1;
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r; 
}
/*
求投影点x：对于给定的三点p1,p2,p从点p向通过p1,p2的直线为对称轴与点p
成线对称点为x 
通过求solve3的垂足延长一倍就可以求x 
*/
Point solve4(Segment s,Point p)//求映象 
{
	return p+(solve3(s,p)-p)*2.0;
}

/*
点a与点b之间的距离等于向量a-b或b-a的绝对值。 
*/ 
double getdis(Point a,Point b)//求俩点间的距离                    
{
	return (a-b).ABS();
} 

/*
设直线p1 p2上的向量为a=p2-p1,p与p1构成的向量b=p-p1
则点p与直线p1p2的距离d就等于a,b构成的平行四边形的高
用a与b外积的大小(平行四边形的面积)除以a的大小|a|即可求出高d
d=|a*b|/|a|=|(p2-p1)*(p-p1)|/|p2-p1|; 
*/
//注意：这里Segmet s是不规范的应该是 Line s 才对 
double getdis_Li(Segment s,Point p)//点与直线的距离 
{
	return abs(cross(s.p2-s.p1,p-s.p1)/(s.p2-s.p1).ABS());
}
int ccw(Point p0,Point p1,Point p2)
{
	Point a=p1-p0;
	Point b=p2-p0;
	if(cross(a,b)>eps) return 1;
	if(cross(a,b)<-eps) return -1;
	if(dot(a,b)<-eps) return 2;
	if(a.norm()<b.norm()) return -2;
	return 0;
	
}
int main()
{
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	Point p1(x1,y1),p2(x2,y2);
	int T;scanf("%d",&T);
	while(T--){
		int x,y;
		scanf("%d %d",&x,&y);
		Point p(x,y);
		if(ccw(p1,p2,p)==1) printf("COUNTER_CLOCKWISE\n");
		else if(ccw(p1,p2,p)==-1) printf("CLOCKWISE\n");
		else if(ccw(p1,p2,p)==2) printf("ONLINE_BACK\n");
		else if(ccw(p1,p2,p)==-2) printf("ONLINE_FRONT\n");
		else printf("ON_SEGMENT\n");
	} 
	
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int k,n;
    cin>>k>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    a.push_back(k+a[0]);
    int max1=0;
    rep(i,n){
        max1=max(max1,abs(a[i]-a[i+1]));
    }
    cout<<k-max1<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>
#define FOR(arg, ini, end) for(int arg = ini; arg < end; arg++)


using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b, n;
    cin >> a >> n >> b;

    cout << min(b, n*a) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$argline = "%d %d";
fscanf(STDIN, $argline, $N, $M);

$argline = "";
for ($i = 0; $i < $N - 1; $i++) {
    $argline .= "%d ";
}
$argline .= "%d";

$votes = fscanf(STDIN, $argline);
$allvotes = array_sum($votes);

$THRESHOLD = (1 / (4 * $M)) * $allvotes;

$popularProductsCount = 0;
foreach ($votes as $vote) {
    if ($vote >= $THRESHOLD) {
        $popularProductsCount++;
    }
}

if ($popularProductsCount >= $M) {
    echo "Yes\n";
} else {
    echo "No\n";
}


Measured memory_bytes: 3828
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int asc(const void *a, const void *b) {
	return *(int *)b - *(int *)a;
}

int main(void) {
	int N;//num of monster
	int *H;//hit point of monsters
	int K;//special attak
	int i;
	unsigned long long int sum;
	char buf[128], *ch;
	char *buf_array;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	K = atoi(ch);

	buf_array = (char *)calloc(N * 12, sizeof(char));
	H = (int *)calloc(N, sizeof(int));

	fgets(buf_array, N * 12, stdin);
	ch = strtok(buf_array, " ");
	H[0] = atoi(ch);
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		H[i] = atoi(ch);
	}
	free(buf_array);

	qsort(H, N, sizeof(int), asc);
	sum = 0;
	for(i = K; i < N; i += 1) {
		sum += (unsigned long long int)H[i];
	}
	printf("%llu\n", sum);

	free(H);
	return 0;
}


Measured memory_bytes: 3328
#abc111c
from collections import Counter

n=int(raw_input())
v=map(int,raw_input().split())
a,b=[],[]
for i in xrange(0,n,2):
 a.append(v[i])
 b.append(v[i+1])
acnt=Counter(a)
bcnt=Counter(b)
x=acnt.most_common()[0][0]
y=bcnt.most_common()[0][0]
if x!=y:
 res=n-acnt.most_common()[0][1]-bcnt.most_common()[0][1]
else:
 if acnt.most_common()[0][1]==n/2:
  res=n-bcnt.most_common()[0][1]
 elif bcnt.most_common()[0][1]==n/2:
  res=n-acnt.most_common()[0][1]
 else:
  res=min(n-acnt.most_common()[0][1]-bcnt.most_common()[1][1],n-bcnt.most_common()[0][1]-acnt.most_common()[1][1])
print res


Measured memory_bytes: 19468
a = [int(input()) for _ in range(4)]
print(a[0]+a[2] if a[0] <= a[1] and a[2] <= a[3] else a[0]+a[3] if a[0] <= a[1] and a[3] <= a[2] else a[1]+a[2] if a[1] <= a[0] and a[2] <= a[3] else a[1]+a[3])

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n;
  cin>>n;
  vector<pii> vec1;
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    vec1.push_back(make_pair(tmp,i));
  }
  sort(vec1.begin(),vec1.end());
  int ans=0;
  for(int i=0;i<n;i+=2)
    if(vec1[i].second%2==1)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
from collections import defaultdict
import math

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

mods = defaultdict(int)
sums = [0]*(N+1)
for i in range(1, N+1):
    sums[i] = sums[i-1] + As[i-1]
    mods[sums[i] % M] += 1

total = 0
for k, v in mods.items():
    if k == 0:
        total += v
    total += v * (v-1) // 2
print(total)

Measured memory_bytes: 15264
#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>;

const int INF = 2e9;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll o,p,q,r;
    o = a*c;
    p = a*d;
    q = b*c;
    r = b*d;
    cout << max({o,p,q,r}) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n, a[100010], dp[100010][3], b[100010], c[100010];
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d%d%d", a+i, b+i, c+i);
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	printf("%d", max({dp[n][0], dp[n][1], dp[n][2]}));

	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();
    int N = scanner.nextInt();
    int[] p = new int[N];

    if(N==0){
      System.out.println(X);
      scanner.close();
    return;
    }

    for(int i = 0; i<N ; i++){
      p[i] = scanner.nextInt();
    }

    int[] q = new int[N];
    for(int i=0; i<N; i++){
      q[i] = p[i] - X;
    }
    int i = 0;
    int[] flag = new int[2];
    flag[0] = 1;
    flag[1] = 1;

    while(flag[0] == 1 && flag[1] == 1){
      for(int j = 0; j< N; j++){
        if(q[j] == i){
          flag[0] = 0;
        }if(q[j] == -i){  
          flag[1] = 0;
        }
      }
      if(flag[1] == 1){
        System.out.println(X - i);
        break;
      }else if(flag[0] == 1){
        System.out.println(X + i);
        break;
      }else{
        flag[0] = 1;
        flag[1] = 1;
        i++;
      }
    }

    scanner.close();
    return;
    

  }
}

Measured memory_bytes: 35868
k = int(input())
from math import gcd

ans=0
for i in range(k):
    ans+=i+1
    for j in range(i+1, k):
        x=gcd(i+1,j+1)
        ans+=6*gcd(i+1,j+1)
        for l in range(j+1, k):
            ans+=6*gcd(x,l+1)
print(ans)


Measured memory_bytes: 67728
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  1000100
#define PII pair<int, int>
#define mp(a,b) make_pair(a,b)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 35;
ll a[MAXN];

int main()
{
	//ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	int n;
	while (cin >> n) {
		a[n] = 0;
		for (int i = 0; i < n; i++) cin >> a[i];
		sort(a, a + n);
		for (int i = 1; i < n; i++) a[i] += a[i - 1];
		int ans = 1;
		for (int i = 0; i < n; i++)
		{
			if (a[i]*2 >= (a[i + 1] - a[i]))
				ans++;
			else
				ans = 1;
		}
		cout << ans-1 << endl;
	}
	return 0;
}


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

int main() {
	// your code goes here
    int n,i;
    cin >> n;
    for(i=1;i<=2*n;i++){
        if(floor(i*108/100)==n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
int n, k;

int sum(int n) {
    return n * (n + 1) / 2;
}

int ssum(int start, int end) {
    int ret = 0;
    return sum(end) - sum(start - 1);
}

signed main() {
    cin>>n>>k;
    int ans = 0;
    for (int i = k; i <= n + 1; i++) {
        ans += ssum(n - i + 1, n) - ssum(0, i - 1) + 1;
        ans %= MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <queue>
#include <map>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
#define MOD int(1e9+7)
#define REP(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define fi first
#define se second

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

	string S; cin >> S;
	bool flag = false;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S.substr(i, 2) == "AC")flag = true;
	}

	cout << (flag ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main(){
    string s,res;
    int i, lng, lngm;
    cin >> s;
    lng = 0;
    lngm = 0;
    forN(i,10){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            lng++;
        }
        else{
            lngm = max(lng,lngm);
            lng = 0;
        }
    }
    lngm = max(lng,lngm);
    cout << lngm << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

s = input()
t = input()

if s == t:
    print('Yes')
    sys.exit(0)

if sorted(s) != sorted(t):
    print('No')
    sys.exit(0)

can = False
n = len(s)
for i in range(1, n):
    if s[i:] == t[:n-i]:
        if s[:i] == t[n-i:]:
            can = True
            break

if can:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int test=0;
    for(int i=0;i<3;i++)
        if(s[i]==t[i])
            test++;
    cout<<test<<endl;
    
    return 0;   
}


 
 


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = ""
for A in a:
  if A % 2 != 0:
    print(0)
    exit()
  cnt = 0
  while A%2==0:
    A /=2
    cnt += 1
  if ans == "" or ans > cnt: ans = cnt
print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;
  cout << (s[0]==s[2] ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int nums[4][3][10] = {}, n, i, b, f, r, v, ib, iff, ir;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d%d%d", &b, &f, &r, &v);
    nums[b - 1][f - 1][r - 1] += v;
  }
  for(ib = 0; ib < 4; ++ib) {
    for(iff = 0; iff < 3; ++iff, printf("\n")) for(ir = 0; ir < 10; ++ir) printf("%2d", nums[ib][iff][ir]);
    if(ib < 3) {
      for(i = 0; i < 20; ++i) printf("#");
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

int main()
{
    int a,b;
    scanf(" %d %d", &a, &b);

    if( (a+b)%3==0 || a%3==0 || b%3==0)
    {
        printf("Possible\n");
    }

    else
    {
        printf("Impossible\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
    int main(void)
    {
    	int n,i,s,b;
    	long long a,m;
    	scanf("%d",&n);
    	s=0;
    	m=1000*1000*1000;
    	for(i=1;i<=n;i++){
    		scanf("%d",&a);
    		if(a>s){
    			s=a;
    		}
    		if(a<m){
    			m=a;
    		}
    	}
    	b=s-m;
    	printf("%d\n",b);
    	return 0;
    }

Measured memory_bytes: 128
#include <stdio.h>
 
int main(){
  int n, a[5000], cnt = 0, i;
  scanf("%d", &n);
  for(i = 0; i < n; i++)scanf("%d", &a[i]);
  for(i = 0; i < n; i++) cnt += a[i];
  printf("%d", cnt - n);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

vector<int> edges[200000];

int main(){
    ll n, m;
    cin >> n >> m;
    vi h(n);
    rep(i, n){
        cin >> h.at(i);
    }
    rep(i, m){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    int cnt = 0;
    rep(i, n){
        bool flag = true;
        for(int j : edges[i]){
            if(h[j] >= h[i]) flag = false;
        }
        if(flag) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define mod 1'000'000'007
typedef long long ll;

template <typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << '\n';
}

void solve()
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    --k;
    char c = s[k];
    for (auto &e : s)
        if (e != c)
            e = '*';
    cout << s << '\n';
}

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

    int t { 1 };
    //cin >> t;
    while (t--)
        solve();

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static class Solver {
        // int INF = (1 << 30) - 1;
        // long L_INF = (1L << 62) - 1;
        // long MOD = (long) 1e9 + 7;

        int S, W;
        // int[] A;

        // write your code
        public void solve(InputReader in, PrintWriter out) {
            S = in.nextInt();
            W = in.nextInt();
            // A = new int[N];
            // for (int i = 0; i < N; i++) {
            // A[i] = in.nextInt();
            // }

            if (S <= W) {
                out.println("unsafe");
            } else {
                out.println("safe");
            }
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 32656
#include<cstring>
#include<iostream>
#include<math.h>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<string>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;
const int MAXN = 11000;


int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie();
    cout.tie(0);
    int n , m , k;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            int tmp = i * (m - j) + j * ( n - i);
            if(tmp == k)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
    
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

//--------------------------------------------------//
int n, m;
vector<int> adj[100010];
int s, t;
int dist[100010][3];
int main() {
  use_cio();
  cin >> n >> m;
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  cin >> s >> t;
  repp(i, 1, n + 1) dist[i][0] = dist[i][1] = dist[i][2] = -3;
  dist[s][0] = 0;
  priority_queue<pair<int, pii>> que;
  que.push({0, {s, 0}});
  while (!que.empty()) {
    auto fr = que.top();
    que.pop();
    int d = -fr.first;
    int cur = fr.second.first;
    int idx = fr.second.second;
    if (dist[cur][idx] < d) continue;
    for (auto nxt : adj[cur]) {
      int nidx = (idx + 1) % 3;
      if (dist[nxt][nidx] > d + 1 || dist[nxt][nidx] == -3) {
        dist[nxt][nidx] = d + 1;
        que.push({-d - 1, {nxt, nidx}});
      }
    }
  }
  cout << dist[t][0] / 3 << endl;
}


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

void solve(long long X) {
  // for (long long i = -64; i <= 64; i++) {
  //     for (long long j = -64; j <= 64; j++) {
  //         if (i * i * i * i * i - j * j * j * j * j == X) {
  //             cout << i << " " << j << endl;
  //             return;
  //         }
  //     }
  // }
  long long b = 0;
  while (1) {
    for (auto B : {b, -b}) {
      long long B5 = B * B * B * B * B;
      long long a = pow(X + B5, 0.2);
      for (auto A : {a - 1, a, a + 1}) {
        if (A * A * A * A * A == X + B5) {
          cout << A << " " << B << endl;
          return;
        }
      }
    }
    b++;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 4184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
void DFS(vector<long long>& A, long long N, long long B) {
	if (B > N) return;
	long long tmp = B;
	bool th = false, fi = false, se = false;
	while (tmp != 0) {
		if (tmp % 10 == 3) th = true;
		else if (tmp % 10 == 5) fi = true;
		else if (tmp % 10 == 7) se = true;
		tmp /= 10;
	}
	if (th && fi && se) A.push_back(B);
	DFS(A, N, B * 10 + 3);
	DFS(A, N, B * 10 + 5);
	DFS(A, N, B * 10 + 7);
}
int main() {
	long long N; cin >> N;
	vector<long long>A;
	DFS(A, N, 0);
	sort(A.begin(), A.end());
	cout << A.size() << endl;
}

Measured memory_bytes: 3748
N=int(input())
A=list(map(int,input().split()))
dp1,dp2=[0]*(N+1),[0]*(N+1)
from heapq import heappop,heappush
q1,q2=[],[]
for i in range(2*N):
    heappush(q1,A[i])
    heappush(q2,-A[-i-1])
    if i<N:
        dp1[0]+=A[i]
        dp2[-1]+=A[-i-1]
    else:
        dp1[i-N+1]=dp1[i-N]+A[i]-heappop(q1)
        dp2[N-i-2]=dp2[N-i-1]+A[-i-1]+heappop(q2)
print(max([dp1[i]-dp2[i] for i in range(N+1)]))

Measured memory_bytes: 37212
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> A >> B;
    if(A == B) {
    	cout << "Draw\n";
    	quit;
    }
    if(A == 1) {
    	cout << "Alice\n";
    }
    else if(B == 1) {
    	cout << "Bob\n";
    }
    else {
    	if(A > B) {
    		cout << "Alice\n";
    	}
    	else if(A == B) {
    		cout << "Draw\n";
    	}
    	else {
    		cout << "Bob\n";
    	}
    }
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    char c; cin >> c;

    if (isupper(c)) cout << "A" << endl;
    else cout << "a" << endl;
    
    return 0;
}


Measured memory_bytes: 3624