akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Point {
    int x, y;

    Point() {}
    Point(int x, int y) : x(x), y(y) {}
};

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

    Point p1(0, 0), p2, p3;

    int low = 0;
    int high = 1000000000;
    int mid = (low + high) / 2;
    while (high - low > 1) {
        int value = mid * mid;
        if (value >= S) {
            high = mid;
        } else {
            low = mid;
        }
        mid = (low + high) / 2;
    }

    p2.x = high;
    p3.y = high;

    p2.y = 1;

    int diff = high * high - S;
    int loop = sqrt(diff);
    REP(i, 2, loop) {
        if (diff % i == 0) {
            diff /= i;
            p2.y = i;
            break;
        }
    }

    p3.x = diff;

    printf("%lld %lld %lld %lld %lld %lld\n", p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);

    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B>C+D){cout << "Left" << endl;}
  else if(A+B==C+D){cout << "Balanced" << endl;}
  else if(A+B<C+D){cout << "Right" << endl;}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

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

  map<pair<ll, ll>, ll> edge_number;
  unordered_map<ll, unordered_set<ll>> joint;

  rep (i, N - 1) {
    ll a, b;
    cin >> a >> b;
    edge_number[make_pair(a, b)] = i;
    edge_number[make_pair(b, a)] = i;
    joint[a].insert(b);
    joint[b].insert(a);
  }

  unordered_map<ll, unordered_set<ll>> seiyaku;

  ll M;
  cin >> M;
  rep (i, M) {
    ll u, v;
    cin >> u >> v;

    queue<pair<ll, unordered_set<ll>>> q;
    q.push(make_pair(u, unordered_set<ll>()));

    unordered_set<ll> checked;
    checked.insert(u);

    while (q.size()) {
      auto current = q.front();
      q.pop();
      if (current.first == v) {
        seiyaku[i] = current.second;
        break;
      }
      for (auto it: joint[current.first]) {
        if (checked.count(it)) continue;
        auto tmp_second = current.second;
        tmp_second.insert(edge_number[make_pair(current.first, it)]);
        q.push(make_pair(it, tmp_second));
        checked.insert(it);
      }
    }
  }

  unordered_map<ll, unordered_set<ll>> edge_included;

  for (auto it: seiyaku) {
    for (auto itit: it.second) {
      edge_included[itit].insert(it.first);
    }
  }

  for (auto it: edge_included) { cerr << it.first << ":"; for (auto itit: it.second) { cerr << " " << itit; } cerr << endl; }

  unordered_map<bitset<30>, ll> aaa;
  aaa[bitset<30>()] = 1;

  rep (i, N-1) {
    unordered_map<bitset<30>, ll> next;
    for (auto it: aaa) {
      next[it.first] += it.second;
      auto tmp = it.first;
      for (auto s: edge_included[i]) tmp[s] = true;
      next[tmp] += it.second;
    }
    aaa = next;
  }

  bitset<30> query;
  rep (i, M) query[i] = true;
  cout << aaa[query] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 82344
n,m = map(int,raw_input().split())
for i in range(0,n):
    if i == 0:
        matrix = [map(int,raw_input().split())]
    else:
        matrix.append(map(int,raw_input().split()))
vec=[]
for j in range(0,m):
    vec.append(raw_input())
mul = []
for k in range(0,n):
    num_sum=0
    for l in range(0,m):
        num_sum += matrix[k][l] * int(vec[l])
    print num_sum



Measured memory_bytes: 4824
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int gcd(int a, int b) {
  if (a < b) swap(a, b);
  int c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}
int main() {
  int k;
  cin >> k;
  vector<vector<int>> g(k, vector<int>(k));
  for (int i = 1; i <= k; ++i) {
    for (int j = i; j <= k; ++j) {
      g.at(i-1).at(j-1) = gcd(i, j);
      g.at(j-1).at(i-1) = gcd(i, j);
    }
  }
  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      int t = g.at(i-1).at(j-1);
      for (int l = 1; l <= k; ++l) {
        ans += g.at(t-1).at(l-1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  YesNo( N/10 == 9 || N%10 == 9);
  return 0;
}


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

using namespace std;

typedef long long ll;
  
int main(){
  int N;
  cin >> N;
  ll ans = 0;
  int a;
  for(int i = 0; i < N; i++){
    cin >> a;
    while(a % 2 == 0){
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;
 
int state[N];
int dp[5000][1005];
 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    
    int n,m;
    cin>>n>>m;

    int cost[m+1];

    for(int i=0;i<5000;i++) for(int j=0;j<1005;j++) dp[i][j]=mod;

    for(int i=1;i<=m;i++) {
        int q;
        cin>>cost[i]>>q;
        for(int j=0;j<q;j++) {
            int x;
            cin>>x;
            state[i]|=(1<<(x-1));
        }

    }

    dp[0][0]=0;

    for(int i=0;i<(1<<n);i++) {
        for(int j=1;j<=m;j++) {
            dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            dp[i|state[j]][j] = min(dp[i|state[j]][j], dp[i][j-1]+cost[j]);
        }
    }
    int ans=dp[(1<<n)-1][m];
    
    cout<<(ans==mod?-1:ans);
 
    return 0;
}


Measured memory_bytes: 19840
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define maximum(x,y) ((x>y)?x:y)


int main()
{
	long long int a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	long long int f[4], temp;
	temp = maximum(maximum(a * c, a * d), maximum(b * c, b * d));



	printf("%lld\n", temp);


	return 0;
}

Measured memory_bytes: 1700
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1000000000001010;
int main(){
int n;cin>>n;
map<int,int> mp;
rep(i,n){
    int a;
    cin>>a;
    mp[a]=i+1;
}
for(auto p:mp)cout<<p.second<<" ";
cout<<endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  do {
    n /= k;
    ans++;
  } while (n);
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
a = list(map(int,input().split()))
d = deque()
for i in range(1,200001):
  d.append(i)
count=0
for i in a:
  if i==d[0]:
    count+=1
    d.popleft()
    
if count==0:
  print(-1)
else:
  print(N-count)

Measured memory_bytes: 33980
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;


int main() {
	ll a, b, x; cin >> a >> b >> x;
	ll ans;
	if (a > 0)  ans = b / x - (a - 1) / x;
	else ans = b / x + 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }


bool check(string str)
{
      // DEBUG(str);
  if(str.size()%2 != 0) return false;

  int s = str.size();
  bool ok = true;
  for (int i = 0; i < str.size()/2; i++)
  {
    if(str[i] != str[s/2 + i]) ok = false;

  }
  return ok;
  
}

void solve(void)
{
  string str;
  cin>>str;
  str.erase(str.end()-1);
  bool ok = 0;
  while(str.size() != 0)
  {
    if(check(str))
    {
      ok = 1;
      break;
    }
    str.erase(str.end()-1);
  }

  cout<<str.size()<<endl;

  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[1000000000*2];
		int a = sc.nextInt();
		int b = sc.nextInt();
		//System.out.println((int)Math.floor(1.5));
		for (int i=1;100000000>i;i++) {
			double c = i*0.08;
			//System.out.println((int)c);
			if((int)Math.floor(c)== a) {
				double d = i*0.1;
				if((int)Math.floor(d)== b) {
					System.out.println(i);
					System.exit(0);
				}
			}
		}
		System.out.println("-1");
	}
}

Measured memory_bytes: 25300
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int K,S;
  cin >> K >> S;
  int ans = 0;

  for (int x = 0; x <= K; x++){
    for (int y = 0; y <= K; y++){
      int z = S - x - y;
      if(0 <= z and z <= K){
        ans++;
      } 
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main()
{  
    int x,k;
    cin >> k >> x;
    for(int i = x-k+1; i <= x+k-1; i++){
        cout << i << endl;
    }
    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int[] arr = new int[n];

                for (int i = 0; i < n; i++)
                {
                    arr[i] = int.Parse(Console.ReadLine());
                }
                sb.AppendLine(Count(arr).ToString());
            }
            Console.Write(sb);
        }

        static int Count(int[] arr)
        {
            int ret = 0;
            bool flg = true;

            for (int i = arr.Length - 1; flg; i--)
            {
                flg = false;

                for (int j = 0; j < i; j++)
                {
                    if (arr[j] > arr[j + 1])
                    {
                        int temp = arr[j];
                        arr[j] = arr[j + 1];
                        arr[j + 1] = temp;

                        flg = true;
                        ret++;
                    }
                }
            }
            return ret;
        }
    }
}

Measured memory_bytes: 9176
function Main(input){
	input = input.split(" ").map(a=>~~a);
  return (input[0]==input[1]&&input[1]==input[2])?"Yes":"No";
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
2 2 2
`);

Measured memory_bytes: 22076
#include<stdio.h>

int main(){
  int key, i, j, N, A[1000];
  scanf("%d", &N);
  for(i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  
  for(j=0; j<N; j++){
    if(j > 0){
      printf(" ");
    }
    printf("%d", A[j]);
  }
  printf("\n");
  
  for(i=1; i<N; i++){
    key = A[i];
    j = i-1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    
    for(j=0; j<N; j++){
      if(j > 0) printf(" ");
      printf("%d", A[j]);
    }
    printf("\n");
    
  }

  return 0;
}

Measured memory_bytes: 608
<?php
$s = trim(fgets(STDIN));


$length = 3;
$end = 2;
$start = 0;
$max_length = strlen($s);
if ($max_length == 2) {
	if ($s[0] === $s[1]) {
		echo '1 2';
		exit(0);
	}
	echo '-1 -1';
}else{
	while ($end < $max_length) {
		$str = substr($s, $start, $length);
		if ($str[0] === $str[1] || $str[1] === $str[2] || $str[0] === $str[2]) {
			echo ($start+1) . ' ' . ($end + 1);
			exit(0);
		}
		$start += 1;
		$end += 1;
	}
	echo '-1 -1';
}


Measured memory_bytes: 4604
A, B, K = map(int, input().split())
x = A
y = B
ans = set()
for _ in range(K):
  if A <= x <= B:
    ans.add(x)
  if A <= y <= B:
    ans.add(y)
  x += 1
  y -= 1

ans = sorted(ans)
print(*ans, sep='\n')

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

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

const int jt=924844033,rg=5;

int n;
vector<int> nei[1<<19];
int f[1<<19],g[1<<19],sz[1<<19];
int jc[1<<19],fjc[1<<19];
int hoddie[1<<19];

int ksmii(int a,int b){
	if(!b)return 1;
	int x=ksmii(a,b>>1);
	x=1ll*x*x%jt;
	if(b&1)x=1ll*x*a%jt;
	return x;
}

void fft(int a[],int inv){
	loop(i,1<<19)hoddie[i]=((hoddie[i>>1]>>1)|((i&1)<<18));
	loop(i,1<<19)if(i<hoddie[i])swap(a[i],a[hoddie[i]]);
	range(i,1,(1<<19)-1,i){
		int omega=ksmii(rg,(jt-1)+inv*(jt-1)/(i<<1));
		range(j,0,(1<<19)-1,i<<1){
			int omg=1;
			loop(k,i){
				int x=a[j+k],y=1ll*omg*a[j+k+i]%jt;
				a[j+k]=(x+y)%jt;
				a[j+k+i]=(x-y+jt)%jt;
				omg=1ll*omg*omega%jt;
			}
		}
	}
	if(inv==-1){
		int rn=ksmii(1<<19,jt-2);
		loop(i,1<<19)a[i]=1ll*a[i]*rn%jt;
	}
}

void dfs(int now,int lst){
	sz[now]=1;
	foreach(i,nei[now]){
		if(*i==lst)continue;
		dfs(*i,now);sz[now]+=sz[*i];
		f[sz[*i]]++;
	}
	f[n-sz[now]]++;
}

int main(){
	scanf("%d",&n);
	cont(i,n-1){
		int a,b;scanf("%d%d",&a,&b);
		nei[a].pub(b);nei[b].pub(a);
	}
	jc[0]=1;cont(i,n)jc[i]=1ll*jc[i-1]*i%jt;
	fjc[n]=ksmii(jc[n],jt-2);range(i,n,1,-1)fjc[i-1]=1ll*fjc[i]*i%jt;
	dfs(1,0);cont(i,n)f[i]=1ll*f[i]*jc[i]%jt,g[i]=fjc[n-i];
	fft(f,1);fft(g,1);loop(i,1<<19)f[i]=1ll*f[i]*g[i]%jt;fft(f,-1);
	cont(i,n){
		int ans=1ll*n*jc[n]%jt*fjc[i]%jt*fjc[n-i]%jt;
		ans=(ans+jt-1ll*f[n+i]*fjc[i]%jt)%jt;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 43900
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))

ans = 0
for j in b:
    #aについてにぶたん
    left = -1
    right = n 
    while(right - left > 1):
        center = (right + left)//2
        if a[center]  < j:
            left = center
        else:
            right = center
    #cについてにぶたん
    l = -1
    r = n 
    while(r - l > 1):
        ce = (r+l)//2
        if c[ce] <= j:
            l = ce
        else:
            r = ce
    ans += right * (n - r)

print(ans)
    

Measured memory_bytes: 24012
#include <iostream>
#include <map>
#include <limits>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a;
    while (cin>>n, n) {
        map<int,int> m;
        for (int i=0; i<n; ++i) {
            cin >> a; ++m[a];
        }
        int res = -1;
        for (map<int,int>::iterator it=m.begin(); it!=m.end(); ++it) {
            if (n < it->second*2) {
                res = it->first;
                break;
            }
        }
        if (res < 0) {
            cout << "NO COLOR" << endl;
        } else {
            cout << res << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#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 setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int flag=-1;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	if(s1.length()>s2.length()){
		cout<<"GREATER";
	}
	else if(s1.length()<s2.length()){
		cout<<"LESS";
	}
	else{
		REP(i,0,s1.length()-1){
			if(s1[i]>s2[i]){
				flag=1;
				break;
			}
			else if(s1[i]<s2[i]){
				flag=0;
				break;
			}
			else flag=2;
		}
	
	}
	if(flag==0)cout<<"LESS";
	else if(flag==1)cout<<"GREATER";
	else if(flag==2)cout<<"EQUAL";
	return 0;

//   TimeTaken();
}


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

int main() {
  int YABAI, WAYO, MRKT = 0;
  string TKSS, EKSA, LAPLAND;
  cin >> YABAI >> WAYO;
  
  vector<string> OOTJNY(100);
  
  for(int YUNI = 0; YUNI < YABAI; YUNI++){
    cin >> OOTJNY.at(YUNI);
  }
  for(int YUNI = 0; YUNI < WAYO; YUNI++){
    EKSA += "#";
  }
  cout << "#" << EKSA << "#" << endl;
    
  for(int YUNI = 0; YUNI < YABAI; YUNI++){
    cout << "#" << OOTJNY.at(YUNI) << "#" << endl;
  }
  cout << "#" << EKSA << "#" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
int coin[4] = {25,10,5,1};

int main(){

	scanf("%d",&N);

	int ans = 0;

	for(int i = 0; i < 4; i++){

		ans += N/coin[i];
		N %= coin[i];
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rng(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)
#define repd(i, n) for(int i = (int)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(int i = (int)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using ll =long long;

int main() {
  int ans=0;
  int a,b,k;
  cin>>a>>b>>k;
  int n=min(a,b);
  repd(i,n+1){
    if(a%i==0 && b%i==0){
      k--;
      ans=i;
      if(k==0){
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import pdb
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M,C = map(int, input().split())
    BS = list(map(int, input().split()))
    ans = 0
    for _ in range(N):
        AS = list(map(int, input().split()))
        total = C
        for i in range(M):
            total += AS[i]*BS[i]
        if total > 0: ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
#define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

const ll MOD = 1e9 + 7;
const ll maxn = 2e5 + 5;
const ll INF = 1e18;

void solve(){
    int n;
    cin >> n;
    vi v(n);
    for(int i=0;i<n;i++){
	    cin >> v[i];
	    
	    v[i] =(v[i]-(i+1));
    }
    sort(all(v));
    ll ans =0;
    
    for(int i=0;i<n;i++){
	ans += abs(v[i] -(v[(n-1)/2]));
    }
    cout << ans;
    
}
int main() {
    IOS
        solve();
    cerr << endl << "[ Time : " << (float) clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>
int main(){
   char o[51],e[51];scanf("%s%s",o,e);
   for(int i = 0;i < strlen(o)-(strlen(o)>strlen(e)?1:0);i++)
      printf("%c%c",o[i],e[i]);
   if(strlen(o)>strlen(e))printf("%c\n",o[strlen(o)-1]);
   return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();

		System.out.println(R/d-(L-1)/d);
		sc.close();
	}
}


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

using namespace std;



int main(){


 
 ios_base::sync_with_stdio(NULL); 
 cin.tie(0);
  #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif

  
 string s;
  cin>>s;
  int n = s.length();
  string t = string(n,'x');
  cout<<t<<endl;





}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N, Q = map( int, input().split())
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map( int, input().split())
        a, b = a-1, b-1
        E[a].append(b)
        E[b].append(a)
    V = [0]*N
    for _ in range(Q):
        p, x = map( int, input().split())
        p -= 1
        V[p] += x
    q = deque([0])
    W = [0]*N
    W[0] = 1
    while q:
        v = q.popleft()
        c = V[v]
        for t in E[v]:
            if W[t] == 1:
                continue
            V[t] += c
            W[t] = 1
            q.append(t)
    print( " ".join( map( str, V)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 121804
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap().chars().collect::<Vec<char>>();

    let mut part = Vec::new();

    let mut ans: Vec<usize> = Vec::with_capacity(s.len());

    let n = s.len();
    for i in 0..n {
        part.push(s[i]);
        if i >= n - 1 || (s[i] == 'L' && s[i + 1] == 'R') {
            let mut a = calc(&part);
            ans.append(&mut a);
            part = Vec::new();
        }
    }

    return ans.iter().map(|x| format!("{} ", x)).collect::<String>().trim().to_string();
}

fn calc(part: &Vec<char>) -> Vec<usize> {
    let l_position = part.iter().position(|&ch| ch == 'L').unwrap();
    let l_count = part.len() - l_position;
    let r_count = part.len() - l_count;

    let mut result = vec![0; part.len()];
    result[l_position - 1] = (r_count + 1) / 2 + l_count / 2;
    result[l_position] = r_count / 2 + (l_count + 1) / 2;
    result
}


Measured memory_bytes: 6524
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    long long A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    long num=min(X,Y);
    long sum=0;
    sum += min(2*(C),A+B)*num;
    if(X-num>0){
        sum += min(A,2*C)*(X-num);
    }
    if(Y-num>0){
        sum += min(B,2*C)*(Y-num);
    }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD 1000000007
#define fi first
#define se second
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define repe(i,n) for(int i = 0 ; i <= n ; i++)
#define repb(i,a,b) for(int i = a ; i < b ; i++)
#define repeb(i,a,b) for(int i = a ; i <= b ; i++)
#define rfor(i,n,a) for(int i = n ; i >= a ; i--)
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define pii pair<int,int> 
#define pll pair < long long, long long >
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a,b) cout << a << " " << b << endl
#define p3(a,b,c) cout << a << " " << b << " " << c << endl
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());
#define sortby(v,prop) sort( v.begin( ), v.end( ), [ ]( const auto& lhs, const auto& rhs ){ return lhs.prop < rhs.prop; });
#define rsortby(v,prop) sort( v.begin( ), v.end( ), [ ]( const auto& lhs, const auto& rhs ){ return lhs.prop > rhs.prop; });

ll modPower(ll num,ll r){
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) { 
    ll res = 1; 
    if (r > n - r) {
        r = n - r; 
    }
    rep(i,r) { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
    return res; 
}

bool isPrime(long long n)
{
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
 
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
 
    return true;
}


/*-------------------------------------------------*/

void solve() {

	ll n, k;
	cin >> n >> k;
	ll a[n];
	rep(i,n) {
		cin >> a[i];
	}

	sort(a,a+n);
	ll sum = 0;
	rep(i,k) {
		sum += a[i];
	}

	p1(sum);
}


int main()
{
	fastio;
	solve();
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int n;
    int a=1;
    cin>>n;
    FOR(i,1,n){
        if(i*i>n) {
            a=i-1;
            break;
        }    
    }
    cout<<a*a<<endl;
    return 0;
}

Measured memory_bytes: 256
local function meld(a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

local function pair(a)
    local b=a and a[4]
    if not b then
        return a
    end
    local q={}
    while b do
        local c=b[4]
        a[4]=false
        b[4]=false
        table.insert(q,meld(a,b))
        a=c
        b=a and a[4]
    end
    for i=#q,1,-1 do
        a=meld(a,q[i])
    end
    return a
end


local PairingHeap={}

PairingHeap.empty=function(self)
    return not self[1]
end

PairingHeap.push=function(self,k,v)
	if not self[1] then
		self[1]={
            k,
            v,
            false,
            false,
		}
	else
		if self[1][1]<k then
			self[1][3]={
				k,
				v,
				false,
				self[1][3],
			}
		else
			self[1]={
				k,
				v,
				self[1],
				false,
			}
		end
	end
end

PairingHeap.top=function(self)
    return self[1][2]
end

PairingHeap.pop=function(self)
    self[1]=pair(self[1][3])
end

PairingHeap.join=function(self,other)
	if self[1][1]<other[1][1]then
		other[1][4]=self[1][3]
        self[1][3]=other[1]
	else
		self[1][4]=other[1][3]
        other[1][3]=self[1]
        self[1]=other[1]
    end
    return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local n,d,a=io.read("n","n","n")
local pq=PairingHeap:new()
for i=1,n do
    local x,h=io.read("n","n")
    pq:push(x,{x,h,0})
end

local atack=0
local total=0
while not pq:empty() do
    local top=pq:top()
    local x,h,c=top[1],top[2],top[3]
    pq:pop()
    if c==0 then
        if atack*a<h then
            h=h-atack*a
            local count=math.floor((h-1)/a)+1
            pq:push(x+2*d+0.5,{x+2*d,count,1})
            total=total+count
            atack=atack+count
        end
    else
        atack=atack-h
    end
end
print(string.format("%d",total))

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


void solve(long long N){
    cout << (N<1000 ? "ABC" : "ABD") << endl;
}

// Generated by 1.1.4 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 N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//public class atcoder0221_B{
public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();

		int result2 = N;
		int result = 0;

		do {
			result2=result2/K;
			result++;
		}while(result2!=0);

		System.out.println(result);
	}
}

Measured memory_bytes: 23124
//Suplex
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int T,a,b,c,d,k,AB;
long long resta,restb;
 
int main()
{
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int l=0,r=a+b+1;k=(max(a,b)-1)/(min(a,b)+1)+1;
		while(l<r){
			int mid=(l+r)>>1;
			resta=a-mid/(k+1)*k-mid % (k+1);
			restb=b-mid/(k+1);
			if(restb<=1ll*resta*k) l=mid+1;else r=mid;
		}
		resta=a-r/(k+1)*k-r % (k+1);
		restb=b-r/(k+1);AB=r+restb-resta*k+1;
		for(int i=c;i<=min(d,r);i++) putchar(i % (k+1) ? 'A' : 'B');
		for(int i=max(c,r+1);i<=d;i++) putchar((i-AB) % (k+1) ? 'B' : 'A');
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++){
			a[i] = scn.nextInt();
		}
      	Arrays.sort(a);
      	int c = a[0];
    	int count = 0;
    	int ans =0;
    	for(int i=0;i<n;i++){
      		if(c==a[i]){
       			count++;
      		}else{
        		c = a[i];
        		if(count%2==1){
          			ans++;
        		}
        		count=1;
      		}
    	}
      	if(count%2==1){
      		ans++;
    	}
     	System.out.println(ans);
	}
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        string s;
        cin>>s;
        int sum=0;
        for(int i=0;i<s.length();i++){
        	sum+=(s[i]-'0');
        }
        if(sum%9==0)
        	cout<<"Yes"<<endl;
        else
        	cout<<"No"<<endl;

    }
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n , a, b ;
  cin >> n >> a >> b ;
  int cnt1 = 0 ;
  int cnt2 = 0 ;
  int cnt3 = 0 ;
  REP(i,n){
    int c ;
    cin >> c ;
    if(c<=a){
      cnt1++ ;
    }
    else if(a<c && c<=b){
      cnt2++ ;
    }
    else{
      cnt3++ ;
    }
  }
  
  cout << min({cnt1,cnt2,cnt3}) <<endl ;
    


  return 0 ;
}




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


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli r;
	cin >> r;
	COUT(3*r*r);

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left

def solve():
    n = int(input())
    ans = [0] * n
    a = [int(x) for x in input().split()]
    ok = 1
    cur = n - 1
    while ok and a:
        ok = 0
        i = len(a) - 1
        while i >= 0:
            if a[i] - 1 == i:
                ok = a[i]
                a.pop(i)
                break
            i -= 1
        ans[cur] = ok
        cur -= 1

    if a:
        print(-1)
    else:
        for e in ans:
            print(e)
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


Measured memory_bytes: 9988
/*

   Author : sea_26

*/

#include<bits/stdc++.h>

using namespace std;

#define vsort(v)   sort(v.begin(),v.end())
#define M          1000000007
#define PI         acos(-1.0)
#define bitc(n)    __builtin_popcount(n)
#define fill(a,x)  memset(a,x,sizeof(a))
#define fastScan   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);


#define db  double
#define ldb long double
#define ll  long long


#define mpa  make_pair
#define pf  push_front
#define vp  vector<int> v


#define rep(i,n)       for(int i=1;i<n;i++)
#define repm(i,m)      for(int i=0;i<=m;i++)
#define repp(i,a,b)    for(int i=a;i<b;i++)
#define reff(i,a,b)    for(int i=a;i>=b;i--)


int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b));}
ll lcm(int a, int b) { return (a * (b / gcd(a, b)));}
ll max(ll a,ll b,ll c){return max(a,max(b,c));}

const int INF = INT_MAX;

int a[125];
int main(){

    int k;
    bool flag = true;
    cin >> a[0];
    rep(i,5){
        cin >> a[i];
        if(a[i]<a[i-1]){
            flag = false;
            break;
        }
    }
    cin >> k;

    for(int i=0;i<=4;i++)
    for(int j=i;j<=4;j++){
        if(a[j]-a[i]>k){
            flag = false;
            break;
        }
    }

    if(flag) cout << "Yay!" << endl;
    else cout << ":(" << endl;



return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#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 fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string d;
    cin >> d;
    int ans;
    if (d == "SUN") ans = 7;
    else if (d == "MON") ans = 6;
    else if (d == "TUE") ans = 5;
    else if (d == "WED") ans = 4;
    else if (d == "THU") ans = 3;
    else if (d == "FRI") ans = 2;
    else ans = 1;
    cout << ans << '\n';
}

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

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

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

int main() {
  int n, x, y;
  const int mod(1000000007);
  cin >> n;
  vector<vector<int>> trees(n);
  int subtrees[n];
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    trees[x - 1].push_back(y - 1);
    trees[y - 1].push_back(x - 1);
  }
  
  auto power = [&](long a, long b){
    long r(1);
    while(b){
      if (b % 2) r = r * a % mod;
      a = a * a % mod;
      b /= 2;
    }
    return r;
  };
  
  long fac[n], invfac[n], sub[n], f[n], g[n], ans[n];
  for (int i = 0; i < n; ++i) {
    fac[i] = i ? fac[i-1] * i % mod : 1L;
    invfac[i] = power(fac[i], mod - 2);
  }
  auto mod_add = [&](const long& a, const long& b){return (a + b) % mod;};
  auto mod_mul = [&](const long& a, const long& b){return a * b % mod;};
  auto mod_div = [&](const long& a, const long& b){return a * power(b, mod - 2) % mod;};
  function<void(int, int)> root = [&](int i, int p) {
    f[i] = sub[i] = 1;
    for(const int& j: trees[i]){
      if (j == p) continue;
      root(j, i);
      f[i] = mod_mul(f[i], f[j]);
      f[i] = mod_div(f[i], fac[sub[j]]);
      sub[i] += sub[j];
    }
    f[i] = mod_mul(f[i], fac[sub[i] - 1]);
  };
  function<void(int, int)> reroot = [&](int i, int p){
    g[i] = 1;
    if (p != -1) {
      g[i] = mod_mul(mod_mul(fac[sub[i]], fac[n-sub[i]-1]), mod_mul(f[p], g[p]));
      g[i] = mod_div(g[i], mod_mul(f[i], mod_mul(fac[sub[p]-1], fac[n - sub[p]])));
    }
    for(const int& j: trees[i]){
        if(j==p)continue;
        reroot(j,i);
    }
    ans[i]=mod_mul(f[i],mod_mul(g[i],fac[n-1]));
    ans[i]=mod_div(ans[i],mod_mul(fac[sub[i]-1], fac[n-sub[i]])); 
  };
  root(0, -1);
  reroot(0, -1);
  for (int i = 0; i < n; ++i)
    cout << ans[i] << '\n';
  return 0;  
}   

Measured memory_bytes: 23284
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int p, z, a;
	p = 9990;
	z = 9990;
	for (int i = 1; i <= 3; i++) {
		cin >> a;
		p = min(a, p);
	}
	for (int i = 1; i <= 2; i++) {
		cin >> a;
		z = min(a, z);
	}
	cout << z + p - 50 << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)

// *start on @date: 2020-05-11 17:52

const int N = 1e6 + 5;

string s;

struct str
{
    int l, r;
} a[N], b[N];

bool cmp2(str a,str b)
{
    return a.l>b.l;
}

bool cmp1(str a,str b)
{
    return a.r<b.r;
}

int main()
{
    IOS;
    int n;
    cin >> n;
    int at = 0, bt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        int ln = 0, rn = 0;
        for (int j = 0; s[j]; j++)
        {
            if (s[j] == '(')
                ln++;
            else if (s[j] == ')'&&ln>0)
                ln--;
            else
                rn++;
        }
        if (ln >= rn)
            a[at++] = (str){ln, rn};
        else
            b[bt++] = (str){ln, rn};
    }
    sort(a,a+at,cmp1);
    sort(b,b+bt,cmp2);
    int suml=0;
    for(int i=0;i<at;i++)
    {
        if(suml<a[i].r)
        {
            cout<<"No";
            return 0;
        }
        suml-=a[i].r;
        suml+=a[i].l;
    }
    for(int i=0;i<bt;i++)
    {
        if(suml<b[i].r)
        {
            cout<<"No";
            return 0;
        }
        suml-=b[i].r;
        suml+=b[i].l;
    }
    if(suml==0)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 11296
def main():
  n=int(input())
  l=list(map(int,input().split()))
  l.sort()
  import bisect
  ans=0
  for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
      a=l[i]
      b=l[j]
      idxl=bisect.bisect_right(l,a-b)
      ans+=max(j-idxl,0)
  print(ans)
if __name__=='__main__':
  main()


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    string s; cin >> s; s.pop_back();
    while(1){
        if(s.size()%2==1){s.pop_back(); continue;}
        string t = s.substr(0,s.size()/2);
        if(s==t+t){out(s.size()); return 0;}
        s.pop_back();
    }

    return 0;
}

Measured memory_bytes: 256