akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
int a, b, v, w, t;
signed main() {
	cin >> a >> v >> b >> w >> t;
	int p = abs(a - b);
	int q = t * (v - w);
	if (p <= q)puts("YES");
	else puts("NO");
	ggr
}


Measured memory_bytes: 3688
//============================================================================
// Name        : AOJCpp.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

void trace(int A[], int n) {
	for (int j = 0; j < n-1; j++) {
		cout << A[j] << " ";
	}

	cout << A[n-1] << endl;
}

int main() {
	int n;
	int A[MAX];
	int count = 0;

	cin >> n;

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

	for(int i = 0; i < n; i++) {
		int minj = i;
		for(int j = i; j < n; j++) {
			if(A[minj]>A[j]) {
				minj = j;
			}
		}
		if(minj!=i) {
			int tmp = A[minj];
			A[minj] = A[i];
			A[i] = tmp;
			count++;
		}

//		trace(A,n);
	}
	trace(A,n);
	cout << count << endl;

}





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

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void solve(){
    int n,m;
    cin>>n>>m;
    cout<<((n*(n-1))/2)+((m*(m-1))/2);
}

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

ll f;

bool ch(ll x){
    if(pow(x,5)>=f)return true;
    return false;
}
bool o(ll x){

    if(pow(x,5)==f)return true;
return false;
}

int main()
{
   ll x;cin >>x;
   ll p=0,q=0;
   for(int b=-1000;b<=1000;b++){
    ll c=b;
    rep(i,4)c*=b;
    f=x+c;
    ll ok=1000,ng=-1000;
    while(abs(ok-ng)>1){
        ll md=(ok+ng)/2;
        if(ch(md))ok=md;
        else ng=md;
    }
   //if(b==){
     //cout <<ok << endl;
     //cout <<f<< endl;
    //}
    if(o(ok)){
        p=ok;
        q=b;
    }
   }
   cout <<p<<" "<< q<< endl;
    return 0;
}


Measured memory_bytes: 4036
N, M = map(int, input().split())
P = [input().split() for _ in range(M)]
 
wa = [0]*N
ac = [False]*N
 
for ps in P:
  p, s = int(ps[0]), ps[1]
  if ac[p-1]:
    continue
  elif s == 'AC':
    ac[p-1] = True
  else:
    wa[p-1] += 1

print(sum(ac), sum([w*a for w,a in zip(wa, ac)]))

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

int main(){
  int n,array[100001],ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
    if(array[i]%2){
      ans++;
    }
  }
  cout<<(ans%2?"NO":"YES")<<endl;
}

Measured memory_bytes: 640
# Red or Not
#　整数aと英小文字からなる文字列sが入力されます。
# aが3200以上ならsと出力し、aが3200未満なら'red'と出力するプログラムを書いてください。

# 2800 < a < 5000
# sは長さ1以上10以下の文字列である。
# sの各文字は英小文字である。

a = int(input())
s = input()
#print(a,s)

if a >= 3200:
    print(s)
elif a < 3200:
    print('red')

Measured memory_bytes: 9116
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    H = list(map(int, input().split()))

    s = [0]
    ans = 0
    for i in range(N):
        if len(s) and s[-1] <= H[i]:
            ans += H[i] - s[-1]
        else:
            while len(s) and s[-1] >= H[i]:
                s.pop()
        s.append(H[i])

    print(ans)


if __name__ == '__main__':
    main()


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

const int MAX=20000;
const int MAX_half=10000;
const int inf=20001;

struct edge { int to, cap, rev; };
vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)(G[to].size())});
    G[to].push_back((edge){from, 0, (int)(G[from].size()-1)});
}

int dfs(int v, int t, int f) {
    if(v == t) return f;
    used[v] = 1;
    for(int i = 0 ; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(used[e.to] or e.cap <= 0) continue;
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0){
            e.cap -= d;
            G[e.to][e.rev].cap += d;
            return d;
        }
    }
    return 0;
}

int ford_fulkerson(int s, int t) {
    int flow = 0, f;
    while(1){
        fill(used, used+MAX, 0);
        f = dfs(s, t, inf);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){
    //input
    int H,W;
    cin >> H >> W;
    string a[H];
    int i,j,k;
    for(i=0; i<H; i++){
        cin >> a[i];
    }

    //calc
    pair<int,int> S,T;
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(a[i][j]=='S'){
                S=make_pair(i,j);
            }
            if(a[i][j]=='T'){
                T=make_pair(i,j);
            }
        }
    }
    if(S.first==T.first||S.second==T.second){
        cout << -1 << endl;
        system("pause");
        return 0;
    }
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(a[i][j]!='.'){
                add_edge(i*W+j,i*W+j+MAX_half,1);
            }
        }
    }
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(a[i][j]!='.'){
                for(k=i+1; k<H; k++){
                    if(a[k][j]!='.'){
                        add_edge(i*W+j+MAX_half,k*W+j,inf);
                        add_edge(k*W+j+MAX_half,i*W+j,inf);
                    }
                }
                for(k=j+1; k<W; k++){
                    if(a[i][k]!='.'){
                        add_edge(i*W+j+MAX_half,i*W+k,inf);
                        add_edge(i*W+k+MAX_half,i*W+j,inf);
                    }
                }
            }
        }
    }

    //output    
    cout << ford_fulkerson(S.first*W+S.second+MAX_half,T.first*W+T.second) << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 67792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int main(){
	int x,t;
	cin >> x >> t;
	if(x >= t) cout << x - t;
	else cout << '0';
}

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

using namespace std;

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

typedef complex<double> point;
struct segment { point p, q; };

double dot(point a, point b) { return real(conj(a) * b); }

double cross(point a, point b) { return imag(conj(a) * b); }

double area2(point a, point b, point c) { return cross(b - a, c - a); }

int ccw(point a, point b, point c)
{
	b -= a; c -= a;
	if (cross(b, c) > 0) return +1; // counter clockwise
	if (cross(b, c) < 0) return -1; // clockwise
	if (dot(b, c) < 0) return 
	+2; // c--a--b on line
	if (dot(b, b) < dot(c, c)) return -2; // a--b--c on line
	return 0;
}

bool intersectSS(const segment &s, const segment &t)
{
	return ccw(s.p, s.q, t.p) * ccw(s.p, s.q, t.q) <= 0 &&
			ccw(t.p, t.q, s.p) * ccw(t.p, t.q, s.q) <= 0;
}

point read(){
	double x, y; cin >> x >> y;
	return point(x, y);
}

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

	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		point p = read(), q = read();
		segment s1 = {p, q};
		p = read(), q = read();
		segment s2 = {p, q};
		if (intersectSS(s1, s2)) cout << 1 << endl;
		else cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

int getmax( const vector<int>&field) {
	int ans = 0;

	//l,h
	stack<pair<int, int>>que;
	que.emplace(0, 0);
	for (int x = 0; x < field.size(); ++x) {
		const int nowh = field[x];
		while (!que.empty()) {
			const int prevh = que.top().second;
			if (nowh > prevh) {
				que.emplace(x, nowh);
				break;
			}
			else if (nowh == prevh) {
				break;
			}
			else {
				auto p(que.top());
				que.pop();
				ans = max(ans, p.second*(x - p.first));
				if (!que.empty() && que.top().second < nowh) {
					que.emplace(p.first, nowh);
					break;
				}
			}
		}
	}
	{
		int x = field.size();
		const int nowh = 0;
		while (!que.empty()) {
			const int prevh = que.top().second;
			if (nowh > prevh) {
				que.emplace(x, nowh);
				break;
			}
			else if (nowh == prevh) {
				break;
			}
			else {
				auto p(que.top());
				que.pop();
				ans = max(ans, int(p.second*(x- p.first)));
				if (!que.empty() && que.top().second < nowh) {
					que.emplace(p.first, nowh);
					break;
				}
			}
		}
	}
	return ans;
}

int main() {
	while (1) {
		int H, W; cin >> H >> W;
		if (!H)break;
		vector<vector<int>>field(H, vector<int>(W));
		for (int i = 0; i < H; ++i) {
			string st; cin >> st;
			for (int j = 0; j < W; ++j) {
				field[i][j] = st[j] == '.';
			}
		}
		for (int x = 0; x < W; ++x) {
			for (int y = 1; y < H; ++y) {
				if (field[y][x]) {
					field[y][x] += field[y - 1][x];
				}
			}
		}
		int ans = 0;
		for (int d = 0; d < H; ++d) {
			ans = max(ans, getmax(field[d]));
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	string x;
	
	int ans = 0;
	for(int i=0; i<n; i++){
		cin >> s[i] >> t[i];
		ans += t[i];
	}

	cin >> x;
	for(int i=0; i<n; i++){
		ans -= t[i];
		if(s[i]==x) break;;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3632
//{{{
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define BR putchar('\n')
#define MS0(ar) memset(ar, 0, sizeof(ar))
#define MS1(ar) memset(ar, -1, sizeof(ar))
#define F first
#define S second
#define MP make_pair
#define MT make_tuple
#define IO(name) freopen(name".in", "r", stdin);freopen(name".out", "w", stdout)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef complex<double> CD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VL;

void R(int &x) { scanf("%d", &x); }
void R(LL &x) { scanf("%lld", &x); }
void R(ULL &x) { scanf("%llu", &x); }
void R(double &x) { scanf("%lf", &x); }
void R(LD &x) { scanf("%Lf", &x); }

template <typename T> void R(T &t) { cin >> t; }
template <typename A, typename B> void R(pair<A, B> &x) {
  R(x.F);
  R(x.S);
}

template <typename T> void R(vector<T> &ar) {
  for (auto &it : ar)
    R(it);
}

template <typename T, typename... Args> void R(T &t, Args &... args) {
  R(t);
  R(args...);
}

void W(const char &c) { putchar(c); };
void W(const int &x) { printf("%d", x); }
void W(const LL &x) { printf("%lld", x); }
void W(const ULL &x) { printf("%llu", x); }
void W(const double &x) { printf("%lf", x); }
void W(const LD &x) { printf("%Lf", x); }

template <typename T> void W(const T &t) { cout << t; }
template <typename T> void W(const vector<T> &ar) {
  for (size_t i = 0; i < ar.size(); ++i) {
    W(ar[i]);
    putchar(" \n"[i + 1u == ar.size()]);
  }
}
template <typename T, typename... Args>
void W(const T &t, const Args &... args) {
  W(t);
  W(args...);
}
#define BR putchar('\n')

template <typename T> void Min(T &x, T v) { x = min(x, v); }
template <typename T> void Max(T &x, T v) { x = max(x, v); }
//}}}
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int maxn = 100010;

int main() {
  LL a, b;
  int n; R(n); REP(i, n) {
    LL x, y;
    R(x, y);
    if (i == 0) a = x, b = y;
    else {
      LL aa = max((a + x - 1) / x, (b + y - 1) / y);
      a = x * aa, b = y * aa;
    }
  }
  W(a + b, '\n');
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // freopen("in.txt", "r", stdin);
    int a, b, c;
    while (cin >> a >> b >> c)
    {
        if (a + b + c >= 22) cout << "bust" << endl;
        else cout << "win" << endl;
    }
    return 0;
}

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

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

    int count = 1;
    int r, l;
    int len = s.length();
    s.push_back('R');
    vector<int> d(len);
    rep(i, len){
        if(s.at(i) == 'R'){
            if(s.at(i+1) == 'R'){
                d.at(i) = 0;
                count++;
            }
            else{
                r = i;
                l = i+1;
                if(count%2 == 0){
                    d.at(r) = count/2;
                    d.at(l) = count/2;
                }
                else{
                    d.at(r) = count/2+1;
                    d.at(l) = count/2;
                }
                count = 1;
            }
        }
        else{
            if(s.at(i+1) == 'L'){
                d.at(i+1) = 0;
                count++;
            }
            else{
                if(count%2 == 0){
                    d.at(r) += count/2;
                    d.at(l) += count/2;
                }
                else{
                    d.at(r) += count/2;
                    d.at(l) += count/2+1;
                }
                count = 1;
            }
        }
    }

    rep(i, len){
        cout << d.at(i);
        if(i != len-1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
alist = list(map(int,input().split()))

prev_a = []
for i in range(n):
    prev_a.append(alist[i])
    if i >= k:

        if prev_a.pop(0) < alist[i]:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 31612
N = int(input())
count, n1, n2 = 0, 1, 9
while n1 <= N:
    if n2 <= N:
        count += n1 * 9
    else:
        count += (N - n1 + 1)
    n1, n2 = n1 * 100, n1 * 1000 - 1
print(count)


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

using namespace std;

const int N=1000005,P=998244353;
typedef long long ll;

int fac[N],ifac[N],n,m,ans;
int fpow(int a,int t){
	static int r;
	for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}
int C(int n,int m){
	if(n<m)return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main(){
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	fac[0]=1;
	for(int i=1;i<=n+m;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[n+m]=fpow(fac[n+m],P-2);
	for(int i=n+m;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=1;i<=n;i++)ans=(ans+(ll)C(i<<1,i)*C(n+m-(i<<1),n-i))%P;
	ans=((ll)ans*fpow(C(n+m,n)*2,P-2)+m)%P;
	printf("%d\n",ans);
	return 0; 
}

Measured memory_bytes: 8192
import sys


N, Q = map(int, input().split())
S = input()

AC = [0] * N

for i in range(1, N):
    a = 0
    if S[i - 1] == 'A' and S[i] == 'C':
        a = 1
    AC[i] = AC[i - 1] + a

LR = [map(int, x.split()) for x in sys.stdin.readlines()]

for l, r in LR:
    print(AC[r - 1] - AC[l - 1])


Measured memory_bytes: 60020
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define mod 1000000007
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cout<<#x<<": "<<x<<endl;
const double PI = acos(-1.0);
using namespace std;

void cp()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
}

int main()
{
    FASTIO;
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Dice_II
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
 
             
                 
 
            Dice dice1 = new Dice(input1);
            Dice dice2 = new Dice(input2);
 
            List<string> result1 = new List<string>();
            List<string> result2 = new List<string>();
            string ctr = " zzzxyyyzxxxzyyyzxxxyzzz";
 
            for (int i = 0; i < ctr.Length; i++)
            {
                dice1.Rotate(ctr[i]);
                for (int j = 0; j < ctr.Length; j++)
                {
                    dice2.Rotate(ctr[j]);
                    if (dice1.top.Equals(dice2.top) && dice1.front.Equals(dice2.front))
                    {
                        if (dice1.right.Equals(dice2.right))
                        {
                            if (dice1.back.Equals(dice2.back))
                            {
                                if (dice1.left.Equals(dice2.left))
                                {
                                    if (dice1.bottom.Equals(dice2.bottom))
                                    {
                                        Console.WriteLine("Yes");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
 
            }
            Console.WriteLine("No");
             
        }
    }
 
    class Dice
    {
        public string top, front, right, left, back, bottom;
 
        public Dice(string[] input)
        {
            this.top = input[0];
            this.front = input[1];
            this.right = input[2];
            this.left = input[3];
            this.back = input[4];
            this.bottom = input[5];
        }
 
        void RotateX()
        {
            string temp = this.top;
            this.top = this.front;
            this.front = this.bottom;
            this.bottom = this.back;
            this.back = temp;
        }
 
        void RotateY()
        {
            string temp = this.front;
            this.front = this.right;
            this.right = this.back;
            this.back = this.left;
            this.left = temp;
        }
 
        void RotateZ()
        {
            string temp = this.top;
            this.top = this.left;
            this.left = this.bottom;
            this.bottom = this.right;
            this.right = temp;
        }
 
        public void Rotate(char ctr)
        {
            switch (ctr)
            {
                case 'x':
                    RotateX();
                    break;
                case 'y':
                    RotateY();
                    break;
                case 'z':
                    RotateZ();
                    break;
                default:
                    break;
            }
        }
 
    }
}



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

using namespace std;

int main(){
  int N;
  cin >> N;
  map<int,int,greater<int>> M;
  for(int i=1; i<=N; i++){
    int A;
    cin >> A;
    M[A]++;    
  }
  vector<long long> ans;
  auto itr=M.begin();
  while(ans.size()<2){
    if(itr->second>=2) ans.emplace_back(itr->first);
    if(itr->second>=4) ans.emplace_back(itr->first);
    if(itr==M.end()) break;
    else itr++;
  }
  if(ans.size()<2) cout << 0 << endl;
  else cout << ans[0]*ans[1] << endl;
  
  return 0;
}

Measured memory_bytes: 4992
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/
#include <bits/stdc++.h>
#define newline ("\n")
#define deb(x) cerr << (#x) << " = " << (x) << '\n'
#define FOR(x, n) for (int x = 0; x < n; x++)
#define PI (3.141592653589)

#define MOD 1000000007
using namespace std;

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

    // Highly sophisticated code starts here

    int n;
    cin >> n;
    int arr[n];
    int brr[n];
    for (auto &i : arr)
    {
        cin >> i;
    }
    for (auto &i : brr)
    {
        cin >> i;
    }
    int sol[n];
    for (int i = 0; i < n; i++)
    {
        sol[i] = arr[i];
    }
    vector<pair<int, int>> m;
    for (int i = 0; i < n; i++)
    {
        if (arr[i] > brr[i])
        {
            m.push_back({arr[i] - brr[i], i});
        }
    }
    int index = 0;
    int count = 0;
    sort(m.rbegin(), m.rend());
    for (int i = 0; i < n; i++)
    {
        if (sol[i] < brr[i])
        {
            while (sol[i] < brr[i])
            {
                if (index >= m.size())
                {
                    cout << -1;
                    return 0;
                }
                int current = m[index].first;
                if (current > brr[i] - sol[i])
                {
                    int diff = brr[i] - sol[i];
                    m[index].first = m[index].first - (diff);
                    sol[m[index].second] -= diff;
                    sol[i] = brr[i];
                }
                else if (current == (brr[i] - sol[i]))
                {
                    int diff = brr[i] - sol[i];
                    m[index].first = 0;
                    sol[m[index].second] -= diff;
                    sol[i] = brr[i];
                    index++;
                }
                else
                {
                    int diff = m[index].first;
                    sol[m[index].second] -= diff;
                    sol[i] += diff;
                    index++;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (sol[i] != arr[i])
        {
            count++;
        }
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 2172
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h1,m1; cin >> h1 >> m1;
    ll h2,m2; cin >> h2 >> m2;
    ll k; cin >> k;
    ll st = h1 * 60 + m1;
    ll ed = h2 * 60 + m2;
    cout << ed - st - k << endl;
}

Measured memory_bytes: 3640
// AOJ Volume2 0256

#include <stdio.h>

int main(void)
{
	int b1, b2, b3;
	
	scanf("%d%d%d", &b1, &b2, &b3);
	
	switch (b1 * 4 + b2 * 2 + b3){
	  case 6:
	  case 1:
	  	printf("Open\n");
		break;
	
	  default:
	    printf("Close\n");
		break;
	}
	
	return (0);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
#define mp make_pair
#define pb push_back
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll dp[n];
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    for(ll i=2;i<n;i++)
        dp[i]=mn(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i-1]-a[i]));
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX 1e9+7
#define lim 1e5
using namespace std;

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

	std::vector<int> v(n);

	for(int i=0;i<n;i++)
		cin>>v[i];

	std::vector<bool> dp(k+1);


	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if( i>=v[j] && !dp[i-v[j]])
			{
				dp[i]=1;
			}
		}
	}




	if(dp[k])
		cout<<"First"<<endl;

	else
		cout<<"Second"<<endl;

}

Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#define FAST        ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)        cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
const int INF = 0x3f3f3f3f;

vi adj[100005];
int vis[100005]={0},n,m;
void dfs(int node)
{
  vis[node]=1;
  for(auto i:adj[node])
  {
    if(!vis[i]) dfs(i);
  }
}
int main()
{
    FAST;
    //  #ifndef ONLINE_JUDGE
//      freopen("input.txt", "r", stdin);
//      freopen("output.txt", "w", stdout);
//  #endif
    int t; t=1;
    while(t--)
    {
       cin>>n>>m;
       rep(i,0,m)
       {
         int x,y,z; cin>>x>>y>>z;
         adj[x].pb(y);
         adj[y].pb(x);
       }
       int ans=0;
       rep(i,1,n+1)
       {
         if(!vis[i])
         {
           ans++;
           dfs(i);
         }
       }
       cout<<ans;
    }
}

Measured memory_bytes: 9216
import java.util.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner s= new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int sum = (a+b);
		if(sum%2!=0)
		System.out.println((sum-(sum%2)+2)/2);
		else
		System.out.println((sum-(sum%2))/2);
	}
}

Measured memory_bytes: 21588
n, k = map(int, input().split())

table = [0 for _ in range(n)]

for i in range(k):
    d = int(input())
    sweet = list(map(int, input().split()))
    for a in sweet:
        table[a-1] += 1

ans = 0
for sunuke in table:
    if sunuke == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9192
n = int(input())
lst = [0] * 5
march = ['M', 'A', 'R', 'C', 'H']
for i in range(n):
  nf = input()[0]
  if nf in march:
    lst[march.index(nf)] += 1
ret = 0
for a in range(0, 3):
  for b in range(a + 1, 4):
    for c in range(b + 1, 5):
      ret += lst[a] * lst[b] * lst[c]
print(ret)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int data[31];
  int d,i;
  for(i=0;i<31;i++)data[i]=0;

  for(i=1;i<=28;i++){
    scanf("%d",&d);
    data[d]=1;
  }
  for(i=1;i<=30;i++){
    if(data[i]==0){
      printf("%d\n",i);
    }
  }
  return 0; 
}

Measured memory_bytes: 596
//
//  main.cpp
//  atcoder
//
//  Created by caokai on 16/7/16.
//  Copyright © 2016年 caokai. All rights reserved.
//

#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;
int n, mymax;
vector<int> tp;
vector<int> tptmp;
vector<int> ori;
void input() {
    scanf("%d", &n);
    for (int i = 0; i < n*2; i++) {
        int tmp;
        scanf("%d", &tmp);
        ori.push_back(tmp);
    }
    sort(ori.begin(), ori.end());
}
void solve() {
     mymax = 0;
    for (auto i = ori.begin(); i!= ori.end(); i += 2) {
        mymax += *i;
    }
    printf("%d\n", mymax);
}
int main() {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<" "<<#x<<"="<<x

#define bit(k) (1LL<<(k))

typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
/*------------------------------------*/
ll modpow(ll a, ll n, int mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n - i;
        y *= i+1;
    }
    return x / y;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,a,b;
    cin>>n>>a>>b;
    mint ans = modpow(2, n, MOD) - 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout<<ans.x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
int main() {
	int n, A, B;
	scanf("%d%d%d", &n, &A, &B);
	if (A > B) swap(A, B);
	vector<Mint> H(n + 3), I(n + 1, 1);
	vector<vector<Mint>> F(n + 1, vector<Mint>(2));
	vector<vector<Mint>> G(n + 1, vector<Mint>(2));
	for (int i = 1; i <= n; ++i) {
		I[i] = I[i - 1];
		for (int j = A; j <= i; ++j) I[i] += i == j ? 1 : I[i - j - 1];
	}
	for (int i = 1; i <= n + 2; ++i) {
		H[i] = i == 1 ? 1 : I[i - 2];
	}
	G[0][0] = F[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int p = 0; p < 2; ++p) {
			for (int j = 1; j <= min(i, A - 1); ++j) {
				F[i][p] += G[i - j][p];
			}
		}
		for (int j = 1; j <= i; ++j) {
			int jj = j;
			if (i == j) ++jj;
			if (i == n) ++jj;
			Mint h = H[jj];
			if (j < B) G[i][0] += h * F[i - j][0];
			G[i][1] += h * F[i - j][1];
			if (j >= B) G[i][1] += h * F[i - j][0];
		}
	}
	Mint ans = F[n][1] + G[n][1];
	printf("%d\n", ans.val);
}

Measured memory_bytes: 4324
N,K = list(map(int, input().split()))
V = list(map(int, input().split()))
#print(N,K,min(N,K))

from itertools import accumulate
Lcumsum = [0] + list(accumulate(V))
Rcumsum = [0] + list(accumulate(V[::-1]))
#print(Lcumsum)
#print(Rcumsum)

ans = 0
               
for l in range(min(N,K)+1):
  for r in range(min(N-l,K-l)+1):
    Lsum = Lcumsum[l]
    Rsum = Rcumsum[r]
    Nsum = sum(sorted([v for v in (V[:l] + V[N-r:]) if v<0])[:K-l-r])
    ans = max(ans, Lsum+Rsum-Nsum)
    #print(l,r,Lsum,Rsum,Nsum,Lsum+Rsum-Nsum)
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,i,j,b[205]={0},han[205]={0},pb;
char ou[10];

int que_a(int x){
    cout << "?";
        for(j=x;j<x+n;j++) cout << " " << j+1;
        cout << endl;
        cin >> ou;
        if(ou[0]=='-') return 0;
        if(ou[0]=='R') return 1;
        else return -1;
}

int que_b(int x){
    cout << "?";
        for(j=pb;j<=pb+n;j++) if(j!=x) cout << " " << j+1;
        cout << endl;
        cin >> ou;
        if(ou[0]=='-') return 0;
        if(ou[0]=='R') return -1;
        else return 1;
}

int que_c(int x){
    cout << "?";
        for(j=pb+n;j<2*n;j++) if(j!=x) cout << " " << j+1;
        for(j=0;j<=pb;j++) if(j!=x) cout << " " << j+1;
        cout << endl;
        cin >> ou;
        if(ou[0]=='-') return 0;
        if(ou[0]=='R') return -1;
        else return 1;
}

int main() {
	// your code goes here
    cin >> n;
    int l,r,mid;
    l=0; r=n;
    han[0]=que_a(0);
    han[n]=-han[0];
    while(r-l>1){
        mid=(l+r)/2;
        han[mid]=que_a(mid);
        if(han[l]==han[mid]) l=mid;
        else r=mid;
    }
    pb=l;
    b[pb]=han[pb];
    b[pb+n]=-han[pb];
    for(i=pb+1;i<pb+n;i++) b[i]=que_b(i);
    for(i=pb+n+1;i<2*n;i++) b[i]=que_c(i);
    for(i=0;i<pb;i++) b[i]=que_c(i);
    cout << "! ";
    for(i=0;i<2*n;i++){
        if(b[i]==1) cout << "R";
        else if(b[i]==-1) cout << "B";
        else cout << "0";
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000000
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,k,s;
    cin>>n>>k>>s;
    if(s==mod){
        for(int x=0;x<k;x++){
            cout<<mod<<" ";
        }
        for(int x=k;x<n;x++){
            cout<<3<<" ";
        }
        return 0;
    }
    for(int x=0;x<k;x++){
        cout<<s<<" ";
    }
    for(int x=k;x<n;x++){
        cout<<mod<<" ";
    }








	
return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main()
{
    signed long int a, b, min=2147483647, max=-2147483648, sum=0;
    cin >> a;
    for (; a>0; a--) {
        cin >> b;
        if (b>max) max=b;
        if (b<min) min=b;
        sum=sum+b;
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3104
fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }
    val list = mutableListOf<Long>()
    for(i in 1..Math.sqrt(m.toDouble()).toInt()){
        if(m % i == 0L){
            list.add(i.toLong())
            list.add(m/i)
        }
    }
    list.sortDescending()
    list.forEach {
        if((m - it*(n - 1)) % it == 0L && m - it*(n - 1) > 0){
            println(it)
            return
        }
    }
}

Measured memory_bytes: 37872
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)	for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  100005
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



void solve(){
	ll n;
	string s;
	cin>>n>>s;
	vi v1,v2,v3;
	ll an=0;
	ll c[n+5][3];
	rep(i,0,n+5)
	rep(j,0,3)
	c[i][j]=0;
	rep(i,0,n){
		if(i){
			rep(j,0,3) c[i][j]=c[i-1][j];
		}
		if(s[i]=='R') c[i][0]+=1;
		if(s[i]=='G') c[i][1]+=1;
		if(s[i]=='B') c[i][2]+=1;
	}
	rep(j,0,3) c[n][j]=c[n-1][j];
	map<char,int> m;
	m['R']=0;
	m['G']=1;
	m['B']=2;
	ll x=0;
	rep(i,0,n){
		// cout<<an<<endl;
		x+=m[s[i]];
		rep(j,i+1,n){
			if(s[i]==s[j]) continue;
			x+=m[s[j]];
			if(x==1){
				an+=(c[n][2]-c[j][2]);
				if(2*j-i<n&&s[2*j-i]=='B') an--;
			}
			if(x==2){
				an+=(c[n][1]-c[j][1]);
				if(2*j-i<n&&s[2*j-i]=='G') an--;
			}
			if(x==3){
				an+=(c[n][0]-c[j][0]);
				if(2*j-i<n&&s[2*j-i]=='R') an--;
			}
			x-=m[s[j]];
		}
		x-=m[s[i]];
	}
	cout<<an<<endl;
}	

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1,an=1;
	// cin>>TESTS;
	while(TESTS--){
		// cout<<"Case #"<<an<<": ";
		an++;
		solve();

	}
	return 0;
}


Measured memory_bytes: 3660
import math
N = int(input())
ans = 0
for m in range(1,N+1,2):
    P = set([1,m])
    for k in range(2,math.floor(math.sqrt(m))+1):
        if m % k == 0:
            P.add(k)
            P.add(m//k)
    if len(P) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 38384
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize,
    }
    let mut a = Vec::new();
    let mut c = Vec::new();
    for _ in 0..m {
        input!(aa: i64, b: usize);
        input!(cc: [Usize1; b]);
        a.push(aa);
        c.push(cc);
    }

    let mut keybit = Vec::new();
    for (i, cc) in c.into_iter().enumerate() {
        let mut bit = 0;
        for id in cc {
            bit += 1<<id;
        }
        keybit.push((bit, a[i]));
    }
    
    let mut price = vec![1<<30; 1<<n];
    for mask in 1..1<<n {
        for &(bit, value) in &keybit {
            if mask & bit == mask {
                price[mask] = min(price[mask], value);
            }
        }
    }

    let mut memo = HashMap::new();
    let ans = dfs(0, 0, &price, n, &mut memo);
    if ans > 1<<25 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn dfs(mask: usize, prev: usize, price: &[i64], n: usize, memo: &mut HashMap<(usize, usize), i64>) -> i64 {
    if mask == (1<<n) - 1 {
        return 0;
    }
    if let Some(&res) = memo.get(&(mask, prev)) {
        return res;
    }

    let mut res = 1<<30;
    for mask2 in 1..1<<n {
        if mask & mask2 != 0 {
            continue;
        }
        res = min(res, price[mask2] + dfs(mask | mask2, mask, price, n, memo));
    }
    memo.insert((mask, prev), res);
    res
}

Measured memory_bytes: 40764
#include <stdio.h>


void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}


void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}

int main(void)
{
    int na, nb, nc;
    

 scanf("%d", &na);
 scanf("%d", &nb);
 scanf("%d", &nc);
    
    sort3(&na, &nb, &nc);

    printf("%d %d %d\n",na,nb,nc);
    return (0);
}


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

typedef long long ll;
ll MOD = 1000000007;

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}


int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll cnt4 = 0,cnt2 = 0;
  for(ll i = 0;i < N;i++){
    cin >> A[i];
    A[i] %= 4;
    if(A[i] == 0){
      cnt4++;
    }
    if(A[i] == 2){
      cnt2++;
    }
  }
  if(cnt4 + 1 >= N-cnt4){
    cout << "Yes" << endl;
    return 0;
  }
  
  ll re = cnt2;
  ll t = N - cnt4 - cnt2;
  bool frag = 0;
  if(cnt4 + 1 == t){
    if(cnt2 % 2 == 1){
      cout << "No" << endl;
      return 0;
    }else{
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(cnt4 + 1 > t){
    cnt2 -= cnt4 + 1 - t;
    frag = 1;
  }
  /*if(cnt4 * 2>= t && cnt2 == 0){
    cout << "Yes" << endl;
    return 0;
  }
  ll cnt27 = cnt2 / 2;
  if(cnt2 % 2 == 1){
    cnt2 = 1;
  }else{
    cnt2 = 0;
  }
  if(cnt4 * 2 > t && cnt2 == 1){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;*/
  if(cnt4 + 1 < t){
    cout << "No" << endl;
    return 0;
  }
  if(frag){
    cout << "Yes" << endl;
    return 0;
  }else{
    if(cnt2 % 2 == 0){
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1024