akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  int ans = 0;

  for(int i = 1;i <= n;i=i+2)
  {
    int cnt = 0;
    for(int j = 1; j <= i;j++)
    {
      if(i % j == 0)
        cnt++;
    }
    if(cnt == 8)
      ans++;
  }

  cout << ans << endl;
  
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    nstr = str(n)
    nlen = len(nstr)
    ans0 = [0, 0, 9, 9, 909, 909, 90909][nlen]
    if nlen % 2 == 0:
        print(ans0)
        return
    print(ans0 + n - 10 ** (nlen - 1) + 1)


main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define repr(i, r, l) for (ll i = (ll)(r); i > (ll)(l); i--)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define all(p) p.begin(), p.end()
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 998244353
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 20005;
ll ceel(ll a, ll b){if (a % b == 0)return a / b;return a / b + 1;}
ll modneg(ll a,ll m){a = a % m;if(a<0)a=a+m;return a;}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };


int main() 
{

fastIO;
ll test,a,b,c,d,i,j,n,sum=0;
cin>>n;
ll mx=0;
rep(i,0,n)
{
    cin>>a;
    mx=max(mx,a);
    sum+=(mx-a);
}
cout<<sum<<endl;
return 0;
}

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

int main () {
	int K, N;
  	cin >> K >> N;
  	vector<int> dis(N);
  	for (int i = 0; i < N; i++) {
    cin >> dis.at(i);
    }
  	sort(dis.begin(), dis.end());
  	int far = 0;
  	for(int i = 0; i < N - 1; i++) {
    	far = max(far, dis.at(i + 1) - dis.at(i));
    }
  	far = max(far, K - dis.at(N - 1) + dis.at(0));
  	cout << K - far << endl;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

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

const lli MOD = 2019;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}

string s;
unordered_map<int, int> m;
lli res;

int main(void){
    cin >> s;

    reverse(s.begin(), s.end());
    int r=0;
    rep(i, s.size()){
        r = ((s[i]-'0')*modpow(10, i) + r)%2019;
        m[r]++;
    }

    res = m[0];
    for(auto i : m){
        res += i.second*(i.second-1)/2;
        //cout << i.second << endl;
    }

    cout << res << endl;
    return 0;
}


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

int main() {
  int n, k;

  cin >> n >> k;

  long long ans;
  if (k % 2 == 0) {
    ans = pow(n/k, 3) + pow(n/(k/2) - n/k, 3);
  }
  else if (k % 2 == 1) {
    ans = pow(n/k, 3);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
int main(){

	int i;
	int n;
	long long c,k;
	scanf("%d %lld %lld",&n,&c,&k);
	long long t[100001];
	for(i=1;i<=n;i++){
		scanf("%lld",&t[i]);
	}
	t[0]=0;
	std::sort(t,t+n+1);

	int bus,cp=0;
	long long lim=t[1]+k;
	for(i=1;i<=n;i++){
		if(t[i]>lim){//時間
			bus++;
			cp=i-1;
			lim=t[i]+k;
			if(i!=n)continue;
		}
		if(i-cp==c){//定員
			bus++;
			cp=i;
			lim=t[i+1]+k;
			continue;
		}
		if(i==n){//最終便
			bus++;
		}
	}
	printf("%d",bus);
}

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

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

  deque<int> D;

  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D.push_back(d);
  }

  int64_t ref = 0;

  for (int i = 0; i < D.size();i) {
    for (int j = 1; j < D.size();j++) {
      ref += D.at(i) * D.at(j);
      if (D.size() == 2) {
        break;
      }
    }
    D.pop_front();
    if (D.size() == 1) {
      break;
    }
  }

  cout << ref << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP_5_A{
    public class Program{
        public static void Main(string[] args){
            bool loopFlag = true;

            while(loopFlag){
                string[] temp = Console.ReadLine().Split(' ');
                int y = int.Parse(temp[0]);
                int x = int.Parse(temp[1]);

                if(x==0 && y==0){
                    loopFlag = false;
                }else{
                    //???????????????????????????
                    for(int h=0;h<y; h++){
                        for(int w=0;w<x; w++){
                            Console.Write("#");
                        }
                        Console.WriteLine();
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 8860
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    string a = input[0];
    string b = input[1];
    string c = input[2];
    Console.WriteLine(a[a.Length-1] == b[0] && b[b.Length-1] == c[0] ? "YES" : "NO");
  }
}

Measured memory_bytes: 13140
n  = int(input())
ai = list(reversed(sorted(map(int, input().split()))))

added   = 2
mins    = [ ai[1], ai[1] ]
comfort = ai[0]

def double(xs):
    for x in xs:
        yield x
        yield x

while added < len(ai):
    pick = mins[ : len(ai) - added ]
    comfort += sum(pick)
    mins = list(double(ai[ added : added + len(pick) ]))
    added += len(pick)

print(comfort)

# 7 6 5 4 3 2 1 0

# (0) 7
# (_ + 7 * 1) 7 6
# (_ + 6 * 2) 7 5 6 4
# (_ + 5 * 2 + 4 * 2) 7 3 5 2 6 1 4 0

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

int n;

void dfs(string s, char a)
{
 if(s.size() == n){
  	cout << s << endl;
    return;
  }
  for(char c = 'a'; c <= a+1;c++)
  {
    string t = s;
    t += c;
    dfs(t, max(a, c));
  }
}

int main()
{
  cin >> n;
  dfs("", 'a' - 1);
  return 0;
}




Measured memory_bytes: 1536
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: i64, mut x: i64, mut d: i64);
    if d == 0 {
        if x == 0 {
            println!("{}", 1);
        } else {
            println!("{}", n + 1);
        }
    } else {
        if d < 0 {
            x = -x;
            d = -d;
        }
        let mut ranges = std::collections::HashMap::<i64, Vec<std::ops::Range<i64>>>::new();
        for k in 0..(n + 1) {
            let r = k * x % d;
            let low = k * x / d + k * (k - 1) / 2;
            let high = k * x / d + (n * k - k * (k + 1) / 2) + 1;
            // println!("{:?}", (low, high)); // DEBUG
            ranges.entry(r).or_insert(Vec::new()).push(low..high);
        }
        for v in ranges.values_mut() {
            v.sort_by(|x, y| x.start.cmp(&y.start));
            let mut newv: Vec<std::ops::Range<i64>> = vec![];
            for vi in v.iter() {
                if newv.len() > 0 {
                    let last = newv.last_mut().unwrap().clone();
                    if last.end < vi.start {
                        newv.push(vi.clone());
                    } else {
                        newv.pop();
                        newv.push(last.start..max(last.end, vi.end));
                    }
                } else {
                    newv.push(vi.clone());
                }
            }
            std::mem::swap(v, &mut newv);
        }

        let mut ret = 0;
        for v in ranges.values() {
            for range in v {
                ret += range.end - range.start;
            }
        }
        println!("{}", ret);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 26816
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll dp[10002][100][2];
string s;
int n,d;
ll calc(int pos,int val,int f){
    if(pos==n)
        return (val==0);
    ll &ans=dp[pos][val][f];
    if(ans!=-1)
       return ans; 
    ans=0ll;
    int hi=(f==0)?(s[pos]-'0'):9;
    for(int i=0;i<=hi;i++){
        int _f=(f|(i<hi));
        ans+=calc(pos+1,(val+i)%d,_f);
    }
    ans%=MOD;
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        memset(dp,-1,sizeof(dp));
        cin>>s;
        cin>>d;
        n=s.length();
        cout<<((calc(0,0,0)-1+MOD)%MOD)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 20156
n,q=map(int,input().split())
s=input()
cnt=[0]*n
for i in range(n):
    cnt[i]=cnt[i-1]
    if s[i-1:i+1]=="AC":
        cnt[i]+=1
for i in range(q):
    l,r=map(int,input().split())
    print(cnt[r-1]-cnt[l-1])



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

int main() {
  int h,w;
  cin>>h>>w;
  char c[h][w];
  
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>c[i][j];
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]=='#')
        cout<<c[i][j];
      if(c[i][j]=='.'){
       int cnt=0;
       for(int k=-1;k<2;k++)
         for(int l=-1;l<2;l++)
           if(i+k!=-1 && i+k!=h && j+l!=-1 && j+l!=w && c[i+k][j+l]=='#')
             cnt++;
       cout<<cnt;
        
     }
    }
    cout<<endl;
  }

  
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "vector"
# include "queue"

using namespace std;

const int maxm=1e5+10;

int N,M,A,B;

vector<int> L[maxm];
priority_queue<int> H;

int main(){
	register int i;
	register long long Ans=0;
	scanf("%d%d",&N,&M);
	for(i=1;i<=N;i++){
		scanf("%d%d",&A,&B);
		if(A<=M) L[M-A].push_back(B);
	}
	for(i=M-1;i>=0;i--){
		while(L[i].size()) H.push(L[i].back()),L[i].pop_back();
		if(H.size()) Ans+=H.top(),H.pop();
	}
	printf("%lld",Ans);
	return 0;
}

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

typedef long long ll;

ll N;
map<ll, ll> ND;
const ll MOD = 998244353;

ll solve() {
  ll k = ND.size();
  if (ND.rbegin()->first != k - 1) return 0;
  if (ND.begin()->second != 1) return 0;
  ll res = 1;
  for (ll i = 0; i + 1 < k; ++i) {
    for (ll j = 0; j < ND[i + 1]; ++j) {
      (res *= ND[i]) %= MOD;
    }
  }
  return res;
}
int main() {
  cin >> N;
  bool bad = false;
  for (ll i = 0; i < N; ++i) {
    ll d;
    cin >> d;
    if (i == 0 && d != 0) bad = true;
    ++ND[d];
  }
  cout << (bad ? 0 : solve()) << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;
const ll mod=1000000007;
const ll INF=0x3f3f3f3f;
ll inv(ll b)
{
    return b==1?1:(mod-mod/b)*inv(mod%b)%mod;
}
ll n,m,k,l,i,j,a,b,c,w,ans,sum;
int main()
{
    scanf("%lld %lld",&n,&m);
    for(i=1,k=1; i<=n; i++)
    {
        k%=mod;
        k*=i;
        k%=mod;
    }
    for(i=1,w=1; i<=m; i++)
    {
        w%=mod;
        w*=i;
        w%=mod;
    }
    ans=w*k;
    ans%=mod;
   if(max(n,m)-min(n,m)==1)printf("%lld\n",ans%mod);
   else {if(max(n,m)-min(n,m)==0) printf("%lld\n",ans*2%mod);
   else printf("0\n");}
    return 0;
}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


void Solve() {
	
	string s;
	cin >> s;
	string undera = "a";
	undera[0]--;
	string st = s + undera;
	int size = st.size();
	for (int i = 0; i < st.size(); i++)
	{
		int ind = st.size() - 1 - i;
		char b = st[ind] + 1;

		for (char c = b; c <= 'z'; c++)
		{
			bool ok = true;
			for (size_t j = 0; j < size - i - 1; j++)
			{
				if (st[j] == c) {
					ok = false;
					break;
				}
			}
			if (ok) {
				for (size_t j = 0; j < size - i - 1; j++)
				{
					cout << st[j];
				}
				
				cout << c << endl;
				return;
			}
		}
	}

	cout << -1 << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6016
/* AtCoder Panasonic Programming Contest 2020. Task D. */
#include <bits/stdc++.h>

using namespace std;

#define COUT_PRECISION 10

namespace abreto {

struct nform {
    int length;
    string form;
    int used;
    nform(int l = 0, string f = "", int u = 0)
        : length(l), form(f), used(u)
    {}
};

void main(void)
{
    int N;
    vector<nform> *v = new vector<nform>();

    cin >> N;
    v->push_back(nform(1, "a", 1));
    while (--N) {
        vector<nform> *nv = new vector<nform>();
        for (auto it = v->begin(); it != v->end(); it++) {
            int alphabet = it->used + 1;
            for (int i = 0; i < alphabet; i++) {
                char append = 'a' + i;
                nv->push_back(nform(
                    it->length + 1,
                    it->form + append,
                    it->used + (i == it->used)
                ));
            }
        }

        delete v;
        v = nv;
    }

    for (auto it = v->begin(); it != v->end(); it++) {
        cout << it->form << '\n';
    }
}

}

int main(void) {
    cin.sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(COUT_PRECISION);
    abreto::main();
    return 0;
}


Measured memory_bytes: 10972
#include<stdio.h>
#define N 100000
int A[N],n;

int Partition(int *A,int p,int r){
  int x,i,j,exc;
  x = A[r];
  i = p - 1;
  for(j=0;j<r;j++){
    if(A[j]<=x){
      i = i+1;
      exc = A[i];
      A[i] = A[j];
      A[j] = exc;
    }
  }
  exc = A[i+1];
  A[i+1]=A[r];
  A[r]= exc;
  
  return i+1;
}

int main(){
  int i,part,p,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  p=0;
  r=n-1;
  part = Partition(A,p,r);
  
  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    if(part==i) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
n = int(input())

B = list(map(int, input().split()))
b = len(B)
A = []

A.append(B[0])
if len(B) == 1:
    A.append(B[0])
if len(B) > 1:
    for i in range(b-1):
        if B[i] <= B[i +1]:
            A.append(B[i])
        else:
            A.append(B[i+1])
    A.append(B[b-1])
print(sum(A))
     

Measured memory_bytes: 3064
def c_Candies(N, A):
    # dp[i][j]は最もアメが取れるようにi行j列まで進んだときのアメの獲得数
    dp = [[0] * N for _ in range(2)]

    # 1行目の値と、2行1列の値は先に計算できる
    dp[0][0] = A[0][0]
    dp[1][0] = dp[0][0] + A[1][0]
    for j in range(1, N):
        dp[0][j] = dp[0][j - 1] + A[0][j]

    for j in range(1, N):
        # 2行j+1列の値は、その左か上のうち小さくない値にそのマスのアメの個数を足す
        dp[1][j] = max(dp[0][j], dp[1][j - 1]) + A[1][j]
    return dp[1][-1]

N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
print(c_Candies(N, A))

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a + b >= k){
		cout << min(k,a) << endl;
	}
	else{
		cout << a - (k - (a+b)) << endl;
	}
}


Measured memory_bytes: 3632
//Akash Kumar Mondol
//Department of ICE,University of Rajshahi,Bangladesh
#include<bits/stdc++.h>
using namespace std;
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)
#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define mod 1000000007
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
//#define valid(nx,ny) nx>=0&& nx<r && ny>=0 && ny<c
//memset(a, 0, sizeof(a));
//freopen("file_name.txt","read_or_write",stdout_or_stdin);
int main()
{
    //freopen("file_name.txt","w",stdout);
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
  	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 <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 005_agc_b / Link: https://agc005.contest.atcoder.jp/tasks/agc005_b?lang=en  ----- */
/* ------問題------

すぬけ君はある日友人から長さ N の順列 a1,a2,…,aN を貰いました。

ΣΣmin(A_l,...,A_r)

を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


template<typename type>
struct BIT0 { // 0-index
	int N;
	int nn;
	vector<type> data;
	//動的はmap<int?,type>data
	BIT0(int n) {
		N = n + 1;
		data = vector<type>(n + 1, 0);
		nn = 1;
		while (nn * 2 <= N)nn *= 2;
	}
	void add(int i, type w) {
		// a[i] += w
		i++;
		for (int x = i; x < N; x += x & -x) {
			data[x] += w;
		}
	}
	type sum(int i) {
		// iまでの和 [0,i)
		type ret = 0;
		for (int x = i; x > 0; x -= x & -x) {
			ret += data[x];
		}
		return ret;
	}
	// [l, r)
	type sum(int l, int r) {
		return sum(r) - sum(l);
	}

	int lower_bound(type w) {
		//  w≦[0,x]以上となる最小のindex,x
		if (w <= 0) return 0;
		int x = 0;
		for (int k = nn; k > 0; k /= 2) {
			if (x + k <= N && data[x + k] < w) {
				w -= data[x + k];
				x += k;
			}
		}
		return x + 1;
	}
};

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(N + 10);
	VI ra(N + 10);
	FOR(i, 0, N) {
		cin >> a[i];
		ra[a[i]] = i;
	}
	BIT0<int>bit(N + 10), rbit(N + 10);
	FOR(i, 1, N + 1) {
		int l = bit.lower_bound(bit.sum(ra[i]));
		int r = N-1  - rbit.lower_bound(rbit.sum(N - 1 - ra[i]));
		//cout << l << "," << r << endl;

		ans += i*(LL)(r - ra[i]+1)*(ra[i] - l+ 1 );
		bit.add(ra[i], 1);
		rbit.add(N - 1 - ra[i], 1);
	}
	cout << ans << "\n";

	return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v{0} {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M(0) - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return (*this).pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const int MN = 2333;
int n, k;
Mint dp[MN], ndp[MN];
Mint two[MN];

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

    two[0] = 1;
    for (int i = 1; i < MN; i++) {
        two[i] = Mint(2) * two[i - 1];
    }

    cin >> n >> k;
    if (n == 1) {
        cout << 1 << "\n";
        return 0;
    }
    if (k == 1) {
        cout << two[n - 2] << "\n";
        return 0;
    }
    fill(dp + 2, dp + n + 1, 1);
    for (int i = 1; i < k - 1; i++) {
        copy(dp + 2, dp + n - i + 2, ndp + 2);
        for (int j = n - i; j >= 2; j--) {
            ndp[j] += ndp[j + 1];
        }
        copy(ndp + 2, ndp + n - i + 1, dp + 2);
    }

    Mint ans = accumulate(dp + 2, dp + n - k + 3, Mint(0));
    ans *= two[max(0, n - k - 1)];
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll cal(ll x) {
    return x * x * x * x * x;
}
int main() {
    ll x;
    scanf("%lld", &x);
    for(ll a = 1;; a++) {
        ll det = cal(a) - x, bb = -1;
        for(ll b = 0;; b++) {
            ll t = cal(b);
            if(t == abs(det)) {
                bb = b;
                break;
            }
            if(t > abs(det)) {
                break;
            }
        }
        if(bb != -1) {
            printf("%lld %lld\n", a, bb * (det < 0 ? -1 : 1));
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3824
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 1003;
const int K = 20;
int ans1[N][N], ans2[N][N];

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++){
        ans1[i][1] = 1;
        ans2[i][w] = 1;
    }
    for (int i = 1; i <= h; i++){
        string s;
        cin >> s;
        for (int j = 0; j < w; j++){
            if (s[j] == '#'){
                ans1[i][j + 1] = 1;
                ans2[i][j + 1] = 1;
            }
        }
    }
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            if (j != 1 && j != w)
            if (i % 2) ans1[i][j] = 1; else ans2[i][j] = 1;
        }
    }
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            if (ans1[i][j] == 1) cout << "#"; else cout << ".";
        }
        cout << endl;
    }
    cout << endl;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            if (ans2[i][j] == 1) cout << "#"; else cout << ".";
        }
        cout << endl;
    }
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  map<long long int, int> mp;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    mp[a]++;
  }
  long long int a = 0, b = 0;
  auto itr = mp.end();
  auto itr2 = itr--;
  for(; ; --itr){
    if(itr->second >= 2){
      if(a == 0){
        a = itr->first;
        itr->second -= 2;
        itr = itr2;
      }
      else{
        b = itr->first;
        cout << a * b << endl;
        return;
      }
    }
    if(itr == mp.begin()){
      cout << 0 << endl;
      return;
    }
  }
  return;
}

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


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long 
//#define inf 1000000000000000000
using namespace std;
  
// Main function which finds difference 
int diff(int h1,int m1,int h2,int m2) 
{ 
  
    // change string (eg. 2:21 --> 221, 00:23 --> 23) 
    int time1 = h1*100+m1; 
    int time2 = h2*100+m2; 
  
    // difference between hours 
    int hourDiff = time2 / 100 - time1 / 100 - 1; 
  
    // difference between minutes 
    int minDiff = time2 % 100 + (60 - time1 % 100); 
  
    if (minDiff >= 60) { 
        hourDiff++; 
        minDiff = minDiff - 60; 
    } 
    int res=hourDiff*60+minDiff;
    return res; 
} 
int main(){
    int h,m,h2,m2,k;
    cin>>h>>m>>h2>>m2>>k;
    cout<<diff(h,m,h2,m2)-k<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int n, s[100], mu = 0;

signed main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		mu += s[i];
	}
	if (mu % 10 != 0) {
		cout << mu << endl;
		return 0;
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		if (s[i] % 10 != 0) {
			cout << mu - s[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    int N, count;
    vector<vector<int>> A;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        vector<int> t;
        for (int j = 0; j < N - 1; j++)
        {
            int tmp;
            cin >> tmp;
            t.push_back(tmp);
        }
        A.push_back(t);
    }

    vector<int> ids(N, N - 2);
    set<int> check;
    for(int i = 0; i < N; i++)
        check.insert(i);
    count = 0;
    while (true)
    {
        //vector<int> update;
        set<int> update;
        //for (int i = 0; i < N; i++)
        for (auto i : check)
            if (ids[i] >= 0 && A[A[i][ids[i]] - 1][ids[A[i][ids[i]] - 1]] - 1 == i){
                update.insert(i);
                update.insert(A[i][ids[i]] - 1);
            }

        for(auto x : update)
            ids[x]--;

        if (update.size() == 0)
            break;

        check = update;

        count++;
    }

    bool f = false;
    for (int i = 0; i < N; i++)
        if (ids[i] != -1)
            f = true;
    if (f == true)
        cout << -1 << endl;
    else
        cout << count << endl;
}

Measured memory_bytes: 4224
require 'pp'
n, m = gets.split.map(&:to_i)
s = []
m.times do
  _, *si = gets.split.map(&:to_i)
  si.map! { |x| x - 1 }
  s << si
end
pika = gets.split.map(&:to_i)
ans = 0
(1 << n).times do |i|
  flag = true
  m.times do |j|
    t = s[j].map { |si| i[si] }.inject(:+)
    if pika[j] != t % 2
      flag = false
      break
    end
  end
  ans += 1 if flag
end
p ans


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

ll pref[200009],suf[200009];

void precal(int n)
{
	int i;
	for(i=1;i<=n;i++)
	{
		pref[i]=(pref[i-1]+i)%mod;
	}
	int t=1;
	for(i=n;i>0;i--)
	{
		suf[t]=(suf[t-1]+i)%mod;
		t++;
	}
}

void solve()
{
	int n,k;
	cin>>n>>k;
	precal(n+1);
	ll sum=0;
	for(int i=k;i<=n+1;i++)
	{
		//cout<<suf[k]<<' '<<pref[k]<<'\n';
		sum=(sum+suf[i]-pref[i]+1+mod)%mod;
	}
	cout<<sum;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int> > data;
vector<int> pot(1000);
int INF = 3e18;
void dfs(int vertex, int last, int dst){
    int ctr = 0;
    for (int i=0; i < data[vertex].size(); i++){
        int to = data[vertex][i];
        if (to==last) continue;
        ctr++;
        dfs(to, vertex, dst+1);
    }
    pot[dst] = max(pot[dst], ctr);
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i=0; i < n; i++){
        vector<int> help;
        pot[i] = 0;
        data.push_back(help);
    }
    for (int i=0; i < n-1; i++){
        int x, y;
        cin >> x >> y;
        data[x-1].push_back(y-1);
        data[y-1].push_back(x-1);
    }
    int cmp = 1e9, res = INF;
    for (int i=0; i < n; i++){
        fill(pot.begin(), pot.end(), 0);
        dfs(i, -1, 0);
        int th = 1;
        for (int j=0; j < 1000; j++){
            if (pot[j] == 0){
                if (cmp == j+1) res = min(res, th);
                if (cmp > j+1){
                    cmp = j+1;
                    res = th;
                }
                break;
            }
            if (INF/pot[j] < th) break;
            th *= pot[j];
        }
    }
    for (int i=0; i < n; i++){
        for (int p=0; p < data[i].size(); p++){
            fill(pot.begin(), pot.end(), 0);
            int to = data[i][p];
            dfs(i, to, 0);
            dfs(to, i, 0);
            int th = 2;
            for (int j=0; j < 1000; j++){
                if (pot[j] == 0){
                    if (cmp == j+1) res = min(res, th);
                    if (cmp > j+1){
                        cmp = j+1;
                        res = th;
                    }
                    break;
                }
                if (INF/pot[j] < th) break;
                th *= pot[j];
            }
        }
    }
    cout << cmp << " " << res << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gcd(a,b)   __gcd(a,b)
#define lcm(a,b)   (a*b)/gcd
#define rep(i,n)   for(int i=0;i<n;i++)
#define Rep(i,n)   for(int i=1;i<=n;i++)
#define REP(i,j,n) for(int i=j;i<=n;i++)
#define fast   ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)


int main()
{ 
	fast;
	int n;
	cin>>n;
	int ar[n];
	rep(i,n){
		cin>>ar[i];
	}
	int cnt=1;
	int mini=ar[0];
	for(int i=1;i<n;i++){
		if(ar[i]<=mini){
			cnt++;
			mini=ar[i];
		}
	}
	cout<<cnt<<endl;
	return 0;

}

Measured memory_bytes: 4392
import sys
input=sys.stdin.readline
import bisect

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    N,M = map(int,input().split())
    S = input().strip()
    T = input().strip()
    m = lcm(N,M)
    for i in range(M):
        si = i*m//M
        ti = i*m//N
        if si < N and ti < M and S[si] != T[ti]:
            print("-1")
            return
    print(m)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5460
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

ans = []
s = A[0]
n = 1
for i in range(1, N):
  if len(ans) == 2: break
  if A[i] == s:
    n += 1
    if n == 2 or n == 4:
      ans.append(s)
  else:
    s = A[i]
    n = 1
print(ans[0] * ans[1] if len(ans) != 0 else 0)

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

using namespace std;
int n, lp[1001];
vector < int > prime;
const long long mod = 1e9 + 7;
map < int, long long > m;
int main(){
    cin >> n;
    for(int i = 2; i <= n; i++){
        if(!lp[i]){
            lp[i] = i;
            prime.push_back(i);
        }
        for(int j = 0; j < prime.size() && i * prime[j] <= n && lp[i] >= prime[j]; j++){
            lp[i * prime[j]] = prime[j];
        }
    }
    for(int i = 2; i <= n; i++){
        int j = i;
        while(j > 1){
            m[lp[j]]++;
            j /= lp[j];
        }
    }
    long long ans = 1;
    for(auto i : m){
        ans = (ans * (i.second + 1)) % mod;
    }
    cout << ans;
}


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

int main(){

		int  a, b;
		cin >> a >> b;

		if ((a + b) % 2 != 0) {
			cout << "IMPOSSIBLE" << endl;
		}
		else {
			cout << (a + b) / 2 << endl;
		}

	
    return 0;
}

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

void hoge(int &m,int &n){
		int tmp=m;
		m=n;
		n=tmp;
	}

int main(){
	vector<int>v;
	int a;
	for(int i=0;i<10;i++){
		cin>>a;
		v.push_back(a);
    }
	
	for(int l=0;l<9;l++){
		for(int i=0;i<9;i++){
	    	if(v[i]>v[i+1]){
				hoge(v[i],v[i+1]);
			}
		}
	}
	
	
	for(int i=9;i>6;i--){
		cout<<v[i]<<endl;
    }
	
}


Measured memory_bytes: 3160
/// 2222 by 1 february, thx

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long n, m;
long long dp[100002];
bool viz[100002];
struct str
{
    long long weight, value;
};
str v[102];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        cin >> v[i].weight >> v[i].value;
    viz[0] = 1;
    for(int j = 1; j <= n; ++j)
        for(int k = 100000; k >= 0; --k)
            if(viz[k])
            {
                if(viz[k + v[j].value])
                    dp[k + v[j].value] = min(dp[k + v[j].value], dp[k] + v[j].weight);
                else
                    dp[k + v[j].value] = dp[k] + v[j].weight;
                viz[k + v[j].value] = 1;
            }
    for(int j = 100000; j >= 0; --j)
        if(viz[j] && dp[j] <= m)
        {
            cout << j;
            return 0;
        }
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a": " << a << endl;
#define mst(a, b) memset(a, b, sizeof(a))
#define lc rt << 1
#define rc rt << 1 | 1
#define X first
#define Y second
inline int lowbit(int x) { return x & -x; }
typedef long long LL;
typedef pair<int, int> pii;
const int N = 3000 + 10;
const int M = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;

char s[N];
char t[N];
int dp[N][N];
stack<char> sta;

int main() {
#ifdef purple_bro
    freopen("in.txt","r",stdin);
#endif
    scanf("%s%s", s + 1, t + 1);

    int lens = strlen(s + 1);
    int lent = strlen(t + 1);

    for (int i = 1; i <= lens; i++) {
        for (int j = 1; j <= lent; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    int now = dp[lens][lent] + 1;

    for (int i = lens; i >= 1; i--) {
        for (int j = lent; j >= 1; j--) if (dp[i][j] == now - 1 && s[i] == t[j]) {
            sta.push(s[i]);
            now--;
            break;
        }
    }

    for (; !sta.empty(); sta.pop())
        printf("%c", sta.top());

    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

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

    rep(i,16)
        rep(j,26)
            if(i*7+j*4 == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        

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

Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

#define MAX_V 1000

struct Edge{ int to,cap,rev; };
int used[MAX_V];
typedef vector<vector<Edge>> Graph;

void addEdge(Graph &g,int from,int to,int cap){
    g[from].push_back((Edge){to,cap,(int)g[to].size()});
    g[to].push_back((Edge){from,0,(int)g[from].size()-1});
}

int DFS(Graph &g,int v,int t,int f){
    if(v==t)
        return f;
    used[v]=true;
    for(int i=0;i<(int)g[v].size();i++){
        Edge &e=g[v][i];
        if(!used[e.to] && 0<e.cap){
            int d=DFS(g,e.to,t,min(f,e.cap));
            if(0<d){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

int maxFlow(Graph &g,int s,int t){
    int flow=0;
    while(1){
        for(int i=0;i<MAX_V;i++)
            used[i]=false;
        int f=DFS(g,s,t,INT_MAX);
        if(f==0)
            break;
        flow+=f;
    }
    return flow;
}

int a[100],b[100],c[100],d[100];

int main(void){
    int N;
    GI(N);
    Graph g(2*N+2);
    REP(i,N){
        GI(a[i]);GI(b[i]);
    }
    REP(i,N){
        GI(c[i]);GI(d[i]);
    }
    REP(i,N)
        REP(j,N)
            if(a[i]<c[j]&&b[i]<d[j])
                addEdge(g,i,j+N,1);
    REP(i,N){
        addEdge(g,2*N,i,1);
        addEdge(g,i+N,2*N+1,1);
    }
    int r = maxFlow(g,2*N,2*N+1);
    printf("%d\n",r);
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";

using ll = long long;
using ii = pair<ll,ll>;

const int S = 2005;
const int N = 670;
const int MOD = 1e9+7;

ll dp[N][S];
int main() {
  int s; scanf("%d", &s);
  dp[0][0] = 1;
  for(int i = 1; i < N; i++) {
    for(int j = 3; j <= s; j++) {
      // dp[i][j] = dp[i - 1][j - 3] + dp[i - 1][j - 4] + ... + dp[i - 1][0]
      // dp[i][j - 1] = dp[i - 1][j - 4] + dp[i - 1][j - 5] + ... + dp[i - 1][0]
      // dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 3];

      dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 3];
      if(dp[i][j] >= MOD) dp[i][j] -= MOD;

      // for(int k = 3; k <= j; k++) {
      //   dp[i][j] += dp[i - 1][j - k];
      //   if(dp[i][j] >= MOD) dp[i][j] -= MOD;
      // }
    }
  }
  ll ans = 0;
  for(int i = 0; i < N; i++) {
    ans += dp[i][s];
    if(ans >= MOD) ans -= MOD;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 14172
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [x, a, b] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let t n = abs (n - x)
    putStrLn $ if t a < t b then "A" else "B"


Measured memory_bytes: 380
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int A1, B;

int main(){
    INIT;
    cin >> A1 >> B;
    if(6 <= A1 && A1 <= 12) B /= 2;
    if(A1 <= 5) B = 0;
    cout << B;
}

Measured memory_bytes: 256
// =====================================================================================
//
//       Filename:  1092.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  14/04/20 08:28:57 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:  
//
// =====================================================================================

#include<bits/stdc++.h>


using namespace std;

#define int long long 
#define pb push_back
//#define _SHOW_TIME

void solve(){
    string s;
    cin>>s;
    int ok =1,a[26]={0};
    for(int i=0;i<s.size();i++){
        int in = s[i] - 'a';
       if(a[in]>=1) {ok = 0 ; break;}
        a[ in  ]++;
       
    }
    if(ok) cout<<"yes"<<endl;
    else cout<<"no"<<endl;

}
int32_t main(){
 /////////////////////////////////////
    #ifdef _SHOW_TIME
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
    solve();
    /////////////////////////////////////
    #ifdef _SHOW_TIME
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
    return 0;

}



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

using namespace std;

// void computeLPSArray(string pat, vector<int> &lps) 
// {
//     int len = 0;
//     int i = 1; 
//     lps[0] = 0;
//     int M = lps.size();
//     cout<<"m "<<M<<endl;
//     while (i < M) 
//     { 
//         if (pat[i] == pat[len] ) { 
//             len++; 
//             lps[i] = len; 
//             i++; 
//         } 
//         else
//         { 
//             if (len != 0) { 
//                 len = lps[len -1]; 
//             } 
//             else  
//             { 
//                 lps[i] = 0; 
//                 i++; 
//             } 
//         } 
//     }
// }

int main()
{ 
	string pat; 
	int M;
	cin>>M;
	cin>>pat;

	int maxL = 0;
	vector<vector<int>> dp(M+1,vector<int> (M+1));
	for(int i=0;i<=M;i++)
	{
		for(int j=i+1;j<=M;j++)
		{
			if(pat[i-1]==pat[j-1])
			{
				if(j-dp[i-1][j-1]!=i)
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=dp[i-1][j-1];
			}
			else
				dp[i][j]=0;
			maxL=max(maxL,dp[i][j]);
		}
	}
	cout<<maxL<<endl;
    return 0 ; 
} 

Measured memory_bytes: 98176
from collections import defaultdict


def main():
    A, B = map(int, input().split())
    d = {1: 14}

    if d.get(A, A) == d.get(B, B):
        print("Draw")
    elif d.get(A, A) > d.get(B, B):
        print("Alice")
    else:
        print("Bob")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316