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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

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

int main (void) {
    int H,W;
    cin >> H >> W;
    vector<string> A(H);
    REP(i,H) cin>>A[i];
    ll ans = 0;
    queue<pair<int,int>> q;
    vector<vector<bool>> used(H,vector<bool>(W,false));
    REP(i,H) {
        REP(j,W) {
            if (A[i][j] == '#') {
                q.push(make_pair(j,i));
                used[i][j] = true;
            }
        }
    }
    
    while (1) {
        ans ++;
        vector<pair<int,int>> nn;
        while (q.size()) {
            pair<int,int> p = q.front();
            q.pop();
            int x = p.fi;
            int y = p.se;
            //cout << x << " " << y << endl;
            REP(i,4) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx < 0 || nx >= W) continue;
                if (ny < 0 || ny >= H) continue;
                if (used[ny][nx]) continue;
                //cout << "    " << nx << " " << ny << endl;
                used[ny][nx] = true;
                A[ny][nx] = '#';
                nn.pb(make_pair(nx,ny));
            }
        }
        if (nn.size() == 0) break;
        REP(i,nn.size()) {
            q.push(nn[i]);
        }
    }
    cout << ans - 1 << endl;
    return 0;
}

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

ll mem[55][55*55][55];
int a[55] , n , A ;


ll dp(int i,int sum,int cnt){
if( i==n ){
    return ( sum==A*cnt && cnt>0 )?1ll:0ll;
}

ll &ret=mem[i][sum][cnt];
if( ret !=-1 )return ret;

return ret=dp(i+1,sum,cnt)+dp(i+1,sum+a[i],cnt+1);
}

int main(){
scanf("%d %d",&n,&A);
for(int i=0;i<n;i++)scanf("%d",a+i);
memset(mem,-1,sizeof mem);
printf("%lld\n",dp(0,0,0));
return 0;
}


Measured memory_bytes: 71680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int value[n],cost[n];
    rep(i,n) cin >> value[i];
    rep(i,n) cin >> cost[i];
    int ans = 0;
    rep(i,n) if(value[i] > cost[i]) ans += value[i] - cost[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c0=0,c1=0,c2=0,c3=0;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="AC"){
      c0+=1;
    }
    else if(s=="WA"){
      c1+=1;
    }
    else if(s=="TLE"){
      c2+=1;
    }
    else if(s=="RE"){
      c3+=1;
    }
  }
  cout<<"AC x "<<c0<<endl;
  cout<<"WA x "<<c1<<endl;
  cout<<"TLE x "<<c2<<endl;
  cout<<"RE x "<<c3<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define MOD 1000000007
#define Long long long 
using namespace std;
Long fac(int t){
	Long ans = 1;
	For(i,1,t){
		ans *= i;
		ans %= MOD;		
	}
//	cout << ans <<" " ;
	return ans;
}
main(){
	int n, m;
	cin >> n >> m;
	if(n<m){
		int a = n; n = m; m = a;		
	}
	Long ans = 0;
//	cout << fac(100000);
	if(n>m+1){
		cout << 0;
	}	else	{
		if(n==m ){			
			ans = (fac(n)*fac(m))% MOD;
			ans = (ans*2) % MOD;
		}	else	{
			ans = (fac(n)*fac(m)) % MOD;
		}
		cout << ans;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int ans=1;
    int i;
    if (n==1)
    {
        cout<<"1"<<endl;
        return 0;
    }
    for (i=1;; i++)
    {
        ans=ans*2;
        if (ans>n)
        {
            break;
        }
    }
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  cout << C <<" " << A <<" "<< B << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

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

int main()
{
	int N; cin >> N;
	int mx=0, mi=0;
	vector<int> b(8),a(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());

	for (int i = 0; i < N; i++) {
		if (a[i] >= 1 && 399 >= a[i]){
			if (b[0] != 1) mx++, mi++;
			b[0] = 1;
		}
		else if (a[i] >= 400 && 799 >= a[i]) {
			if (b[1] != 1) mx++, mi++;
			b[1] = 1;
		}
		else if (a[i] >= 800 && 1199 >= a[i]) {
			if (b[2] != 1)mx++, mi++;
			b[2] = 1;
		}
		else if (a[i] >= 1200 && 1599 >= a[i]) {
			if (b[3] != 1)mx++, mi++;
			b[3] = 1;
		}
		else if (a[i] >= 1600 && 1999 >= a[i]) {
			if (b[4] != 1)mx++, mi++;
			b[4] = 1;
		}
		else if (a[i] >= 2000 && 2399 >= a[i]) {
			if (b[5] != 1)mx++, mi++;
			b[5] = 1;
		}
		else if (a[i] >= 2400 && 2799 >= a[i]) {
			if (b[6] != 1)mx++, mi++;
			b[6] = 1;
		}
		else if (a[i] >= 2800 && 3199 >= a[i]) {
			if (b[7] != 1)mx++, mi++;
			b[7] = 1;
		}
		else{
			if (mi == 0)mi++;
			mx++;
		}
	}
	cout << mi <<" "<< mx << endl;
	return	0;
}

Measured memory_bytes: 256
a = 0
b = 0
c = 0

while True:
    t = sorted(list(map(int, input().split())))
    if t[0]+t[1] <= t[2]:
        print(a+b+c, b, a, c)
        break
    elif t[0]**2+t[1]**2 > t[2]**2:
        a += 1
    elif t[0]**2+t[1]**2 == t[2]**2:
        b += 1
    else:
        c += 1


Measured memory_bytes: 5596
import sys
sys.setrecursionlimit(500000)
 
N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])
 
 
def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)
 
 
dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])

Measured memory_bytes: 152280
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int H, W; cin >> H >> W;
    int count[26] = {};
    REP(i, 0, H) {
        string s; cin >> s;
        for (auto c : s) count[c - 'a']++;
    }

    int center = 0, odd = 0;
    REP(i, 0, 26) {
        if (count[i] % 2 == 1) odd++;
        center += count[i] % 4;
    }

    if (odd > 1) {
        cout << "No" << endl;
        return 0;
    }

    int center_line = ((H % 2 == 0) ? 0 : W) + ((W % 2 == 0) ? 0 : H) - ((H % 2 == 1 && W % 2 == 1) ? 1 : 0);
    if (center == center_line) {
        cout << "Yes" << endl;
    } else if (center < center_line && (center - center_line) % 4 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<int> dp(n);
	for (int i = 0; i < n - 1; ++i) {
		dp[i + 1] = dp[i];
		if (s.substr(i, 2) == "AC") dp[i + 1]++;
	}
	for (int i = 0; i < q; ++i) {
		int l, r; cin >> l >> r;
		l--, r--;
		cout << dp[r] - dp[l] << endl;
	}

	return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    int blank = 16 - (A + B);
    int flag = 0;
    if(A<B){
        swap(A,B);
    }
    for(int i=0; i <= blank; i++){
        int C = A - i;
        if(abs(C - B) == 1 || abs(C - B) == 0){
            flag = 1;
        }
        else{
            continue;
        }
    }
    if(flag == 1){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 3588
using System;

class Program
{
    static void Main(string[] args)
    {
        //変数定義
        int n;
        string[] input2;
        int[] ls;
        int x=0;
        string output;

        //Inputします
        n = int.Parse(Console.ReadLine());
        input2 = Console.ReadLine().Split(' ');
        ls = new int[input2.Length];
        for (int i = 0; i < n; i++)
        {
            ls[i]= int.Parse(input2[i]);
        }

        //処理
       Array.Sort(ls);
        Array.Reverse(ls);
        for(int i = 1; i < n; i++)
        {
            x = x + ls[i];
        }
        x = x - ls[0];

        //判定
        if (x > 0)
            output = "Yes";
        else
            output = "No";

        //Outputします
        Console.WriteLine(output);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
      fact%=1000000007;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n;
  cin >> n;
  cout << fact(n) << endl;
}

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


int main(){
    ll A,B;
    cin >> A >> B;
    if(A>12){
        cout << B << endl;
    }else if(A>5){
        cout << B/2 << endl;
    }else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;


int main() {
	string str;
	stack<int> st;

	

	while(getline(cin, str) && str != ".") {
		bool successed = true;
		st.push(2);

		FOR(i, 0, str.size()) {
			char c = str[i];

			if(c == '(') {
				st.push(0);
			} else if(c == '[') {
				st.push(1);
			} else if(c == ')') {
				if(st.top() != 0) {
					successed = false;
					break;
				}
				st.pop();
			} else if(c == ']') {
				if(st.top() != 1) {
					successed = false;
					break;
				}
				st.pop();
			}
		}

		if(successed) {
			if(st.top() == 2) {
				cout << "yes" << endl;
			} else {
				cout << "no" << endl;
			}
		} else {
			cout << "no" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 924
let arr1=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let m1 = arr1[0]
let d1 = arr1[1]
let arr2=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
print( (m1 != arr2[0]) ? 1 : 0 )

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string S;

  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3652
import sys

input_lines = sys.stdin.readlines()


lines = map(lambda x: x[:-1], input_lines)

lines = map(lambda x: x.split(" "), lines)

n = int(lines[0][0])

lines.pop(0)

for l in lines:
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, l)
    
    X1 = x2 - x1
    X2 = x4 - x3
    Y1 = y2 - y1
    Y2 = y4 - y3
    if abs(X1*Y2 - X2*Y1) < 1e-10:
        print "YES"
    else:
        print "NO"

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

using namespace std;
using int64 = long long int;

int A[3][3];
bool open[3][3];

int main()
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> A[i][j];
		}
	}

	int n;
	cin >> n;

	for (int _ = 0; _ < n; _++)
	{
		int b;
		cin >> b;

		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (A[i][j] == b)
				{
					open[i][j] = true;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++)
	{
		bool contains = true;
		for (int j = 0; j < 3; j++)
		{
			if (!open[i][j])
			{
				contains = false;
				break;
			}
		}

		if (contains)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	for (int i = 0; i < 3; i++)
	{
		bool contains = true;
		for (int j = 0; j < 3; j++)
		{
			if (!open[j][i])
			{
				contains = false;
				break;
			}
		}

		if (contains)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	bool contains = true;
	for (int i = 0; i < 3; i++)
	{
		if (!open[i][i])
		{
			contains = false;
		}
	}

	if (contains)
	{
		cout << "Yes" << endl;
		return 0;
	}

	contains = true;
	for (int i = 0; i < 3; i++)
	{
		if (!open[i][2 - i])
		{
			contains = false;
		}
	}

	if (contains)
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
class c
{
    static void Main()
    {
        var nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var ans = new long[nm[0] + 1];
        ans[0] = 1;
        for (int i = 0; i < nm[1]; i++)
        {
            ans[int.Parse(Console.ReadLine())] = -1;
        }
        for (int i = 1; i < ans.Length; i++)
        {
            if (ans[i] == -1) continue;
            if (i - 1 >= 0 && ans[i - 1] != -1)
            {
                ans[i] += ans[i - 1];
            }
            if (i - 2 >= 0 && ans[i - 2] != -1)
            {
                ans[i] += ans[i - 2];
            }
            ans[i] %= 1000000007;
        }
        Console.WriteLine(ans[ans.Length - 1]);
    }
}

Measured memory_bytes: 13792
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let d = nextIntArray()
    let ans = 0
    for(let i = 0;i<d.length; i++){
        for (let j = 0; j<d.length; j++){
            if(i == j) continue
            ans += d[i]*d[j]
        }
    }
    console.log(ans/2)
}
Main()


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

int main(void){
	int i,j,k;
	int n,m,val,a[7],b[7];
	int dp[8][1001];

	while(scanf("%d",&n), n){
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}

		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;

		for(i=0;i<n;i++){
			for(j=0;j<=1000;j++){
				for(k=0;k<=b[i];k++){
					if(j+a[i]*k>1000) continue;
					dp[i+1][j+a[i]*k] += dp[i][j];
				}
			}
		}

		scanf("%d",&m);
		while(m--){
			scanf("%d",&val);
			printf("%d\n",dp[n][val]);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
vecl(A)
vecl(B)

ll ref(int n,ll x){
     if(x<=1||n==0){if(n==0)return 1; else return 0;}
     if(A.at(n-1)+2>x){return ref(n-1,x-1);}
     if(A.at(n-1)+2==x){return (B.at(n-1)+1);}
 if(A.at(n-1)+2<x){return (B.at(n-1)+1+ref(n-1,x-A.at(n-1)-2));}
}

int main() {

	int N;
	ll X;
	cin>>N>>X;
pb(A,1)pb(B,1)
fx(N+1){
pb(A,A.at(x)*2+3)
pb(B,B.at(x)*2+1)
}
ll ans=0;
ans=ref(N,X);
	ce(ans)


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define endl '\n';
typedef long long int ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int x,y,z,k;
    cin >> x >> y >> z >> k;

    ll a[x];
    ll b[y];
    ll c[z];


    for(int i=0; i<x; i++){
        cin >> a[i];
    }

    for(int i=0; i<y; i++){
        cin >> b[i];
    }

    for(int i=0; i<z; i++){
        cin >> c[i];
    }

    vector<ll> b_c;
    for(int i=0; i<y; i++){
        for(int j=0; j<z; j++){
            b_c.push_back(b[i]+c[j]);
        }
    }

    sort(b_c.begin(), b_c.end(), greater<ll>());
    vector<ll> a_b_c;

    for(int i=0; i<x; i++){
        for(int j=0; j<min(3000, y*z); j++){
            a_b_c.push_back(b_c[j] + a[i]);
        }
    }

    sort(a_b_c.begin(), a_b_c.end(), greater<ll>());

    for(int i=0; i<k; i++){
        cout << a_b_c[i] << endl;
    }


    return 0;
}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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;
}


Measured memory_bytes: 3596
from itertools import starmap


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


q = int(input())
while q:
    q -= 1
    p0, p1, p2, p3 = starmap(complex, zip(*[map(int, input().split())] * 2))
    d1, d2 = abs(cross(p3 - p2, p0 - p2)), abs(cross(p3 - p2, p1 - p2))
    c = p0 + (p1 - p0) * d1 / (d1 + d2)
    print(c.real, c.imag)

Measured memory_bytes: 7756
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

#define ll long long

ll read()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

inline void out (int x)
{
	if (x>9) out(x/10);
	putchar (x%10+'0');
}

int n;
ll a[110];

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;
}

void doing ()
{
	n=read();
	ll ans;
	for (int i=1;i<=n;i++) a[i]=read();
	ans=a[1];
	for (int i=2;i<=n;i++)
	  ans=lcm(ans,a[i]);
	cout<<ans<<endl;
}

int main ()
{
	//freopen("xx.in","r",stdin);
	//freopen("xx.out","w",stdout);
	doing ();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

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

using namespace std;
using ll = long long;


// const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

const int mod = 2019;

int main() {
  ll L, R;
  cin >> L >> R;

  vector<ll> data;
  for(int i = L; i <= R; i++) {
    if(data.size() == mod) break;
    data.push_back(i % mod);
  }

  sort(all(data));
  ll ans = 2018;
  for(int i = 0; i < data.size(); i++) {
    for(int j = 0; j < data.size(); j++) {
      if(i != j) ans = min(ans, (data[i] * data[j]) % mod);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n, k;
    cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for (int i=0;i<n;i++)
    {
        int m=min(a[i], abs(a[i]-k));
        ans+=2*m;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main() {
  int n, k; cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x; cin >> x;
    n -= x;
  }
  cout << (n > 0 ? "No" : "Yes") << 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 n = sc.nextInt();
        int t = n % 10;
        if(t == 2 || t == 4 || t == 5 || t == 7 || t == 9){
            System.out.println("hon");
        }else if(t == 0 || t == 1 || t == 6 || t == 8){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }
    }
}

Measured memory_bytes: 26908
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
sub = []
for i in range(m - 1):
    sub.append(x[i+1] - x[i])
sub.sort()
ans = 0
for i in range(m - n):
    ans += sub[i]
print(ans)

Measured memory_bytes: 13968
H,W = map(int,input().split())
if H==1 and W==1:
    print(1)
elif H%2==0 and W%2==0:
    print((H-2)*(W-2))
elif H%2==0 and W%2!=0:
    print(max(1,(H-2))*max(1,(W-2)))
else:
    print(H*(W-2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
 
int main() {
    int n,cnt,acnt;
    string a;
    cin >> n;
    cin >> a;
    cnt = 0;
    acnt = 0;


    for(int i=0;i<n;i++){
        if(a[i] == 'R'){
            cnt++;
        }else{
            acnt++;
        }
    }

    if(cnt>acnt){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#pragma endregion

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x;
    if(n < b - 1)
        x = n;
    else
        x = b - 1;
    cout << (a * x / b) - a * (x / b) << endl;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[520000],n,b[520000];
bool cmp(int a,int b) {return a>b;}
signed main(){
	int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++) {cin>>a[i];b[i]=a[i]-i;}
	sort(b+1,b+n+1,cmp);
	if(n%2==1){
		for(int i=1;i<=n;i++) ans+=abs(b[i]-b[n/2+1]);
		cout<<ans<<endl;
	} else {
		for(int i=1;i<=n;i++) ans+=abs(b[i]-(b[n/2]+b[n/2+1])/2);
		cout<<ans<<endl;
	}

	// for(int i=1;i<=n;i++) b[i]=b[i-1]+b[i];
	// for(int i=1;i<=n;i++){
	// 	int s=0;
	// 	s+=b[i-1]-(i-1)*(b[i]-b[i-1]);
	// 	s+=(n-i)*(b[i]-b[i-1])-(b[n]-b[i]);
	// 	ans=min(ans,
	// }
	// cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5888
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    long long C;
    cin >> N >> C;
    vector<long long> x(N), v(N);
    repeat(i, N) cin >> x[i] >> v[i];
    vector<pair<long long, long long>> AnOA(N + 1, make_pair(0LL, 0LL));
    vector<pair<long long, long long>> BnOB(N + 1, make_pair(0LL, 0LL));
    repeat(i, N) {
        AnOA[i + 1].first = v[i] + AnOA[i].first;
        AnOA[i + 1].second = x[i];
    }
    repeat(i, N) {
        if (AnOA[i + 1].first - AnOA[i + 1].second <= AnOA[i].first - AnOA[i].second) {
            AnOA[i + 1] = AnOA[i];
        }
    }
    for (int i = N - 1; i >= 0; --i) {
        BnOB[i].first = v[i] + BnOB[i + 1].first;
        BnOB[i].second = C - x[i];
    }
    for (int i = N - 1; i >= 0; --i) {
        if (BnOB[i].first - BnOB[i].second <= BnOB[i + 1].first - BnOB[i + 1].second) {
            BnOB[i] = BnOB[i + 1];
        }
    }
    long long B = 0;
    long long OB = 0;
    long long res = numeric_limits<long long>::min();
    for (int i = N; i >= 0; --i) {
        if (i < N) {
            B += v[i];
            OB = C - x[i];
        }
        long long A = AnOA[i].first;
        long long OA = AnOA[i].second;
        setmax(res, B - OB - OB + A - OA);
    }
    long long A = 0;
    long long OA = 0;
    for (int i = 0; i <= N; ++i) {
        if (0 < i) {
            A += v[i - 1];
            OA = x[i - 1];
        }
        long long B = BnOB[i].first;
        long long OB = BnOB[i].second;
        setmax(res, A - OA - OA + B - OB);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8012
n = int(input())

x, y, t = 0, 0, 0
for i in range(n):
  t2, x2, y2 = map(int, input().split())
  d = abs(x-x2) + abs(y-y2)
  dt = t2 - t
  if d > dt or (dt - d) % 2 == 1:
    print("No")
    exit(0)
  x, y, t = x2, y2, t2

print("Yes")

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

int main(){
   int a,b,A,B,k ,K;
   cin >>a >>b>>k;
   for(int i=0;i<k;i++){
      if(i%2==0){
      if(a%2==1){
         a --;}
      A = a;
      B = b;
      b = b + A/2;
      a =a - A/2;}
      else{
      if(b%2==1){
         b --;}
      A = a;
      B = b;
      b = b - B/2;
      a =a +B/2;
   }
   }
   cout << a << " " <<b<<endl;
}     

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll D, T, S;

void read(){
    cin >> D >> T >> S;
}

void solve(){
    read();
    if(S * T >= D) cout << "Yes";
    else cout << "No";
}



int main(){
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

template<class T>
struct Triangle {
  T a,b,c;
  Triangle(T a, T b, T c) : a(a),b(b),c(c) {}
  double area() {
    double s = (a+b+c)*0.5;
    return sqrt(s*(s-a)*(s-b)*(s-c));
  }
  bool isTriangle() {
    return abs(a-b) < c && c < a+b;
  }
  // G getG() {
  //   G t(3);
  //   t[0] = P(0,0);
  //   t[1] = P(a,0);
  //   double x = (a*a+b*b-c*c)/(2*a);
  //   t[2] = P(x,sqrt(b*b-x*x));
  //   return t;    
  // }
  int typeByAngle() {
    if (a*a>b*b+c*c ||
        b*b>c*c+a*a ||
        c*c>a*a+b*b) return -1; // Oblique
    if (a*a==b*b+c*c ||
        b*b==c*c+a*a ||
        c*c==a*a+b*b) return 1; // Right
    return 0;                   // Acute
  }  
};

int main() {
  int a,b,c;
  int A=0,B=0,C=0,D=0;
  while(cin >> a >> b >> c) {
    Triangle<ll> tri(a,b,c);
    if (!tri.isTriangle()) break;
    A++;
    int type = tri.typeByAngle();
    if (type == 0) C++;
    else if (type > 0) B++;
    else D++;
  }
  printf("%d %d %d %d\n",A,B,C,D);
}

Measured memory_bytes: 1144
(let* ((n (read))
       (p (make-array `(,n)))
       (q (make-array `(,n))))
  (loop :for i :from 0 :to (1- n)
        :for x := (read)
        :do (setf (aref p i) x)
        :do (setf (aref q i) x))
  (setf q (sort q #'<))
  (if (<= (loop :for i :from 0 :to (1- n)
                :if (/= (aref p i) (aref q i))
                :sum 1) 2)
      (format t "YES~%")
      (format t "NO~%")))


Measured memory_bytes: 23796
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;
    
    int ans=(a+b)/2;
    if((a+b)%2) ans++;
    
    cout1(ans)
}

Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

counter i = i *  (i - 1) `div` 2

solve :: [String] -> Int
solve ws = let
    sws = sort <$> ws
    inner mp wd = let
        cnt = M.findWithDefault 0 wd mp
        in
            M.insert wd (cnt + 1) mp
    search = foldl' inner M.empty sws
    in
        foldl' (\acc  (k,v) -> acc + counter v) 0 $ M.toList search


main = do
    num <- readInt
    ws <- replicateM num getLine
    print $ solve ws


Measured memory_bytes: 107900
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;
int main(){
    string scin;
    cin >> scin;
    int n = scin.size();
    vector<int> s(n);
    for(int i=0; i<n; ++i){
        s[i] = scin[i] - 'A';
    }
    ll ctr = 0;
    ll ctr_tmp = 0;
    for(int i=0; i<n-1; ++i){
        if(s[i] == 0){++ctr_tmp;}
        else if( (s[i]==1) && (s[i+1] == 2) ){
            ctr += ctr_tmp;
            i++;
        }else{
           ctr_tmp=0;
        }
    }
    cout << ctr << endl;
    return 0;
}




Measured memory_bytes: 1404
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;

//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<ll> a(Q);
    vector<ll> b(Q);
    vector<ll> c(Q);
    vector<ll> d(Q);
    rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    //
    ll mx = 0;
    const auto check = [&](std::array<int,10> A)
    {
        if (M < A[N - 1]) return;
        ll score = 0;
        rep(i,Q) if (A[b[i]-1] - A[a[i] - 1] == c[i]) score += d[i];
        chmax(mx, score);
    };
    // 
    for (int i1 = 1; i1 <= 10; ++i1)
        for (int i2 = i1; i2 <= 10; ++i2)
            for (int i3 = i2; i3 <= 10; ++i3)
                for (int i4 = i3; i4 <= 10; ++i4)
                    for (int i5 = i4; i5 <= 10; ++i5)
                        for (int i6 = i5; i6 <= 10; ++i6)
                            for (int i7 = i6; i7 <= 10; ++i7)
                                for (int i8 = i7; i8 <= 10; ++i8)
                                    for (int i9 = i8; i9 <= 10; ++i9)
                                        for (int i10 = i9; i10 <= 10; ++i10)
                                            check({ i1,i2, i3, i4, i5, i6, i7, i8, i9, i10 });

    cout << mx;

    return 0;
}

Measured memory_bytes: 3620
def resolve():
    n=int(input())
    A=sorted(list(map(int,input().split())))
    if n%2:
        A.insert(0,0)
        flag=all(A[2*i]==2*i and A[2*i+1]==2*i for i in range(len(A)//2))
    else:
        flag=all(A[2*i]==2*i+1 and A[2*i+1]==2*i+1 for i in range(len(A)//2))
    print(2**(n//2)%(10**9+7) if flag else 0)
resolve()

Measured memory_bytes: 52844
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
	int n, m, l[100000], r[100000], cnt = 0, ans = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
	}
	sort(l, l + m);
	reverse(l, l + m);
	sort(r, r + m);
	ans = r[0] - l[0] + 1;
	if (ans < 0) {
		ans = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
H = list(map(int,input().split(" ")))
H_orig = H[:]
heights = [0 for i in range(N)]

cnt = 0

while True:
    #print(heights,H)
    if min(H) > min(heights):
        for i in range(N):
            heights[i] += 1
            H[i] -= 1
        cnt += 1
    else:
        flag = False
        for i in range(N):
            #H[i]
            if H[i] > 0:
                heights[i] += 1
                H[i] -= 1
                flag = True
            else:# H[i] == 0:
                if flag:
                    cnt += 1
                    flag = False
                    
            if i == N-1 and flag:
                cnt += 1
        
    if H_orig == heights:
        break
    
print(cnt)


Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#define _GLIBCXX_DEBUG

#include <iomanip>
using namespace std;

template<typename T> vector<T> range(T begin, T end, T stride = 1) {
    vector<T> vec;
    for (T i = begin; i < end; i += stride) {
        vec.push_back(i);
    }
    return vec;
}

template<typename T> T factorial(T in) {
    long long ans = 1;
    for (int i=2; i < in + 1; ++i) ans *= i;
    return ans;
}

int main() {
    int n; cin >> n;
    vector<int> v = range(0, n);
    vector<int> x(n), y(n);
    for (int i=0; i < n; ++i) cin >> x[i] >> y[i];
    double sum = 0;
    do {
        for (int i=0; i<n-1; i++) {
            sum += sqrt((x[v[i+1]] - x[v[i]]) * (x[v[i+1]] - x[v[i]]) + (y[v[i+1]] - y[v[i]]) * (y[v[i+1]] - y[v[i]]));
        }
    } while(next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(15) << sum / factorial(n) << endl;
}


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

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	int K, X;
	cin >> K >> X;
	for (int i = -K + 1; i < K; i++) {
		cout << X + i << endl;
	}
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const 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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool ok = true;
  for(int i=0; i<A+B; i++){
    if(i == A){
      if(S[i] != '-') ok = false;
    }else{
      if(!isdigit(S[i])) ok = false;
    }
  }
  if(ok){
     cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	list<char> li;
	for(char c: s) {
		if(c == 'B') {
			if(li.size() > 0) li.pop_back();
		} else {
			li.push_back(c);
		}
	}
	for(char c: li) cout << c;
}


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

// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int X;
  cin >> X;
  if(X<=599) cout << 8;
  else if(X<=799) cout << 7;
  else if(X<=999) cout << 6;
  else if(X<=1199) cout << 5;
  else if(X<=1399) cout << 4;
  else if(X<=1599) cout << 3;
  else if(X<=1799) cout << 2;
  else  cout << 1;
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

void yes() {
    cout << "Yes" << '\n';
}
void no() {
    cout << "No" << '\n';
}

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(a < b or a%b > c or b > d) {
            no();
        } else if(c >= b-1) {
            yes();
        } else {
            a %= b;
            ll num = gcd(b, d);
            if((b-1-a)/num != (c+1-a)/num or (c+1-a)%num == 0) {
                no();
            } else {
                yes();
            }
        }
    }
}

Measured memory_bytes: 3652