akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
d = []
A = []
ari = []

for i in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

for a in A:
  for k in range(1, N+1):
    if k in a:
      ari.append(k)


print(N-len(set(ari)))

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

using namespace std;

int bfs(int, int);

vector<int> v[110];
bool checked[110] = {};
int tag[110] = {};
int tag2[110] = {};
int cnt = 0;

int main()
{
	int n, m;
	int u = 0;
	int ans = 0;

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	ans = bfs(1, -1);
	cout << ans;
	return 0;
}

int bfs(int cul, int pre)
{
	static int tag_num = 0;
	checked[cul] = true;
	tag_num++;
	tag[cul] = tag2[cul] = tag_num;
	for (auto next : v[cul])
	{
		if (next == pre) continue;
		if (checked[next] == true)
		{
			if (tag2[cul] > tag[next])
			{
				tag2[cul] = tag[next];
			}
		}
		else
		{
			bfs(next, cul);
		}

		if (tag[cul] < tag2[next])
		{
			cnt++;
		}
		else if (tag2[cul] < tag2[pre])
		{
			tag2[pre] = tag2[cul];
		}
	}

	return cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main()
{
    int  n;
    int r=0;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            r += d[i] * d[j];
        }
    }
    
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main()
{
    rapido;
    char c;
    cin>>c;
    
    if(c>='A' && c<='Z')
    cout<<'A'<<endl;
    else if(c>='a' && c<='z')
    cout<<'a'<<endl;
}


Measured memory_bytes: 3648
n, m = map(int, input().split())
x = list(map(int, input().split()))

xsort = sorted(x)

if n >= m:
    print("0")
else:
    ans = xsort[m - 1] - xsort[0]
    masum = [0] * m
    for i in range(m - 1):
        masum[i] = xsort[i + 1] - xsort[i]
    sum = sorted(masum)
    for i in range(n - 1):
        ans -= sum[len(sum) - 1 - i]
    print(ans)

Measured memory_bytes: 13968
#include<stdio.h>
int main(){
  int i,j=0;
  char str1[11];
  char str2[11];
  
  scanf("%s",str1);
  for(i=0;str1[i]!='\0';i++){
    if(str1[i]=='0'){
      str2[j++]='0';
    }else if(str1[i]=='1'){
      str2[j++]='1';
    }else if(j!=0){
      j--;
    }
  }
  str2[j]='\0';
  for(i=0;str2[i]!='\0';i++)printf("%c",str2[i]);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int gcd(int a,int b) {
	if (b == 0)return a;
	gcd(b, a % b);
}
int main() {
	int N, X;
	cin >> N >> X;
	vector<int> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	vector<int> GCD(N);
	if (X > x[0]) {
		GCD[0] = X-x[0];
	}
	else {
		GCD[0] = x[0]-X;
	}
	for (int i =1; i < N; i++) {
		if (x[i] > GCD[i - 1]) {
			if(x[i]>X)GCD[i] = gcd(x[i]-X, GCD[i - 1]);
			else GCD[i] = gcd(X-x[i], GCD[i - 1]);
		}
		else {
			if(x[i]>X)GCD[i] = gcd(GCD[i - 1], x[i] - X);
			else GCD[i] = gcd(GCD[i - 1], X-x[i]);
		}
	}
	cout << GCD[N - 1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
    int N, M ,X, Y;
    cin >> N>>M>>X>>Y;
    int x[N], y[M];
    rep(i, 0, N) cin >> x[i];
    rep (i, 0,M) cin >> y[i];
    sort(x, x+N); sort (y, y+M);
    if (min(Y, y[0])>x[N-1] && min(Y, y[0])>X) cout << "No War" << endl;
    else cout <<"War" << endl;
}


Measured memory_bytes: 256
class Node:
    def __init__(self):
        self.parent = -1
        self.degree = 0
        self.sibling = -1

def cal_depth(node_id, d = 0):
    Tree[node_id].depth = d
    if Tree[node_id].left !=-1:
        cal_depth(Tree[node_id].left, d+1)
    if Tree[node_id].right !=-1:
        cal_depth(Tree[node_id].right, d+1)
        
def cal_height(node_id):
    left_h = 0
    right_h = 0
    if Tree[node_id].left != -1:
        left_h = cal_height(Tree[node_id].left) + 1
    if Tree[node_id].right != -1:
        right_h = cal_height(Tree[node_id].right) + 1
    Tree[node_id].height = max(left_h, right_h)
    return max(left_h, right_h)
    
    
    
    
    
N = int(input())
Tree = [Node() for _ in range(N)]

#make_tree
for _ in range(N):
    #id, 子供の数k, c_0~c_k
    tree_info = list(map(int, input().split()))
    node_id = tree_info[0]
    left = tree_info[1]
    right = tree_info[2]
    #自身の子をセット
    Tree[node_id].left = left
    Tree[node_id].right = right
    #子からみた親をセット
    if left != -1:
        Tree[left].parent = node_id
    if right != -1:
        Tree[right].parent = node_id
    #ノードのタイプをセット
    if left == -1 and right == -1:
        Tree[node_id].type = "leaf"
    elif left == -1 or right == -1:
        Tree[node_id].degree = 1
        Tree[node_id].type = "internal node"
    else:
        #兄弟をセット
        Tree[right].sibling = left
        Tree[left].sibling = right
        Tree[node_id].degree = 2
        Tree[node_id].type = "internal node"
        

#search_root
root_id =[i for i,t in enumerate(Tree) if t.parent == -1][0]
Tree[root_id].type = "root"
cal_depth(root_id)
cal_height(root_id)


#answer_output
for i, t in enumerate(Tree):
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(i, t.parent, t.sibling, t.degree, t.depth, t.height, t.type))


Measured memory_bytes: 5620
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

map< pair<int,int> ,double> dp;

int n,m,k;
double dfs(int sum,int n){
	if( dp.count(make_pair(sum,n)) ) return dp[make_pair(sum,n)];
	if( sum < 0 ) return 0.0;
	if( sum == 0 ){	
		return n == 0 ? 1.0 : 0.0;
	}
	if( n <= 0 ) return 0.0;
	double res = 0;
	for(int i = 1 ; i <= m ; i++){
		res += dfs(sum-i,n-1) / m;
	}
	return dp[make_pair(sum,n)] = res;
}

int main(){
	while( cin >> n >> m >> k && n){
		dp.clear();
		double sum = 0;
		if( n == 1 ){
			for(int i = 1 ; i <= m ; i++)
				sum += (1./m) * max(1,(i-k));
		}else{
			for(int i = 1 ; i <= n * m ; i++){
				double p = dfs(i,n);
				sum += max(1,i-k) * p;
			}
		}
		printf("%.10lf\n",sum);
	}
}

Measured memory_bytes: 1292
#include <iostream>
#include <cstdlib>

using namespace std;


int main()
{
	int A, B;
	int flag = 1;
	cin >> A;
	cin >> B;
	char *s = (char *) malloc((A + B + 2) * sizeof(char));
	cin >> s;
	for (int i = 0; i < A && flag; i++) {
		flag = s[i] <= '9' && s[i] >= '0';
	}
	flag = flag && s[A] == '-'; 
	for (int i = A + 1; i < A + B + 1 && flag; i++) {
		flag = s[i] <= '9' && s[i] >= '0';
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";
	free(s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string A; cin >> A;
    vector<int> B { A.size() };
    int letters = 0;
    for (int i = A.size()-1; i >= 0; i--) {
        letters |= 1 << (A[i] - 'a');
        if (letters == (1 << 26)-1) {
            B.push_back(i);
            letters = 0;
        }
    }
    int pos = 0;
    while (!B.empty()) {
        int letters = 0;
        for (int i = pos; i < B.back(); i++) {
            letters |= 1 << (A[i] - 'a');
        }
        char ch = 0;
        for (int i = 0; i < 26; i++) {
            if (!(letters & (1 << i))) {
                ch = 'a' + i;
                break;
            }
        }
        cout << ch;
        while (pos < A.size() && A[pos] != ch) pos++;
        pos++;
        B.pop_back();
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


void solve() {
}
int IsPrime(int n)  //0なら素数
{
    if (n == 2) {
        return 0;
    } else if (n % 2 == 0 || n < 2) {
        return 1;
    } else {
        for (int i = 3; i <= sqrt(n); i += 2) {
            if (n % i == 0) {
                return 1;
            }
        }
    }
    return 0;
}
signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    for (int i = a;; i++) {
        if (IsPrime(i) == 0) {
            cout << i << endl;
            break;
        }
    }

    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e3+5;
const int mod=1e9+7;
ll dp[maxn][maxn];
struct ac
{
    ll p,v;
};
ac a[maxn];
bool cmp(ac a,ac b)
{
    return a.v>b.v;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].v;
        a[i].p=i;
    }
    sort(a+1,a+1+n,cmp);
    ll ans=-1;
    for(int la=1;la<n;la++) //已放置到第几个数
    {
        for(int s=0;s<=la;s++)
        {
            int i=s+1;
            int j=n-la+s;
            if(j+1<=n)
            dp[i][j]=max(dp[i][j],dp[i][j+1]+a[la].v*abs(j+1-a[la].p));
            if(i-1>=1)
            dp[i][j]=max(dp[i][j],dp[i-1][j]+a[la].v*abs(a[la].p-(i-1)));
        }
    }
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i][i]+a[n].v*abs(a[n].p-i));
    }
    cout<<ans<<'\n';

  
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1e8
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (long long)pow
#define BIT(i) (long long)pow(2, i)
typedef long long Lint;

int main() {
  int n;
  cin >> n;
  if (n == 0) {
    cout << 0 << endl;
  }

  else {
    vector<int> vcDigits1;
    while (n) {
      if (n < 0) {
        for (int k = 1; k < 32; k += 2) {
          if (-2 * (POW(2, k + 1) - 1) / 3 <= n) {
            vcDigits1.push_back(k);
            n += POW(2, k);
            break;
          }
        }
      } else {
        for (int k = 0; k < 31; k += 2) {
          if (n < 2 * (POW(2, k + 1) + 1) / 3) {
            vcDigits1.push_back(k);
            n -= POW(2, k);
            break;
          }
        }
      }
    }
    vcDigits1.push_back(-1);

    int nPrevDigit = vcDigits1[0];
    vcDigits1.erase(vcDigits1.begin());
    for (int digit : vcDigits1) {
      cout << 1;
      REP(i, nPrevDigit - digit - 1) { cout << 0; }
      nPrevDigit = digit;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
from time import time
from random import random

limit_secs = 2
start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score(t):
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(len(t)):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution1():
    return [i % 26 for i in range(D)]

def solution2():
    t = None
    score = -1
    for i in range(26):
        nt = [(i + j) % 26 for j in range(D)]
        if calc_score(nt) > score:
            t = nt
    return t

#def solution3():
#    t = []
#    for _ in range(D):
#        for i in range(26):


def optimize0(t):
    return t

def optimize1(t):
    score = calc_score(t)
    while time() - start_time + 0.15 < limit_secs:
        d = int(random() * D)
        q = int(random() * 26)
        old = t[d]
        t[d] = q
        new_score = calc_score(t)
        if new_score < score:
            t[d] = old
        else:
            score = new_score
    return t

t = solution2()
t = optimize0(t)
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 9844
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

vector<int> a, c;
string s;
map<char, int> isHead;

int dfs(int n, int used){
	if(n == a.size()){
		int res = 0;
		rep(i, n){
			res += a[i]*c[i];
		}
		return res == 0;
	}

	int cnt = 0;
	rep(i, 10){
		if(i == 0 && isHead[s[n]]) continue;
		if((used>>i)&1) continue;
		a[n] = i;
		cnt += dfs(n+1, used|(1<<i));
	}

	return cnt;
}

int main(){
	int n;
	while(cin >> n, n){
		vector<string> v(n);
		rep(i, n) cin >> v[i];
		c.clear();
		isHead.clear();
		s = "";
		rep(i, n){
			if(v[i].size() > 1) isHead[v[i][0]] = 1;
			reverse(all(v[i]));
			int C = (i<n-1)?1:-1;
			rep(j, v[i].size()){
				int m = s.size();
				rep(k, s.size()){
					if(v[i][j] == s[k]) m = k;
				}
				if(m == s.size()) s.push_back(v[i][j]), c.push_back(0);
				c[m] += C;
				C *= 10;
			}
		}

		//rep(i, c.size()) cout << s[i] << ':' << c[i] << endl;
		a.clear();
		a.resize(c.size(), 0);
		cout << dfs(0, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
char a;
int main(){
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') printf("vowel");
	else printf("consonant");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int X;
  cin >> X;
  yes(X >= 30);
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long L, R;
    cin >> L >> R;
    long long qL = L / 2019;
    long long rL = L % 2019;
    long long qR = R / 2019;
    long long rR = R % 2019;
    if(qL != qR){
        cout << 0 << endl;
        return 0;
    }else{
        int m = 2018;
        for(int i=rL; i<rR;i++){
            for(int j=rL+1; j<=rR; j++){
                m = min(m, (i*(j)) % 2019);
            } 
        }
        cout << m << endl;
    }

     
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<utility>
#include<set>
#include <queue>
#define ull unsigned long long
#define ll long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define S(x) scanf("%d",&x)
#define Sl(x) scanf("%lld",&x)
#define M(x,i) memset(x,i,sizeof(x))
#define F(i,a,n) for(i=(a);i<(n);++i)
#define FD(i,a,n) for(i=(a);i>=(n);--i)
using namespace std;
int main()
{
    int i,cnt;
    cnt = 0;
    string s;
    cin>>s;
    int len = s.length();
    if(len == 1){
        cout<<0<<endl;
        return 0;
    }

    F(i,1,len){
        if(s[i] != s[i-1]){
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int64_t lcm(int64_t a,int64_t b){
    return a/__gcd(a,b)*b;
}
int main(){
    int N;
    vector<int64_t> T(1000);
    cin >>N;
    for(int i=0;i<N;i++){
        cin >>T.at(i);
    }
    if(N==1){
        cout<<T.at(0)<<endl;
        return 0;
    }
    int64_t ans=lcm(T.at(0),T.at(1));
    for (int j=0;j<N-2;j++){
        ans=lcm(ans,T.at(j+2));
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    rep(nn, n) {
        string s, t; cin >> s >> t;
        int num = 1;
        int a=0, b=0;
        rep(i, s.size()) {
            if (s[i]=='m') {a += num*1000; num=1;}
            else if (s[i]=='c') {a += num*100; num=1;}
            else if (s[i]=='x') {a += num*10; num=1;}
            else if (s[i]=='i') {a += num; num=1;}
            else num = s[i]-'0';
        }
        rep(i, t.size()) {
            if (t[i]=='m') {b += num*1000; num=1;}
            else if (t[i]=='c') {b += num*100; num=1;}
            else if (t[i]=='x') {b += num*10; num=1;}
            else if (t[i]=='i') {b += num; num=1;}
            else num = t[i]-'0';
        }
        int tmp = a+b;
        int m=(tmp/1000)%10, c=(tmp/100)%10, x=(tmp/10)%10, i=tmp%10;
        string ans;
        if (m) {if(m>1) ans += (m+'0'); ans+='m';}
        if (c) {if(c>1) ans += (c+'0'); ans+='c';}
        if (x) {if(x>1) ans += (x+'0'); ans+='x';}
        if (i) {if(i>1) ans += (i+'0'); ans+='i';}

        cout << ans << endl;
    }
}


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

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;

    for (int i = 0; i < a + b + 1; i++) {
        if (i == a) {
            if (s[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == '-') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<string.h>
using namespace std;
#define LL long long int
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define PI pair<int,int>
#define mem(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(v) (int)sizeof(v)
const int inf=0x3f3f3f3f;
const int mod=10007;
const int M=20;
using namespace std;
#define N 105
string str,s1,s2;

int main()
{
    cin>>str;
    rep(i,0,4) cout<<str[i];
    cout<<' ';
    rep(i,4,str.length()) cout<<str[i];
    cout<<endl;
    return 0;
}


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

int main(){
	int x; cin>>x;
	int p1=100, p2=101, p3=103, p4=103, p5=104, p6=105;
	rep(a,1000){
		if(p1*a>x) break;
		rep(b,1000){
			if(p1*a+p1*b>x) break;
			rep(c,1000){
				if(p1*a+p2*b+p3*c>x) break;
				rep(d,1000){
					if(p1*a+p2*b+p3*c+p4*d>x) break;
					rep(e,1000){
						if(p1*a+p2*b+p3*c+p4*d+p5*e>x) break;
						rep(f,1000){
							if(p1*a+p2*b+p3*c+p4*d+p5*e+p6*f==x){
								cout<<1<<endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	cout<<0<<endl;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	int l;
	rep(i,N) {
		int a;
		cin >> a;
		if (a == 1) {
			l = i;
			break;
		}
	}
	K--;
	int ans = (l+K-1)/K;
	int r = N -1 - K*ans;
	ans += (r+K-1)/K;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b == c+d) {
    cout << "Balanced" << endl;
  } else if (a+b < c+d) {
    cout << "Right" << endl;
  } else {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 30)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, P[5001];
vector<ll> E[5001];

pll dfs(ll v, ll p) {
  ll cnt = 0, t = 1;
  for(ll u : E[v]) {
    if(u == p) continue;
    pll d = dfs(u, v);
    cnt += d.first;
    if(d.second == 1) t = 0;
  }
  if(t == 0) cnt++;

  // cout << v << ": " << cnt << " " << t << endl;

  return pll(cnt, t);
}

int main(void) {
  cin >> N;
  REP(i, 1, N + 1) cin >> P[i];

  REP(i, 1, N + 1) {
    E[P[i]].push_back(i);
    E[i].push_back(P[i]);

    cout << dfs(i, -1).first << endl;
  }
}

Measured memory_bytes: 3484
pattern = ["S","H","C","D"]
cards = [[0 for i in range(13)]for j in range(4)]

n = int(input())
for i in range(n):
    ch,rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1]=1

for i in range(4):
    for j in range(13):
        if cards[i][j]==0:
            print(pattern[i],j+1)
        



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n; scanf("%d", &n);
	bool approve = true;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		if (x&1) continue;
		if (x % 3 != 0 && x % 5 != 0) approve = false;
	}
	puts(approve? "APPROVED" : "DENIED");
}


Measured memory_bytes: 256
s = input()
res = 0

x = [s[0]]

i = 1
while i < len(s):
  if s[i] != x[-1]:
    x.append(s[i])
    i += 1
  else:
    if i == len(s) - 1:
      x[-1] += s[i]
      i += 1
    else:
      x.append(s[i] + s[i + 1])
      i += 2

print(len(x))


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

#define lp(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define ff first
#define ss second

using namespace std;

const int maxn = 1000 + 5;
const int model = 1000000000 + 7;

int r, c;
char mem[maxn][maxn];
int f[maxn][maxn];

void matrix1()
{
    cin >> r >> c;
    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            cin >> mem[i][j];
        }
    }

    f[0][0] = 1;
    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            if (i >= 1 && mem[i - 1][j] == '.')
            {
                f[i][j] += f[i - 1][j] % model;
            }
            if (j >= 1 && mem[i][j - 1] == '.')
            {
                f[i][j] += f[i][j - 1] % model;
            }
        }
    }
    cout << f[r - 1][c - 1] % model << endl;
}

int main() {
    matrix1();
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int n,t,a;
int h[1005];
int ans;
double temp;
double dt;
double dt1;

int main()
{
    scanf("%d",&n);
    scanf("%d%d",&t,&a);
    for(int i=0;i<n;i++)
        scanf("%d",&h[i]);
    temp=t-h[0]*0.006;
    dt=temp-a;
    if(dt<0)
        dt=-dt;
    ans=1;
    for(int i=1;i<n;i++)
    {
        temp=t-h[i]*0.006;
        dt1=temp-a;
        if(dt1<0)
            dt1=-dt1;
        if(dt>dt1)
        {
            ans=i+1;
            dt=dt1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;
int G[10][10],mx;
bool in(int x,int y){
  if(0<=x && x < 10 && 0<=y && y < 10)return true;
  else return false;
}
void m(int x,int y,int size)
{
  G[x][y]++;
  if(size == 1){
    if(in(x,y+1))G[x][y+1]++;
    if(in(x,y-1))G[x][y-1]++;
    if(in(x+1,y))G[x+1][y]++;
    if(in(x-1,y))G[x-1][y]++;
  } else if(size == 2){
    if(in(x,y+1))G[x][y+1]++;
    if(in(x,y-1))G[x][y-1]++;
    if(in(x+1,y))G[x+1][y]++;
    if(in(x-1,y))G[x-1][y]++;
    if(in(x-1,y-1))G[x-1][y-1]++;
    if(in(x+1,y+1))G[x+1][y+1]++;
    if(in(x-1,y+1))G[x-1][y+1]++;
    if(in(x+1,y-1))G[x+1][y-1]++;
  } else {
    if(in(x,y+1))G[x][y+1]++;
    if(in(x,y-1))G[x][y-1]++;
    if(in(x+1,y))G[x+1][y]++;
    if(in(x-1,y))G[x-1][y]++;
    if(in(x-1,y-1))G[x-1][y-1]++;
    if(in(x+1,y+1))G[x+1][y+1]++;
    if(in(x-1,y+1))G[x-1][y+1]++;
    if(in(x+1,y-1))G[x+1][y-1]++;
    if(in(x+2,y))G[x+2][y]++;
    if(in(x-2,y))G[x-2][y]++;
    if(in(x,y+2))G[x][y+2]++;
    if(in(x,y-2))G[x][y-2]++;
  }
}
int main(){
  char d;
  int a,b,c;
  mx = 0;
  fill(G[0],G[10],0);
  while(cin >> a >> d >> b >> d >>c  ){
    m(a,b,c);
  }
  int cnt = 0;
  for(int i = 0 ; i < 10 ; i++ ){
    for(int j = 0 ; j < 10 ; j++ ){
      if(G[j][i] > mx)mx = G[j][i];
      if(G[j][i] == 0)cnt++;
    }
  }
  cout << cnt << endl;
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000;
#define all(v) v.begin(), v.end()

int main(){
  string w;
  cin >> w;
  vector<ll> A(26,0);
  rep(i,w.size()){
    A.at(w.at(i)-'a')++;
  }
  rep(i,26){
    if(A.at(i)%2==1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

//int dx[] = {-1, 0, 1, 0},                  dy[] = {0, 1, 0, -1};                  // 4 Direction
//int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1},    dy[] = {0, 1, 0, -1, -1, 1, -1, 1};    // 8 Direction

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}
inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}

const ll INF = 1e15;
const int nax = 2e6 + 6;
int ara[nax];
int n;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> ara[i];
    }
    int cur = 1;
    for (int i = 0; i < n; i++){
        if (ara[i] == cur){
            cur++;
        }
    }
    if (cur == 1){
        cout << -1 << endl;
    }
    else{
        cout << n - cur + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};




int main() {

	ll div = 1000000007;
	int n;
	cin >> n;
	vector<int> prime;
	vector<bool> primeb(n + 1, false);
	FOR(i, 2, n + 1) {
		if (primeb[i] == false) {
			prime.push_back(i);
			for (int j = i * 2;j < n + 1;j += i)
				primeb[j] = true;
		}
	}
	ll ans = 1;
	REP(i, prime.size()) {
		ll cnt = 0;
		FOR(j,1, n+1) {
			int copy = j;
			while (copy%prime[i] == 0) {
				cnt++;
				copy /= prime[i];
			}
		}
		ans = ans*(cnt+1);
		ans %= div;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

ll n;
vector<double> p;

void solve() {
  // dp[i]: the probability of getting i heads
  vector<double> dp1(n+1);
  vector<double> dp2(n+1);
  dp1[0] = 1;
  for (int i=0; i<n; ++i) {
    for (int j=0; j<=n; ++j) {
      dp2[j] = dp1[j] * (1 - p[i]);
      if (j > 0) {
        dp2[j] += dp1[j-1] * p[i];
      }
    }
    swap(dp1, dp2);
  }
  double res = 0;
  for (int i=(n+1)/2; i<=n; ++i) {
    res += dp1[i];
  }
  cout << setprecision(10) << res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  p = vector<double>(n);
  for (int i=0; i<n; ++i) {
    cin >> p[i];
  }
  solve();
  return 0;
}

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


mod = 1000000007
F = [1]
f = 1
for i in range(1,M+1):
    f *= i
    f %= mod
    F.append(f)

ans = 0

for k in range(N+1):
    a =  F[M-k]
    b = F[M-N]*F[N-k]*F[k]
   #print(ans,b)
    a *= pow(b,mod-2,mod)
    if k%2==0:
        ans += a
    else:
        ans += mod-a
    ans %= mod

ans *= F[N]
ans %= mod

for i in range(N):
    ans *= M-i
    ans %= mod
print(ans)

Measured memory_bytes: 104388
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    if a > b:
        print(str(b)*a)
    else:
        print(str(a)*b)

if __name__ == '__main__':
    main()

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

const int MAX_A = 300005;
                                               
int op(int a, int b){ return max(a, b);}
int e(){return 0;}
 
int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  
  segtree<int, op, e> dp(MAX_A);
  for (int i=0; i<n; i++){
  	int x = a[i];
    int l = x-k;
    int r = x+k+1;
    l = max(l, 0);
    r = min(r, MAX_A);
    int now = dp.prod(l, r)+1;
    dp.set(x, now);
  }
  
  cout <<  dp.prod(0, MAX_A) << endl;
}

Measured memory_bytes: 9612
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();

        Arrays.sort(a);

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0)
                ans += a[i];
            else
                ans -= a[i];
        }

        if (n % 2 == 0)
            ans = -ans;

        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
from collections import deque
n = int(input())
a = list(map(str,input().split()))
d = deque()

for i in range(len(a)):
    if i%2==0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if n%2==1:
    d.reverse()

print(' '.join(d))

Measured memory_bytes: 26556
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll 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;

map<ll, ll> mp;
#include <iostream>
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void prime_factorize(ll n) {
    while (n % 2 == 0) mp[2]++, n /= 2;

    for (ll i = 3; i <= sqrt(n); i+=2) {
        while (n % i == 0) mp[i]++, n /= i;
    }

    if (n > 2) mp[n]++;
}

int main()
{
    COMinit();
    ll N, M; cin >> N >> M;
    prime_factorize(M);
    // for (auto p : mp) {
    //     cout << p.first << " " << p.second << endl;
    // }

    ll ans = 1;
    for (auto p : mp) {
        ans = ans * COM(N + p.second - 1, N - 1) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

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

	int X, Y; cin >> X >> Y;
	int res = X + Y / 2;
	cout << res << endl;
	
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int dp[1<<16];
int G[101][101];

string bin_str(int l, int x) {
    string ret(l, '0');
    for (int i = 0; i < l; i++) {
        ret[l - 1 - i] = '0' + (x % 2);
        x /= 2;
    }
    return ret;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> d(m);
    for (int i = 0; i < m; i++) {
        cin >> d[i];
        d[i]--;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> G[i][j];
            G[i][j]--;
        }
    }
    for (int bit = 0; bit < (1<<m); bit++) {
        dp[bit] = inf;
    }
    dp[(1<<m) - 1] = 0;
    queue<int> q;
    q.push((1<<m) - 1);
    while (not q.empty()) {
        int bit = q.front();
        q.pop();
        for (int i = 0; i < k; i++) {
            int nxt = 0;
            for (int j = 0; j < m; j++) {
                if (bit & (1<<j)) {
                    int to = G[d[j]][i];
                    for (int l = 0; l < m; l++) {
                        if (to == d[l]) {
                            nxt |= 1<<l;
                            break;
                        }
                    }
                }
            }
            // cout << bin_str(m, bit) << " " << bin_str(m, nxt) << endl;
            // cout << dp[bit] << " " << dp[nxt] << endl;
            
            if (dp[bit] + 1 < dp[nxt]) {
                // if (nxt == 65520 or nxt == 65280 or nxt == 61440 or nxt == 0) {
                //     dump(i);
                //     cout << bin_str(m, bit) << " " << bin_str(m, nxt) << endl;
                //     cout << bit << " " << nxt << endl;
                //     cout << dp[bit] << " " << dp[nxt] << endl;
                // }
                dp[nxt] = dp[bit] + 1;
                q.push(nxt);
            }
        }
    }
    // for (int i = 0; i < m; i++) {
    //     cout << d[i] << " " << G[d[i]][0] <<  " " << G[d[i]][80] << " " << G[d[i]][81] << endl;
    //     for (int j = 0; j < k; j++) {
    //         cout << G[d[i]][j] << " ";
    //     } cout << endl;
    // }
    for (int bit = (1<<m) - 1; bit >= 0; bit--) {
        //cout << bin_str(m, bit) << " " << dp[bit] << endl;
    }
    dump(dp[0]);
    return 0;
}



Measured memory_bytes: 3592
package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	zero := 0
	one := 0

	for _, c := range s {
		if c == '0' {
			zero++
		} else if c == '1' {
			one++
		}
	}

	if zero > one {
		fmt.Println(one * 2)
	} else {
		fmt.Println(zero * 2)
	}
}


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

namespace CodeForce
{



    class CF
    {

        static void Main(string[] args)
        {
            int yen = Convert.ToInt32(Console.ReadLine());
            int happiness = 0;
            int x = yen / 500;
            happiness += x * 1000;
            yen -= x * 500;

            int y = yen / 5;

            happiness += y * 5;
            Console.WriteLine(happiness);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n[10];int temp;
int a,num;
bool check(int mon)
{
    while(mon)
    {
        temp=mon%10;
        if(n[temp]==1)return false;
        mon=mon/10;
    }
    return true;
}
int main()
{
    while(cin>>a>>num)
    {
        memset(n,0,sizeof(n));
        for(int i=0;i<num;i++)
        {
            cin>>temp;
            n[temp]=1;
        }
        int mon=a;
        while(!check(mon))
        {
            mon+=1;

        }
        cout<<mon<<endl;
    }
}


Measured memory_bytes: 256
// 179

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>
#include <utility>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    ll n, a, b, c, ans=0;
    cin >> n;
    for(ll i=1; i<n; i++){
        ans += (n-1)/i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#include<stdlib.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
vector<long long> Prime;
void SieveOfEratosthenes(long long e) //setup vector<long long>Prime(~x)
{
	bool *x=new bool[e];
	for (long long i = 0; i <= e; i++)x[i] = false;
	for (long long i = 2; i <= e; i++)
	{
		if (x[i]);
		else
		{
			Prime.push_back(i);
			for (long long l = i; l <= e; l += i)x[l] = true;
		}
	}
	return;
}
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}
/*
(char)'1' - (int)48 = (int)1;
???1111181
*/
////////////////////////////////////////////////////



int main()
{
	vector<pair<int, int > > ans;
	for (int i = 1; i <= 150; i++)
	{
		for (int l = i+1; l <= 150; l++)
		{
			pair<int, int> now;
			now.first = i*i + l*l;
			now.second = i;
			ans.push_back(now);
		}
	}
	bool enn = true;
	while (enn)
	{
		enn = false;
		for (int i = 1; i < ans.size(); i++)
		{
			if (ans[i].first == ans[i - 1].first&&ans[i].second < ans[i-1].second)
			{
				swap(ans[i], ans[i - 1]);
				enn = true;
			}
			if (ans[i].first < ans[i - 1].first)
			{
				swap(ans[i], ans[i - 1]);
				enn = true;
			}
		}
	}
	
	int h,w;
	while (cin>>h>>w&&h)
	{
		int t = h*h + w*w;

		rep(i, ans.size())
		{
			if (ans[i].first==t&&h<ans[i].second)
			{
				cout << ans[i].second << " " << sqrt(ans[i].first - (ans[i].second*ans[i].second)) << endl;
				break;
			}
			else if (ans[i].first > t)
			{
				cout << ans[i].second << " " << sqrt(ans[i].first - (ans[i].second*ans[i].second)) << endl;
				break;

			}
		}

	}
	
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
main(){
  int N,K;
  cin >> N >> K;
  int I[59];
  for(int i=0;i<N;i++) cin >> I[i];
  int ans=0;
  sort(I,I+N,greater<int>());
  for(int i=0;i<K;i++) ans+=I[i];
  cout << ans <<endl;
}

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

#define llong long long

using namespace std;

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

  llong n;
  cin >> n;
  llong minP = LLONG_MAX;
  for (int i = 0; i < 5; i++) {
    llong p;
    cin >> p;
    minP = min(minP, p);
  }

  cout << 4 + ((n + (minP - 1)) / minP) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;


using Weight = int;
using Capacity = int;
struct Edge {
	int src, dst; Weight weight; Capacity cap;
	Edge(int s, int d, Weight w, Capacity c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct Dinic {
	int n, s, t;
	vector<int> level, prog, que;
	vector<vector<Capacity>> cap, flow;
	vector<vector<int>> g;
	Capacity inf;
	Dinic(const Graph &graph)
		: n(graph.size()),
		cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
		g(n, vector<int>()), inf(numeric_limits<Capacity>::max() / 8) {
		for(int i = 0; i < n; i++) {
			for(auto &e : graph[i]) {
				int u = e.src, v = e.dst;
				Capacity c = e.cap;
				cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
				g[u].push_back(v); g[v].push_back(u);
			}
		}
	}
	inline Capacity residue(int u, int v) { return cap[u][v] - flow[u][v]; }
	Capacity solve(int s_, int t_) {
		this->t = t_, this->s = s_;
		que.resize(n + 1);
		Capacity res = 0;
		while(levelize()) { prog.assign(n, 0); res += augment(s, inf); }
		return res;
	}
	bool levelize() {
		int l = 0, r = 0;
		level.assign(n, -1); level[s] = 0; que[r++] = s;
		while(l != r) {
			int v = que[l++]; if(v == t) break;
			for(const int &d : g[v]) if(level[d] == -1 && residue(v, d) != 0) {
				level[d] = level[v] + 1; que[r++] = d;
			}
		}
		return level[t] != -1;
	}
	Capacity augment(int v, Capacity lim) {
		Capacity res = 0;
		if(v == t) return lim;
		for(int &i = prog[v]; i < (int)g[v].size(); i++) {
			const int &d = g[v][i];
			if(residue(v, d) == 0 || level[v] >= level[d]) continue;
			const Capacity aug = augment(d, min(lim, residue(v, d)));
			flow[v][d] += aug; flow[d][v] -= aug;
			res += aug; lim -= aug;
			if(lim == 0) break;
		}
		return res;
	}
};


const int INF = 1 << 25;
int wf[100][100];
int A[10000];
int B[10000];
int D[10000];
int P[100];
int K[100];

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

	int N, M, L;
	while(cin >> N >> M >> L) {
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				wf[i][j] = i == j ? 0 : INF;

		for(int i = 0; i < M; i++) {
			cin >> A[i] >> B[i] >> D[i];
			A[i]--, B[i]--;
			wf[A[i]][B[i]] = wf[B[i]][A[i]] = D[i];
		}
		for(int i = 0; i < N; i++) {
			cin >> P[i];
		}
		for(int i = 0; i < N; i++) {
			cin >> K[i];
		}

		for(int k = 0; k < N; k++)
			for(int i = 0; i < N; i++)
				for(int j = 0; j < N; j++)
					wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);

		Graph G(N + N + 2);
		int S = N + N, T = N + N + 1;
		for(int i = 0; i < N; i++) {
			G[i].push_back(Edge(S, i, 0, P[i]));
			G[N + i].push_back(Edge(N + i, T, 0, K[i]));
			for(int j = 0; j < N; j++) {
				if(wf[i][j] < L) {
					G[i].push_back(Edge(i, N + j, 0, P[i]));
				}
			}
		}

		Dinic dinic(G);
		cout << dinic.solve(S, T) << endl;
	}
}

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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rep2(name,container) for(auto name=begin(container); name != end(container);name++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

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

	vi a(3);
	rep(i, 0, 3)cin >> a[i];
	string ans = "win";
	if (accumulate(all(a), 0LL) >= 22) {
		ans = "bust";
	}
	cout << ans << endl;
	return 0;
}


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


int main(void) {
  int N;
  cin >> N;
  // N:要素数
  using rest = tuple<string, int, int>;
  vector<rest> r(N);
  // r:要素
  for(int i = 0; i < N; ++i) {
    string restname;
    int restpoint;
    // restname:地名 restpoint:得点
    cin >> restname;
    cin >> restpoint;
    restpoint = -restpoint;
    r[i] = make_tuple(restname, restpoint, i+1);
  }
  sort(r.begin(), r.end());
  for(int i = 0; i < N; ++i) {
    int num;
    tie(ignore, ignore, num) = r[i];
    cout << num << endl;
  }
  // 出力
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int a[100000]={};
    long long int ans=1;
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        a[tmp]++;
    }
    a[0]++;
    for (int i = 1-n%2; i < n; i+=2) {
        if(a[i]!=2){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    int e=(n-n%2)/2;
    for (int i = 0; i < e; i++) {
        ans=ans*2%1000000007;
    }
    std::cout << ans << std::endl;
    return 0;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main()
{   
    int N, K;
    cin >> N >> K;
    vector<int> X(1000);
    for(int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        ans += min(X[i]*2, (K-X[i])*2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long const mod = pow(10, 9) + 7;
	long long N;
	vector<long long>A(100000);
	A.at(0) = 1;
	for (long long i = 1; i < 100000; i++) {
		A.at(i) = A.at(i - 1) * (i + 1) % mod;
	}
	cin >> N;
	cout << A.at(N - 1) << endl;
}

Measured memory_bytes: 1024