akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N, K;
int card[10];
bool used[10];
set<int> s;

int keta(int n) {
	int tmp = 1;
	while (n != 0)
	{
		n /= 10;
		tmp *= 10;
	}
	return tmp;
}

void solve(int m, int l) {
	if (m == K) {
		s.insert(l);

		return;
	}

	for (int i = 0; i < N; i++) {
		if (used[i] == false) {
			used[i] = true;
			solve(m + 1, l*keta(card[i]) + card[i]);
			used[i] = false;
		}
	}
}

int main() {

	while (cin >> N >> K, N)
	{
		s.clear();

		for (int i = 0; i < N; i++) {
			cin >> card[i];
			used[i] = false;
		}

		for (int i = 0; i < N; i++) {
			used[i] = true;
			solve( 1, card[i]);
			used[i] = false;
		}


		cout << s.size() << endl;
	}


	return 0;
}




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

int main(void){
  double x;

  while(cin>>x, x!=-1){
    int dec = x;
    double flo = x - dec;

    string decStr = "";
    while(dec != 0){
      if(dec % 2 == 0){
        decStr = '0' + decStr;
      }
      else{
        decStr = '1' + decStr;
      }

      dec /= 2;
    }

    string floStr = "";
    int cnt = 0;

    while(cnt < 4 && flo != 0){
      flo *= 2;
      if(flo >= 1){
        floStr += '1';
        flo -= 1;
      }
      else{
        floStr += '0';
      }
      cnt++;
    }

    if(flo != 0 || decStr.length() > 8){
      cout<<"NA\n";
    }
    else{
      while(decStr.length() != 8) decStr = '0' + decStr;
      while(floStr.length() != 4) floStr += '0';
      cout<<decStr<<"."<<floStr<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100

int main(){
  int N;
  cin>>N;
  vector<vector<pair<string,int>>> S(N);
  S.at(0).push_back(make_pair("a",1));
  for(int i=1;i<N;i++){
    for(auto T :S.at(i-1)){
      for(int j=0;j<T.second+1;j++){
        string TT=T.first;
        TT.push_back((char)('a'+j));
        S.at(i).push_back(make_pair(TT,max(T.second,j+1)));
      }
    }
  }
  sort(S.at(N-1).begin(),S.at(N-1).end());
  int n=S.at(N-1).size();
  for(int i=0;i<n;i++){
    cout<<S.at(N-1).at(i).first<<endl;
  }
}


Measured memory_bytes: 10736
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int ngcd(vector<int> a) {
    int res;
    res = a[0];
    for (int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
int main() {
	int n, x;cin >> n >> x;
    vector<int> v(n),d(n);v.push_back(x);
    rep(i, n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    rep(i, n) d[i] = v[i + 1] - v[i];
    cout << ngcd(d) << endl;
}

Measured memory_bytes: 1408
n=int(input())
a=list(map(int,input().split()))
ans=1;before=a[0];mode=0
for i,v in enumerate(a):
    nmode=0
    if before>v:
        nmode=-1
    elif before<v:
        nmode=1
    before=v
    if mode*nmode==-1:
        mode=0
        ans+=1
    elif mode==0:
        mode=nmode
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <cstdlib>
		using namespace std;
int main(){
			int x, t;

			cin >> x >> t;
			if (x - t>0) {
				cout << x - t;
			}
			
			if(x-t<=0){
				cout << "0";
			}
		
	return 0;
	}

Measured memory_bytes: 256
n, c, k = map(int, input().split())

arr = []

for i in range(n):
    arr.append(int(input()))

arr.sort()

cnt = 1

a = arr[0]

bc = 1

for i in range(1, n):

    if arr[i] - a <= k:
        bc += 1

        if bc > c:
            bc = 1
            a = arr[i]
            cnt += 1
    else:
        bc = 1
        a = arr[i]
        cnt += 1

print(cnt)


Measured memory_bytes: 7384
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val warshall_floyd :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 辿り着けなければinf，負閉路を含む経路があればneg_infを返す関数 *)
    (int -> int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let warshall_floyd n es =
    let d = Array.make_matrix n n Weight.inf in
    for v = 0 to n - 1 do
      d.(v).(v) <- Weight.zero
    done;
    es.fold (fun (u, v, c) () ->
      (* c < d.(u).(v) *)
      if 0 < Weight.compare d.(u).(v) c
      then d.(u).(v) <- c) ();
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        for k = 0 to n - 1 do
          let open Weight in
          if 
            (* 経路がない場合は更新しない *)
            0 < Weight.compare inf d.(j).(i)
            && 0 < Weight.compare inf d.(i).(k)
            (* d.(j).(i) + d.(i).(k) < d.(j).(k) *)
            && 0 < Weight.compare d.(j).(k) (d.(j).(i) + d.(i).(k))
          then d.(j).(k) <- d.(j).(i) + d.(i).(k)
        done
      done
    done;
    for i = 0 to n - 1 do
      (* 頂点iを通る負閉路がある *)
      if 0 < Weight.compare Weight.zero d.(i).(i) then
        for j = 0 to n - 1 do
          for k = 0 to n - 1 do
            (* 負閉路を通る経路があれば，最短距離を負の無限大で更新 *)
            let open Weight in
            if 0 < Weight.compare inf d.(j).(i) && 0 < Weight.compare inf d.(i).(k)
            then d.(j).(k) <- Weight.neg_inf
          done
        done
    done;
    fun u v -> try d.(u).(v) with _ -> Weight.inf
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let inf = max_int
  let neg_inf = min_int
  let compare = compare
end)

let select xs f acc =
  let rec select acc trace = function
    | [] -> acc
    | x :: xs -> select (f trace x xs acc) (x :: trace) xs in 
  select acc [] xs

let perm n xs f =
  let rec perm trace n xs acc =
    match n, xs with
    | 0, _ -> f trace acc
    | _, [] -> acc
    | _, _ ->
        select xs (fun xs x ys ->
          perm (x :: trace) (n - 1) @@ List.rev_append xs ys) acc in
  perm [] n xs

let () = Scanf.scanf "%d %d %d\n" @@ fun n m r ->
  let rs = Array.init r @@ fun _ -> Scanf.scanf "%d " pred in
  let abcs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c in
  let d = G.warshall_floyd n { G.fold = fun f -> Array.fold_right (fun ((a, b, c) as e) acc -> f (b, a, c) @@ f e acc) abcs } in
  Printf.printf "%d\n" @@
  perm r (Array.to_list rs) (fun (r :: rs) acc ->
    min acc @@
    snd @@
    List.fold_left (fun (r, a) s -> (s, d r s + a)) (r, 0) rs) max_int


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    string T;
    cin >> T;
    string X = T;
    rep(i, 0, T.size()){
        if (T.at(i) == '?'){
            X.at(i) = 'D';
        }
        else{
            X.at(i) = T.at(i);
        }
    }
    cout << X << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> p(3 * n);
	for (int i = 0; i < p.size(); i++) {
		cin >> p[i];
	}
	sort(p.rbegin(), p.rend());
	long sum = 0;
	for (int i = 1; i < 2 * n; i += 2) {
		sum += p[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N = 310;
int n;
int a[N][N], b[N][N];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j) scanf("%d", &a[i][j]), b[i][j] = a[i][j];
	for(int k = 1; k <= n; ++k)
		for(int i = 1; i <= n; ++i) if(k != i)
			for(int j = 1; j <= n; ++j) if(k != i && i != j && k != j)
			{
				if(a[i][j] > a[i][k] + a[k][j]) 
				{
					puts("-1");
					return 0;
				}
				if(a[i][j] == a[i][k] + a[k][j]) b[i][j] = b[j][i] = 0;
			}
	long long ans = 0;			
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j) ans += b[i][j];
	cout << ans / 2;	
	return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, std::vector<long long> d) {
    long long ans = 0;
    rep (i, N) {
        loop (j, i+1, N) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> d(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

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

int main(){
  string s,t;
  cin >> s >> t;
  int ans =0;
  rep(i,s.size()){
    if(s[i] != t[i])
      ans++;
  }
  cout << ans;

}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 200005, MOD = 1e9 + 7;
int n, m, X, Y;
vector<int> vec[MAXN];
LL fac[MAXN], inv[MAXN];
LL modpow(LL a, int b) {
	LL res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = res * a % MOD;
		a = a * a % MOD;
	}
	return res;
}

int main() {
	scanf("%d%d%d", &n, &X, &Y);
	for (int i = fac[0] = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
	inv[n] = modpow(fac[n], MOD - 2);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % MOD;
	int mn = 1e9, sec = 1e9;
	for (int i = 1; i <= n; i++) {
		int c, w; scanf("%d%d", &c, &w);
		vec[c].push_back(w);
		chkmax(m, c);
		if (w < mn) sec = mn, mn = w;
		else if (w < sec) sec = w;
	}
	int all = 0; LL ans = 1;
	for (int i = 1; i <= m; i++) if (!vec[i].empty()) {
		int p = 0, tmn = 1e9;
		for (int j : vec[i]) chkmin(tmn, j);
		int pmn = mn == tmn ? sec : mn;
		if (pmn + tmn > Y) continue;
		for (int j : vec[i])
			if (pmn + j <= Y || tmn + j <= X) ++p;
		ans = ans * inv[p] % MOD, all += p;
	}
	printf("%lld\n", ans * fac[all] % MOD);
	return 0;
}

Measured memory_bytes: 12416
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n, 0);
  for(int i = 0; i < k; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int t;
      cin >> t;
      t--;
      a[t] = 1;
    }
  }
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] == 0){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

typedef long long ll;

int main(){
    //入力部
    int N,M;
    cin>>N>>M;
    vector<int> X(M);
    for(int i=0;i<M;i++){
        cin>>X.at(i);
    }
    sort(X.begin(),X.end());
    //差のvectorを作る。
    vector<int> sa(M-1);
    for(int i=0;i<M-1;i++){
        sa.at(i)=X.at(i+1)-X.at(i);
    }
    sort(sa.begin(),sa.end());
    reverse(sa.begin(),sa.end());
    if(N<M){
    int cnt=0;
    for(int i=0;i<N-1;i++){
        cnt+=sa.at(i);
    }
    int rng=0;
    rng=X.at(M-1)-X.at(0);
    cout<<rng-cnt<<endl;
    }
    else{
        cout<<0<<endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++)cin >> a[i][j];
    }
    int ans=1e9;
    int tmp;
    int flag;
    int T[m];
    for(int i=0;i<(1 << n);i++){
        flag=0;
        tmp=0;
        memset(T,0,sizeof(T));
        for(int j=0;j<n;j++){
            if(i & (1<<j)){
                for(int k=0;k<m;k++)T[k]+=a[j][k];
                tmp+=c[j];
            }
        }
            for(int k=0;k<m;k++)if(T[k]<x)flag++;
            if(flag==0)ans=min(ans,tmp);
        }
    if(ans==1e9)cout << -1 << endl;
    else cout << ans << endl;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;

  void init() {
    scanf("%lld", &N);
  }

  void solve() {
    ll ans = 0;
    rep1c(i, N) if(i%3!=0 && i%5!=0) ans+=i;
    printf("%lld\n", ans);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int a,b,k;
	cin >> a >> b >> k;
	bool bb=0;
	for(int i=a; i<=b; i++){
		if(i<a+k || i>b-k) bb=1;
		if(bb) cout << i << endl;
		bb=0;
	}
/////////////////////////////////////////////
}


Measured memory_bytes: 384
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n; scan(n);
    int[] v = reads();
    v.sort();
    double x = v[0];
    foreach (i; v[1..$])
        x = (x + i) / 2.0;
    writefln("%.10f", x);
}


Measured memory_bytes: 256
import           Control.Applicative
import           Data.Functor

main :: IO ()
main = do
  [h,w] <- fmap read . words <$> getLine
  if (h,w) == (0,0)
    then pure ()
    else printChessboard h w >> main

printChessboard :: Int -> Int -> IO ()
printChessboard h w = putStrLn chessboard
  where
    chessboard :: [Char]
    chessboard = unlines $ chunksOf w $ do
      i <- [1..h]
      j <- [1..w]
      pure $ if even (i+j)
             then '#'
             else '.'

chunksOf :: Int -> [a] -> [[a]]
chunksOf n l
  | n >= length l = [l]
  | otherwise = take n l : chunksOf n (drop n l)



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

int parent (int);
int left (int);
int right (int);

int main(void){
    int K,i,M[MAX+1];
    scanf("%d",&K);
    for(i=1;i<=K;i++)
        scanf("%d",&M[i]);
    for(i=1;i<=K;i++){
        printf("node %d: key = %d, ",i,M[i]);
        if(parent(i) >= 1)
            printf("parent key = %d, ",M[parent(i)]);
        if(left(i) <= K)
            printf("left key = %d, ",M[left(i)]);
        if(right(i) <= K)
            printf("right key = %d, ",M[right(i)]);
        puts("");
    }
    return 0;
}

int parent (int i){ return i/2; }

int left(int i){ return 2*i; }

int right(int i){ return 2*i+1; }


Measured memory_bytes: 2088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//----------------------------------------------------------------------------
long *C;
//----------------------------------------------------------------------------
void CountingSort(long *A, long *B,  long n, long k)
{
    long i;

    /* C[i] ??? i ???????????°????¨?????????? */
    for (i = 0; i<n; i++)
        C[A[i]]++;
    /* C[i] ??? i ??\????????°???????????°????¨??????????*/
    for (i = 1; i<=k; i++)
        C[i] += C[i-1];
    for (i=n-1; 0<=i; i--){
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
    }
}
//----------------------------------------------------------------------------
/*
7
2 5 1 3 2 3 0
*/
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long i,n; long *A,*B,max;

    fscanf(file, "%ld", &n);
    A = malloc(succ(n)*sizeof(long));
    B = malloc(succ(n)*sizeof(long));
    for (i=max=0; i<n; i++){
        fscanf(file, "%ld", &A[i]);
        if (max<A[i])
            max=A[i];
    }
    C = malloc(succ(max)*sizeof(long));
    memset(C, 0, sizeof(long)*succ(max));
    CountingSort(A, B, n, max);
    for (i=0; i<n; i++){
        if (i) printf(" ");
        printf("%ld", B[i]);
    }
    printf("\n");
    free(A);
    free(B);
    free(C);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

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

int main()
{
    int n, m, i, j, a, w;
    int* adj[10000];
    int* dist[10000];
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d", &i, &m);
        adj[i] = new int [m + 1];
        dist[i] = new int [m + 1];
        for(j = 0; j < m; j++){
            scanf("%d %d", &a, &w);
            adj[i][j] = a;
            dist[i][j] = w;
        }
        adj[i][m] = -1;
        dist[i][m] = -1;
    }
    int *d, *prev, *Q;
    d = new int [n];
    prev = new int [n];
    Q = new int [n];
    for(i = 0; i < n; i++){ d[i] = 200000; prev[i] = -1; Q[i] = i; }
    int rest = n;

    int u, v, min;
    d[0] = 0;
    while(rest > 0){
        min = 200000;
        for(i = 0; i < n; i++){
            if(min > d[i] && Q[i] >= 0){ min = d[i]; u = i; }
        }
        Q[u] = -1;
        rest--;

        for(j = 0; adj[u][j] >= 0; j++){
            v = adj[u][j];
            if(d[v] > d[u] + dist[u][j]){
                d[v] = d[u] + dist[u][j];
                prev[v] = u;
            }
        }
    };
    for(i = 0; i < n; i++){ printf("%d %d\n", i, d[i]); }
    for(i = 0; i < n; i++){
        delete adj[i]; delete dist[i]; }
    delete d;
    delete prev;
    delete Q;
 
    return 0;
}

Measured memory_bytes: 5096
import std;

void main() {
    auto K = readln.split[0].to!int;
    auto AB = readln.split.to!(int[]);
    auto A = AB[0], B = AB[1];
    
    foreach (i; A .. B+1) {
        if (i % K == 0) { writeln("OK"); return; }
    }
    
    writeln("NG");
}


Measured memory_bytes: 3660
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in a:
    if i%2 ==1:
        cnt += 1
    elif i%2 == 0 and i%15 == 0:
        cnt += 1
    elif i%2 == 0 and i%5 == 0:
        cnt += 1
    elif i%2 == 0 and i%3 == 0:
        cnt += 1
if cnt == n:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
import java.util.Scanner;
import java.lang.Math;

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i=0;i<n;i++) 
		{
			a[i] = in.nextInt();
			b[i] = in.nextInt();
			c[i] = in.nextInt();
		}
		int[][] dp = new int[n][3];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<3;j++)
			{
				dp[i][j]=0;
			}
		}
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		for(int i=1;i<n;i++)
		{
			dp[i][0] = a[i] + Math.max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = b[i] + Math.max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = c[i] + Math.max(dp[i-1][1], dp[i-1][0]);
		}
		int ans = 0;
		for(int i=0;i<3;i++) ans = Math.max(ans, dp[n-1][i]);
		System.out.print(ans);
	}
}


Measured memory_bytes: 94168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 char c;
	 cin>>c;
	 if(c>='a' && c<='z')
	 cout<<'a'<<'\n';
	 else
	 cout<<'A'<<'\n';
	 return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = [int(i) for i in input().split()]

right = 0
answer = 0
now = 0

for left in range(N):
    while right < N and now + A[right] == now ^ A[right]:
        now += A[right]
        right += 1

    answer += right - left

    if right == left:
        right += 1
    else:
        now -= A[left]


print(answer)

Measured memory_bytes: 23560
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_N = 100010;
int N;
int h[3][MAX_N];
int dp[3][MAX_N];

int main()
{
    cin >> N;
    REP(i, N) cin >> h[0][i] >> h[1][i] >> h[2][i];

    REP(action, 3) REP(day, MAX_N) dp[action][day] = 0;
    REP(action, 3) dp[action][0] = h[action][0];
    REP(day, N)
    {
        if (day == 0) continue;
        REP(action, 3)
        {
            REP(prevAction, 3)
            {
                if (action != prevAction)
                {
                    updateMax(dp[action][day], h[action][day] + dp[prevAction][day - 1]);
                }
            }
        }
    }
    int ans = 0;
    REP(action, 3) updateMax(ans, dp[action][N - 1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

bool isEvenString(string& s) {
  if(s.size() % 2 == 1) return false;

  for (int i = 0; i < s.size()/2; i++) {
    if(s[i] != s[(s.size()/2)+i]) return false;
  }

  return true;
  
}

int main(int argc, char const *argv[])
{
  string s;
  cin >> s;

  int deleteCnt = s.size() - 1;
  for (int i = deleteCnt; i > 1 ; i--){
    string sub = s.substr(0, i);
    // cout << "debug : " << sub << endl;
    if(isEvenString(sub)) {
      cout << sub.size() << endl;
      break;
    } 
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    X = sorted(in_nl())

    A, B, C = X[0], X[1], X[2]

    t = (C - A) + (C - B)
    if t % 2 == 0:
        ans = t // 2
    else:
        C += 1
        A += 1
        ans = ((C - A) + (C - B)) // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>V;
  for(int i=1;i<=9;i++){
    if(n%i==0) V.push_back(n/i);
  }
  int l=V.size();
  int ct=0;
  for(int i=0;i<l;i++){
    //cout<<V[i]<<endl;
    if(V[i]<=9 && V[i]>=1) ct++;
  }
  if(ct>=1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i;
    int num;
    int add;
    char number[1001];
    while(1){
        add=0;
        scanf("%s",number);
        if(number[0]=='0'){
            break;
        }
        for(i=0;number[i]!='\0';i++){
            num=number[i]-'0';
            add+=num;
            number[i]='0';
        }
        printf("%d\n",add);

        
    }
    return 0;
}

Measured memory_bytes: 536
n,a,b=map(int,input().split())
m=10**9+7
def com(n,k,m):
  p,q=1,1
  for i in range(n-k+1,n+1):
    p*=i
    p%=m
  for i in range(1,k+1):
    q*=i
    q%=m
  return p*pow(q,m-2,m)%m
ca,cb=com(n,a,m),com(n,b,m)
ans=(pow(2,n,m)-1-ca-cb)%m
print(ans)

Measured memory_bytes: 38640
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }

ll A[200002],B[200002];

// ll gcd(ll a, ll b){
//     if (a%b==0) return b;
//     else if (b%a==0) return a;
//     else if (a > b) return gcd(a%b, b);
//     else return gcd(a, b%a);
// }

int main(){
    int A,B;
    cin >> A >> B;
    if (A<= 5) cout << 0 << endl;
    else if (A >= 13) cout << B << endl;
    else cout << B/2 << endl;
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <queue>

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

int x, y;

int main() {
  cin >> x >> y;
if( x > 8 || y > 8) {
cout << ":(" << endl;
} else {
cout << "Yay!" << endl;
}}


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

int main() {
  ll N, Z, W; cin >> N >> Z >> W;
  vector<ll> a(N);
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  reverse(a.begin(), a.end());
  if(N == 1) {
    cout << abs(a[0] - W) << endl;
  } else {
    long long ans = max(abs(a[0] - W), abs(a[0] - a[1]));
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

getSum :: [Int] -> Int -> Int -> Int
getSum [] a b = 0
getSum (x : xs) a b = k + getSum xs a b
  where
    s = sum (map digitToInt (show x))
    k = if s >= a && s <= b then x else 0

main = do
  [n, a, b] <- getIntList
  print $ getSum [1 .. n] a b


Measured memory_bytes: 1404
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}

		int[] b = new int[n + 1];

		for (int i = n; i >= 1; i--) {
			int sum = 0;
			for (int j = i * 2; j <= n; j += i) {
				sum = (sum + b[j]) % 2;
			}
			if (a[i] % 2 == 0) {
				if (sum % 2 == 1) b[i] = 1;
			} else {
				if (sum % 2 == 0) b[i] = 1;
			}
		}

		List<Integer> answer = new ArrayList<>();
		for (int i = 1; i <= n; i++) {
			if (b[i] % 2 == 1) {
				answer.add(i);
			}
		}
		System.out.println(answer.size());
		if (answer.size() == 0) return;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < answer.size(); i++) {
			sb.append(answer.get(i));
			sb.append(" ");
		}

		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 90612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final String S = sc.next();

        for (int i = 0; i < S.length(); i++) {
            if (i % 2 == 0) System.out.print(S.charAt(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 28976
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back


#define L_B lower_bound
#define U_B upper_bound

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf (1000*1000*1000+5)
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	string str;
	cin>>str;
	ll x=SZ(str);
	string ans(x,'x');
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	int n,m,k;
	cin>>n>>m>>k;

	vector<ll> A(n);
	Cin(A);

	vector<ll> B(m);
	Cin(B);

	vector<ll> PA(n+1), PB(m+1);
	partial_sum(begin(A), end(A), PA.begin()+1);
	partial_sum(begin(B), end(B), PB.begin()+1);

	int mx = 0;
	FOR(i,0,PA.size()) {
		if (PA[i] > k) break;
		ll tar = k-PA[i];
		auto it = upper_bound(begin(PB), end(PB), tar);
		mx = max(mx, i + int(it - PB.begin() - 1));
	}
	cout<<mx;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 9532
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int K = sc.nextInt();


		long ans = 0;

		int m = 0;

		for(int i=1;i<=N;i++) {

			if(i%K==0) m++;

		}

		ans +=(long) Math.pow(m, 3);

		if(K%2==0) {

			int mm = 0;


			for(int i=1;i<=N;i++) {

				if(i%K==K/2) mm++;

			}



			ans += (long)Math.pow(mm, 3);
		}

		System.out.println(ans);

	}



}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define deb1(x) cout << #x << ": " << x << endl
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define prec(n) fixed << setprecision(n)
#define all(a) a.begin(), a.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define pii pair<int, int>
#define vii vector<int>
#define ld long double
#define int long long
#define MOD LLONG_MAX
#define mp make_pair
#define pb push_back
#define endl "\n";
inline void get(vector<int> &arr, int n)
{
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        arr.push_back(a);
    }
}
inline void print(vector<int> &arr, int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
/*----------------------------------TEMPLATE------------------------------------*/
/*struct UnionFind
{
    vector<int> parent;
    vector<int> size;
    UnionFind(int n)
    {
        parent = vector<int>(n,-1);
        size = vector<int>(n,1));
    }
};*/
const int mx = 2 * (1e5) + 5;
vector<int> parent(mx, -1);
vector<int> group(mx,1);
void make_set(int n)
{
    parent[n] = n;
}
int find_set(int n)
{
    if (parent[n] == n)
        return (n);
    return(parent[n] = find_set(parent[n]));
}
void union_set(int a,int b)
{
    int pa = find_set(a);
    int pb = find_set(b);
    if(pa==pb) return;
    if(group[pa]<group[pb]) swap(pa,pb);
    parent[pb] = pa;
    group[pa]+=group[pb];

}
int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    fast;
    /*----------------------------PEEPEEPOOPOO-------------------------------------*/
    int n,m;
    cin >> n >> m;
    rep(i,0,m)
    {
        int a,b;
        cin >> a >> b;
        if(parent[a]==-1) make_set(a);
        if(parent[b]==-1) make_set(b);
        union_set(a,b);
    }
    int ans = 0;
    rep(i,0,n+1) ans = max(ans,group[i]);
    cout << ans << endl;
    return 0;
}
/*--------------------------------PEEPEEPOOPOO-------------------------------------*/

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

using ll = long long;

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N)); cin >> A;
    vector<vector<int>> B(A);

    for (int i = 0; i < N; i++) {
        if (A[i][i] != 0) {
            cout << -1 << endl; return false;
        }
    }
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            if (A[i][j] != A[j][i]) {
                cout << -1 << endl; return false;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            bool necessary = true;
            for (int k = 0; k < N; k++) {
                if (i == k || j ==k) continue;
                if ((ll)A[i][k] + A[k][j] < A[i][j]) {
                    cout << -1 << endl;
                    return false;
                } else if ((ll)A[i][k] + A[k][j] == A[i][j]) {
                    necessary = false;
                }
            }
            if (necessary) ans += A[i][j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int h = scan.nextInt();
        int n = scan.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++){
            int a = scan.nextInt();
            sum += a;
        }
        scan.close();

        if(sum >= h){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 50172
# F - I hate Matrix Construction

n = int(input())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
u = list(map(int, input().split()))
v = list(map(int, input().split()))
assert len(s) == len(t) == n
assert len(u) == len(v) == n

nbits = 64
AND = 0
OR  = 1

# conflict check
for i in range(n):
    for j in range(n):
        if (s[i] == AND and t[j] == OR  and  u[i] & ~v[j]) or \
           (s[i] == OR  and t[j] == AND and ~u[i] &  v[j]):
            print(-1)
            exit()

# 初期配列
A = [[u[i]] * n for i in range(n)]
for i in range(n):
    for j in range(n):
        if t[j] == AND:
            A[i][j] |= v[j]  # v[j]で1のビットは1
        else:
            A[i][j] &= v[j]  # v[j]で0のビットは0

# 1であるビット数を数える
ucount = [[0] * nbits for i in range(n)]
vcount = [[0] * nbits for j in range(n)]
for i in range(n):
    for j in range(n):
        for k in range(nbits):
            if A[i][j] & (1 << k):
                ucount[i][k] += 1
                vcount[j][k] += 1

def must_set(s, u, ucount, i, k):
    return s[i] == OR  and u[i] & (1 << k) and ucount[i][k] == 0
def must_clear(s, u, ucount, i, k):
    return s[i] == AND and u[i] & (1 << k) == 0 and ucount[i][k] == n

def find_and_set(t, v, vcount, k):
    "いずれかの列の第kビットを1にする"
    for j in range(n):
        if (t[j] == OR  and v[j] & (1 << k)) or \
           (t[j] == AND and v[j] & (1 << k) == 0 and vcount[j][k] < n - 1):
            return j
    raise Exception

def find_and_clear(t, v, vcount, k):
    "いずれかの列の第kビットを0にする"
    for j in range(n):
        if (t[j] == AND and v[j] & (1 << k) == 0) or \
           (t[j] == OR  and v[j] & (1 << k) and vcount[j][k] > 1):
            return j
    raise Exception

# 仕様通りでない箇所を修正
try:
    for i in range(n):
        for k in range(nbits):
            if must_set(s, u, ucount, i, k):
                # いずれかの列の第kビットを1にする
                j = find_and_set(t, v, vcount, k)
                A[i][j] |= 1 << k
                ucount[i][k] += 1
                vcount[j][k] += 1
            elif must_clear(s, u, ucount, i, k):
                # いずれかの列の第kビットを0にする
                j = find_and_clear(t, v, vcount, k)
                A[i][j] &= ~(1 << k)
                ucount[i][k] -= 1
                vcount[j][k] -= 1
    for j in range(n):
        for k in range(nbits):
            if must_set(t, v, vcount, j, k):
                i = find_and_set(s, u, ucount, k)
                A[i][j] |= 1 << k
                ucount[i][k] += 1
                vcount[j][k] += 1
            elif must_clear(t, v, vcount, j, k):
                i = find_and_clear(s, u, ucount, k)
                A[i][j] &= ~(1 << k)
                ucount[i][k] -= 1
                vcount[j][k] -= 1
except:
    print(-1)
    exit()

for i in range(n):
    print(' '.join(map(str, A[i])))


Measured memory_bytes: 93568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[11][2][2][2][2];
ll solve(vector<int> &nm, int s, int e, int a, int b, int c, int small){
    if(s > e){
        if(a > 0 && b > 0 && c > 0)
        return 1;
        return 0;
    }
    if(dp[s][a][b][c][small] != -1)
        return dp[s][a][b][c][small];
    ll so = 0;
    if(small == 1){
        so += solve(nm, s + 1, e, 1, b, c, small);
        so += solve(nm, s + 1, e, a, 1, c, small);
        so += solve(nm, s + 1, e, a, b, 1, small);
        return dp[s][a][b][c][small] = so;
    }
    if(3 < nm[s])
     so += solve(nm, s + 1, e, 1, b, c, 1);
    if(5 < nm[s])
     so += solve(nm, s + 1, e, a, 1, c, 1);
    if(7 < nm[s])
     so += solve(nm, s + 1, e, a, b, 1, 1);
    if(3 == nm[s])
     so += solve(nm, s + 1, e, 1, b, c, small);
    if(5 == nm[s])
     so += solve(nm, s + 1, e, a, 1, c, small);
    if(7 == nm[s])
     so += solve(nm, s + 1, e, a, b, 1, small);
    return dp[s][a][b][c][small] = so;
}
int main() {
    ll n;
    cin >> n;
    ll sz = 0;
    ll num = n;
    if(n < 357){
        cout << 0;
        return 0;
    }
    vector<int> nm;
    while(num > 0){
        nm.push_back(num % 10);
        num /= 10;
        sz++;
    }
    ll c = 0;
    reverse(nm.begin(), nm.end());
    for(int i = 3; i <= sz; i++){
    memset(dp, -1, sizeof(dp));
    int sm = 0;
    if(i < sz)
    sm = 1;
    c += solve(nm, 0, i - 1, 0, 0, 0, sm);
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int N, K;
        cin >> N;

        int n = N / 4;
        for (int i = 0; i < n + 1; i++)
        {
                if ((N - i * 4) % 7 == 0)
                {
                        cout << "Yes" << endl;
                        return 0;
                }
        }

        cout << "No" << endl;

        return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v[27];
    rep(i, n) {
        string s;
        cin >> s;
        for (char c = 'a'; c <= 'z'; c++) {
            int cnt = count(s.begin(), s.end(), c);
            v[c - 'a'].push_back(cnt);
        }
    }

    rep(i, 26) {
        sort(v[i].begin(), v[i].end());
        if (v[i][0] != 0) {
            char c = 'a' + i;
            rep(j, v[i][0]) cout << c;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3616