akhauriyash/Code-Regression huggingface dataset:
#find number range

N = int(input())

range_num = 0
odd_num = 0

for i in range(7):
    if N % (10 ** i) == N:
        range_num = i
        break

if range_num == 1:
    odd_num = N
elif range_num == 2:
    odd_num = 9
elif range_num == 3:
    odd_num = N - 90
elif range_num == 4:
    odd_num = 909
elif range_num == 5:
    odd_num = N-9090
elif range_num == 6:
    odd_num = 90909
else:
    print("out of range")

print(odd_num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	vl a(n);
	rep(i,0,n)cin >> a[i];
	vl memo(n);
	ll sum = 0;
	rep(i,0,n){
		if(i % 2 == 0)sum += a[i];
		else sum -= a[i];
	}
	sum /= 2;
	memo[0] = sum;
	rep(i,1,n){
		memo[i] = a[i-1] - memo[i-1];
	}
	rep(i,0,n)cout << memo[i]*2 << endl;


	return 0;
}

Measured memory_bytes: 4840
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
#def MXI(): return [LI() for i in range(n)]　
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
s=SI()
t=SI()
a=len(s)
b=len(t)
#アルファベットから数字へと変換する辞書
alphasm=[chr(i) for i in range(97, 97+26)]
alphadic={}
for i in range(26):
    alphadic[alphasm[i]]=i
strlis=[[] for i in range(26)]
#print(alphadic)
#print(strlis)
for i in range(a):
    strlis[alphadic[s[i]]].append(i)
#print(strlis)
rd=0
pos=-1
#print(strlis[a])
i=0
while i<b:
    if len(strlis[alphadic[t[i]]])==0:
        print(-1)
        sys.exit()
        #print("a")
    if pos==-1:
        pos=strlis[alphadic[t[i]]][0]
        i+=1
        #print("b")
    elif strlis[alphadic[t[i]]][-1]<=pos:
        rd+=1
        pos=-1
        #print("c")
    else:
        pos=strlis[alphadic[t[i]]][bisect_right(strlis[alphadic[t[i]]],pos)]
        i+=1
        #print("d")
    #print(rd,pos)
print(rd*a+pos+1)


    
        
#現在の周回数、何個目かの情報を持っておく
#次の周回に行くかどうかの判定 行かないなら二分探索




            
    
    

Measured memory_bytes: 13792
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

Int par1[200005];
Int par2[200005];

Int find(Int *f, Int x) {
    return f[x] == x ? x : (f[x] = find(f, f[x]));
}

int main() {
    ios::sync_with_stdio(false);
    Int n, k, l;
    cin >> n >> k >> l;
    for (Int i = 1; i <= n; i++) par1[i] = par2[i] = i;
    vector<Int> p(k), q(k), r(l), s(l);
    for (Int i = 0; i < k; i++) {
        cin >> p[i] >> q[i];
        par1[find(par1, p[i])] = find(par1, q[i]);
    }
    for (Int i = 0; i < l; i++) {
        cin >> r[i] >> s[i];
        par2[find(par2, r[i])] = find(par2, s[i]);
    }
    map<pair<Int, Int>, Int> mp;
    for (Int i = 1; i <= n; i++) {
        mp[make_pair(find(par1, i), find(par2, i))]++;
    }
    for (Int i = 1; i <= n; i++) {
        cout << mp[make_pair(find(par1, i), find(par2, i))] << " ";
    }
    cout << '\n';
    return 0;  
}

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

using namespace std;
#define ll long long

ll dp[10011][110][2];
int done[10011][110][2];
int cs;
string A;

ll k;

#define mod 1000000007

ll solve(int pos, int sum, bool small)
{
    if(pos == A.size())
    {
        if(sum == 0)
            return 1;
        else
            return 0;
    }

    if(done[pos][sum][small] == cs)
        return dp[pos][sum][small];

    ll ret = 0, i;
    if(small)
    {
        for(i = 0; i < 10; i++)
            ret = (ret + solve(pos + 1, (sum + i) % k, true))%mod;
    }
    else
    {
        for(i = 0; i < A[pos] - '0'; i++)
            ret = (ret + solve(pos + 1, (sum + i) % k, true))%mod;
        ret = (ret + solve(pos + 1, (sum + A[pos]-'0') % k, false))%mod;
    }

    done[pos][sum][small]=cs;
    return dp[pos][sum][small] = ret;
}

int main()
{
    //freopen("out.txt", "w", stdout);
    int test, i;
    ll low, high;
    for(int caseno = 1; cin >> A; caseno++)
    {
        cin >> k;
        cs++;
        high = solve(0, 0, 0) - 1;
        if (high < 0) high += mod;
        printf("%lld\n", high);
    }

    return 0;
}


Measured memory_bytes: 26880
#include <stdio.h>

main(){
    int n;
    char s[300000];

    scanf("%d",&n);
    scanf("%s",s);

    int i;
    int c,min=0;

    for(i=1;i<n;i++)
        if(s[i]=='E')
            min++;
    c=min;
    for(i=1;i<n;i++){
        if(s[i-1]=='W')
            c++;
        if(s[i]=='E'){
            c--;
            if(min>c)
                min=c;
        }
    }
    printf("%d\n",min);
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {set_intersection(ALL(a),ALL(b),inserter(c,c.end()));}
template<class T> void getor(const T &a,const T &b,T &c) {set_union(ALL(a),ALL(b),inserter(c,c.end()));}

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

const int MOD=1e9+7;


int main() {
  int N;cin>>N;
  int tmp = N*100;
  if (tmp%108==0) OUT(tmp/108);
  else {
    int tmp2=tmp/108+1;
    (tmp2*108/100==N) ? OUT(tmp2) : OUT(":(");
  }

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int ans = N;
    int c = 0;
    for (int i = 0;i <= N;i++){
        c = 0;
        int t = i;
        while (t > 0){
            c += t%6;
            t /= 6;
        }
        t = N - i;
        while (t > 0){
            c += t%9;
            t /= 9;
        }
        if (ans > c){
            ans = c;
        }
        
    }
    cout << ans << endl;
}


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

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

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

    int H,A; cin >> H >> A;

    cout << (H-1)/A+1 << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll dp[3005][3005][4];
vector<vector<p2>> v(3005);
void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	for(ll i=0;i<k;i++){
		ll x,y,w;
		cin>>x>>y>>w;
		v[x].push_back({y,w});
	}
	for(ll i=1;i<=n;i++)
		if(!v[i].empty())
			sort(v[i].begin(),v[i].end());
	for(ll i=1;i<=n;i++){
		k=0;
		for(ll j=1;j<=m;j++){
			ll val=0;
			if(k<sz(v[i])&&v[i][k].first==j){
				val=v[i][k].second;
				k++;
			}
			ll tr=0;
			for(ll t=0;t<4;t++){
				tr=max(tr,dp[i-1][j][t]);
				dp[i][j][t]=dp[i][j-1][t];
			}
			dp[i][j][0]=max(dp[i][j][0],tr);
			if(val){
				dp[i][j][1]=max(dp[i][j][1],tr+val);
				for(ll t=1;t<4;t++)
					dp[i][j][t]=max(dp[i][j][t],dp[i][j-1][t-1]+val);
			}
		}
	}
	ll res=0;
	for(ll i=0;i<4;i++)
		res=max(res,dp[n][m][i]);
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 290916
n=int(input())
w=[input() for i in range(n)]
setw=set(w)
if len(setw)!=len(w):
    print("No")
    exit()
for i in range(1,n):
    if w[i][0]!=w[i-1][-1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
//#include <bits / stdc++.h>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
#define Maxl (5000)
#define LL long long
#define inf (0X7fffffff/2)

LL K;
int len,nl,nr;
char st[Maxl],ans[Maxl];
int dp[Maxl][Maxl];
LL cnt[Maxl][Maxl];
void dfs(int l,int r){
	if (dp[l][r]!=0) return;
	dp[l][r]=inf;
	cnt[l][r]=0;
	if (l>=r)
	{
		dp[l][r]=(l==r);
		cnt[l][r]=1;
		return;
	}
	if (st[l]==st[r])
	{
		dfs(l+1,r-1);
		dp[l][r]=dp[l+1][r-1]+2;
		cnt[l][r]=cnt[l+1][r-1];
		return;
	}
	
	dfs(l+1,r);
	dfs(l,r-1);
	dp[l][r]=min(dp[l+1][r]+2,dp[l][r-1]+2);

	if (dp[l][r]==dp[l+1][r]+2) cnt[l][r]+=cnt[l+1][r];
	if (dp[l][r]==dp[l][r-1]+2) cnt[l][r]+=cnt[l][r-1];
	if (cnt[l][r]>K) cnt[l][r]=K+1;
}
void getans(int l,int r,LL Now){
	if (l>=r)
	{
		if (l==r) ans[nl++]=st[l];
		return;
	}
	if (st[l]==st[r])
	{
		ans[nl++]=st[l];
		ans[nr--]=st[r];
		getans(l+1,r-1,Now);
		return;
	}
	if (dp[l][r]==dp[l+1][r]+2&&dp[l][r]!=dp[l][r-1]+2)
	{
		ans[nl++]=st[l];ans[nr--]=st[l];
		getans(l+1,r,Now);
		return;
	}
	if (dp[l][r]!=dp[l+1][r]+2&&dp[l][r]==dp[l][r-1]+2)
	{
		ans[nl++]=st[r];ans[nr--]=st[r];
		getans(l,r-1,Now);
		return;
	}
	if (st[l]<st[r])
	{
		if (Now<=cnt[l+1][r])
		{
			ans[nl++]=st[l];ans[nr--]=st[l];
			getans(l+1,r,Now);
		}
		else
		{
			ans[nl++]=st[r];ans[nr--]=st[r];
			getans(l,r-1,Now-cnt[l+1][r]);
		}
	}
	else
	{
		if (Now<=cnt[l][r-1])
		{
			ans[nl++]=st[r];ans[nr--]=st[r];
			getans(l,r-1,Now);
		}
		else
		{
			ans[nl++]=st[l];ans[nr--]=st[l];
			getans(l+1,r,Now-cnt[l][r-1]);
		}
	}
}
int main(){
	scanf("%s",st+1);
	scanf("%lld",&K);
	len=strlen(st+1);
	dfs(1,len);	if (cnt[1][len]<K)
	{
		printf("NONE\n");
	}
	else
	{
		nl=1;nr=dp[1][len];
		getans(1,len,K);
		printf("%s\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 120340
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
using namespace std;
const int maxn = 1e5+5;
map<int,int>mp;

int main(){
	int n, k; cin >> n >> k;
	int d, x;
	for(int i = 1; i <= k; i++){
		cin >> d;
		for(int j = 1; j <= d; j++){
			cin >> x;
			mp[x] = 1;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) if(!mp[i]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3644
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    string s, pre;
    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") return;
    pre = s;
    int a = 0, b = n;
    while (s != "Vacant") {
        int mid = (a + b) / 2;
        cout << mid << endl;
        cin >> s;
        if ((mid - a)%2 == 0) {
            if (s == pre) {
                a = mid;
                pre = s;
            } else {
                b = mid;
            }
        } else {
            if (s == pre) {
                b = mid;
            } else {
                a = mid;
                pre = s;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


int main() {
    int n;cin>>n;
    vector<int>a(n),ecnt(101000),ocnt(101000);

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

    int emaxc=0,emaxn=0,esmaxc=0;
    int omaxc=0,omaxn=0,osmaxc=0;

    rep(i,n){
        if(i%2==0){
            ecnt[a[i]]++;
        }
        else {
            ocnt[a[i]]++;
        }
    }

    rep(i,101000){
        if(emaxc<ecnt[i]){
            emaxc=ecnt[i];
            emaxn=i;
        }
    }

    ecnt[emaxn]=0;
    rep(i,101000){
        if(esmaxc<ecnt[i]){
            esmaxc=ecnt[i];
        }
    }

    rep(i,101000){
        if(omaxc<ocnt[i]){
            omaxc=ocnt[i];
            omaxn=i;
        }
    }

    ocnt[omaxn]=0;
    rep(i,101000){
        if(osmaxc<ocnt[i]){
            osmaxc=ocnt[i];
        }
    }

    if(emaxn!=omaxn){
        cout<<n-emaxc-omaxc<<endl;
        return 0;
    }

    cout<<min(n-emaxc-osmaxc,n-esmaxc-omaxc)<<endl;

}



Measured memory_bytes: 1408
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    A = read_ints()
    dp = [
        [0]*(N+1) for _ in range(N+1)
    ]
    AI = sorted(((a, i) for i, a in enumerate(A)), reverse=True)
    for i, (a, ix) in enumerate(AI):
        # dp[x][y] = max(dp[x-1][y]+A[x+y]*x, dp[x][y-1]+A[x+y]*y)
        # add a to the left
        for x in range(i+2):
            y = i+1-x
            if y > 0:
                dp[x][y] = max(dp[x][y], dp[x][y-1]+a*abs(N-y-ix))
            if x > 0:
                dp[x][y] = max(dp[x][y], dp[x-1][y]+a*abs(ix-x+1))
    return max(dp[i][N-i] for i in range(N+1))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 106196
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef pair<int, int>P;
typedef long long ll;

struct st {
	int a, b, c;
};
bool operator<(st a, st b) {
	return a.a < b.b;
}
int main() {
	int t; scanf("%d", &t);
	rep(i, t) {
		int n, d; scanf("%d%d", &n, &d);
		vector<int>cook{ d };
		priority_queue<st>que;
		rep(j, n - 1) {
			for (int k = j; k < cook.size(); k++) {
				int idx, Max = 0;
				rep(l, 128) {
					if (Max < l + cook[k] ^ l) {
						idx = l;
						Max = l + cook[k] ^ l;
					}
				}
				que.push({ Max - cook[k], k,idx });
			}
			st p = que.top(); que.pop();
			cook.push_back(p.c);
			cook.push_back(cook[p.b] ^ p.c);
			cook.erase(cook.begin() + p.b);
		}
		int sum = 0;
		for (int i : cook)sum += i;
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> grid(h + 2, vector<char>(w + 2, '#'));
	for(int i = 1; i <= h; ++i) for(int j = 1; j <= w; ++j) cin >> grid[i][j];
	for(auto &row : grid)
	{
		for(auto &node : row) cout << node;
		cout << '\n';
	}
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD 1000000007

int n, a, b, c, d;
vector<lli> k;
vector<vector<lli>> o;
vector<vector<lli>> dp;

void kk(void){
	k.resize(n+1);
	k[0] = 1;
	reg(i, 1, n) k[i] = (k[i-1] * i)%MOD;
	return;
}

lli po(lli ii, lli j){
	lli t[32], ret = 1; t[0] = ii%MOD;
	rep(i, 31) t[i+1] = (t[i]*t[i])%MOD;
	rep(i, 31) if((j>>i)&1) ret = (ret*t[i])%MOD;
	if(ret < 0) cout << ii << " " << j << endl;
	return ret;
}

void rev(void){
	vector<lli> w(n+1);
	rep(i, n+1) w[i] = po(k[i], MOD-2);
	rep(i, n+1) rep(l, n+1) o[l][i] = (po(k[l], MOD-1-i)*w[i])%MOD;
	return;
}

lli f(lli l, lli r){
	if(dp[l][r] != -1) return dp[l][r];
	if(l == b+1){
		if(r == 0) return dp[l][r] = k[n];
		else return dp[l][r] = 0;
	}else{
		lli ret = f(l+1, r);
		reg(i, c, min(d, int(r/l))) ret += (f(l+1, r - i*l)*o[l][i])%MOD;
		return dp[l][r] = ret%MOD;
	}
}

int main(void){
	cin >> n >> a >> b >> c >> d;
	dp.assign(n+2, vector<lli>(n+2, -1));
	o.assign(n+2, vector<lli>(n+2));
	kk(); rev();
	cout << f(a, n) << endl;	
	return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 
int A[50], n, memo[50][500];
 
int solve (int i, int m) {
  
  if (m == 0) 
    memo[i][m] = 1;
  else if (i >= n) 
    memo[i][m] = 0;
  else if (solve(i + 1, m))
    memo[i][m] = 1;
  else if (solve(i + 1, m - A[i])) 
    memo[i][m] = 1;
  else 
    memo[i][m] = 0;

  return memo[i][m];
}
 
int main(){
  REP(i, 50) {
    REP(j, 500) {
      memo[i][j] = -1;
    }
  }
  int q, M;
  cin >> n;
  REP(i, n) {
    cin >> A[i];
  }
  cin >> q;
  REP(i, q) {
    cin >> M;
    if (solve(0, M)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
 
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=300005,maxm=1006;
const double pi=acos(-1.0);
//const ll mod=1000000007;
const ll mod=998244353;
const double eps=1e-8;

int n;

char c[maxm];

int main()
{
	int i,j;
	scanf("%s",&c);
	for(i=0;i<3;i++) printf("%c",c[i]);
	printf("\n");
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(0);
   int a,b,c;
   cin>>a>>b>>c;
   if(a>=1&&b>=1&&c>=1&&a<=1000&&b<=1000&&c<=1000)
   {
      for(int i=b;i<=c;i++)
     {   
         if(i%a==0)
         {
           cout<<"OK";
           return 0;
         }
     }
      cout<<"NG";
    }

return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 123456789012345
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

ll A, B;


int main()
{
	IN >> A >> B;

	if ((A * B) % 2 == 0) OUT << "No" << endl;
	else OUT << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> mpq;

const ll INF = 1e18;
const int mod = 1e9+7;
const int dX[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

#define whatis(x) cerr << #x << " is " << x << endl;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft front()
#define bk back()
#define sz(x) (long long)x.size()
#define all(x) (x).begin(), (x).end()
#define ub upper_bound
#define lb lower_bound
#define FOR(i, a) for(int i = 0; i < a; i++)
#define FoR(i, a) for(int i = 1; i <= a; i++)
#define ROF(i, a) for (int i = (a)-1; i >= 0; i--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//-----------------------| Template By: DakDak |----------------------------
int n, m;
vector<int> adjList[100005];
vector<bool> visited;
vector<int> topoSorted;
int dp[100005];

void dfs(int curr){
    visited[curr] = true;
    for(int u : adjList[curr]){
        if(!visited[u]){
            dfs(u);
        }
    }
    topoSorted.pb(curr);
}
void topoSort(){
    for(int i = 0; i < n; i++){
        if(!visited[i]){
            dfs(i);
        }
    }
}

int main(){
    cin >> n >> m; int a, b;
    for(int i = 0; i < m; i++){
        cin >> a >> b; a--; b--;
        adjList[a].pb(b);
    }
    visited.assign(n, false);
    topoSorted.clear();
    topoSort(); 
    reverse(all(topoSorted));
    int ans = -1;
    for(int v : topoSorted){
        for(int u : adjList[v]){
            dp[u] = max(dp[u], dp[v]+1);
            ans = max(ans, dp[u]);
        }
    }
    cout << ans << endl;
    return 0;
    // Read notes to self
}

/* NOTES TO SELF:
 * Check for int vs ll, worst case just switch everything to ll
 * Check for array bounds if you SEGFAULT, especially in range based loops
 * Always initialize everything in global 
 * Edge cases such as n = 1 or 0
 * Make sure to calculate big O complexity
 * You are geniosity you got this
 */





Measured memory_bytes: 7672
n = int(input())
w_former = 0
w_latter = 0
diff = 100
w = list(map(int, input().split()))
i = 0

while i < n:
    i += 1
    if diff > abs(sum(w[0:i+1]) - sum(w[i+1:n])):
        diff = abs(sum(w[0:i+1]) - sum(w[i+1:n]))
print(diff)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

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

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	vector<int> s(100003);
	++s[0];
	REP(i,0,N){
		int a,b;
		cin >> a >> b;
		++s[a];
		--s[b+1];
	}
	int ans=0;
	REP(i,1,100003){
		s[i]+=s[i-1];
		if(i<=s[i]) ans=max(ans,min(i-1,s[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1524
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool solve(int f,int t,int o){
    return f+(t%2==0)>=o or (t%2 and f>=o) ;
}
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int n; cin  >> n;
    vector<int>v(n);
    for(auto && e: v) cin >> e;
    int f = 0,t = 0,o  = 0;
    for(auto val : v) (val % 4 == 0 ? ++f :val % 2 == 0 ? ++t : ++o);
    cout << (solve(f,t,o) /*or solve2(f,t,o)*/ ? "Yes":"No" ) << endl;
}




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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i=0; i<n; i++){
        cin >> A.at(i);
    }
    for(int i=0;i<n-k; i++){
        if(A.at(i) < A.at(k+i)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4048
program skip
  implicit none
  integer :: n, x(100001) = 0, i, m
  read(*,*) n, x(1)
  read(*,*) x(2:n+1)
  call quick_sort(x(1:n+1))
  m = x(2)-x(1)
  do i = 2, n
    m = gcd(m,x(i+1)-x(i))
  end do
  write(*,'(i0)') m
contains
  integer function gcd(a,b)
    integer, intent(in) :: a, b
    integer :: x, y
    x = max(abs(a),abs(b))
    y = min(abs(a),abs(b))
    do while (y > 0)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      a(l) = xor(a(l),a(r))
      a(r) = xor(a(l),a(r))
      a(l) = xor(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program skip

Measured memory_bytes: 1152
#include<iostream>

using namespace std;

typedef long long ll;
const int MAX = 101;
ll path[MAX][MAX];
int N;

void input(){
  cin >> N;
  for(int i = 0; i < N; i++)
    for(int j = 0; j < N; j++)
      cin >> path[i][j];
}

void solve(){
  ll ans = 0;
  for(int i = 0; i < N; i++)
    for(int j = i+1; j < N; j++)
      ans += min(path[i][j],path[j][i]);
  cout << ans << endl;
}

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

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <limits>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <queue>

#define MAX 100009
#define INF 99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()  
#define mp       make_pair
#define ll	long long
#define fi	first
#define se second

const long double pi = 3.141592653589793238L;
const ll mod = 1e9 + 7;

/**
*
* @Author Lahia omar
*/

using namespace std;

void split(vector<string> &v, string cur) {
	istringstream iss(cur);
	copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(v));
}
int n;
vector<int > tab;
int main(int argc, char* argv[]) {
	
	cin >> n; tab.resize(n);
	for (int i = 0; i < n;i++) {
		cin >> tab[i];
	}
	cout << *max_element(all(tab)) - *min_element(all(tab)) << endl;
	return 0;
}

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

using namespace std;

int main() {          
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a % b == 0) {
		cout << -1 << endl;
	} else {
	 	cout << a << endl;
	}
	return 0;
}


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

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

  int n; cin >> n;
  vector<int> v(5);
  int mn = 1LL << 60;
  for(int i = 0; i < 5; i++){
    cin >> v[i];
    mn = min(mn,v[i]);
  }

  cout << (n + mn-1)/mn + 4 << 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);
		while(sc.hasNext()) {
			double[] p = new double[8];
			for(int i = 0; i < 8; i++) {
				p[i] = sc.nextDouble() * 10;
			}
			Vec AB = new Vec(p[2] - p[0], p[3] - p[1]);
			Vec CD = new Vec(p[6] - p[4], p[7] - p[5]);
			double d = AB.x * CD.x + AB.y * CD.y;
			if(d == 0.0) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
		sc.close();
	}
	static class Vec {
		double x, y;
		Vec(double x, double y){
			this.x = x;
			this.y = y;
		}
	}
}


Measured memory_bytes: 30052
class Combination:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        l = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            l.append(num)
        self.fac = l.copy()

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        l = [1 for i in range(n+1)]
        l[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            l[i] = num
        self.rec = l.copy()

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod

mod = 10**9 + 7

k = int(input())
s = input()
n = len(s)

c = Combination(k + n, mod)

pow25 = [1]
pow26 = [1]
for _ in range(k):
    pow25.append(25 * pow25[-1] % mod)
    pow26.append(26 * pow26[-1] % mod)

ans = 0
for i in range(k+1):
    ans += c.comb(n+i-1, i) * pow25[i] * pow26[k-i]
    ans %= mod

print(ans)

Measured memory_bytes: 245636
#include <iostream>
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES

using namespace std;
int a,b,n;

int main()
{
    scanf("%d%d%d",&a,&b,&n);
    double mx = a*b*a/2.0, ans;
    if(mx>=n){
        double da = 1.0*n/b/a*2;
        ans = 90 - atan(da/b)*180/M_PI;
    }else if(mx<n){
        double x = 2.0*n/a/a-b;
        ans = 90 - atan(a/(b-x))*180/M_PI;
    }
    printf("%.9lf\n",ans);
    return 0;
}


Measured memory_bytes: 4016
import sys
sys.setrecursionlimit(10**8)
N = int(input())
UVW = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for u,v,w in UVW:
    u,v = u-1,v-1
    es[u].append((v,w))
    es[v].append((u,w))

ans = [None] * N
ans[0] = 0

def dfs(v,p=-1):
    for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v)
dfs(0)

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

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

int N,K;
vector<int> G[2222];
void bfs(int id,int *A){
  queue<int> q; q.push(id); A[id] = 0;
  while( !q.empty() ){
    int p = q.front(); q.pop();
    for( int to : G[p] ){
      if( A[to] == -1 ){
        A[to] = A[p] + 1;
        q.push( to );
      }
    }    
  }
}


int main(){
  cin >> N >> K;
  for(int i=0;i<N-1;i++){
    int a,b; cin >> a >> b; --a; --b;
    G[a].push_back( b );
    G[b].push_back( a );
  }

  int A[2222];
  int B[2222];

  int res = N;

  if( K & 1 ){//k
    for(int u = 0; u < N; u++ ){      
      for( int v : G[u] ){
        int ret = 0;
        memset( A, -1, sizeof( A ) );
        memset( B, -1, sizeof( B ) );
        bfs( u, A ); bfs( v, B ) ;       
        for(int i=0;i<N;i++) if( min( A[i], B[i] ) > K/2 ) ret++;
        res = min( res, ret );
      }      
    }
  } else {//g
    for(int u = 0; u < N; u++ ){
      int ret = 0;
      memset( A, -1,sizeof( A ) );
      bfs( u, A );
      for(int i=0;i<N;i++) if( A[i] > K/2 ) ret++;
      res = min( ret, res );
    }
  }

  cout << res << endl;
  
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

int main()
{
	double l;
	cin >> l;
	cout << setprecision(12) << l/3 * l/3 * l/3 << endl;
}


Measured memory_bytes: 256
n = list(map(int,input().split()))
vote = list(map(int,input().split()))
a = sum(vote)/(4*n[1])
result = 0
for i in range(n[0]):
  if vote[i]>=a:
    result += 1
if result<n[1]:
  print('No')
else:
  print('Yes')

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

constexpr int MX_V = 1000000;
int cp[MX_V + 1];
int ns[MX_V + 1];

void solve() {
    for (ll i = 2; i <= MX_V; i++) {
        if (cp[i] == 0) {
            cp[i] = i;
        }
        for (ll j = i + i; j <= MX_V; j += i) {
            if (cp[j] != 0) continue;
            cp[j] = i;
        }
    }

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

    unordered_set<int> st;
    int mx = 0;
    for (ll i = 0; i < N; i++) {
        st.clear();
        int t = A[i];
        while (t > 1) {
            int q = cp[t];
            if (q > 1) {
                st.emplace(q);
                t /= q;
            }
        }
        for (auto x : st) {
            chmax(mx, ++ns[x]);
        }
    }

    if (mx <= 1) {
        prints()("pairwise coprime");
    }
    else if (mx < N) {
        prints()("setwise coprime");
    }
    else {
        prints()("not coprime");
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 14900
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int S[101];
int ans;
bool dp[101][10001];
int main(void) {
	cin >> N;
	const int MAX = N * 100;
	for (int n = 1; n <= N; ++n) cin >> S[n];
	dp[0][0] = true;
	for (int n = 1; n <= N; ++n) {
		for (int s = 0; s <= MAX; ++s) {
			if (dp[n - 1][s])  dp[n][s] = dp[n][s + S[n]] = true;
		}
	}
	for (int s = N * 100; s >= 0; --s) {
		if (dp[N][s] && s % 10 != 0) {
			ans = s;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, p: [usize; n]};
    let p: Vec<usize> = p;

    let mut count = 1;
    let mut index = 0;

    for i in 1..n {
        if p[index] >= p[i] {
            index = i;
            count += 1;
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4748
S = input()
K = int(input())
N = len(S)
spyon = set([])
alp = alp2 = alp3 = 'z'
for i in range(N):
    alp = min(alp,S[i])
if N - S.rfind(alp) + 1 < K:
    for i in range(N):
        if S[i] == alp:
            continue
        alp2 = min(alp2,S[i])
if 2*N - S.rfind(alp)- S.rfind(alp2) + 2 < K:
    for i in range(N):
        if S[i] == alp or S[i] == alp2:
            continue
        alp3 = min(alp3,S[i])

for i in range(N):
    if S[i] != alp and S[i] != alp2 and S[i] != alp3:
        continue
    for j in range(6):
        spyon.add(S[i:i+j])
print(sorted(spyon)[K])

Measured memory_bytes: 3064
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll cul(ll n) {
	ll step = 1;
	FOR(i, 2, n + 1)step = (step*i) % mod;
	return step;
}

int main() {
	ll N,M,ans=0;
	cin >> N >> M;

	if (N == M) {
		ans = (2*((cul(N)*cul(M)) % mod))%mod;
	}
	else if (N-M==1) {
		ans = (cul(N)*cul(M)) % mod;
	}
	else if (N - M == -1) {
		ans = (cul(N)*cul(M)) % mod;
	}
	else {
		ans = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 

using namespace std;
int main() {
    int A, B, ans = 0;
    cin >> A >> B;
    for (int i = 0; i < 2; i++) {
        if (A >= B) {
            ans += A;
            A--;
        } else {
            ans += B;
            B--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int a,b,k;
   cin>>a>>b>>k;

   for(int i=a;i<=b;i++){
      if(i<a+k ||i>b-k)cout<<i<<endl;

   }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int ans=0;

  for(int i=1;i<=N;i+=2){
      int counter=0;
  	for(int j=1;j<=i;j++){
    	if(i%j==0){
        counter++;
        }
	}
   	if(counter==8){
    ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3620
import           Control.Monad (when)

main :: IO ()
main = do
  n <- readLn
  ls <- map read . words <$> getLine
  when (length ls /= n) $ error "length ls /= n"
  putStrLn $ if f ls then "Yes" else "No"

f :: [Int] -> Bool
f xs = let (m, ys) = maxAndOthers xs in m < sum ys

maxAndOthers :: (Ord a) => [a] -> (a, [a])
maxAndOthers [] = error "empty"
maxAndOthers (x:xs) = foldr (\y (z, ys) -> if y > z then (y, z : ys) else (z, y : ys)) (x, []) xs


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

int main() {
    int N,h;
    cin >> N>>h;
  
    vector<int> vec(N);
    vector<int> vecb(N);
    for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    cin >> vecb.at(i);
    }

    sort(vec.begin(), vec.end());
     sort(vecb.begin(), vecb.end());
  
  
 int syamu=0;
  
   for (int i = 0; i < N; i++) {
    if(vecb.at(N-1-i) > vec.at(N-1) ){
      syamu +=1;
      h -=vecb.at(N-1-i);
    }
     if(h<=0){
       h =0;
       break;
   }
   }
     
    int p;
  if(h%vec.at(N-1) ==0){
  p= h/vec.at(N-1);
  }
  else{
  p= h/vec.at(N-1) +1;
  }
    
    syamu +=p;
    h =0;
    
  cout << syamu << endl;
 
 }

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  for (int i = 0; i < N; i++) {
    if (((C * i - (N - 1 - i) * D) <= (B - A)) && ((B - A) <= (D * i - (N - 1 - i) * C))) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
//-- In The Name of God --
#include<bits/stdc++.h>
using namespace std;


#define      mod     1e9+7
#define      pai     acos(-1)
#define      ff      first
#define      ss      second
#define      ll      long long
#define      pb      push_back
#define      mp      make_pair
#define      endl    "\n"
#define      fii     freopen("input.txt","r",stdin);
#define      foo     freopen("output.txt","w",stdout);
#define      fast    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const   ll   mx=1e6+10;
bool visited[mx];
int main()
{
    fast;
    ll i,j,a,b,c,d,n,m,t;
    cin>>n>>m;
    vector<ll>vec1,vec2;

    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        if(a==1||b==1)
        {
            if(a==1)
            {
                vec1.pb(b);
            }
            else
            {
                vec1.pb(a);
            }
        }
        if(a==n||b==n)
        {
            if(a==n)
            {
                vec2.pb(b);
                visited[b]=true;
            }
            else
            {
                vec2.pb(a);
                visited[a]=true;
            }
        }
    }
    if(vec1.size()==0||vec2.size()==0)
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    else
    {
        for(auto it:vec1)
        {
            if(visited[it])
            {
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    return 0;
}



Measured memory_bytes: 5204