akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; 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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string s) {
  cout << s.at(0) << sz(s) - 2 << s.at(sz(s) - 1) << endl;
}

int main() {
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}


Measured memory_bytes: 256
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb emplace_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int mod = (int)1e9 + 7;
//const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/
const int  N = 1e6+1;
vector<int> sieve(N+7,1);
void fun()
{
    sieve[0] =0;
    sieve[1] = 0;
    for(int i=2;i*i<=N;++i)
    {
        if(sieve[i])
        {
            for(int j=i*i;j<=N;j+=i)
            {
                sieve[j] = 0;
            }
        }
    }
}
int modExpo(int x,int y){
  int res = 1;
  while(y > 0){
    if(y&1)
      res = (res*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
  }
  return res;
}
int32_t main() 
{
    fastio
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n&1)
    {
        cout<<"No";
        return 0;
    }
    if(s.substr(0,n/2)==s.substr(n/2,n/2))
        cout<<"Yes"<<el;
    else
        cout<<"No"<<el;
    
    return 0;
}



Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main() {
	int n,i,j,kara,made,flag;
	flag = 0;
	cin >> n;
	for (i = 0;i < n;i++) {
		cin >> kara >> made;
		for (j = kara;j <= made;j++) {
			flag = flag + 1;
		}
	}
	cout << flag << endl;
}

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

int main(){
  string s;
  int zero_counter,one_counter;
  int i,slength,answer;
  cin >> s;
  zero_counter = 0;
  one_counter = 0;
  slength = s.size();
  for(i = 0;i<slength;i++)
    {
      if(s[i] == '0')
	{
	  zero_counter = zero_counter + 1;
	}
      else
	{
	  one_counter = one_counter + 1;
	}
    }
  if( one_counter < zero_counter )
    {
      answer = one_counter * 2;
    }
  else
    {
      answer = zero_counter * 2;
    }
  cout << answer << endl;
}


Measured memory_bytes: 512
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

typedef long long ll;

bool nonNegative(ll x) {
    return x >= 0;
}

struct linie {
    vector <pair <long long, long long>> T;
    int poz = 0;
    
    void insert(long long a, long long b) {
        int sz = T.size();
        while (sz - poz > 1) {
            if (!nonNegative((b - T[sz - 2].second) * (T[sz - 2].first - T[sz - 1].first) - 
                 (T[sz - 1].second - T[sz - 2].second) * (T[sz - 2].first - a))) {
                T.pop_back();
                sz--;
            }
            else break;
        }
        T.push_back({a, b});
    }
    
    long long query(int h) {
        long long war = 1e18;
        int sz = T.size();
        if (poz < sz) war = T[poz].first * h + T[poz].second;
        while (poz + 1 < sz) {
            long long nwar = T[poz + 1].first * h + T[poz + 1].second;
            if (nwar <= war) {
                poz++;
                war = nwar;
            }
            else break; 
        }
        return war;
    }
};

const int N = 2e5 + 7;
long long C;
int h[N];
int n;
long long dp[N];

int main() {
    scanf("%d %lld", &n, &C);
    for (int i = 1; i <= n; ++i) scanf("%d", h + i);
    
    linie X;
    
    for (int i = 1; i <= n; ++i) {
        if (i == 1) dp[i] = 0;
        else {
            dp[i] = X.query(h[i]) + C + 1ll * h[i] * h[i];
        }
        
        X.insert(-2 * h[i], dp[i] + 1ll * h[i] * h[i]);
    }
    printf("%lld\n", dp[n]);
    return 0;
}


Measured memory_bytes: 8176
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def enum_divisors(n):
    # 約数列挙

    divisors = []

    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():
    n = int(readline())
    divs = enum_divisors(n)
    ans = 0

    for x in divs:
        m = n // x - 1
        if n - m * x < m:
            ans += m

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65552
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    ll R, G, B, n;
    cin >> R >> G >> B >> n;
    ll ans = 0;
    for(ll i = 0; i*R <= n; i++){
        for(ll j = 0; i*R+j*G <= n; j++){
            if((n-i*R-j*G)%B == 0){
                //cout << i << " " << j << " " << n-i*R-j*G << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}




int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int K; cin >> K; string S;cin>>S;
	if(S.size() <= K) out(S);
	else{
		string ans = S.substr(0,K);
		ans += "...";
		out(ans);
	}

}

Measured memory_bytes: 3644
n, m = [int(v) for v in input().split()]
#print(n, m)
gates = [[int(v) for v in input().split()] for i in range(m)]
#print(gates)
left = max(gates, key=lambda x: x[0])[0]
right = min(gates, key=lambda x: x[1])[1]
if left <= right:
  print(right - left + 1)
else:
  print(0)

Measured memory_bytes: 21156
#include <stdio.h>

int main(){
    int d,s;
    int i;
    while(scanf("%d",&d)!=EOF){
        s = 0;
        for(i=1;d*i<600;i++){
            s += d*(d*i)*(d*i);
        }
        printf("%d\n",s);
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct node{
    int num; //ノードに書かれた数
    int right,left;//子のindex
};

struct node v[2][1000];

vector<string> s(2);
vi num(2);
void f(int ind, int l, int r){
    int st = 0;
    int sum = 0;
    int no = num[ind];

    for(int i = l; i <= r; i++){
        if(s[ind][i] == '('){
            st++;
        }
        if(s[ind][i] == ')'){
            st--;
        }
        if(s[ind][i] == '[' && st == 0){
            num[ind]++;
            v[ind][no].left = num[ind];
            f(ind, l+1, i-2);
        }
        if(s[ind][i] == ']' && st == 0){
            num[ind]++;
            v[ind][no].right = num[ind];
            v[ind][no].num = sum;
            f(ind, i+2, r-1);
        }
        if(isdigit(s[ind][i]) && st == 0){
            sum *= 10;
            sum += s[ind][i] - '0';
        }
    }

}

string g(int a, int b){
    string ret = "";

    ret += "(";
    if(v[0][v[0][a].left].num >= 0 && v[1][v[1][b].left].num >= 0){
        ret += g(v[0][a].left, v[1][b].left);
    }
    ret += ")";

    ret += "[";
    ret += to_string(v[0][a].num + v[1][b].num);
    ret += "]";

    ret += "(";
    if(v[0][v[0][a].right].num >= 0 && v[1][v[1][b].right].num >= 0){
        ret += g(v[0][a].right, v[1][b].right);
    }
    ret += ")";

    return ret;
}

int main(void) {
    int i,j;
    cin >> s[0];
    cin >> s[1];

    rep(i,2)rep(j,1000) v[i][j].num = v[i][j].right = v[i][j].left = -1;

    f(0,0,s[0].size()-1);
    f(1,0,s[1].size()-1);


    cout << g(0,0) << endl;

}



Measured memory_bytes: 3304
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]#(行き先、容量、逆辺の参照)
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow
N = int(input())
a = list(map(int, input().split()))
D = Dinic(N+2)
inf = 10**18
profit = 0
cost = 0
for i in range(N):
    if a[i]>=0:
        D.add_edge(i, N+1, a[i])
    else:
        D.add_edge(N, i, -a[i])
        cost+=a[i]
    profit+=abs(a[i])
    

for i in range(1, N+1):
    for k in range(2, N//i+1):
        D.add_edge(i-1, i*k-1, inf)
f = D.flow(N, N+1)
print(profit-f+cost)
    

Measured memory_bytes: 41196
#include<stdio.h>
int main(){
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long ans=(n/(a+b))*a;
	if(n%(a+b)<=a) ans+=n%(a+b);
	else ans+=a;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int d = sc.nextInt();
        int n = sc.nextInt();
        int ans = n;
        int num = 0;
        num = (int)Math.pow(100, d);
        ans = num * n;
        if(n == 100){
        	System.out.println(ans + num);
        }else{
        	System.out.println(ans);
        }
    }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];
    vector<int> dp(110000, 1001001001);
    dp[0] = 0;
    for (int j = 0; j < n; ++j) {
        for (int i = 1; i <= k; ++i) {
            dp[j + i] = min(dp[j + i], dp[j] + abs(h[j + i] - h[j]));
        }
    }
    cout << dp[n - 1] << endl;
}


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

using namespace std;

int main()
{
  vector<pair<double, int> > v;
  vector<double> w =  { 0.25, 0.5, 1.0, 2.0 };
  vector<int> x;
  for ( int i = 0; i < 4; i++ ) {
    int t;
    cin >> t;
    v.push_back( make_pair( t / w[i], i ) );
    x.push_back( t );
  }

  long long n;
  cin >> n;

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

  long long c = 0;
  for ( auto& e : v ) {
    long long a = n / w[e.second];
    n -= a * w[e.second];
    c += a * x[e.second];
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif


struct UnionFind{
    // par[i] parent. if i == par[i] i is root
    vector<ll> par;
    // sizes[i] sizeof tree i if i is root
    vector<ll> sizes;

    UnionFind(ll n) : par(n), sizes(n, 1){
        // init: all node is root i
        rep(i, n) par[i] = i;
    }

    // find root of x
    ll find(ll x){
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // recursive, editing root
    }

    // merge x, y
    void unite(ll x, ll y){
        // root
        x = find(x);
        y = find(y);

        // do not merge if same tree
        if (x == y)
            return;

        // force size x > y
        if (sizes[x] < sizes[y])
            swap(x, y);

        // unite: x is parent of y
        par[y] = x;
        sizes[x] += sizes[y];
    }

    // x, y same root
    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    // size of tree containing x
    ll size(ll x){
        return sizes[find(x)];
    }
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll p(n);
    rep(i, n){
        cin >> p[i];
    }
    vll x(m), y(m);
    UnionFind uf(n+1);
    rep(i, m){
        cin >> x[i] >> y[i];
        uf.unite(x[i], y[i]);
    }
    ll ans = 0;
    rep(i, n){
        ans += uf.same(i+1, p[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    int n;
    
    cin >> n;
    
    if(n%2 ==0) cout<<0.5<<endl;
    
    else{
        double a = (n+1.0)/(2*n);
        cout<<setprecision(12)<<a<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main(){
   int N,L;
   cin>>N>>L;
   vector<string>S(N);
   rep(i,N){
       cin>>S[i];
   }
   sort(S.begin(),S.end());
   rep(i,N){
       cout<<S[i];
   }
   cout<<""<<endl;
}

Measured memory_bytes: 3608
INFTY = 100000000
n = int( raw_input() )
graph = {}
for i in range(n):
  In = map( int , raw_input().split(' ') )
  u = In[0]
  k = In[1]
  graph[u] = {}
  for j in range(k):
    v = In[2+j*2]
    c = In[2+j*2+1]
    graph[u][v] = c
 
da = {}
visited = {}
for i in range(n):
  da[i] = INFTY
  visited[i] = False
s = 0
da[s] = 0
visited[s] = True
 
while True:
  for i in range(n):
    if not visited[i] and i in graph[s] and da[i] > da[s] + graph[s][i]:
      da[i] = da[s] + graph[s][i]
  cost = INFTY
  node = -1
  for i in range(n):
    if not visited[i] and da[i] < cost:
      cost = da[i]
      node = i
  if cost == INFTY: 
    break
  visited[node] = True
  s = node
  
for i in range(n):
  print i,da[i]

Measured memory_bytes: 6652
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
for i in range(N):
  if A[i]%2 == 0:
    if A[i]%3 != 0  and A[i]%5 != 0:
      print("DENIED")
      exit()
      
print("APPROVED")

Measured memory_bytes: 5148
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 500005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
 
int n, k, ans;
int a[10005], tp;
bitset<5005> f, w;
int main(){
	int i, j, x, l, r, mid;
	n = read(), k = read();
	for(i = 1;i <= n;i++){
		 a[++tp] = read();
		 if(a[tp] >= k) tp--;
	}
	sort(a + 1, a + tp + 1);
	l = 1, r = tp; 
	for(i = tp + 1;i <= 2 * tp;i++) a[i] = a[i - tp];
	while(l <= r){
		f = w, f[0] = 1;
		mid = l + r >> 1;
		for(j = mid + 1;j <= mid + tp - 1;j++) 
			f |= f << a[j];
		bool flag = 0;
		for(j = k - a[mid];j < k;j++) if(f[j]) {flag = 1;break;}
		if(!flag) ans = mid, l = mid + 1; 
		else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  long long n;
  string s;
  cin >> n >> s;
  long long cnt = n;
  for (int i = 0;i < n-1;i++){
    if (s[i] == s[i+1]) cnt--;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
const LL INF = 1ll<<60;
int n,m,a[10050],b[10050];
LL dp[10050];
int main(){
	int i,j;
	read(m),read(n);
	for (i = 1; i <= n; ++i) read(a[i]),read(b[i]);
	for (i = 1; i <= m+1; ++i) dp[i] = INF; dp[0] = 0;
	for (i = 1; i <= n; ++i){
	//	for (j = 0; j <= m; ++j) cout << dp[j] << ' '; cout << endl; 
		for (j = 1; j <= m; ++j) dp[j] = min(dp[j],dp[max(0,j-a[i])]+b[i]);

	}
	cout << dp[m] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define CTOI(x) (x - 'A') 
#define ctoi(x) (x - 'a')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;
}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum) % MOD;
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int count(int x){
    int res = 0;
    while(x){
        res += x & 1;
        x>>=1;
    }
    return res;
}

class pease{
    public:
        int w;
        int h;
        int id;
};

bool compare(const pease &a, const pease &b){
    return a.id < b.id;
}

int main(){
    int N, W, H;
    while(cin >> N >> W >> H && W){
        vector<pease> peases;
        pease hoge;
        hoge.w = W;
        hoge.h = H;
        hoge.id = 0;
        peases.push_back(hoge);
        REP(i, N){
            int p, s;
            cin >> p >> s;
            --p;
            pease d = peases[p];
            peases.erase(peases.begin() + p);
            sort(ALL(peases), compare);
            REP(i, peases.size())peases[i].id = i;
            s = s % (d.w + d.h);
            if(s < d.w){
                pease a;
                pease b;
                a.h = b.h = d.h;
                a.w = d.w - s;
                b.w = s;
                if(a.w * a.h < b.w * b.h){
                    a.id = 1000;
                    b.id = 1001;
                    peases.push_back(a);
                    peases.push_back(b);
                }else{
                    a.id = 1001;
                    b.id = 1000;
                    peases.push_back(a);
                    peases.push_back(b);
                }
            }else{
                pease a;
                pease b;
                a.w = b.w = d.w;
                a.h = d.h - s + d.w;
                b.h = s - d.w;
                if(a.w * a.h < b.w * b.h){
                    a.id = 1000;
                    b.id = 1001;
                    peases.push_back(a);
                    peases.push_back(b);
                }else{
                    a.id = 1001;
                    b.id = 1000;
                    peases.push_back(a);
                    peases.push_back(b);
                }
            }
            sort(ALL(peases), compare);
            REP(i, peases.size())peases[i].id = i;
        }
        vector<int> ans;
        REP(i, peases.size())ans.push_back(peases[i].w * peases[i].h);
        sort(ALL(ans));
        REP(i, N+1){
            cout << ans[i] << (i==N?'\n':' ');
        }
    }
    return 0;
}



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

int main()
{
    char x, y;
    
    cin >> x >> y;
    
    if(int(x) == int(y)) {
        cout << "=\n";
    } else if(int(x) > int(y)) {
        cout << ">\n";
    } else {
        cout << "<\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;



int main(){
    string s;
    cin >> s;
    int ans=700;
    for(int i=0;i<3;i++){
        if(s[i]=='o') ans+=100;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a <= c && c <= b ? "Yes" : "No") << endl;
}

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

using namespace std;

int main() {
  int n, ans = 0;
  cin >> n;
  int l[n], r[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    ans += (r[i] - l[i] + 1);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

static const int N = 10005;

struct vertex {
	int id;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

struct edge {
	int end;
	int w;
};

int main() {
	int n;
	cin >> n;
	vector<vector<edge>> E(N);
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(i, k) {
			int v, c;
			cin >> v >> c;
			E[u].push_back({ v,c });
		}
	}

	priority_queue<vertex> pq;
	vi color(N, 0), dist(N, 0);     //!
	pq.push({ 0,0 });
	int cnt = 0;
	while (pq.size() > 0) {
		if (cnt == n) break;
		vertex v = pq.top();
		pq.pop();
		if (color[v.id] == 1) continue;
		dist[v.id] = v.d;
		color[v.id] = 1;
		cnt++;
		Loop(j, E[v.id].size()) {
			if (color[E[v.id][j].end] != 1) {
				pq.push({ E[v.id][j].end, dist[v.id] + E[v.id][j].w });
			}
		}
	}
	Loop(i, n) {
		cout << i << " " << dist[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 9980
import kotlin.math.abs

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    val sums = Array(n + 1) { 0L }
    for (i in 1..n) sums[i] = sums[i - 1] + a[i - 1]

    var ans = 1e18.toLong()

    var x = 1
    var z = 3
    for (y in 2..n - 2) {
        while (true) {
            val cur = abs(sums[x] - (sums[y] - sums[x]))
            val next = abs(sums[x + 1] - (sums[y] - sums[x + 1]))
            if (cur > next) x++
            else break
        }

        while (true) {
            val cur = abs((sums[z] - sums[y]) - (sums[n] - sums[z]))
            val next = abs((sums[z + 1] - sums[y]) - (sums[n] - sums[z + 1]))
            if (cur > next) z++
            else break
        }

        val cuts = listOf(sums[x], sums[y] - sums[x], sums[z] - sums[y], sums[n] - sums[z])
        ans = minOf(ans, cuts.max()!! - cuts.min()!!)
    }

    println(ans)
}

Measured memory_bytes: 75736
#include <iostream>
#include <string>

using namespace std;

int main()
{
	while(1){
		string s("");
		cin >> s;
		if(s.empty())
			break;
		
		int p1 = 0, q1 = 0; 
		int JOI=0, IOI=0;
		for(int i=0; i<s.size(); i++){
			string::size_type p = s.find("JOI", p1);
			if(p != string::npos){
				p1 = p+2;
				++JOI;
			}
			string::size_type q = s.find("IOI", q1);
			if(q != string::npos){
				q1 = q+2;
				++IOI;
			}
			if(p == string::npos && q == string::npos)
				break;
		}
		std::cout << JOI << "\n" << IOI << std::endl;
	}
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 1000000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    if (x * y == 1)
    {
        cout << "No\n";
        return 0;
    }
    int X = (1000000000 % (x * y - 1) != 0 ? 1000000000 / (x * y - 1) : 999999999 / (x * y - 1));
    int a[n][m];
    rep(i, 0, n)
        rep(j, 0, m)
            if (i % x == x - 1 && j % y == y - 1)
                a[i][j] = -(x * y - 1) * X - 1;
            else
                a[i][j] = X;
    ll sum = 0;
    rep(i, 0, n)
        rep(j, 0, m)
            sum += a[i][j];
    if (sum > 0)
    {
        cout << "Yes\n";
        rep(i, 0, n)
        {
            rep(j, 0, m)
                cout << a[i][j] << " ";
            cout << endl;
        }
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
int prime[1300001];

void isprime(void){
    int i,j,n,c;

    for(i = 4;i<1300001;i += 2)prime[i] = 1;

    for (i = 3;i * i <= 1300001;i += 2){
        if (prime[i] == 0){
            for (j = i + i; j <= 1300001; j += i){
                prime[j] = 1;
            }
        }
    }
}

int main(void){
    int n,i,a;
     
    isprime();
    
    while (scanf("%d",&n),n){
        a = 0;
        for (i = n; prime[i]; i++)a++;
        for (i = n; prime[i]; i--)a++;
        printf("%d\n", a);
    }
     
    return (0);
}

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

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;

    if (k < s.size()) {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "..." << endl;
    } else {
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
H, W, M = map(int, input().split())

countW = [0]*(W+1)
countH = [0]*(H+1)
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    bomb.append((h, w))
    countH[h] += 1
    countW[w] += 1

maxW = max(countW)
maxH = max(countH)
ans = maxW + maxH - 1
countMaxW = countW.count(maxW)
countMaxH = countH.count(maxH)

sumz = 0
for i in range(M):
    h, w = bomb[i]
    if countH[h] == maxH and countW[w] == maxW:
        sumz += 1

if countMaxW*countMaxH > sumz:
    ans += 1
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pii pair<int,int>
#define pll pair<ll, ll>
#define forn(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007


int vis[100005];
ll dis[100005];
vector<int> a[100005];
vector<int> s;

int dfs(int pos){
	vis[pos] = 1;
	for(int v : a[pos]){
		if(vis[v] == 0){
			dfs(v);
		}
	}
	s.pb(pos);
}


int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	forn(i, 0, m - 1){
		int u, v;
		cin >> u >> v;
		a[u].pb(v);
	}
	forn(i, 1, n){
		if(vis[i] == 0) dfs(i);
	}
	ll ans = 0;
	forn(i, 0, n - 1){
		for(int v : a[s[i]]){
			dis[s[i]] = max(dis[s[i]], dis[v] + 1);
		}
		ans = max(ans, dis[s[i]]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 9464
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long int llint;
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	string N;
	cin >> N;
	if (N[0] == '9' || N[1] == '9')cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    
    int a[3];
    rep(i,3){
        cin>>a[i];
    }
    if(a[0]==a[1]){
        cout<<a[2]<<endl;;
    }else if(a[2]==a[1]){
        cout<<a[0]<<endl;
    }else if(a[0]==a[2]){
        cout<<a[1]<<endl;
    }
    
    
    
return 0;
}


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


struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;


void insert(int);
void delete(int);
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
NodePointer find(int);
NodePointer make_1node();
void ListPrint();


NodePointer nil; 


int main () {
  char str[15];
  int n = 0, i, x = 0;

  nil = make_1node(); //二分木の場合

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf("%s",str);
    //scanf("%d",&x);
    //printf("i = %d\n", i);
    //scanf("%s%d", str, &x);
    if(strcmp(str, "insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(str, "delete") == 0) {
      scanf("%d",&x);
      delete(x);
    }
    else if(strcmp(str, "deleteFirst") == 0) deleteFirst();
    else if(strcmp(str, "deleteLast") == 0) deleteLast();

    //ListPrint();
  }

  ListPrint();

  
  return 0;
}

void insert(int key) {
  NodePointer p;

  p = (NodePointer)malloc(sizeof(struct node));
  p->key = key;
  
  p->next = nil->next;
  nil->next->prev = p;
  nil->next = p;
  p->prev = nil;
  
}


NodePointer find(int key) {
  NodePointer n;

  for(n = nil->next ; n != nil ; n = n->next) {
    if(n->key == key) return n;
  }

  return NULL;
}


NodePointer make_1node() {
  NodePointer n;

  if((n = (NodePointer)malloc(sizeof(struct node))) == NULL) {
    exit(8);
  }

  n->next = n;
  n->prev = n;

  return n;
}

void delete(int key) {
  NodePointer n;
  n = find(key);

  if(n != NULL) {
    deleteNode(n);
  }
}

void deleteNode(NodePointer t) {
  //printf("key:%d\n", t->key);
  if(t != nil) {
    t->prev->next = t->next;
    t->next->prev = t->prev;
    
    free(t);
  }
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  //printf("last\n");
  deleteNode(nil->prev);
}


void ListPrint() {
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}



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

const int MAX_N = 1e5;
int N, M;
int used[MAX_N+5];
vector<vector<int>> E(MAX_N+5);
deque<int> ans;

int main(){
    scanf("%d %d", &N, &M);
    for(int i=0;i<M;i++){
        int a, b; scanf("%d %d", &a, &b);
        E[a].push_back(b); E[b].push_back(a);
    }

    ans.push_back(1); used[1]++;
    while(1){
        bool ok = true;
        int v = ans.front();
        for(int i=0;i<E[v].size();i++){
            if(!used[E[v][i]]){
                ans.push_front(E[v][i]); used[E[v][i]]++;
                ok = false; break;
            }
        }

        if(ok) break;
    }

    while(1){
        bool ok = true;
        int v = ans.back();
        for(int i=0;i<E[v].size();i++){
            if(!used[E[v][i]]){
                ans.push_back(E[v][i]); used[E[v][i]]++;
                ok = false; break;
            }
        }

        if(ok) break;
    }

    printf("%d\n", ans.size());
    for(int it : ans) printf("%d ", it);
    printf("\n");
    return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i < (b); i++)
ll modi = 1000000007;

bool cp(ll n){
    if(n == 1)return false;
    else if(n == 2)return true;
    else if(n ==3)return true;
    for(int i  = 2; i*i<=n; i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}
void SforPrime(int n)
{
	bool prime[n+1];
	memset(prime, true, sizeof(prime));

	for (int p=2; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*p; i<=n; i += p)
				prime[i] = false;
		}
	}
}
ll calPower(ll val, ll n){
    ll i = 1;
    ll ind = 1;
    ll prev = val;
    while(val<=n){
        if(n%val == 0)ind = i;
        val  = val*prev;
        i++;
    }
    return i-1;
}
bool check(ll val, int vec[]){
    while(val != 0){
        ll rem = val %10;
        if(vec[rem] == 1)return false;
        val /= 10;
    }
    return true;
}
int main(){
    //130016239756757
    string s;
    cin>>s;
    string str;
    rep(i, 0, s.size()){
        if(s[i] == 'B'){
            if(str.size() != 0){
                str =str.substr(0, str.size()-1); 
            }
        }
        else if(s[i] == '0'){
            str += '0';
        }
        else {
            str += '1';
        }
    }
    cout<<str<<endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

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

    ll n, h, w;
    for(n = 1; n <= 3500; ++n) {
        for(h = 1; h <= 3500; ++h) {
            ll c = N * n * h;
            ll m = 4 * n * h - N * n - N * h;
            if(m <= 0) { continue; }
            if(c % m == 0) {
                w = c / m;
                printf("%lld %lld %lld\n", h, n, w);
                return 0;
            }
        }
    }
    printf("%lld %lld %lld\n", h, n, w);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
vector<int> edge[10];
bool vis[10] = {false};
int ans = 0;
int n, m, a, b;

void dfs(int t, int d)
{
	if(d == n)	
	{
		ans++;
		return;
	}
	for(int i = edge[t].size() - 1; i >= 0; --i)
	{
		int now = edge[t][i];
		if(vis[now] == false)
		{
			vis[now] = true;
			dfs(now, d + 1);
			vis[now] = false;
		}
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		scanf("%d%d", &a ,&b);
		edge[a].push_back(b);
		edge[b].push_back(a);	
	}
	vis[1] = true;
	dfs(1, 1);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int main(){
	int n,c[2]={};
	vector<int> a,ans;
	cin>>n;
	rep(i,n){
		int d;
		cin>>d;
		if(d>=2) a.pb(d);
		else c[d]++;
	}
	sort(all(a),greater<int>());
	if(c[1]==0&&c[0]%2==1){
		if(a.size()==0){
			rep(i,c[0]) cout<<0<<endl;
			return 0;
		}else{
			int mn=a[a.size()-1];
			c[min(1,mn)]--;
			a.erase(a.end()-1);
			ans.pb(0);
			ans.pb(mn);
			rep(i,c[0]-1) ans.pb(0);
		}
	}else if(c[0]%2==0){
		rep(i,c[1]) ans.pb(1);
		rep(i,c[0]) ans.pb(0);
	}else{
		rep(i,c[1]-1) ans.pb(1);
		ans.pb(0);
		ans.pb(1);
		rep(i,c[0]-1) ans.pb(0);
	}
	if(a.size()<=1){
		rep(i,a.size()) ans.pb(a[i]);
	}else{
		if(a[0]==3&&a[1]==2) swap(a[0],a[1]);
		rep(i,a.size()) ans.pb(a[i]);
	}
	rep(i,ans.size()) cout<<ans[ans.size()-1-i]<<endl;
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,k,l;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++){
		cin >> l;
		v[i] = l;
	}
	sort(ALL(v));
	int ans = 0;
	for (int i = 0; i < k; i++){
		ans+= v[n - 1 - i];
	}
	cout << ans <<endl;
	
	
	return 0;
}

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

int main()
{
	string edit;
	int r,l;
	bool turn=false;
	int ans=0;
	int tmp=0;
	while(1)
	{
		cin>>edit;
		if(edit=="#")
			break;
		//最初のノーツを右足で踏むケース
		turn=false;
		r=edit[0]-'0';
		ans=1e8-1;
		tmp=0;
		for(int i=1;i<edit.size();i++)
		{
			//左
			if(i&1)
			{
				l=edit[i]-'0';
				if((!turn && (l-1)%3>(r-1)%3)||(turn && (l-1)%3<(r-1)%3))
				{
					//cerr<<i<<" "<<(l-1)%3<<" "<<(r-1)%3<<" "<<turn<<endl;
					turn^=true;
					tmp++;
				}
			}else{
				//右
				r=edit[i]-'0';
				if((!turn && (l-1)%3>(r-1)%3)||(turn && (l-1)%3<(r-1)%3))
				{
					//cerr<<i<<" "<<(l-1)%3<<" "<<(r-1)%3<<endl;
					turn^=true;
					tmp++;
				}
			}
		}
		//cerr<<tmp<<" ";
		ans=min(tmp,ans);
		tmp=0;
		//最初のノーツを左足で踏むケース
		l=edit[0]-'0';
		turn=false;
		for(int i=1;i<edit.size();i++)
		{
			//右
			if(i&1)
			{
				r=edit[i]-'0';
				if((!turn && (l-1)%3>(r-1)%3)||(turn && (l-1)%3<(r-1)%3))
				{
					//cerr<<i<<" "<<(l-1)%3<<" "<<(r-1)%3<<endl;
					turn^=true;
					tmp++;
				}
			}else{
				//左
				l=edit[i]-'0';
				if((!turn && (l-1)%3>(r-1)%3)||(turn && (l-1)%3<(r-1)%3))
				{
					//cerr<<i<<" "<<(l-1)%3<<" "<<(r-1)%3<<endl;
					turn^=true;
					tmp++;
				}
			}
		}
		//cerr<<tmp<<endl;
		ans=min(ans,tmp);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3276
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int n,k;scanf("%d%d",&n,&k);
   int ans=1;
   for(int i = 0;i < n;i++){
      ans=MIN(ans+k,ans*2);
   }
   printf("%d",ans);
}

Measured memory_bytes: 128
n,C=list(map(int,input().split()))
part=[[0]*(3*10**5) for _ in range(31)]
part2=[0]*(3*10**5)

for _ in range(n):
    s,t,c=list(map(int,input().split()))

    part[c][s]+=1
    part[c][t]-=1

for i in range(1,C+1):
    for j in range(1,10**5+1):
        if part[i][j]==1:
            part2[2*j-1]+=1
        elif part[i][j]==-1:
            part2[2*j]-=1

ans=0
for i in range(1,2*10**5+1):
    part2[i]+=part2[i-1]
    ans=max(ans,part2[i])

print(ans)

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

count = 0
is_true = False
for i in range(n):
    d1, d2 = list(map(int, input().split()))

    if d1 == d2:
        count = count + 1
    else:
        count = 0
    if count >= 3:
        is_true = True

if is_true:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int n, w;
    cin >> n >> w;
    // w = w+1;
    // n = n+1;
    long long int item[n+1];
    long long int wt[n+1];
    item[0] = 0;
    wt[0] = 0;

    for(int i = 1;i<n+1;i++)
        cin >> item[i] >> wt[i];

    long long int dp[n+1][w+1];
    for(int i = 0;i<n+1;i++)
        for(int j = 0;j<w+1;j++) {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else {
                if(j >= item[i])
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j-item[i]] + wt[i]);
                else
                    dp[i][j] = dp[i-1][j];
            }
        }
    cout << dp[n][w] << endl;
}

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

int a[10];
int main(){
	int n;
	cin>>n;
	int i = 0;
	while(n)
	{
		a[++i] = n % 10;
		n = n / 10;
	}
	for(int i = 1;i <= 2;i++)
	{
		if(a[i] == a[i + 1] && a[i] == a[i + 2])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int siz = s.size();
  int m,answer;
  m = 0;
  answer = 0;
  for(int i = 0;i < siz;i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      m++;
      if(answer < m)answer = m;
    }else{
      m = 0;
    }
  }
  cout << answer << endl;
}
      
      

Measured memory_bytes: 256