akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll m = 0, sign=1;
		RANGE(i, 1, N) {
			m += sign * A[i];
			sign = sign > 0 ? -1 : 1;
		}
		VI R(N);
		R[0] = A[0] - m;
		RANGE(i, 1, N) {
			R[i] = 2*A[i-1] - R[i-1];
		}
		
		REP(i, N) {
			cout<<R[i];
			if(i<N-1) cout<<" ";
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
	int bingo[3][3];
	
	REP(i,3){
		REP(j,3){
			cin >> bingo[i][j];
		}
	}
	
	int cleared[3][3];
	
	REP(i,3){
		REP(j,3){
			cleared[i][j] = 0;
		}
	}
	int N;
	cin >> N;
	int b;
	REP(i,N){
		cin >> b;
		REP(i,3){
			REP(j,3){
				if(bingo[i][j] == b){
					cleared[i][j] = 1;
				}
			}
		}
	}
	int passed = 0;
	REP(i,3){
		if(cleared[i][0]&&cleared[i][1]&&cleared[i][2]) passed = 1;
		if(cleared[0][i]&&cleared[1][i]&&cleared[2][i]) passed = 1;
	}
	if(cleared[0][0]&&cleared[1][1]&&cleared[2][2]) passed = 1;
	if(cleared[2][0]&&cleared[1][1]&&cleared[0][2]) passed = 1;
	
	if(passed){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}	
}

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

int main(){
  int N;
  
  cin >> N;
  
  int count = 1;
  vector<string> gacha(N);
  
  for(int i=0; i<N; i++){
    cin >> gacha.at(i);
  }
  
  sort(gacha.begin(), gacha.end());
  
  //sting first = gacha.at(0);

  for(int i=0; i<N-1; i++){
    if(gacha.at(i+1) != gacha.at(i)){
    count++;
    }
  }
  cout << count << endl;
}


  


Measured memory_bytes: 9540
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	ll p = 0;
	ll q = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			p += a[i];
		}
		else {
			q += a[i];
		}
	}
	cout << abs(p - q) << endl;
}

Measured memory_bytes: 256
import java.util.*

enum class Ref(val msg: String) {
    LESS("a < b"),
    MORE("a > b"),
    EQ("a == b")
}

fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    if (a < b) {
        println(Ref.LESS.msg)
    } else if (a > b) {
        println(Ref.MORE.msg)
    } else {
        println(Ref.EQ.msg)
    }
}


Measured memory_bytes: 25440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> list(50);
  for(int i=0;i<M;i++){
    int a,b;
  	cin >> a >> b;
    list.at(a-1) += 1;
    list.at(b-1) += 1;
  }
  for(int i=0;i<N;i++)
    cout << list.at(i) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}
// 0-indexed
template <class T, class Op = T (*) (T, T)>
struct Segtree {
  int n;
  vector<T> dat;
  Op op;
  T unit;
  Segtree(int al, Op op = Op(), T unit = T()): op(op), unit(unit) {
    n = 1;
    while(n < al) {
      n *= 2;
    }
    dat = vector<T>(2 * n - 1, unit);
  }
  Segtree(const vector<T> &arr, Op op = Op(), T unit = T()): op(op), unit(unit) {
    int al = arr.size();
    n = 1;
    while(n < al) {
      n *= 2;
    }
    dat = vector<T>(2 * n - 1, unit);
    copy(arr.begin(), arr.end(), dat.begin() + n - 1);
    for(int i=n-2; i >= 0; i--) {
      dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  void update(int k, T x) {
    k += n - 1;
    dat[k] = x;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  // accumlate [a, b)
  T accum(int a, int b, int k = 0, int l = 0, int r = -1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return unit;
    if(a <= l && r <= b) return dat[k];
    T vl = accum(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = accum(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }
};

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;
  auto cl = [](int x, int y){return x | y;};
  Segtree<int, decltype(cl)> tr(n, cl, 0);
  REP(i,0,n) {
    tr.update(i, 1 << (s[i] - 'a'));
  }
  REP(x,0,q) {
    int t;
    cin >> t;
    if (t == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      tr.update(i, 1 << (c - 'a'));
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      int x = tr.accum(l, r);
      // cout << "x = " << hex << x << endl;
      int ret = 0;
      while (x > 0) {
        if (x % 2 == 1) {
          ret += 1;
        }
        x /= 2;
      }
      cout << ret << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5020
h,w,k = map(int,input().split())
a = []
for i in range(h):
	temp = []
	t = input()
	for j in range(w):
		if t[j] == ".": temp.append(0)
		else: temp.append(1)
	a.append(temp)
#print(a)
h_max = pow(2,h)
w_max = pow(2,w)
ans = 0
for i in range(h_max):
	h_str = str(bin(i)[2:])
	if len(h_str) < h: h_str = "0"*(h-len(h_str)) + h_str
	for j in range(w_max):
		w_str = str(bin(j)[2:])
		if len(w_str) < w: w_str = "0"*(w-len(w_str)) + w_str
		s = 0
		for m in range(h):
			for n in range(w):
				if h_str[m] == "0" and w_str[n] == "0":
					if a[m][n]: s += 1
		if s == k: ans += 1
		#print(h_str,w_str,s)
print(ans)


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

int main() {
  int i, current_index = 0;
  char input_str[11], answer_str[11] = "";
  scanf("%s", input_str);
  for(i = 0; i < strlen(input_str); i++) {
    if(input_str[i] == 'B') {
      if(current_index != 0) {
        current_index--;
        answer_str[current_index] = NULL;
      }
    } else {
      answer_str[current_index] = input_str[i];
      current_index++;
    }
  }
  printf("%s\n", answer_str);
  return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=[]
num=0
sum=0
for i in range(n):
    q=a[i]-b[i]
    if q<0:
        num+=1
        sum-=q
    else:
        cnt.append(q)

if num==0:
    print(0)
    exit()

else:
    res=num
    cnt.sort(reverse=True)
    p=0
    for i in range(len(cnt)):
        p+=cnt[i]
        res+=1
        if p>=sum:
            break

    if p>=sum:
        print(res)
        exit()

print(-1)


Measured memory_bytes: 18356
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define fr(i,a,b) for(i=a;i<b;i++)
#define rfor(i,a,b) for(i=b-1;i>=a;i++)     // reverse loop
#define yes "YES"
#define no "NO"
#define srt(a) sort(a.begin(),a.end())
#define rsort(a) sort(a.rbegin(),a.rend())          // reverse sort

using namespace std;
const int mod = 1e9 + 7;
vector<ll>prime(1000001,1);
vector<ll>sdf(1000001,1);
long long inf=1000000000000000007;


vector<vector<int>>l;
vector<bool>visited;


/*

int isprime(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            {//cout<<i<<endl;
            return 0;}
    }
    return 1;
}
int isperfectsq(ll n)
{


    long double x;
    x=(long double)(sqrt((long double )(n)));
    ll y=sqrt(n);
    if(x==y)
        return 1;
        else
            return 0;
}
*/
//ll C[101][101];
/*void ncr()
{
    C[0][0] = 1;
    for (int n = 1; n <= 500000; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; ++k)
            C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
    }
}
*/
/*
void sieve()
{
    //cout<<"in1";
    ll i;
    //sdf[i]=1;
    ll j;
    //for(i=1;i<=1000000;i++)
      //  sdf[i]=i;
    prime[0]=prime[1]=0;
    for(i=2;i<=1000000;i++)
    {
            if(prime[i]){
            //isprime.push_back(i);
            for(j=2*i;j<=1000000;j+=i)
            {
                prime[j]=0;
               // if(sdf[j]==j)
                 //   sdf[j]=i;
                 a[j]++;
            }
            }

    }

}
*/

ll maxi(ll a,ll b,ll c)
{
    ll m1=max(a,b);
    ll m2=max(a,c);
    return max(m1,m2);
}

long long modular_expo(long double x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return modular_expo(x*x,y/2);
    if(y%2==1)
        return x*modular_expo(x*x,(y-1)/2);


}
/*
void dfs(int t)
{
    int temp;
    visited[t]=true;
    //cout<<t<<" ";

        for(auto i=l[t].begin();i!=l[t].end();i++)
        {
            if(!visited[*i])
                dfs(*i);
        }

}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    if(t>=30)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }


}



////////////////////// bit masking ///////////
/*
ll total=long (pow(2,n));
    ll mask,j,cnt=0,ans=0,maxi,mini;
    for(mask=0;mask<total;mask++)
    {
        if(mask==0||mask==1||mask==2||mask==4||mask==8)
                continue;
        cnt=0;maxi=-1000000000000;mini=1000000000000;
        for(i=0;i<n;i++)
        {

            ll f=1<<i;
            if(mask&f)
            {
                maxi=max(maxi,a[i]);
                mini=min(mini,a[i]);
                cnt+=a[i];
            }
        }
        if(cnt>=l&&cnt<=r&&(maxi-mini>=x))
            ans++;


    }
    cout<<ans;
*/
///////////////////////////////////////////////////////


Measured memory_bytes: 18684
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long a = 0, b = 0, c = 0, hairetu[1000] = { }, mi = 0, ma = 0, ansa = 0, ansb = 0,count=1;
	using namespace std;
	int x=0,y=0,z=0;
	
		cin >> x>>y>>z;
		mi=std::min(std::min(x, y), z);
		ma = std::max(std::max(x, y), z);
	


	cout <<ma-mi<<endl;

}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int a,b,c; cin >> a >> b >> c;

    if(a==b and b==c  and c==a) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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


int main(){

    int N, M;
    cin >> N >> M;
    vector<int>path[101010];
    vector<int>flg(N+1, 0);
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    vector<int>A, B;
    
    for(int pos = 1;;){
        A.push_back(pos);
        int noPath = 1;
        flg[pos] = 1;
        for(int i = 0; i < path[pos].size(); i++){
            if(flg[path[pos][i]])continue;
            pos = path[pos][i];
            noPath = 0;
            break;
        }
        if(noPath)break;
    }
    for(int pos = 1;;){
        if(pos != 1)B.push_back(pos);
        int noPath = 1;
        flg[pos] = 1;
        for(int i = 0; i < path[pos].size(); i++){
            if(flg[path[pos][i]])continue;
            pos = path[pos][i];
            noPath = 0;
            break;
        }
        if(noPath)break;
    }
    reverse(A.begin(), A.end());
    cout << A.size() + B.size() << endl;
    for(int i = 0; i < A.size(); i++){
        if(i)cout << " ";
        cout << A[i];
    }
    for(int i = 0; i < B.size(); i++){
        cout << " ";
        cout << B[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 7160
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, max, min, buf;
  cin >> n;
  vector<int> v1(n);
  for(int i = 0; i < n; ++i) {
	cin >> buf;
	v1[i] = buf;
	
	if(i == 0) {
	  min = v1[i];
	}

	if(i == 1) {
	  max = v1[i] - v1[i - 1];
	}
	
	max = max > (v1[i] - min) ? max : v1[i] - min;
	min = min < v1[i] ? min : v1[i];
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3556
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,a,b = LI()
    print(min(a*n,b))
    return

#B
def B():
    n,d = LI()
    x = LIR(n)
    f = defaultdict(lambda : 0)
    for i in range(1000000):
        f[i*i] = 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            s = 0
            for k in range(d):
                s += (x[i][k]-x[j][k])**2
            if f[s]:
                ans += 1
    print(ans)
    return

#C
def C():
    l,r = LI()
    if r-l > 2019:
        print(0)
        quit()
    ans = float("inf")
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if i*j%2019 < ans:
                ans = i*j%2019
    print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    for i in range(n):
        a[i] *= 2
    x = a[0]
    for i in range(1,n):
        if i%2:
            x -= a[i]
        else:
            x += a[i]
    b = [x//2]
    for i in range(n-1):
        b.append(abs(b[-1]-a[i]))
    print(*b)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 66020
N = int(input())
a = list(map(int, input().split()))
aeve = map(lambda x: x if x % 2 == 0 else 0, a)
ad35 = map(lambda x: True if x % 3 == 0 or x % 5 == 0 else False, aeve)
print("APPROVED") if all(ad35) else print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n;
  char a;
  cin >> a;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  //cout << n << "\n";
  
  cout << ( 65<=a and a<=90 ?"A" :"a") << "\n";

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    vector<ll>h(n),dp(n);
    rep(i,0,n){
        cin>>h[i];
    }
    dp[0]=0;
    rep(i,1,n){
        if(i==1){
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
        else{
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),
            dp[i-2]+abs(h[i]-h[i-2]));
        }
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n-1]<<endl;
    

    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], k;
string s;

void solve(){
   cin >> k >> s;
   n = (int)(s.size());

   if (n <= k){
      cout<<s;
   }
   else{
      cout<<s.substr(0,k);
      cout<<"...";
   }

}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	playList := make([][]string, 0)
	for i := 0; i < n; i++ {
		tmp := scanTextSlice(2)
		playList = append(playList, tmp)
	}
	x := scanText()

	ans := 0
	t := false
	for _, value := range playList {
		title := value[0]
		time, _ := strconv.Atoi(value[1])
		if t {
			ans += time
		}
		if title == x {
			t = true
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 640
//Target for Pupil
//Implementation and Data structures
//Prodip sarker(student_ip)
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define al(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
	int a,b,c,d,n,i,t,tmp,e,f,p;
	string str;
	cin>>str;
	a=str[0]-'0';
	b=str[1]-'0';
	c=str[2]-'0';
	d=str[3]-'0';
	if((a*10+b>=1&&a*10+b<=12)&&(c*10+d>=1&&c*10+d<=12))
	cout<<"AMBIGUOUS\n";
	else if((a*10+b>=1&&a*10+b<=12))
	cout<<"MMYY\n";
	else if((c*10+d>=1&&c*10+d<=12))
	cout<<"YYMM\n";
	else 
	cout<<"NA\n";
	
	return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <stdlib.h>
 
int N, T, A, X,z,c;
 
int main(){
    scanf("%d%d%d",&N,&T,&A);
    int zz = 300000000;
    for (int i=1;i <= N;i++){
       scanf("%d",&X);
       int d=(T*1000-X*6)-1000*A;
      if(d<0)d=-d;
       if(zz >= d) zz=d, c=i;
 
    }
    printf("%d\n", c);
}
    

    

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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> ball(N,1);
  vector<int> red(N,0);
  red.at(0)=1;
  int x,y;
  for(int i=0;i<M;i++){
    cin >> x >> y;
    if(red.at(x-1)==1){
      red.at(y-1)=1;
    }
    if(ball.at(x-1)==1){
      red.at(x-1)=0;
    }
    ball.at(x-1)--;ball.at(y-1)++;
  }
  int C=0;
  for(int i=0;i<N;i++){
    if(red.at(i)==1)
      C++;
  }
  cout << C;
}

Measured memory_bytes: 1024
#include <stdio.h>

template <typename T> inline T min(const T &x, const T &y) { return x < y ? x : y; }
template <typename T> inline T max(const T &x, const T &y) { return x > y ? x : y; }
template <typename T> inline bool cmin(T &x, const T &y) { if (x > y) { x = y; return 1; } return 0; }
template <typename T> inline bool cmax(T &x, const T &y) { if (x < y) { x = y; return 1; } return 0; }

int main() {
	int k, x;
	scanf("%d%d", &k, &x);
	int st = max(-1000000, x - k + 1), ed = min(1000000, x + k - 1);
	for (int i = st; i <= ed; ++i) printf("%d ", i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

}

Measured memory_bytes: 3160
#include <iostream>

int main() {
  int N, A;
  std::cin >> N >> A;

  int pay = N - (N / 500) * 500;
  pay -= A;
  if ( pay > 0 ) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int gcd(int a, int b) {
	if(a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}

int main() {
	int n;
	cin >> n;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<int> right(n);
	vector<int> left(n);
	for(int i = 0; i < n; i++) {
		if(i > 0) {
			right[i] = gcd(right[i - 1], v[i]);
		}
		else {
			right[i] = v[i];
		}
	}
	for(int i = n - 1; i >= 0; i--) {
		if(i < n - 1) {
			left[i] = gcd(left[i + 1], v[i]);
		}
		else {
			left[i] = v[i];
		}
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(i == 0) {
			ans = max(ans, left[i + 1]);
		}
		else if(i == n - 1) {
			ans = max(ans, right[i - 1]);
		}
		else {
			ans = max(ans, gcd(right[i - 1], left[i + 1]));
		}
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long int;
ll mod = 1e9+7;
int main(void){
    ll n,cnt=1,cnt2=1,cnt3=1;
    cin >> n;
    for(int i=0;i<n;i++){
        cnt *= 10;
        cnt %= mod;
    }
    for(int i=0;i<n;i++){
        cnt2 *= 9;
        cnt2 %= mod;
    }
    for(int i=0;i<n;i++){
        cnt3 *= 8;
        cnt3 %= mod;
    }
    ll ans = cnt-2*cnt2+cnt3;
    while(ans<0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin>>H>>W;
  vector<vector<char>> table(H, vector<char>(W));
  vector<bool> deleted_row(H, true);
  vector<bool> deleted_col(W, true);
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++){
      cin>>table.at(i).at(j);
      if(table.at(i).at(j)=='#'){
        deleted_row.at(i)=false;
        deleted_col.at(j)=false;
      }
    }
  }
  
  for(int i=0;i<H;i++){
    if(!deleted_row.at(i)){
      for(int j=0;j<W;j++){
        if(!deleted_col.at(j)){
          cout<<table.at(i).at(j);
        }
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

int n, m, h, k, ans;
int num[1000];
int tmp[1000];
int x[1000];
vector<int> v[1010];
bool used[1000][1000];

void solve(){
	ans = 0;
	memset(used,0,sizeof(used));
	for(int i = 0; i < 1010; i++) v[i].clear();
	for(int i = 0; i < 1000; i++) num[i] = i;
	for(int i = 0; i < n; i++) scanf("%d", &x[i]);
	for(int i = 0; i < m; i++){
		int a, b; scanf("%d%d", &a, &b);
		a--;
		v[b].push_back(a);
	}
	for(int i = 0; i < 1010; i++){
		for(int j = 0; j < v[i].size(); j++){
			swap(num[v[i][j]],num[v[i][j]+1]);
			used[num[v[i][j]]][num[v[i][j]+1]] = true;
			used[num[v[i][j]+1]][num[v[i][j]]] = true;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(num[j] == i) tmp[i] = j;
		}
	}
	for(int i = 0; i < k; i++) ans += x[tmp[i]];
	int Ans = ans;
	for(int i = 0; i < k; i++){
		for(int j = k; j < n; j++){
			if(!used[i][j]) continue;
			Ans = min(Ans,ans-x[tmp[i]]+x[tmp[j]]);
		}
	}
	printf("%d\n", Ans);
}

int main(){
	while(scanf("%d%d%d%d",&n,&m,&h,&k),n||m||h||k) solve();
}

Measured memory_bytes: 2628
using System;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            var NHW = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int N = NHW[0], H = NHW[1],W = NHW[2];
            var ABs = new List<int[]>();
            for(int i=0;i<N;i++)
                ABs.Add(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
            int ans = 0;
            foreach (int[] AB in ABs)
                if (AB[0] >= H && AB[1] >= W)
                    ans++;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/algorithm/find.hpp>

using namespace std;
using boost::multiprecision::int128_t;
using boost::find;

int main() {
    int128_t ans = 1;
    int n;
    cin >> n;
    vector<long> a(n);
    for (auto &&i : a) cin >> i;

    if (find(a, 0) != a.end()) {
        cout << 0 << endl;
        return 0;
    }

    for (auto i : a) {
        ans *= i;
        if (ans > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3992
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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


long long gcd(long long a, long long b) {
	if (b == 0) {
		return a;
	}
	if (a == 0) {
		return b;
	}

	return gcd(b, a % b);
}

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

	ll N, M;


	cin >> N;

	vector<ll> A(N);

	rep(i, N) {
		cin >> A[i];
	}

	vector<ll> L(N+1), R(N+1);

	rep(i, N) {
		L[i + 1] = gcd(L[i], A[i]);
		R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
	}
	ll ret = 0;

	rep(i, N) {
		ret = max(ret, gcd(L[i], R[i + 1]));
	}





	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

int main(){

	int n; cin >> n;
	int x; cin >> x;
	vector<int> a(n);
	for(int& aa : a) cin >> aa;
	sort(a.begin(), a.end());
	int ans = 0;
	for(int aa : a){
		if(x >= aa){
			ans++; x-=aa;
		}
	}
	if(x && ans == n){
		ans --;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    else:
        if m == -1 or f == -1:
            print('F')
        else:
            totalresult = int(m + f)
            if totalresult >= 80:
                print('A')
            elif totalresult >= 65:
                print('B')
            elif totalresult >= 50:
                print ('C')
            elif totalresult >= 30:
                if r >= 50:
                    print('C')
                else:
                    print('D')
            else:
                print('F')


Measured memory_bytes: 5596
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),w=sc.nextInt();
    String[] s=new String[n];
    for(int i=0;i<n;i++){
      s[i]=sc.next();
      System.out.println(s[i]+"\n"+s[i]);
    }
    
  }
}


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

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

    int ok = 0;
    for(int i=0; i<N.size(); i++){
        if(N[i] == '7'){
            ok = 1;
            break;
        }

    }

    if(ok == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000000010

using namespace std;

int n, a[500010], cnt=0;

void merge (int left, int mid, int right)
{
    int n1=mid-left, n2=right-mid, L[n1+1], R[n2+1];
    for (int i=0; i<n1; i++) L[i]=a[left+i];
    for (int i=0; i<n2; i++) R[i]=a[mid+i];
    L[n1]=INF; R[n2]=INF;
    int i=0, j=0;
    for (int k=left; k<right; k++)
    {
        cnt++;
        if (L[i]<=R[j])
        {
            a[k]=L[i];
            i++;
        }
        else
        {
            a[k]=R[j];
            j++;
        }
    }
}

void mergesort (int left, int right)
{
    if (left+1<right)
    {
        int mid=(left+right)/2;
        mergesort(left, mid);
        mergesort(mid, right);
        merge(left, mid, right);
    }
}
int main()
{
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    mergesort(0, n);
    for (int i=0; i<n; i++)
    {
        if (i!=n-1) cout<<a[i]<<' ';
        else cout<<a[i]<<'\n';
    }
    cout<<cnt<<'\n';
    return 0;
}



Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
int time0[100010];
int main()
{
    int n,k;
    int i;
    double ans;
    cin>>n>>k;
    if(n<=(k-1)){
        for(i=1;i<=n;i++) time0[i]=ceil(log((double)k/i)/log(2));
        for(i=1;i<=n;i++) ans+=pow(0.5,time0[i]);
        ans/=n;
    }
    else{
        for(i=1;i<=k-1;i++) time0[i]=ceil(log((double)k/i)/log(2));
        for(i=1;i<=k-1;i++) ans+=pow(0.5,(double)time0[i]);
        ans/=n;
        ans+=(n-k+1)/(double)n;
    }
    printf("%.12lf",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using lint=int64_t;
using namespace std;

constexpr int INF=1e9;

int N,M;
int a[1010]={};
int b[1010]={};
int c[1010][15]={};

int dp[(1<<12)+10];

int rec(int bit)
{
	if(dp[bit]!=-1)
		return dp[bit];
	
	if(bit==0)
		return 0;
	
	int ret=INF;
	for(int i=0;i<M;i++)
	{
		bool pass=true;
		int pbit=bit;
		for(int j=0;j<b[i];j++)
		{
			if(pbit&(1<<c[i][j]))
			{
				pbit&=(~(1<<c[i][j]));
				pass=false;
			}
		}
		if(pass)continue;
		ret=min(ret,rec(pbit)+a[i]);
	}

	dp[bit]=ret;
	return ret;
}

int main()
{

	cin >> N >> M;
	for(int i=0;i<M;i++)
	{
		cin >> a[i] >> b[i];
		for(int j=0;j<b[i];j++)
		{
			cin >> c[i][j];
			c[i][j]--;
		}
	}

	for(int bit=0;bit<(1<<N);bit++)
		dp[bit]=-1;
	dp[0]=0;

	int ans=rec((1<<N)-1);
	if(ans==INF)ans=-1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	long[] as = rlong(n);
	
	long amin= as[0], amax = as[0];
	int imin = 0, imax = 0;
	foreach(int i, a; as){
		if(a < amin) amin = a, imin = i;
		if(a > amax) amax = a, imax = i;
	}
	
	(n * 2 - 1).writeln;
	if(amin >= 0 || amax >= 0 && -amin <= amax){
		foreach(j; 0 .. n) writeln(imax + 1, " ", j + 1);
		foreach(j; 0 .. n - 1) writeln(j + 1, " ", j + 2);
	}
	else{
		foreach(j; 0 .. n) writeln(imin + 1, " ", j + 1);
		foreach_reverse(j; 0 .. n - 1) writeln(j + 2, " ", j + 1);
	}
	
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> A;
  A = {a, b, c};
  sort(A.begin(), A.end());
  if(A.at(0)+A.at(1)==A.at(2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

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

#define rep(i,N) for(int i=0; i<N; i++)

typedef long long ll;

int main(void)
{
    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    vector<ll> dp(N,0);
    rep(i,N) cin >> h[i];
    rep(i,N) {

        if (i==0) {dp[i] = 0; continue;}

        ll vmin = std::numeric_limits<ll>::max();
        for(int j=i-1; i-j<=K && j>=0; j--){
            vmin = min(vmin, dp[j]+abs(h[i]-h[j]));
        }

        dp[i] = vmin;

        //rep(j,N) cout << dp[j] << ",";
        //cout << endl;
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }

    let ret = if a == b {
        2*a
    } else {
        let k = std::cmp::max(a, b);
        2*k-1
    };
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int N;
	cin >> N;
	int n = N%10;
	if(n == 3) cout << "bon" << endl;
	else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else cout << "hon" << endl;


  return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val line = jin.readLine().split(" ")
    val n = line[0].toInt()
    val k = line[1].toLong()
    val logs = jin.readLine().split(" ").map { it.toLong() }
    var upper = logs.max()!!
    var lower = 1L
    while (upper > lower) {
        val mid = (upper + lower) / 2L
        var cuts = 0L
        for (log in logs) {
            cuts += (log - 1L) / mid
        }
        if (cuts <= k) {
            upper = mid
        } else {
            lower = mid + 1L
        }
    }
    println(upper)
}

Measured memory_bytes: 64124
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, N-1):
  if p[i-1] < p[i] < p[i+1]:
    ans += 1
  elif p[i+1] < p[i] < p[i-1]:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
    using namespace std;
    #define _GLIBCXX_DEBUG
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define ll long long
    #define all(x) (x).begin(),(x).end()
    template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
    template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    int main() {
        int a, b, c, d;
        string s;
        cin >> s;
        a = stoi(s.substr(0,1));
        b = stoi(s.substr(1,1));
        c = stoi(s.substr(2,1));
        d = stoi(s.substr(3,1));
        
        char op1, op2, op3;
        for (int i=0; i<2; i++){
            if (i == 0){
                op1 = '+';
            }
            else {
                op1 = '-';
                
            }
            
            for (int j=0; j<2; j++){
                if (j == 0 ){
                    op2 = '+';
                }
                else {
                    op2 = '-';
                }

                for(int k=0; k<2; k++){
                    if (k == 0 ){
                        op3 = '+';
                    }
                    else {
                        op3 = '-';
                    }
                    
                    int ans = a;
                    if (op1 == '+')ans += b;
                    else ans -= b;

                    if (op2 == '+')ans += c;
                    else ans -= c;
                    
                    if (op3 == '+') ans += d;
                    else ans -= d;

                    if (ans == 7){
                        cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
                        return 0;
                    }
                }
            }
        }
    }

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,t,n;
  for(i=1;i <= 4;i++){
        scanf("%d%d",&t,&n);
            if(t == 1)printf("%d\n",6000*n);
            if(t == 2)printf("%d\n",4000*n);
            if(t == 3)printf("%d\n",3000*n);
            if(t == 4)printf("%d\n",2000*n);
  }  
 return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			double x1=sc.nextDouble();
			double y1=sc.nextDouble();
			double x2=sc.nextDouble();
			double y2=sc.nextDouble();
			double x3=sc.nextDouble();
			double y3=sc.nextDouble();
			double x4=sc.nextDouble();
			double y4=sc.nextDouble();	
			System.out.println(Math.abs((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3))<1e-10?"YES":"NO");
		}
	}
}

Measured memory_bytes: 23152