akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

string b[128];
int cr[128][1024], cc[1024][128];
int mh;

struct glyph{
	char c;
	vector<string> v, r;
	void input(){
		int h, w;
		cin >> c >> h >> w;
		v.resize(h);
		r.resize(h);
		for(int i = 0; i < h; ++i){
			cin >> v[i];
			r[i] = string(v[i].rbegin(), v[i].rend());
		}
		mh = max(mh, h);
	}
	bool match_base(int y1, int x1, int y2, int x2, const vector<string> &a) const{
		int h = a.size(), w = a[0].size();
		if(y2 - y1 + 1 != h || x2 - x1 + 1 != w){ return false; }
		for(int i = 0; i < h; ++i){
			if(b[y1 + i].compare(x1, w, a[i])){ return false; }
		}
		return true;
	}
	bool match(int y1, int x1, int y2, int x2) const{
		return match_base(y1, x1, y2, x2, v);
	}
	bool rmatch(int y1, int x1, int y2, int x2) const{
		return match_base(y1, x1, y2, x2, r);
	}
};

vector<glyph> gs;

string term(int, int, int, int);

string seq(int y1, int x1, int y2, int x2){
	bool ex = false;
	vector<string> v;
	for(int j = x1; j <= x2 + 1; ++j){
		if(j <= x2 && cc[j][y2] - cc[j][y1 - 1]){
			ex = true;
		}
		else if(ex){
			ex = false;
			v.push_back(term(y1, x1, y2, j - 1));
			x1 = j + 1;
		}
	}

	int idx = 1;
	for(size_t i = 0; i < v.size(); ++i){
		if(v[i][0] == '_' && v[i][1] == '_'){
			idx = 2;
			break;
		}
	}
	for(size_t i = 0; i < v.size(); ++i){
		if(v[i][0] == '_'){
			v[i] = string(1, v[i][idx]);
		}
	}

	if(idx == 1){
		return accumulate(v.begin(), v.end(), string());
	}
	return accumulate(v.rbegin(), v.rend(), string());
}

string term(int y1, int x1, int y2, int x2){
	while(cr[y1][x2] - cr[y1][x1 - 1] == 0){ ++y1; }
	while(cr[y2][x2] - cr[y2][x1 - 1] == 0){ --y2; }
	while(cc[x1][y2] - cc[x1][y1 - 1] == 0){ ++x1; }
	while(cc[x2][y2] - cc[x2][y1 - 1] == 0){ --x2; }

	string ret;
	if(y2 - y1 + 1 > mh){
		ret = '[' + seq(y1 + 2, x1 + 2, y2 - 2, x2 - 2) + ']';
	}
	else{
		ret = "___";
		for(size_t i = 0; i < gs.size(); ++i){
			if(gs[i].match(y1, x1, y2, x2)){
				ret[1] = gs[i].c;
				break;
			}
		}
		for(size_t i = 0; i < gs.size(); ++i){
			if(gs[i].rmatch(y1, x1, y2, x2)){
				ret[2] = gs[i].c;
				break;
			}
		}
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);

	int n, m;
	string s;
	while(cin >> n >> m, n){
		mh = 0;
		gs.resize(n);
		for(int i = 0; i < n; ++i){
			gs[i].input();
		}
		for(int k = 1; k <= m; ++k){
			int h, w;
			cin >> h >> w;
			b[0].assign(w + 1, '.');
			for(int i = 1; i <= h; ++i){
				cin >> s;
				b[i] = '.' + s;
				for(int j = 1; j <= w; ++j){
					cr[i][j] = cr[i][j - 1] + (b[i][j] == '*');
					cc[j][i] = cc[j][i - 1] + (b[i][j] == '*');
				}
			}

			s = seq(1, 1, h, w);
			cout << s << '\n';
		}
		cout << "#\n";
	}
}

Measured memory_bytes: 2332
N = int(input())
graph = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    graph[a-1].append((c,b-1))
    graph[b-1].append((c,a-1))
Q,K = map(int,input().split())

from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist
    # dist = [costs to nodes]

cost = dijkstra(graph,N,K-1)
for i in range(Q):
    x,y = map(int,input().split())
    print(int(cost[x-1]+cost[y-1]))

Measured memory_bytes: 48288
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main(){
     int N;
     int W[101];
     int sum = 0;
     int t = 0;
     int min = 100000;
     cin >> N;
     for(int i = 0; i < N; i++){
          cin >> W[i];
          sum += W[i];
     }
     for(int i = 0; i < N; i++){
          t += W[i];
          if(abs(sum - 2*t) < min){
               min = abs(sum - 2*t);
          }
     }
     cout << min << endl;
     return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007
#define pi 3.14159265358979323846264338327950

void solve()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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

Measured memory_bytes: 3656
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define MODk 998244353
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modularExponentiation(ll x,ll n,ll M);
void dsp(vector<ll> &V);
void dsp2(vector<pair<ll,ll>>&V);
void dsp3(map<ll,ll>&M);
double fact(double n);
ll nPr(ll n,ll r);
ll nCr(ll n,ll r);
ll mx;
bool isPalindrome(string k) 
{ 
    // Start from leftmost and rightmost corners of str 
    ll l = 0; 
    ll h = sz(k) - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (k[l++] != k[h--]) 
        { 
            return false; 
        } 
    } 
    return true; 
} 
void solve()
{
   ll n,N,a=0;cin>>n;
   N=n;
  if(N>=500)
  {
      a=(N/500)*1000;
      N%=500;
  }
  a+=(N/5)*5;
  cout<<a<<"\n";
  }
int main()
{
   fastio
   solve();
  return 0;
}
ll gcd(ll a,ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
          
} 
ll lcm(ll a,ll b)  
{  
    return (a*b)/gcd(a, b);  
}  
ll modularExponentiation(ll x,ll n,ll M)
{   
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
        result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
        return result;
}
void dsp(vector<ll> &V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j]<<" ";
    }
    cout<<endl;
}
void dsp2(vector<pair<ll,ll>>&V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j].first<<" "<<V[j].second<<" ";
    }
    cout<<endl;
}
void dsp3(map<ll,ll>&M)
{
      map<ll,ll>::iterator it=M.begin();
      while(it!=M.end())
      {
        cout<<it->first<<" "<<it->second<<endl;
        it++;
      }
}
double fact(double n)
{
    double i=1;
    double res=1;
    
    if(n==0)
        return 1.00;
    
    while(i<=n)
    {
        res*=i;
        i++;
    }
    
    return res;
}
ll nPr(ll n,ll r)
{
    return (fact(n)/fact(n-r));
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>

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

int a;
int main()
{
    int n=0,k;
    scanf("%d",&a);
    while(1)
    {
        if(n*(n+1)/2>=a)
            break;
        n++;
    }
    k = n*(n+1)/2-a;
    for(int i=0;i<n - k;i++)
        printf(")");

    printf("(");

    for(int i=0;i<k;i++)
        printf(")");

    for(int i=0;i<n-1;i++)
        printf("(");

    printf("\n");
    return 0;
}

Measured memory_bytes: 3156
# -*- coding: utf-8 -*-
import numpy as np
import sys


def main():
    N = int(input())
    A = np.zeros(N)
    B = np.array(input().split(), dtype='int64')


    for i in range(N):
        if i == 0:
            A[0] = B[0]
        elif i == N-1:
            A[-1] = B[-1]
        else:
            if B[i-1] < B[i]:
                A[i] = B[i-1]
            else:
                A[i] = B[i]
    ans = int(np.sum(A))
    print(ans)








if __name__ =='__main__':
    main()


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

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];

    if (count(a, a + 3, 5) == 2 && count(a, a + 3, 7) == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
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;
}
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(){
    ll n,m;cin>>n>>m;
    vl a(n),b(m);
    vl h(n*m+1),w(n*m+1);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    rep(i,n) h[a[i]]++;
    rep(i,m) w[b[i]]++;
    rep(i,n*m+1){
        if(h[i]>1){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,n*m+1){
        if(w[i]>1){
            cout<<0<<endl;
            return 0;
        }
    }
    mint ans=1;
    ll hh=0,ww=0;
    ll use=0;
    for(ll i=n*m;i>=1;i--){
        hh+=h[i];
        ww+=w[i];
        if(h[i]&&w[i]){
            use++;
            continue;
        }
        else if(h[i]){
            ans*=ww;
        }
        else if(w[i]){
            ans*=hh;
        }
        else{
            ans*=hh*ww-use;
        }
        use++;
    }
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 15872
w,h,n = map(int,input().split())
x = [0] * n
y = [0] * n
a = [0] * n
for i in range(n):
    x[i], y[i], a[i] = map(int, input().split())
box = []

for i in range(h):
    box.append([1]*w)
for i in range(n):
    if a[i] == 1:
        for m in range(h):
            for j in range(x[i]):
                box[m][j] = 0  
    elif a[i] == 2:
        for m in range(h):
            for j in range(x[i],w):
                box[m][j] = 0
    elif a[i] == 3:
        for m in range(y[i]):
            for j in range(w):
                box[m][j] = 0
    else:
        for m in range(y[i],h):
            for j in range(w):
                box[m][j] = 0
print(sum(map(sum,box)))

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_set>

using namespace std;

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

  char A[50][50];
  char B[50][50];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      cin >> A[i][j];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++)
      cin >> B[i][j];
  }

  if (n < m) {
    cout << "No" << endl;
    return 0;
  }

  bool exist = false;

  for (int ly = 0; ly < n; ly++) {
    for (int lx = 0; lx < n; lx++) {
      if (ly + m - 1 >= n || lx + m - 1 >= n)
        continue;

      bool flag = true;
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          if (B[i][j] != A[i + ly][j + lx]) {
            flag = false;
          }
        }
      }
      if (flag)
        exist = true;
    }
  }

  cout << (exist ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<int> d2cnt(N);
    rep(i, N) {
        int a = A[i];
        while (a % 2 == 0) {
            a /= 2;
            d2cnt[i]++;
        }
    }
    rep(i, 1, N) {
        if (d2cnt[i] != d2cnt[0]) {
            write(0);
            return 0;
        }
    }

    ll hlcm = A[0] / 2;
    ll lcm = A[0];
    rep(i, 1, N) {
        if (hlcm <= 1e9) {
            hlcm = hlcm * (A[i] / 2) / gcd(hlcm, A[i] / 2);
        }
        if (lcm <= 1e9) {
            lcm = lcm * A[i] / gcd(lcm, A[i]);
        }
    }

    if (M < hlcm) write(0);
    else if (hlcm + lcm > M) write(1);
    else write((M - hlcm) / lcm + 1);
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

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

    vector<vector<pair<int, int>>> list(N);
    int p, q, r;
    for (int i = 0; i < N - 1; i++)
    {
        cin >> p >> q >> r;
        p--, q--;
        list[p].push_back({q, r}), list[q].push_back({p, r});
    }

    vector<bool> arrived(N, false); //訪問済みかどうか
    vector<int> length(N);          //始点からの距離
    queue<int> que;                 //訪問予定

    que.push(0);
    arrived[0] = true;
    length[0] = 0;
    int search, now, dis;
    while (!que.empty())
    {
        now = que.front();
        que.pop();
        for (int i = 0; i < list[now].size(); i++)
        {
            search = list[now][i].first;
            dis = list[now][i].second;
            if (!arrived[search]) //未訪問
            {
                arrived[search] = true;
                length[search] = (length[now] + dis) % 2;
                que.push(search);
            }
        }
    }
    for (auto x : length)
        cout << x << endl;
}

Measured memory_bytes: 9480
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int s;
    cin>>s;
    vector<vector<in>> dp(max(s/3,1),vector<in>(s+1,0));
    REP(i,3,s+1) dp[0][i]=1;
    in ans=0;
    ans += dp[0][s];

    for(int i=1;i<s/3;i++){
        in sum=0;
        REP(j,3*i+3,s+1){
            sum += dp[i-1][j-3];
            sum %= MOD;
            dp[i][j]=sum;
        }
        ans += dp[i][s];
        ans %= MOD;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 13696
#include <iostream>

using namespace std;

int main(void)
{
    int N, A[100000],B[100000], num, i;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];
    }

    for(i=1; i<=N; i++){
        B[A[i]] = i;
    }

    for(i=1; i<=N; i++){
        cout << B[i] << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,a,b,i,j,x[100000];
	long long sum;
	scanf("%d %d %d",&n,&a,&b);
	for(i=0;i<n;i++)	scanf("%d",&x[i]);
	sum=0;
	for(i=0;i<n-1;i++)	{
		sum+=min((long long)a*(x[i+1]-x[i]),(long long)b);
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct UnionFind {
    vector<int> par;

    UnionFind(int sz) {
        par.assign(sz, -1);
    }

    bool merge(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return (false);
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return (true);
    }

    int root(int k) {
        if(par[k] < 0) return (k);
        return (par[k] = root(par[k]));
    }

    int size(int k) {
        return (-par[root(k)]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main(){
    int n,k,l; cin >> n >> k >> l;
    UnionFind ur(n), ut(n);
    rep(i,k){
        int p,q; cin >> p >> q; p--; q--;
        ur.merge(p,q);
    }
    rep(i,l){
        int r,s; cin >> r >> s; r--; s--;
        ut.merge(r,s);
    }
    map<P, int> mp;
    rep(i,n) mp[P(ur.root(i), ut.root(i))]++;
    rep(i,n) printf("%d%c", mp[P(ur.root(i), ut.root(i))], i == n-1 ? '\n' : ' ');
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  bool ok = true;
  rep(i,n) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) ok = false;
    }
  }
  if (ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}

Measured memory_bytes: 256
func main() {
  let n = Int(readLine()!)!
  let a = readLine()!.split(separator: " ").map { Int($0)! }

  var cEven = 0
  var dp = Array(repeating: 0, count: n)
  
  // initial conditions
  cEven += a[0]
  dp[0] = 0
  dp[1] = max(a[1], cEven)

  for i in 2..<n {
    if i % 2 == 0 {
      cEven += a[i]
      dp[i] = max(dp[i-1], dp[i-2] + a[i])
    }
    else {
      dp[i] = max(dp[i-2] + a[i], cEven)
    }
  }

  print(dp[n-1])
}

main()


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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		for(int i=0;i<=x;i++) {
			if(2*i+4*(x-i)==y) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}


Measured memory_bytes: 35812
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=(1<<18)+10;
int n,k,s,t,m;
vector<int> a;
ll C[55][55],ways[55];
ll cnt[maxn];
void solve()
{
	for(int i=0;i<m;i++)
	{
		for(int msk=0;msk<(1<<m);msk++)
		{
			if(!(msk>>i&1))
			{
				cnt[msk^(1<<i)]+=cnt[msk];
			}
		}
	}
}
int main()
{
	scanf("%d%d%d%d",&n,&k,&s,&t);
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		if(((x&s)==s)&&((x|t)==t))a.push_back(x);
	}
	if(a.empty())
	{
		printf("0\n");
		return 0;
	}
	n=a.size();
	C[0][0]=1;
	for(int i=1;i<55;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++)C[i][j]=C[i-1][j]+C[i-1][j-1];
	}
	for(int i=0;i<55;i++)
	{
		for(int j=0;j<=i&&j<k;j++)ways[i]+=C[i][j];
	//	if(i<=n)cout<<i<<" "<<ways[i]<<endl;
	}
	int free=(s^t);
	vector<int> bts;
	bts.clear();
	for(int i=0;i<18;i++)if(free>>i&1)bts.push_back(i);
	m=bts.size();
	for(int i=0;i<n;i++)
	{
		int tmp=a[i];
		a[i]=0;
		for(int j=0;j<m;j++)if(tmp>>bts[j]&1)a[i]|=(1<<j);
	//	cout<<a[i]<<endl;
	}
	ll ans=0;
	int s2=__builtin_popcount(s);
	for(int i=0;i<n;i++)
	{
		memset(cnt,0,sizeof(cnt));
		for(int j=i+1;j<n;j++)
		{
			cnt[a[i]^a[j]]++;
		}
	//	for(int j=0;j<(1<<m);j++)cout<<cnt[j]<<endl;system("pause");
		solve();
		for(int j=0;j<(1<<m);j++)
		{
			int sz=__builtin_popcount(j);
			if(sz&1)ans-=ways[cnt[j]];
			else ans+=ways[cnt[j]];
		}
	}
	if(m&1)
	{
		ans=-ans;
	//	cout<<__builtin_popcount(s)<<" "<<__builtin_popcount(t)<<" "<<m<<" "<<__builtin_popcount(free)<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5864
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	ll a,b; cin >> a >> b;
	if(a==1||b==1) cout << 1 << endl;
	else if(a*b%2==0) cout << a*b/2 << endl;
	else cout << (a*b+1)/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;
int x,y;

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> nums(n);

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

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

  int ans = 0;
  for (int i=0; i<k; ++i) {
    ans += nums[i];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  long ans = B - A + 1;
  A--;
  ans -= (B / C - (A / C)) + (B / D - (A / D)) - (B / (C * D / __gcd(C, D)) - A / (C * D / __gcd(C, D)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();
    int n = s.length();
    boolean[] dir = new boolean[n]; // left false, right true

    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'R')
        dir[i] = true;
    }

    int[] children = new int[n];

    int l = 0;
    int r = 1;

    do {
      // R -> L
      while(r < n && dir[l] == dir[r]) r++;
      for (int i = l; i < r; i++) {
        if ((r - i) % 2 == 1) children[r - 1]++;
        else children[r]++;
      }
      if (r == n) break;
      // reset
      l = r;
      r = r + 1;
      // L -> R
      while(r < n && dir[l] == dir[r]) r++;
      for (int i = r - 1; l <= i ; i--) {
        if ((i - l) % 2 == 1) children[l - 1]++;
        else children[l]++;
      }
      l = r;
      r = r + 1;
    } while (r < n);
    
    for (int i = 0; i < n - 1; i++) {
      os.print(children[i] + " ");
    }
    os.println(children[n - 1]);
  }
}

Measured memory_bytes: 46364
# coding: utf-8
# Your code here!
line = input().split()
l = [int(s) for s in line]

# print(l)

a = 0 

if -100 <= l[0] <= l[2] <= l[1]<=100:
    a = 1
    
    
if a == 1 :
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 3060
time = [0]*5
time_ = [0]*5
for i in range(5):
    time[i] = int(input())
    time_[i] = time[i] % 10
    if time_[i] == 0:
        time_[i] = 10

idx = time_.index(min(time_))
ans = 0
for i in range(5):
    if i == idx:
        ans += time[i]
    else:
        if 1 <= time_[i] and time_[i] <= 9:
            ans += ((time[i]//10)+1)*10
        else:
            ans += time[i]

print(ans)

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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

const ll big = 1000000007ll;
const ll big2 = 1000000009ll;
ll n,m,k,q,w,h,T;

string s;

//int MASK[(1 << 26)] = {0};
int ANS[(1 << 26)] = {0};

//ll DP[200001] = {0};
vector<ll> A;
/*
ll dp(ll i){
    if(i == n)return 0;
    if(DP[i] != 0)return DP[i];
    ll a = A[i];
    ll ans = big;
    if(MASK[a] > i){
            ans = 1+dp(MASK[a]);
    }
    for(ll c1 = 0; c1 < 26; c1++){
        ll b = a^(1 << c1);
        if(MASK[b] > i){
            ans = min(ans, 1+dp(MASK[b]));
        }
    }
    DP[i] = ans;
    return ans;
}
*/
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;


    cin >> s;
    n = s.length();

    ll F[26] = {0};
    ll mask = 0;
    for(ll c1 = 0; c1 < n; c1++){
        //MASK[mask] = c1;
        a = s[c1]-'a';
        A.push_back(mask);
        mask ^= (1 << a);
    }

    //MASK[mask] = n;

    for(ll c1 = 0; c1 < (1<<26); c1++){
        ANS[c1] = big;
    }

    ANS[0] = 0;

    for(ll c1 = 0; c1 < n; c1++){
        a = A[c1];
        for(ll c2 = 0; c2 < 26; c2++){
            b = a^(1 << c2);
            ANS[a] = min(ANS[a],1+ANS[b]);
        }
        //cout << a <<"  " << ANS[a] << "\n";

    }

    int ans = 1+ANS[mask];

    for(ll c1 = 0; c1 < 26; c1++){
        ans = min(ans, 1 + ANS[mask^(1 << c1)]);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 264436
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
ll a[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, n) scanf("%lld", a+i);
	sort(a, a+n);
	ll ans = 0;
	REP(i, n-k) ans += a[i];
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import java.util.*;
import java.awt.geom.*;

class Star{
    Point2D o;
    Point2D[] t;
    double a, r;

    Star(double x, double y, double a, double r){
        this.o = new Point2D.Double(x, y);
        this.a = a;
        this.r = r;

        t = new Point2D[5];

        for(int i = 0; i < 5; i++){
            double theta = (90 + a + 72 * i) % 360;
            theta = theta * Math.PI / 180;

            double dx = r * Math.cos(theta);
            double dy = r * Math.sin(theta);

            t[i] = new Point2D.Double(x + dx, y + dy);
        }
    }
}

public class Main{
    final static double INF = 999999999;

    static double distSS(Line2D la, Line2D lb){
        return
            Math.min(Math.min(la.ptSegDist(lb.getP1()), la.ptSegDist(lb.getP2())), 
                     Math.min(lb.ptSegDist(la.getP1()), lb.ptSegDist(la.getP2())));
    }

    static double calcDist(Star sa, Star sb){
        double res = INF;

        for(int i = 0; i < 5; i++){
            Line2D a = new Line2D.Double(sa.t[i], sa.t[(i + 2) % 5]);

            for(int j = 0; j < 5; j++){
                Line2D b = new Line2D.Double(sb.t[j], sb.t[(j + 2) % 5]);

                if(a.intersectsLine(b)){
                    return 0;
                }
                else{
                    res = Math.min(res, distSS(a, b));
                }
            }
        }

        return res;
    }

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

        while(true){
            int N = sc.nextInt();
            int M = sc.nextInt() - 1;
            int L = sc.nextInt() - 1;
            if(N == 0) break;

            Star[] t = new Star[N];

            for(int i = 0; i < N; i++){
                double x = sc.nextDouble();
                double y = sc.nextDouble();
                double a = sc.nextDouble();
                double r = sc.nextDouble();
                t[i] = new Star(x, y, a, r);
            }

            double[][] dist = new double[N][N];

            for(int i = 0; i < N; i++){
                for(int j = i; j < N; j++){
                    if(i == j) dist[i][j] = 0;
                    else       dist[i][j] = dist[j][i] = calcDist(t[i], t[j]);
                }
            }

            for(int k = 0; k < N; k++){
                for(int i = 0; i < N; i++){
                    for(int j = 0; j < N; j++){
                        if(i == j) continue;
                        dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
                    }
                }
            }

            System.out.printf("%.20f\n", dist[M][L]);
        }
    }
}

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

class Plogram
{
    static void Main()
    {
        var n = Console.ReadLine().Split();
        int N = int.Parse(n[0]);
        int K = int.Parse(n[1]);

        double score;
        double[] rate = new double[N];
        int j = 0;

        for (int i = 0; i < N; i++)
        {
            score = i + 1;
            j = 0;
            while (true)
            {
                if (score >= K)
                {
                    rate[i] = (1 / (double)N) * Math.Pow(0.5, j);
                    break;
                }

                score *= 2;
                j++;
            }
        }
        Console.WriteLine(rate.Sum());
    }
}

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

int main()
{
    int n,i,ans=0;
    cin>>n;
    int a[n];
    int b[n];
    int c[n-1];
    for(i=0;i<n;i++)
        cin>>a[i];
     for(i=0;i<n;i++)
        cin>>b[i];
    for(i=0;i<n-1;i++)
        cin>>c[i];
        int x;
    for(i=0;i<n;i++)
    {
        x=a[i];
        ans+=b[x-1];
        if(i!=n-1 && x+1==a[i+1])
            ans+=c[x-1];
    }
    cout<<ans<<endl;
    return 0;
}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int a, b;

int main(){
	cin >> a >> b;
	cout << max(a-(2*b), 0) << endl;


	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    int n , a , b , x , i;

    while(cin >> n >> a >> b)
    {
        int cnt=0;

        for(i=0; i<n; i++)
        {
            cin >> x;

            if(x<a)cnt++;
            if(x>=b)cnt++;
        }

        cout << cnt << "\n";
    }

    return 0;
}


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

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

  int count0 = 0, count2 = 0, count4 = 0;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;

    if (!(num % 4)) {
      count4++;
    } else if (!(num % 2)) {
      count2++;
    } else {
      count0++;
    }
  }

  // 4が半分以上あれば、すべて4の倍数となる
  if (count4 >= N / 2) {
    cout << "Yes" << endl;
    return 0;
  }

  // 4の数が0の数以上であれば、4の倍数とできる
  // 仮に2が1つだけあった場合も末尾に移動することで4の倍数となる(1,4,1,4,2)
  if (count4 >= count0) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int64 n = 0;
    int64 ans = 0;
    rep(i, N) {
        if(A[i]) {
            n += A[i];
        } else {
            ans += n / 2;
            n = 0;
        }
    }
    ans += n / 2;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector< int > p(N);
  int total = 0, maxVal = 0;
  REP(i, N) {
    int p;
    cin >> p;
    total += p;
    maxVal = max(maxVal, p);
  }
  cout << total - maxVal / 2 << "\n";
}

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

const int N = 2e5 + 5, djq = 998244353;

int n, tot, p[N], p2[N], f[N], ans;
char s[N];

char inv(char c) {return c == '0' ? '1' : '0';}

char conv(int d, int i) {return i / d & 1 ? inv(s[i % d]) : s[i % d];}

int calc(int d)
{
	int res = 0;
	for (int i = 0; i < d; i++) if (s[i] == '1')
		res = (res + p2[d - i - 1]) % djq;
	for (int i = 0; i < n; i++)
		if (conv(d, i) < s[i]) return (res + 1) % djq;
		else if (conv(d, i) > s[i]) return res;
	return (res + 1) % djq;
}

int main()
{
	scanf("%d%s", &n, s);
	int S = sqrt(n); p2[0] = 1;
	for (int i = 1; i <= n; i++) p2[i] = (p2[i - 1] << 1) % djq;
	for (int i = 1; i <= S; i++)
	{
		if (n % i) continue; p[++tot] = i;
		if (i < n / i) p[++tot] = n / i;
	}
	std::sort(p + 1, p + tot + 1);
	for (int i = 1; i <= tot; i++)
	{
		int x = p[i]; if (!(n / x & 1)) continue;
		f[x] = calc(x);
		for (int j = 1; j < i; j++)
			if (x % p[j] == 0) f[x] = (f[x] - f[p[j]] + djq) % djq;
		ans = (2ll * x * f[x] + ans) % djq;
	}
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 4764
def main():
    N = int(input())
    A = list(map(int,input().split()))
    answer = "APPROVED"
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                answer = "DENIED"
    print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>

int main() {
	int A, B;
	std::cin >> A >> B;

	if(B == 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	const int result = (B - 1 - 1) / (A - 1) + 1;

	std::cout << result << std::endl;

	return 0;
}


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

int main() {
    int n, d;
    cin >> n >> d;
    int ans = 0;

    while (n > 0) {
        n -= (2 * d + 1);
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[310], num[4] = {0};

    cin >> n;

    REP(i, n)
    {
        cin >> a[i];
        num[a[i]]++;
    }

    double dp[301][301][301];

    memset(dp, 0, sizeof(dp));

    for (int k = 0; k <= n; k++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int i = 0; i <= n; i++)
            {
                if ((i + j + k) && i + j + k <= n)
                {

                    if (i)
                        dp[i][j][k] += dp[i - 1][j][k] * i / n;
                    if (j)
                        dp[i][j][k] += dp[i + 1][j - 1][k] * j / n;
                    if (k)
                        dp[i][j][k] += dp[i][j + 1][k - 1] * k / n;
                    dp[i][j][k] += 1;
                    dp[i][j][k] /= 1.0 * (i + j + k) / n;
                }
            }
        }
    }

    cout << setprecision(20) << dp[num[1]][num[2]][num[3]] << endl;

    return 0;
}

Measured memory_bytes: 213376
n=int(input())
a=1
b=1
c=1
p=10**9+7

for i in range(n):
    a=(a*10)%p
for i in range(n):
    b=(b*9)%p
for i in range(n):
    c=(c*8)%p
print((a-2*b+c)%p)


Measured memory_bytes: 63952
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;


int main()
{

        ll d,t,s;
        cin>>d>>t>>s;
        if(t*s>=d)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;


}



























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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  bool a = false;
  sort(A.begin(), A.end());
  for(int i = 0; i < N -1; i++){
    if(A.at(i) == A.at(i+1)){
      a = true;
      break;
    }
  }
  if(a) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 1024
n = gets.to_i
h = gets.split.map(&:to_i)
ans = [0]
cnt = 0
(n - 1).times do |i|
  if h[i] >= h[i + 1]
    cnt += 1
  end
  if h[i] < h[i + 1] || i == n - 2
    ans << cnt
    cnt = 0
  end
end
puts ans.max


Measured memory_bytes: 8964
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n,a[220000],cnt=1;
signed main()
{
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(a[i]==cnt){
			cnt++;
		}
	}
	if(cnt==1){
		cout<<-1;
	}else{
		cout<<n+1-cnt;
	}
}

Measured memory_bytes: 1792
// practice with kaiboy, coached by rainboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] dd = new int[8];
		int[] d2c = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
		while (m-- > 0) {
			int d = sc.nextInt();
			int c = d2c[d];
			dd[c] = Math.max(dd[c], d);
		}
		int[] dp = new int[n + 1]; Arrays.fill(dp, -1); dp[0] = 0;
		for (int i = 0; i < n; i++) {
			int k = dp[i];
			if (k != -1)
				for (int c = 2; c <= 7 && i + c <= n; c++)
					if (dd[c] != 0)
						dp[i + c] = Math.max(dp[i + c], k + 1);
		}
		for (int i = n; i > 0; ) {
			int d_ = 0, c_ = 0;
			for (int c = 2; c <= 7 && i - c >= 0; c++) {
				int d = dd[c];
				if (d_ < d && dp[i] == dp[i - c] + 1) {
					d_ = d; c_ = c;
				}
			}
			print(d_);
			i -= c_;
		}
		println();
	}
}


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

#define REP(i, a, b) for(int i = a; i < b; i++)

const int maxn = 100100;

int n, m;

int a, b;

int ua, ub;

vector <vector <int> > graf;
vector <int> vi;

list <int> rj;

bool bio[maxn];

int main()
{
    scanf("%d%d", &n, &m);
    graf.insert(graf.begin(), n, vi);
    REP(i, 0, m)
    {
        scanf("%d%d", &ua, &ub);
        ua--; ub--;
        graf[ua].push_back(ub);
        graf[ub].push_back(ua);
    }
    a = 0;
    bio[a] = 1;
    b = graf[a][0];
    bio[b] = 1;
    rj.push_back(a);
    rj.push_front(b);
    while(1)
    {
        bool z = 0;
        REP(i, 0, (int) graf[a].size())
        {
            if(!bio[graf[a][i]])
            {
                z = 1;
                a = graf[a][i];
                bio[a] = 1;
                rj.push_back(a);
                break;
            }
        }
        if(!z) break;
    }
    while(1)
    {
        bool z = 0;
        REP(i, 0, (int) graf[b].size())
        {
            if(!bio[graf[b][i]])
            {
                z = 1;
                b = graf[b][i];
                bio[b] = 1;
                rj.push_front(b);
                break;
            }
        }
        if(!z) break;
    }
    printf("%d\n", (int) rj.size());
    for(list <int>::iterator it = rj.begin(); it != rj.end(); it++)
    {
        printf("%d ", (*it) + 1);
    }
    return 0;
}


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

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

  ll N, K, C; cin >> N >> K >> C;
  string S; cin >> S;
  vector<ll> l(K, 0), r(K, 0);

  ll cnt = 0;
  for (ll i = 0; i < N; i++) {
    if (S[i] == 'o') {
      l[cnt] = i;
      cnt++;
      i += C;
      if (cnt == K) break;
    }
  }

  cnt = 0;
  for (ll i = 0; i < N; i++) {
    if (S[N - 1 - i] == 'o') {
      r[cnt] = N - 1 - i;
      cnt++;
      i += C;
      if (cnt == K) break;
    }
  }

  for (ll i = 0; i < K; i++) {
    if (l[i] == r[K - 1 - i]) {
      cout << l[i] + 1 << '\n';
    }
  }

  return 0;
}

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

int main() {
  int n, k; cin >>n >>k;
  vector<int> d(k);
  for (int i=0; i<k; i++) cin >>d.at(i);
  bool pay = false;
  
  while (!pay){
    pay = true;
    for (int i=0; i<k; i++){
      int cah = d.at(i);
      if (n<10){ //nが1桁
        if (n==cah) pay = false;
      }
      else if (n<100){ //nが2桁
        if (n/10==cah || n%10==cah) pay = false;
      }
      else if (n<1000){ //nが3桁
        if (n/100==cah || n/10%10==cah || n%10==cah) pay = false;
      }
      else if (n<10000){ //nが4桁
        if (n/1000==cah || n/100%10==cah || n/10%10==cah || n%10==cah) pay = false;
      }
      else{ //nが5桁
        if (n/10000==cah||n/1000%10==cah||n/100%10==cah||n/10%10==cah||n%10==cah) pay = false;
      }
    }
    if (!pay) n++;
  }
  
  cout <<n <<endl;
}


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

int main(){

    string N;
    cin >> N;

    int count = 0;
    for (int i=0; i<N.length(); i++) {
        if (N[i] == '2') {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

#define Num 1001

void print (char* str,int a,int b);
void reverse (char* str,int a,int b);
void replace (char* str,int a,int b,char* rep);

int main () {
	char str[Num],func[Num],rep[Num];
	int a,b;
	int command;
	
	scanf ("%s",&str); //操作する文字列
	scanf ("%d",&command); //命令の数
	
	while (command != 0) {
		scanf ("%s",&func);
	    if ( strcmp (func,"print") == 0) {
	    	scanf ("%d %d",&a,&b);
	    	print (str,a,b);
	    } else if ( strcmp (func,"reverse") == 0) {
	    	scanf ("%d %d",&a,&b);
	    	reverse (str,a,b);
	    } else if ( strcmp (func,"replace") == 0) {
	    	scanf ("%d %d %s",&a,&b,&rep);
	    	replace (str,a,b,rep);
	    }
	    command --;
	}
	return 0;
}

void print (char* str,int a,int b) {
	int i;
	for (i = a;i <= b;i ++) {
		printf ("%c",str[i]);
	}
	putchar ('\n');
}

void reverse (char* str,int a,int b) {
	int i;
	char rev[Num];
	for (i = 0;i < b - a + 1;i ++) { //b-a+1 個
		rev[i] = str[b -i];
	}
	for (i = 0;i < b - a + 1;i ++) {
		str[a + i] = rev[i];
	}
}

void replace (char* str,int a,int b,char* rep) {
	int i;
	for (i = 0;i < b - a + 1;i ++) {
		str[a + i] = rep[i];
	}
}




Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	cout<<h*w-(a*w+b*h-a*b);
}



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

int hext(string a){
	int c,d;
	if(a[0]>='0'&&a[0]<='9')c=a[0]-'0';
	else c=a[0]-'a'+10;
	
	if(a[1]>='0'&&a[1]<='9')d=a[1]-'0';
	else d=a[1]-'a'+10;
	
	return c*16+d;
	}

int main(){
	string s;
	while(cin>>s&&s!="0"){
		int r,g,b;
		r=hext(s.substr(1,2));
		g=hext(s.substr(3,2));
		b=hext(s.substr(5,2));
		
		string ans;
		int d=1e9;
		if(d>((r*r)+(g*g)+(b*b)))ans="black",d=((r*r)+(g*g)+(b*b));
		if(d>((r*r)+(g*g)+((b-255)*(b-255))))ans="blue",d=((r*r)+(g*g)+((b-255)*(b-255)));
		if(d>((r*r)+((g-255)*(g-255))+(b*b)))ans="lime",d=((r*r)+((g-255)*(g-255))+(b*b));
		if(d>((r*r)+((g-255)*(g-255))+((b-255)*(b-255))))ans="aqua",d=((r*r)+((g-255)*(g-255))+((b-255)*(b-255)));
		if(d>((r-255)*(r-255))+(g*g)+(b*b))ans="red",d=((r-255)*(r-255))+(g*g)+(b*b);
		if(d>((r-255)*(r-255))+(g*g)+((b-255)*(b-255)))ans="fuchsia",d=((r-255)*(r-255))+(g*g)+((b-255)*(b-255));
		if(d>((r-255)*(r-255))+((g-255)*(g-255))+(b*b))ans="yellow",d=((r-255)*(r-255))+((g-255)*(g-255))+(b*b);
		if(d>((r-255)*(r-255))+((g-255)*(g-255))+(b-255)*(b-255))ans="white";
		
		cout<<ans<<endl;
		
		}
		return 0;
	}

Measured memory_bytes: 3060