akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
constexpr int mod = 26;

class UnionFind{
private:
    vec<int> p,s;
    int cnt;
public:
    vec<int> v;
    UnionFind(){}
    UnionFind(int N):cnt(N),s(N,1),p(N),v(N){
        iota(p.begin(),p.end(),0);
    }
    int find(int x){
        if(p[x]==x) return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x,int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(s[x]>s[y]) swap(x,y);
        p[x] = y;
        s[y] += s[x];
        (v[y] += v[x])%=mod;
        cnt--;
    }
    bool is_same_set(int x,int y) {return find(x)==find(y);}
    int size(int x) {return s[find(x)];}
    int compnents_number(){return cnt;}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    vec<int> A(N+2,0);
    for(int i=0;i<N;i++) A[i+1] = S[i]-'a';
    vec<int> D(N+1);
    UnionFind uf(N+1);
    for(int i=0;i<=N;i++){
        D[i] = (A[i+1]-A[i]+mod)%mod;
        (uf.v[min(i,N-i)] += D[i])%=mod;
    }
//    for(int i=0;i<=N/2;i++) cerr << uf.v[i] << "\n";
    int M;
    cin >> M;
    for(int i=0;i<M;i++){
        int l,r;
        cin >> l >> r;
        l--; r--;
        uf.unite(min(l,N-l),min(r+1,N-r-1));
    }
    bool ok = true;
    for(int i=0;i<=N;i++) ok &= !uf.v[uf.find(i)];
    cout << (ok? "YES\n":"NO\n");
}

Measured memory_bytes: 2384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

const string color = "RYGB";
const int ex[4] = {-1,0,1,0};
const int ey[4] = {0,-1,0,1};
const int B = 1700;
const int offset = 750;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,d; cin >> H >> W >> d;
    
    vector<int> dx,dy;
    if (d&1) {
        dx = {(d+1)/2,-(d/2),-((d+1)/2),d/2};
        dy = {d/2,(d+1)/2,-(d/2),-((d+1)/2)};
    } else {
        dx = {-d/2,d/2,d/2,-d/2};
        dy = {-d/2,-d/2,d/2,d/2};
    }
    vector<vector<char>> ans(B, vector<char>(B,'#'));
    auto dfs=[&](auto&& self, int x, int y, int c)->void {
        //print(x,y,c);
        ans[x][y] = color[c];
        if (~d&1 and y+1 < B) ans[x][y+1] = color[c];
        rep(k,4) {
            int nx = x + dx[k];
            int ny = y + dy[k];
            int nc = ((k&1) ? (c^1) : (c^2));
            if (nx < 0 or nx >= B or ny < 0 or ny >= B) continue;
            if (ans[nx][ny]!='#') continue;
            self(self,nx,ny,nc);
        }
    };
    dfs(dfs,0,0,0);

    queue<pii> que;
    rep(i,B) rep(j,B) {
        if (ans[i][j]!='#') que.emplace(i,j);
    }
    while (!que.empty()) {
        auto[x,y] = que.front(); que.pop();
        rep(k,4) {
            int nx = x + ex[k];
            int ny = y + ey[k];
            if (nx < 0 or nx >= B or ny < 0 or ny >= B) continue;
            if (ans[nx][ny]!='#') continue;
            ans[nx][ny] = ans[x][y];
            que.emplace(nx,ny);
        }
    }

    for (int i = offset; i < offset+H; i++) {
        for (int j = offset; j < offset+W; j++) cout << ans[i][j];
        cout << ln;
    }
}

Measured memory_bytes: 210240
import scala.io.StdIn._

object Main {
    def main(args: Array[String]): Unit = { 
        val seq: Seq[Int] = (0 until 10).map(_ => readInt())
        val rev: Seq[Int] = seq.sorted.reverse
        for(i <- 0 until 3) println(rev(i))
    }   
}

Measured memory_bytes: 43940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

const int64 mod = 998244353;

int64 mpow(int64 mm, int64 xx)
{
	if(xx == 0)
	{
		return 1;
	}
	int64 tmp = mpow(mm, xx / 2);
	tmp *= tmp;
	tmp %= mod;
	if(xx % 2 == 1)
	{
		tmp *= mm;
		tmp %= mod;
	}
	return tmp;
}

int main()
{
	int64 nn;
	cin >> nn;
	vector<int64> hh(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> hh[ii];
	}
	for(int64 ii = nn - 2;ii >= 0;ii--)
	{
		if(hh[ii] > hh[ii + 1])
		{
			if(hh[ii] - hh[ii + 1] == 1)
			{
				hh[ii]--;
			}
			else
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

ll fact[N], inv[N];
ll c(ll n, ll k){
	return 1ll * fact[n] * inv[n - k] % mod * inv[k] % mod;
}
void solve(){
	ll n, k;
	cin >> n >> k;
	
	ll pref[n + 1];
	pref[0] = 0;
	for(ll i = 1; i <= n + 1; ++i){
		pref[i] = pref[i - 1] + i;
	}

	ll res = 1;
	for(ll i = k; i <= n; ++i){
		ll x = pref[i - 1];
		ll y = (pref[n] - pref[n - i] + 1) % mod + mod;
		y %= mod;
		//cotu << x << ' ' << y << endl;
		res += y - x;
		res %= mod;
		res += mod;
		res %= mod;
	}
	cotu << res;
}



 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;

}

Measured memory_bytes: 5172
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;cin>>a>>b;
    string aa="",bb="";
    for(int i=0;i<b;i++)aa+=to_string(a);
    for(int i=0;i<a;i++)bb+=to_string(b);
    cout<<mmin(aa,bb)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

int main(){
	int n, F[100][10], P[100][11];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 10; j++)
			scanf("%d", &F[i][j]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= 10; j++)
			scanf("%d", &P[i][j]);

	int max = -1e9;
	for (int i = 1; i < (0x1 << 10); i++) {
		int count[100] = { 0 };
		for (int j = 0; j < n; j++)
			for (int k = 0; k < 10; k++)
				count[j] += (i >> k) & F[j][k];
		int score = 0;
		for (int j = 0; j < n; j++)
			score += P[j][count[j]];
		max = std::max(score, max);
	}
	printf("%d\n", max);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    long long int ans = 0;
    cin >> N;
    for (int i = 1; i < N+1; i++) {
        if (i%15 != 0 && i%3 !=0 && i%5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int h, w;
int a[80][80];
int b[80][80];

const int kMax = 80 * 80 * 2;

bool dp[81][81][kMax + 1];

int main() {
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  dp[0][1][0] = true;
  rep(i, h) rep(j, w) {
    int diff = abs(a[i][j] - b[i][j]);
    for (int d = 0; d <= kMax; ++d) {
      if (dp[i][j + 1][d] || dp[i + 1][j][d]) {
        dbg(i, j, d, diff);
        dp[i + 1][j + 1][abs(d - diff)] = true;
        if (d + diff <= kMax) {
          dp[i + 1][j + 1][diff + d] = true;
        }
      }
    }
  }
  rep(i, kMax + 1) if (dp[h][w][i]) {
    out(i);
    return 0;
  }
}


Measured memory_bytes: 80896
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b): return a * b // gcd(a, b)

def lcm_list(A):
    l = A[0]
    for a in A[1:]:
        l = lcm(l, a)
    return l

MOD = 10**9 + 7

N = int(input())
*A, = map(int, input().split())
L = lcm_list(A)
ans = 0
for a in A:
    ans += L // a
print(ans % MOD)

Measured memory_bytes: 4084
#include<stdio.h>

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

  if(d==25){
    printf("Christmas");
  }else if(d==24){
    printf("Christmas Eve");
  }else if(d==23){
    printf("Christmas Eve Eve");
  }else if(d==22){
    printf("Christmas Eve Eve Eve");
  }

  return 0;
}

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

long long renum(long long x){
    if(x == 2){
        return 3;
    }else{
        return 1 + 2 * renum(x / 2);
    }
}

long long renum2(long long sq){
    if(sq == 0){
        return 1;
    }else{
        return 1 + 2 * renum2(sq - 1);
    }
}

int main(){
    long long H;
    cin >> H;

    int sq = -1;
    for(long long i = 0; i < H; i++){
        if(pow(2, i) <= H && pow(2, i + 1) > H){
            sq = i;
            break;
        }
    }

    // long long ask = pow(2, sq);

    // cout << renum(ask) << endl;

    cout << renum2(sq) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[5]= {0},i,max,sum,t=0,b[5]= {0};
    sum=0;
    for(i=0; i<5; i++)
        scanf("%d",&a[i]);
    for(i=0; i<5; i++)
    {
        if(a[i]%10==0)
            b[i]=0;
        else
            b[i]=10-a[i]%10;
    }
    max=b[0];
    for(i=1; i<5; i++)
    {
        if(b[i]>max)
            max=b[i];
    }
    for(i=0; i<5; i++)
    {
        if(b[i]==max)
            t++;
    }
    for(i=0; i<5; i++)
    {

        if(b[i]==max&&t==1)
            sum=sum+a[i];
        else
            sum=sum+b[i]+a[i];
    }
    if(t!=1)
        sum=sum-max;
    printf("%d",sum);
}

Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n = readline() |> parseInt
    f = 0
    for i in 1:n
        if i*(i+1)==2*n
            f = 1
            println("Yes")
            println(i+1)
            ans = [Int[] for j in 1:i+1]
            h = -ones(Int,i+1)
            ans[1] = [j for j in 1:i]
            h[1] = 1
            btm = i
            for j in 2:i+1
                for k in 1:j-1
                    push!(ans[j],h[k])
                    h[k] += 1
                end
                h[j] = btm+1
                for k in 1:i-j+1
                    push!(ans[j],btm+k)
                end
                btm += i-j+1
            end
            for j in 1:i+1
                print(i," ")
                for k in 1:i-1
                    print(ans[j][k]," ")
                end
                println(ans[j][i])
            end
            break
        end
    end
    if f == 0
        println("No")
    end      
end
main()

Measured memory_bytes: 170068
#include<bits/stdc++.h>
using namespace std;
#define LEN 100005

struct P{
    char name[100];
    int t;
};

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int main(){
    int elaps = 0,c;
    int i,q;
    P u;
    cin >> n >> q;

    for(i=1;i<=n;i++){
        cin >> Q[i].name;
        cin >> Q[i].t;
    }
    head = 1; tail = n + 1;
    
    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            cout << u.name << " " << elaps << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 13156
#include <stdio.h>

int main(void) {
  int n, m, l;
  long a[100][100] = {0};
  long b[100][100] = {0};
  long c[100][100] = {0};
  int i, j, k;

  scanf("%d %d %d", &n, &m, &l);

  for(i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      scanf("%ld", &a[i][j]);

  for(i = 0; i < m; i++)
    for (j = 0; j < l; j++)
       scanf("%ld", &b[i][j]);

  for(i = 0; i < n; i++) {
    for(j = 0; j < l; j++) {
      for (k = 0; k < m; k++) {
	c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  

  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      printf("%ld", c[i][j]);
      if (j != l - 1)
	printf(" ");
    }
    printf("\n");
  }


  return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

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


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	string s;
	int k;
	cin >> s >> k;
	rep(i, 0, k) {
		if (s[i] > '1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int check(string &s,string &t) {
  if(sz(s) != sz(t)) return sz(s) < sz(t) ? 1 : -1;
  rep(i,sz(s)) {
    if(s[i] != t[i]) return s[i] < t[i] ? 1 : -1;
  }
  return 0;
}
  
int main() {
  int N,M;
  cin >> N >> M;
  vi A(M);
  rep(i,M) {
    cin >> A[i];
  }
  vi cost = {2,5,5,4,5,6,3,7,6};
  v(string) dp(N+1,"");
  rep(i,N+1) {
    rep(c,M) {
      int x = cost[A[c]-1];
      if((i-x > 0 && dp[i-x] != "") || i-x == 0) {
        string t = dp[i-x] + to_string(A[c]);
        int res = check(dp[i],t);
        if(res < 1) continue;
        dp[i] = t;
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 31872
-- C
local sub = string.sub
local n = io.read('*n', '*l')
local s = io.read('*l')
ss = {}
for i = 1, n do
	ss[i] = sub(s, i, i)
end
local ret = {
	{[1] = 1, [2] = 1},
	{[1] = 1, [2] = 0},
	{[1] = 0, [2] = 0},
	{[1] = 0, [2] = 1},
}
for i = 2, n-1 do
	for j = 1, 4 do
		local ans = ret[j]
		if (ss[i] == 'o') == (ans[i] == 1) then
			ans[i + 1] =  ans[i - 1]
		else
			ans[i + 1] =  1 - ans[i - 1]
		end
	end
end

local function isOK(a, b, c, ch)
	if (ch == 'o') == (b == 1) then
		return a == c
	end
	return a ~= c
end

local sum = 0
local result = nil
for j = 1, 4 do
	local ans = ret[j]
	if isOK(ans[n], ans[1], ans[2], ss[1]) and isOK(ans[n-1], ans[n], ans[1], ss[n]) then
		sum = sum  + 1
		result = ans
		break
	end
end

if sum >= 1 then
	for i = 1, n do
		result[i] = result[i] == 1 and "S" or "W"
	end
	print(table.concat(result))
else
	print(-1)
end


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

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> score(n, k-q);
	rep(i, q) {
		int a; cin >> a;
		a--;
		score[a]++;
	}
	for (int c : score) {
		if (c > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;


int main(){
	int n, k;

	cin >> n >> k;
	
	int ar[n];

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

	sort(ar, ar+n);

	int total = 0;

	for (int i = 0; i < k; i++){
		total += ar[i];
	}


	cout << total << endl;

	return 0;
}

Measured memory_bytes: 3624
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	int min_moto = int.max;
	foreach(_; 0..N) {
		auto m = ri;
		min_moto = min(min_moto, m);
		M -= m;
	}
	(M / min_moto + N).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll half = N / 2;
    ll maxskip = (N % 2 == 0) ? 1 : 2;
    vector<vector<ll>> dp(maxskip + 1, vector<ll>(N, -INF));
    if (N % 2 == 0) {
        dp[0][0] = A[0];
        dp[1][1] = A[1];
        if (N > 2) {
            dp[0][2] = A[0] + A[2];
        }
        for (ll i = 3; i < N; i++) {
            dp[0][i] = dp[0][i - 2] + A[i];
            dp[1][i] = max(dp[1][i - 2] + A[i], dp[0][i - 3] + A[i]);
        }
        ll result = max(dp[0][N - 2], dp[1][N - 1]);
        print(result);
    } else {
        dp[0][0] = A[0];
        dp[1][1] = A[1];
        dp[2][2] = A[2];
        if (N > 2) {
            dp[0][2] = A[0] + A[2];
        }
        if (N > 3) {
            dp[1][3] = max(A[1] + A[3], A[0] + A[3]);
        }
        for (ll i = 4; i < N; i++) {
            dp[0][i] = dp[0][i - 2] + A[i];
            dp[1][i] = max(dp[1][i - 2] + A[i], dp[0][i - 3] + A[i]);
            dp[2][i] = max(max(dp[2][i - 2] + A[i], dp[1][i - 3] + A[i]), dp[0][i - 4] + A[i]);
        }
        ll result = max(max(dp[0][N - 3], dp[1][N - 2]), dp[2][N - 1]);
        print(result);
    }
}


Measured memory_bytes: 11172
n,m,x=parse.(Int,split(readline()))
l=vcat([(x->parse(Int,x)).(split(i))' for i in readlines()]...)
ans=[i[1] for i=[l'*i for i in [[i...] for i=Iterators.product(fill(0:1,n)...)]][:] if all(z->z>=x,i[2:end])]
print(length(ans)==0 ? -1 : minimum(ans))

Measured memory_bytes: 233660
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
    string a[3];
    for (int i=0;i<3;i++)
             cin>>a[i];
    cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
    return 0;
} 


Measured memory_bytes: 256
S=input()
Q=int(input())
reverse=False
front=""
rear=""
for _ in range(Q):
    inp=input()
    if inp[0]=="1":
        reverse= not reverse
    elif inp[0]=="2":
        if (inp[2]=="1" and not reverse) or (inp[2]=="2" and reverse):
            front=inp[4]+front
        else:
            rear=rear+inp[4]
ans=front+S+rear
if reverse:
    ans=ans[::-1]
print(ans)

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

int main(){
  int N;
  cin >> N;
  
  int t_now = 0;
  int x_now = 0;
  int y_now = 0;
  bool can_travel = true;
  for(int i=0; i<N; ++i){
    int t_next, x_next, y_next;
    cin >> t_next >> x_next >> y_next;
    
    int step = t_next - t_now;
    int gap = abs(x_next - x_now) + abs(y_next - y_now);
    if(step<gap){
      can_travel = false;
      break;
    }
    
    if(step%2 != gap%2){
      can_travel = false;
      break;
    }
  }
  
  if(can_travel) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	////////input///////////
	ll N, M;
	cin >> N >> M;

	std::vector<pair<ll,ll>> v;

	for (int i = 0; i < N; ++i)
	{
		ll a, b;
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	////////compute//////////
	sort(v.begin(), v.end());

	ll count = 0;
	ll money = 0;

	for (int i = 0; i < N; ++i)
	{
		count += v[i].second;
		if (count <= M)
		{
			money += v[i].first * v[i].second;
		}else{
			money += v[i].first * (v[i].second + M - count);
			break;
		}
	}

	

	cout << money << endl;

}

Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
#define df 0

int c(const void* a,const void* b){
  int p=*(int *)a;
  int q=*(int *)b;
  return p-q;
}


int main(){
  int n,ans;
  scanf("%d",&n);
  int d[n],i;
  for(i=0;i<n;i++)
    scanf("%d",&d[i]);
  qsort(d,n,sizeof(int),c);
  ans=d[n/2]-d[n/2-1];
  
  if(n&1)ans=0;
  printf("%d",ans);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 892
#include<stdio.h>
#define MAX 100000

int partition(int A[], int n, int p, int r);

int main() {
	int  i, n, m, A[MAX];
  	scanf("%d", &n) ;
  	for ( i = 0; i < n; i++ ) {
  		scanf("%d", &A[i]) ;
  	}
  	m = partition(A, n, 0, n-1);

  	for ( i = 0; i < n; i++ ) {
    	if ( i != 0 ) printf(" ") ;
    	if ( i == m ) {
    		printf("[%d]", A[i]) ;
    	} else {
    		printf("%d", A[i]) ;
    	}
  }
  printf("\n") ;

  return 0;
}

int partition(int A[], int n, int p, int r) {
  int i, j, cp, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j <= r-1 ; j++ ){ 
    if ( A[j] <= x ) {
      i++;
      cp = A[i]; 
      A[i] = A[j];
      A[j] = cp;
    }
  }
  	cp = A[i+1]; 
  	A[i+1] = A[r]; 
  	A[r] = cp;
  	
  	return i+1;
}


Measured memory_bytes: 2112
def main():
    n = int(input())
    l = list(input())
    R = [0]
    G = [0]
    B = [0]
    Rl = set()
    Gl = set()
    Bl = set()

    for i in range(n):
        if l[i] == "R":
            R.append(R[-1]+1)
            G.append(G[-1])
            B.append(B[-1])
            Rl.add(i+1)
        if l[i] == "G":
            R.append(R[-1])
            G.append(G[-1]+1)
            B.append(B[-1])
            Gl.add(i+1)
        if l[i] == "B":
            R.append(R[-1])
            G.append(G[-1])
            B.append(B[-1]+1)
            Bl.add(i+1)
    ans = 0


    for i in range(1,n-1):
        if l[i] == "R":
            ans += G[i]*(B[-1]-B[i+1])
            ans += B[i]*(G[-1]-G[i+1])
            for j in range(i+1):
                if j+i+1 > n or i-j+1 < 0:
                    break
                else:
                    if j+i+1 in Gl and i-j+1 in Bl:
                        ans -= 1
                    if j+i+1 in Bl and i-j+1 in Gl:
                        ans -= 1
        if l[i] == "G":
            ans += R[i]*(B[-1]-B[i+1])
            ans += B[i]*(R[-1]-R[i+1])
            for j in range(i+1):
                if j+i+1 > n or i-j+1 < 0:
                    break
                else:
                    if j+i+1 in Rl and i-j+1 in Bl:
                        ans -= 1
                    if j+i+1 in Bl and i-j+1 in Rl:
                        ans -= 1
        if l[i] == "B":
            ans += G[i]*(R[-1]-R[i+1])
            ans += R[i]*(G[-1]-G[i+1])
            for j in range(i+1):
                if j+i+1 > n or i-j+1 < 0:
                    break
                else:
                    if j+i+1 in Gl and i-j+1 in Rl:
                        ans -= 1
                    if j+i+1 in Rl and i-j+1 in Gl:
                        ans -= 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 74672
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin >> n >> k;
    if(k==1){
        cout << 0;
        return 0;
    }
    cout << n-k;
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

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

bool isDistinct(vector<long> as)
{
    if (as.size() <= 1)
    {
        return true;
    }
    long pivot = as[0];
    vector<long> larger, smaller;
    for (int i = 1; i < as.size(); i++)
    {
        if (as[i] > pivot)
        {
            larger.push_back(as[i]);
        }
        else if (as[i] < pivot)
        {
            smaller.push_back(as[i]);
        }
        else
        {
            return false;
        }
    }
    return isDistinct(larger) & isDistinct(smaller);
}

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

    vector<long> as(n);

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

    if (isDistinct(as))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 19312
/**
 * @file b.cpp
 * @brief B - Red or Blue
 * @version 0.1
 * 
 * @copyright Copyright (c) 2019
 * 
 */

#include <iostream>
#include <string>
using namespace std;

/**
 * @brief Entry point
 * 
 * @return int 
 */
int main()
{
    int N;
    cin >> N;

    string colors;
    int red = 0;
    int blue = 0;
    cin >> colors;

    for (int i = 0; i < N; ++i)
    {
        ('R' == colors[i]) ? ++red : ++blue;
    }

    cout << (red > blue ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy
N = int(input())
L = numpy.array(list(map(int, input().split())))

m = numpy.inf

while True:
    if numpy.min(L) == m:
        break

    m = numpy.min(L)
    mi = numpy.argmin(L)

    L = L % m
    L[mi] = m
    L = L[L != 0]

print(numpy.sum(L))

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

int main()
{
	stack<int> S;
	string s;
	while (cin >> s)
	{
		//printf("input:%s.", s.c_str());
		if (s == "+")
		{
			//printf("i got +.\n");
			int right = S.top(); S.pop();
			int left = S.top();	S.pop();
			S.push(right + left);
			continue;
		}
		if (s == "-")
		{
			//printf("i got -.\n");
			int right = S.top(); S.pop();
			int left = S.top();	S.pop();
			S.push(left - right);
			continue;
		}
		if (s == "*")
		{
			//printf("i got *.\n");
			int right = S.top(); S.pop();
			int left = S.top();	S.pop();
			S.push(right * left);
			continue;
		}
		//printf("i got number\n");
		S.push(stoi(s));
	}
	printf("%d\n", S.top());
	return 0;

}

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

#すぬけ数候補
# [n, S(n)/n] で覚える
snukePairs = []

for i in range(1, 16):
    top = 1  #上位何桁を1-9の走査範囲とするか
    if i >= 12:
        top = 3
    elif i >= 4:
        top = 2
    p = pow(10, i - top)
    fill9 = p - 1
    top_num = pow(10, max(top, 1)) #たかが1000。全部回す
    check_index = len(snukePairs)
    for j in range(pow(10, top - 1), top_num):
        num = j * p + fill9
        nn = num
        s = 0
        #各桁合計、 S(n) / n 計算
        while nn > 0:
            s += nn % 10
            nn = nn // 10
        val = num / s

        #既存のもののうち、valより小さいものを除外
        idx = len(snukePairs) - 1
        while idx >= 0:
            if snukePairs[idx][1] > val:
                del snukePairs[idx]
            idx -= 1
        snukePairs.append([num, val])

for i in range(0, K):
    print(snukePairs[i][0])



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
// const long double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n,k;
	cin>>n>>k;
	int a[n];
	int b[n];
	int cnt=0;
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<k;i++)
	{
		int p,q;
		cin>>p>>q;
		if(a[p-1]>a[q-1])
		{
			b[q-1]=-1;
		}
		else if(a[p-1]<a[q-1])
		{
			b[p-1]=-1;
		}
		else if(a[p-1]==a[q-1])
		{
			b[p-1]=-1;
			b[q-1]=-1;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(b[i]==0)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;
    vector<pair<int, int>> key;
    rep (i, M) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep (j, b) {
            int c;
            cin >> c;
            --c;
            s |= 1<<c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<N, INF);
    dp[0] = 0;
    rep (s, 1<<N) {
        rep (i, M) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }

    int ans = dp.back();
    if (ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N; cin >> N ;
    
    ll ans = 0 ;
    rep(i, N){
        ll aim = i + 1;
        if(aim % 3 == 0) continue;
        if(aim % 5 == 0) continue;
        ans += aim  ;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <vector>
#include <map>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;

int n, m, a[100005];
priority_queue<int, vector<int>> q;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> a[i], q.push(a[i]);
    while (!q.empty() && m > 0)
    {
        int t = q.top();
        q.pop();
        q.push(t >> 1);
        --m;
    }
    ll s = 0;
    while (!q.empty())
        s += q.top(), q.pop();
    cout << s << endl;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    int p[101] = {}, in, maxv = 0;

    REP(i, n) {
        scanf("%d", &in);
        FOR(i, 1, in + 1) {
            p[i]++;
            if (p[i] >= i) {
                maxv = max(maxv, i);
            }
        }
    }

    OUT(maxv);

    return 0;
}




Measured memory_bytes: 3188
#  --*-coding:utf-8-*--


MOD = 998244353

def main():
    N = int(input())
    S = input()

    r,g,b = 0, 0, 0
    rg, rb, gb = 0, 0, 0
    empty=N

    x = 1
    for c in S:
        if c == 'R':
            if gb > 0:
                x = x*gb%MOD
                gb -= 1
            elif g > 0:
                x = x*g%MOD
                g -= 1
                rg += 1
            elif b > 0:
                x = x*b%MOD
                b -= 1
                rb += 1
            else:
                x = x*empty%MOD
                empty -= 1
                r += 1
        elif c == 'G':
            if rb > 0:
                x = x*rb%MOD
                rb -= 1
            elif r > 0:
                x = x*r%MOD
                r -= 1
                rg += 1
            elif b > 0:
                x = x*b%MOD
                b -= 1
                gb += 1
            else:
                x = x*empty%MOD
                empty -= 1
                g+= 1
        else:
            if rg > 0:
                x = x*rg%MOD
                rg -= 1
            elif r > 0:
                x = x*r%MOD
                r -= 1
                rb += 1
            elif g > 0:
                x = x*g%MOD
                g -= 1
                gb += 1
            else:
                x = x*empty%MOD
                empty -= 1
                b += 1

    print(x)
                

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

const int m[4]={10,50,100,500};
int main(){
    int cost;
    bool f=true;
    int havingMoney[4];
    int a[4];
    while(cin>>cost&&cost!=0){
        if(!f)
            cout<<endl;
        else
            f=false;
        int sumKoka=0;
        int sumMoney=0;
        for(int i = 0; i < 4; i++){
            cin>>havingMoney[i];
            sumKoka+=havingMoney[i];
            sumMoney+=havingMoney[i]*m[i];
        }
        int left=sumMoney-cost;

        for(int i = 3; i >= 0; i--){
            a[i]=left/m[i];
            left-=a[i]*m[i];
        }
        for(int i = 3; i >= 0; i--)
            a[i]=max(havingMoney[i]-a[i],0);
        int num=10;
        for(int i = 0; i < 4; i++){
            if(a[i]!=0)
                cout<<num<<" "<<a[i]<<endl;
            if(i%2==0)
                num*=5;
            else
                num*=2;
        }
    }
    return 0;
}

Measured memory_bytes: 0
def main():
    import sys
    from math import sqrt, hypot
    input = sys.stdin.readline

    def dist(p1, p2):
        return hypot(p1[0]-p2[0], p1[1]-p2[1])

    def CP(x1, y1, r1, x2, y2, r2):
        rr0 = (x2 - x1) ** 2 + (y2 - y1) ** 2
        xd = x2 - x1
        yd = y2 - y1
        rr1 = r1 ** 2
        rr2 = r2 ** 2
        cv = (rr0 + rr1 - rr2)
        if 4 * rr0 * rr1 - cv ** 2 >= 0:
            sv = sqrt(4 * rr0 * rr1 - cv ** 2)
            return (
                (x1 + (cv * xd - sv * yd) / (2. * rr0), y1 + (cv * yd + sv * xd) / (2. * rr0)),
                (x1 + (cv * xd + sv * yd) / (2. * rr0), y1 + (cv * yd - sv * xd) / (2. * rr0)),
            )
        else:
            return (x1, y1), (x2, y2)

    N, K = map(int, input().split())

    if N == 1:
        print(0)
        exit()

    info = []
    for _ in range(N):
        info.append(tuple(map(int, input().split())))

    eps = 10**-8
    ok = 150000.
    ng = -eps
    mid = (ok+ng)/2
    while ok - ng > 10**-7:
        cp_list = []
        flg = 0
        fin = 0
        for i in range(N):
            x1, y1, c1 = info[i]
            p1 = (x1, y1)
            r1 = mid / c1
            for j in range(i+1, N):
                x2, y2, c2 = info[j]
                p2 = (x2, y2)
                r2 = mid / c2
                pa, pb = CP(x1, y1, r1, x2, y2, r2)
                cp_list.append(pa)
                cp_list.append(pb)

        flg = 0
        for p0 in cp_list:
            tmp = 0
            for x, y, c in info:
                p = (x, y)
                r = mid / c
                if dist(p0, p) < r + eps:
                    tmp += 1
            if tmp >= K:
                flg = 1
                break

        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok+ng)/2
    print(ok)


if __name__ == '__main__':
    main()


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, t;
    cin >> n >> t;
    int ans = INF;
    for(int i = 1; i <= n; i++){
        int c, f;
        cin >> c >> f;
        if(f > t){
            continue;
        }
        ans = min(ans, c);
    }
    if(ans == INF){
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Data.Char
import Data.List

check xs = cond1 && cond2 && cond3
    where
        cond1 = head xs == 'A'
        cond2 = (length $ filter (=='C') $ init $ drop 2 xs) == 1
        cond3 = and $ map isLower $ delete 'C' $ delete 'A' xs

main = do
    xs <- getLine
    putStrLn $
        if check xs
            then "AC"
            else "WA"

Measured memory_bytes: 380
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans;
int main()
{
	scanf("%d",&n);if (n<4) {printf("1\n");return 0;}
	for (int i=2;i<n;++i)
	for (int s=i;;){
		s*=i;if (s>n) break;
		if (s>ans) ans=s;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Y; cin >> N >>Y;
  for(int x = 0; x <= N; x++){
    for(int y = 0; y <= N - x; y++){
      int z = N -x -y;
      if(10000*x +5000*y+1000*z == Y){
        printf("%d %d %d\n",x,y,z);
        return 0;
      }
    }
  }
  printf("-1 -1 -1");
}

Measured memory_bytes: 3692