akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	int i = 0;
	for (char c : S) {
		if (i == 0 && c == 'C') ++i;
		if (i == 1 && c == 'F') ++i;
	}
	print((i == 2) ? "Yes" : "No");
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
#define fs  first  
#define sc  second
#define ARR array
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#include <bits/stdc++.h>
using namespace  __gnu_pbds; 
using namespace std;
 
 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
inline void WRITE_CHAR(char c)  {putchar_unlocked(c);} 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  while (!isdigit(ch) && ch!=EOF) minus = (ch == '-'? -1 : minus),ch= (char) getchar_unlocked();
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char *x) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
 
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
inline void WRITE_STRING(string &x) {
  for(char c: x) 
    putchar_unlocked(c);
}
const ll OOl = 1e18 ;
const int N = 1e6+1,OO = 1e9,OOm = 0x3f3f3f3f, MOD = 1e9 + 7;
char s[N],t[N];
int main()
{
  READ_CHAR_ARRAY(s);
  READ_CHAR_ARRAY(t);
  int n = strlen(s),ans=0;
  for(int i=0;i<n;++i) if(s[i]==t[i]) ans++;
  WRITEn(n-ans);
  
  return 0; 
}

Measured memory_bytes: 3972
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
#define BLACK 0
#define WHITE 1
vector<int> G[100010];
struct mint {
    int x;
    mint(int 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    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;
    }
};
mint dp[100010][2];
bool visited[100010][2];
mint dfs(int x, int p, int c) {
    if(visited[x][c]) return dp[x][c];
    visited[x][c] = true;
    mint ret = 1;
    for(auto to: G[x]) {
        if(to == p) continue;
        mint tmp = 0;
        if(c == WHITE) {
            tmp += dfs(to, x, BLACK);
        }
        tmp += dfs(to, x, WHITE);
        ret *= tmp;
    }
    return dp[x][c] = ret;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << (dfs(0, -1, WHITE) + dfs(0, -1, BLACK)).x << endl;

    // rep(i, N) {
    //     cout << i + 1 << ": " << dp[i][WHITE].x << " " << dp[i][BLACK].x << endl;
    // }

    return 0;
}


Measured memory_bytes: 17780
n,k = map(int,input().split())
v = [int(i) for i in input().split()]
jewel = []
ans = 0
for i in range(min(k+1,n+1)):
  for j in range(min(k-i+1,n-i+1)):
    jewel = v[:i] + v[:-(j+1):-1]
    jewel.sort()
    temp = sum(jewel)
    leng = len(jewel)
    for m in range(k-i-j):
      if leng > m and jewel[m] < 0:
        temp += -jewel[m]
    ans = max(ans,temp)
print(ans)

Measured memory_bytes: 3064
N, D = map( int, input().split())
X = [ list( map( int, input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        t = 0
        for k in range(D):
            t += (X[i][k] - X[j][k])**2
        if t == ( int(t**(1/2)))**2:
            ans += 1
print(ans)

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  string s;
  cin >> s;
  int n = s.size(), ans = 0;
  for(int i = 0; i < n; i++){
  	if(i%2 == 0){
    	if(s.at(i) == 'p'){
        	ans--;
        }
    }  
    
    else{
    	if(s.at(i) == 'g'){
        	ans++;
        }
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main( int argc, char *argv[] )
{
int A;
int B;

	// A B を取得
	cin >> A;
	if( A < 0 || A > 23 ) return 0;

	cin >> B;
	if( B < 0 || B > 23 ) return 0;

	// 出力
	cout << ( A + B ) % 24;

	return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int h, n, ans = 0;
    cin >> h >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
    }
    cout << (sum >= h? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 9

def main():
    N = int(input())
    A = [[0]*19 for _ in range(19)]
    power10 = [1]
    for _ in range(9):
        power10.append(power10[-1] * 10)
    for i in range(N):
        s = input()
        a = s.split('.')
        if len(a) > 1:
            s = a[0] + a[1]
            power = power10[9 - len(a[1])]
        else:
            s = a[0]
            power = power10[9]
        x = int(s) * power
        cnt1 = 0
        while x > 0 and x%2 == 0:
            x //= 2
            cnt1 += 1
        cnt2 = 0
        while x > 0 and x%5 == 0:
            x //= 5
            cnt2 += 1
        if cnt1 >= 18 and cnt2 >= 18:
            A[18][18] += 1
        elif cnt1 >= 18:
            A[18][cnt2] += 1
        elif cnt2 >= 18:
            A[cnt1][18] += 1
        else:
            A[cnt1][cnt2] += 1
    
    ans = 0
    for i in range(19):
        for j in range(19):
            for k in range(18 - i,19):
                for l in range(18 - j,19):
                    if i == k and j == l:
                        ans += A[i][j] * (A[k][l] - 1)
                    else:
                        ans += A[i][j] * A[k][l]
    print(ans//2)
if __name__ == '__main__':
    main()

Measured memory_bytes: 89832
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >=0 && x+r <=w && y+r <=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
n = int(input())
a = list(map(int,input().split()))
b = dict()
c = dict()
d = dict()
for i in range(n):
    if a[i] not in b:
        b[a[i]] = 0
    b[a[i]] += 1
b = list(b.items())
for i in range(len(b)):
    c[b[i][0]] = b[i][1] * (b[i][1]-1) // 2
    d[b[i][0]] = (b[i][1]-1) * (b[i][1]-2) // 2
c_sum = sum(list(c.values()))
for i in range(n):
    num = a[i]
    print(c_sum - c[num] + d[num])



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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a;
	cin >> a;
	cout << 48-a << endl;

}


Measured memory_bytes: 256
program main
    implicit double precision (a-h,o-z)
    read(*, *)i, j
    k = ibits(i, 0, 1) * ibits(j, 0, 1)
    if(k == 0)then
        write(*, *) "Even"
    else
        write(*, *) "Odd"
    endif
    stop
end program main

Measured memory_bytes: 256
N=int(input())
b=[]
for i in range(9):
	b.append([0]*9)
for i in range(N):
	c=str(i+1)
	d=int(c[0])
	e=int(c[-1:])
	if d*e==0:
		continue
	b[d-1][e-1]+=1
f=0
for j in range(9):
	f+=b[j][j]**2
for i in range(8):
	for j in range(i+1):
		f+=b[j][i+1]*b[i+1][j]*2
print(f)

Measured memory_bytes: 3064
s = input()
S = list(s[i] for i in range(4))
set_S = list(set(S))

if len(set_S) == 2:
  if S.count(set_S[0]) == 2 and S.count(set_S[1]) == 2:
    print('Yes')
  else:
    print('No')
else:
  print('No')


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

int main()
{
    std::string S;
    std::cin >> S;
    int count_zero = 0, count_one = 0;
    for (int i = 0; i < S.length(); ++i)
    {
        if (S[i] == '0')
        {
            count_zero++;
        }
        else
        {
            count_one++;
        }
    }
    std::cout << std::min(count_zero, count_one) * 2 << std::endl;
    return 0;
}


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    int ans=max(a*10+b+c,max(b*10+a+c,c*10+a+b));
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int n;
vll po2;
ll ans = 0;
int dfs(int now, int prev, const vvi &tr) {
  vi sizes;
  ll su = 0;
  for(int i=0;i<(int)(tr[now].size());++i) {
    int nxt = tr[now][i];
    if(nxt == prev) continue;
    sizes.push_back(dfs(nxt, now, tr));
    su += sizes.back();
  }
  if(n > su + 1) sizes.push_back(n - su - 1);
  ll tmp = po2[n-1];
  for(int i=0;i<(int)(sizes.size());++i) {
    tmp += po2[sizes[i]];
    tmp %= MOD;
  }
  tmp += MOD - ((int)(sizes.size()) - 1);
  tmp %= MOD;
  ans += po2[n] + MOD - tmp;
  ans %= MOD;
  return su + 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> n;
  vvi tr(n);
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  Combination<MOD> comb(500000);
  po2.resize(500000);
  po2[0] = 1;
  for(int i=1;i<500000;++i) {
    po2[i] = po2[i-1] * 2 % MOD;
  }
  ll inv = comb.getinv(2);
  ll invpow = 1;
  for(int i=0;i<n;++i) {
    invpow *= inv;
    invpow %= MOD;
  }
  dfs(0, -1, tr);
  cout << ans * invpow % MOD << endl;
}


Measured memory_bytes: 42624
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    int i=0;
    for(i=0;i<n;i++){
        scanf("%d", &a[n-i-1]);
    }
    for(i=0;i<n;i++){
        if(i==n-1){
            printf("%d\n",a[i]);
            break;
        }
        printf("%d ",a[i]);
    }

    return 0;
}


Measured memory_bytes: 2104
# https://atcoder.jp/contests/abc054/tasks/abc054_b

N, M = map(int, input().split())
A_list = []
for n in range(N):
    a = input()
    A_list.append(a)

B_list = []
for m in range(M):
    b = input()
    B_list.append(b)

diff = N - m

for i in range(diff):
    is_same = False
    for j in range(diff):
        for b in range(M):
            if B_list[b] == A_list[i + b][j: j + M]:
                is_same = True
            else:
                is_same = False
                break

        if is_same:
            print('Yes')
            exit()

    else:
        continue

print('No')


# 5 3
# ..#..
# ..#.#
# .....
# #..#.
# .....
# ...
# ..#
# #.#


Measured memory_bytes: 3064
#include <iostream>

#define N 15

using namespace std;

void Mahou(int);

main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    Mahou(n);
  }
  return 0;
}

void Mahou(int n){
  int d[N][N];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j]=-1;
    }
  }
  int x=n/2, y=n/2+1;
  int count=1;
  d[y][x]=count;
  y++;
  x++;
  count++;
  while(count<=n*n){
    while(1){
      if(y>=0 && y<n){
	if(x>=0 && x<n){
	  if(d[y][x]==-1){
	    break;
	  }else{
	    y++;
	    x--;
	  }
	}else{
	  if(x<0){
	    x=n-1;
	  }else{
	    x=0;
	  }
	}
      }else{
	if(y<0){
	  y=n-1;
	}else{
	  y=0;
	}
      }
    }
    d[y][x]=count++;
    y++;
    x++;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      printf("%4d", d[i][j]);
    }
    cout << endl;
  }
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
  }else if(b==c){
    cout<<a<<endl;
  }else{
    cout<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int a, b;
  cin >> a >> b;
  if(a == 1)
    a = 14;
  if(b == 1)
    b = 14;
  
  if(a > b)
    FINA("Alice");
  else if(a < b)
    FINA("Bob");
  else
    FINA("Draw");

 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < 500000; i++) {
		if (i * 1.08 < N + 1 && i * 1.08 >= N) {
			cout << i << endl; return 0;
		}
	}

		cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 3664
N = int(input())
Numbers = list(input().split())
A = Numbers[::]
for i in range(N):
    for j in range(N - 1, i, -1):
        if int(A[j][1]) < int(A[j - 1][1]):
            A[j], A[j - 1] = A[j - 1], A[j] 
print(' '.join(A))
print('Stable')
B = Numbers[::]
for i in range(N):
    minj = i
    for j in range(i, N):
        if int(B[j][1]) < int(B[minj][1]):
            minj = j
    B[i], B[minj] = B[minj], B[i]
print(' '.join(B))
if A == B:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

#define ll long long
#define maxn 200000

int a[maxn+1], ans[maxn+1], prv[maxn+1];
int vis[maxn+1];
vector<int> adj[maxn+1];
int t[2*maxn];
int n,mx;
map<int,int> m;
set<int> s;

void modify(int p, int value) {
    for (t[p += s.size()] = value; p > 1; p >>= 1) t[p >> 1] = max(t[p], t[p ^ 1]);
}

int query(int l, int r) {
    int res = 0;
    for (l += s.size(), r += s.size(); l < r; l >>= 1, r >>= 1) {
        if (l & 1) res = max(res, t[l++]);
        if (r & 1) res = max(res, t[--r]);
    }
    return res;
}

void dfs(int v) {
    vis[v] = 1;
    mx = query(0, m[a[v]]);
    ans[v] = max(ans[v], mx + 1);
    prv[v] = query(m[a[v]], m[a[v]] + 1);
    modify(m[a[v]], mx + 1);
    for (int u:adj[v]) {
        if (vis[u]) continue;
        ans[u] = ans[v];
        dfs(u);
    }
    modify(m[a[v]], prv[v]);
}

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

    int u, v;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s.insert(a[i]);
    }
    int c = 0;
    for (int i:s) {
        m[i] = c;
        c++;
    }
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < n; i++) t[n + i] = 0;
    memset(t, 0, sizeof(t));
    memset(vis, 0, sizeof(vis));
    ans[1] = 0;
    dfs(1);

    for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 53216
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int func(double v)
{
	if ( (int)(v * 10) % 10 == 0 )
	{
		return (int)v;
	}
	else
	{
		return (int)v + 1;
	}

}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> arr;
	for ( int i = 0; i < n; i++ )
	{
		int dat;
		cin >> dat;
		arr.push_back(dat);
	}

	if ( n == k )
	{
		cout << 1 << endl;
	}
	else
	{
		int lhs = (n - k);
		int rhs = (k - 1);

		if ( lhs % rhs == 0 )
		{
			cout << lhs / rhs + 1 << endl;
		}
		else
		{
			cout << lhs / rhs + 2 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 892
#include<stdio.h>

int main()

{
    int x;
    scanf("%d",&x);
    int happy_point=0;
    int k,l,m;
    k=x/500;
    happy_point=k*1000;
    l=x%500;
    m=l/5;
    happy_point=happy_point+m*5;
    printf("%d\n",happy_point);
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		char[] array = input.toCharArray();
		int count[] = new int[3];
		for(int i = 0; i < array.length; i++){
			count[array[i]-'a']++;
		}

		Arrays.sort(count);

		if(array.length == 1){
			System.out.println("YES");
		}
		else if(array.length == 2){
			if(array[0] == array[1]){
				System.out.println("NO");
			}
			else {
				System.out.println("YES");
			}
		}
		else if(array.length == 3){
			if(count[2] == 2){
				System.out.println("NO");
			}
			else {
				System.out.println("YES");
			}
		}
		else {
			if(array.length % 3 == 0){
				if(count[0] == count[1] && count[1] == count[2]){
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}

			else if(array.length % 3 == 1){
				if(count[0] == count[1] && count[1] + 1 == count[2]){
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}
			else {
				if(count[1] == count[2] && count[0] + 1 == count[1]){
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}
		}

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
// five elements

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rev(i, s, n) for (int i = s; i > n; i = i - 1)
using namespace std;
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define mv vector<ll>
#define vii vector<pair<ll, ll>>
// akane_psycho
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define c1(a) cout << a << endl;
#define c2(a, b) cout << a << " " << b << endl;
#define inf 1e18
#define mod 1000000007
#define ii pair<ll,ll>
#define sw(v)      cout << endl;                                                                \
  for(auto u:v) {cout << u << " ";}                                     \
  cout << endl;
  
  /*
  ll ml(ll a, ll b){
  	return ( (a%mod)*(b%mod) )%mod;
  }
ll fp(ll num,ll g)
{
    if(g==0)return 1;
    if(g%2==1)return ml(num,fp(ml(num,num) ,g/2) );
    return fp( ml(num,num),g/2);
}
ll d(ll a, ll b) {//a/b
	return a*fp(b, mod - 2) % mod;
}
ll pm(ll f[] , ll n, ll r){
	return d(  f[n] , f[n-r] );
}
ll cm(ll f[] , ll n , ll r ){
		return d( f[n] , ml( f[r],f[n-r] ) );
	}
*/
int main(){
	ll n,m;cin>>n>>m;
	vector<ll> ad[n+1];
	ll h[n+1];
	rep(i,1,n+1)cin>>h[i];
	rep(i,0,m){
		ll l,r;cin>>l>>r;
		ad[l].pb(r);
		ad[r].pb(l);
	}	
	ll x=n;
	rep(i,1,n+1){bool g=1;
		for(auto u:ad[i]){
			if(h[u] >= h[i] )g=0;
		}
		if(!g)x--;
	}
	c1(x)

}


Measured memory_bytes: 10244
#include <iostream>
using namespace std;
class Stack_10{
private:
	int num;
	int x[10];
public:
	Stack_10(){num=0;};
	void push(int i){
		if(num<10){			
			x[num]=i;
			num++;
		}
	};
	int pop(){
		if(num>0){
			num--;
			return x[num];
		}
		else return -1;
	
	};
};
	
int main(int argc, char *argv[]){
	int car;
	Stack_10 stack;
	while(cin>>car){
	if(car>0) stack.push(car);
	else cout<<stack.pop()<<endl;
}

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define M 100

int main(){
  int i, j, N, flag, A[M], count=0, a;

  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  flag=1;
  i=0;
  while(flag){
    flag=0;
    for(j=N-1;j>i;j--){
      if(A[j-1]>A[j]){
	   a = A[j-1];
	  A[j-1]=A[j];
	  A[j]=a;
	  count++;
      }
      flag=1;
    }
    i++;
  }
  printf("%d",A[0]);
    for(i=1;i<N;i++)
      printf(" %d",A[i]);
    
    printf("\n%d\n",count);

    return 0;
}
  



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()


int main(int argc, const char * argv[]) {
    string s;
    int K;
    cin >> s >> K;
    set<string> SS;
    for (int i=0; i<s.size(); ++i) {
        for (int j=1; j<=K; ++j) {
            SS.insert(s.substr(i, j));
        }
    }
    auto it = SS.begin();
    for (int i=0; i<K-1; ++i) {
        cerr << *it << endl;
        ++it;
    }
    cout << *it << endl;

    return 0;
}


Measured memory_bytes: 1664
include Math
A, B, H, M = gets.chomp.split(" ").map(&:to_i)
HA = (H*PI)/6
MA = (M*PI)/360
HB = 2*PI*H
MB = (M*PI)/30
arad = HA + MA
brad = HB + MB
theta = [brad - arad, 2*PI - (brad - arad)].min
if theta == PI/2
  puts A + B
else
  puts sqrt(A**2 - 2*A*B*cos(theta) + B**2)
end

Measured memory_bytes: 14724
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
vector<pair<LL,LL> >vec[N + 5];

LL dp[N + 5];
LL ST[4 * N + 5];
LL lazy[4 * N + 5];

void pushdown(int idx,int l,int r) {
	if(lazy[idx] == 0 || l == r) return ;
	ST[2 * idx] += lazy[idx];
	ST[2 * idx + 1] += lazy[idx];
	lazy[2 * idx] += lazy[idx];
	lazy[2 * idx + 1] += lazy[idx];
	lazy[idx] = 0;
}

void update(int idx,int l,int r,int le,int ri,LL v) {
	pushdown(idx,l,r);
	if(r < le || ri < l) return ;
	if(le <= l && r <= ri) {
		ST[idx] += v;
		lazy[idx] += v;
		return ;
	}
	int mid = (l + r) / 2;
	update(2 * idx,l,mid,le,ri,v), update(2 * idx + 1,mid + 1,r,le,ri,v);
	ST[idx] = max(ST[2 * idx], ST[2 * idx + 1]);
}

LL query(int idx,int l,int r,int le,int ri) {
	pushdown(idx,l,r);
	if(r < le || ri < l) return -1e18;
	if(le <= l && r <= ri) return ST[idx];
	int mid = (l + r) / 2;
	return max(query(2 * idx,l,mid,le,ri),query(2 * idx + 1,mid + 1,r,le,ri));
}

void hora(int tc) {
	int n,m;
	cin>>n>>m;
	for(int i = 0;i < m;i++) {
		int l,r,x;
		cin>>l>>r>>x;
		vec[l].PB({l - 1,x});
		vec[r + 1].PB({l - 1,-x});
	}
	LL res = 0;
	for(int i = 1;i <= n;i++) {
		for(int j = 0;j < vec[i].size();j++) {
			int x = vec[i][j].FI;
			LL v = vec[i][j].SE;
			update(1,0,n,0,x,v);
		}
		dp[i] = query(1,0,n,0,i - 1);
		update(1,0,n,i,i,dp[i]);
		res = max(res,dp[i]);
	}
	cout<<res<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 29440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int n,m;
int a[60],b[60],c[60],d[60];
int func(int x){
  int best=INF;
  int ans;
  rep(i,m){
    if(abs(a[x]-c[i])+abs(b[x]-d[i])<best){
      best=abs(a[x]-c[i])+abs(b[x]-d[i]);
      ans=i;
    }
  }
    return ans+1;
  }
int main(){
  
  cin>>n>>m;
   
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,m)cin>>c[i]>>d[i];
  rep(i,n)
  cout<<func(i)<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
adj = [[i] for i in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

dp = [[0 for _ in range(11)] for _ in range(n)]
qs = [0]

q = int(input())
for i in range(q):
	v, d, c = map(int, input().split())
	qs.append(c)
	dp[v-1][d] = i+1

for j in range(10, 0, -1):
	for i in range(n):
		for v in adj[i]:
			dp[v][j-1] = max(dp[v][j-1], dp[i][j])

for i in range(n):
	print(qs[dp[i][0]])


Measured memory_bytes: 110496
n,m = gets.chomp.split(' ').map(&:to_i)
if n > 2 && m > 2
  puts (n-2)*(m-2)
elsif [n,m].min == 2
  puts 0
elsif n == 1 && m == 1
  puts 1
else
  puts [[n,m].max - 2 ,0].max
end


Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }
};

//--global--//



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

bool calc(ll n, ll m, ll v, ll p, ll *s, int index) { //条件判定
	ll i = upper_bound(s, s+n, s[index]) - s - 1;
	ll a = s[i] + m, now = 0;
	ll k = upper_bound(s, s+n, a) - s - 1;
	if (k < n - p) return false;
	if (i >= n - p) return true;
	rep(j, n) {
		if (j >= n - p + 1) now += m;
		else now += min(a - s[j], m);
	}
	//cout << i << " " << now << endl;
	if (now >= m * v)return true;
	return false;
}

bool calc(ll n, ll m, ll v, ll p, ll *a, ll mid, ll nextMax){
    ll fm = a[mid] + m;
    ll allselect = m * (v-p+1LL);
    // cout << allselect << ", " << mid << endl;
    // cout << fm << endl;
    //if(fm < nextMax)return false;

    rep(i, n-(p-1LL)){
        //if(fm-a[i] <= 0LL)continue;
        allselect -= (min(fm-a[i], m));
    }

    if(allselect <= 0LL)return true;
    return false;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    ll *a;
    a = new ll[MAX];
    ll nextMax = -1;
    ll Ma = -1;
    rep(i, n){
        cin >> a[i];
        if(Ma == -1){
            Ma = a[i];
            nextMax = Ma;
        }
        if(Ma < a[i]){
            nextMax = Ma;
            Ma = a[i];
        }
    }
    //cout << nextMax << endl;

    sort(a, a+n);

    ll ansNum = LLINF;
    ll l = -1LL;
    ll r = n;
    while(r - l > 1LL){
        ll mid = (l + r) / 2LL;
        // cout << mid << ", " << a[mid] << endl;
        if(calc(n, m, v, p, a, mid)){
            // できていたら
            r = mid;
            ansNum = min(ansNum, mid);
        }
        else{
            l = mid;
        }
    }

    //cout << ansNum << endl;

    cout << n - ansNum << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

   long A , B; cin >> A >> B;
   cout << max(max(A + B , A - B) , A * B) << endl;
    
}

Measured memory_bytes: 256
N = int(input())
F = []
for _ in range(N):
    f = [int(s) for s in input().split()]
    b = sum([v * (1 << i) for i, v in enumerate(f)])
    F.append(b)
P = []
for _ in range(N):
    p = [int(s) for s in input().split()]
    P.append(p)
ans = max([sum([P[j][bin(i & F[j]).count("1")] for j in range(N)])
           for i in range(1, 2 ** 10)])
print(ans)


Measured memory_bytes: 3444
#include <stdio.h>
int main (){
  int a,b,c[200000],d[199999],max=0,ans;
  scanf("%d%d\n",&a,&b);
  for(int i=0;i<b;i++)
    scanf("%d",&c[i]);
  for(int i=0;i<b-1;i++){
    d[i]=c[i+1]-c[i];
    if (max<d[i])
      max=d[i];
    }
   if (max<c[0]+a-c[b-1])
     max=c[0]+a-c[b-1];
    ans=a-max;
    printf("%d",ans);
    
  return 0;
  }

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define se second
#define fi first
 
int32_t main(){
    
  //int a,b,c;
 	int n;
  cin>>n;
  bool flag=true;
  for(int i = 0; i < n ; i++)
  {
    	int x;
    cin>>x;
    if(x%2==0)
    {
     	if(x%3!=0 && x%5!=0)
          	flag=false;
    }
    
  }
  if(flag)
    	cout<<"APPROVED";
  else	
    	cout<<"DENIED";
    
  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    string s;cin >> s;
    ll ans = 0;
    int n = s.size();
    for(int i=0;i<(1<<n-1);i++){
        bitset<9> bit(i);
        ll sum = 0;
        ll tmp = s[0]-'0';
        rep(j,n-1){
            if(bit.test(j)){
                sum += tmp;
                tmp = s[j+1]-'0';
            }else{
                tmp = tmp * 10 + (s[j+1]-'0');
            }
        }
        sum += tmp;
        ans += sum;
    }
    cout << ans << endl;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    int n, l;
    cin >> n >> l;
    vector<int> ns(n), abss(n);
    int ttl = 0;
    rep(i, n) {
        ns[i] = l+i;
        abss[i] = abs(ns[i]);
        ttl += ns[i];
    }
    auto it = min_element(be(abss));
    cout << ttl - ns[distance(begin(abss), it)] << nl;
}


Measured memory_bytes: 256
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 q = sc.nextInt();
        String s = sc.next();
        String[] str = s.split("");
        List<Integer> l = new ArrayList<>();
        List<Integer> r = new ArrayList<>();
        List<Integer> ac = new ArrayList<>();
        for (int i = 0; i < q; i++) {
            l.add(sc.nextInt());
            r.add(sc.nextInt());
        }

        for (int i = 0; i < n - 1; i++) {
            if ("A".equals(str[i]) && "C".equals(str[i + 1])) {
                if (i == 0) {
                    ac.add(1);
                } else {
                    ac.add(ac.get(i - 1) + 1);
                }
            } else {
                if (i == 0) {
                    ac.add(0);
                } else {
                    ac.add(ac.get(i - 1));
                }
            }
        }
        for (int i = 0; i < q; i++) {
            int start = l.get(i);
            int end = r.get(i);
            if (start == 1) {
                System.out.println(ac.get(end - 2));
            } else {
                System.out.println(ac.get(end - 2) - ac.get(start - 2));
            }
        }
    }

}


Measured memory_bytes: 111816
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	x := nextInt()
	for !isPrime(x) {
		x++
	}
	fmt.Println(x)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


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

ans = n % 10

if ans == 2 or ans ==  4 or  ans == 5 or ans == 7 or ans == 9:
    print('hon')
elif ans == 0 or ans == 1 or ans == 6 or ans == 8:
    print('pon')
elif ans == 3:
    print('bon')

Measured memory_bytes: 9156
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int h,n;
    cin>>h>>n;
    int a[n];
    int sum=0;
    forn(i,n){
        cin>>a[i];
        sum += a[i];
    }
    if(sum >= h) cout<<"Yes\n";
    else            cout<<"No\n";
    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

ll dp[200005][5];

int main(int argc, char* argv[])
{
    long L;
    scanf("%ld", &L);

    vector<long> a(L+1);
    long i;
    for(i=1; i<=L; i++) {
        scanf("%ld", &a[i]);
    }

    for(i=1; i<=L; i++) {
        dp[i][0] = dp[i-1][0] + a[i];
        dp[i][1] = MIN(dp[i-1][0], dp[i-1][1]) + (a[i]<2? 2-a[i]: a[i]%2);
        dp[i][2] = MIN(MIN(dp[i-1][0], dp[i-1][1]), dp[i-1][2]) + (a[i]+1)%2;
        dp[i][3] = MIN(MIN(MIN(dp[i-1][0], dp[i-1][1]), dp[i-1][2]), dp[i-1][3]) + (a[i]<2? 2-a[i]: a[i]%2);
        dp[i][4] = MIN(MIN(MIN(MIN(dp[i-1][0], dp[i-1][1]), dp[i-1][2]), dp[i-1][3]), dp[i-1][4]) + a[i];
    }

    ll ans=LINF;
    long k;
    for(k=0; k<5; k++) {
        ans = MIN(ans, dp[L][k]);
    }

    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 9600
N, M = map(int, input().split())

flg = False
if N == 1 and M == 1:
  if input() == input(): flg = True
else:
  A = [(input()) for _ in range(N)]
  B = [(input()) for _ in range(M)]


for i in range(N-M):
  if flg:
    break
  for j in range(N-M):
    if all([A[i+x][j+y] == B[x][y] for x in range(M) for y in range(M)]):
      flg = True
      break
if flg: print ("Yes")
else: print ("No")

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

int main() {
    int a,b;
    cin>>a>>b;
    int ans=1;
    while(true) {
        if(ans*a-(ans-1)>=b) break;
        ans++;
    }
    if(b==1) ans=0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF=1001001001;


int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  //a[0]Aはの本を全く読まない
  rep(i,n) cin >> a[i+1];
  rep(i,m) cin >> b[i+1];
  for(int i= 1; i <= n; i++) a[i] += a[i-1];//机Aの本を読むのにかかった時間
  for(int i= 1; i <= m; i++) b[i] += b[i-1];
  b.push_back(INF);


  int ans = 0;
  rep(i,n+1) {
    int x = k - a[i];
    if(x<0) break;
    int l = 0;
    int r = m+1;
    while(r-l>1) {
      int h = (l+r)/2;
      if(b[h]<=x) l = h;
      else r = h; 
    }
    ans = max(ans,i+l);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7964
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define ll long long
#define ii pair<string,int>ii;

string IntToStr(int tmp){
    ostringstream out;
    out << tmp;
    return out.str();
}

int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b)cout<<"delicious"<<endl;
    else if((b-a)<=x)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
S = input()


ans = 0
num = 0
cnum = 0

if S[0] == "A":
  ans += 1

for i in range(2,len(S)-1):
  if S[i] == "C":
    cnum += 1
    
if cnum == 1:
  ans +=1

for j in range(len(S)):
  if S[j].islower() == True:
    num += 1

    
if num == len(S)-2:
  ans +=1
  
  
  

if ans ==3:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n;

void solve(){
    cin >> n;
    ll arr[n], _sum[n], _diff[n];
    for(auto &i : arr)
        cin >> i;
    unordered_map<ll, ll> m1, m2;
    unordered_set<ll> done;
    for(ll i = 0; i < n; i++){
        _sum[i] = i + 1 + arr[i];
        m1[_sum[i]]++;
    }
    for(ll i = 0; i < n; i++){
        _diff[i] = (i + 1) - arr[i];
        m2[_diff[i]]++;
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(done.count(_sum[i]))
            continue;
        ll a = m1[_sum[i]], b = m2[_sum[i]];
        ans += a * b;
        done.insert(_sum[i]);
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 38780
def check():
    while True:
        l=len(p)
        if l==0 or l==1: return l-1
        for i in range(l-1):
            if p[i]+p[i+1]=='()' or p[i]+p[i+1]=='[]':
                del p[i+1],p[i]
                break
        if l==len(p):return False
while True:
    s=input()
    if s=='.':break
    p = [c for c in s if c=='(' or c ==')' or c=='['or c==']']
    print('yes' if check() else 'no')

Measured memory_bytes: 6724
//16, 02, 2019, 10:20:19 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = int(1e5);
int dp[N];
int cost[] = {2,5,5,4,5,6,3,7,6};
int n, m;
int a[N];

int solve(int number_sticks){
    if(number_sticks == 0){
        return 0;
    }

    if(number_sticks < 0){
        return -1e9;
    }

    int &ans = dp[number_sticks];

    if(ans != -1){
        return ans;
    }

    for(int i = 0 ; i < m ; i++){
        ans = max(ans, solve(number_sticks - cost[a[i] - 1]) + 1);
    }

    return ans;
}

void print(int number_sticks){
    if(number_sticks == 0){
        return;
    }

    int &ans = dp[number_sticks];

    for(int i = 0 ; i < m ; i++){
        if(ans == solve(number_sticks - cost[a[i] - 1]) + 1){
            cout << a[i];
            print(number_sticks - cost[a[i] - 1]);
            break;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    memset(dp, -1, sizeof dp);

    cin >> n >> m;

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

    sort(a, a + m, greater< int >());

    solve(n);
    print(n);
    cout << endl;

    return 0;
}

Measured memory_bytes: 768