akhauriyash/Code-Regression huggingface dataset:
N,K = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
K = bin(K)[2:]
K = "0"*(30-len(K))+K
A = [bin(X[i][0])[2:] for i in range(N)]
A = ["0"*(30-len(A[i]))+A[i] for i in range(N)]
F = [K]
for i in range(30):
    if K[i]=="1":
        x = K[:i]+"0"+"1"*(30-i-1)
        F.append(x)
G = []
for f in F:
    g = []
    for i in range(30):
        if f[i]=="0":
            g.append(i)
    G.append(g)
cmax = 0
for g in G:
    cnt = 0
    for i in range(N):
        a = A[i]
        flag = 0
        for j in g:
            if a[j]!="0":
                flag = 1
                break
        if flag==0:
            cnt += X[i][1]
    cmax = max(cmax,cnt)
print(cmax)

Measured memory_bytes: 114076
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  string s;cin>>s;
  int n=(int)s.size();
  if(n<5 || n>9){cout<<"NO"<<endl;return 0;}
  if(s[0]=='A'){s=s.substr(1, n-1);n--;}
  if(s.substr(0, 3)!="KIH"){cout<<"NO"<<endl;return 0;}
  s=s.substr(3, n-3);n-=3;
  if(s[0]=='A'){s=s.substr(1, n-1);n--;}
  if(s=="BR" || s=="BAR" || s=="BARA" || s=="BRA")cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

vector<pair<ll,ll>> f(ll n){
    vector<pair<ll,ll>> p;
    for(ll i = 2;i * i<=n;++i){
        if(n%i == 0){
            ll tmp = 0;
            while(n%i == 0){
                n/=i;
                tmp++;
            }
            p.push_back(make_pair(i,tmp));
        }
    }
    if(n != 1) p.push_back(make_pair(n,1));
    return p;
}



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

    ll n;
    cin >> n;
    vector<pair<ll,ll>> p;
    p = f(n);
    ll ans = 0;
    for(auto pp : p){
        ll a = pp.second;
        ll x = 1;
        
        while(a >= x){
            a-=x;
            x++;
            ans++;
        }
    }
    cout << ans << endl;
    

    cout << endl;
    return 0;
}


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

using namespace std;

int main()
{  char str[20];
   //cout<<"enter the sentence not more than 19 character:";
   cin.getline(str,20);
   str[5]=',';
   str[13]=',';
   int i=0;
  while(str[i]!='\0')
  {
      if (str[i]==','){str[i]=' ';}
      else if (isupper(str[i]))
            str[i] = tolower(str[i]);
      //else str[i]='xx';

     i++;
  }
        cout <<str<< endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define PI 3.14159265359

int main(int argc, char **argv)
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double theta_m = 6 * M;
    double theta_h = 30 * H + 0.5 * (double)M;
    double theta;
    if (theta_m < theta_h) theta = theta_h - theta_m;
    else theta = theta_m - theta_h;

    //if (theta > 180) theta -= 180;
    theta = theta * PI / 180;

    double a = A * A + B * B - 2 * A * B * cos(theta);
    cout << setprecision(10) << sqrt(a) << endl;

    return 0;
}


Measured memory_bytes: 4208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a, b, c;
lli rest;
int main() {
  cin >> n;
  read_n(a, n); read_n(b, n); init_n(c, n);
  for (lli i=0; i<n; ++i) c[i] = a[i] - b[i];
  sort(begin(c), end(c));
  lli cnt = 0;
  for (lli i=0; i<n; ++i) {
    if (c[i] < 0) {
      rest += -c[i];
      ++cnt;
    }
  }
  for (lli i=n-1; i>=0 && rest > 0; --i) {
    if (c[i] >= 0) {
      rest -= c[i];
      ++cnt;
    } else {
      cout << -1 << endl; return 0;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	float a[1005];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	sort(a,a + N);
	float ram = (a[0] + a[1]) / 2;
//	cout << ram << endl;
	for(int i = 2; i < N; i++){
		ram = (ram + a[i]) / 2;
//		cout << ram << endl;
	}
	cout << ram;
}

Measured memory_bytes: 256
alfabets = [chr(i) for i in range(97,97+26)]
a = []
s = input()
for i in s :
    a += i
s1 = set(alfabets)
s2 = set(a)
aaa = s1 - s2
alfabets = list(aaa)
alfabets.sort()
if alfabets == [] :
    print('None')
else : 
    print(alfabets[0]) 

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

const ll INFLL= (1LL << 61) - 1;
 
int main()
{
  int N;
  cin>>N;
  vector<ll>A(N),sum(N+1);
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum[i+1]=sum[i]+A[i];
  }
  ll ans=INFLL;
  ll a,b,c,d;
  int left=0, right=2;
  for(int i=1;i<N-1;i++){
    while(left<=i-1 && (sum[i+1]-sum[left+1]>=sum[left+1])){
      left++;
    }
    if(abs(2*sum[left]-sum[i+1])<abs(2*sum[left+1]-sum[i+1])){
      a=sum[left];
      b=sum[i+1]-sum[left];
      left--;
    }else{
      a=sum[left+1];
      b=sum[i+1]-sum[left+1];
    }
 
    while(right<=N-2 && (sum[N]-sum[right+1]>=sum[right+1]-sum[i+1])){
      right++;
    }
 
    if(abs(sum[N]+sum[i+1]-2*sum[right])<abs(sum[N]+sum[i+1]-2*sum[right+1])){
      c=sum[right]-sum[i+1];
      d=sum[N]-sum[right];
      right--;
    }else{
      c=sum[right+1]-sum[i+1];
      d=sum[N]-sum[right+1];
    }
    ans=min(ans,max({a,b,c,d})-min({a,b,c,d}));
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

  map<string, long long> m;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }

  long long ans = 0;
  for (auto e: m) {
    long long m = e.second - 1;
    ans += (m * (m + 1)) / 2;
  }

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



Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 100000 + 5;

int n,W;
int dp[maxn];

struct node{
	int w;
	int v;
}a[maxn];

inline void Solve (){
	for(int i = 1; i <= n; i++){
		for(int j = W; j >= a[i].w; j--){
			dp[j] = max(dp[j],dp[j - a[i].w] + a[i].v);	
		}	
	}
	printf("%lld\n",dp[W]);
}

inline void Input (){
	n = read<int>();
	W = read<int>();
	for(int i = 1; i <= n; i++){
		a[i].w = read<int>();
		a[i].v = read<int>();
	}
}

signed main(){
	Input();
	Solve();
	return 0;
}

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

bool is_prime(int num) {
  if (num <= 1) return false; 
  if (num == 2) return true;
  if (num % 2 == 0) return false;
  int square = sqrt(num) + 2;
  for(int i = 3; i <= square; i = i + 2) {
    if(num % i == 0) return false;
  }
  return true;
}

int prime(int a, int d, int n)
{
  int sum = a;
  int count = 0;
  
  while(true) {
    if(is_prime(sum)) count++;
    if(n == count) return sum;
    sum += d;
  }
}
  
int main() {
  int a, d, n;
  while(true) {
    cin >> a >> d >> n;
    if(a * d * n == 0) break;
    cout << prime(a, d, n) << endl;
  }
  return 0;
}

Measured memory_bytes: 2996
from math import ceil


def main():
    a, b = map(int, input().split())
    answer = 0
    if a < b:
        for i in range(a, ceil(a / 4) * 4):
            answer ^= i
        for i in range((b // 4) * 4, b + 1):
            answer ^= i
    else:
        answer = a
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


string bigger(const string& a, const string& b)
{
	if (a.size() > b.size() || a.size() == b.size() && a > b)
		return a;
	else
		return b;
}
int main()
{
	int w, h;
	char c[128][128];
	while (cin >> w >> h, w)
	{
		for (int i = 0; i < h; ++i)
			scanf("%s", c[i]);

		string res = "";
		string dp[128][128];
		for (int y = 0; y < h; ++y)
		{
			for (int x = 0; x < w; ++x)
			{
				if (isdigit(c[y][x]))
				{
					string t = bigger(dp[y][x + 1], dp[y + 1][x]) + c[y][x];
					if (t != "0")
					{
						dp[y + 1][x + 1] = t;
						res = bigger(res, t);
					}
				}
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, s, u, v, w, x, e[55] = {}, f[55] = {};
    ll d[55][5555] = {};
    priority_queue<pair<ll, pii>, vector<pair<ll, pii>>, greater<pair<ll, pii>>> q;
    pii a[55][55];
    cin >> n >> m >> s;
    s = min(s, 5000);
    for (int i = 1; i <= n; i++) for (int j = 0; j <= 5000; j++) d[i][j] = 1ll * mod * mod;
    while (m--) cin >> u >> v >> w >> x, a[u][v] = a[v][u] = {w, x};
    for (int i = 1; i <= n; i++) cin >> e[i] >> f[i], e[i] = min(e[i], 5000);
    q.push({0, {1, s}});
    d[1][s] = 0;
    while (!q.empty()) {
        u = q.top().second.first, v = q.top().second.second;
        q.pop();
        if (v + e[u] <= 5000 && d[u][v + e[u]] > d[u][v] + f[u]) {
            d[u][v + e[u]] = d[u][v] + f[u];
            q.push({d[u][v + e[u]], {u, v + e[u]}});
        }
        for (int i = 1; i <= n; i++) if (a[u][i].first && v >= a[u][i].first) {
            if (d[i][v - a[u][i].first] > d[u][v] + a[u][i].second) {
                d[i][v - a[u][i].first] = d[u][v] + a[u][i].second;
                q.push({d[i][v - a[u][i].first], {i, v - a[u][i].first}});
            }
        }
    }
    for (int i = 2; i <= n; i++) {
        ll z = 1ll * mod * mod;
        for (int j = 0; j <= 5000; j++) z = min(z, d[i][j]);
        cout << z << '\n';
    }
}


Measured memory_bytes: 9720
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
n=len(s)
anslst=[0]*n

cnt=0
for i in range(n):
    if s[i]=="R":
        cnt+=1
    else:
        anslst[i]+=cnt//2
        anslst[i-1]+=(cnt+1)//2
        cnt=0

for i in range(n)[::-1]:
    if s[i]=="L":
        cnt+=1
    else:
        anslst[i]+=cnt//2
        if i+1<n:
            anslst[i+1]+=(cnt+1)//2
        cnt=0

print(*anslst)

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

using namespace std;

int main() {
    int q, h, s, d; cin >> q >> h >> s >> d;
    int n; cin >> n;


    int best_unit = 4 * q;
    best_unit = min(best_unit, 2 * h);
    best_unit = min(best_unit, s);
    best_unit = min(best_unit, h + 2 * q);

    long long a1 = 1LL * best_unit * n;
    long long a2 = 1LL * d * (n / 2) + best_unit * (n % 2);
    cout << min(a1, a2) << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map(String::toInt).toMutableList()

  var sortedCount = 0
  var count = 0
  var flag = true
  while (flag) {
    flag = false
    (N - 1 downTo sortedCount + 1).forEach { i ->
      if (A[i] < A[i-1]) {
        val tmp = A[i]
        A[i] = A[i-1]
        A[i-1] = tmp
        flag = true
        count += 1
      }
    }
    sortedCount += 1
  }

  println(A.joinToString(" "))
  println(count)
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0) {
      cout << "No";
      return 0;
  } 

  cout << "Yes";
   return 0;
}

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

typedef long long int ll;

ll MOD = 1000000007;
ll INF = 100000000;

int main(){
 string S;
 cin >> S;
 int n = S.size();
 int R = count(S.begin(),S.end(),'0'),B = count(S.begin(),S.end(),'1');
 cout << n - abs(R-B) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>


struct pos {
	int x, y;
	pos(int xv, int yv) :x{ xv }, y{ yv }{}
};

int main() {

	constexpr static const auto inf = (1 << 30);

	auto put = [&](const auto&container) {

		for (const auto& e : container) {
			for (const auto& ee : e) {
				std::cout << ee<<" ";
			}std::cout << "\n";
		}

	};


	int H, W;
	std::cin >> H >> W;

	std::vector<std::string> tab(H);
	std::vector<std::vector<int>> count(H, std::vector<int>(W, inf));

	for (auto&e : tab)
		std::cin >> e;

	std::queue<pos> q;

	q.emplace(0,0);
	count[0][0] = 1;

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

	while (!q.empty()) {
		const auto p = q.front(); q.pop();

		//if (p.x == H - 1 && p.y == W - 1)
		//	break;


		for (int i{}; i < 4; ++i) {

			const int cx = p.x + dx[i];
			const int cy = p.y + dy[i];

			if (cx < 0 || cy < 0 || H <= cx || W <= cy)
				continue;

			if (tab[cx][cy] == '#')
				continue;


			if (count[cx][cy] > count[p.x][p.y] + 1) {
				count[cx][cy] = count[p.x][p.y] + 1;
				q.emplace(cx, cy);
			}
//			std::cout << count[cx][cy]<<" "<< cx << " " << cy << "\n";
//			put(count);
		}

	}


	if (count[H - 1][W - 1] == inf) {
		std::cout << "-1\n";
	}
	else {

		auto sum = 0;
		for (const auto&e : tab) {
			sum += std::count(std::begin(e), std::end(e), '.');
		}

		sum -= count[H - 1][W - 1];
		std::cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 504
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	s,w = MI()
	if (s <= w):
		print("unsafe")
	else:
		print("safe")

if __name__ == '__main__':
	main()

Measured memory_bytes: 9224
s = gets
f, c = 0, 0
p = []
0.upto(s.size - 1) do |i|
  if s[i] == 'R'
    if f == 1
      f = 0
      p.push(c)
      c = 0
    end
    c += 1
  else
    if f == 0
      f = 1
      p.push(c)
      c = 0
    end
    if i == s.size - 1
      p.push(c)
    end
    c += 1
  end
end
ans = ''
while p.size > 0
  x = p.shift
  y = p.shift
  if (x + y).even?
    (x - 1).times do
      ans.concat('0 ')
    end
    ans.concat(((x + y) / 2).to_s)
    ans.concat(' ')
    ans.concat(((x + y) / 2).to_s)
    ans.concat(' ')
    (y - 1).times do
      ans.concat('0 ')
    end
  elsif (x.even?)
    (x - 1).times do
      ans.concat('0 ')
    end
    ans.concat(((x + y) / 2).to_s)
    ans.concat(' ')
    ans.concat(((x + y) / 2 + 1).to_s)
    ans.concat(' ')
    (y - 1).times do
      ans.concat('0 ')
    end
  else
    (x - 1).times do
      ans.concat('0 ')
    end
    ans.concat(((x + y) / 2 + 1).to_s)
    ans.concat(' ')
    ans.concat(((x + y) / 2).to_s)
    ans.concat(' ')
    (y - 1).times do
      ans.concat('0 ')
    end
  end
end
puts ans

Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }

int main(){
	int n,k;cin>>n>>k;
	vector<ll> h(n);
	for(int i = 0; i < n; i++) {
		cin>>h[i];
	}
	vector<int> w(n,1);
	for(int i = 0; i < k; i++) {
		int a,b;cin>>a>>b;
		a--;b--;
		if(h[a] <= h[b])w[a] = 0;
		if (h[b] <= h[a])w[b] = 0;
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if (w[i] == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4576
N, M=map(int, input().split())
mod=10**9+7
def kaijou(x, mod):
  out=1
  for i in range(2, x+1):
    out*=i
    out%=mod
  return out

if N==M:
  print((((kaijou(N, mod)**2)%mod)*2)%mod)
  exit()
if abs(N-M)>1:
  print(0)
  exit()
  
print(((kaijou(N, mod)*kaijou(M, mod))%mod))

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

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	int score = -1;
	for ( int i = 0; i < 2; i++ ) {
	    int pscore = 0;
	    for ( int j = 0; j < 4; j++ ) {
		pscore += stdin.nextInt();
	    }
	    score = Math.max( score, pscore );
	}
	System.out.println( score );
    }    
}

Measured memory_bytes: 17168
#NC3 * 3!
from itertools import combinations
N = int(input())
L = list(map(int,input().split()))
#重複ありの線分集合L
edges = list(combinations(L,3))
#Lの組み合わせedges
count = 0
for i in edges:
    if i[0] < i[1] + i[2] and i[1] < i[2] + i[0] and i[2] < i[0] + i[1]:
        if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
            count += 1
print(count)

Measured memory_bytes: 20616
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


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

using namespace std;
using ll = long long;

#define M (1'000'000'007)

int hoge() { return 1; }

int main() {
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = max(a * c, b * d);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3216
import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]


#if __name__ == '__main__':
h, w = wi()
s = hs(h)
flagli = [[0] * w for i in range(h)]
stack = deque()
black = 0
white = 0
for i in range(h):
    for j in range(w):
        if flagli[i][j] == 0:
            flagli[i][j] = 1
            white = 1 if s[i][j] == "." else 0
            black = 1 if s[i][j] == "#" else 0
            stack.append([i, j])
            while stack != deque():
                p, q = stack.pop()
                k = 0 if s[p][q] == "." else 1
                for dx, dy in dd:
                    nx = q + dx;
                    ny = p + dy
                    if 0 <= nx < w and 0 <= ny < h:
                        if flagli[ny][nx] == 0:
                            if k == 0 and s[ny][nx] == "#":
                                flagli[ny][nx] = 1
                                stack.append([ny, nx])
                                black += 1
                            elif k == 1 and s[ny][nx] == ".":
                                flagli[ny][nx] = 1
                                stack.append([ny, nx])
                                white += 1
            ans += black * white
            black = 0
            white = 0
print(ans)

Measured memory_bytes: 14792
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
ll f[1000001];
ll bigmod(ll b,ll p ,ll m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        ll temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}
ll InverseEuler(ll n, ll MOD)
{
    return bigmod(n,MOD-2,MOD);
}
ll c(ll n, ll r, ll MOD)
{
 
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
int main()
{
 f[0] = 1;
 for(int i=1; i<=200000; i++)
   f[i] = (f[i-1]*i)%1000000007;
 int n;
 cin>>n;
 int a[n+10];
 int b[n+10];
 int st = 0 , En = 0;
 memset(b,0,sizeof(b));
 for(int i=1;i<=n+1;i++)
 {
     scanf("%d",&a[i]);
     if(b[a[i]]!=0)
     {
         st = b[a[i]];
         En = i;
     }
     b[a[i]] = i;
 }
 int mod = 1e9+7;
 cout<<n<<endl;
 for(int i=2;i<=n+1;i++)
 {
     ll ans = 0;
     ans = c(n+1,i,mod);
     if(st-1+(n+1-En) >= i-1)
     ans-=c(st-1+(n+1-En) , i-1,mod);
 
     if(ans < 0)
        ans+=mod;
     ans%=mod;
     cout<<ans<<endl;
 }
 
 
}

Measured memory_bytes: 3584
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

max_num = 0
j = 0
j_max = M
A_sums=[0]
B_sums=[0]
for i in range(N):
    A_sums.append(A_sums[i]+A[i])
for i in range(M):
    B_sums.append(B_sums[i]+B[i])


for i in range(N + 1):
    j = 0
    if A_sums[i]>K:
        break
    while A_sums[i]+B_sums[j_max] > K:
        j_max -=1

    max_num = max(max_num, i + j_max)
print(max_num)


Measured memory_bytes: 47376
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	char a[302][302];
	char next[302][302];
	rep(i, n) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}
	ll ans = 0;
	rep(plus, n) {
		rep(i, n) {
			rep(j, n) {
				next[i][j] = a[(plus + i) % n][j];
			}
		}
		bool flag = true;
		rep(i, n) {
			rep(j, n) {
				flag = flag && (next[i][j] == next[j][i]);
			}
		}
		if (flag) { ans++; }
	}
	cout << ans*n << endl;
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[100010][3];
int main(){
    int n;
    cin >> n;
    VVI point(n,VI(3,0));
    rep(i,n){
        rep(j,3){
            scanf("%d",&point[i][j]);
        }
    }

    rep(i,n){
        rep(j,3){
            dp[i+1][j] = max(dp[i][(j+1)%3], dp[i][(j+2)%3]) + point[i][j];
        }
    }
    ll ans = 0;
    rep(i,3) ans = max(ans,dp[n][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    vector<int> b = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<string> dp(10010, "-");
    dp[0] = "";

    rep(i, n - 1)
    {
        rep(j, m)
        {
            if (dp[i] == "-")
                break;
            string x = dp[i + b[a[j]]];
            string y = dp[i] + (char)('0' + a[j]);
            if (x.size() < y.size() || (x.size() == y.size() && x < y))
                dp[i + b[a[j]]] = y;
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 43776
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}




int main(){


  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j])continue;
      for(int k=j+1;k<n;k++){
        if(j-k!=i-j && s[k]!=s[i] && s[k]!=s[j])ans++;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if(a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

int main() {
  std::cout << std::setprecision(9);
  int n, k;
  cin >> n >> k;

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

  int left = 1;
  int right = max;
  double mid;
  while(left < right) {
    mid = (left + right) / 2;
    long cut = 0;
    for(int i=0; i<n; i++) {
      cut += ceil(a[i] / mid) - 1;
    }
    if(cut > k) {
      left = mid + 1;
    }
    else {
      right = mid;
    }
  }

  cout << (left + right) / 2 << endl;
}

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

int n;

int same[2][2] = {{0,1},{1,0}};

int inf[100010];

string mozi = "SW";

bool sim(vector<int>& vec)
{
	//cout << vec.size() << endl;
	if(vec.size() == n)
	{
		bool res = true;

		res = res && (2 + vec[n - 1] + vec[1]) % 2 == same[vec[0]][inf[0]];
		res = res && (2 + vec[n - 2] + vec[0]) % 2 == same[vec[n - 1]][inf[n - 1]];
		return res;
	}
	int i = vec.size() - 1;
	vec.push_back((2 + vec[i - 1] - same[vec[i]][inf[i]]) % 2);
	return sim(vec);
}

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

	for(int i = 0;i < n;i++)
	{
		if(s[i] == 'x')
		{
			inf[i] = 1;
		}
	}

	for(int i = 0;i <= 1;i++)
	{
		for(int j = 0;j <= 1;j++)
		{
			vector<int> v;
			v.push_back(i);
			v.push_back(j);
			if(sim(v))
			{
				for(int c : v)
				{
					cout << mozi[c];
				}
				return 0;
			}
		}
	}

	cout << -1;
	return 0;
}


Measured memory_bytes: 4952
#pragma optimize("O3")
#include <bits/stdc++.h>

#define f(i,a,b)    for(int i = a; i < b; i++)
#define pb push_back
#define F first
#define S second
#define ii pair<int, int>

using ll = long long;
using db = long double;

using namespace std;
const int N = 1e6 + 5;
int get(int x){
  int ans = 0;
  for(int j = 1; x >= j; x -= j, j++)
    ans++;
  return ans;
}
int calc(ll x){
  int ans = 0;
  for(ll i = 2; i * i <= x; i++)
  if(x % i == 0){
    int c = 0;
    while(x%i==0){
      c++;
      x/=i;
    }
    ans += get(c);
  }
  return ans + (x > 1);
}

int main(){

    ll x; cin >> x; cout << calc(x) << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int n; 
    while(cin>>n){
        vvi can(n, vi(n));
        forn(i,n)
            forn(j,n)
                cin>>can[i][j];
        
        vi dp(1<<n);
        dp[0] = 1;

        for(int mask=0; mask<(1<<n)-1; ++mask){
            int boy = __builtin_popcount(mask);
            for(int girl = 0; girl<n; ++girl){
                if(can[boy][girl] && !((1<<girl) & mask)){
                    int matched_mask = mask | (1<<girl);
                    add_self(dp[matched_mask], dp[mask]);
                }
            }
        }

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

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<bool>> used;
vector<ll> d;

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    vector<ll> ret;
    while (n > 0)
    {
        ll cur = n % 26ll;
        n /= 26ll;
        ret.push_back(cur);
    }
    string rret = "";
    for (int i = 0; i < ret.size() - 1; ++i)
    {
        if (ret[i] <= 0)
        {
            ret[i] += 26;
            ret[i + 1]--;
        }
    }
    for (int i = ret.size() - 1; i >= 0; --i)
    {
        ll p = ret[i] - 1;
        if (p < 0)
        {
            continue;
        }

        rret += ('a' + p);
    }
    
    cout << rret << endl;
    
    return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int K = input.nextInt();
		long mod = (long)(1e9+7);
		long[] gcdPerNum = new long[K+1];
		long answer = 0;
		for (int curGCD = K; curGCD>=1; curGCD--) {
			long base = K/curGCD;
			gcdPerNum[curGCD] = FastExp(base,N,mod);
			for (int OVERCNT = 2*curGCD; OVERCNT <= K; OVERCNT+=curGCD) {
				gcdPerNum[curGCD]-=gcdPerNum[OVERCNT];
				gcdPerNum[curGCD]%=mod;
				if (gcdPerNum[curGCD]<0) gcdPerNum[curGCD]+=mod;
			}
			answer+=gcdPerNum[curGCD]*curGCD;
			answer%=mod;
		}
		System.out.println(answer);
	}
	public static long FastExp(long base, long exp, long mod) {
		String Binary = Binary(exp);
		long[] mods = new long[Binary.length()];
		mods[0] = base%mod;
		long FinalProduct = 1;
		for (int i = 1; i < mods.length; i++) {
			mods[i] = ((mods[i-1]%mod)*(mods[i-1]%mod))%mod;
		}
		for (int i = 0; i < Binary.length(); i++) {
			if (Binary.charAt(i)=='1') {
				FinalProduct*=mods[Binary.length()-i-1];
				FinalProduct%=mod;
			}
		}
		return FinalProduct;
	}
	public static String Binary(long exp) {
		String answer = "";
		int length = 0;
		for (int i = 0;;i++) {
			if (Math.pow(2, i)>exp) {
				length=i;
				break;
			}
		}
		for (int i = length-1; i >= 0; i--) {
			if (Math.pow(2, i)<=exp) {
				answer+="1";
				exp-=Math.pow(2, i);
			}else {
				answer+="0";
			}
		}
		return answer;
	}
}


Measured memory_bytes: 45952
#include<iostream>
using namespace std;
int main(){
  int n,r,i,p,c,v;
  int array[100];
  int box[100];
  while(1){
    cin>>n>>r;
   
    if(n==0&&r==0) break;
    else{
      for(i=0;i<n;i++){
	box[i]=i+1;
      }
     
      for(i=0;i<r;i++){
	v=i;
	cin>>p>>c;
	for(i=0;i<c;i++){
	  array[i]=box[n-p-i];
	 
	}
	for(i=0;i<p-1;i++){
	 box[n-p-c+1+i]=box[n-p+1+i];
	  
	}
	for(i=0;i<c;i++){
	  box[n-1-i]=array[i];
	  
	}
	i=v;
      }
	cout<<box[n-1]<<endl;

    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL M = 1000003;

	static ULL Power(ULL a, ULL i) {
		if (i == 0) return 1;
		ULL buf = Power(a, i >> 1);
		buf = buf * buf % M;
		if (i & 1) buf = buf * a % M;
		return buf;
	}

	vector<ULL> I;
	vector<ULL> F;
	vector<ULL> iF;

	ULL Solve2() {
		ULL x, d, n; cin >> x >> d >> n;

		if (x == 0) return 0;
		if (d == 0) return Power(x, n);

		if (n >= M) return 0;
		ULL dpn = Power(d, n);
		ULL a = I[d] * x % M;
		if (a + n - 1 >= M) return 0;
		ULL Fr = F[a + n - 1] * iF[a - 1] % M;
		return dpn * Fr % M;
	}

	void Solve() {
		I.resize(M); F.resize(M); iF.resize(M);
		I[1] = 1; for (UL i = 2; i < M; i++) I[i] = M - M / i * I[M % i] % M;
		F[0] = 1; for (UL i = 1; i < M; i++) F[i] = F[i - 1] * i % M;
		iF[0] = 1; for (UL i = 1; i < M; i++) iF[i] = iF[i - 1] * I[i] % M;

		UL Q; cin >> Q;
		rep(i, Q) {
			cout << Solve2() << endl;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 26112
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] n = new int[N];
		int count = 0;
		boolean even = true;
		for(int i = 0;i < N;i++) {
			n[i] = sc.nextInt();
		}
		while(even) {
			for(int k = 0;k < N;k++) {
				if(n[k] % 2 == 0) {
					n[k] /= 2; 
				}
				else even = false;
			}
			if(even) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;

void solve(){
	cin >> k;
	cin >> s;
	n = s.length();
	if(n<=k){
		cout << s;
	}else{
		cout << s.substr(0,k)<<"...";
	}

}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int top=1e9;

int n,m,a,b,x,y;

int main(){
	n=IN(),m=IN(),a=IN(),b=IN();
	if (n%a==0&&m%b==0){
		puts("No");
		return 0;
	}
	x=(top-1)/(a*b-1);
	y=x*(a*b-1)+1;
	assert(1ll*(n*m-(n/a)*(m/b))*x-1ll*(n/a)*(m/b)*y>0);
	puts("Yes");
	For(i,1,n+1){
		For(j,1,m+1){
			if (i%a==0&&j%b==0){
				printf("%d ",-y);
			} else{
				printf("%d ",x);
			}
		}
		puts("");
	}
}

Measured memory_bytes: 2944
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e9;
const ll MOD=1e9+7;
// ac cmtr;
const ll MAX_N = 1e5;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll dp[105][100005];
ll peso[100005];
ll val[100005];


int main(){
    fastio;
    ll n,w;
    cin>>n>>w;
    f(i,0,n){
        ll a,b;
        cin>>a>>b;
        peso[i+1]=a;
        val[i+1]=b;
    }
    f(i,1,n+1){
        f(j,1,w+1){
            if(j>=peso[i])dp[i][j]=max(dp[i-1][j],dp[i-1][j-peso[i]]+val[i]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;


    return 0;
}   



Measured memory_bytes: 80128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		System.out.println(getMax(a, b));
	}

	private static int getMax(int a, int b) {
		ArrayList<Integer> integers = new ArrayList<Integer>();
		integers.add(a + b);
		integers.add(a - b);
		integers.add(a * b);
		return Collections.max(integers);
	}

}

Measured memory_bytes: 22868
#include <iostream>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	string s;
	cin >> s;
	int b[11];
  for(int i=0;i<=11;i++)
      {
        b[i]=0;}
int n = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == '1')b[i] = 1;
		if (s[i] == '2')b[i] = 2;
		if (s[i] == '3')b[i] = 3;
		if (s[i] == '4')b[i] = 4;
		if (s[i] == '5')b[i] = 5;
		if (s[i] == '6')b[i] = 6;
		if (s[i] == '7')b[i] = 7;
		if (s[i] == '8')b[i] = 8;
		if (s[i] == '9')b[i] = 9;
		
	}
	
      while(b[n]!=0){
        n++;
      }
      n--;
	
	int min = 100000;
	int ans;
	for (int i = 0; i <= n - 2; i++) {
      int pre=0;
      int test=0;
		pre = 100 * b[i] + 10 * b[i + 1] + b[i + 2] ;
		test = pre - 753;
		if (test < 0) test = -test;
		if (test < min) min = test;
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
//In The Name Of GOD
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 100*1000+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
 
int main(){
  IO;
  ll n,m;
  cin>>n>>m;
  ll i=0;
  while(n<=m){
    // cout<<n<<" "<<m<<' '<<i<<endl;
    i++;
    n*=2;
  }
  cout<<i;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
bool ok = true;

void input() {
  IN(N);
  REP(i, N) {
    IN(t);
    if (t % 2 == 0) {
      if (t % 3 == 0 || t % 5 == 0) {
        continue;
      } else {
        ok = false;
      }
    }
  }
}

void solve() {
  PRINT(ok?"APPROVED":"DENIED");
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1e5+10;
void io(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	io();
	int n;cin>>n;
	int a=0,b=0,c=0,d=0;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		int m=s.size();
		if(s[0]=='B'&&s[m-1]!='A')a++;
		if(s[m-1]=='A'&&s[0]!='B')b++;
		if(s[0]=='B'&&s[m-1]=='A')d++;
		for(int j=1;j<m;j++){
			if(s[j]=='B'&&s[j-1]=='A')c++;
		}
	}
	//printf("a %d b %d c %d d %d\n",a,b,c,d);
	int ans=c;
	if(d){
		ans=ans+d-1;
		if(a){
			ans++;
			a--;
		}
		if(b){
			ans++;
			b--;
		}
	}
	ans=ans+min(a,b);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256