akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    ll now = 0;
    map<int, vector<int> > m; m[0].push_back(0);
    rep (i, n) {
        int a; cin >> a; a--;
        now = (a + now) % k;
        m[now].push_back(i + 1);
    }
    ll ans = 0;
    for (auto i : m) {
        rep (j, i.second.size()) {
            int ok = j, ng = j_len;
            while (ng - ok > 1) {
                int med = (ng + ok) / 2;
                if (i.second[med] - i.second[j] < k) ok = med;
                else ng = med;
            }
            ans += ok - j;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
 ll N;  
cin >> N;
const char table[] = "abcdefghijklmnopqrstuvwxyz";
ll n = N ;
string ret;
  n -= 1;
while(n >= 26){
 
  // cout << "n" << n << endl;
  // if(n % 26 == 0){
  //  ret += table[25];
  // }else{
  ret += table[n%26];
  // }
  n /= 26;
  n -= 1;
  // cout << "n after" << n <<endl;
}
ret += table[n];
reverse(all(ret));
  cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var nm = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var list = new List<Tuple<long, long>>();
        for (int i = 0; i < nm[0]; i++)
        {
            var line = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            list.Add(new Tuple<long, long>(line[0], line[1]));
        }
        list = list.OrderBy(f => f.Item1).ThenBy(f => f.Item2).ToList();
        long ans = 0;
        for (int i = 0; i < nm[0]; i++)
        {
            ans += Math.Min(list[i].Item2, nm[1]) * list[i].Item1;
            nm[1] -= list[i].Item2;
            if (nm[1] <= 0) break;
        }
        Console.WriteLine(ans);
    }
}


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

long dfs(long n,long x){
  ///cout<<n<<" "<<x<<" "<<x-((1<<(n+1))-3+2)<<endl;
  //レベルnのを下からx食べていくつPがあるか
  if(x==0)return 0;
  if(n==0)return(x==0?0:1);
  if(x==(((long)1<<(n+2))-3)) return -1+((long)1<<(n+1));
  if(x<((long)1<<n+1)-3+2)return dfs(n-1,x-1);
  else if(x==((long)1<<n+1)-3+2)return -1+((long)1<<(n))+1;
  else return dfs(n-1,((long)1<<(n+1))-3)+1+dfs(n-1,x-(((long)1<<(n+1))-3+2));
}
int main(){
  long N,X;cin>>N>>X;
  cout<<dfs(N,X)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 2000000

using namespace std;

int h, A[MAX+1];

void maxHeapify(int i){
    int left = 2 * i;
    int right = 2 * i + 1;
    int largest;
    if(left <= h && A[left] > A[i]) largest = left;
    else largest = i;
    if(right <= h && A[right] > A[largest]) largest = right;
    if(largest != i){
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
    }
}

void buildMaxHeap(){
    for(int i = h/2; i >= 1; i--) maxHeapify(i);
}

int main(){
    int i;
    cin >> h;
    for(i = 1; i <= h; i++) cin >> A[i];
    buildMaxHeap();
    for(i = 1; i <= h; i++) cout << " " << A[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 5084
from itertools import combinations

def main():
    _ = int(input())
    A = list(map(int, input().split()))
    if len(set(A)) < 3:
        print(0)
        return
    C = combinations(A, 3)
    ans = 0
    for c in C:
        c = sorted(c)
        if c[0] != c[1] and c[0] != c[1] and c[1] != c[2]:
            if c[2] < c[1] + c[0]:
                ans += 1
    print(ans)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 73732
n = gets.to_i
max_of_7 = n / 7
max_of_4 = n / 4
(max_of_7).downto(0) do |num7|
  (max_of_4).downto(0) do |num4|
    if n == 7 * num7 + 4 * num4
      puts "Yes"
      exit
    end
  end
end
puts "No"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    ll ctr=0;
    rp(i,n){
        ll a;
        cin >> a;
        while(a%2==0){
            a/=2;
            ctr++;
        }
    }
    print(ctr);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
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<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll 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;
}

// べき乗
ll modpow(ll x, ll n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int main() {
  int x,t,N;
  cin >> N >> x >> t;
  rep(i,1010) {
    if (i*x>=N) {
      cout << t*i << endl;
      return 0;
    }
  }
}


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

int main(){
    int M, N,i,j, L, R;
    cin >> N >> M;
    int L_temp = 1;
    int R_temp = N;

    for(i = 0;i<M;i++){        
        cin >> L >> R;
        L_temp=max(L,L_temp);
        R_temp=min(R,R_temp);
        if(R_temp-L_temp<0){
            cout << 0 <<endl;
            return 0;
        }
    }

    cout << R_temp-L_temp + 1 << endl;
    return 0;

}

Measured memory_bytes: 3636
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int x;cin >> x;
    int count = x/11;
    x%=11;
    count*=2;
    // cout << count << endl;
    // cout < x << endl;
    if(x<=6&&x>0)count+=1;
    else if(x>0&&x<=11)count+=2;
    cout << count << endl;
    return 0;
}

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

int main(void){
    int n = 0; 
    int x = 0;
    int sum = 0;

    scanf("%d", &n);
    x = n;

    while(n  > 10){
        sum += n % 10;
        n /= 10;
    }
    sum += n;

    if(x % sum == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
typedef long long  ll;
int main()
{
int n;
cin>>n;
int a[n+1]={0};
int b[n+1]={0};
int c[n]={0};
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
for(int i=1;i<=n;i++)
{
    cin>>b[i];
}
for(int i=1;i<n;i++)
{
    cin>>c[i];
}
int sum=b[a[1]];
for(int i=2;i<=n;i++)
{
    sum+=b[a[i]];
    if(a[i]-a[i-1]==1)
    {
        sum+=c[a[i-1]];
    }
}
cout<<sum;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,c=0;
  cin>>N;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      int K;
      K=4*i+7*j;
      if(N==K){
        c++;
      }
    }
  }
  if(c>0){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    let n = s.len();
    let mut ans = n;
    for i in 0..n {
        let mut t = 0;
        let mut c = 0;
        for j in 0..n {
            if s[j] == s[i] {
                t = max(t, c);
                c = 0;
            } else {
                c += 1;
            }
        }
        t = max(t, c);
        ans = min(ans, t);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
def main():
    N = int(input())
    h = [int(i) for i in input().split()]
    c = [0]*N

    c[0]=0
    c[1]=abs(h[1]-h[0])
    for i in range(2,N):
        c[i] = min(abs(h[i]-h[i-1])+c[i-1],abs(h[i]-h[i-2])+c[i-2])

    print(c[N-1])

main()

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

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    vector<double> diff(N);
    for(int i=0; i<N; i++){
        int h;
        cin >> h;
        diff[i] = abs(T-h*0.006-A);
    }
  
  int ans = 0;
  
  for (int j = 0; j < N; j++){
     if (diff[ans] > diff[j]) {
       ans = j;
     }
  }
  cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
    int len=0;
    char s[200010];

    scanf("%s",s);
    len=strlen(s);
    int i,sum=0;

    //printf("%d",len);
    for(i=0;i<len;i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0)printf("Yes");
	else printf("No");
}


Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+20 , SIZE = 1020 , Mod = 1e9+7;
int n,m,p[SIZE],a[SIZE],cnt,fac[2*N],inv[2*N],Max,ans;
inline int add(int x,int y) { return x + y >= Mod ? x + y - Mod : x + y; }
inline int mul(int x,int y) { return 1LL * x * y % Mod; }
inline void Add(int &x,int y) { x = add( x , y ); }
inline void Mul(int &x,int &y) { x = mul( x , y ); }
inline int quickpow(int a,int b) { int res = 1; for (;b;Mul(a,a),b>>=1) if ( 1 & b ) Mul(res,a); return res; }
inline int C(int a,int b) { return 1LL * fac[a] * inv[b] % Mod * inv[a-b] % Mod; }
int main(void)
{
    scanf("%d%d",&n,&m);
    int val = m;
    for (int i=2;i*i<=val;i++)
        if ( m % i == 0 )
        {
            p[++cnt] = i;
            while ( m % i == 0 )
                m /= i , Max = max( Max , ++a[cnt] );
        }
    if ( m > 1 ) p[++cnt] = m , Max = max( Max , a[cnt] = 1 );
    fac[0] = inv[0] = 1LL;
    for (int i=1;i<=n+Max;i++)
        fac[i] = mul( fac[i-1] , i );
    inv[n+Max] = quickpow( fac[n+Max] , Mod-2 );
    for (int i=n+Max-1;i>=1;i--)
        inv[i] = mul( inv[i+1] , i+1 );
    ans = 1LL;
    for (int i=1;i<=cnt;i++)
        ans = 1LL * ans * C( a[i] + n - 1 , n - 1 ) % Mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#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 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)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
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 };

/* -----  2019/03/21  Problem: ABC 064 C / Link: http://abc064.contest.atcoder.jp/tasks/abc064_c  ----- */


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

	LL N;
	cin >> N;
	vector<LL> a(N);
	VI M(9, 0);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		if (a[i] >= 3200)a[i] = 3200;
		M[a[i] / 400]++;
	}
	int emptys = 0;
	FOR(i, 0, 8) {
		if (!M[i])emptys++;
	}

	cout << (emptys == 8 ? !!M[8] : 8 - emptys)
		<< " " << 8 - emptys + M[8] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 200005;

int A[MX], B[MX];
int chk[MX];
int N, K, Q;

int main()
{
	scanf("%d%d%d", &N, &K, &Q);
	for(int i = 1; i <= N; i++) scanf("%d", A+i);
	for(int i = 1; i <= N; i++) B[i] = i;
	sort(B+1, B+N+1, [](int l, int r){ return A[l] < A[r]; });
	chk[N+1] = 1;
	int ans = 1e9;
	for(int i = 1; i <= N; i++){
		vector<int> L, M;
		for(int i = 1; i <= N+1; i++){
			if(chk[i]){
				sort(L.begin(), L.end());
				for(int t = 0; t < (int)L.size() - K + 1; t++) M.push_back(L[t]);
				L.clear();
			}
			else L.push_back(A[i]);
		}
		sort(M.begin(), M.end());
		if(M.size() >= Q) ans = min(ans, M[Q-1] - M[0]);
		chk[B[i]] = 1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ne(ll ar[],ll br[],ll cr[],ll n,int x,ll p)
{
	if(p<n-1)
	{
		if(x==1)return max(br[p+1]+ne(ar,br,cr,n,2,p+1),cr[p+1]+ne(ar,br,cr,n,3,p+1));
		else if(x==2)return max(ar[p+1]+ne(ar,br,cr,n,1,p+1),cr[p+1]+ne(ar,br,cr,n,3,p+1));
		else if(x==3)return max(ar[p+1]+ne(ar,br,cr,n,1,p+1),br[p+1]+ne(ar,br,cr,n,2,p+1));
	}
	else if(p==n-1)
	{
		return 0;
	}
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll ar[n],br[n],cr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>ar[i]>>br[i]>>cr[i];	
	}
	ll dr[n][3];
	dr[n-1][0]=ar[n-1];
	dr[n-1][1]=br[n-1];
	dr[n-1][2]=cr[n-1];
	for(ll i=n-2;i>=0;i--)
	{
		dr[i][0]=ar[i]+max(dr[i+1][1],dr[i+1][2]);
		dr[i][1]=br[i]+max(dr[i+1][0],dr[i+1][2]);
		dr[i][2]=cr[i]+max(dr[i+1][1],dr[i+1][0]);
	}
	cout<<max(max(dr[0][0],dr[0][1]),dr[0][2]);
	return 0;
}

Measured memory_bytes: 4992
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
ans = 'Yay!'
if b - a > k:
    ans = ':('
if c - a > k:
    ans = ':('
if d - a > k:
    ans = ':('
if e - a > k:
    ans = ':('
if c - b > k:
    ans = ':('
if d - b > k:
    ans = ':('
if e - b > k:
    ans = ':('
if d - c > k:
    ans = ':('
if e - c > k:
    ans = ':('
if e - d > k:
    ans = ':('
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    int N;
    cin >> N;

    cout << 180 * (N - 2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
int main()
{
    int    a, b;
    double c;
    int    C;
 
    cin >> a >> b >> C;
     
    double S = (1.0 / 2.0) * a * b * sin(C * (double)M_PI / 180.0);
     
    c = (double)sqrt(a * a + b * b - 2 * a * b * (cos(C * (double)M_PI / 180.0)));
 
    double L = a + b + c;
 
    double h = 2.0 * S / a;
 
    cout << fixed << setprecision(13) << S << " " << setprecision(13) << L << " "
                  << setprecision(13) << h << endl;
    
    return (0);
}

Measured memory_bytes: 3576
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

import itertools
accum_a1 = list(itertools.accumulate(a1))
accum_a2 = list(itertools.accumulate(a2[::-1]))[::-1]

ans = 0
for i in range(n):
    ans = max(ans, (accum_a1[i]+accum_a2[i]))
print(ans)

Measured memory_bytes: 3188
// practice with Dukkha, coached by rainboy
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 10000;

int d2c[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int dd[8];
int dp[N + 1];

int main() {
	int n, m; cin >> n >> m;
	while (m--) {
		int d; cin >> d;
		int c = d2c[d];
		dd[c] = max(dd[c], d);
	}
	fill(dp, dp + n + 1, -1);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int k = dp[i];
		if (k == -1)
			continue;
		for (int c = 2; c <= 7 && i + c <= n; c++)
			if (dd[c])
				dp[i + c] = max(dp[i + c], k + 1);
	}
	for (int i = n; i > 0; ) {
		int d_ = 0, c_ = 0;
		for (int c = 2; c <= 7 && i - c >= 0; c++) {
			int d = dd[c];
			if (d_ < d && dp[i] == dp[i - c] + 1) {
				d_ = d;
				c_ = c;
			}
		}
		cout << d_;
		i -= c_;
	}
	cout << '\n';
	return 0;
}


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

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int cnt=0;

bool binary_search(vector<int>& data, int keyv){
    int r_ind = data.size();
    int l_ind = 0;
    while(l_ind < r_ind){
        int c_ind = (l_ind + r_ind) / 2;
        if(data[c_ind] == keyv){
            return true;
        }else if(keyv < data[c_ind]){
            r_ind = c_ind;
        }else{
            l_ind = c_ind+1;
        }
    }
    return false;
}

void solve(vector<int>& sorted, vector<int>& unsorted){
    int l = unsorted.size();
    for(int i=0; i<l; i++){
        if( binary_search(sorted, unsorted[i]) ){
            cnt++;
        }
    }
}

int main(){
    int n; cin >> n;
    vector<int> S(n);
    rep(i,n){
        cin >> S[i];
    } 

    int q; cin >> q;
    vector<int> T(q);
    rep(i,q){
        cin >> T[i];
    }

    solve(S, T);    

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3336
N,M = map(int,input().split())
A=[]
for i in range(0,N,1):
    a = list(map(int,input().split()))
    A.append(a[1::])

ans = [i for i in range(1,M+1,1)]
for i in range(0,N,1):
    ans = list(set(ans) & set(A[i]))
print(len(ans))


Measured memory_bytes: 62756
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i,n-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(50000)
#define INFL LLONG_MAX
#define NINFL LLONG_MIN
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

int main() {

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

	// Write your code here

	int t = 1;
	// cin >> t;
	while (t--) {
		ll len;
		cin >> len;
		string s;
		ll n;
		cin >> n >> s;
		n--;
		s[n] = s[n] + 32;
		cout << s << "\n";
	}


	return 0;
}

Measured memory_bytes: 3620
#include<iostream>

using namespace std;

const int N = 123456;
int dp[3][N];

int main(){
  int n;
  cin >> n;
  int a,b,c;
  cin >> a >> b >> c;
  dp[0][0] = a;
  dp[1][0] = b;
  dp[2][0] = c;
  for(int i = 1; i<n; i++){
    cin >> a >> b >> c;
    dp[0][i] = max(dp[1][i-1],dp[2][i-1])+a;
    dp[1][i] = max(dp[0][i-1],dp[2][i-1])+b;
    dp[2][i] = max(dp[1][i-1],dp[0][i-1])+c;
  }
  cout << max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]) << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
using namespace std;

struct Node{
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

struct Node *NIL, *root;

void init(){
    root = NIL;
}

void insert(Node* z){
    struct Node* y = NIL; // xの親
    struct Node* x = root;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;

    if(y == NIL){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z; 
    }else{
        y->right = z;
    }
}

bool find_number(Node* x, int num){
    if(x == NIL){
        return false;
    }
    if(x->key == num){
        return true;
    }
    if(x->key < num){
        return find_number(x->right, num);
    }
    return find_number(x->left, num);
}

void print_node_inorder(Node* x){
    if(x == NIL){
        return;
    }
    print_node_inorder(x->left);
    printf(" %d", x->key);
    print_node_inorder(x->right);
}

void print_node_pre(Node* x){
    if(x == NIL){
        return;
    }
    printf(" %d", x->key);
    print_node_pre(x->left);
    print_node_pre(x->right);
}

void print_(){
    print_node_inorder(root);
    printf("\n");
    print_node_pre(root);
    printf("\n");
}

int main(void){
    void init();
    
    int m;
    scanf("%d", &m);

    string com;

    for(int i = 0; i < m; i++){
        cin >> com;
        if(com == "insert"){
            struct Node* n;
            n = (struct Node*)malloc(sizeof(struct Node));
            n->right = NIL;
            n->left = NIL;
            n->parent = NIL;
            scanf("%d", &n->key);
            insert(n);
        }else if(com == "print"){
            print_();
        }else if(com == "find"){
            int num;
            scanf("%d", &num);
            if(find_number(root, num)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }else{
            printf("invalid command");
            cout << com;
        }
    }

    return 0;
}



Measured memory_bytes: 21932
#include<stdio.h>
#include<iso646.h>

int main(){
  int X,A,B;

  scanf("%d %d %d",&X,&A,&B);
  if(B <= A){
    printf("delicious\n");
  }else if((B - A) <= X){
    printf("safe\n");
  }else if((B - A) > X){
    printf("dangerous\n");
  }
  return 0;
}

Measured memory_bytes: 128
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    auto N = lread();
    auto A = aryread();
    auto B = aryread();
    auto C = aryread();
    // writeln(A);
    // writeln(B);
    // writeln(C);
    auto a = A.sort();
    auto b = B.sort();
    auto c = C.sort();
    // writeln(a);
    // writeln(b);
    // writeln(c);
    auto x = new long[](N);
    auto y = new long[](N);
    // writeln(x);

    foreach (i; 0 .. N)
    {
        long ok = -1;
        long ng = a.length;
        while (abs(ng - ok) > 1)
        {
            long mid = (ok + ng) / 2;
            if (a[mid] < b[i])
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }

        }
        // writeln("b[i]:", b[i]);
        // writeln("ok:", ok);
        // writeln("ng:", ng);
        // writeln("a[ok]:", a[ok]);
        x[i] = ok + 1;
        // writeln("x:", x);
    }
    foreach (i; 0 .. N)
    {
        long ok = b.length;
        long ng = -1;
        while (abs(ok - ng) > 1)
        {
            long mid = (ok + ng) / 2;
            if (c[mid] > b[i])
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        // writeln("b[i]:", b[i]);
        // writeln("ok:", ok);
        // writeln("ng:", ng);
        // writeln("c[ok]:", c[ok]);
        y[i] = b[ok .. $].length;
        // writeln("y:", y);

    }
    // writeln(x);
    // writeln(y);
    long ans;
    foreach (i; 0 .. N)
    {
        ans += x[i] * y[i];
    }
    // writeln("ans:", ans);
    writeln(ans);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 16032
#include <cstdlib>
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<fstream>
#include<deque>
#include<cmath>
#define LL long long int
using namespace std;
#define Maxn 100010
#define  M 1000000000
#define lowbit(x) (x&(-x))
int n,m;
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        if(n==0&&m==0) break;
        n=(n*m)%2;
        if(n) printf("no\n");else printf("yes\n");
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
typedef long long ll;


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string s;
    cin >> s;

    rep(i, s.size()) {
        cout << "x";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3628
from itertools import accumulate


n,k = map(int, input().split())
a = list(map(int, input().split()))
def new(a):
    if all([i == n for i in a]):
        print(*a)
        exit()
    res = [0] * (n+1)
    for k,v in enumerate(a):
        res[max(0,k-v)] += 1
        res[min(n,v+k+1)] -= 1
    return list(accumulate(res[:-1]))

for i in range(k):
    a = new(a)
print(*a)

Measured memory_bytes: 182328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s,k; cin >> s >> k;
    cout << k + s << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 KMnO4 is _____________ agent.
*/
#include <set>          
#include <map>           
#include <list>
#include <ctime>
#include <deque>         
#include <bitset>        
#include <vector>
#include <list>
#include <stack>
#include <random>		 
#include <string>       
#include <numeric>      //  needed for  accumulate
#include <utility>      // needed for std:: move
#include <iterator> 
#include <iostream>   
#include <algorithm> 
#include <functional>    
#include <cmath>         
#pragma warning(disable:4996) // ignore this
#define siz size()
#define ve vector
#define pb push_back
#define mp make_pair                     
#define rsz(n) resize(n)
#define get_int(x) scanf("%d",&x)              
#define get_long(x) scanf("%lld",&x)           
#define srt(x) sort(x.begin(),x.end())         
#define gor(i,x,y) for(int i=x;i<y;i++)        
#define mod static_cast<long long> (1e9+7)     
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define ti(v) for(int i=0,u,w;i<v.size()-1;i++,v[u-1].pb(w-1),v[w-1].pb(u-1))scanf("%d%d",&u,&w) ; // rarely used 
#define FU 2e9
#define SZ 15000000
#define testing 1
#include <queue>
using namespace std;
template<typename T>									
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		in >> x;
	return in;
}
template<typename T>									
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		in << x << " ";
	return in;
}
long long fast(long long a,long long b)
{
	if(b==0)
		return 1;
	long long ans=a;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return ans;
}
class solve
{
	long long int n,m;
	long long fact(long long va)
	{
		long long ans=1;
		for(int i=1;i<=va;i++)
		{
			ans = (ans*i)%mod;
		}
		return ans;
	}
public:
	solve()
	{
		int mi,M;
		cin >> n >> m;
		mi=min(n,m);
		M=max(n,m);
		m=mi;
		if(M-m>1)
		{
			cout << 0 << endl;
			return;
		}
		n=fact(M)*fact(m);
		n%=mod;
		if(M-m==0)
		{
			cout << (n*2)%mod<<endl;
			return;
		}
		cout << n << endl;
		
		
	}
};
int main()
{
	int t=1;
	//scanf("%d",&t);
	while(t--)
		new solve;
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
 
int a,b,n,sum;
 
int main(){
  while(scanf("%d%d%d",&a,&b,&n)!=EOF){
    sum=0;
    a=a%b;
    while(n--){
      sum+=(a*10)/b;
      a=(a*10)%b;
    }
    printf("%d\n",sum);
  }
  return 0;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b;
  cin >> a >> b;
  a = (a + 11) % 13;
  b = (b + 11) % 13;
  cout << (a == b ? "Draw" : (a > b ? "Alice" : "Bob")) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int sum=0;
  string n;
  cin>>n;
 for(long long int i=0;i<n.size();i++)
   sum+=n[i]-'0';
  
  if(sum%9==0)
    cout<<"Yes"<<'\n';
  else
    cout<<"No"<<'\n';
  
    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N, M; cin >> N >> M; int a[M];
  rep(i, M){
    cin >> a[i];
  }
  int match[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  int dp[N+1];
  rep(i, N+1){
    dp[i] = -inf;
  }
  dp[0] = 0;
  rep(i, N+1){
    rep(j, M){
      if(i-match[a[j]-1]>=0) dp[i] = max(dp[i-match[a[j]-1]] + 1, dp[i]);
    }
  }
  sort(a, a+M, greater<int>());
  int ma = N;
  while(ma != 0){
    rep(i, M){
      if(ma-match[a[i]-1]<0) continue;
      else if(dp[ma]==dp[ma-match[a[i]-1]]+1){
        cout << a[i]; ma -= match[a[i]-1]; break;
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt(),h = scanner.nextInt(),n = scanner.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] a = new int[n];
		int xmax = w,xmin = 0;
		int ymax = h,ymin = 0;
		for(int i=0;i<n;i++){
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
			a[i] = scanner.nextInt();
			switch(a[i]){

			case 1:
				xmin = Math.max(xmin, x[i]);
				break;
			case 2:
				xmax = Math.min(xmax, x[i]);
				break;
			case 3:
				ymin = Math.max(ymin, y[i]);
				break;
			case 4:
				ymax = Math.min(ymax, y[i]);
				break;
			}
		}
		w = Math.max(xmax-xmin, 0);
		h = Math.max(ymax-ymin, 0);

		System.out.println(w*h);

	}

}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    constexpr auto M = 998244353L;

    int64_t n, a, b, k;
    cin >> n >> a >> b >> k;

    vector<int64_t> fact(n + 1, 1L), ifact(n + 1, 1L), inv(n + 1, 1L);
    for (auto i : irange(2L, n + 1)) {
        fact[i] = fact[i - 1] * i % M;
        inv[i] = (M - inv[M % i] * (M / i) % M) % M;
        ifact[i] = ifact[i - 1] * inv[i] % M;
    }

    auto combi = [&](int64_t x, int64_t y) {
        return fact[x] * ifact[y] % M * ifact[x - y] % M;
    };

    int64_t ans = 0;
    for (auto i : irange(0L, n + 1)) {
        if (i * a > k) {
            break;
        }

        int64_t j = (k - i * a) / b;
        if (i * a + j * b != k || j > n) {
            continue;
        }

        ans += combi(n, i) * combi(n, j) % M;
        ans %= M;
    }

    cout << ans << endl;
}

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

const double pi = acos(-1);
double a, b, h, m;

int main()
{
	ios::sync_with_stdio(false);
	cin >> a >> b >> h >> m;
	double ang = fabs(h * 30 - 5.5 * m); 
	ang = ang / 180 * pi;
//	cout << ang << endl;
	double res = sqrt(a*a + b*b - 2*a*b*cos(ang));
	cout << fixed << setprecision(20) << res << endl; 
	return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

string S;

bool isdiverse(string V) {
	for (int i = 0; i < V.size(); i++) {
		for (int j = i + 1; j < V.size(); j++) { if (V[i] == V[j]) return false; }
	}
	return true;
}

int main() {
	cin >> S; S += (char)('a' - 1);
	while (S.size() >= 1) {
		while (S[S.size() - 1] < 'z') {
			S[S.size() - 1]++;
			if (isdiverse(S) == true) {
				cout << S << endl;
				return 0;
			}
		}
		S = S.substr(0, S.size() - 1);
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
ox,oy=0,0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        if ox<x:
            ox=x
    elif a==2:
        if w>x:
            w=x
    elif a==3:
        if oy<y:
            oy=y
    else:
        if h>y:
            h=y
print(max(w-ox,0)*max(h-oy,0))


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll<<60;
const int mod = 1e9 + 7;
// using Graph = vector<vector<int>>;

struct edge {
    int to, cost;
    edge(){}
    edge(int _to, int _cost) : to(_to), cost(_cost) {}
};
using Graph = vector<vector<edge>>;

// directed
void addEdge(Graph& G, int x, int y, int c) {
    G[x].emplace_back(y, c);
    // G[y].emplace_back(x, c);
}
int dijkstra(const Graph& G, int s, int g) {
    int n = G.size();
    using State = pair<int, int>;
    priority_queue<State, vector<State>, greater<State>> pq;   // cost, vertex
    vector<int> d(n, inf);
    d[s] = 0;
    pq.push(State(0, s));

    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        int v = p.second;
        if (v == g) break;
        if (d[v] < p.first) continue;
        for (const auto& e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(State(d[e.to], e.to));
            }
        }
    }
    return d[g];
}


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

    int x, y;
    cin >> x >> y;
    vi a{x, -x, y, -y};
    Graph G(4);
    rep(i, 4) {
        rep(j, 4) {
            if (i == j) continue;
            if (a[i] == -a[j]) {
                addEdge(G, i, j, 1);
            }
            if (a[i] <= a[j]) {
                addEdge(G, i, j, a[j] - a[i]);
            }
        }
    }

    cout << dijkstra(G, 0, 2) << endl;
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=255;
int n,cnt,b[MAXN*2],dp[MAXN*3][MAXN*3],MOD;
pair<int,int>a[MAXN*3];
inline int f(int i){return (int)(sqrt(n*n-i*i-1))+1;}
inline int g(int i){return min(2*n,(int)(sqrt(4*n*n-i*i))+1);}
inline int mod1(int x){return x<MOD?x:x-MOD;}
inline int mod2(int x){return x<0?x+MOD:x;}
int main() {
	n=read();MOD=read();
	for(int i=0;i<n;++i)a[++cnt]=mk(f(i),1);//a
	for(int i=0;i<n;++i)a[++cnt]=mk(g(i),2);//b
	for(int i=n;i<2*n;++i)a[++cnt]=mk(g(i),3);//c
	sort(a+1,a+cnt+1);
	int pos=2*n;
	for(int i=1;i<=2*n;++i)if(a[i].scd==1)b[i]=++pos;
	assert(pos==3*n);
	int ans=0;
	for(int k=0;k<=n;++k){
		for(int i=1;i<=2*n;++i)for(int j=1;j<=k;++j)dp[i][j]=0;
		dp[0][0]=1;
		int c=0;
		for(int i=1;i<=2*n;++i){
			if(a[i].scd==1){
				for(int j=0;j<=k;++j){
					dp[i][j]=(ll)dp[i-1][j]*mod2(a[b[i]].fst%MOD-(n+i-1-c-j+k)%MOD)%MOD;
					if(j)dp[i][j]=mod1(dp[i][j]+(ll)dp[i-1][j-1]*mod2(a[i].fst%MOD-(j-1+c))%MOD);
				}
			}else{
				for(int j=0;j<=k;++j)dp[i][j]=(ll)dp[i-1][j]*mod2(a[i].fst%MOD-(j+c))%MOD;
				++c;
			}
		}
		if(k&1)ans=mod2(ans-dp[2*n][k]);
		else ans=mod1(ans+dp[2*n][k]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
s = list(input() for _ in range(n))

alphabet = [[0] * n for _ in range(26)]

for i in range(n):
    for x in s[i]:
        alphabet[ord(x) % 97][i] += 1

ans = ''
for i in range(26):
    m = min(alphabet[i])
    if m != 0:
        for _ in range(m):
            ans += chr(i + 97)

print(ans)


Measured memory_bytes: 9192