akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, Q;
int S, T, X;
size_t pos = 0;
int D[200001];
pair<int, int> E[400002];

int main() {
    scanf("%d %d\n", &N, &Q);
    set<int> C;
    REP(i, N) {
        scanf("%d %d %d\n", &S, &T, &X);
        E[i*2] = make_pair(S - X, X);
        E[i*2+1] = make_pair(T - X, -X);
    }
    N <<= 1;
    REP(i, Q) scanf("%d", D + i);
    sort(E, E + N);
    REP(i, Q) {
        while(pos < N && E[pos].first <= D[i]) {
            if(E[pos].second > 0) C.insert(E[pos].second);
            else C.erase(C.find(-E[pos].second));
            pos++;
        }
        printf("%d\n", C.empty() ? -1 : *C.begin());
    }
 	return 0;
}

Measured memory_bytes: 14592
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long double D;

int main(){
  D d;
  cin >> d;

  D ans = 0;
  int a = floor(d);
  if( d*d < a*a + 1 + 1e-9 )ans = a+1;

  cout << fixed << setprecision(12) << max(sqrt(d*d/2)*2,ans) << endl;
}

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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        left = min(a[i], b[i])
        ans += left
        a[i] -= left
        b[i] -= left

        right = min(a[i + 1], b[i])
        ans += right
        a[i + 1] -= right
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 19228
import Data.Int

main :: IO ()
main = do
    [a,b,k] <- map read . words <$> getLine :: IO [Int64]
    let k' = max 0 (k - a)
        a' = max 0 (a - k)
        b' = max 0 (b - k')
    putStr $ show a'
    putStr " "
    putStrLn $ show b'

Measured memory_bytes: 508
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
ans = max(a+b, a-b, a*b)
print(ans)


Measured memory_bytes: 5696
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h , w;
    cin >> h >> w;
    char a[h + 2][w + 2];
    for( int i = 0 ; i <= h + 1 ; i++ ) {
        for( int j = 0 ; j <= w + 1 ; j++ ) {
            if( i == 0 || j == 0 || i == h + 1 || j ==  w + 1 ) a[i][j] = '.';
            else cin >> a[i][j];
        }
        cout << endl;
    }
    for( int i = 1 ; i <= h ; i++ ) {
        for( int j = 1 ; j <= w ; j++ ) {
            int c = 0;
            if( a[i][j] == '#' ) cout << '#';
            else {
                if( a[i - 1][j - 1] == '#' ) c++;
                if( a[i - 1][j] == '#' ) c++;
                if( a[i - 1][j + 1] == '#' ) c++;
                if( a[i][j - 1] == '#' ) c++;
                if( a[i][j + 1] == '#' ) c++;
                if( a[i + 1][j - 1] == '#' ) c++;
                if( a[i + 1][j] == '#' ) c++;
                if( a[i + 1][j + 1] == '#' ) c++;
                cout << c;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
int main(){

  //input
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  
  //dp_setup
  //define:dp[i]=0-indexedでi番目のマスに辿り着くまでの最小コスト
  int dp[N];
  for(int i=1;i<N;i++) dp[i]=INF;
  dp[0]=0;
  
  //dp_onwork
  for(int i=0;i<N-1;i++){
    dp[i+1]=min(dp[i+1],dp[i]+abs(A[i+1]-A[i]));
    if(i+2<N) dp[i+2]=min(dp[i+2],dp[i]+abs(A[i+2]-A[i]));
  }
  
  //output
  cout << dp[N-1] << endl;

}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.replaceAll("/", "");
        Integer in = Integer.valueOf(s);
        if (in <= 20190430) {
            System.out.println("Heisei");
        } else {
            System.out.println("TBD");
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n, m, dp[3007][3007];
string s, t, ans = "";

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s >> t;
	n = (int)s.length();
	m = (int)t.length();
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(s[i - 1] == t[j - 1]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	int ct = m, cur = dp[n][m];
	if(dp[n][m] == 0) exit(0);
	for(int i = n; i >= 1; i--){
		for(int j = ct; j >= 1; j--){
			if(dp[i][j] < cur) break;
			if(s[i - 1] == t[j - 1]){
				ct = j - 1;
				ans = s[i - 1] + ans;
				cur--;
				break;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	int a[4] = { 10,50,100,500 };
	bool flag = true;
	int coin[4];
	int mcoin[4];
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			cin >> coin[0] >> coin[1] >> coin[2] >> coin[3];

			n = coin[0] * 10 + coin[1] * 50 + coin[2] * 100 + coin[3] * 500 - n;
			for (int i = 3; i >= 0; i--) {
				mcoin[i] = n / a[i];
				n -= mcoin[i] * a[i];
			}

			if (flag) {
				flag = false;
			} else {
				cout << endl;
			}
			REP(i, 4)
			{
				if (coin[i] - mcoin[i] > 0) {
					cout << a[i] << ' ' << coin[i] - mcoin[i] << endl;
				}
			}
		}
	}
}

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

const int mod = 1e9 + 7;

int main() {
	int n, b; long long ans; string s1, s2;
	cin >> n >> s1 >> s2;
	if (s1[0] == s2[0])ans = 3; else ans = 6;
	for (int i = 0; i < n - 1; i++) {
		if (s1[i] == s1[i+1])continue;
		if (s1[i] == s2[i]) {
			if (s1[i + 1] == s2[i + 1])b = 2;
			else if (s1[i + 1] != s2[i + 1])b = 2;
		}
		else if (s1[i] != s2[i]) {
			if (s1[i + 1] == s2[i + 1])b = 1;
			else if (s1[i + 1] != s2[i + 1])b = 3;
		}
		ans = (ans * b) % mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  double odd =(n+1)/2;
  double pre = odd/n;
  cout << fixed << setprecision(15) << pre << endl;
  return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, M;
int K[110000];
vint L[110000], G[220000];
bool visited[220000];
void dfs(int x) {
    visited[x] = true;
    for (int i = 0; i < G[x].size(); i++) {
        if (!visited[G[x][i]]) dfs(G[x][i]);
    }
}

signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> K[i];
        L[i].resize(K[i]);
        for (int j = 0; j < K[i]; j++) {
            cin >> L[i][j];
            G[i].push_back(110000 + L[i][j]);
            G[110000 + L[i][j]].push_back(i);
        }
    }
    dfs(0);
    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mes(a,b) memset((a),(b),sizeof((a)))
#define syio std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
#define lson l, mid, rt << 1
#define rson mid+1, r, rt << 1 | 1
typedef long long ll;
typedef long double real;
typedef pair<int, int> pii;

const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mxn = 200033;
const int mod = 1e9+7;
inline int read(){
    int x = 0,f = 1;char c = getchar();
    while(!isdigit(c))f = c == '-' ? -1 : 1,c = getchar();
    while(isdigit(c))x = x * 10 + c - '0',c = getchar();
    return x * f;
}
int n;
ll a[mxn], sa[mxn];
int main()
{
    syio;
    cin>>n;
    for (int i = 1; i <= n; ++ i)
    {
        cin>>a[i]; sa[i] = (sa[i - 1] + a[i])%mod;
    } 
    ll res = 0;
    for (int i = 1; i < n; ++ i)
    {
        res = (res + a[i] * (sa[n] - sa[i] + mod)%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 6760
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  map<string, int> cnt;
  rep(i, n){
    string s;
    cin >> s;
    cnt[s]++;
  }
  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>

using namespace std;
#define NUM 300010
#define INF 1000000000

int A[NUM];
int B[NUM];
char V[NUM];

int main(void){
    int N;
    scanf("%d", &N);

    scanf("%s", V);

    for(int i = 0; i < N; i++){
        if(i == 0){
            A[i] = 0;
            continue;
        }
        if(V[i - 1] == 'W'){
            A[i] = A[i - 1] + 1;
        }else{
            A[i] = A[i - 1];
        }
    }

    for(int i = 0; i < N; i++){
        if(i == 0){
            B[N - 1 - i] = 0;
            continue;
        }
        if(V[N - i] == 'E'){
            B[N - i - 1] = B[N - i] + 1;
        }else{
            B[N - i - 1] = B[N - i];
        }
    }

    int min_ = INF;
    for(int i = 0 ; i < N; i++){
        min_ = min(min_, A[i] + B[i]);
    }

    /*
    for(int i = 0; i < N; i++){
        printf("%d, %c  %d %d\n",i, V[i],  A[i], B[i]);
    }
    */

    printf("%d\n", min_);

}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
string s[200005];
map<string, int> mp;
void solve() {
    cin >> n;
    rep(i, n) cin >> s[i];
    rep(i, n) ++mp[s[i]];

    int ma = 0;
    for (auto& p : mp) maxs(ma, p.second);

    vector<string> v;
    for (auto& p : mp) if (p.second == ma) v.emplace_back(p.first);
    all(sort, v);
    rep(i, v.size()) cout << v[i] << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N;
	const int MAX_VAL = 1000005;

	cin >> N;
	vector<int> cnt(MAX_VAL);
	vector<int> val(N, 0);

	int t;
	rep(i, N) cin >> val.at(i);

	for (int x : val)
	{
		if (cnt.at(x) != 0)
		{
			cnt.at(x) = 2;
			continue;
		}
		for (int i = x; i < MAX_VAL; i += x) cnt.at(i)++;
	}

	int ans = 0;
	for (int x : val)
	{
		if (cnt.at(x) == 1) ans++;
	}

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

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
    {
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
ll d[N];

int main(){
	ll x;
	cin>>x;
	while(x%2==0) x /= 2;
	while(x%5==0) x /= 5;
	deque<int> q;
	fill(d, d+x+1, INF);
	d[1] = 1;
	q.push_back(1);
	while(!q.empty()){
		ll u = q.front(); q.pop_front();
		rep(i, 2){
			int v = (i?(u+1):(u*10))%x;
			if(d[v]>d[u]+i){
				d[v] = d[u]+i;
				if(i) q.push_back(v);
				else q.push_front(v);
			}
		}
	}
	cout<<d[0]<<endl;
	return 0;
}


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

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

  long long int y;
  cin >> y;

  int ichi = 0, gosen = 0, sen =0;
  
  bool loop = false;
  for(int i = 0; i <= n; ++i){
    for(int j = 0; j <= n; ++j){
      int c = y - (i * 10000 + j * 5000);
      if(c >= 0 && (c % 1000) == 0 && (i + j + c / 1000) == n){
        ichi = i, gosen = j, sen = c / 1000;
        loop = true;
        break;
        }
      else continue;
    }
    if(loop) break;
    else continue;
  }

  if(loop) cout << ichi << ' ' << gosen << ' ' << sen  << endl;
  else cout << -1 << ' ' << -1  << ' ' << -1 << endl;

  return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        ll n=s.size();
        ll A[200]={0},k=0;
        for(ll i=0;i<n;i++)
        {
            A[s[i]]++;
        }
        for(ll i=97;i<=122;i++)
        {
            if(A[i]>1)
            {
                cout<<"no";
                k=1;
                break;
            }
        }
        if(k==0)
        cout<<"yes";
    }
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> b(n);
    rep(i, n-1)cin >> b[i];
    b[n-1] = 1000000;
    reverse(ALL(b));
    
    ll ans = 0;
    ll mx = 1000000;
    rep(i, n-1){
        ans += min(b[i], b[i+1]);
    }
    ans += b.back();
    cout << ans << endl;
}

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

typedef long long ll;

const int maxn = 100010;

ll h[maxn];
int n;
ll a,b;

bool check(ll k)
{
	ll cnt = 0;
	for (int i=1;i<=n;i++)
	{
		if (h[i] <= b * k) continue;
		cnt += (h[i] - b*k) / (a-b);
		if ((h[i]-b*k)%(a-b)!=0) cnt++;
	}
	if (cnt <= k) return true;
	else return false;
}

int main()
{
	scanf("%d%lld%lld",&n,&a,&b);
	for (int i=1;i<=n;i++) scanf("%lld",&h[i]);
	
	ll lb = 1ll, ub = 1000000010ll;
	while (ub > lb+2)
	{
		ll mid = (ub+lb)/2;
		if (check(mid)) ub = mid+1;
		else lb = mid+1;
	}
	if (check(lb)) cout<<lb<<endl;
	else cout<<lb+1<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
	int n;
	cin >> n;
 
	vector<pair<int, int>> r(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> r[i].second >> r[i].first;
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i].first >> b[i].second;
	}
 
 	sort(r.begin(), r.end());
  	sort(b.begin(), b.end());
  	vector<int> used(n);
  	int idx, res = 0;
  	for (int i = 0; i < n; ++i) {
    	bool f = false;
    	for (int j = 0; j < n; ++j) {
      		if (r[j].second < b[i].first && r[j].first < b[i].second) { 
        		if (used[j]==0) {
          			f = true;
          			idx = j;
        		}
      		}
    	}
    	if (f) {
      		++res;
      		used[idx] = 1;
    	}
  	}
  	cout << res << endl;
 }

Measured memory_bytes: 256
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))	
y = list(map(int,input().split()))	
ans="War"
for Z in range(X+1,Y+1):
    if( max(x)<Z and Z<=min(y)):
        ans="No War"
        break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		int n,l;
		cin>>n>>l;
		vector<string> s(n);
		for(int i=0;i<n;i++)
			cin>>s[i];

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

		for(auto i:s)
			cout<<i;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll fastpow(ll x, int k, ll mod){
    ll res = 1;
    while(k){
        if(k%2) res = res*x%mod;
        x = x*x%mod;
        k >>= 1;
    }
    return res;
}

void solve(){
    ll x, y, a, b;
    
    cin >> x >> y;
    if((2*y-x)%3 != 0 | (2*x-y)%3 != 0){
        cout << 0 << '\n';
        return ;
    }
    a = (2*y-x)/3;
    b = (2*x-y)/3;
    
    if(a < 0 || b < 0){
        cout << 0 << '\n';
        return ;
    }
    ll ans = 1;
    if(a < b)   swap(a,b);
    for(ll i=a+1;i<=a+b;i++)
        ans = ans*i%MOD;
    for(ll i=2;i<=b;i++)
        ans = ans*fastpow(i, MOD-2, MOD)%MOD;
    cout << ans << '\n';
}

int main(){
    int t = 1;
    
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#define EPS (1e-7)
using namespace std;






int main() {

	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << "0" << endl;
	}
	else {
		cout << "10" << endl;
	}

	return 0;
}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll H, W;
    cin >> H >> W;
    vector<string> map(H);
    vector<bool> rows(H, false);
    vector<bool> cols(W, false);
    for(ll h = 0;h < H;h++) {
        cin >> map[h];
        for(ll w = 0;w < W;w++) {
            if(map[h][w] == '#') {
                rows[h] = true;
                cols[w] = true;
            }
        }
    }
    for(ll h = 0;h < H;h++) {
        if(rows[h]) {
            for(ll w = 0;w < W;w++) {
                if(cols[w]) cout << map[h][w];
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    if n % 2 == 0 {
        put!(0.5);
    } else {
        put!((n - n / 2) as f64 / n as f64);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
import sys

stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str

s=ns()
if (s[0:2]<="12")&(s[0:2]>"00")&((s[2:4]>"12")|(s[2:4]=="00")):
	print("MMYY")
elif (s[0:2]<="12")&(s[0:2]>"00")&(s[2:4]<="12")&(s[2:4]>"00"):
	print("AMBIGUOUS")
elif ((s[0:2]>"12")|(s[0:2]=="00"))&(s[2:4]<="12")&(s[2:4]>"00"):
	print("YYMM")
else:
	print("NA")

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

int main(){
int n,ans[100],kuri,i,j,ap,bp;
char a[1000],b[1000];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s%s",a,b);
if(strlen(a)>80||strlen(b)>80){
printf("overflow\n");
continue;
}
ap=strlen(a)-1;
bp=strlen(b)-1;
j=0;
kuri=0;
while(ap>=0||bp>=0){
ans[j]=kuri;
if(ap>=0)ans[j]+=a[ap]- '0';
if(bp>=0)ans[j]+=b[bp]- '0';
kuri=ans[j]/10;
ans[j]%=10;
j++;
ap--;
bp--;
}
if(kuri==1)ans[j]=1;
else j--;
if(j>=80){
printf("overflow\n");
continue;
}
for(;j>=0;j--){
printf("%d",ans[j]);
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

vi trans(vi p, int k){
  vi a;
  for(int i=0;i<p.size();i++){
    for(int j=0;j<p[i];j++){
      a.push_back(k);
    }
    k = 1-k;
  }
  return a;
}

vi pos(vi a){
  vi res;
  for(int i=0;i<a.size();i++){
    if(a[i])res.push_back(i);
  }
  return res;
}

int main(){
  int n,m;
  cin >> n >> m;
  vi b(n),p(m);
  for(int i=0;i<n;i++)cin >> b[i];
  for(int j=0;j<m;j++)cin >> p[j];
  
  int ans = 1e9;
  for(int c=0;c<2;c++){
    vi a = trans(p,c);
    vi pos1 = pos(b), pos2 = pos(a);
    if(pos1.size() != pos2.size())continue;

    int sum = 0;
    for(int i=0;i<pos1.size();i++){
      sum += abs(pos1[i] - pos2[i]);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String s = scan.nextLine();

		//System.out.println(s);
		StringBuilder ss = new StringBuilder("");

		int nagasa = s.length();
		int a = 0;
		int i = 0;
		int b=ss.length();

		for (i = 0; i < nagasa; i++) {

			char c1 = s.charAt(i);
			String str = String.valueOf(c1);

			if (str.equals("1")) {

				ss = ss.append("1");

			}else if (str.equals("0")) {

				ss = ss.append("0");

			}else if (str.equals("B")) {

				if(ss.length()==0) {

				}else {
					ss = ss.deleteCharAt(ss.length()-1);

				}
			}
			//System.out.println(ss);
		}

		System.out.println(ss);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == '1') {
            S.at(i) = '9';
        } else if (S.at(i) == '9') {
            S.at(i) = '1';
        }
    }
    cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a;
  cin>>a;

  int b;
  b=a*800;
  a=(a/15)*200;
  cout<<b-a<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef  long long  ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll binpow(ll x, ll y) {
	ll z = 1;
	while (y) {
		if (y % 2) z = (z * x) % mod;

		y = y / 2;
		x = (x * x) % mod;
	}
	return z % mod;
}

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

//	cin >> tc;

	while (tc--) {
		
		string s,t ;
		cin >> s;
		cin >> t;
		
		for(int i=0; i<s.length(); i++){
			if(s[i] != t[i]){
				cout << "No" << endl;
				return 0;
			}
		}
		
		cout << "Yes" << endl;

	}

}


Measured memory_bytes: 3612
p = input()

s = list(p)
s.sort()

answer = -1

check = []
for i in range(26):
    check.append(False)

for i in range(len(s)):
    x = ord(s[i])
    check[x - 97] = True

for i in range(26):
    if not check[i]:
        answer = i + 97
        break

if answer == -1:
    print('None')
else:
    print(chr(answer))

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

int main() {
    string s;
    int k;
    int l;
    vector<string> v;
    
    cin >> s >> k;
    l = s.length();
    
    for (int i = 1; i <= 5; i++) {
        for (int ii = 0; ii < (l - i + 1); ii++) {
            v.push_back(s.substr(ii, i));
        }
    }
    
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
/* Work 3_3
 * AtCoder Digits
 * cy_an */

#include <stdio.h>

int main(void){
    int n, k, count = 1;    // 変数宣言
    scanf("%d %d", &n, &k); // n, kを入力

    while(n / k != 0){      // n ÷ kの商が0になるまでループ
        n = n / k;          // nの値をn ÷ kの商にする
        count++;            // 1回ごとにカウントアップ
    }
    printf("%d\n", count);  // countの値を出力
    return 0;
}

Measured memory_bytes: 128
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
bool com(pi &a,pi&b)
{
       return a.first-a.second>b.first-b.second;
}

void solve()
{
    ll n;cin>>n;
    string s;
    vector<pi>vec;ll left=0,right=0,s0=0,s1=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        ll open,closed;
        open=closed=0;
        for(int j=0;j<s.size();j++)
        {
            if(s[j]=='(')
                open++;
            else if(s[j]==')')
            {
                if(open)
                    open--;
                else
                    closed++;
            }
        }
        if(closed==0)
            left+=open;
        else if(open==0)
            right+=closed;
        else
            vec.pb({open,closed});
        //cout<<open<<" "<<closed<<endl;
        //cout<<s0<<" "<<s1<<endl;
        //cout<<open<<" "<<closed<<endl;
    }
    sort(vec.begin(),vec.end(),com);
    //for(auto it:vec)
      //  cout<<it.first<<" "<<it.second<<endl;
    pi ans=vec[0];
    for(int i=0;i<vec.size();i++)
    {
        if(left<vec[i].second)
        {cout<<"No"<<endl;return;}
        left+=vec[i].first-vec[i].second;
    }
    if(left==right)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 7364
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;

void trace(int A[], int N){
    int i;
    for (i=0;i<N;i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N){
    int j,v;
    for (int i=1;i<N;i++){
        v = A[i];
        j = i-1;
        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
    }
}
int main(){
    int n, A[MAX];
    cin >> n;
    for (int i=0;i<n;i++) cin >> A[i];

    trace(A,n);
    insertionSort(A,n);

    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
int main()
{
    int n,i;
    double t=0,y=0,v;
    while(scanf("%lf",&v)!=EOF)
        {
            t=v/9.8;
            y=t*t*4.9;

            for(i=0;;i=i+5)
            {
                if(y<i+5&&i<=y)
                {
                    n=i/5+2;
                    break;
                }

            }
            printf("%d\n",n);
        }
        return 0;
}

Measured memory_bytes: 628
//LETS START AGAIN
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int 
signed main() 
{ 
    fast;
    int n,m;
    cin>>n>>m;
    set<int> fact;
    for(int i=1;i*i<=m;i++)
    {
        if(m%i == 0)
        {
            fact.insert(i);
            fact.insert(m/i);
        }
    }
    int ans = 1;
    for(auto it:fact)
    {
        if(it*n<=m)
        {
            ans = it;
        }
        else break;
    }
    cout<<ans;
} 



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

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

    int K, N, A[200003];

    cin >> K >> N;
    for (int i = 1; i <= N; i++)
        cin >> A[i];

    int maxi = 0;
    for (int i = 2; i <= N; i++)
        maxi = max(maxi, A[i] - A[i - 1]);

    maxi = max(maxi, K - A[N] + A[1]);

    cout << K - maxi << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if (h == 0 && w == 0) {
				scanner.close();
				return;
			}
			
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					System.out.print(((i + j) % 2 == 0) ? '#': '.');
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



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


int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b){
		cout << c << endl;
	}else if(b==c){
		cout << a << endl;
	}else{
		cout << b << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a;
    int t = 0, f = 0, o = 0;
    for (int j = 0; j < n; j++) {
        cin >> a;
        if (a % 4 == 0) {
            f++;
        }
        else if (a % 2 == 0) {
            t++;
        }
        else {
            o++;
        }
    }
    if (t == 0 && f >= o - 1) {
        cout << "Yes";
    }
    else if (f == o) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  int mni = min_element(all(A)) - begin(A);
  ll mn = A[mni];
  int mxi = max_element(all(A)) - begin(A);
  ll mx = A[mxi];
  cout << 2*n-1 << endk;
  if(abs(mx) > abs(mn)) {
    rep(i, n) {
      cout << mxi+1 << ' ' << i+1 << endk;
      A[i] += A[mxi];
    }
    rep(i, n-1) {
      cout << i+1 << ' ' << i+2 << endk;
      A[i+1] += A[i];
    }
  } else {
    rep(i, n) {
      cout << mni+1 << ' ' << i+1 << endk;
      A[i] += A[mni];
    }
    rrep(i, n-1) {
      cout << i+2 << ' ' << i+1 << endk;
      A[i] += A[i+1];
    }
  }
  return 0;
}


Measured memory_bytes: 3664
n, m = map(int, input().split())
par = [i for i in range(n)]
import sys
sys.setrecursionlimit(1000000)

def find(x, par):
    if par[x] == x:
        return x
    else:
        a = find(par[x], par)
        par[x] =a
        return a

def unite(x, y):
    x = find(x, par)
    y = find(y, par)
    if x != y:
        par[x] = y

for _ in range(m):
    a, b = map(int, input().split())
    unite(a-1, b-1)

groups= 0
for i in range(n):
    if i == par[i]:
        groups +=1
print(groups-1)

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

#define MAXN 20
#define MAXD 105
#define int long long
#define LL long long
#define pii pair<long, long>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;

string K;
int N;
int a[MAXN][MAXN];
int dp[1<<16];

signed main() {
    fastio;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) cin >> a[i][j];
    }
    for (int state = 0; state < (1<<N); state++) {
        dp[state] = 0;
        for (int i = 0; i < N; i++) {
            if (!(state & (1 << i))) continue;
            for (int j = i+1; j < N; j++) {
                if (state & (1 << j)) dp[state] += a[i][j];
            }
        }
        for (int substate = state; substate > 0; substate = state & (substate - 1)) {
            int sub2 = state ^ substate;
            if (sub2 > substate) break;
            dp[state] = max(dp[state], dp[substate] + dp[sub2]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 896
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long INF = 1LL << 60;
ll MOD = 1e9+7;

int main() {

    int N; cin>>N;
    vector<ll> A(N+1,0);
    for (int i = 1; i <= N; ++i) {
        cin>>A[i];
    }

    vector<ll> B(N+1,0);
    for (int i = N-1; i >= 1; --i) {
        B[i] = (A[i+1] + B[i+1]) % MOD;
    }

    ll ans = 0;
    for (int i = 1; i < N; ++i) {
        ans += A[i]*B[i];
        ans %= MOD;
    }

    cout<<ans<<endl;

}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) cout << "Left" << endl;
  if (A + B == C + D) cout << "Balanced" << endl;;
  if (A + B < C + D) cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1


print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

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

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
  mint p(int n, int k)
  {
    return fact[n] * ifact[n - k];
  }
} c(1000005);

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  mint ans = 0;
  for (int i = 0; i <= N; i++)
  {
    mint now = c(N, i);
    now *= c.p(M - i, N - i);
    if (i & 1)
      now = -now;
    ans += now;
  }
  ans *= c.p(M, N);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18588
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	cin>>N;
	long long i=0;
	while(i*i<=N)
	{
		i++;
	}
	printf("%lld\n",(i-1)*(i-1));
	return 0;
}

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

int main(){
    string str, com, p;
    int q, a, b;

    cin >> str >> q;
    for (int t = 0; t < q; t++){
        cin >> com >> a >> b;
        if (com == "print"){
            cout << str.substr(a, b-a+1) << endl;
        }
        else if (com == "reverse"){
            string tmp = str.substr(a, b-a+1);
            int n = tmp.size();
            for (int i = 0; i < n; i++)  str[i+a] = tmp[n-i-1];
        }
        else if (com == "replace"){
            cin >> p;
            str = str.replace(a, b-a+1, p);
        }
    }

}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S; cin >> S;
  stack<char> st;
  REP(i, N){
    if(st.empty()){
      st.push(S[i]);
    }else{
      char C = st.top();
      if(C == '(' && S[i] == ')'){
        st.pop();
      }else{
        st.push(S[i]);
      }
    }
  }
  int a = 0, b = 0;
  while(!st.empty()){
    char C = st.top(); st.pop();
    if(C == ')') a++;
    if(C == '(') b++;
  }
  REP(i, a){
    cout << "(";
  }
  cout << S;
  REP(i, b){
    cout << ")";
  }
  cout << endl;
}

Measured memory_bytes: 3620
X, N = map(int, input().split())

if N == 0:
    print(X)

else:
    p = list(map(int, input().split()))
    q = [i for i in range(-1, 102)]

    for r in p:
        idx = q.index(r)
        del q[idx]

    if X in q:
        print(X)

    else:
        q.sort()
        mindif = 1000

        for num in q:
            dif = abs(X - num)
            if mindif <= dif:
                break
            else:
                mindif = dif
                ans = num
        print(ans)


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

int main() {
	int n ,team1 ,team2 ,score1 ,score2 ,a[100]={} ,save[100]={};
	cin>>n;
	for(int i=0;i<(n*(n-1)/2);i++){
		team1=0;
		team2=0;
		score1=0;
		score2=0;
		cin>>team1>>team2>>score1>>score2;
		if(score1>score2){
			a[team1]+=3;
		}
		else if(score1<score2){
			a[team2]+=3;
		}
		else if(score1==score2){
			a[team1]++;
			a[team2]++;
		}
	}
	for(int i=1;i<=n;i++){
		save[i]=a[i];
	}
	sort(a,a+n+1);
	for(int i=1;i<=n;i++){
		for(int l=1;l<=n;l++){
				if(a[l]==save[i]){
				if(a[l]==a[l+1]){

				}
				else{
						cout<<n-l+1<<endl;
						break;
				}	
			}
		}
	}

return 0;
}

Measured memory_bytes: 1180
//abc178_d.cpp
//Sun Sep 13 20:42:21 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	ll s;
	cin >> s;

	ll dp[2010];
	rep(i,2010)dp[i] = 0;
	dp[3] = 1;
	for (int i=4;i<2001;i++){
		dp[i] = (dp[i-3]+dp[i-1])%MOD;
	}

	ll ans = dp[s];


	cout << ans << endl;
//	printf("%.4f\n",ans);
}


Measured memory_bytes: 3604