akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
int main()
{
    int i = 0, x = 0, a = 1, b = 0, j = 0, y = 0, n = 0;
    cin >> x;
    for(i = x; i >= 1; i--)
    {
        for(j = 2; j <= i; j++)
        {
            n = i;

            while(n > 1)
            {
                if(n % j != 0)
                {
                    break;
                }
                n /= j;
                y++;
            }

            if(n == 1 && y != 1)
            {
                a = i;
                break;
            }
            y = 0;
        }
        if(a == i)
        {
            break;
        }
    }
    cout << a;

return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;

    int a = 1;
    while (a * 2 <= n) {
        a *= 2;
    }

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll w,a,b;
    cin>>w>>a>>b;
    if(a>b) swap(a,b);
    cout<<max(0ll,b-a-w)<<endl;
}

 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int K;
int D[5000];
int Q;
int N;
int X;
int M;
long long a[5000];
long long s;
int main(){
  int e98WHCEY;
  rd(K);
  rd(Q);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(K);Lj4PdHRW++){
      rd(D[Lj4PdHRW]);
    }
  }
  for(e98WHCEY=(0);e98WHCEY<(Q);e98WHCEY++){
    int i;
    rd(N);
    rd(X);
    rd(M);
    for(i=(0);i<(K);i++){
      if(D[i]%M==0){
        a[i] =M;
      }
      else{
        a[i] =D[i] % M;
      }
    }
    {
      int WYIGIcGE;
      long long t_ynMSdg;
      if(K==0){
        t_ynMSdg = 0;
      }
      else{
        t_ynMSdg = a[0];
        for(WYIGIcGE=(1);WYIGIcGE<(K);WYIGIcGE++){
          t_ynMSdg += a[WYIGIcGE];
        }
      }
      {
        int tU__gIr_;
        long long a2conNHc;
        if((N-1)%K==0){
          a2conNHc = 0;
        }
        else{
          a2conNHc = a[0];
          for(tU__gIr_=(1);tU__gIr_<((N-1)%K);tU__gIr_++){
            a2conNHc += a[tU__gIr_];
          }
        }
        s = X % M + (N-1) / K *t_ynMSdg+a2conNHc;
      }
    }
    wt_L(N - 1 - s / M);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// int K, D[5000], Q, N, X, M;
// 
// ll a[5000], s;
// {
//   rd(K,Q,D(K));
//   rep(Q){
//     rd(N,X,M);
//     rep(i,K) a[i] = if[D[i]%M==0, M, D[i] % M];
//     s = X % M + (N-1) / K * sum(a(K)) + sum(a((N-1)%K));
//     wt(N - 1 - s / M);
//   }
// }


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
}; 


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(h); readint(n);
        forr(i,0,n) {
            readll(aa); h -= aa;
        }
        cout << (h<=0 ? "Yes" : "No") << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint fact(mint n) const {
        if(n.x==1) return 1;
        else return n*fact(n-1);
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
int main() {
    int N; cin >> N;
    // 0: dammy, 1: 'A', 2: 'G', 3: 'C', 4: 'T'
    // "AGC, GAC, ACG", "A*GC", "AG*C" を含まない (012, 102, 021 を禁止)
    // dp[i文字][3文字前][2文字前][1文字前]
    mint dp[105][5][5][5]={0};
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                for (int k = 0; k < 5; ++k) {
                    for (int l = 1; l < 5; ++l) {
                        if (i == 1 && j == 2 && l == 3) continue;//AG*C
                        if (i == 1 && k == 2 && l == 3) continue;//A*GC
                        if (j == 1 && k == 2 && l == 3) continue;//AGC
                        if (j == 2 && k == 1 && l == 3) continue;//GAC
                        if (j == 1 && k == 3 && l == 2) continue;//ACG
                        dp[n+1][j][k][l] += dp[n][i][j][k];
                    }
                }
            }
        }
    }
    mint res = 0;
    for (int i = 1; i < 5; ++i)
        for (int j = 1; j < 5; ++j)
            for (int k = 1; k < 5; ++k)
                res += dp[N][i][j][k];
    cout << res.x;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ma=1;
    int maki;
    for(int i=2;i<=n;i++){
        maki=i;
        while(maki*i<=n){
            maki*=i;
            ma=max(ma,maki);
        }
    }
    cout << ma<<endl;
    return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)

    // input
    val N = sc.nextInt
    val Z = sc.nextInt
    val W = sc.nextInt
    val a = for(i <- 1 to N) yield sc.nextInt

    //output
    if (N == 1){
      println(Math.abs(a(0)-W))
    }else{
      println(Math.max(Math.abs(a(N-1)-W), Math.abs(a(N-2)-a(N-1))))
    }
  }
}


Measured memory_bytes: 29740
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

total = sum(Bs)

for i in range(N-1):
    if As[i+1] - As[i] == 1:
        # print(i)
        total += Cs[As[i]-1]
print(total)

Measured memory_bytes: 3064
n=int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card]=1
#print(cards)

for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c +' '+str(n)
        if not key in cards:
            print(key)


Measured memory_bytes: 5600
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = list(input().rstrip())

        S2 = []
        cnt = 1
        for i in range(1, len(S)):
            if S[i] != S[i - 1]:
                S2.append((S[i - 1], cnt))
                cnt = 1
            else:
                cnt += 1
        S2.append((S[-1], cnt))

        if len(S2) == 1:
            print((S2[0][1] * (S2[0][1] + 1)) // 2)
            exit()

        ans = 0
        for i in range(len(S2)):
            ans += (S2[i][1] * (S2[i][1] + 1)) // 2

        for i in range(len(S2) - 1):
            if S2[i][0] == '>' and S2[i + 1][0] == '<':
                continue
            else:
                ans -= min(S2[i][1], S2[i + 1][1])
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 25520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        out.println((n + 1) / 2);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
#include <stdio.h>

int main(void)
{
	int array[5000];
	int n;
	
	scanf("%d", &n);
	while (n != 0){
		int i;
		int max;
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		max = -(100000 * 5000);
		for (i = 0; i < n; i++){
			int j;
			int sum = 0;
			for (j = i; j < n; j++){
				sum += array[j];
				if (max < sum){
					max = sum;
				}
			}
		}
		printf("%d\n", max);
		
		scanf("%d", &n);
	}
	
	return 0;
}

Measured memory_bytes: 612
s = input().rstrip("\n")

mode = 'R'

import re
pattern = "(R+)(L+)"

result = len(s) * ["0"]
index = 0
for r, l in re.findall(pattern, s):
    r_len = len(r)
    l_len = len(l)
    r_len_half,r_len_mod = divmod(r_len, 2)
    l_len_half,l_len_mod = divmod(l_len, 2)
    
    
    r_left = r_len_half + r_len_mod
    r_right = r_len_half
    l_left = l_len_half
    l_right = l_len_half + l_len_mod
    
    result[index + r_len - 1] = str(r_left + l_left)
    result[index + r_len] = str(r_right + l_right)
    index += (r_len + l_len)
    
print(" ".join(result))
    

Measured memory_bytes: 13252
#include<iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include<cstring>
using namespace std;

const int maxn=2e5+5;
int arr[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int ma=0;
	int sum=1;
	for(int i=0;i<n;i++){
		if(arr[i]==sum){
			ma++;
			sum++;
		}
	}
	if(n==1){
		cout<<"0";
		return 0;
	}
	if(ma==0){
		cout<<-1<<endl;
	}else{
		cout<<n-ma<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
N=int(input())
S=input()

left=[0]*N
right=[0]*N
to_change=[0]*N

if S[0]=="E":
    right[0]=1
else:
    left[0]=1

for i in range(1,N):
    if S[i]=="W":
        left[i] = left[i-1]+1
        right[i] = right[i-1]
    if S[i]=="E":
        right[i] = right[i-1]+1
        left[i]= left[i-1]

to_change[0]=right[-1]-right[0]
to_change[-1]=left[-2]

for j in range(1,N-1):
    to_change[j]=(right[-1]-right[j])+(left[j-1])
#print(to_change)
print(min(to_change))

Measured memory_bytes: 29468
X, Y, Z, K = [int(i) for i in input().split()]
ABCList = [sorted([int(i) for i in input().split()], reverse=True) for _ in range(3)]

ansList = []
for i, A in enumerate(ABCList[0]):
    for j, B in enumerate(ABCList[1]):
        for k, C in enumerate(ABCList[2]):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                ansList.append(A + B + C)
            else:
                break

for ans in sorted(ansList, reverse=True)[:K]:
    print(ans)



Measured memory_bytes: 9548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, A, B, C;
  cin >> a >> b >> c;
  A = min(a, b);
  A = min(A, c);
  C = max(a, b);
  C = max(C, c);
  B = a + b + c - A - C;
  cout << A << " " << B << " " << C << endl;
  
}



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

int h,w;
using graph = vector<string>;
int INF = 1e9;
vector<string> maze(h);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int solve(const graph &maze,int i,int j,vector<vector<int>> &dist){
    if(maze[i][j]=='#') return 0;  
    queue<P> q;
    q.push(make_pair(i,j));
    dist[i][j] = 0;
    while(q.size()){
        int y =q.front().first;
        int x =q.front().second;
        q.pop();
        for(int l=0;l<4;l++){
            int ny = y + dy[l];
            int nx = x + dx[l];
            if(ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
            if(maze[ny][nx]=='#' || dist[ny][nx] != INF) continue;
            dist[ny][nx] = dist[y][x] + 1;
            q.push(make_pair(ny,nx));
        }
    }
    return 0;
}

int main(){
    cin >> h >> w;
    maze.assign(h,"");
    rep(i,h) cin >> maze[i];
    int M = 0;
    rep(i,h)rep(j,w){
        vector<vector<int>> dist(h,vector<int>(w,INF));
        solve(maze,i,j,dist);
        rep(k,h)rep(l,w) {
            if(dist[k][l] == INF) continue;
            M = max(M,dist[k][l]);
        }

    }

    cout << M << endl;
    
}

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

int main(void){
    int N, M, ans = 0;
    std::cin >> N;
    std::vector<std::string> S(N);
    for (int i = 0; i < N; ++i){
        std::cin >> S.at(i);
    }
    std::cin >> M;
    std::vector<std::string> T(M);
    for (int i = 0; i < M; ++i){
        std::cin >> T.at(i);
    }

    for (int i = 0; i < N; ++i){
        int tmp = 0;
        for (int j = 0; j < N; ++j){
            if (S.at(i) == S.at(j)) ++tmp;
        }
        for (int j = 0; j < M; ++j){
            if (S.at(i) == T.at(j)) --tmp;
        }
        ans = std::max(ans, tmp);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3528
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)

Measured memory_bytes: 3064
n = int(input())
s = [input() for _ in range(n)]
count = 0
a_count = 0
b_count = 0
ab_count = 0

for ss in s:
    count += ss.count("AB")
    if ss[0] == "B" and ss[-1] == "A":
        ab_count += 1
    elif ss[0] != "B" and ss[-1] == "A":
        a_count += 1
    elif ss[0] == "B" and ss[-1] != "A":
        b_count += 1

tmp_count = min(a_count,b_count)
if ab_count == 0:
    count += tmp_count
else:
    if a_count + b_count > 0:
        count += ab_count + tmp_count
    else:
        count += ab_count - 1
print(count)



Measured memory_bytes: 9780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SS=SZB,*TT=SZB;
    inline char gc(){   if (SS==TT){  TT=(SS=SZB)+fread(SZB,1,GYN,stdin); if (SS==TT) return '\n';  }   return *SS++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace SHENZHEBEI;
const ll N=400010;
ll mark[N],fa[N],n,m,Ji,Ou,Gu;
ll Count(ll x){return x*(x-1)/2;}
ll find(ll x){return x==fa[x]?x:fa[x]=find(fa[x]);}
int main(){
	n=read(),m=read();
	For(i,1,2*n)fa[i]=i;
	for(;m--;){
		ll x=read(),y=read();
		fa[find(x)]=find(y+n);
		fa[find(x+n)]=find(y);
		mark[x]=mark[y]=1;
	}
	For(i,1,n)if (find(i)==i||find(i)==i+n){
		if (find(i)==find(i+n))	++Ji;
		else					++Ou;
	}
	For(i,1,n)if (!mark[i])	++Gu;
	Ou-=Gu;
	writeln(Ji*Ji+Ou*Ji*2+Ou*Ou*2+Gu*(n-Gu)*2+Gu*Gu);
}
/*
1 1
1*1+
1*1+
1*1*2
*/

Measured memory_bytes: 6272
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int A, B, C;
        A = Integer.parseInt (arr[0]);
        B = Integer.parseInt (arr[1]);
        C = Integer.parseInt (arr[2]);
        System.out.println (A < B + C ? B + C - A : 0);
        return;
    }
}

Measured memory_bytes: 32644
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	string a,b;
	cin >> a >> b;
	int n=stoi(a+b);
	for(int x=1;x*x<=n;++x){
		if(x*x==n){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.append(0)
b = {}
c = 0
for i in range(n):
    if a[i] not in b:
        for j in range(1, 10**6//a[i]+1):
            b[a[i]*j] = 1
        if a[i] != a[i+1]:
            c += 1
print(c)


Measured memory_bytes: 101708
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	vi co(26);
	rep(i,s.size())co[s[i]-'a']++;
	bool h=true;
	rep(i,26)if(co[i]%2)h=false;
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
  int n;
  cin>>n;
  ll ans=0;
  vector<int> a(n);
  int mx=-1;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<mx)ans+=mx-a[i];
    mx=max(a[i],mx);
  }
  cout<<ans<<"\n";
}  

  

Measured memory_bytes: 4024
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();

		int[] p = new int[N+1];
		for(int i=1;i<=N;i++) {
			int cnt = 0;
			int pdt = i;
			while(pdt<K) {
				pdt *= 2;
				cnt++;
			}
			p[i] = cnt;
		}
		long sum = 0;
		int max = p[1];
		for(int i=1;i<=N;i++) {
			sum += Math.pow(2, max-p[i]);
		}
		BigDecimal SUM = BigDecimal.valueOf(sum);
		BigDecimal P = BigDecimal.valueOf(Math.pow(2, max)*N);
		BigDecimal ans = SUM.divide(P,10,RoundingMode.HALF_UP);
		System.out.println(ans);
	}
}

Measured memory_bytes: 27708
using System;
using System.Linq;

namespace _4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong[]x = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
            ulong a = x[0];
            ulong b = x[1];
            ulong d = a/b;
            ulong r = a % b;
           decimal f = (decimal)a / (Decimal)b;
            Console.WriteLine(d+ " " + r + " " + (decimal)f);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,a,b;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else if(n==2){
        cin>>a>>b;
        cout<<a+b<<endl;
    }

}



Measured memory_bytes: 384
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

anti_clockwise_dist = A[0] - (A[-1] - K) 

dist = 0 
for i in range(N-1):
    dist = max(dist, A[i+1] - A[i])

dist = max(dist, anti_clockwise_dist)

print(K - dist)

Measured memory_bytes: 72180
#include<stdio.h>
int main(){
  int N,M,ans = 0;
  scanf("%d %d",&N,&M);
  int K[N],A[N][M];
  for(int i = 0;i < N;i++){
    scanf("%d",&K[i]);
    for(int j = 0;j < K[i];j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(int i = 0;i < K[0];i++){
    int cnt = 1;
    for(int j = 1;j < N;j++){
      for(int f = 0;f < K[j];f++){
        if(A[0][i] == A[j][f]){
          cnt++;
        }
      }
    }
    if(cnt == N){
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int H ,W;
	cin>>H>>W;
	while ( H != 0 && W != 0 ){
		for(int i=1; i<=H; i++){
			for(int j=1; j<=W; j++){
				if(i==1 || i==H || j==1 || j==W){
					cout<<'#';
				}else{
					cout<<'.';
				}
				
			}
			cout<<endl;
		}
		cout<<endl;
		cin>>H>>W;
		
	}
	return 0;
}

Measured memory_bytes: 1152
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] a = nextInts();
		Arrays.sort(a);
		int[] b = {0,400,800,1200,1600,2000,2400,2800,3200,5000};
		int idx=0;
		int[] c = new int[b.length];
		int min=0;
		int max=0;
		Arrays.fill(c, 0);
		int i=0;
		while(i<N){
			if(b[idx]<=a[i] && a[i]<b[idx+1]){
				c[idx]++;
				i++;
			}else{
				idx++;
			}
		}
		int all = c[c.length-2];

		for(i=0;i<c.length-2;i++){
			if(c[i]!=0){
				min++;
			}
		}
		max=min+all;
		min=min==0?1:min;
		System.out.println(min+" "+max);


	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X)
{
    if (X <= K * 500)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    long long X;
    scanf("%lld", &X);
    solve(K, X);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  long long n,m,down=0;
  cin>>n>>m;
  if(n>=2){
    if(m>=2){
      down=(n-2)*(m-2);
    }else{
      down=n-2;
    }
  }else{
    if(m>=2){
      down=m-2;
    }else{
      down=1;
    }
  }
  cout<<down<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
#define MAXN 100005
#define NULL -1
typedef struct  {
	int p, l, r;
}Node;

Node T[MAXN];
int n, D[MAXN];

void print(int u)
{
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].p);
	printf("depth = %d, ", D[u]);

	if (T[u].p == NULL)
		printf("root, ");
	else if (T[u].l == NULL)
		printf("leaf, ");
	else
		printf("internal node, ");

	printf("[");
	for (int i = 0, c = T[u].l; c != NULL; i++, c = T[c].r)
	{
		if (i)
			printf(", ");
		printf("%d", c);
	}
	printf("]\n");
}
int rec(int u, int p)
{
	D[u] = p;
	if (T[u].r != NULL)
		rec(T[u].r, p);
	if (T[u].l != NULL)
		rec(T[u].l, p + 1);
}
int main()
{
	int d, v, c, l, r;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		T[i].p = T[i].l = T[i].r = NULL;
	}

	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &v, &d);
		for (int j = 0; j < d; j++)
		{
			scanf("%d", &c);
			if (j == 0)
				T[v].l = c;
			else
				T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (T[i].p == NULL)
			r = i;
	}
	rec(r, 0);
	for (int i = 0; i < n; i++)
		print(i);
	return 0;
}


Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	cin>>n;
	ll ans = 0, cur = 0;
	fo(i, n) {
		int x;
		cin>>x;
		if(!x) ans += cur/2, cur = 0;
		cur += x;
	}
	ans += cur/2;
	cout<<ans<<endl;

	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int m){
	int i, u, v;
	fo(i, m){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k; cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }

  vector<ll> su(n+1);
  su[0] = 0;
  FOR(i, 1, n+1) {
    su[i] = su[i-1] + a[i-1];
  }
  // printv(su);

  vector<ll> su2(n+1);
  su2[0] = 0;
  FOR(i, 1, n+1) {
    su2[i] = su2[i-1] + max(0ll, a[i-1]);
  }
  // printv(su2);

  ll ma = 0;
  ll now = 0;
  FOR(i, 1, n-k+2) {
    now = su2[i-1];
    now += max(0ll, su[i+k-1] - su[i-1]);
    now += su2[n] - su2[i+k-1];
    // cout << now << endl;
    ma = max(ma, now);
  }

  cout << ma << endl;
  
}


Measured memory_bytes: 2560
import numpy as np
import heapq


def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def main():
    s = input()
    K = ii()

    sub = []
    for i in range(len(s)):
        sub.append(s[i:])

    heapq.heapify(sub)
    minsub = heapq.heappop(sub)

    if len(minsub) >= K:
        print(minsub[:K])
        return

    cand = []
    for i in range(1, len(minsub)+1):
        cand.append(minsub[:i])
    K -= len(minsub)
    assert K > 0

    while K > 0:
        minsub_ = heapq.heappop(sub)
        for i in range(1, len(minsub_)+1):
            if not minsub_[:i] in cand:
                cand.append(minsub_[:i])
                K -= 1
                if K == 0:
                    print(minsub_[:i])
                    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 24868
import sys
from collections import Counter
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
MOD = 1000000007

def calc(A):
    CA = Counter(A)
    if max(CA.values()) > 3:
        return 0
    
    pop = [0]*(N+3)
    pop[-1] = 3
    
    res = 1
    for a in A:
        if pop[a-1] <= 0:
            return 0
        res = (res*pop[a-1]) %MOD
        pop[a-1] -= 1
        pop[a] += 1
        
    
    
        
    return res
        

print(calc(A))

Measured memory_bytes: 62684
import sys
sys.setrecursionlimit(10000000)

N = int(open(0).read())
p = [59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1]

mem = [0] * (N+1)
def dp(n):
    global mem
    if n <= 0:
        return 0
    elif mem[n]:
        return mem[n]
    else:
        mem[n] = min([dp(n-x) + 1 for x in p if n - x >= 0])
        return mem[n]
print(dp(N))

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

public class BinarySearch
{
    public static void Main()
    {
        Console.ReadLine();
        var s = new HashSet<int>(Console.ReadLine().Split(' ').Select(int.Parse));
        Console.ReadLine();
        var t = Console.ReadLine().Split(' ').Select(int.Parse);
    
//        "BinarySearch".Measure(() =>
//        {
            var c = t.Count(x => s.Contains(x));
            Console.WriteLine(c);
//        });
    }
}
// Define other methods and classes here

Measured memory_bytes: 18384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<int> x(n), y(n), h(n);

    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
    }

    int maxi = 100;

    rep(poy,maxi+1){
        rep(pox,maxi+1){

            int nece = -1;

            rep(i,n){

                if(h[i] > 0){

                //仮の頂点の高さ
                int tmp = h[i] + abs(poy - y[i]) + abs(pox - x[i]);

                if(nece == -1) nece = tmp;

                else{
                    if(nece != tmp){
                        nece = -2;
                        break;
                    }
                }

                }
                
            }

            if(nece == -2) continue;

            rep(i,n){
                if(h[i] == 0){

                    int mandis = abs(poy - y[i]) + abs(pox - x[i]);
                    if(0 + mandis < nece){
                        nece = -2;
                        break;
                    }

                }
            }
            if(nece == -2) continue;

            cout << pox << " " << poy << " " << nece << endl;

            return 0;

        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(void){
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; i++){
        reverse(divide[i].begin(), divide[i].end());
    }

    bool can = true;
    for(int i = 0; i < S.size();){

        bool can2 = false;
        for(int j = 0; j < 4; j++){
            string d = divide[j];
            if(S.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }

        if(!can2){
            can = false;
            break;
        }

    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
 

    return 0;
}

Measured memory_bytes: 512
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const d = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    
    for(let i in d) {
        for(let j= ~~i + 1; j<N; j++) {
            // console.log((d[i] * d[j]))
            answer += (d[i] * d[j]);
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  bool ans=true;
  for(int i=0;i<a+b+1;++i){
    if(i<a || i>=a+1){
      if(s[i]<'0' || s[i]>'9'){
        ans=false;
      }
    }
    else{
      if(s[i]!='-'){
        ans=false;
      }
    }
    if(!ans) break;
  }
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  for(int i=0;i<n;i++) cin >> m[i];

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

  int sum = 0;
  for(int i=0;i<n;i++) sum += m[i];

  x -= sum;
  int ans = n + x/m[0];

  cout << ans << endl;
}


Measured memory_bytes: 3604
X, K, D = map(int, input().split(" "))
X = abs(X)
 
a = X // D
b = X % D
 
remain_count = K - a
 
if remain_count < 0:
    ans = X - K * D
else:
    if remain_count % 2 == 0:
        ans = b
    else:
        ans = abs(b - D)
    
print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int >;
using P = pair<int,int>;

int main()
{
   int n;cin >>n;
   int m=0,mm=0;
   rep(i,n){
    int a;cin >>a;
    if(a%2==0)m++;
    if(a%4==0)mm++;
   }
   bool flg=false;
   if(m>=n)flg=true;
   if(mm>=n/2)flg=true;
   if(m+mm>=n)flg=true;
   if(flg)puts("Yes");
   else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
long long powmod(long long a,long long po){
	if(po==0)return 1;
	if(po==1)return a;
	long long int p1=powmod(a,po/2ll);
	long long int p2=p1*p1;
	long long p3=powmod(a,po%2ll);
	return ((p2%mod)*(p3%mod))%mod;
}

void solve(){
	ll n;
	cin>>n;
	if(n==1){
		cout<<0;
		return;
	}
	ll ans=1;
	ans=powmod(10,n);
	ll a=powmod(9,n);
	ll b=powmod(9,n);
	ll c=powmod(8,n);
	ans=(ans-a-b+c)%mod;
	ans+=mod;
	ans%=mod;
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3640
H, W = map(int, input().split())
Slist = list()
HWlist =list()
for i in range(0,H):
    Slist.append(str(input()))
    HWlist.append(list(Slist[i]))

Reslist = list()
for h in range(0,H):
    Reslist.append("")

for i in range(0,H):
    for j in range(0,W):
        if HWlist[i][j] != "#":
            count = 0
            if i-1 >= 0:
                if HWlist[i-1][j] == "#":
                    count = count + 1
            if i+1 < H:
                if HWlist[i+1][j] == "#":
                    count = count + 1
            if j-1 >= 0:
                if HWlist[i][j-1] == "#":
                    count = count + 1
            if j+1 < W:
                if HWlist[i][j+1] == "#":
                    count = count + 1
            if i-1 >= 0 and j-1>=0:
                if HWlist[i-1][j-1] == "#":
                    count = count +1
            if i-1 >=0 and j+1<W:
                if HWlist[i-1][j+1] == "#":
                    count = count +1
            if i+1 <H and j-1>=0:
                if HWlist[i+1][j-1] == "#":
                    count = count +1
            if i+1 <H and j+1<W:
                if HWlist[i+1][j+1] == "#":
                    count = count +1
            Reslist[i] = Reslist[i] + str(count)
        else:
            Reslist[i] = Reslist[i] + "#"
for l in range (0,H):
    print(Reslist[l])

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

typedef long long ll;

int main()
{
  int n;
  cin>>n;
  ll A[n+1];
  A[0]=0;
  for(int i=1;i<=n;i++)
    cin>>A[i];
  for(int i=1;i<=n;i++)
    A[i]+=A[i-1];
  ll v[n][n];
  for(int i=0;i<n;i++)
    v[i][i]=0;
  for(int i=1;i<n;i++)
  {
	for(int j=i-1;j>=0;j--)
    {
      ll ans=1e15;
      for(int k=j;k<i;k++)
        ans=min(ans,v[j][k] + v[k+1][i]);
      v[j][i]=ans+ A[i+1]-A[j];
    }
  }
  cout<<v[0][n-1];
  return 0;
}


Measured memory_bytes: 1536