akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int A,B;
    cin>>A>>B;
    A-=B*2;
    if(A<0)A=0;
    cout<<A<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int c = Integer.parseInt(input[2]);
        
        out.println(c - (a - b) >= 0 ? c - (a - b) : 0);
        out.close();
        
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		int X=in(),H=in();
		if(!X && !H) break;
		double L = hypot(X/2.0,H);
		double S = X*X+2.0*X*L;

		printf("%.10lf\n",S);
	}
	return 0;
}


Measured memory_bytes: 3264
#include<stdio.h>
#include<math.h>
int main()
{   int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A==5&&B==5&&C==7)
    printf("YES");
    else if (A==5&&B==7&&C==5)
    printf("YES");
    else if (A==7&&B==5&&C==5)
    printf("YES");
    else 
    printf("NO");
}

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

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

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

	int n; cin >> n;
	vector<int> p(2*n),dp(2*n,INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) cin >> p[i];
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int now = q.front(); q.pop();
		for (int i = 1; i <= 6; i++) {
			int next = now + i;
            if(next>n-1) break;
			while (dp[next]==INF) {
                if(p[next]==0) q.push(next);
				dp[next] = dp[now] + 1;
				next += p[next];
			}
		}
		if (dp[n - 1] != INF) break;
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 4408
from itertools import accumulate
n = int(input())
s = list(input())
l = [1 if s[i] == "E" else 0 for i in range(n)]
l = list(accumulate(l))
ans = l[-1]-l[0]
for i in range(1, n):
    ans = min(ans, i-l[i-1] + l[-1]-l[i])
print(ans)

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

int main(void) {
	int a, b;
	int c = 0;
	cin >> a >> b;
	if (a < b) {
		cout << b + (b - 1) << endl;
		
	}
	else if (a > b) {
		cout <<a+(a-1)<<endl;
		
	}
	else {
		cout << a * 2 << endl;
	}
}

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

int main() {
    int A, B, K;
    cin >> K;
    cin >> A >> B;

    if (A % K == 0) {
        cout << "OK" << endl;
    }
    else if (B >= K * ((A / K) + 1)) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#define MAX 25
#define NIL -1
 
typedef struct node {
  int parent;
  int left;
  int right;
}Node;
 
 
Node U[MAX];
int n;

void preorder(int u) {

  if( u == NIL ) return;
 
  printf(" %d", u);
  preorder(U[u].left);
  preorder(U[u].right);
}
 
void inorder(int u){

  if( u == NIL )return;
 
  inorder(U[u].left);

  printf(" %d", u);

  inorder(U[u].right);
}
 
void postorder(int u) {

  if(u == NIL)return;
 
  postorder(U[u].left);

  postorder(U[u].right);

  printf(" %d", u);
}


 
int main() {

  int id, data, r,i, j;
 
  scanf("%d", &n);
 
  for (i = 0;i < n;i ++ )
    {
    U[i].parent = NIL;
    U[i].left = NIL;
    U[i].right = NIL;
  }
 
  for (i = 0;i < n;i ++ )
    {
    scanf("%d", &id);

    for (j = 0;j < 2;j ++)
      {
      scanf("%d", &data);

      if(j == 0)U[id].left = data;

      else U[id].right = data;

      U[data].parent = id;
    }
  }
 
    for (i = 0;i < n;i ++ )

      if ( U[i].parent == NIL )

	r = i;
 
    printf("Preorder\n");

    preorder(r);

    printf("\n");

    printf("Inorder\n");

    inorder(r);

    printf("\n");

    printf("Postorder\n");

    postorder(r);

    printf("\n");
 
  return 0;
}
 

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

void mainsolve(){

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i,n) cin >> f[i];
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    ll asum = 0;
    rep(i,n) asum += a[i];
    if(asum <= k){
        cout << 0 << endl;
        return;
    }


    auto isOK = [&](ll c){
        ll sum = 0;
        rep(i,n) sum += max(0ll,a[i] - c/f[i]);
        return sum <= k;
    };

    auto bs = [&]{
        ll ng = -1;
        ll ok = 1e18+1;
        ll mid = (ng+ok)/2;

        while(abs(ng-ok)>1){
            if(isOK(mid)) ok = mid;
            else ng = mid;
            mid = (ng+ok)/2;
        }
        return ok;
    };

    cout << bs() << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY puts("Yes")
#define NN puts("No")
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int k,x;
  cin >> k >> x;
  if(k * 500 >= x)YY;
  else NN;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int PRIME_TABLE_RANGE = 100;
const int PRIME_TABLE_NUM   = 25;
const int primeNumberTable[PRIME_TABLE_NUM] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

int getNumberOfPrimeNumber(int A[], int n)
{
    int primeNum = 0;

    for (int i = 0; i < n; i++)
    {
        if (A[i] > PRIME_TABLE_RANGE)
        {
            bool detectFrag = false;
            for (int j = 0; j < PRIME_TABLE_NUM; j++)
                if (A[i] % primeNumberTable[j] == 0)
                {
                    detectFrag = true;
                    break;
                }
            
            if (detectFrag) continue;

            int startNum = PRIME_TABLE_RANGE % 2 == 0 ? PRIME_TABLE_RANGE + 1 : PRIME_TABLE_RANGE;
            int endNum   = A[i] / PRIME_TABLE_RANGE;
            for (int j = startNum; j <= endNum; j+=2)
                if (A[i] % j == 0)
                {
                    detectFrag = true;
                    break;
                }
            
            if (!detectFrag) primeNum++;;
        }
        else
        {
            for (int j = 0; j < PRIME_TABLE_NUM; j++)
                if (A[i] == primeNumberTable[j])
                {
                    primeNum++;
                    break;
                }
        }
        
    }

    return primeNum;
}

int main()
{
    int num;
    std::cin >> num;

    int *elements = new int[num];
    for (int i = 0; i < num; i++) std::cin >> elements[i];

    std::cout << getNumberOfPrimeNumber(elements, num) << std::endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string s,t;
	cin >> s >> t;
	int ans=1000000;
	int n=s.length();
	int m=t.length();
	for(int i=0;i<=n-m;i++){
		int l=i,h=0;
		int c=m;int count=0;
		while(c--){
			if(s[l]!=t[h]){
				count++;
			}
			l++;h++;
		}
		ans=min(ans,count);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> A(3);
    for(int i=0;i<3;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    int ans=0;
    ans=abs(A[0]-A[1])+abs(A[1]-A[2]);
    cout<<ans;
}

Measured memory_bytes: 256
input1 = input().split()
n = input1[0]
k = input1[1]

n = int(n)
k = int(k)

me = 1 #さいころの目の変数
ten = 0#得点のカウント
count = 0 #いくらコインを連続させなきゃいけないかのカウント
total = 0 #確率はここに累積させる

while me <= n:
    ten = me
    while ten < k:
        count += 1
        ten = ten * 2
    total += 1/n * (1/2) ** count
    count = 0
    me += 1

print(total)


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


bool isPalindromic(int x) {
   string s = to_string(x);
   string t = s;
   reverse(t.begin(), t.end());
   return s == t;
}

void solve() {
   int a, b;
   cin >> a >> b;
   int ans = 0;
   for(int i = a; i <= b; i++) {
      if(isPalindromic(i)) ans++;
   }
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

struct Tolower {
	char operator()(char c) { return tolower(c); }
};
int main() {
	string s, in;
	int ans = 0;
	cin >> s;
	while (cin >> in) {
		if (in == "END_OD_TEXT") break;
		transform(in.begin(), in.end(), in.begin(), Tolower());
		if (in == s)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {

  vector<long long> a(3);
  for ( int i = 0; i < 3; i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  
  int k;
  cin >> k;
  
  for ( int i = 0; i < k; i++){
    a[2] *= 2;
  }
  
  cout << a[0] + a[1] + a[2] << endl;
  
}

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

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

	ll answer = 0;
	for(ll i=0;i<=N;i++){
		if(i%3 != 0 && i%5 != 0){
			answer += i;
		}
	}

	cout << answer << endl;

}


Measured memory_bytes: 3592
#[allow(non_snake_case)]

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let A = iter.next().unwrap().parse::<isize>().unwrap();
    let B = iter.next().unwrap().parse::<isize>().unwrap();
    let C = iter.next().unwrap().parse::<isize>().unwrap();

    if A < B && B < C {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5032
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,y,d;
    lli m;
    string s;
    vi a;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    scanf("%lld/%lld/%lld",&y,&m,&d);
    // cout<<y<<" "<<m<<" "<<d<<endl;
    if(y<2019||(y==2019&&m<=4))
        cout<<"Heisei"<<endl;
    else
        cout<<"TBD"<<endl;
}   aryanc403();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);

    rep(i, n) {
        cin >> a[i];
    }

    if ((n - k) % (k - 1) == 0) cout << 1 + (n - k) / (k - 1) << endl;
    else cout << 1 + (n - k) / (k - 1) + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N,M; cin>>N>>M;

    int64_t ans=0;
    rep(i,1,M/N+1){
        if(M%i==0 && M/i>=N){
            ans=i;
            if(((M/i)%N)%(M/i/N)==0){
                ans=(M/i/N)*i;
                i=ans;
            }
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int h[n];
  REP(i,n) cin >> h[i];
  int ans = 0;

  while(1) {
    int left = -1,right = n-1,m = INF;
    REP(i,n) {
      if (h[i] > 0) {
        if (left == -1) left = i;
        m = min(m, h[i]);
      } else {
        if (left != -1) {
          right = i;
          break;
        }
      }
    }
    if (left == -1) break; // 終了

    for(int i = left; i <= right; i++) h[i]-=m;
    ans+=m;
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

signed  main(){
    int n;
    cin >> n;
    vector<int> a(n);
    For(n, i){
        cin >> a.at(i);
    }
    if (n==2) {
        Pr(a[1]);
        Pr(a[0]);
    }else{
        int maxe =*max_element(a.begin(), a.end());
        int itr =find(a.begin(), a.end(), maxe)-a.begin();//max banme
        if (count(a.begin(), a.end(), maxe)==1) {
            For(n, i){
                if (i==itr) {
                    if (itr==0) {
                        Pr(*max_element(a.begin()+1, a.end()));
                    }else if (itr==n-1){
                        Pr(*max_element(a.begin(), a.end()-1));
                    }else{
                        Pr(max(*max_element(a.begin(), a.begin()+itr-1),
                               *max_element(a.begin()+itr+1,a.end())));
                    }
                }else{
                    Pr(maxe);
                }
            }
        }else{
            For(n, i){
                Pr(maxe);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		Sunuke[] sunukeArr = new Sunuke[n];
		
		for(int i = 0; i < n; i++) {
			int a = fs.nextInt();
			sunukeArr[i] = new Sunuke(a);
		}
		
		
		for(int i = 30; i >= 0; i--) {
			ArrayList<Sunuke> oneSunuke = new ArrayList<>();
			ArrayList<Sunuke> zeroSunuke = new ArrayList<>();
			
			for(Sunuke sunuke : sunukeArr) {
				long bit = sunuke.getNBit(i);
				if(bit == 1L) {
					oneSunuke.add(sunuke);
				}else {
					zeroSunuke.add(sunuke);
				}
			}
			
			if(oneSunuke.size() % 2 == 0 || oneSunuke.size() == n) {
				for(Sunuke sunuke : oneSunuke) {
					sunuke.setOneBit(i);
				}
				continue;
			}
			if(oneSunuke.size() % 2 == 1) {
				for(Sunuke sunuke : zeroSunuke) {
					sunuke.setOneBit(i);
				}
				continue;
			}
		}
		
		for(int i = 0; i < n; i++) {
			System.out.print(sunukeArr[i].calcVal());
			if(i < n-1) {
				System.out.print(" ");
			}
		}
		
		System.out.print("\n");
	}

	class Sunuke {
		long a;
		int[] bitArr;
		
		Sunuke(long a){
			this.a = a;
			this.bitArr = new int[31];
		}
		
		long getNBit(int n) {
			return (a >> n) & 1L;
		}
		
		void setOneBit(int n ) {
			bitArr[n] = 1;
		}
		
		long calcVal() {
			long retVal = 0;
			for(int i = 30; i >= 0; i--) {
				retVal = (retVal << 1);
				if(bitArr[i] == 1) {
					retVal++;
				}
			}
			return retVal;
		}
	}
 	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 101840
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n ,m; cin >> n >> m;
    vector<map<int,int>> s(m);
    rep(i,m){
        int k; cin >> k;
        rep(j,k){
            int ss; cin >> ss;
            s[i][ss-1] = 1;
        }
    }
    VI p(m);
    rep(i,m) cin >> p[i];
    int ans = 0;
    rep(i,(1 << n)){
        bool ok = true;
        rep(j,m){
            int swi = 0;
            rep(k,n){
                if(i & (1 << k)) swi += s[j][k];
            }
            if(swi % 2 != p[j]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import fractions

A, B = map(int, input().split())

G = fractions.gcd(A, B)

res = 1

for i in [2] + list(range(3, int(G ** 0.5) + 1, 2)):
    if G % i == 0:
        res += 1
        while G % i == 0:
            G //= i

if G > 2:
    res += 1

print(res)


Measured memory_bytes: 28728
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

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

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, q; vector<ll> s, t;
	cin >> a >> b >> q;
	REP(i, a){ll tmp; cin >> tmp; s.pb(tmp);}
	REP(i, b){ll tmp; cin >> tmp; t.pb(tmp);}
	REP(i, q){
		ll x; cin >> x;
		ll ans = 5000000000000000000;
		// s -> t
		REP(j, 4){
			ll pos = x, num = 0;
			int bit = j;
				auto itr = upper_bound(ALL(s), pos);
				if(bit % 2){
					if(itr == s.end()) continue;
					num += *itr - pos;
					pos = *itr;
				} else {
					itr--;
					if(itr < s.begin()) continue;
					num += pos - *itr;
					pos = *itr;
				}
				bit /= 2;
			
				itr = upper_bound(ALL(t), pos);
				if(bit % 2){
					if(itr == t.end()) continue;
					num += *itr - pos;
					pos = *itr;
				} else {
					itr--;
					if(itr < t.begin()) continue;
					num += pos - *itr;
					pos = *itr;
				}
				bit /= 2;

			ans = min(ans, num);
		}
		// t -> s
		REP(j, 4){
			ll pos = x, num = 0;
			int bit = j;
				
				auto itr = upper_bound(ALL(t), pos);
				if(bit % 2){
					if(itr == t.end()) continue;
					num += *itr - pos;
					pos = *itr;
				} else {
					itr--;
					if(itr < t.begin()) continue;
					num += pos - *itr;
					pos = *itr;
				}
				bit /= 2;

				itr = upper_bound(ALL(s), pos);
				if(bit % 2){
					if(itr == s.end()) continue;
					num += *itr - pos;
					pos = *itr;
				} else {
					itr--;
					if(itr < s.begin()) continue;
					num += pos - *itr;
					pos = *itr;
				}
				bit /= 2;

			ans = min(ans, num);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3060
def main():
    n = int(input())
    max_quot = 0
    max_quot_i = 1
    for i in range(1, n + 1):
        quote = 0
        ii = i
        while ii % 2 == 0:
            ii //= 2
            quote += 1
        if quote > max_quot:
            max_quot = quote
            max_quot_i = i
    print(max_quot_i)


if __name__ == '__main__':
    main()


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

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}

int H, W;
int D[2];
int mp[1000][1000];

int n_added;
int added[1000*1000];


int find(int y, int x, int level)
{
    if(y == D[1] && x == D[0]) return level;

    if(mp[y][x] != -1) return -1;
    // cout << "(" << x << "," << y << ")" << level << endl;
    mp[y][x] = level;
    added[n_added++] =  y * 1000 + x;

    if(0 < x){
        int v = find(y, x - 1, level);
        if(0 <= v) return v;
    }
    if(0 < y){
        int v = find(y - 1, x, level);
        if(0 <= v) return v;
    }
    if(x < W-1){
        int v = find(y, x + 1, level);
        if(0 <= v) return v;
    }

    if(y < H-1){
        int v = find(y + 1, x, level);
        if(0 <= v) return v;
    }

    return -1;
}

void execute()
{
    int C[2];
    string S[1000];

    cin >> H >> W;
    cin >> C[1] >> C[0];
    C[0]--;
    C[1]--;
    cin >> D[1] >> D[0];
    D[0]--;
    D[1]--;
    for(int y = 0; y < H; y++){
        cin >> S[y];
        for(int x = 0; x < W; x++){
            mp[y][x] = (S[y][x]=='.' ? -1 : -2);
            // cout << -mp[y][x];
        }
        // cout << endl;
    }

    int level = 0;
    int n_que = 0;
    int deque[1000*1000];

    deque[n_que++] = C[1] * 1000 + C[0];
    do{
        n_added = 0;
        for(int i = 0; i < n_que; i++){
            int v = find(deque[i] / 1000, deque[i] % 1000, level);
            if(0 <= v) {cout << v << endl; return;}
        }

        n_que = 0;
        for(int i = 0; i < n_added; i++){
            int y = added[i] / 1000;
            int x = added[i] % 1000;
            for(int dy = -2; dy <= 2; dy++){
                int yy = y + dy;
                if(yy < 0 || H <= yy) continue;
                for(int dx = -2; dx <= 2; dx++){
                    int xx = x + dx;
                    if(xx < 0 || W <= xx) continue;
                    if(mp[yy][xx] == -1){
                        deque[n_que++] = yy * 1000 + xx;
                    }
                }
            }
        }
        n_added = 0;

        level++;
    }while(0 < n_que);

    cout << -1  << endl; 
}


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

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i, N) {
		cin >> H.at(i);
	}

	if (N == 1) {
		cout << "Yes" << endl;
		return 0;
	}

	int m = H.at(N-1);
	for (int i = N-2; i >= 0; i--) {
		int s = m - H.at(i);
	
		if (-1< s) {
			m = H.at(i);
		}
		else if (s == -1) {
			m = H.at(i) - 1;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
		
	}
	
	cout << "Yes" << endl;
	return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    double r = 0.0;
    for (int i = 1; i <= n; i ++) {
        int a = i;
        int c = 0;
        while (a < k) {
            a *= 2;
            c++;
        }
        r += 1.0 / n * pow(1.0 / 2, c);
    }

    cout << fixed << setprecision(10) << r << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>

using std::cin;
using std::cout;
using std::endl;

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

    using pii=std::pair<int, int>;
    std::vector<pii> A(N);
    std::vector<pii> B(N);

    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        A.at(i) = pii(ai, i);
    }

    for (int i = 0; i < N; i++) {
        int bi;
        cin >> bi;
        B.at(i) = pii(bi, i);
    }

    std::sort(B.begin(), B.end());
    for (auto i = 0; i < N; i++) {
        int j = B.at(i).second;
        A.at(j).second = i;
    }
    std::sort(A.begin(), A.end());

    for (int i = 0; i < N; i++) {
        if (A.at(i).first > B.at(i).first) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (auto i = 0; i < N - 1; i++) {
        if (A.at(i + 1).first <= B.at(i).first) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    auto next_i = 0;
    for (auto i = 0; i < N; i++) {
        auto tmp_i = next_i;
        next_i = A.at(tmp_i).second;
        A.at(tmp_i).second = -1;

        if (next_i == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1792
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


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

	int min = floor(n / 1.08)-1;
	int max = ceil(n / 1.08);
	int i;
	for ( i = min; i < max+1; ) {
		if (n == floor(i * 1.08)) {
			
			break;

		}
i++;
	}

	if (i == max+1) {
		cout << ":(";
	}
	else {
		cout << i;
	}
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout << (x ? "Yes" : "No") << endl;
#define out(s) cout << s << endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(), s.end()
void vout(vi v)
{
    for (int i = 0; i < v.size(); i++)
        cout << v.at(i) << endl;
}
int main()
{
    set<int> a, b;
    lli A, B;
    cin >> A >> B;
    rep(i, 100000)
    {
        if (((lli)(i * 0.08)) == A)
        {
            a.insert(i);
        }
        if (((lli)(i * 0.1)) == B)
        {
            b.insert(i);
        }
    }
    lli ans = -1;
    for (lli v : a)
    {
        if (b.count(v))
        {
            ans = v;
            break;
        }
    }
    out(ans);
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define TOP 0
#define BOTTOM 2
#define RIGHT 1
#define LEFT 3

int dx[] = {3,-1,-3,1};
int pt[] = {TOP,RIGHT,BOTTOM,LEFT};
int my[] = {BOTTOM,LEFT,TOP,RIGHT};

vector<string> puz(9);
vector<string> cur(9);
bool done[9];
int ret;

bool check(char a,char b){
	if(a != b && tolower(a) == tolower(b))return true;
	return false;
}
bool check(int p){
	rep(i,4){
		if( p%3==0 && i == 1)continue;
		if( p%3==2 && i == 3)continue;
		
		int t = p+dx[i];
		if(t<0 || t>=9)continue;
		if(cur[t]== "")continue;
		if(!check(cur[t][pt[i]],cur[p][my[i]]))return false;
	}
	return true;
}
void bt(int x){

	if( x == 9){
		ret++;
		return;
	}
	
	rep(i,9){
		if(done[i])continue;
		
		rep(l,4){
			rotate(puz[i].begin(),puz[i].begin()+1,puz[i].end());
			cur[x] = puz[i];
			done[i] = true;
			if(check(x))bt(x+1);
			done[i] = false;
			cur[x] = "";
		}
	}
	return;
}


int main(){
	int n; cin >> n;
	while(n--){
		ret = 0;
		rep(i,9)cin >> puz[i];

		bt(0);
		
		cout << ret << endl;
	}
}

Measured memory_bytes: 932
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
using namespace std;


vector<pair<int,int> > nodes[10010];

class priority {
  public:
    bool operator() (const pair<int,int> &x, const pair<int,int> &y) {
      return x.second > y.second;
    }
};

int mst(int n) {
  vector<int> vis(n, 0);
  vector<int> dis(n, INT_MAX);
  priority_queue<pair<int,int>, vector<pair<int,int> >, priority> pq;
  pq.push(make_pair(0, dis[0] = 0));
  int ans = 0;
  while (!pq.empty()) {
    pair<int,int> now = pq.top();
    pq.pop();
    int no = now.first;
    int di = now.second;
    if (vis[no]) continue;
    vis[no] = 1;
    ans += di;
    for (int i = 0; i < nodes[no].size(); i++) {
      pair<int,int> next = nodes[no][i];
      if (!vis[next.first] && next.second < dis[next.first]) {
        dis[next.first] = next.second;
        pq.push(next);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) return -1;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, x, y, z;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    nodes[x].push_back(make_pair(y, z));
    nodes[y].push_back(make_pair(x, z));
  }
  cout << mst(n) << endl;
  return 0;
}

Measured memory_bytes: 6164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, D, a, ans;
		N = sc.nextInt();
		D = sc.nextInt();
		sc.close();
		a = 0;
		ans = 0;
		while (N > a) {
			a += 2 * D + 1;
			ans++;
		}
		System.out.println(ans);
	}
}


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

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

  vector<int> vec(num);
  for(int i = 0; i < num; ++i) cin >> vec.at(i);

  sort(vec.begin(), vec.end(), greater<int>());

  // 交互に大きい数を取っていくのが最善
  int alice = 0, bob = 0;
  for(int i = 0; i < num; ++i){
    if(i % 2 == 0) alice += vec.at(i);
    else bob += vec.at(i);
  }

  cout << alice - bob << endl;

  return 0;
  
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let nm = lines.next().unwrap().unwrap();
    let mut nm = nm.split_whitespace();
    let n: i32 = nm.next().unwrap().parse().unwrap();
    let m: i32 = nm.next().unwrap().parse().unwrap();
    let ans = if n == m { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  ll n;
  cin >> n;

  string ans;

  while (n != 0) {
    int x = n % 26;
    if (x == 0) x = 26;
    ans.push_back(char('a' + x - 1));
    n -= x;
    n /= 26;
  }

  reverse(ALL(ans));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
vector<pair<long long,long long> >hai;
long long n;
long long k;
long long a[100006];
long long ans[100005];
long long min_index;
int main()
{
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)
	{
		hai.push_back(make_pair(-1*a[i],-1*i));
	}
	sort(all(hai));
	k=-1*hai[0].first;
	min_index=(-1)*hai[0].second;
	rep(i,n-1)
	{
		if(hai[i].first==hai[i+1].first)
		{
			min_index=min(min_index,-1*hai[i].second);
			continue;
		}
		min_index=min(min_index,-1*hai[i].second);
		ans[min_index]+=(hai[i+1].first-hai[i].first)*(i+1);
	}
	ans[0]+=(-1*hai[n-1].first*n);
	rep(i,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4336
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Stream;
import java.util.Map;
import java.util.Collection;
import java.util.Scanner;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }

            String ret = "No";
            Map<Integer, List<Integer>> group = Arrays.stream(a).boxed().collect(Collectors.groupingBy(n -> n));
            int kinds = group.size();
            if (kinds == 1 && group.containsKey(0)) {
                ret = "Yes";
            } else if (kinds == 2 && group.containsKey(0) && group.get(0).size() == N / 3) {
                ret = "Yes";
            } else if (kinds == 3 && group.values().stream().filter(l -> l.size() == N / 3).count() == 3) {
                int n = group.keySet().stream().reduce((x, y) -> x ^ y).get();
                if (n == 0) {
                    ret = "Yes";
                }
            }
            out.println(ret);
        }

    }
}



Measured memory_bytes: 53340
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,c,x,v,ans=0;
	cin>>n>>c;
	vector<pll> l(n),r(n);
	rep(i,n){
		cin>>x>>v;
		l[i]=pll(x,v);
		r[n-i-1]=pll(c-x,v);
	}
	range(i,1,n){
		l[i].sc+=l[i-1].sc;
		r[i].sc+=r[i-1].sc;
	}
	vl ll(n+1),rr(n+1),lret(n+1),rret(n+1);
	rep(i,n)ll[i+1]=max(ll[i],l[i].sc-l[i].fs);
	rep(i,n)rr[i+1]=max(rr[i],r[i].sc-r[i].fs);
	rep(i,n)lret[i+1]=max(lret[i],l[i].sc-l[i].fs*2);
	rep(i,n)rret[i+1]=max(rret[i],r[i].sc-r[i].fs*2);
	rep(i,n+1)chmax(ans,ll[i]+rret[n-i]);
	rep(i,n+1)chmax(ans,lret[i]+rr[n-i]);
	cout<<ans<<endl;
}


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

int main() {
  int a, b, c, x, y, o = INT_MAX;
  cin >> a >> b >> c >> x >> y;
  for(int i = 0; i <= max(x, y); i++)
    o = min(o, max(0, (x - i)) * a + max(0, (y - i)) * b + i * 2 * c);
  cout << o << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int INF = 1e8;

vector<pair<int,pair<int,int>>> e[10000];
int dist[10000];

int main(void) {
    while (true) {
        int i, n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) return 0;
        REP (i,n) e[i].clear();
        REP (i,m) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            u--; v--;
            e[u].push_back({v,{d,c}});
            e[v].push_back({u,{d,c}});
        }
        priority_queue<pair<int,int>> q;
        q.push({0,0});
        REP (i,n) dist[i] = INF;
        dist[0] = 0;
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            int u = p.second;
            for (auto x: e[u]) {
                int v = x.first;
                int d = x.second.first;
                if (dist[v] > dist[u] + d) {
                    dist[v] = dist[u] + d;
                    q.push({-dist[v],v});
                }
            }
        }
        int ans = 0;
        REP (i,1,n-1) {
            int mn = INF;
            for (auto p: e[i]) {
                int v = p.first;
                int d = p.second.first;
                int c = p.second.second;
                if (dist[i] == dist[v] + d) mn = min(mn,c);
            }
            ans += mn;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5032
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int a, b;
	cin >> a >> b;
	puts(max(a, b) <= 8 ? "Yay!" : ":(");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256