akhauriyash/Code-Regression huggingface dataset:
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):
        score = -1
        best = None
        for i in range(26):
            new_score = calc_score(t + [i])
            if new_score > score:
                best = t + [i]
                score = new_score
        t = best
    return t

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 = solution3()
t = optimize1(t)
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 85128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int dp[100][200000];
signed main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,W;
   cin>>n>>W;
   vector<int>w,v;
   for(int i=0;i<n;i++)
   {
       int x,y;
       cin>>x>>y;
       w.emplace_back(x);
       v.emplace_back(y);
   }
   for(int i=0;i<n;i++)
    dp[i][0]=1;
   if(w[0]<=W)
   {
       for(int j=w[0];j<=W;j++)
        dp[0][j]=v[0];
   }
   for(int i=1;i<n;i++)
   {
      for(int x=0;x<=W;x++)
      {
           dp[i][x]=max(dp[i][x],dp[i-1][x]);
           if(x>=w[i])
            dp[i][x]=max(dp[i][x],dp[i-1][x-w[i]]+v[i]);
      }
   }
   cout<<dp[n-1][W]<<endl;
   return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int n; cin >> n;
    pair<pair<string, int>, int> p[120];
    for (int i = 0; i < n; i++) {
        string temp;
        int x;
        cin >> temp >> x;
        p[i] = make_pair(make_pair(temp, -x), i);
    }
    sort(p, p+n);
    for (int i = 0; i < n; i++) {
        cout << p[i].second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll a[20010];
ll b[20010];
ll p[20010];

int main()
{
	
	int n;cin >> n;
	REP(i,n)cin >> p[i];
	REP(i,n)
	{
		a[i+1] = (i+1)*30000;
		b[n-i] = (i+1)*30000;
	}
	REP(i,n)
	{
		b[p[i]] += i+1;
	}
	
	REP(i,n-1)cout << a[i+1] << ' ';cout << a[n] << endl;
	REP(i,n-1)cout << b[i+1] << ' ';cout << b[n] << endl;
	
	
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int n,m,x;cin>>n>>m>>x;
  vector<int> a(m);
  rep(i,m) cin>>a[i];

  int R = 0;
  for (int i = x; i < n; i++) {
    rep(j,m) if (a[j]==i) R++;
  }

  int L = 0;
  for (int i = x; i > 0; i--) {
    rep(j,m) if (a[j]==i) L++;
  }

  int ans = min(R,L);
  cout << ans << endl;
}


Measured memory_bytes: 256
// mitsui_sumitomo_2019_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    REP(n, 1000){
        ostringstream ss;
        ss << setw(3) << setfill('0') << n;
        string x = ss.str();

        int idx = 0;
        REP(i, N){
            if (S[i] == x[idx]){
                idx++;
                if (idx == 3){
                    ans++;
                    break;
                }
            }
        }
    }

    print(ans);



    return 0;
}


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

auto gcd(long long a, long long b) {
  long long x = a;
  long long y = b;
  long long last_r = y;

  for (;;) {
    auto q = x / y;
    auto r = x % y;
    cerr << "q:" << q << ",r" << r << endl;

    x = (x - r) / q;
    y = r;
    if (r == 0)
      break;
    last_r = r;
  }

  return last_r;
}

int main() {
  long long a, b;
  cin >> a >> b;
  if (a < b)
    swap(a, b);
  cerr << a << b << endl;
  cout << (a * b / gcd(a, b));
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;
long long a[200100];
long long b[200100] = {};
long long kaizo(long long c){
    return c*(c-1)/2;
}
int main()
{
    int n;
    scanf("%d",&n);
    rep(i,n){
        scanf("%lld",&a[i]);
        b[i+1] = b[i]+a[i];
    }
    sort(b,b+n+1);
    long long ans = 0;
    long long cnt = 1;
    REP(i,1,n+1){
        if(b[i]!=b[i-1]){
            if(cnt>=2){
                ans += kaizo(cnt); 
            }
            cnt = 1;
        } else cnt++;
    }
    if(cnt>=2){
      ans += kaizo(cnt);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;

typedef int long long;

const int q = 10000000000 + 7;

int main() {
	
	string s;
	cin >> s;
	int length = s.length();

	int cnt = 0;
	vector<int> num(length, 0);

	cnt++;
	for (int i = 1; i < length; i++)
	{
		if (s[i - 1] == s[i]) {
			cnt++;
		}
		else {
			if (s[i - 1] == 'R') {
				num[i - 1] += (cnt / 2) + (cnt % 2);
				num[i] += (cnt / 2);
				cnt = 1;
			}
			else {
				num[i - cnt] += (cnt / 2) + (cnt % 2);
				num[i - cnt - 1] += (cnt / 2);
				cnt = 1;
			}
		}
	}
	num[length - cnt] += (cnt / 2) + (cnt % 2);
	num[length - cnt - 1] += (cnt / 2);

	for (int i = 0; i < length; i++)
	{
		if (i != length - 1) {
			cout << num[i] << " ";
		}
		else {
			cout << num[i] << endl;
		}
	}
	
	return 0;
}

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

int main(){
	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++){
		cout << S[i];
		if (i == 3){
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, x1, y1, x2, y2);
	int x3, y3, x4, y4;
	int dx = x2-x1;
	int dy = y2-y1;
	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x1 - dy;
	y4 = y1 + dx;
	OUT(x3)SP;
	OUT(y3)SP;
	OUT(x4)SP;
	OUT(y4)BR;
	
  
  return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
inpl = lambda: list(map(int,input().split()))
H, W = inpl()
sh, sw = inpl()
start = (sh-1, sw-1)
gh, gw = inpl()
goal = (gh-1, gw-1)
S = [input() for _ in range(H)]

count = [[-1]*W for _ in range(H)]
count[start[0]][start[1]] = 0
q = [(0, start)]
while q:
    d, p = heappop(q)
    if p == goal:
        print(d)
        exit()
    h, w = p
    if d > count[h][w]:
        continue
    for dh, dw in ((1,0), (-1,0), (0,1), (0,-1)):
        nh, nw = h+dh, w+dw
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and (count[nh][nw] < 0 or count[nh][nw] > d):
            count[nh][nw] = d
            heappush(q, (d, (nh, nw)))
    for dh in range(-2,3):
        for dw in range(-2,3):
            nh, nw = h+dh, w+dw
            if (dh,dw) != (0,0) and 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and count[nh][nw] < 0:
                count[nh][nw] = d+1
                heappush(q, (d+1, (nh, nw)))
print(-1)


Measured memory_bytes: 106800
#include <iostream>
#include <map>
using namespace std;
typedef unsigned long long LL;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	map<LL,int> aMap;
	map<LL,int>::iterator mit;
	int A;
	for (int i=0;i<N;i++){
		cin>>A;
		mit = aMap.find(A);
		if (mit == aMap.end()){
			aMap[A]=1;
		}else{
			int num=(*mit).second;
			if (num==1){
				(*mit).second = 0;
			}else if (num == 0){
				(*mit).second = 1;
			}
		}
	}
	LL aw=0;
	for (mit=aMap.begin();mit!=aMap.end();mit++){
		if ((*mit).second != 0){
			aw++;
		}
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
    
    int a, b;
    scanf("%d %d", &a, &b);
    if(a < b)
        printf("a < b\n");
    else if(a == b) 
        printf("a == b\n");
    else 
        printf("a > b\n");
    
    return 0;
}


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

using Graph = vector<vector<int>>;
using Pii = pair<int, int>;

void dfs(int v, int& i, const Graph& G, vector<Pii>& vp) {
  vp[v].first = i++;
  for (auto u : G[v]) {
    dfs(u, i, G, vp);
  }
  vp[v].second = i;
}

template<class I>
class SegTree {
private:
  int n;
  std::vector<I> dat, lazy;

public:
  SegTree(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
  }

  void eval(int k, int l, int r) {
    if (lazy[k] == 0) return;
    dat[k] = (r - l) - dat[k];
    if (k < n - 1) {
      lazy[2 * k + 1] = (lazy[2 * k + 1] + lazy[k]) % 2;
      lazy[2 * k + 2] = (lazy[2 * k + 2] + lazy[k]) % 2;
    }
    lazy[k] = 0;
  }

  void update(int a, int b, I x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = (lazy[k] + x) % 2;
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = dat[2 * k + 1] + dat[2 * k + 2];
    }
  }

  // return op[a..b)
  // k: node id, [l, r): node interval
  I query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    I vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    I vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return vl + vr;
  }
};

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

  int n, q;
  cin >> n >> q;
  Graph G(n);
  rep2(i, 1, n) {
    int x;
    cin >> x;
    x--;
    G[x].push_back(i);
  }

  vector<Pii> vp(n);
  int cnt = 0;
  dfs(0, cnt, G, vp);

  SegTree<int> seg(n);
  rep(i, n) {
    char c;
    cin >> c;
    if (c == 'G') {
      seg.update(vp[i].first, vp[i].first + 1, 1);
    }
  }

  rep(i, q) {
    int v;
    cin >> v;
    v--;
    seg.update(vp[v].first, vp[v].second, 1);
    int sm = seg.query(0, n);
    cout << (2 * sm > n ? "broccoli" : "cauliflower") << endl;
  }

  return 0;
}



Measured memory_bytes: 17380
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int a, b, c, d, e, k;
    vector<int>at(5);
    rep(i, 5)cin >> at[i];
    cin >> k;
    bool ans = true;
    rep(i, 4)for (int j = i + 1; j < 5; j++)if (abs(at[i] - at[j]) > k)ans = false;
    if (ans) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
    return 0;
}

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

int main(int argc, char *argv[])
{
    unordered_map<int, bool> m;
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        m[x] = !m[x];
    }
    cout << accumulate(m.begin(), m.end(), 0, [](auto& x, auto& y) { return x + y.second; }) << endl;
}


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

int main(void){

  char s[16];
  scanf("%s", s);
  int k = strlen(s);
  int lose = 0;
  for (int i = 0; i < k; i++) {
    if (s[i] == 'x') {
      lose++;
    }
  }
  if (lose < 8) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

const int N = 2E5 + 100;

vector<int> G[N], rG[N];
int indg[N], vis[N], order[N];

int main() {
    int n, m; cin >> n >> m;
    m += n - 1;
    FOR (i, 0, m) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        rG[b].push_back(a);
        indg[b]++;
    }

    queue<int> q;
    vector<int> seq;
    FOR (i, 1, n + 1) {
        if (indg[i] == 0) {
            vis[i] = 1;
            q.push(i);
            seq.push_back(i);
        }
    }
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v: G[u]) {
            if (--indg[v] == 0) {
                vis[v] = 1;
                q.push(v);
                seq.push_back(v);
            }
        }
    }
    FOR (i, 0, seq.size()) {
        order[seq[i]] = i;
    }
    
    FOR (u, 1, n + 1) {
        int parent = 0;
        for (int v: rG[u])
            if (parent == 0 || order[v] > order[parent])
                parent = v;
        cout << parent << endl;
    }
}

Measured memory_bytes: 18428
#include <iostream>
using namespace std;
int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {      
        cin >> a >> b;
        
        if( a==0 && b==0 )
        break;
        
        if(a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll h,n;
	cin>>h>>n;
	ll a[n],b[n];
	for(ll i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	ll dp[h+1];
	for(ll i=1;i<=h;i++) dp[i]=inf;
	dp[0]=0;
	for(ll i=1;i<=h;i++){
		for(ll j=0;j<n;j++){
			if(i-a[j]>=0) dp[i] = min(dp[i] , dp[i-a[j]] + b[j]);
			else dp[i] = min(dp[i] , b[j]);
		}
		//cout<<dp[i]<<" ";
	}
	cout<<dp[h];
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

#include <cstdio>

using namespace std;

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

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		long long a, b;
		cin >> a >> b;

		long long absqrt = (long long)sqrt((long double)(a * b));
		if (absqrt * absqrt == a * b) {
			absqrt--;
		}

		long long ans = absqrt * 2;
		if (a <= absqrt) {
			ans--;
		}
		if (b <= absqrt) {
			ans--;
		}
		if (a * b <= absqrt * (absqrt + 1)) {
			ans--;
		}

		cout << ans << "\n";
	}

	cin >> q;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int taka_count = (c + b - 1) / b;
    int ao_count = (a + d - 1) / d;

    std::cout << (taka_count <= ao_count ? "Yes" : "No") << std::endl;    

    return 0;
}

Measured memory_bytes: 3648
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    ll a,b,k; cin >> a >> b >> k;
    if(k <= a) cout << a-k << " " << b << endl;
    else if(k <= (a+b)) cout << 0 << " " << b-(k-a) << endl;
    else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static int[] descend(int[] result){
		int[] ans = new int[result.length];
		for(int i = 0; i < result.length; i++){
			int max = 0;
			for(int j = 0; j < result.length; j++){
				if( result[j] > result[max] ){
					max = j;
				}
			}
			result[max] = -1;
			ans[i] = max+1;
		}
		return ans;
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int[][] result = new int[1000][];
		int index = 0;
		
		while( n != 0 || m != 0 ){
			int[][] p = new int[n][m];
			result[index] = new int[m];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					p[i][j] = stdIn.nextInt();
					result[index][j] += p[i][j];
				}
			}
			index++;
			n = stdIn.nextInt();
			m = stdIn.nextInt();
		}
		
		for(int i = 0; i < index; i++){
			int[] ans = new int[result[i].length];
			ans = descend(result[i]);
			for(int j = 0; j < result[i].length-1; j++){
				System.out.print(ans[j] + " ");
			}
			System.out.println(ans[result[i].length-1]);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>

using namespace std;

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

    int i, j, tmp;
    for(i=1; i<=(N/4); i++) {
        tmp = 4*i;
        if(tmp==N) {
            printf("Yes\n");
            return 0;
        }
        for(j=1; j<=i; j++) {
            tmp += 3;
            if(tmp==N) {
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");

    return 0;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 300001), 300001)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	var str string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	chars := strings.Split(str, "")

	ws := make([]int, N)
	es := make([]int, N)

	wcnt := 0
	for i := 1; i < N; i++ {
		if chars[i-1] == "W" {
			wcnt++
		}
		ws[i] = wcnt
	}

	ecnt := 0
	for i := N - 2; i >= 0; i-- {
		if chars[i+1] == "E" {
			ecnt++
		}
		es[i] = ecnt
	}

	//	fmt.Println(ws)
	//  fmt.Println(es)

	ans := math.MaxInt64
	for i := 0; i < N; i++ {
		ans = min(ans, es[i]+ws[i])
	}
	fmt.Println(ans)
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long long n;
    cin >> n;
    long long ans = 1e12;
    for(long i = 1;i<=1e6+4;i++){
        if(n%i==0){
            long long tmp = n/i;
            ans = min(ans,tmp+i-2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
d = {chr(i): 0 for i in range(97,97+26)}
for line in sys.stdin:
  s = list(line.lower())
  for i in s:
    if d.get(i) != None:
      d[i] += 1
[print(f"{key} : {value}") for [key,value] in d.items()]


Measured memory_bytes: 5584
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int N,M;
int L[200010];
int R[200010];
bool used[600010];
vector < int > cnd[600010];

int main ()
{
    cin >> N >> M;
    REP(i,N) cin >> L[i] >> R[i];

    vector < pair < int,int > > ord;
    REP(i,N) {
        cnd[R[i]].push_back(L[i] + M);
        cnd[R[i] + M].push_back(L[i] + 2 * M);
    }

    int cnt = 0;
    int ans = 0;
    reversed_priority_queue < int > pos;
    for (int i = 0; i < 600000; i++) {
        for (int j = 0; j < (int)cnd[i].size(); j++) {
            pos.push(cnd[i][j]);
        }
        while (!pos.empty()) {
            if (pos.top() < i) {
                pos.pop();
            } else {
                break;
            }
        }
        if (!pos.empty()) {
            used[i] = true;
            cnt++;
            pos.pop();
        }
        if (i - M >= 0) {
            if (used[i - M]) {
                cnt--;
            }
        }
        ans = max(ans, cnt);
    }

    cout << N - ans << endl;

    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int ans;
	if (A == B) ans = C;
	else if (B == C) ans = A;
	else if (C == A) ans = B;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
// #define mod 1000000007
// #define mod 163577857 
#define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    while(t--)
        solve();
} 

int dp[3001][3001] = {};
int vis[3001][3001] = {};
int a[3000];

int calc(int s , int ind)
{
    if(s==0)
        return powmod(2,ind+1);
    if(s<0)
        return 0;
    if(ind==-1)
        return 0;
    if(vis[s][ind])
        return dp[s][ind];
    vis[s][ind] = 1;
    return (dp[s][ind] = (2*calc(s,ind-1) + calc(s-a[ind],ind-1))%mod);
}

void solve()            
{
    int n , s;
    cin >> n >> s;
    rep(i,n)
        cin >> a[i];
    cout << calc(s,n-1);
}

Measured memory_bytes: 144460
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c,d,e;cin>>a>>b>>c>>d>>e;
  ll f=(c-a)*60+d-b;
  cout<<f-e;
}

Measured memory_bytes: 27060
const LIMIT: i64 = 1_000_000_000_000_000_000;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let mut a: i64 = sc.read();
    let mut b: i64 = sc.read();
    let mut c: i64 = sc.read();
    let k: usize = sc.read();
    let ans = if k % 2 == 0 {
        a - b
    } else {
        b - a
    };
    if ans.abs() > LIMIT {
        println!("Unfair");
    } else {
        println!("{}", ans);
    };
}

// Thanks, kenkoooo(https://kenkoooo.hatenablog.com/entry/2019/05/07/101033)
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> v[M];
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            v[i].emplace_back(s);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        int mask = i;
        int sum = 0;
        for (int j = 0; j < M; j++) {
            int cnt = 0;
            for (int k = 0; k < v[j].size(); k++) {
                if (mask & (1 << v[j][k] - 1)) {
                    cnt++;
                }
            }
            if (cnt % 2 == p[j]) sum++;
        }
        if (sum == M) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;

public class Main {
  private static void solve() {
    int n = ni();
    Map<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < n; i ++) {
      int a = ni();
      if (map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
      } else {
        map.put(a, 1);
      }
    }
    
    long count = 0;
    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
      int a = entry.getKey();
      int num = entry.getValue();
      
      if (a < num) {
        count += num - a;
      } else if (a > num) {
        count += num;
      }
    }
    System.out.println(count);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 45852
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define ALL(V) V.begin(), V.end()
#define endl '\n';
template <typename T> using V = vector<T>;
template <typename T> void chmin(T &a, T b) { a = min<T>(a, b); }


int main() {
    while(true) {
        ll N, M;
        cin >> N >> M;
        if(!(N + M)) break;
        V<ll> S(N), D(M);
        for(ll &e : S) cin >> e;
        for(ll &e : D) cin >> e;
        sort(ALL(D));
       
        V<ll> ssum(1ll << N);
        for(ll i = 0; i < ssum.size(); i++) {
            ll tmp = 0;
            for(ll j = 0; j < N; j++) if(i & (1ll << j)) tmp += S[j];
            ssum[i] = tmp;
        }
        
        ll sum = accumulate(ALL(D), 0ll);
        V<ll> dp(1ll << N, sum);
        for(ll S = 0; S < (1ll << N); S++) {
            for(ll i = 0; i < N; i++) {
                if(S & (1ll << i)) continue;
                ll psum = ssum[S];
                ll nsum = ssum[S | (1ll << i)];
                ll score = dp[S];
                for(ll d : D) {
                    ll dec = abs(d - psum) - abs(d - nsum);
                    score -= max<ll>(0, dec);
                }
                chmin(dp[S | (1ll << i)], score);
            }
        }
        cout << dp[(1ll << N) - 1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3408
n, m = gets.chomp.split(' ').map(&:to_i)
a = []
b = []
m.times { |i|
  a[i], b[i] = gets.chomp.split(' ').map(&:to_i)
}
def selectFrom(ab, from)
  ab.select { |v|
    v[0] == from
  }.uniq
end
ab = a.zip(b)
from0 = ab.select { |v|
  v[0] == 1
}.map { |v| v[1] }
ton = ab.select { |v|
  v[1] == n
}.map { |v| v[0] }
ret = from0 & ton
puts ret.length != 0 ? 'POSSIBLE' : 'IMPOSSIBLE'


Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int h,w;
  cin >> h >> w;
  if(h%3 == 0 || w%3 == 0){
    cout << 0 << endl;
    return 0;
  }
  vector<long long int> s(3),t(3);
  long long int cutw=(w+1)/3;
  long long int cuth=h/2;
  long long int cutha=(h+1)/3;
  long long int cutwa=w/2;
  s[0]=h*cutw;
  s[1]=h/2*(w-cutw);
  s[2]=(h-h/2)*(w-cutw);
  sort(s.begin(),s.end());
  t[0]=w*cutha;
  t[1]=w/2*(h-cutha);
  t[2]=(w-w/2)*(h-cutha);
  sort(t.begin(),t.end());
  cout << min(min(s[2]-s[0],t[2]-t[0]),min(h,w)) << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	vector<ll> x(n), y(n);
	vector<pair<ll, ll>> xy(n);
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		if (a > b) swap(a, b);
		x[i] = a;
		y[i] = b;
		xy[i] = { a, b };
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	ll ans = (x[n - 1] - x[0])*(y[n - 1] - y[0]);

	sort(xy.begin(), xy.end());
	ll r = xy[n - 1].first - xy[0].first, ymin = 1e18, ymax = 0;
	for (int i = 0; i < n - 1; i++) {
		ymin = min(ymin, xy[i].second);
		ymax = max(ymax, xy[i].second);
		r = min(r, max(xy[n - 1].first, ymax) - min(xy[i + 1].first, ymin));
	}
	ans = min(ans, (y[n - 1] - x[0])*r);
	cout << ans << endl;
	return 0;
}

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

int INF = 1001001001;

vector<vector<int> > to(100005);
vector<int> dis(100005, INF);
vector<int> dis2(100005, INF);

int N;

void discalc(int a, int d){
    dis[a] = d;
    for(int p : to[a]){
        if(dis[p] != INF)continue;
        discalc(p, d+1);
    }
    return;
}

void discalc2(int a, int d){
    dis2[a] = d;
    for(int p : to[a]){
        if(dis2[p] != INF)continue;
        discalc2(p, d+1);
    }
    return;
}

int main() {
    cin >> N;
    rep(i, N-1){
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    discalc(0, 0);
    discalc2(N-1, 0);

    int cnt = 0;
    rep(i, N){
        if(dis[i] > dis2[i]){
            cnt++;
        }
    }

    int need = (N+1)/2;
    if(cnt >= need){
        cout << "Snuke" << endl;
    } else {
        cout << "Fennec" << endl;
    }

    return 0;
}

Measured memory_bytes: 12692
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i(0);i<n;i++)
typedef long long ll;

int main(){

	string S;
	cin >> S;

	int cnt(0);
	int ans(0);

	rep(i,S.length()){
		if(S[i]!='A' && S[i]!='T' && S[i]!='G' && S[i]!='C'){
			ans=max(ans,cnt);
			cnt=0;
		}else cnt++;
	}

	ans = max(ans,cnt);

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


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	tap := 1 //必要なタップ数．
	if B == 1 {
		fmt.Println(0)
	} else {
		for A < B {
			tap++
			B -= A - 1
		}
		fmt.Println(tap)
	}
}


Measured memory_bytes: 1836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(a==b&&b==c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;

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

		ans += (x - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <ctime>
#include <numeric>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int R, G, B;
int N;
int dp[6123][3];

int main(){
	
	cin>>R>>G>>B>>N;
	
	fill( dp[0], dp[6000], 0 );
		
	int s = 0;
	while( s <= N ){
		dp[s][0]++;
		s += R;
	}
	
	REP( i, N+1 ){
		s = 0;
		if( dp[i][0] == 0 ) continue;
		while( s <= N ){
			dp[i+s][1] += dp[i][0];
			s += G;
		}
	}
	
	REP( i, N+1 ){
		s = 0;
		if( dp[i][1] == 0 ) continue;
		while( s <= N ){
			dp[i+s][2] += dp[i][1];
			s += B;
		}
	}
	
	
	cout<<dp[N][2]<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  char a;
  cin >> a;
  int x=a-'a';
  if(0<=x&&x<=25) cout << "a" << endl;
  else cout << "A" << endl;
}

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

typedef long long ll;

int N;
ll K;
ll A[200010], F[200010];

bool judge(ll mid) {
    ll k = K;
    for(int i = 0; i < N; i++) {
        ll dif = A[i] * F[i] - mid;
        if(dif <= 0) continue;
        k -= (dif - 1 + F[i]) / F[i];
    }

    return (k >= 0);
}

int main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> F[i];

    sort(A, A + N);
    sort(F, F + N);
    reverse(F, F + N);

    ll l = 0, r = 1001001001001001001;
    for(int i = 0; i < 100; i++) {
        ll mid = (l + r) / 2;
        if(judge(mid)) r = mid;
        else l = mid;
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    if (b == 'T') cout << 'A' << endl;
    if (b == 'C') cout << 'G' << endl;
    if (b == 'G') cout << 'C' << endl;
}

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

using namespace std;

const int INF = 1001001001;

struct Edge {
	int to, cost;
	Edge(){}
	Edge(int to, int cost) : to(to), cost(cost){}
};

struct State {
	Edge e;
	int ltime;
	State(Edge e, int ltime) : e(e), ltime(ltime){}
	bool operator > (const State &rhs) const {
		return (e.cost > rhs.e.cost);
	}
};

int main()
{
	int N, M, L, K, A, H;

	while (scanf("%d %d %d %d %d %d", &N, &M, &L, &K, &A, &H) && N){
		vector<Edge> G[128];
		bool able[128] = {0};
		int dp[128][128];

		for (int i = 0; i < N; i++){
			fill(dp[i], dp[i] + 128, INF);
		}

		for (int i = 0; i < L; i++){
			int x;
			scanf("%d", &x);
			able[x] = true;
		}
		able[A] = able[H] = true;

		for (int i = 0; i < K; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			G[a].push_back(Edge(b, c));
			G[b].push_back(Edge(a, c));
		}

		priority_queue< State, vector<State>, greater<State> > pq;
		pq.push(State(Edge(A, 0), M));

		while (!pq.empty()){
			State tmp = pq.top(); pq.pop();
			if (dp[tmp.e.to][tmp.ltime] <= tmp.e.cost) continue;
			dp[tmp.e.to][tmp.ltime] = tmp.e.cost;

			if (tmp.e.to == H) break;

			for (int i = 0; i < G[tmp.e.to].size(); i++){
				Edge nxt = G[tmp.e.to][i];
				if (nxt.cost > tmp.ltime) continue;
				if (dp[nxt.to][tmp.ltime - nxt.cost] > tmp.e.cost + nxt.cost){
					pq.push(State(Edge(nxt.to, tmp.e.cost + nxt.cost), tmp.ltime - nxt.cost));
				}
			}

			if (!able[tmp.e.to]) continue;
			for (int i = 1; i + tmp.ltime <= M; i++){
				if (dp[tmp.e.to][tmp.ltime + i] > tmp.ltime + i){
					pq.push(State(Edge(tmp.e.to, tmp.e.cost + i), tmp.ltime + i));
				}
			}
		}

		int ans = *min_element(dp[H], dp[H] + M + 1);
		if (ans != INF) printf("%d\n", ans);
		else printf("Help!\n");
	}

	return (0);
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define INF 1000000000
#define pow10 tipa_pow10
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int mult(int a , int b)
{
    return ((ll)a * b) % mod;
}
int add(int a , int b)
{
    return a + b >= mod ? a + b - mod : a + b;
}
int main()
{
    int a , b;
    cin >> a >> b;
    if(a + b == 15)
    {
        cout << "+";
    }
    else if(a * b == 15)
    {
        cout << "*";
    }
    else
        cout << "x";
}


Measured memory_bytes: 256