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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> dist(h, vector<int>(w, INF));
  queue<P> q;

  auto update = [&](P now) {
    int i=now.first, j=now.second;
    rep(k, 4) {
      int ni=i+di[k], nj=j+dj[k];
      if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if(dist[ni][nj] == INF && s[ni][nj] == '.') {
        dist[ni][nj] = dist[i][j]+1;
        q.push(make_pair(ni, nj));
      }
    }
  };

  dist[0][0] = 1;
  q.push(make_pair(0, 0));

  while(!q.empty()) {
    P now = q.front(); q.pop();
    update(now);
  }

  int black = 0;
  rep(i, h) rep(j, w) if(s[i][j] == '#') ++black;
  if(dist[h-1][w-1] == INF) cout << -1 << endl;
  else cout << h*w-dist[h-1][w-1]-black << endl;
}

Measured memory_bytes: 3628
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, K = mi()
maxK = (N-1)*(N-2)//2

if K>maxK:
  print(-1)
  exit()

edges = [] #答えの配列


#N個の頂点について、1番に2～N番をくっつける辺をつくる（うにグラフ作成）
for i in range(2,N+1):
  edges.append((1,i))


#この時点で、K'の数は(N-1)(N-2)/2（最大値）。
now_k_num = ((N-1)*(N-2))//2

#now_k_num - K 分だけ、うにグラフの針同士を繋いで、K'の数を減らす
cnt = 0 #すでに減らした辺の数を入れる
for i, j in combinations(range(2, N+1),2): #針(2~N番)の組み合わせを列挙
  if cnt >= now_k_num - K: #既に必要数の辺を増やし終わっていたら
    break
  else:
    edges.append((i,j))
    cnt += 1

print(len(edges))
for i, j in edges:
  print(i, j)



Measured memory_bytes: 43376
from math import ceil
A, B = map(int,input().split())

def non_taxed_price_8(x):
    min_8 = x/0.08
    Max_8 = (x+1)/0.08
    eight = set(range(ceil(min_8), ceil(Max_8)))
    return eight

def non_taxed_price_10(x):
    min_10 = x/0.1
    Max_10 = (x+1)/0.1
    ten = set(range(ceil(min_10), ceil(Max_10)))
    return ten

a = non_taxed_price_8(A)
b = non_taxed_price_10(B)

r = a&b
if len(r) == 0:
    print(-1)
else:
    print(min(list(r)))


Measured memory_bytes: 3064
get_string(String) :- current_input(Input),
  read_string(Input, ' \n', '', _, String).
     
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

fiz(N) :- K is N mod 3,K=\=0,A is N mod 5, A =\= 0.

solve(N,N,0).
solve(A,N,Sum) :- fiz(A),A1 is A+1,solve(A1,N,Sum1),Sum is Sum1+A.
solve(A,N,Sum) :- A1 is A+1,solve(A1,N,Sum).

main :- get_number(N),NN is N+1,solve(1,NN,S),writeln(S).




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

vector<vector<double>> dp(3000+1,vector<double>(3000+1,-1));
vector<double> p(3001, 0);

double solve(int n, int h) {
    if (h<0) 
        return 0.0;
    if (n==0) 
        return h==0;
    if (dp[n][h]!=-1) 
        return dp[n][h];
    return dp[n][h]=p[n]*solve(n-1,h-1)+(1-p[n])*solve(n-1,h);
}

int main() {
    int n;
    cin >> n;
    for (int i=1;i<=n;i++) cin >> p[i];
    double tot=0;
    for (int i=0;i<=n;i++) if (2*i>n)
        tot+=solve(n, i);
    cout << setprecision(9);
    cout << tot;
    return 0;
}

// f(n,h)=p[n]*f(n-1,h-1) + (1-p[n])*f(n-1,h)
// f(0,h)=0
// f(n,0)=


Measured memory_bytes: 74484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDivideTheProblems solver = new CDivideTheProblems();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDivideTheProblems {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            ArrayList<Integer> a = new ArrayList<>();
            for (int i = 0; i < n; i++) a.add(in.nextInt());
            if (n % 2 == 1) {
                out.println(0);
                return;
            }
            Collections.sort(a);
            out.println(a.get(n / 2) - a.get(n / 2 - 1));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 38604
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1000000007;

vector<int> G[100001];
bool vsd[100001];

ll K;
ll ans;

void dfs(int n){
  //cout << n << " " <<  ans << endl;
  int cnt = 1;
  for(int i = 0; i < G[n].size(); i++){
    if(vsd[G[n][i]]) cnt++;
  }

  for(int i = 0; i < G[n].size(); i++){
    int v = G[n][i];
    if(!vsd[v]){
      ans *= (K - cnt);
      ans %= MOD;
      cnt++;
      vsd[v] = true;
      dfs(v);
    }
  }
}

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

  ans = K;
  fill(vsd, vsd + 100001, false);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }

  vsd[0] = true;
  dfs(0);

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


Measured memory_bytes: 9344
#include<stdio.h>
#include<math.h>
#include<string.h>
int max(int a,int b){
   if(a>b) return a;
   return b;
}
int min(int a,int b){
   if(a<b) return a;
   return b;
}
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
   printf("%d",max(a,max(b,c))-min(a,min(b,c)));


}


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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int>& v) {
    if (v.size() == n + 1) {
        int s = 0;
        for (int i = 0; i < q; i++) {
            if (v[b[i]] - v[a[i]] == c[i]) s += d[i];
        }
        ans = max(ans, s);
        return;
    }
    for (int i = v.back(); i <= m; i++) {
        v.push_back(i);
        dfs(v);
        v.pop_back();
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> v(1, 1);
    dfs(v);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << 2*a-1 << "\n";
    }
    else if (b > a) {
        cout << 2*b-1 << "\n";
    }
    else {
        cout << a + b << "\n";
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int arr[200005] , brr[200005];
int main()
{
    int n , i , x = 1;
    cin >> n;
    for(i = 0 ; i < n ; i++) scanf("%d" , &arr[i]);
    if(n == 1)
    {
        cout << 1 << endl;
        exit(0);
    }
    brr[0] = -1;
    brr[1] = min(arr[0] , arr[1]);
    for(i = 2 ; i < n ; i++)
    {
        if(arr[i] < brr[i - 1]) brr[i] = arr[i];
        else brr[i] = brr[i - 1];
        if(arr[i] == brr[i]) x++;
    }
    if(arr[1] == brr[1]) x++;
    cout << x << endl;
    //for(i = 0 ; i < n ; i++) cout << brr[i] << ' ';
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
D = []
ans = 0
for i in range(N):
    D.append(A[i]-B[i])
DMINUS = list(filter(lambda x: x < 0,D))
ans += len(DMINUS)
MINUSSUM = sum(DMINUS)
DPULUS = sorted(filter(lambda x: x > 0,D),key=lambda x: -x)
for d in DPULUS:
    if MINUSSUM >= 0:
        break
    MINUSSUM += d
    ans += 1
if MINUSSUM < 0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 18492
#include<bits/stdc++.h>
using namespace std;
#define cases           int T;cin>>T;for(int TC=1;TC<=T;TC++)
#define FastRead        ios_base::sync_with_stdio(0)
#define power(n,i)      (long long)ceil(pow(n,i))
#define ABS(x)          ((x)<0?-(x):(x))
#define MAX(x,y,z)      max(max(x,y),z)
int mark[100000000];
int v[105];
int c[105];
long long dp[105][100005];
int n,w;
long long call(int i, int weight)
{
    if(i==n)
      return 0;
    if(dp[i][weight]!=-1)
      return dp[i][weight];
 
    long long res1=0,res2=0;
    if(weight-v[i]>=0)
        res1=call(i+1,weight-v[i])+c[i];
    res2=call(i+1,weight);
 
    return dp[i][weight]=max(res1,res2);
}
int main()
{
   
   cin>>n>>w;
   memset(dp,-1,sizeof(dp));
   for(int i=0;i<n;i++)
      cin>>v[i]>>c[i];
   
   cout<<call(0,w)<<endl;
}

Measured memory_bytes: 84224
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N, M; cin >> N >> M;
    set<int> G[200200];
    rep(i, M) {
        int a, b; cin >> a >> b; a --; b --;
        G[a].insert(b);
    }
    rep(j, N) {
        if(j == 0 || j == N - 1) continue;
        if(G[0].find(j) != G[0].end()) {
            if(G[j].find(N - 1) != G[j].end()) {
                cout << "POSSIBLE" << endl;
                return;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 19072
import sys
sys.setrecursionlimit(10**7)
import itertools

# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    k_list = []
    n, m = map(int, input().split())
    for i in range(m):
        row = list(map(int, input().split()))
        k = row[0]
        k_list.append(row[1:])
    p_list = list(map(int, input().split()))

    # print(n, m)
    # print(k_list)
    # print(p_list)

    # 全通り
    n_all_on = 0

    comb = [[0, 1]] * n
    for pattern in itertools.product(*comb):
        pat_on = True
        for iden in range(m):
            p = p_list[iden]
            on_s_iden = 0
            for isw in k_list[iden]:
                on_s_iden += pattern[isw-1]
            if p != on_s_iden % 2:
                pat_on = False
                break

        if pat_on == True:
            n_all_on += 1

    print(n_all_on)


solve()

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
        return 0;
    } else {
        cout << "Impossible" << endl;
        return 0;
    }
}

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

int main()
{
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;
	bool brought[101] = { false };
	brought[a] = true;
	brought[b] = true;
	brought[c] = true;
	int num = 0;
	for(int i = 0; i <= 100; i++){
		num += brought[i]? 1 : 0;
	}
	cout << num << endl;

	return 0;
}

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

bool ok(int x, int sum, vector<int> v) {
    int M = sum - abs(x);
    if (M < 0) return false;
    int N = v.size();
    vector<bool> dp(M + 1);
    dp[0] = true;
    
    rep(i, N) v[i] *= 2;
    
    REP(i, 1, N) if(v[i] > 0){
        rep(k, M + 1) {
            int j = M - k;
            if (j - v[i] < 0) continue;
            dp[j] = dp[j] || dp[j - v[i]];
        }
    }
    return dp[M];
}

signed main() {
    string s; cin >> s;
    int n = s.size();
    vector<vector<int>> v{{0},{0}};
    vector<int> sum{0,0};
    bool ver = false;
    rep(i, n) {
        if (s[i] == 'F') {
            v[ver].back() += 1;
        } else {
            sum[ver] += v[ver].back();
            ver = !ver;
            v[ver].push_back(0);
        }
    }
    sum[ver] += v[ver].back();
    
    int x, y; cin >> x >> y;
    bool ans = ok(x - v[0][0], sum[0] - v[0][0], v[0]) && ok(y, sum[1], v[1]);
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define INF 2000000000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
ll A[MAX_N + 1];
ll colors[MAX_N + 1];

void solve()
{
  deque<int> d;
  REP(i, N)
  {
    int p = lower_bound(d.begin(), d.end(), A[i]) - d.begin();
    if (p == 0) {
      d.push_front(A[i]);
    }
    else {
      d[p - 1] = A[i];
    }
  }
  int ans = d.size();
  cout << ans << endl;
}

int main(void)
{
  cin >> N;
  REP(i, N) cin >> A[i];
  solve();
  return 0;
}


Measured memory_bytes: 1408
W,H,N = map(int, input().split())
XYA = []
for i in range(N):
    XYA.append(list(map(int, input().split())))

a1 = [0]
a2 = [W]
a3 = [0]
a4 = [H]
for x,y,a in XYA:
    if a==1:
        a1.append(x)
    elif a==2:
        a2.append(x)
    elif a==3:
        a3.append(y)
    elif a==4:
        a4.append(y)
        
x_min = max(a1)
x_max = min(a2)
y_min = max(a3)
y_max = min(a4)

ans = 0
if x_max-x_min > 0 and y_max-y_min > 0:
    ans = (x_max-x_min) * (y_max-y_min)

print(max(0,ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

bool dp[6500][26000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w;
    cin >> h >> w;
    vvi a(h,vi(w)),b(h,vi(w));
    rep(i,h) cin >> a[i];
    rep(i,h) cin >> b[i];
    rep(i,6500) rep(j,13000) dp[i][j] = false;
    int fi = abs(a[0][0]-b[0][0]);
    dp[0][13000+fi] = true;
    dp[0][13000-fi] = true;
    rep(i,h) rep(j,w) {
        int pos = i*w+j;
        int now = abs(a[i][j]-b[i][j]);
        rep(k,26000) {
            if(k+now < 26000) {
                if(j > 0) dp[pos][k] |= dp[pos-1][k+now];
                if(i > 0) dp[pos][k] |= dp[pos-w][k+now];
            }
            if(k-now > 0) {
                if(j > 0) dp[pos][k] |= dp[pos-1][k-now];
                if(i > 0) dp[pos][k] |= dp[pos-w][k-now];
            }
        }
    }
    int ans = inf;
    rep(i,26000) if(dp[h*w-1][i]) chmin(ans,abs(13000-i));
    cout << ans << endl;
}


Measured memory_bytes: 164992
#include <iostream>
#include <string>
//#include<set>
using namespace std;
int n, a[110],ans;
//set<string> str;
//string s[201010];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2 != 0)
        {
            ans += 1;
        }else if(a[i] % 3 == 0){
            ans += 1;
        }else if(a[i] % 5 == 0){
            ans += 1;
        }
    }
    if(n == ans){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      intvector vec (3);
      for(int i = 0;i < 3;i++){
          cin >> vec[i];
      }
      SORT(vec);
      cout << vec[0]*vec[1]/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k, l;
  
  ll a, b;
  cin >> a >> b;
  string A=string(a, b+'0');
  string B=string(b, a+'0');
  
  pt(min(A, B));
  
}




Measured memory_bytes: 256
n, M = map(int, input().split())
H = map(int, input().split())
ranking = []
order = [0] * n
good = [1] * n

for num, h in enumerate(H):
    ranking.append((num, h))
ranking.sort(key=lambda x: x[1])
for num, tpl in enumerate(ranking):
    order[tpl[0]] = (num, tpl[1])
#print(ranking, order, good)
for m in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if order[a][1] > order[b][1]:
        good[b] *= 0
    elif order[a][1] < order[b][1]:
        good[a] *= 0
    else:
        good[a] *= 0
        good[b] *= 0
#print(good)
print(sum(good))


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int color[110] = {0};
    color[a] += 1;
    color[b] += 1;
    color[c] += 1;

    int ans = 0;
    for (int i = 1; i <= 100; ++i) {
        if (color[i] != 0) ++ans;
    }

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

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
string s;
int main()
{
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
  return 0;
}


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

class simplecalc {
public:
	int a,b;
	char c;
	int calculation(void);
};

int simplecalc::calculation() {
	if (c == '+')
		return a+b;
	else {
		if (c == '-')
			return a-b;
		else {
			if (c == '*')
				return a*b;
			else {
				if (c == '/')
					return a/b;
				else
					return -1;
			}
		}
	}

}

int main() {
	int i=0, n;
	class simplecalc x[30000];
	cin >> x[i].a >> x[i].c >> x[i].b;

	while (x[i].c=='+' || x[i].c=='-' || x[i].c=='*' || x[i].c=='/') {
		i++;
		cin >> x[i].a >> x[i].c >> x[i].b;
	}
	n = i;
	while (i>0) {
		cout << x[n-i].calculation() << endl;
		i--;
	}
	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n, i;
    string s, t;
    cin >> n >> s >> t;
    for(i=0; i<n; i++){
        cout << s[i] << t[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  
  bool f = 0;
  
  int count = 0;
  while(1){
  	for (int i = 0; i < N; i++){
       if(A[i] % 2 == 0){
          A[i] = A[i] / 2;
       }else{
         f= 1;
       }
    }
    if(f == 1)
      break;
    count++;
  }
 
  cout << count << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 100005

ll ar[N],dp[N];

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;cin>>n>>k;
   for(int i=1;i<=n;i++) cin>>ar[i];
   dp[n]=0;
   for(int i=n-1;i>=1;i--){
      dp[i]=INT_MAX;
      for(int j=1;j<=k&&i+j<=n;j++){
         dp[i]=min(dp[i],dp[i+j]+abs(ar[i]-ar[i+j]));
      }
   }
   cout<<dp[1]<<"\n";
   return 0;
}



Measured memory_bytes: 5212
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;;
    cin>>n;
    string s;
    do{
        n--;
        s+=char('a'+n%26);
        n/=26;
    }while(n);
    reverse(all(s));
    cout<<s<<endl;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void){

int S;
int h,m,s;

scanf("%d",&S);
h = S / 3600;
m = (S - h * 3600) / 60;
s = S - 3600 * h - m * 60;
printf("%d:%d:%d\n",h,m,s);
return 0;
}

Measured memory_bytes: 592
s = input()
if int(s[:4]) <= 2019:
  if int(s[5:7]) == 4 and int(s[8:]) <= 30:
    print("Heisei")
  elif int(s[5:7]) < 4:
    print("Heisei")
  else:
    print("TBD")
else:
  print("TBD")

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

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

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }



int main()
{
  ll H,W,K; cin>>H>>W>>K;
  vector<string> grid(H); rep(i,H) cin>>grid.at(i);
  
  ll ans=0;
  rep(i,1<<H){
    rep(j,1<<W){
      
      ll count=0;
      rep(k,H){
        rep(l,W){
          if(!(i&(1<<k))&&!(j&(1<<l))&&grid.at(k).at(l)=='#') count++;
        }
      }
      if(count==K) ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int c[300001] = { 0 },N,Q,max=1,num,q;
  cin >> N >> Q;
  for(int i=0;i<N;i++){
   cin >> num;
   c[num]=1;
   if(max < num)max=num;
  }
  for(int i=0; i<Q ; i++){
   cin >> q;
   for(int j=q-1;j>=0;j--){
    for(int k = j;k <= max;k+=q){
     if(c[k]){
      cout << j << endl;
      goto SKIP;
     }
    }
   }
SKIP:;
  }
  return 0;
}

Measured memory_bytes: 4276
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <vector>
using namespace std;

int main(){
    
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int N, M, a, b, ind, j;
    cin >> N >> M;

    vector<vector<int>> G(N, vector<int>());
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }
    
    vector<int> ans(N, -1);
    ans[0] = 1;
    int count = 1;

    vector<int> stack{0};

    while(!stack.empty()){
        if(count == N){
            break;
        }
        j = stack[0];
        stack.erase(stack.begin());
        for(int i = 0; i < G[j].size(); i++){
            ind = G[j][i];
            if(ans[ind] == -1){
                ans[ind] = j;
                stack.push_back(ind);
                count++;
            }
        }
    }
            
    if(count != N){
        cout << "No" << endl; 
    }
        
    else{
        cout << "Yes" << endl;            
        for(int i = 1; i < N; i++){
            cout << ans[i] + 1 << endl;
        }
    }
    
}


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

int main(){
  int N = 0;
  string S = "";
  int AC, WA, TLE, RE;
  AC = 0;
  WA = 0;
  TLE = 0;
  RE = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "AC"){
      AC += 1;
    }else if (S == "WA"){
      WA += 1;
    }else if (S == "TLE"){
      TLE += 1;
    }else if (S == "RE"){
      RE += 1;
    }
  }
  cout << "AC x " << AC << "\n";
  cout << "WA x " << WA << "\n";
  cout << "TLE x " << TLE << "\n";
  cout << "RE x " << RE << "\n";
}

Measured memory_bytes: 3620
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N =5e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    int n = read();
    ll sum = 0;
    rep(i,1,n){
        if(i%3==0||i%5==0) {}
        else sum += i;
    }
    cout << sum;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	int cnt[5] = { 0 };
	REP(i, 6) {
		LL v;
		cin >> v;
		cnt[v]++;
	}

	bool fail = false;
	int kCnt = 0;
	for (int i = 1; i <= 4; ++i) {
		if (cnt[i] == 0) {
			fail = true;
			break;
		}

		if (cnt[i] % 2) {
			++kCnt;
		}
	}

	if (kCnt != 0 && kCnt != 2) {
		fail = true;
	}

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


	return 0;
}


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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int hash = 0, period = 0;
  rep(i, n) {
    if (s[i] == '.') period++;
  }
  int ans = period;
  rep(i, n) {
    if (s[i] == '#') {
      hash++;
    } else {
      period--;
    }
    ans = min(ans, hash + period);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;

int main() {
  ll n,w;
  cin>>n>>w;
  ll dp[n+5][100005];
  vector<ll> V(n);
  vector<ll> W(n);
  rep(i,n){
    cin>>W[i];
    cin>>V[i];
  }

  rep(i,n+5)rep(j,100005)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,n)rep(j,100005){
    if (j-V[i]>=0){
      dp[i+1][j]=min(dp[i][j],dp[i][j-V[i]]+W[i]);
    }
    else dp[i+1][j]=dp[i][j];
  //  cout<<dp[i+1][j]<<"i"<<(i+1)<<"j"<<j<<endl;
  }
  ll ans=100005;
  while(dp[n][ans]>w)ans--;
cout<<ans;
}


Measured memory_bytes: 85640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll N; cin>>N;
    vec C(4,0);
    rep(i,N){
        string S; cin>>S;
        if(S=="AC") C[0]++;
        else if(S=="WA") C[1]++;
        else if(S=="TLE") C[2]++;
        else C[3]++;
    }
    cout<<"AC x "<<C[0]<<endl;
    cout<<"WA x "<<C[1]<<endl;
    cout<<"TLE x "<<C[2]<<endl;
    cout<<"RE x "<<C[3]<<endl;
}

Measured memory_bytes: 3624
A,B,C,D,E,F=[int(x) for x in input().split()]
from itertools import product
def gauss(i):
    return F//i+1
waters=set()
sugers=set()
ans={"water":100*A,"suger":0}
for a,b in product(range(gauss(A)),range(gauss(B))):
    waters.add(100*(a*A+b*B))
for c,d in product(range(gauss(C)),range(gauss(D))):
    sugers.add(c*C+d*D)
for water in sorted(waters):
    if water==0:
        continue
    for suger in sorted(sugers):
        if water+suger>F:
            break
        if 100*suger>E*water:
            break
        if ans["suger"]*(water+suger)<suger*ans["water"]:
            ans={"water":water+suger,"suger":suger}
print(ans["water"],ans["suger"])

Measured memory_bytes: 43244
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

ll n, m, p, v;
ll a[MAX], b[MAX];

int main()
{
    cin >> n >> m >> v >> p;
    for(ll i = 1; i <= n; ++i){
        scanf("%lld", &a[i]);
    }
    sort(a+1, a+n+1, greater<ll>());
    for(ll i = 1; i <= n; ++i){
        b[i] = b[i-1]+a[i];
    }
    ll ans = p, s = 0, all = m*(v-1), sum = 0, r = 1;
    for(ll i = 1; i < p; ++i){
        sum = sum+a[i];
    }
    for(ll i = p+1; i <= n; ++i){
        while(a[i]+m < a[r]) sum -= a[r], r++;
        if(r > p) break;
        s = (a[i]+m)*(i-r)-b[i-1]+b[r-1]+(n-i)*m;
        if(s+m*(r-1)+sum-a[i]*(p-r) >= all){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std; using ll=long long; const ll INF=1e18; using P=pair<ll,ll>;
struct da{ll v,a,b;};
struct e{ll c,g,i; bool operator>(const e x)const{if (c!=x.c) return c>x.c; if (g!=x.g) return g>x.g; return i>x.i;}};
int main() {
  int n,m; cin>>n>>m;
  ll s; cin>>s; s=min(s,2500LL);
  vector<da> v[n];
  for(int i=0;i<m;i++) {
    ll u,w,a,b; cin>>u>>w>>a>>b; u--; w--;
    v[u].push_back({w,a,b}); v[w].push_back({u,a,b});
  }
  ll c[n],d[n];
  for(int i=0;i<n;i++) cin>>c[i]>>d[i];
  priority_queue<e, vector<e>, greater<e>> que;
  ll an[n][2501]; fill(an[0], an[n], INF);
  que.push({0,s,0}); an[0][s]=0;
  while(!que.empty()) {
    e o = que.top(); que.pop();
    if (an[o.i][o.g] < o.c) continue;

    for(da x:v[o.i]) {
      if (x.a > o.g) continue;
      ll val = an[x.v][o.g-x.a];
      ll val2 = an[o.i][o.g] + x.b;
      if (val > val2) {
        an[x.v][o.g-x.a] = val2;
        que.push({val2, o.g-x.a, x.v});
      }
    }

    ll neg = min(2500LL, o.g+c[o.i]);
    ll val = an[o.i][neg];
    ll val2 = an[o.i][o.g] + d[o.i];

    if (val > val2) {
      an[o.i][neg] = val2;
      que.push({val2, neg, o.i});
    }
  }

  for(int i=1;i<n;i++) {
    ll ans=INF;
    for(int j=0;j<=2500;j++) {
      ans = min(an[i][j], ans);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 7264
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(N);
  rep(i,N){
    int x;
    cin >> x;
    v[i] = x;
    if(i!=0)v[i]+=v[i-1];
  }
  ll mi = MAX_I;
  rep(i,N-1){
    mi = min(mi,abs(2*v[i] - v[N-1]));
  }
  cout << mi << endl;
  return 0;
}


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

int main() {
  string str;
  getline(cin, str);

  vector<string> vs;
  string word = "";
  for(int i = 0; i < str.size(); i++) {
    char c = str[i];
    if(c == ' ' || c == ',' || c == '.' || i+1 == str.size()) {
      if(3 <= word.size() && word.size() <= 6) vs.push_back(word);
      word = "";
    } else {
      word += c;
    }
  }

  cout << vs[0];
  for(int i = 1; i < vs.size(); i++) {
    cout << " " << vs[i];
  }
  cout << endl;
}

Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, n;
    cin >> h >> n;

    vl a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    vl dp(h+1, INF);  // dp[j] : jダメージ与えるときの魔力の総和の最小値
    dp[0] = 0;
    rep(i, n) {
        rep(j, h+1) {
            chmin(dp[min(h, j + a[i])], dp[j] + b[i]);
        }
    }

    out(dp[h]);
    re0;
}

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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<pair<int,int>> a(n);
  for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second;
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(a[i].second>=k){
      cout << a[i].first << endl;
      break;
    }
    else k-=a[i].second;
  }
}

Measured memory_bytes: 4024
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

const double eps = 1e-9;
inline bool equals(double a, double b) { return fabs(a - b) < eps ;}

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {};

    Point operator + (Point p) { return Point(x + p.x, y + p.y); }
    Point operator - (Point p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < eps && fabs(y - p.y) < eps;
    }
};
typedef Point Vector;

struct Segment { Point p1, p2; };

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

// return abs of closs product
double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Point cross_point(Segment s1, Segment s2) {
    Vector base = s2.p2 - s2.p1;
    double d1 = abs(cross(base, s1.p1 - s2.p1));
    double d2 = abs(cross(base, s1.p2 - s2.p1));
    double t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1) * t;
}

int main(void) {
    int q;
    cin >> q;
    while (q--) {
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Segment s1 = {Point(x0, y0), Point(x1, y1)};
        Segment s2 = {Point(x2, y2), Point(x3, y3)};
        Point c = cross_point(s1, s2);
        printf("%.10f %.10f\n", c.x, c.y);
    }
    return 0;
}

Measured memory_bytes: 1236
//Prime Numbers
#include <iostream>
#include <cmath>

using namespace std;

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

int main() {
    int n, x, cnt = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x;
        if(isPrimeNumber(x)) cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;

typedef long long ll;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll h,w;
	cin>>h>>w;
	vector<string> arr(h);
	for(int i=0;i<h;i++)
		cin>>arr[i];
	vector<vector<ll>> adj(h*w,vector<ll>());
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(arr[i][j]=='#')
				continue;
			if(i+1<h)
			{
				if(arr[i+1][j]=='.')
				{
					ll x=i*w+j;
					ll y=(i+1)*w+j;
					adj[x].push_back(y);
				}
				

			}
			if(i-1>=0)
			{
				if(arr[i-1][j]=='.')
				{
					ll x=i*w+j;
					ll y=(i-1)*w+j;
					adj[x].push_back(y);
				}
			}
			if(j+1<w)
			{
				if(arr[i][j+1]=='.')
				{
					ll x=i*w+j;
					ll y=(i)*w+j+1;
					adj[x].push_back(y);
				}
			}
			if(j-1<w)
			{
				if(arr[i][j-1]=='.')
				{
					ll x=i*w+j;
					ll y=(i)*w+j-1;
					adj[x].push_back(y);
				}
			}

		}
	}
	ll ans=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			queue<ll> q;
			vector<bool> visit(h*w,false);
			ll x=i*w+j;
			q.push(x);
			visit[x]=true;
			ll ct=0;
			while(1)
			{
				queue<ll> tmp;
				while(!q.empty())
				{
					ll x=q.front();
					q.pop();
					for(ll node:adj[x])
					{
						if(visit[node]==false)
						{
							visit[node]=true;
							tmp.push(node);
						}
					}
				}
				if(!tmp.empty())
				{
					q=tmp;
					ct++;
				}
				else
					break;
			}
			ans=max(ans,ct);
			
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#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()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int h,w; cin>>h>>w;
  vector<string> s(h); rep(i,h) cin>>s[i];
  vector<vector<int>> ans(h,vector<int>(w));
  int dx[8]={-1,-1,0,1,1,1,0,-1};
  int dy[8]={0,1,1,1,0,-1,-1,-1};
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        ans[i][j]=-1;
        continue;
      }
      int c=0;
      rep(k,8){
        int x=i+dx[k];
        int y=j+dy[k];
        if(x<0||h<=x||y<0||w<=y||s[x][y]=='.') continue;
        c++;
      }
      ans[i][j]=c;
    }
  }
  rep(i,h){
    rep(j,w){
      if(ans[i][j]==-1)
      cout<<"#";
      else
      cout<<ans[i][j];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int p[101], N;

int num(int m){
    int ret = 0;
    for(int i=2; i<=N; i++){
        if(p[i] >= m) ret++;
    }
    return ret;
}

int main(void){
    cin >> N;

    // N!に含まれる素因数を全て列挙する
    for(int i=2; i<=N; i++){
        int cur = i;
        for(int j=2; j*j<=cur; j++){
            while(cur%j == 0){
                p[j]++;
                cur /= j;
            }
        }
        if(cur != 1) p[cur]++;
    }

    cout << num(74) + num(14)*(num(4)-1) + num(24)*(num(2)-1) + (num(4)*(num(4)-1)/2)*(num(2)-2) << endl;

}


Measured memory_bytes: 256
function Main(input){
var A = input.split(" ")[0];
var B = input.split(" ")[1];
var add = new Number(A) + new Number(B);
var dev = A - B;
var mul = A * B;
if(add >= dev && add >= mul){
  console.log(add);
}else if(dev >= add && dev >= mul){
  console.log(dev);
}else{
  console.log(mul);
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int mn = n+1;
    int t, ans = 0;
    for(int i=0;i<n;i++){
        cin >> t;
        if(t < mn){
            ans ++;
            mn = t;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
    String str = new Scanner(System.in).nextLine();
    String[] strs = str.split(" ");
    int W = Integer.parseInt(strs[0]);
    int H = Integer.parseInt(strs[1]);
    int x = Integer.parseInt(strs[2]);
    int y = Integer.parseInt(strs[3]);
    int r = Integer.parseInt(strs[4]);
    if(x<r || x+r>W || y<r || y+r>H) {
      System.out.println("No");
    }else {
      System.out.println("Yes");
    }
  }
    }



Measured memory_bytes: 26296