akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INFLL (1ll<<60)
ll H,W;
ll ans=INFLL;

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>H>>W;
    
    if(H%3==0||W%3==0){
        cout<<0<<"\n";
        return 0;
    }else{
        for(int k=0;k<2;k++){
            ans=min(ans,(H/3+1)*W-H/3*W); //割り切れない時必ず最大(H+1)/3,最小H/3
            swap(H,W);
        }
    }
    
    //次は縦＋横二分割
    
    for(int k=0;k<2;k++){
        for(int ha=1;ha<=H;ha++){
            ll a=ha*W;
            ll b=(H-ha)*(W/2);
            ll c=(H-ha)*((W+1)/2);
            ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
        }
        swap(H,W);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=200010;
int size[N],Flag,cnt2[N],pp[N],cc,sd[N];
int cnt[N],col[N],n,m,ne[N],tot,fi[N],zz[N],flag[N],x,y,X,Y;
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs2(int x){
	cnt2[x]=col[x];flag[x]=1;
	for (int i=fi[x];i;i=ne[i])
		if (!flag[zz[i]]&&!pp[i]){
			dfs2(zz[i]);
			cnt2[x]+=cnt2[zz[i]];
		}
}
int solve(){
	memset(flag,0,sizeof flag);
	dfs2(1);
	int ans=0;
	for (int i=1;i<=n;i++)ans+=abs(size[i]-cnt2[i]-cnt[i]);
	return ans;
}
int check(int x){
	col[X]-=x;col[Y]+=x;
	int k=solve();
	col[X]+=x;col[Y]-=x;
	return k+abs(x);
}
void dfs(int x,int y){
	size[x]=flag[x]=1;cnt[x]=col[x];
	for (int i=fi[x];i;i=ne[i])
		if (i!=y){
			if (flag[zz[i]]&&sd[zz[i]]<sd[x]){
				X=x;cc++;
				Y=zz[i];
				Flag=(sd[x]-sd[zz[i]])&1;
				pp[i]=pp[i^1]=1;
				continue;
			}
			if (flag[zz[i]])continue;
			sd[zz[i]]=sd[x]+1;
			col[zz[i]]=col[x]^1;
			dfs(zz[i],i^1);
			cnt[x]+=cnt[zz[i]];
			size[x]+=size[zz[i]];
		}
}
signed main(){
	scanf("%lld%lld",&n,&m);
	tot=1;
	for (int i=1;i<=m;i++){
		scanf("%lld%lld",&x,&y);
		jb(x,y);jb(y,x);
	}
	col[1]=1;
	dfs(1,0);
	int S=cnt[1],T=n-cnt[1];
	if (m==n-1){
		if (S!=T){
			puts("-1");
			return 0;
		}
		printf("%lld\n",solve());
	}
	else if (Flag){
		if (S!=T){
			puts("-1");
			return 0;
		}
		int l=-n,r=n;
		while (l+5<r){
			int mid1=l+(r-l)/3,mid2=r-(r-l)/3;
			if (check(mid1)>check(mid2))l=mid1;
			else r=mid2;
		}
		int ans=1e18;
		for (int i=l;i<=r;i++)ans=min(ans,check(i));
		printf("%lld\n",ans);
	}
	else {
		if ((S&1)!=(T&1)){
			puts("-1");
			return 0;
		}
		col[X]+=(T-S)/2;
		col[Y]+=(T-S)/2;
		printf("%lld\n",solve()+abs(T-S)/2);
	}
	return 0;
}

Measured memory_bytes: 18176
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string>W(N);
	set<string>st;
	for (int n = 0;n<N;++n) {
		cin >> W[n];
		st.insert(W[n]);
	}
	if (N != st.size()) {
		cout << "No"<<endl;
		return 0;
	}
	for (int n = 0; n < N - 1; ++n) {
		if (W[n][W[n].size()-1]  != W[n+1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(){
	char  a,b,c,d;
	int  A,B,C,D;
	
	cin >> a >> b >> c >> d;
	
	a == '+' ? A=1:A=-1;
	b == '+' ? B=1:B=-1;
	c == '+' ? C=1:C=-1;
	d == '+' ? D=1:D=-1;
	
	cout<< A+B+C+D;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int H=0,W=0;
char getNum(vector<string> &S,int i,int j)
{
	if (S[i][j]=='#'){
		return '#';
	}
	int num=0;
	if (i>=1 && j>=1){
		if (S[i-1][j-1]=='#'){
			num++;
		}
	}
	if (i>=1){
		if (S[i-1][j]=='#'){
			num++;
		}
	}
	if (i>=1 && j<W-1){
		if (S[i-1][j+1]=='#'){
			num++;
		}
	}
	if (j>=1){
		if (S[i][j-1]=='#'){
			num++;
		}
	}
	if (j<W-1){
		if (S[i][j+1]=='#'){
			num++;
		}
	}
	if (i<H-1 && j>=1){
		if (S[i+1][j-1]=='#'){
			num++;
		}
	}
	if (i<H-1){
		if (S[i+1][j]=='#'){
			num++;
		}
	}
	if (i<H-1 && j<W-1){
		if (S[i+1][j+1]=='#'){
			num++;
		}
	}
	return '0'+num;
}
int main(int argc, char* argv[])
{


	cin>>H>>W;
	vector<string> S(H);
	int i,j;
	for (i=0;i<H;i++){
		cin>>S[i];
	}
	for (i=0;i<H;i++){
		for (j=0;j<W;j++){
			char num=getNum(S,i,j);
			S[i][j]=num;
			cout<<S[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n;
    cin >> n;
    vector<string> S(n);
    vector<int> T(n);
    string x;
    rep(i, n) { cin >> S[i] >> T[i]; }
    cin >> x;
    lint ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == x) {
            for (int j = i + 1; j < S.size(); j++) {
                ans += T[j];
            }
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll l[105];
bool check(ll a,ll b,ll c)
{	return a!=b&&b!=c&&a!=c&&a+b>c&&abs(a-b)<c; }
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&l[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			for(int k=j+1;k<=n;k++)
				if(check(l[i],l[j],l[k])) ans++;
	printf("%d",ans);
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
using namespace std;
 
 
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define siii(a, b, c) scanf("%d %d %d", &a, &b, &c)
 
#define sl(a) scanf("%I64d", &a)
#define sll(a, b) scanf("%I64d %I64d", &a, &b)
#define slll(a, b, c) scanf("%I64d %I64d %I64d", &a, &b, &c)
 
#define outi(a) printf("%d\n", a)
#define outii(a, b) printf("%d %d\n", a, b)
#define outiii(a, b, c) printf("%d %d %d\n", a, b, c)
 
#define outl(a) printf("%I64d\n", a)
#define outll(a, b) printf("%I64d %I64d\n", a, b)
#define outlll(a, b, c) printf("%I64d %I64d %I64d\n", a, b, c)
 
#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
 
 
#define fr(i, n) for(ll i=0; i<n;i++)
#define fr1(i, n) for(ll i=1; i<=n;i++) 
 
#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
 
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
typedef long long ll;
typedef pair<int,int> pii;
 
bool ar[5];
 
int main()
{
 
	int a,b;

	sii(a,b);

	ar[a] = 1 ,ar[b] = 1;

	fr1(i,3){
		if(!ar[i])
			outi(i);
	}

 
 
    return 0;
}

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

int a[1001] = {};

int main() {
    bool flag;
    int N;
    long long int ans = 1, tmp = 0;
    long long int M = 1000000007;

    cin >> N;

    for (int i = 2; i <= N; i++) {
     flag = true;
        if (i > 2) {
            for (int k = 2; k < i; k++) {
                if (i % k == 0) {
                    flag = false;
                    break;
                }
            }
        }

        if(flag == false)continue;

        int j = i;
        int cnt = 0;
        while (j <= N) {
            cnt += N / j;
            j *= i;
        }
        ans *= (cnt + 1);
        ans %= M;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    string S;cin >> S;long long N = S.size();
    long long ans = 0;
    long long Bcount = 0;
    //BW→WBということは、Bが前にくるということ（それはそう）
    for(int i = 0;i<N;i++){
        if(S.at(i) == 'B') Bcount++;
        else ans += Bcount;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> A(N); 
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        A[i]--;
    }
    int ret = 0;
    for(int i = 0; i < N; ++i){
        if(A[A[i]] == i) ret++;
    }
    cout << ret/2 << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> d(N+1, vector<ll>(N+1, 1e18));
    vector<pair<ll,ll>> edge(M);
    vector<ll> cost(M);
    rep(i, 0, M){
        ll a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
        edge[i] = {a, b};
        cost[i] = c;
    }
    rep(i, 1, N+1) d[i][i] = 0;
    rep(i, 1, N+1){
        rep(j, 1, N+1){
            rep(k, 1, N+1){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    vector<bool> v(M, false);
    rep(i, 1, N){
        rep(j, i+1, N+1){
            rep(k, 0, M){
                ll a = edge[k].first;
                ll b = edge[k].second;
                if(d[i][b] + cost[k] + d[a][j] == d[i][j]) v[k] = true;
                if(d[i][a] + cost[k] + d[b][j] == d[i][j]) v[k] = true;
            }
        }
    }
    ll ans = 0;
    rep(i, 0, M){
        if(!v[i]){
            cerr << i << endl;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
const solve = xs => {
    let rs = [];

    if (xs.length === 0) return rs;

    let i = -1; j = 0;
    let p = xs[xs.length - 1];

    while (j < xs.length) {
        if (xs[j] <= p) {
            i = i + 1;
            t = xs[i]; xs[i] = xs[j]; xs[j] = t;
        }
        j = j + 1;
    }


    for (let k = 0; k < xs.length; k++) {
        if (k === i) {
            rs.push("[" + xs[k] + "]");
        } else {
            rs.push(String(xs[k]));
        }
    }

    return rs;
}


const main = () => {
    args =
        require('fs').
        readFileSync('/dev/stdin', 'UTF-8').
        split("\n").
        map(line => line.split(' ').map(c => parseInt(c)));

    args.pop();

    const cs = solve(args[1].concat());

    console.log(cs.join(' '));
}

main();



Measured memory_bytes: 34140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    long long int A, B, C, K;
    cin >> A >> B >> C >> K;

    long long int keisuu = (pow(2, K) + 1) / 3;

    long long int takahashi, nakahashi, sub;

    if (K % 2 == 0)
    {
        takahashi = keisuu * A + (keisuu - 1) * B + (keisuu - 1) * C;
        nakahashi = (keisuu - 1) * A + keisuu * B + (keisuu - 1) * C;
    }
    else
    {
        takahashi = (keisuu - 1) * A + keisuu * B + keisuu * C;
        nakahashi = keisuu * A + (keisuu - 1) * B + keisuu * C;
    }

    sub = takahashi - nakahashi;
    if (sub > pow(10, 18))
    {
        cout << "Unfair" << endl;
    }
    else
    {
        cout << sub << endl;
    }

    return 0;
}

Measured memory_bytes: 384
s=input()
a=int(s[:2])
b=int(s[2:])
if a<13 and a>0 and b<13 and b>0:
    print('AMBIGUOUS')
elif a<13 and a>0:
    print('MMYY')
elif b<13 and b>0:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
n,m=map(int,input().split())
a=list()
for i in range(n):
    a.append(list(map(int,input().split())))
b=list()
for i in range(m):
    b.append(int(input()))

for i in range(n):
	ans = 0
	for j in range(m):
		ans += a[i][j] * b[j]
	print(ans)



Measured memory_bytes: 6012
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc103/tasks/abc103_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    vector<pll> ab(M); for(auto& in:ab) cin >> in.first >> in.second;
    sort(ab.begin(),ab.end(),[](const pll& o1,const pll& o2){return o1.second < o2.second; });
    ll l = 0;
    for(int i = 0; i < M;i++){
        if(ab[i].first >= l){
            res++;
            l = ab[i].second;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1792
N, A, B = map(int, input().split())
answer = 0

def sumDigits(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num //= 10
    return sum

for i in range(N+1):
    sum = sumDigits(i)
    if A <= sum <= B:
        answer += i

print(answer)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll N,W;cin>>N>>W;
	ll wo[N+1],vo[N+1];
	wo[0]=vo[0]=0;

	for(ll i=1;i<=N;i++) cin>>wo[i]>>vo[i];
    ll mxv=100000;
	ll DP[mxv+1];
	for(ll i=0;i<=mxv;i++) DP[i]=INT_MAX;
    DP[0]=0;
	for(ll i=1;i<=N;i++){
		for(ll val=mxv;val>=0;val--){
			DP[val]=min(DP[val],(val>=vo[i])?wo[i]+DP[val-vo[i]]:INT_MAX);
		}
	}
	ll ans=0;
	for(ll val=0;val<=mxv;val++){
        if(DP[val]<=W) ans=val;
	}
	cout<<ans;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	char c;
	cin>>c;
	switch(c) {
		case 'A': cout<<"T\n"; break;
		case 'T': cout<<"A\n"; break;
		case 'G': cout<<"C\n"; break;
		case 'C': cout<<"G\n"; break;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) {  
		Scanner input = new Scanner(System.in);
		ArrayList<Integer> arr = new ArrayList<Integer>();
		int N = input.nextInt();
		boolean bad=false;
		for (int i = 1; i <= N; i++) {
			int x = input.nextInt();
			arr.add(x);
			if (x>i) bad=true;
		}
		if (!bad) {
			int[] ans = new int[N];
			int cur = N-1;
			while (arr.size()>0) {
				int index = -1;
				for (int i = 0; i < arr.size(); i++) {
					if (arr.get(i)==i+1) index = i;
				}
				ans[cur] = arr.get(index);
				cur--;
				arr.remove(index);
			}
			for (int i = 0; i < N; i++) {
				System.out.println(ans[i]);
			}
			
		}else System.out.println(-1);
	}	
}

Measured memory_bytes: 24020
K = int(input())

mod = 7
cnt = 0

for i in range(K):
    if mod % K == 0:
        cnt += 1
        break
    else:
        cnt += 1
        mod = (mod * 10 + 7) % K
if mod % K == 0:
    print(cnt)
else:
    print(-1)


Measured memory_bytes: 9168
n,w = map(int,input().split())
value = []
weight = []
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    x,y = map(int,input().split())
    value += [y]
    weight += [x]
for i in range(n):
    for j in range(w+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][w])

Measured memory_bytes: 120684
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl;

int main() {
    int n;
    cin >> n;
    struct S {
        int t, x, y;
    };
    S prev;
    prev.t = prev.x = prev.y = 0;
    for (int i = 0; i < n; ++i) {
        S next;
        cin >> next.t >> next.x >> next.y;
        int d = abs(prev.x - next.x) + abs(prev.y - next.y);
        if (next.t - prev.t >= d) {
            if ((next.t - prev.t) % 2 == d % 2) {

            } else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main() {
  int n;
  while( cin >> n, n != -1 ) {
    int sum = 1150;
    for(int i=11; i<=n; i++) {
      if( i > 30 ) sum += 160;
      else if( i > 20 ) sum += 140;
      else if( i > 10 ) sum += 125;
    }

    cout << 4280 - sum << endl;
  }
} 

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;

namespace arc097_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(Console.ReadLine());
            HashSet<string> set = new HashSet<string>();
            for (int i = 1; i <= n; i++)
            {
                for (int j = 0; j <= s.Length - i; j++) set.Add(s.Substring(j, i));
            }
            var a = set.ToArray();
            Array.Sort(a);
            Console.WriteLine(a[n - 1]);
        }
    }
}

Measured memory_bytes: 14688
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def main():
    S = input()
    return "NO" if S.count("x")>7 else "YES"

print(main())


Measured memory_bytes: 38256
import itertools
N = int(input())
L1 = tuple(map(int,input().split()))
a = 0
L2 = tuple(map(int,input().split()))
b = 0
L = [i for i in range(1,N+1)]
Base = list(itertools.permutations(L))
for i in range(len(Base)):
    if Base[i] == L1:
        a = i+1
for i in range(len(Base)):
    if Base[i] == L2:
        b = i+1
print(abs(a-b))

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

int main(){
    long N, K;
    cin >> N >> K;
    if(!K){
        cout << N * N << endl;
        return 0;
    }
    long ans = 0;
    for(long i = K + 1; i <= N; i++){
        ans += (N + i) / i * (i - K) - min((i * long(1e9) - (N + 1)) % i, i - K);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.HashMap

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = HashMap<Long, Int>(n shl 1)
    readLine()!!.split(' ').forEach {
        val a = it.toLong()
        if (a in aa) {
            aa[a] = aa[a]!! + 1
        } else {
            aa[a] = 1
        }
    }
    val edges = aa.filterValues { 2 <= it }
        .keys
        .sortedDescending()
    val ans = if (edges.isEmpty()) {
        0
    } else if (4 <= aa[edges[0]]!!) {
        edges[0] * edges[0]
    } else if (edges.size < 2) {
        0
    } else {
        edges[0] * edges[1]
    }
    println(ans)
}


Measured memory_bytes: 70760
import math
 
a,b,h,m = map(int,input().split())
tan_sin = math.pi * (h + m/60) / 6  # 時針が H + M/60 時間で動いた角度
cho_sin = math.pi * m/30   # 分針が M 分で動いた角度
 
theta = abs(tan_sin - cho_sin)
c = math.cos(theta)
 
ans = math.sqrt(a**2 + b**2 - 2*a*b*c)  # 余弦定理
 
print(ans)

Measured memory_bytes: 9500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

vector<ll> prime_factor(ll n) {
    vector<ll> res;
    for (ll i = 2; i*i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            int j = i;
            while (n % j == 0) {
                n /= j;
            }
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}
 
int main () {
    
    ll a, b; cin >>a>>b;
 
    vector<ll> ad = prime_factor(a);
    vector<ll> bd = prime_factor(b);

    sort(ad.begin(), ad.end());

    if (ad.size() == 0 || bd.size() == 0) {
        cout << 1 << endl;
        return 0;
    } 

    int count = 1;
    for (int i = 0; i < bd.size(); i++) {
        int ng = -1;
        int ok = ad.size();
        while (abs(ok - ng)>1) {
            int m = (ok+ng)/2;
            if (ad[m] >= bd[i]) {
                ok = m;
            } else {
                ng = m;
            } 
        }
        if (ad[ok] == bd[i]) {
            count++;
        } 
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    d = {}
    N = int(input())
    for i in range(N):
        s = input()
        d.setdefault(s, 1)
        d[s] += 1
    
    d = sorted(d.items())
    d = sorted(d, key=lambda x:x[1], reverse=True)
    n = d[0][1]
    for i in range(len(d)):
        if d[i][1] != n:
            break
        print(d[i][0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 46700
#include<stdio.h>
#include<stdlib.h>
int p[111111];
void set(int t,int y){
p[y]=t;
}
int compare(const void *a,const void *b){
return p[*(int*)a]-p[*(int*)b];
}
int main(){
int n,m,i,a[111111],b[111111],c[111111],ans=0,r=0;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
scanf("%d%d",&a[i],&b[i]);
c[i]=i;
set(a[i],i);
}
qsort(c,m,sizeof(int),compare);
for(i=0;i<m;i++){
if(a[c[i]]>=r){
ans++;
r=b[c[i]];
}
else if(b[c[i]]<r)
r=b[c[i]];
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b * 2) << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;
const long long INF = 1LL << 60;

int N;
vector<int> score;
vector<int> a;
int main(){
   cin >> N;
   a.resize(N); int cnt = 0;
   REP(i,N){
       cin >> a[i];
       if(a[i] % 10 == 0) ++cnt;
   }
   if(cnt == N){
       cout << 0 << endl;
       return 0;
   }
   sort(a.begin(),a.end(),greater<int>());
   int sum = 0;
   REP(i,N) sum += a[i];
   
   int i = N - 1;
   while(sum % 10 == 0 && sum != 0){
       if(a[i] % 10 != 0) sum -= a[i]; --i;
   }

  
   cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(void) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    double slope1, slope2;
    int n;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        slope1 = (y2 - y1) * (x4 - x3);
        slope2 = (y4 - y3) * (x2 - x1);
        
        if(abs(slope1 - slope2) < 0.0000000001) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3124
// aftershock :D
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=3e5+1;
int main() {
    quick
    long long l,r,mn=LONG_LONG_MAX; cin>>l>>r;
    if(r-l>2018){return cout<<0,0;}
    for(long long i = l; i < r; ++i){
        for(long long j = l+1; j <= r; ++j){
            mn = min(mn , ((i*j)%2019));
        }
    }
    cout<<mn;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  s = " " + s;
  auto check = [&](int l, int r) {
    if (s[l] == '#' || s[r] == '#') return false;
    for (int i = l + 1; i <= r; i++) {
      if (s[i] == '#' && s[i - 1] == '#') return false;
    }
    return true;
  };
  if (c == d) return puts("No"), 0;
  if (c < d) {
    if (check(b, d) && check(a, c))
      puts("Yes");
    else
      puts("No");
    return 0;
  } else {
    if (!check(b, d) || !check(a, c)) return puts("No"), 0;
    for (int i = b; i <= d; i++) {
      if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') return puts("Yes"), 0;
      // puts("N");
    }
    puts("No");
  }
}


Measured memory_bytes: 772
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define F first
#define S second

using ll = long long;

int main() {
    int n;
    cin >> n;
    int gcd = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        gcd = __gcd(gcd, x);
    }
    cout << gcd << '\n';
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

long long Pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x *= x;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>m(k);
    rep(i,1,n+1){
        m.at(i%k)++;
    }
    if(k%2==1){
        cout<<Pow(m.at(0),3)<<endl;
        return 0;
    }
    else{
        cout<<Pow(m.at(0),3)+Pow(m.at(k/2),3)<<endl;
    }
return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
int main() {
    long long int n, q, a, b, c;
    cin >> n >> q;
    vector<stack<long long int>> v(n);
    for (int i = 0; i < q; i++) {
        cin >> a;
        if (a == 0) {
            cin >> b >> c;
            v[b].push(c);
        }
        else if (a == 1) {
            cin >> b;
            if (!v[b].empty())   cout << v[b].top() << endl;
        }
        else if (a == 2) {
            cin >> b;
            if (!v[b].empty())   v[b].pop();
        }
    }
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

class IT{
	private:
	struct node{
		int l,r;
		ll val=0,lazy=0;
	};
	vector<node> a;
	void push(int id){
		if(a[id].lazy){
			a[id<<1].val+=a[id].lazy;
			a[id<<1].lazy+=a[id].lazy;
			a[id<<1|1].val+=a[id].lazy;
			a[id<<1|1].lazy+=a[id].lazy;
			a[id].lazy=0;
		}
	}
	void upd(int id){
		a[id].val=max(a[id<<1].val,a[id<<1|1].val);
	}
	void build(int l,int r,int id){
		a[id].l=l,a[id].r=r;
		if(l==r) return;
		int mid=(l+r)>>1;
		build(l,mid,id<<1);
		build(mid+1,r,id<<1|1);
	}
	public:
	IT(int n):a(n<<2){
		build(0,n,1);
	}
	void add(int l,int r,ll val,int id=1){
		if(a[id].l>=l&&a[id].r<=r){
			a[id].val+=val;
			a[id].lazy+=val;
			return;
		}
		push(id);
		int mid=(a[id].l+a[id].r)>>1;
		if(l<=mid) add(l,r,val,id<<1);
		if(r>mid) add(l,r,val,id<<1|1);
		upd(id);
	}
	ll get_max(int l,int r,int id=1){
		if(l<=a[id].l&&a[id].r<=r) return a[id].val;
		push(id);
		ll res=-9e18;
		int mid=(a[id].l+a[id].r)>>1;
		if(l<=mid) res=max(res,get_max(l,r,id<<1));
		if(r>mid) res=max(res,get_max(l,r,id<<1|1));
		upd(id);
		return res;
	}
};

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<ll> add(n+1);
	vector<vector<pair<int,ll>>> era(n+1);
	for(int i=0;i<m;++i){
		int l,r;
		ll val;
		cin>>l>>r>>val;
		add[l]+=val;
		era[r].emplace_back(l,val);
	}
	IT tree(n+1);
	ll ans=0;
	for(int i=1;i<=n;++i){
		tree.add(0,i-1,add[i]); // wanna put 1 in here 
		ll cur=tree.get_max(0,i-1);
		ans=max(ans,cur);
		tree.add(i,i,cur);
		// erase 
		for(pair<int,ll> x:era[i]){
			tree.add(0,x.first-1,-x.second);
		}
	}
	cout<<ans;
	return 0;	
}


Measured memory_bytes: 31488
import math
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

def didWin(idx, c):
    if c == 'r' and t[idx] == 's':
        return True
    if c == 's' and t[idx] == 'p':
        return True
    if c == 'p' and t[idx] == 'r':
        return True
    return False

def solve(mod):
    l = math.ceil((n - mod) / k)
    dp = [[0] * 4 for _ in range(l + 1)]

    for i in range(l):
        # Case rock
        if didWin(i * k + mod, 'r'):
            dp[i + 1][0] = max(dp[i][1], dp[i][2]) + r
        else:
            dp[i + 1][0] = max(dp[i][1], dp[i][2])
        # Case scissors
        if didWin(i * k + mod, 's'):
            dp[i + 1][1] = max(dp[i][0], dp[i][2]) + s
        else:
            dp[i + 1][1] = max(dp[i][0], dp[i][2])
        # Case paper
        if didWin(i * k + mod, 'p'):
            dp[i + 1][2] = max(dp[i][0], dp[i][1]) + p
        else:
            dp[i + 1][2] = max(dp[i][0], dp[i][1])

    return max(dp[l][0], dp[l][1], dp[l][2])

ans = 0
for i in range(k):
    ans += solve(i)

print(ans)

Measured memory_bytes: 69360
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    vector<int> v(3);
    scan(v);
    sort_(v);
    if (v[0] == v[1])
        print(v[2]);
    else
        print(v[0]);

    return 0;
}

Measured memory_bytes: 256
ps = [2]
for i in range(3, int(1e9**0.5)):
    n = i
    for p in ps:
        if n % p == 0:
            n //= p
            break
    if n == i:
        ps.append(n)



def f(s):
    if s == 0:
        return (0, 0)
    a = s
    b = 1
    i = 0
    while i < len(ps):
        if a <= 1e9 and b <= 1e9:
            break
        p = ps[i]
        if a % p == 0 and 1e9 < b * p:
            break
        if a % p == 0:
            a //= p
            b *= p
        else:
            i += 1
    return (a, b)

s = int(input())

l = 0
r = s
while l + 1 < r:
    m = (l + r) // 2
    if m ** 2 < s:
        l = m
    else:
        r = m
ds = r**2 - s

a, b = f(ds)
print("0 0 %d %d %d %d" % (r, a, b, r))

Measured memory_bytes: 41708
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3]; cin>>a[0]>>a[1]>>a[2];
  int count5=0,count7=0;
  for(int i=0;i<3;i++)
  {
    if(a[i]==5)
      	count5++;
 	else if(a[i]==7)
      	count7++;
  }
  if(count5==2&&count7==1)
    	cout<<"YES\n";
  else cout<<"NO\n";
    
  
}

Measured memory_bytes: 3576
#include<cstdio>
int main(){
	long long int n,p;
	scanf("%lld%lld",&n,&p);
	int a[n]={};
	int b=0;
	int c=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==0)b++;
		else c++;
	}
	long long int ans=1;
	for(int i=1;i<n;i++)ans=ans*2;
	if(c==0){
		if(p==0)ans*=2;
		else ans=0;
	}
	printf("%lld",ans);
	return 0;
}
	

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



int main(){
  int N;cin>>N;
  string s; cin>>s;
  
  ll res=N;
  
  for(int i=0;i<N-1;i++){
    if(s.at(i)==s.at(i+1))
      res--;
  }
  
  cout<<res;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int a,b,ans;
  scanf("%d""%d",&a,&b);
  if(a > 9){
    ans = -1;
  }
  else if(b > 9){
    ans = -1;
  }
  else{
    ans = a*b;
  }
  printf("%d",ans);    
}

Measured memory_bytes: 128
from fractions import gcd

MOD = 1000000000 + 7

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

def fact(a, n):
    r = 1
    while (n > 0):
        if (n & 1):
            r = (r * a) % MOD
        a = (a * a) % MOD
        n //= 2
    return r

def modinv(a):
    return fact(a, MOD-2)

l = 1
ans = 0
for a in A:
    l = l * a // gcd(a, l)
l %= MOD
ans = 0
for a in A:
    ans += (l * modinv(a)) % MOD
print(ans % MOD)


Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N),when(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        when[A[i]-1]=i;
    }
    
    ll ans=0;
    set<int> S;
    
    for(int i=N-1;i>=0;i--){
        auto right=S.lower_bound(when[i]);
        if(right==S.end()){
            if(right==S.begin()){
                S.insert(when[i]);
            }else{
                right--;
                if(right==S.begin()){
                    ans+=ll((*right)+1)*ll(N-when[i])*ll(i+1);
                    S.insert(when[i]);
                }else{
                    int j=(*right);
                    right--;
                    ans+=ll(j-(*right))*ll(N-when[i])*ll(i+1);
                    S.insert(when[i]);
                }
            }
        }else{
            int j=(*right);
            right++;
            if(right==S.end()){
                right--;
                if(right==S.begin()){
                    ans+=ll(when[i]+1)*ll(N-j)*ll(i+1);
                    S.insert(when[i]);
                }else{
                    right--;
                    if(right==S.begin()){
                        ans+=(ll((*right)+1)*ll(j-when[i])+ll(when[i]-(*right))*ll(N-j))*ll(i+1);
                        S.insert(when[i]);
                    }else{
                        int l=(*right);
                        right--;
                        ans+=(ll(l-(*right))*ll(j-when[i])+ll(when[i]-l)*ll(N-j))*ll(i+1);
                        S.insert(when[i]);
                    }
                }
            }else{
                int k=(*right);
                right--;
                if(right==S.begin()){
                    ans+=ll(when[i]+1)*ll(k-j)*ll(i+1);
                    S.insert(when[i]);
                }else{
                    right--;
                    if(right==S.begin()){
                        ans+=(ll((*right)+1)*ll(j-when[i])+ll(when[i]-(*right))*ll(k-j))*ll(i+1);
                        S.insert(when[i]);
                    }else{
                        int l=(*right);
                        right--;
                        ans+=(ll(l-(*right))*ll(j-when[i])+ll(when[i]-l)*ll(k-j))*ll(i+1);
                        S.insert(when[i]);
                    }
                }
            }
        }
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
    
}



Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    char s[5];
    int i,sum=0;
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='+')
            sum++;
        if(s[i]=='-')
            sum--;
    }
    cout << sum;
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust\n";
  } else {
    cout << "win\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long field[101][101];
long n;
long x[105], y[105], h[105];

int main(){
	bool flag = true;
	scanf("%ld", &n);
	for(int i = 0; i < n; i++){
		scanf("%ld %ld %ld", &x[i], &y[i], &h[i]);
	}
	for(int i = 0; i < n; i++){
		if(h[i] != 0){
			for(int j = 0; j <= 100; j++){
				for(int k = 0; k <= 100; k++){
					field[j][k] = h[i] + std::abs(j - x[i]) + std::abs(k-y[i]);
				}
			}
			break;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= 100; j++){
			for(int k = 0; k <= 100; k++){
				if(h[i] != std::max(field[j][k] - std::abs(x[i] - j) - std::abs(y[i] - k), (long)0)){
					field[j][k] = 0;
				}
			}
		}
	}
	/*
	for(int i = 0; i < n-1; i++){
		for(int j = 0; j <= 100; j++){
			for(int k = 0; k <= 100; k++){
				if(std::abs(std::abs((j-x[i]) + (k-y[i])) - std::abs((j-x[i+1]) + (k-y[i+1]))) != std::abs(h[i] - h[i+1])){
					field[j][k] = false;
				}
			}
		}
	}
	
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			printf("%ld ", field[i][j]);
		}
		printf("\n");
	}
	//*/
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			if(field[i][j] != 0){
				printf("%d %d %ld\n", i, j, field[i][j]);
			}
		}
	}
	return 0;
	
}


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

const int N = 55;
const int offset = N * N;

int n, A, a[N];
long long f[N][offset + offset];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> A;
	for (int i = 1; i <= n; ++i) cin >> a[i], a[i] -= A;

	f[0][offset] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < offset + offset; ++j) {
			f[i][j] = f[i-1][j];
			if (j - a[i] >= 0 && j - a[i] < offset + offset) {
				f[i][j] += f[i-1][j - a[i]];
			} 
		}
	}

	cout << f[n][offset] - 1 << endl;
}

Measured memory_bytes: 2688
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 50 + 10;

int x[N], y[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i];
	}
	map<pii, int> mp;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			int p = x[j] - x[i];
			int q = y[j] - y[i];
			if (p or q) {
				mp[{p, q}]++;
			}
		}
	}
	int mx = 0;
	for (auto &i : mp) {
		mx = max(mx, i.second);
	}
	cout << n - mx << endl;
}

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

int main(){

    int X;
    cin >> X;

    int ans = 1;
    for(int b = 2; b * b <= X; b++){
        for(int p = 2; pow(b, p) <= X; p++){
            ans = max(ans, (int)pow(b, p));
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
	double k,nums[1000],sum=0;
  
  	scanf("%lf",&k);
  	
  	for(int i=0;i<k;i++){
      	scanf("%lf",&nums[i]);
    }
  
  	for(int i=0;i<k;i++){
    	sum=sum+(1/nums[i]);
    }
  
  	printf("%lf\n",1/sum);
  
  	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U; typedef pair<int,int > P; typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
void inp(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int l,r;
	l=max(a,c),
		r=min(b,d);
	if(r<l)r=l=0;
	printf("%d\n",r-l);
}
//B.cc by xsthunder at Sat Aug 12 20:04:06 2017


Measured memory_bytes: 128
#!/usr/bin/env python3
def solve(a):
    a = sorted(a)
    if a[0] + 2 <= a[-1]:
        return False
    if a[0] == a[-1]:
        return a[0] + 1 == len(a) or 2 * a[-1] <= len(a)
    x = a.count(a[0])
    return x < a[-1] and x + 2 * (a[-1] - x) <= len(a)
n = int(input())
a = list(map(int, input().split()))
print(['No', 'Yes'][solve(a)])


Measured memory_bytes: 13964
n,m=map(int,input().split())
t=[0]*(1+m)
for i in range(n):
  a=list(map(int,input().split()))
  for j in range(1,len(a)):
    t[a[j]]+=1
ans=0
for i in t:
  if i==n:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  int N;
  int a[110];
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> a[i];
  
  sort(a, a + N, greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) { // Alice のターン
            Alice += a[i];
        }
        else { // Bob のターン
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 200031;

long long n,win;

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n;
    for (int i=1;i<=n;i++){
    	long long val;
    	cin>>val;
    	if (val%2)
    		win=1;
    }
    if (win)
    	cout<<"first"<<endl;
    else
    	cout<<"second"<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

int main() {
    int N, M;
    int L[(int)1e5];
    int R[(int)1e5];

    cin >> N >> M;

    int left = 1, right = N;
    for (int i = 0; i < M; ++i) {
        cin >> L[i] >> R[i];

        left = max(left, L[i]);
        right = min(right, R[i]);
    }

    if (right >= left)
        cout << right - left + 1;
    else
        cout << 0;

    return 0;
}



Measured memory_bytes: 1024