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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n;
	cin >> m >> n;

	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];
	
	vvl dp(m,vl(n));
	dp[0][0] = 1;

	FOR(i,0,m) FOR(j,0,n) if (a[i][j] == '.') {
		if (i > 0) dp[i][j] += dp[i-1][j];
		if (j > 0) dp[i][j] += dp[i][j-1];
		dp[i][j] %= ll(1e9+7);
	}
	cout << dp[m-1][n-1] << endl;
}



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

// #include <iostream>
// #include <vector>
// using std::cin;
// using std::cout;
// using std::endl;

struct Info
{
    int weight;
    int deadline;

    Info(int a, int b)
    {
        weight = a;
        deadline = b;
    }
    bool operator<(const Info &another) const
    {
        return deadline < another.deadline;//年齢を比較
    };
    //2つのconstを付けないとコンパイルエラーになるので注意!!
};

int main(void)
{
    int N;
    cin >> N;
    vector<Info> info;
    int a, b;
    for(int i=0;i<N;i++){
        cin >> a >> b;
        info.push_back(Info(a, b));
    }

    std::sort(info.begin(), info.end());//ソート実行
    int time_count = 0;
    bool ok = true;
    for (auto itr : info)
    {
        time_count += itr.weight;
        if(time_count > itr.deadline){
            ok = false;
            break;
        }
        // cout << "age:" << itr.weight << " name:" << itr.deadline << endl;
    }
    if(ok){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

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

using namespace std;

int main () {

    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

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

    int res = 0;

    for (int i = 0; i < N-2; i++) {
        for (int j = i+2; j < N; j++) {
            int a = v[i];
            int b = v[j];
            bool flag = false;
            for (int k = i+1; k < j; k++) {
                if ((b - a < v[k]) & (v[k] < a + b)) {
                    res += 1;
                    flag = true;
                } else if (flag == true) {
                    break;
                }
            }
        }
    }

    cout << res;

    return 0;
}

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

const int mxN = 1e5 + 5;
int cnt[mxN], a[mxN];
bool answer[mxN];

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	for(int i = 1; i <= n; ++i) {
		cnt[i] = k;
		answer[i] = true;
	}
	int tot = 0;
	while(q--) {
		int x;
		cin >> x;
		if(cnt[x] - tot <= 0)
			answer[x] = false;
		++cnt[x];
		++tot;
	}
	for(int i = 1; i <= n; ++i) {
		if(cnt[i] - tot <= 0)
			answer[i] = false;
		cout << (answer[i] ? "Yes" : "No") << '\n';
	}
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

const int N = 100;

long double tot = 0;
int n;
long double ar[N];

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

    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> ar[i];
    }
    sort(ar + 1, ar + n + 1);
    tot += ar[1] + ar[2];
    tot /= 2; 
    for (int i=3;i<=n;i++){
        tot += ar[i];
        tot /= 2;
    }

    cout << fixed << setprecision(10) << tot << el;

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    int dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(int i=1;i<n;i++) {
        dp[i][0] = arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][2] = arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
        dp[i][1] = arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <random>
#include <vector>
#include <unordered_map>
#include <queue>

using namespace std;

const int LIM = 1e+5 + 100;
const int INF = 1e+9;

vector<vector<pair<int, int>>> g(LIM);
vector<bool> done(LIM);
vector<unordered_map<int, int>> dist(LIM);
vector<unordered_map<int, vector<int>>> c(LIM);
int n, m;

struct box_t {
  int cost, v, type;
};

int get_ans() {
  int res = INF;
  for (const pair<int, int> it : dist[n - 1])
    res = min(res, it.second);
  return res == INF ? -1 : res;
}

bool is_bad() {
  vector<bool> used(LIM, false);
  used[0] = true;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (const pair<int, int>& it : g[v]) {
      int to = it.first;
      if (!used[to]) {
        used[to] = true;
        q.push(to);
      }
    }
  }
  return !used[n - 1];
}

int solve() {
  queue<box_t> q, qq;

  q.push({0, 0, -1});
  dist[0][-1] = 0;

  while (!q.empty() || !qq.empty()) {
    if (q.empty())
      swap(q, qq);

    box_t top = q.front();
    q.pop();
    if (top.v == n - 1)
      return get_ans();
    if (dist[top.v][top.type] < top.cost)
      continue;
    if (!done[top.v]) {
      for (const pair<int, int>& it : g[top.v]) {
        int to = it.first;
        int edge_type = it.second;
        int new_cost = top.cost;
        if (top.type != edge_type)
          ++new_cost;

        if (dist[to].find(edge_type) == dist[to].end() || dist[to][edge_type] > new_cost) {
          dist[to][edge_type] = new_cost;
          if (new_cost == top.cost) {
            q.push({new_cost, to, edge_type});
            if (to == n - 1)
              return get_ans();
          } else {
            qq.push({new_cost, to, edge_type});
          }
        }
      }
      done[top.v] = true;
    } else {
      for (int to : c[top.v][top.type]) {
        int edge_type = top.type;
        int new_cost = top.cost;
        if (top.type != edge_type)
          ++new_cost;

        if (dist[to].find(edge_type) == dist[to].end() || dist[to][edge_type] > new_cost) {
          dist[to][edge_type] = new_cost;
          if (new_cost == top.cost) {
            q.push({new_cost, to, edge_type});
            if (to == n - 1)
              return get_ans();
          } else {
            qq.push({new_cost, to, edge_type});
          }
        }
      }
    }
  }
  return get_ans();
}

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

  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v, cc;
    cin >> u >> v >> cc;
    --u;
    --v;
    g[u].emplace_back(v, cc);
    g[v].emplace_back(u, cc);
    if (c[u].find(cc) == c[u].end())
      c[u][cc] = vector<int>();
    c[u][cc].push_back(v);

    if (c[v].find(cc) == c[v].end())
      c[v][cc] = vector<int>();
    c[v][cc].push_back(u);
  }

  cout << (is_bad() ? -1 : solve()) << endl;

  return 0;
}


Measured memory_bytes: 72320
#include <stdio.h>
#define MAX 100005
#define NIL -1


struct Node{
  int p,l,r;
};
  
struct Node tree[MAX];
int n,dep[MAX];

void print(int);
int rec(int,int);

int main(){
  int i,j,de,val,c,le,ro;

  scanf("%d",&n);
  for(i=0;i<n;i++) tree[i].p = tree[i].l = tree[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&val,&de);
    for(j=0;j<de;j++){
      scanf("%d",&c);
      if(j==0) tree[val].l = c;
      else tree[le].r = c;
      le=c;
      tree[c].p = val;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].p == NIL) ro=i;
  }

  rec(ro,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d,",u,tree[u].p,dep[u]);
  if(tree[u].p == NIL) printf(" root, ");
  else if(tree[u].l == NIL) printf(" leaf, ");
  else printf(" internal node, ");

  printf("[");

  for(i=0,c=tree[u].l; c != NIL; i++, c=tree[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  dep[u] = p;
  if(tree[u].r != NIL) rec(tree[u].r,p);
  if(tree[u].l != NIL) rec(tree[u].l,p+1);
}



Measured memory_bytes: 6412
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;

	return 0;
}

Measured memory_bytes: 5936
// https://atcoder.jp/contests/abc156/tasks/abc156_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, K;
  cin >> N >> K;

  ll res = 1;

  while (N / K) {
    res++;
    N /= K;
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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


int main() {
  int a1,a2,a3;
  
  cin >> a1 >> a2 >> a3;
  
  int total = a1+a2+a3;
  
  if(total < 22)
    cout << "win";
  
  else
    cout << "bust";
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#define F first
#define S second
#define PR pair<ll,ll>
using namespace std;
typedef long long ll;

ll n, a, b, g, c0, M=1e9+7, ans=1, pow2[200005]={1};
map<PR, PR> mp;
int main() {
	cin >> n;
	for(ll i=1; i<=n; i++) pow2[i] = pow2[i-1] * 2 % M;
	while(n--) {
		scanf("%lld%lld", &a, &b);
		if(!a && !b) {c0++; continue;}
		g = __gcd(a, b);
		a/=g, b/=g;
		if(a<0) a=-a, b=-b;
		if(b>0) mp[{a,b}].F++;
		else mp[{-b,a}].S++;
 	}
 	for(auto x:mp) {
		ans = ans * (pow2[x.S.F] + pow2[x.S.S] - 1 + M) % M;
 	}
 	cout << (ans + c0 - 1 + M) % M;
	return 0;
}

Measured memory_bytes: 20844
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
// const int N = ;
int d, t, s;

int main() {
  in(d); in(t); in(s);
  puts(t * s >= d ? "Yes" : "No");
  return 0;
}

void in(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	h*=30;
	double s=double(h)-double(m*5.5);
	s=fabs(s);
	if (s>180) s=360-s;
	double ans=sqrt(double(a*a)+double(b*b)-double(2.0*a*b*cos(s*acos(-1)/180)));
	cout << fixed << setprecision(22) << ans << endl;
	return 0;
}

Measured memory_bytes: 4228
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int R,G;
    cin >> R >> G;
    
    cout << 2*G -R << endl;
    
    return 0;
}

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

using namespace std;

string s[100005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	map <string, long long> anagrams;
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		if (anagrams.count(s[i])) {
			anagrams[s[i]]++;
		}
		else anagrams[s[i]] = 1;
	}
	long long cnt = 0;
	for (auto x: anagrams) {
		cnt += (x.second * (x.second - 1)) / 2;
	}
	cout << cnt << '\n';
	return 0;
}

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

long long gcp(long long x,long long y){
    if(x>y)swap(x, y);
    
    if(y%x==0)return x;
    else return gcp(y%x,x);
}

int main(void){
    long long a,b;cin>>a>>b;
    long long res = gcp(a, b);
    cout<<a/res*b<<endl;
}


Measured memory_bytes: 256
N = int(input())
numbers = [int(i)-1 for i in input().split()]

need_fix_index = []

for i, v in enumerate(numbers):
    if i == v:
        need_fix_index.append(i)
        
cnt = 0

while need_fix_index:
    cnt += 1
    v = need_fix_index.pop(0)
    if len(need_fix_index) == 0:
        break
    if abs(need_fix_index[0]-v) == 1:
        del need_fix_index[0]
    
print(cnt)

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

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


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

using namespace std;

const int N=1e5+5;

int pre[N],suf[N];
int n;

int main()
{
	cin >> n;
	while(n--)
	{
		int x;
		cin >> x;
		pre[x]++;
		suf[x]++;
	}
	for(int i=1;i<N;i++)
		pre[i]+=pre[i-1];
	for(int i=N-2;i>=0;i--)
		suf[i]+=suf[i+1];
	int ans=0;
	for(int i=1;i<N;i++)
		ans+=pre[i-1]==suf[i];
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]){
    int s;
    cin >> s;
    if ((s/1000)==(s/100%10)){
        cout <<"Bad" << endl;
        return 0;
    }
    if ((s/100%10)==(s/10%10)){
        cout <<"Bad" << endl;
        return 0;
    }
    if ((s/10%10)==(s%10)){
        cout <<"Bad" << endl;
        return 0;
    }
    cout <<"Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define MAX 1000000
#define INF 1000000000

int dp1[MAX+1],dp2[MAX+1];

int main() {
    for(int i = 1;i <= MAX;i++) {
        dp1[i] = INF;
        dp2[i] = INF;
    }

    for(int n = 1;n * (n + 1) * (n + 2) / 6 <= MAX;n++) {
        int a = n * (n + 1) * (n + 2) / 6;
        for(int i = a;i <= MAX;i++) {
            dp1[i] = min(dp1[i],dp1[i - a] + 1);
        }
        if(a % 2 == 0)continue;
        for(int i = a;i <= MAX;i++) {
            dp2[i] = min(dp2[i],dp2[i - a] + 1);
        }
    }

    while(true) {
        int n;
        cin >> n;
        if(n == 0)break;
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


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

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

using ll = long long;
using P = pair<int, int>;

const ll INF=1e8;
const ll MOD=1e9+7;

int main(int, char**)
{
    int n;
    cin >> n;

    vector<ll> lf(n+1);
    rep(i,n+1) cin >> lf[i];

    vector<ll> acum(n+2,0);
    rep(i,n+1) acum[n-i] = acum[n-i+1] + lf[n-i];

    vector<ll> innd(n+1);
    rep(i,n+1) {
        if (!i) innd[i] = 1;
        else innd[i] = min(acum[0], innd[i-1] * 2);
        innd[i] -= lf[i];
        if (innd[i] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    rep(i,n+1) ans += min(acum[i], innd[i] + lf[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5636
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    vector<vector<int>> res(h,vector<int>(w,0));
    REP(i,h-b){
        REP(j,a){
            res[i+b][j]=1;
        }
    }
    REP(i,b){
        REP(j,w-a){
            res[i][j+a]=1;
        }
    }
    REP(i,h){
        REP(j,w){
            cout << res[i][j];
        }
        put("");
    }
    return 0;
}


Measured memory_bytes: 5120
k,a,b= map(int,input().split())
cur = 1
#交換しないほうがいい
if b - a <= 2:
  print(cur + k)
  exit()
#交換できない
if cur + k <= a+1:
  print(cur + k)
  exit()
#交換するまで増やす
cur, k, = a, k-a+cur
#偶数回交換する
cur += (b - a) * (k // 2)
k %= 2
#最後に足す
cur += k
print(cur)

Measured memory_bytes: 9048
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.be\
gin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<\
pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), it\
em)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

// 1, 1, -1  kaidoku
ll A, B, C;
// 0, 1, 1 deli

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

    ll A, B, C;
    cin >> A >> B >> C;


    C = min(C, A+B+1);
    cout << B + C << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
position = [[0]*3 for _ in range(n)]
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())
    if ans != "No":
        if x + y > t:
            ans = "No"
        else:
            if t % 2 == (x+y) % 2:
                ans = "Yes"
            else:
                ans = "No"
print(ans)

Measured memory_bytes: 13172
#include<stdio.h>
int main()
{
    int n,i,f=1;
    int a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        if(a[i]%2==0){
            if(a[i]%3==0||a[i]%5==0)
                continue;
            else {f=0;break;}
        }
    if(f==1)
        printf("APPROVED");
    else
        printf("DENIED");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    REP(i,10){
        REP(j,10){
            REP(k,10){
                int ok = 0;
                REP(id,n){
                    if(ok == 0 and int(s[id] - '0')== i){
                        ok ++;
                    }
                    else if(ok == 1 and int(s[id] - '0') == j){
                        ok ++;
                    }
                    else if(ok == 2 and int(s[id] - '0') == k){
                        ans ++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define long long int
signed main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	string s;
	int q;
	while(cin>>s>>q)
	{
		bool reverse=0;
		deque<char>l;
		for(char i:s) l.push_back(i);
		while(q--)
		{
			int t;
			cin>>t;
			if(t==1) reverse=1-reverse;
			else
			{
				char c;
				cin>>t>>c;
				if(reverse)
				{
					if(t==2) l.push_front(c);
					else l.push_back(c);
				}
				else
				{
					if(t==1) l.push_front(c);
					else l.push_back(c);
				}
			}		
		}
		if(reverse)
		{
			for (auto i=l.rbegin();i!=l.rend();i++) cout<<*i;
			cout<<"\n";
		}
		else
		{
			for(char i:l) cout<<i;
			cout<<"\n";
		}
	} 
}

Measured memory_bytes: 896
N = input()
n = [int(N[:2]), int(N[2:])]
a = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']
if n[0] > 12 or n[0] == 0:
  del a[1]
  del a[1]
  if n[1] > 12 or n[1] == 0:
    del a[0]
elif n[1] > 12 or n[1] == 0:
  del a[0]
  del a[1]
else:
  a = [a[2]]
print(a[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
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 repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,m;cin>>n>>m;
  int ans=(n-1)*(m-1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 		int a = sc.nextInt();
 		int b = sc.nextInt();
		if(a == 1){
			a=a+13;
		}
		if(b == 1){
			b=b+13;
		}
		if(a == b) {
			System.out.println("Draw");
		}else if(a > b) {
			System.out.println("Alice");
		}else {
			System.out.println("Bob");
		}
		sc.close();
	}
 
}

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
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 trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

bool check(const vector<pll> &a, const vector<pll> &b){
	ll ans = 0;
	for(auto v: a) {
		ans -= v.first;
		if(ans < 0) return false;
		ans += v.second;
	}
	for(auto v: b) {
		ans -= v.first;
		if(ans < 0) return false;
		ans += v.second;
	}
	return ans == 0;
}

int main(){
	ll n; cin >> n;
	// multiset<pair>ms; 
	vector<pair<ll,ll>> a, b;
	for(ll i = 0; i < n; i++){
		string s; cin >> s;
		ll neg = 0, fineg = 0;
		for(ll i = 0; i < s.size(); i++){
			if(s[i] == '(') {
				neg++;
			} else {
				neg--;
			}
			if(neg < 0) {
				fineg = min(fineg, neg + fineg);
				neg = 0;
			}	
		}
		trace(neg, fineg);
		if(abs(fineg) < abs(neg)) {
			a.pb({abs(fineg), neg});
		}
		else {
			b.pb({abs(fineg), neg});
		}
	}
	sort(a.begin(), a.end(),
		[](const pair<ll,ll> &u, const pair<ll,ll> &v){
			return u.first < v.first;
		});
	sort(b.begin(), b.end(),
		[](const pair<ll,ll> &u, const pair<ll,ll> &v){
			return u.second > v.second;
		});
	for(auto v: a) trace(v.first, v.second);
	for(auto v: b) trace(v.first, v.second);
	if(check(a, b)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 19028
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,m = m()

a = list(map(int,input()))

on = cl.deque()
la = n

while True:
    if la == 0:
        break
    for i in range(m,0,-1):
        if la - i >= 0 and a[la-i] == 0:
            la -= i
            on.appendleft(i)
            break
    else:
        print(-1)
        exit()
print(jo(on))









Measured memory_bytes: 53724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		System.out.println(s.equals("Sunny") ? "Cloudy" : s.equals("Cloudy") ? "Rainy" : "Sunny");

	}
}

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

using ll = long long; 

int main() {
    int N;
    int K;
    
    scanf("%d%d", &N, &K);
    
    int ans = 0;
    
    while (N > 0) {
        N /= K;
        ans += 1;
    }
    
    printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    ll sum=0,dig=0;
    rep(i,m){
        int d;
        ll c;
        cin>>d>>c;
        sum+=d*c;
        dig+=c;
    }

    cout<<dig-1+((sum-1)/9)<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> lp;
const int inf=0x3f3f3f3f;
void A() {
    char c;
    cin>>c;
    if(c<='z'&&c>='a') cout<<'a'<<endl;
    else cout<<'A'<<endl;
}
void B() {

}
void C() {

}
void D() {

}
void E(){

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


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    // (H+1)*(W+1) - 1 edges

    int w, h;
    cin >> w >> h;
    vi p(w), q(h);
    fori(i, w) cin >> p[i];
    fori(i, h) cin >> q[i];
    sort(all(q));
    vl pref(h + 1);
    fori(i, h)
    {
        pref[i + 1] = pref[i] + q[i];
    }
    ll ans = 0;
    fori(i, w)
    {
        int lt = lower_bound(all(q), p[i]) - q.begin();
        ans += pref[lt];
        ans += (h + 1 - lt) * 1LL * p[i];
    }
    ans += pref.back();
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 4844
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    ABs = [tuple(map(int, input().split())) for _ in range(N)]

    def isOK_LE(X, thre):
        num = 0
        for A, B in ABs:
            if A <= X:
                num += 1
        return num >= thre

    def isOK_GE(X, thre):
        num = 0
        for A, B in ABs:
            if X <= B:
                num += 1
        return num >= thre

    def binS_LE(isOK, thre):
        ng, ok = 0, 10**9+1
        while abs(ok-ng) > 1:
            mid = (ng+ok) // 2
            if isOK(mid, thre):
                ok = mid
            else:
                ng = mid
        return ok

    def binS_GE(isOK, thre):
        ng, ok = 10**9+1, 0
        while abs(ok-ng) > 1:
            mid = (ng+ok) // 2
            if isOK(mid, thre):
                ok = mid
            else:
                ng = mid
        return ok

    if N % 2:
        num = (N+1)//2
        mn = binS_LE(isOK_LE, num)
        mx = binS_GE(isOK_GE, num)
#        print('mn:', mn, '/ mx:', mx)
#        print(mx-mn)
        return mx-mn+1
    else:
        num = N//2
        mn1 = binS_LE(isOK_LE, num)
        mx1 = binS_GE(isOK_GE, num+1)
        mn2 = binS_LE(isOK_LE, num+1)
        mx2 = binS_GE(isOK_GE, num)
#        print('mn1:', mn1, '/ mx1:', mx1)
#        print('mn2:', mn2, '/ mx2:', mx2)
        mn = mn1+mn2
        mx = mx1+mx2
#        print('mn:', mn, '/ mx:', mx)
#        print(mx-mn)
        return mx-mn+1


ans = solve()
print(ans)


Measured memory_bytes: 96124
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n;
llint x[100005], y[100005];
UnionFind uf(100005);
vector<llint> vec[100005], vecx[100005];
set<llint> S[100005];
llint cnt[100005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	for(int i = 1; i <= n; i++) vec[x[i]].push_back(y[i]);
	for(int i = 1; i <= n; i++) vecx[y[i]].push_back(x[i]);
	
	for(int i = 1; i < 100005; i++){
		for(int j = 1; j < vec[i].size(); j++) uf.unite(vec[i][j-1], vec[i][j]);
	}
	for(int i = 1; i < 100005; i++){
		for(int j = 0; j < vecx[i].size(); j++){
			S[uf.root(i)].insert(vecx[i][j]);
		}
		cnt[uf.root(i)]++;
	}
	
	llint ans = 0;
	for(int i = 1; i < 100005; i++){
		ans += S[i].size() * cnt[i];
	}
	ans -= n;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 18304
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> p(n);
	REP(i, n) cin >> p[i];
	string ans = "";
	int pos = 0;
	stack<int> st;
	REP(i, n) {
		if(!st.empty() && p[i] == st.top()) {
			ans += ")";
			st.pop();
		} else if(p[i] > pos) {
			while(pos < p[i]) {
				pos++;
				st.push(pos);
				ans += "(";
			}
			ans += ")";
			st.pop();
		} else {
			cout << ":(" << endl;
			return 0;
		}
	}
	cout << ans << endl;
}
/* --------------------------------------- */



Measured memory_bytes: 3780
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String v = sc.nextLine();
        String s;
        int g = 0;
        for (int index = 0; index < v.length(); index++) {
            if (v.charAt(index) != 'W' && v.charAt(index) != 'B') {
                g++;
            }
        }
        if (g != 0) {
            s = sc.nextLine();
        } else {
            s = v;
        }
        int c = s.codePointAt(0);
        int n = 0;
        for (int index = 1; index < s.length(); index++) {
            if (c != s.codePointAt(index)) {
                n++;
                c = s.codePointAt(index);
            }
        }
        System.out.println(n);
    }
}


Measured memory_bytes: 26316
def main():
    n = input()
    S = input()
    cnt = 0
    m = 0
    for s in S:
        if s == '(':
            cnt += 1
        else:
            cnt -= 1
        
        if cnt < 0:
            m += 1
            cnt += 1
            
    ans = "("*m+S+")"*cnt
    print(ans)
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 2940
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n = int(input())
seq = [int(x) for x in input().split()]
d = {}
s = 0
for val in seq:
    try:
        d[val] += 1
    except:
        d[val] = 1
    s += val
for _ in range(int(input())):
    b,c = (int(x) for x in input().split())
    if b in d:
        s -= b * d[b]
        s += c * d[b]
        print(s)
        try:
            d[c] += d[b]
        except:
            d[c] = d[b]
        d[b] = 0
    else:
        print(s)


Measured memory_bytes: 96840
// バブルソート
// O(n^2)　安定

#include <stdio.h>

#define MAX 100

void swap(int *a, int *b) {
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void disp(int A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

int bubbleSort(int A[], int N) {
    int i, cnt = 0;
    int flag = 1;

    while (flag) {
        flag = 0;
        for (i = N - 1; 0 < i; i--) {
            if (A[i] < A[i - 1]) {
	            swap(&A[i], &A[i - 1]);
	            cnt++;
	            flag = 1;
            }
        }
    }
    return cnt;
}


int main(){
    int i, N;
    int A[MAX];
    int count;

    scanf("%d", &N);

    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    count = bubbleSort(A, N);

    disp(A, N);
    printf("%d\n", count);

    return 0;
}


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

int level(int d) {
  int s = 1;
  while (d % 2 == 0) {
    s++;
    d /= 2;
  }
  return s;
}

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      cout << level(j - i);
      if (j == n - 1) {
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }
}


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

using ll = long long;

using namespace std;

int main()
{
	vector<ll> a;
	ll n, tmp, b[2];
	int i, j, c = 0, r;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> r;
		a.push_back(r);
	}

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

	for (i = n - 1; i > 0; i--) {
		if (a[i] == a[i - 1]) {
			b[c] = a[i];
			c++;
			if (c == 2) {
				break;
			}
			i--;
		}
	}

	if (i == 0) {
		cout << '0' << endl;
	}
	else {
		cout << b[0] * b[1] << endl;
	}

	return 0;
}

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

using namespace std;

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

    vector<long long> C(N);
    vector<vector<long long>> A(N);

    for (int i = 0; i < N; ++i) {
        long long Ci;
        cin >> Ci;
        C.at(i) = Ci;

        A.at(i).resize(M);

        for (int j = 0; j < M; ++j) {
            long long Aij;
            cin >> Aij;
            A.at(i).at(j) = Aij;
        }
    }

    vector<long long> skills(M);
    long long price;
    long long min = -1;

    for (int i = 0; i < (1 << N); ++i) {
        for (int j = 0; j < M; ++j) {
            skills.at(j) = 0;
        }

        price = 0;

        for (int j = 0; j < N; ++j) {
            if ((i >> j) % 2) {
                for (int k = 0; k < M; ++k) {
                    skills.at(k) += A.at(j).at(k);
                }

                price += C.at(j);
            }
        }

        bool complete = true;

        for (auto s : skills) {
            if (s < X) {
                complete = false;
            }
        }

        if (complete) {
            if (min == -1 || price < min) {
                min = price;
            }
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int X = max(A, max(B, C));
    int Y = min(A, min(B, C));
    int Z = (A + B + C) - (X + Y);
    for (int i = 0; i < K; i++) {
        X *= 2;
    }
    cout << X + Y + Z << endl;
}

Measured memory_bytes: 3532
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	vector<int>v(5);
	rep(i, 5)cin >> v[i];
	rep(i, 5) {
		if (v[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>

typedef long long lint;

using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
string a, b;
bool judge(int i);
int main() {
	getline(cin, a);
	getline(cin, b);
	rep(i,a.length()){
		if (judge(i)) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}
bool judge(int i) {
	if (a[i] == b[0]) {
		repi(j, 1, b.length()) {
			if (a[(i + j) % a.length()] != b[j])return false;
		}
		return true;
	}
	else return false;
}


Measured memory_bytes: 3200
import java.io.IOException;
import java.util.NoSuchElementException;

fun main(args: Array<String>) {
    val fs = FastScanner()
    val N = fs.nextInt()
    val s = IntArray(N)
    (1..N).forEach {
        s[it - 1] = fs.nextInt()
    }

    val sum = s.sum()
    if (sum % 10 != 0) {
        println(sum)
    } else {
        s.sort()
        val num = s.find {
            it % 10 != 0
        }
        if (num == null) {
            println(0)
        } else {
            println(sum - num)
        }
    }
}
internal class FastScanner {
    private val `in` = System.`in`
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            try {
                buflen = `in`.read(buffer)
            } catch (e: IOException) {
                e.printStackTrace()
            }

            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int {
        return if (hasNextByte()) buffer[ptr++].toInt() else -1
    }

    private fun isPrintableChar(c: Int): Boolean {
        return 33 <= c && c <= 126
    }

    operator fun hasNext(): Boolean {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
        return hasNextByte()
    }

    operator fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n: Long = 0
        var minus = false
        var b = readByte()
        if (b == '-'.toInt()) {
            minus = true
            b = readByte()
        }
        if (b < '0'.toInt() || '9'.toInt() < b) {
            throw NumberFormatException()
        }
        while (true) {
            if ('0'.toInt() <= b && b <= '9'.toInt()) {
                n *= 10
                n += (b - '0'.toInt()).toLong()
            } else return if (b == -1 || !isPrintableChar(b)) {
                if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int {
        val nl = nextLong()
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
}

Measured memory_bytes: 33856
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;



ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

signed main() {
    ll n;
    cin >> n;
    
    vll a(n);
    
    ll r = 0;
    
    rep(i, n) {
        cin >> a[i];
        if (i == 0) r = a[i];
        if (i > 0) {
            r = gcd(r, a[i]);
            
        }
    }
    
    mes(r);
    
    
    

    
    
    
    
    
    
    
    
}

Measured memory_bytes: 4032