akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,i;
    cin>>n;
    long int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i+1<n;i++)
    {
        if(a[i]==a[i+1])
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}


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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    char S;
    cin >> S;
    if(S >= 'A' && S <= 'Z') { print("A"); }
    else { print("a"); }

    return 0;
}


Measured memory_bytes: 3660
def next(n):
    if n & 1:
        return 3 * n + 1
    else:
        return int(n / 2)

s = int(input())

a = [0] * 1000000
a[0] = s

f = True
i = 1
ans = 0
while f:
    a[i] = next(a[i - 1])
    for j in range(i):
        if a[j] == a[i]:
            ans = i + 1
            f = False
            break
    i += 1

print(ans)


Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int K,T; cin >> K >> T;
  v<P> a(T);
  rep(i,T){
    cin >> a[i].first;
    a[i].second=i;
  }
  int banned_index=114514;
  rep(i,K){
    rep(j,T){
      if(a.size()==1){
        cout << a[0].first-1 << endl;
        return 0;
      }
      sort(a.begin(),a.end());
      reverse(a.begin(),a.end());
      int index=0;
      if(a[index].second==banned_index){
        index++;
      }
      a[index].first--;
      //fore(k,a) cout << "a " << k.first << endl;
      //cout << endl;
      //cout << a[index].second << endl;
      banned_index=a[index].second;
      if(a[index].first==0){
        swap(a[index],a[a.size()-1]);
        a.pop_back();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, W = MI()
    dp = [0] * (W+1)
    w = [0] * N
    v = [0] * N

    for i in range(N):
        w[i], v[i] = MI()

    for i in range(N):
        dp_next = [0] * (W + 1)
        for j in range(W+1):
            dp_next[j] = max(dp_next[j], dp[j])
            if j + w[i] <= W:
                dp_next[j+w[i]] = max(dp[j] + v[i], dp_next[j])
        dp = dp_next

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 117612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(4, 0);
  for(int i=0; i<n; i++){
    string s;
    cin>>s;
    if(s=="AC")
      	v[0]++;
    else if(s=="WA")
      v[1]++;
    else if(s=="TLE")
      v[2]++;
    else if(s=="RE")
      v[3]++;
  }
  cout<<"AC x "<<v[0]<<endl;
  cout<<"WA x "<<v[1]<<endl;
  cout<<"TLE x "<<v[2]<<endl;
  cout<<"RE x "<<v[3]<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	ll n;
	rl(n);
	ll ans;
	ans=((n-1)*n)/2;
	wl(ans);
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N,X = map(int,input().split())
A = list(map(int,input().split()))+[X]
A.sort()
diff = []
for i in range(1,N+1):
    diff.append(A[i]-A[i-1])
res = diff[0]
for d in diff:
    res = gcd(res,d)
print(res)

Measured memory_bytes: 16280
#include <iostream>
#include <vector>

#define NUM 100010

using namespace std;

vector<pair<int, int>> V[NUM];
vector<int> x(NUM, 0);
vector<int> flag(NUM, false);

//各頂点を探索
bool dfs(int p) {
	//この頂点の相対的な座標を確定
	flag[p] = true;
	//この頂点からの有向辺それぞれについてチェック
	for (auto u : V[p]) {
		//有向辺先の頂点の座標ｘが既に確定していたら、整合性をチェック
		if (flag[u.first]) {
			if (x[u.first] != x[p] + u.second) return false;
		}
		else {
			//まだ有向辺先の頂点の座標ｘが確定していなければ、座標を確定
			x[u.first] = x[p] + u.second;
			//位置を確定させたことによって矛盾が生じたかチェック
			if (!dfs(u.first)) return false;
		}
	}
	return true;
}


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

	for (int i = 0; i < M; i++)
	{
		int l, r, d;
		cin >> l >> r >> d;
		//l->rに重みd、r->lに重み-dの有向辺を張る
		V[l].push_back(make_pair(r, d));
		V[r].push_back(make_pair(l, -d));
	}

	//各頂点を探索し、座標を確定させていく
	for (int i = 1; i <= N; i++)
	{
		//もし、この頂点の座標が確定していれば何もしない
		if (flag[i]) continue;
		if (!dfs(i)) {//座標を確定させようとしたことによって矛盾が生じたら
			cout << "No" << endl;
			return 0;
		}
	}

	//すべての座標を矛盾なく定義できた
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007

struct edge {
    int to; long long dist;
    edge(int t, long long d) : to(t), dist(d) {}
};

vector<edge> e[100010]; 


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int s, t; cin >> s >> t;
    for (int i = 0; i < m; i++) {
        int u, v; long long d; cin >> u >> v >> d;
        e[u].emplace_back(v, d);
        e[v].emplace_back(u, d);
    }
    vector<long long> v(n+1, 1e16); v[s] = 0;
    set<pair<long long, int>> sp; sp.emplace(v[s], s);
    while (!sp.empty()) {
        auto it = *sp.begin();
        sp.erase(sp.begin());
        if (v[it.second] < it.first) continue;
        auto curr = it.second;
        for (auto &edge: e[curr]) {
            if (v[edge.to] > v[curr] + edge.dist) {
                v[edge.to] = v[curr] + edge.dist;
                sp.emplace(v[edge.to], edge.to);
            }
        }
    }
    vector<long long> dpt(n+1, 0); dpt[t] = 1;
    vector<long long> dps(n+1, 0); dps[s] = 1;
    vector<pair<int, edge>> vi;
    vector<int> c;
    sp.emplace(v[t], t);
    while (!sp.empty()) {
        auto it = *sp.rbegin(); sp.erase(it);
        auto curr = it.second;
        c.emplace_back(curr);
        for (auto &edge: e[curr]) {
            if (v[edge.to] == v[curr] - edge.dist) {
                dpt[edge.to] = (dpt[edge.to] + dpt[curr]) % mod;
                sp.emplace(v[edge.to], edge.to);
            }
        }
    }
    sp.emplace(v[s], s);
    while (!sp.empty()) {
        auto it = *sp.begin(); sp.erase(it);
        auto curr = it.second;
        for (auto &edge: e[curr]) {
            if (v[edge.to] == v[curr] + edge.dist) {
                dps[edge.to] = (dps[edge.to] + dps[curr]) % mod;
                sp.emplace(v[edge.to], edge.to);
                vi.emplace_back(curr, edge);
            }
        }
    }
    long long D = v[t];
    long long ans = dps[t] * dpt[s] % mod;
    for (auto &x: c) {
        long long sub = dps[x] * dpt[x] % mod;
        sub = sub * sub % mod;
        if (v[x] * 2 == D) ans = (ans + mod - sub) % mod;
    }
    for (auto &iter: vi) {
        int ui = iter.first;
        int vi = iter.second.to;
        long long d = iter.second.dist;
        if (v[ui] >= D - v[vi] + d) continue;
        if (D - v[vi] >= v[ui] + d) continue;
        long long sub = dps[ui] * dpt[vi] % mod;
        sub = sub * sub % mod;
        ans = (ans + mod - sub) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 28588
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n

    def find(self, x): # 根を求める関数
        if self.par[x] < 0: return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self, x):
        return -self.par[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    uf.unite(a - 1, b - 1)
cnt = 0
for i in range(n):
    cnt += (uf.par[i] < 0)
print(cnt - 1)


Measured memory_bytes: 10804
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std; const int N=10000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int d[N],res,book[N],pri[N/10],mi[N],cnt;
signed main()
{
    int n=read();
    d[1]=1; res=1;
    for(ri int i=2;i<=n;i++)
    {
        if(!book[i]) pri[++cnt]=i, mi[i]=1, d[i]=2;
        for(ri int j=1;j<=cnt&&i*pri[j]<=n;j++)
        {
            book[i*pri[j]]=1;
            if(i%pri[j]) d[i*pri[j]]=d[i]*2, mi[i*pri[j]]=1;
            else
            {
                mi[i*pri[j]]=mi[i]+1;
                d[i*pri[j]]=d[i]/(mi[i]+1)*(mi[i*pri[j]]+1);
                break;
            }
        }
    }
    for(ri int i=2;i<=n;i++) res+=d[i]*i;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 243252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

bool isPrime(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;

  for (long long i = 3; i * i <= n; i += 2)
    if (n % i == 0)
      return false;

  return true;           
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;

  int r = 0;
  REP (i, n) {
    int x;
    cin >> x;
    r += isPrime(x);
  }
  cout << r << endl;
  
  return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


vector<vector<ll>> dp(11, vector<ll>(1001, -1));
// dp[i][j]...i問目までをj問解いて得られる最大の点数

int main() {
  int d; cin >>d;
  ll g; cin >>g;
  vector<ll> p(d), c(d);
  rep(i, d) cin >>p.at(i) >>c.at(i);

  dp.at(0).at(0) = 0;

  for (int i=0; i<d; i++){
    for (int j=0; j<=1000; j++){
      if (dp.at(i).at(j) == -1) continue;
      for (int k=0; k<=p.at(i); k++){
        if (k == p.at(i)) chmax(dp.at(i+1).at(j+k), dp.at(i).at(j) + k * 100 * (i+1) + c.at(i));
        else chmax(dp.at(i+1).at(j+k), dp.at(i).at(j) + k * 100 * (i+1));
      }
    }
  }

  int res = MOD;
  for (int i=0; i<=d; i++){
    for (int j=0; j<=1000; j++){
      if (dp.at(i).at(j) >= g) chmin(res, j);
    }
  }
  cout <<res <<endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCD = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];
            while(true)
            {
                C -= B;
                if(C<=0)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                A -= D;
                if (A <= 0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

        }
    }
}

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

ll INF=1e15+5;

int main(void){
    ll n;
    vector<ll> v(5);
    cin>>n;
    rep(i, 5) cin>>v[i];
    ll minimum=INF;
    rep(i, 5) minimum=min(minimum, v[i]);
    ll ans = 4+n/minimum;
    if(n%minimum) ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> vec1(N);
  for (int i=0;i<N;i++){
    cin >> vec1.at(i);
  }
  int M;
  cin >> M;
  vector<string> vec2(M);
  for (int k=0;k<M;k++){
    cin >> vec2.at(k);
  }
  int pro=0;
  for (int i=0;i<N;i++){
    int sum=0;
    for (int j=i;j<N;j++){
      if (vec1.at(i)==vec1.at(j)){
        sum++;
      }
    }
    for (int k=0;k<M;k++){
      if (vec1.at(i)==vec2.at(k)){
        sum--;
      }
    }
    if (sum>pro){
      pro=sum;
    }
  }
  cout << pro << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
}

void no(){
  cout << "No" << endl;
}

int main(){
  ll N,K,Q; cin >> N >> K >> Q;
  vector<ll> point(N,0);
  REP(i,Q){
    ll a; cin >> a;
    a--;
    point[a]++;
  }
  REP(i,N){
    if(point[i]>Q-K) yes();
    else no();
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


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

    ll n,a,b;
    cin >> n >> a >> b;
    if (a>b) swap(a,b);
    if ((b-a)%2==0) cout << (b-a)/2 << endl;
    else {
        if (a-1<n-b) {
            cout << a+(b-a-1)/2 << endl;
        } else {
            cout << n-b+1+(b-a-1)/2 << endl; 
        }
    }

    return 0;   
}

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

int main(){
	int length=0, num=0, big=0, small=0;  
	string str;
	cin >> str;
	if(str.size() >= 6) length++;

	for(int i = 0; i < str.size(); i++){
		if(str[i] >= '0' && str[i] <= '9') num++;
		else if(str[i] >= 'a' && str[i] <= 'z') small++;
		else if(str[i] >= 'A' && str[i] <= 'Z') big++;
	}

	if(length != 0 && num != 0 && small != 0 && big != 0) cout << "VALID" << endl;
	else cout << "INVALID" << endl; 

}

Measured memory_bytes: 1180
use proconio::input;

fn main() {
    input! {
        d: i64,
    };
    let ans = match d {
        25 => "",
        24 => " Eve",
        23 => " Eve Eve",
        22 => " Eve Eve Eve",
        _ => unreachable!(),
    };
    println!("Christmas{}", ans);
}


Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()


int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n)cin >> v[i];
    ll res = 0;
    rep(i, min(n, k)+1)rep(j, min(n, k)-i+1){
        vector<ll> vec = v;
        vec.erase(vec.begin()+i, vec.end()-j);
        sort(ALL(vec));
        if(k-(i+j) < 0)continue;
        ll sum = accumulate(ALL(vec), 0);
        int f = min(k-(i+j), (int)vec.size());
        rep(e, f)if(vec[e] < 0)sum-=vec[e];
        // cout << ":" << sum << endl;
        res = max(res, sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 384
import java.io.InputStream
import java.io.PrintStream
import java.util.*

class Arc065A(
    val input: InputStream,
    val output: PrintStream
) {
    fun proc() {
        val sc = Scanner(input)
        var input = sc.nextLine()

        val strs = listOf("dream", "dreamer", "erase", "eraser")

        while (input.isNotEmpty()) {
            val a = strs.find { input.endsWith(it) }
            if (a == null) {
                output.print("NO")
                return
            }
            input = input.removeSuffix(a)
        }
        output.print("YES")
    }
}

fun main(args: Array<String>) {
    Arc065A(System.`in`, System.out).proc()
}


Measured memory_bytes: 120304
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int i,j=0,l;
  l=s.length();
  for(i=0;i<l;i++)
  {
    if(s[i]=='o') j++;
  }
  if(j+(15-l)>=8) cout<<"YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    // 1L当たりの最安値
    ll cheapestPrice = min(min(4*q, 2*h), s);
    ll ans = (n%2 == 1 ? cheapestPrice : 0);
    ans += ((ll)(n/2))*min(d, cheapestPrice*2);
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    LL N = S.size();
    vector<vector<LL>> dp(100010,vector<LL>(13,0));

    if(S[0] == '?')rep(j,10)dp[0][j] = 1;
    else{
        int tmp = S[0] - '0';
        dp[0][tmp] = 1;
    }
    
    rep(i,N-1)  rep(k,13){
            if(S[i+1] == '?')rep(j,10)dp[i+1][(10*k + j) % 13] += dp[i][k] % MOD;
            else{
                int t = S[i+1] - '0';
                dp[i+1][(10*k + t) % 13] += dp[i][k] % MOD;
            }        
    }  

    LL ans = dp[N-1][5] % MOD;
    cout << ans << endl;

}

// 正解にはたどり着いてないけど、貰うDPでやろうとしたらエラー吐いて死んだ。
// おそらくif(i == 0) を作ってたのが原因っぽい。


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll check(ll x){
  if(x == 0) return 0;

  ll ret = 0;
  while(x > 0){
    ll cnt = __builtin_popcount(x);
    x %= cnt;
    ret++;
  }
  return ret;
}

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

  ll cnt = 0;
  rep(i,X.size()){
    if(X[i] == '1') cnt++;
  }

  if(cnt == 0 || cnt == 1){
    ll modB = cnt+1; //for 0->1
    vector<int> modW(N+10,0);

    ll sumB = 0;
    
    {
      ll p = 1;
      for(int i=N-1; i>=0; i--){
        modW[i] = p;
        if(X[i] == '1'){
          sumB += p;
          sumB %= modB;
        }
        p *= 2;
        p %= modB;
      }
    }
    
    
    rep(i,N){
      if(X[i] == '0'){
        ll sum = (sumB + modW[i])%modB;
        cout << 1 + check(sum) << endl;
      }else{
        cout << 0 << endl;
      }
    }
   
  }else{
    ll modA = cnt-1; //for 1->0
    ll modB = cnt+1; //for 0->1
    
    vector<int> modV(N+10,0);
    vector<int> modW(N+10,0);
    
    ll sumA = 0;
    ll sumB = 0;
    
    {
      ll p = 1;
      for(int i=N-1; i>=0; i--){
        modV[i] = p;
        if(X[i] == '1'){
          sumA += p;
          sumA %= modA;
        }
        p *= 2;
        p %= modA;
      }
    }
    {
      ll p = 1;
      for(int i=N-1; i>=0; i--){
        modW[i] = p;
        if(X[i] == '1'){
          sumB += p;
          sumB %= modB;
        }
        p *= 2;
        p %= modB;
      }
    }
    
    
    rep(i,N){
      if(X[i] == '0'){
        ll sum = (sumB + modW[i])%modB;
        cout << 1 + check(sum) << endl;
      }else{
        ll sum = (sumA + (modA - modV[i]))%modA;
        cout << 1 + check(sum) << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 5220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int d,g;
  cin >> d >> g;
  vector<int> p(d),c(d);
  rep(i,d) cin >> p[i] >> c[i];
  
  int ans = 1001001001;
  
  rep(i,1<<d){
    
    //cout << i << ":";
    vector<int> rest = p;
    int temp = 0;
    int point = 0;
    
    rep(j,d){
      if(i>>j&1){
        rest[j] = -1;
        temp += p[j];
        point += 100*(j+1)*p[j];
        point += c[j];
      }
    }
    //cout << temp << ";" << point << endl;
    int ind = d;
    
    while(point<g){
      if(rest[ind-1]<=0){ 
        if(rest[ind-1]==0) point += c[ind-1];
        ind--;
      }
      if(rest[ind-1]<=0) continue;
      point += 100*ind;
      rest[ind-1]--;
      temp++;
    }
    
    ans = min(ans,temp);
  }
  
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

ll h, w, ans = 1e9, a, b, c, ma, mi, p, q;

int main(){
	cin >> h >> w;
	
	for(ll i = 1; i < w; ++i){
		a = h*i, b = (w-i)*(h-h/2), c = (w-i)*(h/2);
		ma = max(a, max(b, c)), mi = min(a, min(b, c));
		ans = min(ans, ma-mi);
	}
	
	for(ll i = 1; i < h; ++i){
		a = w*i, b = (h-i)*(w-w/2), c = (h-i)*(w/2);
		ma = max(a, max(b, c)), mi = min(a, min(b, c));
		ans = min(ans, ma-mi);
	}
	
	for(ll i = 1; i < w; ++i){
		a = h*i, b = h*((w-i)/2), c = h*(w-i-((w-i)/2));
		ma = max(a, max(b, c)), mi = min(a, min(b, c));
		ans = min(ans, ma-mi);
	}
	
	for(ll i = 1; i < h; ++i){
		a = w*i, b = w*((h-i)/2), c = w*(h-i-((h-i)/2));
		ma = max(a, max(b, c)), mi = min(a, min(b, c));
		ans = min(ans, ma-mi);
	}
	
	cout << ans << endl;
}


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

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N;
	cin >> N;
	if (N <= 111) {
		cout << "111" << endl;
	}
	else if (N <= 222) {
		cout << "222" << endl;
	}
	else if (N <= 333) {
		cout << "333" << endl;
	}
	else if (N <= 444) {
		cout << "444" << endl;
	}
	else if (N <= 555) {
		cout << "555" << endl;
	}
	else if (N <= 666) {
		cout << "666" << endl;
	}
	else if (N <= 777) {
		cout << "777" << endl;
	}
	else if (N <= 888) {
		cout << "888" << endl;
	}
	else {
		cout << "999" << endl;
	}
}

Measured memory_bytes: 256
// 理屈はしらんけど全部のxorからA[i]のxorをとるとなんか答えがでた

package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N := nextInt()
	A := nextInts64(N)
	xor := A[0]
	for i := 1; i < N; i++ {
		xor = xor ^ A[i]
	}
	for _, a := range A {
		fmt.Fprintf(out, "%d ", xor^a)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts64(n int) []int64 {
	ret := make([]int64, n)
	for i := 0; i < n; i++ {
		ret[i] = int64(nextInt())
	}
	return ret
}


Measured memory_bytes: 8216
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int N= S.length();
    //string S;
    int flag =1;
    for(int i=0; i<S.length();i++){
        if(S[i]!=S[S.length()-i-1] && (i<=(S.length()-1-i))){
            flag =0;
            break;
        }
        else if(i>(S.length()-1-i)){
            break;
        }
    }
    if(flag ==1){
        //cout<<"Cleared"<<endl;
        //first
        int f = (N-1)/2;
        //cout<<f<<endl;
        int flag1 =1;
        for(int i=0; i<f;i++){
        if(S[i]!=S[f-i-1] && (i<=(f-1-i))){
            flag1 =0;
            break;
        }
        else if(i>(f-1-i)){
            break;
        }
    }
    if(flag1==1){
        //cout<<"Cleared"<<endl;
        int s = (N+3)/2;
        //cout<<s<<endl;
        int flag2 =1;
    for(int i=s-1; i<S.length();i++){
        if(S[i]!=S[S.length()-i-1] && (i<=(S.length()-1-i))){
            flag =0;
            break;
        }
        else if(i>(S.length()-1-i)){
            break;
        }
    }
    if(flag2==1)
        cout<<"Yes";
    else
        cout<<"No";
    }
    else{
        cout<<"No";
    }
    }
    else
        cout<<"No";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
		
		String[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	}
	
}

Measured memory_bytes: 25012
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main(){
    int s[100],n,i,a,b,k;
    char c;
    
    cin>>k>>n;
    
    for(i=1;i<=k;i++){
        s[i]=i;
    }
        
    for(i=0;i<n;i++){
        cin>>a>>c>>b;                 
        swap(s[a],s[b]);
    }
    for(i=1;i<=k;i++){
        cout<<s[i]<<endl;
    }
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    vector<pair<ll, ll> > A(N);

    rep(i,N) cin >> A[i].second >> A[i].first;

    sort(all(A));
    cout << endl;

    ll ans = 0;
    rep(i,N)
    {
        if(ans + A[i].second > A[i].first)
        {
            cout << "No" << endl;
            return 0;
        }
        else ans += A[i].second;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3328
h, w = gets.chomp.split(" ").map(&:to_i)
s = []
h.times do |i|
  s << gets.chomp
end
dh = [-1, -1, -1, 0, 0, 1, 1, 1]
dw = [-1, 0, 1, -1, 1, -1, 0, 1]
h.times do |y|
  w.times do |x|
    next if s[y][x] == '#'
    num = 0
    dh.length.times do |i|
      next if y + dh[i] < 0 or y + dh[i] >= h
      next if x + dw[i] < 0 or x + dw[i] >= w
      num += 1 if s[y + dh[i]][x + dw[i]] == '#'
    end
    s[y][x] = num.to_s
  end
end
h.times do |i|
  puts s[i]
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAX_N = 100000;
const int INF = LLONG_MAX/10;

int I, O, T, J, L, S, Q;

signed main()
{
	cin >> I >> O >> T >> J >> L >> S >> Q;
	int ans = 0;
	for (int jil = 0; jil < 2; jil++)
	{
		int cnt = O;
		J -= jil;
		I -= jil;
		L -= jil;
		if (J < 0 || I < 0 || L < 0) continue;
		cnt += 3*jil;
		cnt += I - (I&1);
		cnt += J - (J&1);
		cnt += L - (L&1);
		ans = max(ans, cnt);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

static int sw=0;

void selectionSort(int a[], int n){
    for(int i=0;i<n;i++){// i: start index of non-sorted
        int minj=i;

        int j;
        for(j=i+1;j<n;j++){   // swap start index of non-sorted and min 
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        if(i!=minj){    // actually swapping
            swap(a[i],a[minj]);
            sw++;
        }
        
    }
}

int main(){

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];

    selectionSort(a,n);

    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<sw<<endl;

    return 0;
}


Measured memory_bytes: 3068
def solve(string):
    n, q, *abpx = map(int, string.split())
    t, c, d, check = [[] for i in range(n + 1)], [0] * (n + 1), [1], [True] * (n + 1)
    for a, b in zip(*[iter(abpx[:2 * n - 2])] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(abpx[2 * n - 2:])] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m - 1)])))


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

int main() {
    int N, X, T;
    cin >> N >> X >> T;

    int quo = N / X;
    int mod = N % X;

    if(mod == 0) {
        cout << quo * T << endl;
    } else {
        cout << (quo + 1) * T << endl;
    }
}


Measured memory_bytes: 3612
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef pair<int, int> pii;

#define fi first
#define se second

namespace io
{
	const int maxb = 1 << 15;
	char b[maxb], *s = b, *t = b;
	bool Getchar(char &ch)
	{
		return ch = s == t && (t = (s = b) + fread(b, 1, maxb, stdin)) == b ? 0 : *s ++;
	}
	int Getint()
	{
		char ch;
		while (Getchar(ch) && (ch < '0' || ch > '9'));
		int s = ch - '0';
		while (Getchar(ch) && ch >= '0' && ch <= '9')
			s = s * 10 + ch - '0';
		return s;
	}
}

using io::Getint;

const int maxn = 1e5 + 10;

struct cmp
{
	bool operator() (const pii &a, const pii &b)
	{
		return a.se < b.se;
	}
};

pii a[maxn];
int c[maxn], s[maxn], del[maxn];
int ans[maxn];
bool used[maxn];

priority_queue<pii> Q;

int main()
{
	int n = Getint();
	for (int i = 1; i <= n; ++ i)
	{
		a[i].fi = Getint();
		a[i].se = Getint();
	}
	for (int i = 1; i <= n + 1; ++ i) c[i] = Getint();
	sort(c + 1, c + n + 2);
	for (int i = 1; i <= n; ++ i)
	{
		a[i].fi = lower_bound(c + 1, c + n + 2, a[i].fi) - c;
		a[i].se = lower_bound(c + 1, c + n + 2, a[i].se) - c;
		++ s[a[i].fi];
	}
	for (int i = 1; i <= n + 1; ++ i) s[i] += s[i - 1];
	for (int i = 1; i <= n + 1; ++ i) s[i] -= i;
	sort(a + 1, a + n + 1);
	int cnt = 0;
	int q = Getint();
	for (int i = n + 1, j = n; i; -- i)
	{
		s[i] += del[i];
		del[i - 1] += del[i];
		for (; j && a[j].fi > i; -- j)
			if (a[j].se < a[j].fi) Q.push(pii(-a[j].se, j));
		while (s[i] < -1)
		{
			if (Q.empty())
			{
				while (q --) puts("-1");
				return 0;
			}
			pii cur = Q.top();
			Q.pop();
			if (-cur.fi > i)
			{
				while (q --) puts("-1");
				return 0;
			}
			++ cnt;
			++ s[i];
			++ del[i - 1];
			-- del[-cur.fi - 1];
			used[cur.se] = true;
		}
	}
	memset(s, 0, sizeof s);
	memset(del, 0, sizeof del);
	for (int i = 1; i <= n; ++ i)
		if (used[i]) ++ s[a[i].se]; else ++ s[a[i].fi];
	for (int i = 1; i <= n + 1; ++ i) s[i] += s[i - 1];
	for (int i = 1; i <= n + 1; ++ i) s[i] -= i;
	int m = 0;
	for (int i = 1; i <= n; ++ i)
		if (!used[i]) a[++ m] = a[i];
	sort(a + 1, a + m + 1, cmp());
	ans[0] = cnt;
	for (int i = 1, j = 1; i <= n + 1; ++ i)
	{
		s[i] += del[i];
		del[i + 1] += del[i];
		for (; j <= m && a[j].se <= i; ++ j)
			if (a[j].se < a[j].fi) Q.push(pii(a[j].fi, j));
		if (s[i] == -1)
		{
			if (Q.empty())
			{
				for (int k = i; k <= n + 1; ++ k) ans[k] = n + 2;
				break;
			}
			pii cur = Q.top();
			Q.pop();
			if (cur.fi <= i)
			{
				for (int k = i; k <= n + 1; ++ k) ans[k] = n + 2;
				break;
			}
			++ cnt;
			++ del[i + 1];
			-- del[cur.fi];
		}
		ans[i] = cnt;
//		printf("  %d %d\n", i, ans[i]);
	}
	for (int i = 1; i <= q; ++ i)
	{
		int a = Getint(), b = Getint();
		a = lower_bound(c + 1, c + n + 2, a) - c;
		b = lower_bound(c + 1, c + n + 2, b) - c;
		printf("%d\n", n + 1 - min(ans[a - 1], ans[b - 1] + 1));
	}
	return 0;
}


Measured memory_bytes: 4976
#include<stdio.h>
#include<string.h>
#include<iostream>
int hideo[2000001] = { 0 };
int main(void)
{
	int noyori = 0, debu = 0, n, temp = 1, ruio[32] = { 0 }, x;
	while (scanf("%d %d", &n, &x)) {
		if (n == 0 && x == 0) {
			return 0;
		}
		for (int i = 1; i <= n; i++) {
			scanf("%d", &ruio[i]);
			hideo[ruio[i]] = 1;
		}
		while (temp != x) {
			if (hideo[temp] == 1) {
				for (int j = 1; j <= n; j++) {
					if (temp + ruio[j] > x)continue;
					if (hideo[temp + ruio[j]] == 0) {
						hideo[temp + ruio[j]] = 1;
					}
				}
			}
			temp++;
		}
		for (int i = x; i >1; i--) {
			if (hideo[i] == 1) {
				for (int j = 2; j < i - 1; j++) {
					if (i%j == 0) {
						debu = 1;
					}
				}
				if (debu == 0) {
					noyori = i;
					break;
				}
			}
			debu = 0;
		}
		if (noyori > 1) {
			printf("%d\n", noyori);
		}
		else {
			printf("NA\n");
		}
		temp = 1;
		noyori = 0;
		debu = 0;
		memset(ruio, 0, sizeof(ruio));
		memset(hideo, 0, sizeof(hideo));
	}
	return 0;
}

Measured memory_bytes: 11024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        if(n == 1) {
            System.out.println(t);
            return;
        }
        long maxTime = (long)n * t;
        int prevTime = sc.nextInt();
        for(int i = 0; i < n - 1; i++) {
            int currentTime = sc.nextInt();
            int diff = currentTime - prevTime;
            if(diff < t) {
                maxTime -= (t - diff);
            }
            prevTime = currentTime;
        }
        System.out.println(maxTime);
    }
}



Measured memory_bytes: 62060
inf = 10 ** 9


def main():
    H, N = map(int, input().split())
    AB = []
    for n in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(reverse=True, key=lambda x: x[0])
    dp = [inf] * (H + 10 ** 4)
    dp[0] = 0
    for a, b in AB:
        for h in range(H):
            # if dp[h] == inf:
            #     continue
            # else:
            #     dp[h+a] = min(dp[h]+b, dp[h+a])
            if dp[h] != inf:
                tmp = dp[h] + b
                if tmp < dp[h + a]:
                    dp[h + a] = tmp
    print(min(dp[H:]))


main()


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define all(v) (v).begin(), (v).end()

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

    if(n > 0 && m > 0){
        cout << (n*(n-1)/2)+(m*(m-1)/2);
    }
    else if(n > 0 && m == 0){
        cout << (n*(n-1)/2);
    }
    else if(n == 0 && m > 0){
        cout << (m*(m-1)/2);
    }
    else{
        cout << "0";
    }
}

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

int main()
{
  int i, j, n, q, nq, t, x;
  fscanf(stdin, "%d %d", &n, &nq);
  int **A = (int**)malloc(sizeof(int*)*n);
  for (i=0; i<n; i++) {
    A[i] = (int*)malloc(sizeof(int)*nq);
  }
  int *alen = (int*)malloc(sizeof(int)*n);
  for (i=0; i<n; i++) alen[i]=0;
  
  for (i=0; i<nq; i++) {
    fscanf(stdin, "%d %d", &q, &t);
    switch (q) {
    case 0:
      fscanf(stdin, "%d", &x);
      A[t][alen[t]++]=x;
      break;
    case 1:
      if (alen[t]==0) {printf("\n"); break;}
      for (j=0; j<alen[t]-1; j++)
	printf("%d ", A[t][j]);
      printf("%d\n", A[t][j]);
      break;
    case 2:
      alen[t]=0;
    }
  }
    return 0;
}



Measured memory_bytes: 7712
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 998244353
#define ll_MAX 19223372036859
#define endl "\n"
inline ll absdiff(ll a,ll b){ return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main(){
    ll n;cin>>n;
    ll arr[n][3];
    for(ll i=0;i<n;++i) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

    ll dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];

    for(ll i=1;i<n;++i){
        for(ll j=0;j<3;++j){
            for(ll k=0;k<3;++k){
                if(k==j) continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);
            }
        }
    }

    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    return 0;   
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll n;
vl numbers;

vvl dp;

vl prefixSum;

ll interval(ll starting, ll ending) {
	if(starting == 0) return prefixSum[ending];
	else return prefixSum[ending] - prefixSum[starting-1];
}

ll recurse(ll starting, ll ending) {
	//TR(starting); TR(ending);
	if(starting == ending) return 0;
	if(dp[starting][ending] != -1) return dp[starting][ending];

	ll result = oo;
	FOR(i, starting, ending) {
		//cerr << recurse(starting, i) << " " << recurse(i + 1, ending) << endl;
		ll combineSum = interval(starting, i) + interval(i + 1, ending);
		ll subsetSum = recurse(starting, i) + recurse(i + 1, ending);

		result = min(result, combineSum + subsetSum);
	}

	dp[starting][ending] = result;
	return result;
}


int main() {
	cin.sync_with_stdio(0);
	cin >> n;
	numbers = vl(n);
	dp = vvl(n, vl(n, -1));

	FOR(i, 0, n) {
		cin >> numbers[i];
	}

	prefixSum = vl(n);
	prefixSum[0] = numbers[0];
	FOR(i, 1, n) {
		prefixSum[i] = prefixSum[i - 1] + numbers[i];
	}

	//cerr << interval(1, 2) << endl;
	cout << recurse(0, n - 1) << endl;

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  int n, yen;
  cin >> n >> yen;
  
  int tmp;
  for (int x = 0; x <= n; x ++)
  {
    for (int y = 0; y <= n - x; y ++)
    {
      if (x * 10000 + y * 5000 + (n - x - y) * 1000 == yen)
      {
        cout << x << " " << y << " " << (n - x - y);
        return 0;
      }
    }
  }

  cout << "-1 -1 -1";
  return 0;
}


Measured memory_bytes: 256
#_*_ coding:utf-8 _*_
import sys


while True:
    vals = sys.stdin.readline()
    if(vals is  None or vals.strip() == '' ):
        break
    a,b,c,d,e,f=list( map(float,vals.strip().split()))
    temp = a * e - d * b
    x = (c * e - b * f) / temp + 0.0
    y = (c * d - a * f) / -temp + 0.0
    print('%.3f %.3f' % (x,y))

Measured memory_bytes: 7296
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int n, k; cin >> n >> k;
    ll cnt = 0;
    FORS(b, 1, n){
        int p = n / b;
        int r = n % b;
        cnt += (ll)p * max(0, b - k) + max(0, r - k + 1);
        if(!k) --cnt;
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, p, a[MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	sort(a + 1, a + n + 1, greater <int> ());
	for (p = 0; a[p + 1] >= p + 1; p ++);
	if (a[p] - p & 1)
		puts("First");
	else
	{
		int ret = 1;
		for (int i = p + 1; a[i] == p; i ++, ret ^= 1);
		if (ret)
			puts("Second");
		else
			puts("First");
	}
	return 0;
}


Measured memory_bytes: 640