akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> K;
		N -= K;
	}
	N = max(N, -1LL);
	cout << N << endl;
}

Measured memory_bytes: 3656
#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 {

	void Solve() {
		UL N; cin >> N;

		if (N < 3) {
			cout << "No" << endl;
			return;
		}
		if (N == 3) {
			cout << "Yes" << endl;
			cout << "1 2" << endl;
			cout << "2 3" << endl;
			cout << "3 4" << endl;
			cout << "4 5" << endl;
			cout << "5 6" << endl;
			return;
		}

		UL M = 4;
		while (M * 2 <= N) M *= 2;
		if (N == M) { cout << "No" << endl; return; }
		cout << "Yes" << endl;
		vector<UL> V(M - 1); rep(i, M - 1) V[i] = i + 1;
		if (N % 2 == 0) {
			swap(V[1], V[(N ^ M ^ 1) - 1]);
		}
		vector<pair<UL, UL>> W((N - M + 1) / 2);
		rep(i, (N - M + 1) / 2) {
			W[i] = { M + i * 2, M + i * 2 + 1 };
		}

		rep(i, V.size() - 1) cout << V[i] << " " << V[i + 1] << endl;
		cout << V.back() << " " << (V[0] + N) << endl;
		rep(i, V.size() - 1) cout << (V[i] + N) << " " << (V[i + 1] + N) << endl;

		rep(i, W.size()) {
			cout << W[i].second << " " << W[i].first << endl;
			cout << W[i].first << " " << 1 << endl;
			cout << 1 << " " << (W[i].second + N) << endl;
			cout << (W[i].second + N) << " " << (W[i].first + N) << endl;
		}
		if (N % 2 == 0) {
			cout << M << " " << N << endl;
			cout << V[1] << " " << (N + N) << endl;
		}
	}

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


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
    int N;
    cin>>N;
    cout<<N*(N+1)/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
ll a[N];
int f[5];
bool cmp(int x,int y)
{
    return abs(x)<abs(y);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>=0) f[1]++;
        else f[2]++;
    }
    int l=1,r=n;
    ll ans=1;
     if(!f[1]&&m%2==1){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            ans=a[i]*ans%mod;
        }
    }
    else {
        sort(a+1,a+1+n,greater<int>());
    while(m>0){
        if(m%2) ans=ans*a[l]%mod,l++,m--;
        else if(m>=2){
           if(a[l]*a[l+1]>=a[r]*a[r-1]){
              ans=ans*a[l]%mod*a[l+1]%mod;
              l+=2;
              m-=2;
           }
           else{
            ans=ans*a[r-1]%mod*a[r]%mod;
            r-=2;
            m-=2;
           }
        }
    }
    }
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}



Measured memory_bytes: 5156
//people on a line
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
using std::queue;
using std::sort;
const int maxn=100010;
const int maxm=400050;
const long long inf=9999999999;
long long dis[maxn];
bool vis[maxn];
int head[maxn]; int cnt=0;
bool inq[maxn];
inline void init(int n) {
	memset(head,-1,sizeof(head));
	for(int i=0;i<=n;i++) {
		dis[i]=inf;
	}
	memset(vis,false,sizeof(vis));
	memset(inq,false,sizeof(inq));
}
struct zmm{
	int to,next;
	int dis;
}a[maxm];
inline void add(int from,int to,int dis) {
	a[++cnt].to=to;
	a[cnt].dis=dis;
	a[cnt].next=head[from];
	head[from]=cnt;
	return;
}
queue<int> q;
bool spfa(int s) {

	//while(!q.empty()) q.pop();
	inq[s]=true; q.push(s);
	dis[s]=0;
	while(!q.empty()) {
		int u=q.front(); q.pop();
		inq[u]=false;
		int v;
		for(int i=head[u];i!=-1;i=a[i].next){
			v=a[i].to;
			if(dis[v]==inf) {
				dis[v]=dis[u]+a[i].dis;
				vis[v]=true;
				if(!inq[v]) {
					q.push(v);
					inq[v]=true;
				}
			}
			else if(dis[v]!=dis[u]+a[i].dis) {
				return false;
				}
		}
	}
	return true;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int u,v,w;
	init(n);
	for(int i=1;i<=m;i++) {
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
		add(v,u,-w);
	}
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			vis[i]=true;
			if(!spfa(i)) {
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


string a[3];

char game(ll now){
  if(a[now].size() == 0) return (char)('a'+ now);

  ll next = a[now][0]-'a';
  a[now].erase(a[now].begin());
  return game(next);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> a[0] >> a[1] >> a[2];
  
  cout <<  (char)(game(0) + 'A'-'a') << endl;

  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	long long a[2020], ans = 0;
	string s;
	cin >> s;

	reverse(s.begin(), s.end());

	int t = 0, p = 1;

	for(int i = 0; i < 2020; i++) a[i] = 0;
	a[0] = 1;

	for(int i = 0; i < (int)s.size(); i++){
		t += (s[i] - '0') * p;
		t %= 2019;
		p *= 10;
		p %= 2019;
		a[t]++;
	}

	for(int i = 0; i < 2019; i++){
		ans += a[i] * (a[i] - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3752
#include <stdio.h>

int main()
{
	char S[27];
	scanf("%s", S);
	int i, j;
	int flag=0;
	for (i = 0; S[i] != '\0'; i++) {
		for (j = i+1; S[j] != '\0'; j++) {
			if (S[i] == S[j]) {
				flag = 1;
				break;
			}
		}
	}
	if (flag == 1) {
		printf("no\n");
	} else {
		printf("yes\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  vec a(3);
  for(ll i=0;i<3;i++) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll k;
  cin >> k;
  while(k--) {
    a[0]*=2;
  }
  cout << a[0]+a[1]+a[2] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int i=1;i<=10005;i++)
		if(a*i%b==c)
		{
			cout<<"YES\n";
			return 0;
		}
	cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto edges = new long[][](N);
	auto deg = new long[](N);
	foreach (i; 0..N-1+M)
	{
		auto A = RD-1;
		auto B = RD-1;
		edges[A] ~= B;
		++deg[B];
	}

	long[] open;
	foreach (i; 0..N)
	{
		if (deg[i] == 0)
		{
			open ~= i;
			break;
		}
	}

	auto par = new long[](N);
	while (!open.empty)
	{
		auto from = open.front; open.popFront;
		foreach (to; edges[from])
		{
			--deg[to];
			if (deg[to] == 0)
			{
				par[to] = from+1;
				open ~= to;
			}
		}
	}

	foreach (i; 0..N)
	{
		writeln(par[i]);
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 13692
#include <iostream>

using namespace std;

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

	if (N[N.length() - 1] == '2'
		|| N[N.length() - 1] == '4'
		|| N[N.length() - 1] == '5'
		|| N[N.length() - 1] == '7'
		|| N[N.length() - 1] == '9') {
		cout << "hon" << endl;

	}
	else if (N[N.length() - 1] == '0'
		|| N[N.length() - 1] == '1'
		|| N[N.length() - 1] == '6'
		|| N[N.length() - 1] == '8') {
		cout << "pon" << endl;
	}
	else if (N[N.length() - 1] == '3') {
		cout << "bon" << endl;
	}

}





Measured memory_bytes: 3636
# AtCoder Beginner Contest 177
# C - Sum of product of pairs

N= int(input())
ls= list(map(int,input().split()))

mod=10**9+7

ans=0
accumls=[0]

for i in range (N):
    accumls.append(accumls[-1]+ls[i])

for i in range (N-1):
    ans+= ls[i]*(accumls[-1]-accumls[i+1])
    ans%=mod

print(ans)


Measured memory_bytes: 31560
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

bool is753num(const string &s) {

  if (!all_of(cbegin(s), cend(s), [](char c) { return c == '7' || c == '5' || c == '3'; })) {
    return false;
  }

  const bool is7 = any_of(cbegin(s), cend(s), [](char c) { return c == '7'; });
  if (!is7) {
    return false;
  }
  const bool is5 = any_of(cbegin(s), cend(s), [](char c) { return c == '5'; });
  if (!is5) {
    return false;
  }
  const bool is3 = any_of(cbegin(s), cend(s), [](char c) { return c == '3'; });
  if (!is3) {
    return false;
  }
  return true;
}

ll dfs(int nowketa, string s, int keta, ll num, ll N) {
  if (nowketa >= keta) {
    if (is753num(s) && stoi(s) <= N) {
      num++;
    }
    return num;
  }

  s[nowketa] = '7';
  auto num7 = dfs(nowketa + 1, s, keta, num, N);

  s[nowketa] = '5';
  auto num5 = dfs(nowketa + 1, s, keta, num, N);

  s[nowketa] = '3';
  auto num3 = dfs(nowketa + 1, s, keta, num, N);

  return num7 + num5 + num3;
}

int main() {
  string N;
  cin >> N;
  ll ans = 0;
  for (ll i = 3; i <= N.size(); i++) {
    string s;
    for (ll j = 0; j < i; j++) {
      s += "9";
    }
    ans += dfs(0, s, i, 0LL, stoi(N));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
 // #pragma GCC optimize("O3")  // CPU 処理並列化
 // #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[210000];
long long sum[1010000];
long long num[1010000];
long long sq[1010000];
long long val[1010000];

int main(){
	init_C(1010000);
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++){
		for(int j=1;j*j<=p[i];j++){
			if(p[i]%j)continue;
			sum[j]=(sum[j]+p[i])%mod;
			num[j]++;
			sq[j]=(sq[j]+(long long)p[i]*p[i])%mod;
			if(j*j<p[i]){
				int t=p[i]/j;
				sum[t]=(sum[t]+p[i])%mod;
				num[t]++;
				sq[t]=(sq[t]+(long long)p[i]*p[i])%mod;		
			}
		}
	}
	for(int i=0;i<1010000;i++){
		val[i]=sum[i]%mod*sum[i]%mod;
		val[i]=(val[i]+mod-sq[i]%mod)%mod;
		val[i]=val[i]*d2%mod;
	}
	long long ret=0;
	for(int i=1005000;i>=1;i--){
		for(int j=i*2;j<1006000;j+=i){
			val[i]=(val[i]+mod-val[j])%mod;
		}
		ret=(ret+val[i]*inv[i]%mod)%mod;
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 61568
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans = "No";
  for(int i = 0; i < s.length()-1; i++){
    if(s[i] == 'A' && s[i+1] == 'C') ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int ans = 0;
	rep (i, 4) {
		if (s[i] == '+') ans++;
		else ans--;
	}

	cout << ans << endl;
	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);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();

		String ans = "No";
		if ( A == B && A != C ) {
			ans = "Yes";
		} else if ( A == C && A != B ) {
			ans = "Yes";
		} else if ( B == C && A != B ) {
			ans = "Yes";
		}
		System.out.println(ans);
	}
}


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

/*
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
*/
 
#define INF 10e9
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
 
int main() {
    long long int n, q;
    cin >> n >> q;
    vector<long long int> a(n);

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

    long long int l = 0;
    long long int r = 0;
    long long int sum = 0;
    long long int count = 0;
    long long int s;

    for(i = 0; i < q; i++){
        cin >> s;
        l = 0;
        r = 0;
        sum = 0;
        count = 0;
        for(l = 0; l < n; l++){
            while(r < n && sum + a[r] <= s){
                sum += a[r];
                r++;
            }
            count += r - l;
            if(l == r){
                r++;
            }else{
                sum -= a[l];
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;

int dp[3005][3005];

string res = "";
string s, t;

void reconstruct(int i, int j) {
    if(i <= 0 || j <= 0) return;
    if(s[i-1] == t[j-1]) {
        res = s[i-1] + res;
        reconstruct(i-1, j-1);
    } else {
        if(dp[i-1][j] > dp[i][j-1]) reconstruct(i-1, j);
        else reconstruct(i, j-1);
    }
}

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


    cin >> s >> t;

    for(int i = 1; i <= s.length(); i++) {
        for(int j = 1; j <= t.length(); j++) {
            if(s[i-1] == t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    reconstruct(s.length(), t.length());
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}

int main(){
	IOS;
	cout.precision(30) ;
	int n ; cin >> n ;
	vector<long double> a(n) ; for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	sort(a.begin() , a.end()) ;
	long double ans = (a[0] + a[1]) / 2;
	for(int i = 2 ; i < n ; i++){
		ans = (ans + a[i]) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int A, B;
  string S;
  cin >> A >> B >> S;
  bool ans = true;
  for (int i = 0; i < A; i++) {
    if ('0'<=S[i] && S[i]<='9') {
      ;
    } else {
      ans = false;
      break;
    }
  }
  if (S[A]!='-') {
    ans = false;
  }
  for (int i = 0; i < B; i++) {
    if ('0'<=S[i+A+1] && S[i+A+1]<='9') {
      ;
    } else {
      ans = false;
      break;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cout<<fixed<<setprecision(50);
    int n;cin>>n;
    ld a[n+5];
    for(int i=1;i<=n;i++)    cin>>a[i];

    ld dp[n+5][n+5];
    memset(dp,0,sizeof(dp));

    dp[1][1]=a[1];
    dp[1][0]=1-a[1];

    for(int i=2;i<=n;i++){
        for(int heads=0;heads<=i;heads++){
            dp[i][heads]=((heads)?(a[i]*dp[i-1][heads-1]):0)+(1-a[i])*dp[i-1][heads];
            // cout<<i<<" "<<heads<<" "<<dp[i][heads]<<"\n";
        }
    }

    ld ans=0.0;
    for(int i=1;i<=n;i++){
        if(2*i>n)   ans+=dp[n][i];
    }
    
    cout<<ans<<"\n";
}

Measured memory_bytes: 144788
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  if(n%10==3)
    cout<<"bon";
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon";
  else
    cout<<"hon";
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<6;i++)
        if(s[i]=='1')
            ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,ll>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

vector<int> ans;
vector<vector<P>> g;

void dfs(int pre, int now, int col){
  ans[now] = col;
  for(P p: g[now]){
    if(p.first == pre) continue;
    if(p.second % 2 == 0) dfs(now, p.first, col);
    else dfs(now, p.first, 1 - col);
  }
}

int main(){
  int n; cin >> n;
  g.resize(n);
  ans.resize(n, -1);
  for(int i = 0; i < n-1; i++){
    int a,b; ll c;
    cin >> a >> b >> c;
    a--; b--;
    g[a].push_back(P(b,c));
    g[b].push_back(P(a,c));
  }
  dfs(-1, 0, 0);
  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 10496
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin >>n >>a >>b;
    if(n*a<b)
    cout<<n*a<<endl;
    else
    cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

n = int(input())
if n == 1:
    print(1)
    sys.exit()

matrix = [input().split() for l in range(n)]

matrix.sort()

# 全部の点の差分を求める
slope_list = []
for i in range(n-1):
    for j in range(i+1, n):
        a = (int(matrix[i][0])-int(matrix[j][0]), int(matrix[i][1])-int(matrix[j][1]))
        if a not in slope_list:
            slope_list.append(a)
#print(slope_list)

max_count = 0
for slope in slope_list:
    count = 0 # 被った回数をカウント
    for i in range(n):
        a = [str(int(matrix[i][0])-slope[0]), str(int(matrix[i][1])-slope[1])]
        #print(a)
        if a in matrix:
            count += 1
            continue
    if max_count < count:
        max_count = count
#print(max_count)

ans = n - max_count
        
print(ans)


            
        
            




Measured memory_bytes: 14448
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int N = 5e5 + 10;
int tree[N << 2];
void upd(int pos , int val , int l = 0 , int r = N - 1 , int t = 1){
    if(l == r){
        tree[t] = val;
        return;
    }
    int mid = (l + r) >> 1;
    if(pos <= mid)
        upd(pos , val , l , mid , t << 1);
    else
        upd(pos , val , mid + 1 , r , t << 1 | 1);
    tree[t] = max(tree[t << 1] , tree[t << 1 | 1]);
}

int qry(int ql , int qr , int l = 0 , int r = N - 1 , int t = 1){
    if(l > qr || r < ql)
        return 0;
    if(l >= ql && r <= qr)
        return tree[t];
    int mid = (l + r) >> 1;
    return max(qry(ql , qr , l , mid , t << 1) , qry(ql , qr , mid + 1 , r , t << 1 | 1));
}

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);
    int n , k;
    cin >> n >> k;
    int ans = 1;
    for(int i = 0 ; i < n ; i++){
        int x;
        cin >> x;
        int p = qry(max(0 , x - k) , min(N , x + k));
        ans = max(ans , 1 + p);
        upd(x , 1 + p);
    }

    cout << ans << '\n';
    return 0;

}



Measured memory_bytes: 6140
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int dp[n];
for(int i=1;i<n;i++)
dp[i]=999999;
dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
for(int i=2;i<n;i++)
{
dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
}
cout<<dp[n-1]<<endl;
return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll N; cin>>N;
  map<string,ll> mp;
  rep(i,N){
    string S; cin>>S;
    if(!mp.count(S)) mp[S]=1;
    else mp.at(S)++;
  }
  
  vector<string> vec(0);
  ll count=-INF;
  for(auto p:mp){
    string key; ll value; tie(key,value)=p;
    chmax(count,value);
  }
  for(auto p:mp){
    string key; ll value; tie(key,value)=p;
    if(count==value) vec.push_back(key);
  }
  
  for(auto ans:vec) cout<<ans<<endl;
  return 0;
}

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


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

vector<vector<int>> tree;
vector<int> X;
vector<int> dp(5010);
vector<int> nex(5010);


int dfs(int v){
	vector<int> tmp;
	if(tree[v].size()==0){
		return 0;
	}
	for(int u: tree[v]){
		tmp.push_back(dfs(u));
		if(tmp.back()==-1) return -1;
	}
	REP(i,5010) dp[i] = INF;
	REP(i, tree[v].size()){
		int u = tree[v][i];
		if(i==0){
			if(X[u] < 5010) dp[X[u]] = tmp[0];
			if(tmp[0] < 5010) dp[tmp[0]] = X[u];
			continue;
		}
		REP(j,5010) nex[j] = INF;
		REP(j,5010){
			int a = X[u];
			int b = tmp[i];
			if(j+a<5010){
				nex[j+a] = min(nex[j+a], dp[j]+b);
			}
			if(j+b<5010){
				nex[j+b] = min(nex[j+b], dp[j]+a);
			}
		}
		dp = nex;
	}
	int ret = INF;
	REP(i, X[v]+1){
		ret = min(ret, dp[i]);
	}
	if(ret == INF) ret = -1;
	return ret;
}


int main(){
	int n;
	cin>>n;
	tree.resize(n);
	REP(i,n-1){
		int p;
		cin>>p;
		p--;
		tree[p].push_back(i+1);
	}
	X.resize(n);
	REP(i,n){
		cin>>X[i];
	}
	cout<<(dfs(0)>=0?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            while (s.Length > 0)
            {
                if (s.EndsWith("erase"))
                {
                    s = s.Substring(0, s.Length - 5);
                }
                else if (s.EndsWith("dream"))
                {
                    s = s.Substring(0, s.Length - 5);
                }
                else if (s.EndsWith("eraser"))
                {
                    s = s.Substring(0, s.Length - 6);
                }
                else if (s.EndsWith("dreamer"))
                {
                    s = s.Substring(0,s.Length - 7);
                }
                else
                {
                    WriteLine("NO");
                    return;
                }
            }
            WriteLine("YES");
        }
    }
}

Measured memory_bytes: 31272
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A;
  for(int i=0; i<N; i++){
    int in;
    cin >> in;
    A.push_back(in);
  }
  int max_index = distance(A.begin(), max_element(A.begin(), A.end()));
  int min_index = distance(A.begin(), min_element(A.begin(), A.end()));
  int max = A[max_index];
  int min = A[min_index];
  if(min >= 0){
    cout << N-1 << endl;
    for(int i=0; i<N-1; i++)
      cout << i+1 << ' ' << i+2 << endl;
  } else if(max < 0){
    cout << N-1 << endl;
    for(int i=N-2; i>=0; i--)
      cout << i+2 << ' ' << i+1 << endl;
  } else if(abs(min) <= max){
    cout << 2*N-1 << endl;
    for(int i=0; i<N; i++)
      cout << max_index+1 << ' ' << i+1 << endl;
    for(int i=0; i<N-1; i++)
      cout << i+1 << ' ' << i+2 << endl;
  } else if(abs(min) > max){
    cout << 2*N-1 << endl;
    for(int i=0; i<N; i++)
      cout << min_index+1 << ' ' << i+1 << endl;
    for(int i=N-2; i>=0; i--)
      cout << i+2 << ' ' << i+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <cstring>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
ll ans;
ll n,a;
ll p[200005];
int main(void){
    scanf("%lld",&n);
    scanf("%lld",&a);
    if(a!=0){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        ll b;
        scanf("%lld",&b);
        if(b==a+1){
            ans++;
            a=b;
        }else{
            if(a+1<b){
                cout<<-1<<endl;
                return 0;
            }
            ans+=b;
            a=b;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	float n;
	int m;
	const char *rank[] = {"light fly", "fly", "bantam", "feather", "light", "light welter","welter", "light middle", "middle", "light heavy", "heavy"};
	while(~scanf("%f\n", &n)){
		if(n <= 48.0) m = 0;
		else if(n <= 51.0) m = 1;
		else if(n <= 54.0) m = 2;
		else if(n <= 57.0) m = 3;
		else if(n <= 60.0) m = 4;
		else if(n <= 64.0) m = 5;
		else if(n <= 69.0) m = 6;
		else if(n <= 75.0) m = 7;
		else if(n <= 81.0) m = 8;
		else if(n <= 91.0) m = 9;
		else m = 10;
		puts(rank[m]);
	}
	return 0;
}

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

#define LL long long
int n, m, a[305][305], vis[305];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            cin >> a[i][j];

    int ans = 1e9; memset(vis, 1, sizeof vis);

    for(int k = 1; k <= m; k++) {
        int res = 0, cnt[m+1]={}, id = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                int x = a[i][j];
                if(vis[x]) {
                    cnt[x]++;
                    if(res < cnt[x]) {
                        res = cnt[x], id = x;
                    }
                    break;
                }
            }   
        }
        vis[id] = 0;
        ans = min(ans, res);
    }        
    cout << (m == 1 ? n : ans);
}

Measured memory_bytes: 3972
/*

*/

#include<bits/stdc++.h>
using namespace std;
typedef pair<long,long> P;
int main(){
  long N,M;cin>>N>>M;
  vector<vector<long>>A(N);
  for(long i=0;i<M;i++){
    long a,b;cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  vector<long>D(N,-1);D[0]=0;
  queue<long>q;q.push(0);
  while(q.size()){
    long f=q.front();q.pop();
    for(long x:A[f])if(D[x]==-1){
      D[x]=f;
      q.push(x);
    }
  }
  for(long x:D)if(x==-1){cout<<"No";return 0;}
  cout<<"Yes"<<endl;
  for(long i=1;i<N;i++)cout<<D[i]+1<<endl;
  
  
}

Measured memory_bytes: 13028
#include<stdio.h>
char a[100] = {"abcdefghijklmnopqrstuvwxyz"};
char b[21] = {};
char c[100] = {};
int i, j;
int d;

int main(){
	scanf("%s", c);
	for (i = 0; i < 100; i++){
		for (j = 0; j < 21; j++){
			if (c[i] == a[j]){
				b[j]++;
			}
		}
		}
	for (i = 0; i < 21; i++){
		if (b[i] % 2 == 0||b[i]%2==2){
			d++;
		}
		else{
		}
	}
	if (d == 21){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

vector<long long int> prime_factor(long long int n) {
    vector<long long int> res;
    for (long long int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) res.push_back(n);
    return res;
};

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    map<i64,i64> count;
    rep(i,2,N+1){
        auto pf=prime_factor(i);
        for(auto f:pf) ++count[f];
    }

    vector<i64> es;
    for(auto p:count){
        es.emplace_back(p.second);
    }

    i64 ans=0;

    rep(i,0,es.size()){
        if(es[i]>=74) ++ans;
    }

    rep(i,0,es.size()){
        rep(j,0,es.size()){
            if(i==j) continue;
            if(es[i]>=2 and es[j]>=24) ++ans;
            if(es[i]>=4 and es[j]>=14) ++ans;
        }
    }

    rep(i,0,es.size()){
        rep(j,0,es.size()){
            rep(k,j+1,es.size()){
                if(i==j or k==i) continue;
                if(es[i]>=2 and es[j]>=4 and es[k]>=4) ++ans;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    int n,y;
    cin >> n >> y;
    int ans10000 = -1;
    int ans5000 = -1;
    int ans1000 = -1;
    for(int a=0; a<=n; ++a ){
    	for(int b=0; (a+b) <= n; ++b){
    		int c = n-a-b;
    		int total = 10000*a + 5000*b + 1000*c;
    		if(total==y) {
    			ans10000 = a;
    			ans5000 = b;
    			ans1000 = c;
    		}
    	}
    }
    cout << ans10000 << " " << ans5000 << " " << ans1000 << "\n";



	
} 


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

int main(void){
    int H, N;
    int sum;
    sum = 0;

    cin >> H >> N;

    int A[N];
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        sum += A[i];
    }

    if(sum < H)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
const int mod=1000000007;
const int INF=1e18;
int n,m,k;
int a[12][1005];
string s[1005];
int root[11];
set <int> se[11];
int join(int i,int j)
{
    int rt=root[i];
    root[j]=rt;
    se[rt].insert(j);
    se[j].erase(j);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>k;
    f(i,0,n)
        cin>>s[i];
    f(i,1,n+1)
    {
        f(j,1,m+1)
        {
            if(s[i-1][j-1]=='1')
                a[i][j]=1;
            a[i][j]+=a[i][j-1];
        }
    }
    int ans=mod;
    for(int i=0;i<(1ll<<(n-1));i++)
    {
        int cnt=0;
        f(i,1,n+1)
        {
            root[i]=i;
            se[i].clear();
            se[i].insert(i);
        }
        f(j,0,n-1)
        {
            if( ((1ll<<j)&i)>0 )
            {
                join(j+1,j+2);
            }
            else
                cnt++;
        }
        // cout<<cnt<<" ";
        int fla=0;
        f(i,1,m+1)
        {
            f(j,1,n+1)
            {
                int count=0;
                for(auto k: se[j])
                {
                    count+=a[k][i]-a[k][i-1];
                }
                if(count>k)
                {
                    fla=1;
                }
            }
        }
        // cout<<fla<<" ";
        if(fla==1)
            continue;
        int abhi=0;
        f(i,1,m+1)
        {
            f(j,1,n+1)
            {
                int count=0;
                for(auto k:se[j])
                {
                    count+=a[k][i]-a[k][abhi];
                }
                if(count>k)
                {
                    abhi=i-1;
                    cnt++;
                }
            }
        }
        // cout<<cnt<<'\n';
        ans=min(ans,cnt);
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, D := sc.nextInt(), sc.nextInt()
	arr := make([][]int, N)
	for i := 0; i < N; i++ {
		a := make([]int, D)
		for j := 0; j < D; j++ {
			a[j] = sc.nextInt()
		}
		arr[i] = a
	}
	count := 0
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			if distance(arr[i], arr[j], D) {
				count++
			}
		}
	}
	fmt.Println(count)
}

func distance(a, b []int, D int) bool {
	sum := 0
	for i := 0; i < D; i++ {
		sum += pow(a[i]-b[i], 2)
	}
	squared := math.Sqrt(float64(sum))
	if squared == float64(int(squared)) {
		return true
	} else {
		return false
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> x(N),y(N),t(N);
  for(int i=0;i<N;i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  if(t.at(0)%2==
       (abs(x.at(0))+abs(y.at(0)))%2
        && t.at(0)>=abs(x.at(0))+abs(y.at(0))){
        }
     else{
       cout << "No" <<endl;
         return 0;
     }
  for(int i=1;i<N;i++){
    if((t.at(i)-t.at(i-1))%2==
       (abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1)))%2
        && (t.at(i)-t.at(i-1))>=(abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1)))){
        }
       else{
         cout << "No" <<endl;
         return 0;
      }
 }
  cout << "Yes" << endl;
       
}

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

bool check(vector<vector<int> > &seen) {
    for (int i = 0; i < 3; ++i) {
        bool ok = true;
        for (int j = 0; j < 3; ++j) {
            ok *= seen.at(i).at(j);
        }
        if (ok) return true;
    }
    for (int j = 0; j < 3; ++j) {
        bool ok = true;
        for (int i = 0; i < 3; ++i) {
            ok *= seen.at(i).at(j);
        }
        if (ok) return true;
    }
    if (seen.at(0).at(0) * seen.at(1).at(1) * seen.at(2).at(2)) return true;
    if (seen.at(2).at(0) * seen.at(1).at(1) * seen.at(0).at(2)) return true;
    return false;
}

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

    vector<vector<int> > A(3, vector<int>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<vector<int> > seen(3, vector<int>(3, 0));
    for (int cnt = 0; cnt < N; ++cnt) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (A.at(i).at(j) == b) {
                    seen.at(i).at(j) = 1;
                }
            }
        }
    }
    cout << ((check(seen)) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000000+7
#define ll long long
using namespace std;
int a[10000]={0};
void fact_count(int n)
{
    while(n%2==0)
    {
        a[2]++;
        n/=2;
    }
    for(int i=3;i<=sqrt(n);i+=2)
    {
        while(n%i==0)
        {
            a[i]++;
            n/=i;
        }
    }
    if(n>2)
        a[n]++;
}
void fact(ll n)
{
    for(int i=2;i<=n;i++)
    {
        fact_count(i);
    }

}

int main()
{
    ll n,r=1;
    cin>>n;
    fact(n);
    for(int i=1;i<=n;i++)
    {
        if(a[i]>0)
        {
            r = (r*(a[i]+1));
            r%=M;

        }
    }
    cout<<r<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep(i, n) for (ll i=0; i<(n); i++) 


int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans1 = 0, ans2 = 0, r = 0, g = 0, b = 0;
    rep(i,n){
        if (s[i]=='R') r++;
        if (s[i]=='G') g++;
        if (s[i]=='B') b++;
    }
    ans1 = r*g*b;
    rep(i,n){
        for (ll j=i+1; j<(n); j++){
            ll k = 2*j - i;
            if ((k<n)&&(s[i]!=s[j])&&(s[i]!=s[k])&&(s[k]!=s[j])) ans2++;
        }
    }
    ll ans = ans1 - ans2;
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int N = 2e5+5;

ll p[N], inv[N], ans = 1;

ll power(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)	res = (res * a) % mod;
		a = (a * a) % mod; b >>= 1;
	}
	return res;
}

ll C(ll n, ll m)
{
	return p[n] * inv[m] % mod * inv[n-m] % mod;
}

int main()
{
	ll n, k;
	cin >> n >> k;
	p[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		p[i] = p[i-1] * i % mod;
		inv[i] = power(p[i], mod-2);
	}
	k = min(k, n - 1);
	for (ll i = 1; i <= k; i++)
	{
		ans = (ans + C(n, i) * C(n-1, i) % mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c; cin >> n >> m >> c;
  vector<int> b(m);
  for(int &k : b) {
    cin >> k;
  }
  vector<vector<int>> a(n, vector<int>(m));
  for(vector<int> &k : a) {
    for(int &l : k) {
      cin >> l;
    }
  }
  int codes, count = 0;
  for(int i = 0; i < n; i++) {
    codes = c;
    for(int j = 0; j < m; j++) {
      codes += a.at(i).at(j) * b.at(j);
    }
    if(codes > 0) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628