akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
int dx[4] = { 1,0/*,-1,0*/ }, dy[4] = { 0,1/*,0,-1*/ };
/**************/

typedef long double ld;
typedef unsigned long long ull;
const int MX = 3007;

ld f[MX][MX], p[MX];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	f[0][0] = 1.0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			f[i + 1][j + 1] += f[i][j] * p[i];
			f[i + 1][j] += f[i][j]*(1.0-p[i]);
		}
	}
	ld ans = 0.0;
	for (int i = 0; i <= n; i++) {
		if (n<= i*2 ) {
			ans += f[n][i];
		}
	}
	//ans = 3.1415162879247329242952658462;
	cout << fixed <<setprecision(20)<< ans << endl;
	printf("%11.9L", ans);
	return 0;
}

Measured memory_bytes: 141568
#include <iostream>
#include <fstream>
#include <string.h>
#include <math.h>

using namespace std;
const int N = 100010;

int main(){
    int n,k,R,S,P;
    int sum = 0;
    cin >> n >> k >> R >> S >> P;
    char T[N];
    cin >> T;
    
    for(int i = k; i < n ; i++){
        if(T[i] == T[i-k]) T[i] = 'a';
    }
    for(int i = 0; i < n; i++){
        if(T[i] == 'r') sum += P;
        else if(T[i] == 's') sum += R;
        else if(T[i] == 'p') sum += S;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;

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

  int ans = 0;
  for (int i = 0; i < N; i++){
    int X; cin >> X;
    ans += 2 * min(abs(X), abs(X - K));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3544
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int b = sc.nextInt();
        int w = sc.nextInt();
        int g = sc.nextInt();
        
        System.out.println(r+b+w+g);
    }
}


Measured memory_bytes: 26164
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second
#define mp1(a,b,c) P1(a,P(b,c))

ll L;

struct SEG{
	bool flag;
	bool ch;
	SEG *chl,*chr;
	void init(bool flag_ = false){
		flag = flag_;
		ch = false;
	}
	void mkch(){
		chl = new SEG;
		chl->init();
		chr = new SEG;
		chr->init();
		ch = true;
	}
	void add(string *s,int d){
		if(s->size() == d){
			flag = false;
			return;
		}
		if(!ch)mkch();
		if(flag){
			flag = false;
			chl->flag = true;
			chr->flag = true;
		}
		if((*s)[d] == '0')chl->add(s,d+1);
		else chr->add(s,d+1);
	}
	ll sum(ll d){
		if(flag)return (L+1-d)&(-L-1+d);
		if(!ch)return 0;
		return chl->sum(d+1)^chr->sum(d+1);
	}
};

int main(){
	static int N;
	static string s[100010];
	cin >> N >> L;
	for(int i = 1 ; i <= N ; i ++){
		cin >> s[i];
	}
	
	SEG seg;
	seg.init(true);
	for(int i = 1 ; i <= N ; i ++){
		seg.add(&(s[i]),0);
	}
	if(seg.sum(0) == 0)puts("Bob");
	else puts("Alice");
}



Measured memory_bytes: 10496
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int cnt=0;
    rep(i,n){
        int x;
        cin>>x;
        if(i+1!=x)++cnt;
    }
    if(cnt<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
    long long N, M;
    long long res = 0;
    cin >> N;
    cin >> M;

    res = N * M - (M * 2 + N * 2 - 4);
    if (res < 0) {
        res = res * (-1);
    }
    cout << res;
    
    return 0;
}

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

int main(){
  int S;
  cin >> S;
  int A=S/100;
  int B=S%100;
  if(A==0) A=100;
  if(B==0) B=100;
  if(A<=12 && B<=12) cout << "AMBIGUOUS" << endl;
  else if(A>12 && B<=12) cout << "YYMM" << endl;
  else if(A<=12 && B>12) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

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

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

	double result = 0.0;

	const double firstRatio = 1.0 / (double)N;
	for (int n = 1; n <= N; ++n) {
		int count = 0;
		int checkPointOK = n;
		while (checkPointOK < K) {
			checkPointOK *= 2;
			++count;
		}
		result += firstRatio * pow(0.5, count);
	}
	
	cout << fixed;
	cout << setprecision(12) << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
int getInt(){
    int s;
    scanf("%d", &s);
    return s;
}
int main(){
    int n;
    cin >> n;
    vector<pair<int, int> > x(n);
    int s1, s2;
    REP(i, n){
        s1 = getInt();
        s2 = getInt();
        x[i].first = s1 + s2;;
        x[i].second = s1 - s2;
    }
    sort(x.begin(), x.end());
    int ans = 1;
    int left = x[0].first;
    for (int i = 1; i < n; i++){
        if (left <= x[i].second){
            ans++;
            left = x[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/17/20
 */

public class Main {
    private int N;
    private int[] increArr;

    private int Q;
    private int[] arrQ;

    public Main (Scanner sc) {
        N = sc.nextInt();
        increArr = new int[N];
        for (int i = 0; i < N; i++) {
            increArr[i] = sc.nextInt();
        }

        Q = sc.nextInt();
        arrQ = new int[Q];
        for (int i = 0; i < Q; i++) {
            arrQ[i] = sc.nextInt();
        }
    }

    private boolean binarySearch(int targetVal) {
        int leftIx = 0, rightIdx = N-1;
        while (leftIx <= rightIdx) {
            int midIx = leftIx + (rightIdx - leftIx) / 2;
            if (increArr[midIx] == targetVal) {
                return true;
            } else if (increArr[midIx] > targetVal) {
                rightIdx = midIx - 1;
            } else {
                leftIx = midIx + 1;
            }
        }
        return false;
    }

    public int countQinN() {
        int count = 0;
        for (int targetVal : arrQ) {
            if (binarySearch(targetVal)) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        int res = m.countQinN();
        System.out.println(res);
    }
}


Measured memory_bytes: 81852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll a[500005];
ll md=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x=0,y,t,m;

	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		x+=a[i];
		x%=md;
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		y=(x-a[i]+md)%md;
		ans+=(a[i]*y)%md;
		ans%=md;
	}
	cout<<(power(2,md-2,md)*ans)%md<<endl;
}

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll r,g,b;cin>>r>>g>>b;
    ll n=r*100+g*10+b;
    if(n%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
N = int(input().rstrip())
H = list(map(int, input().rstrip().split()))
a = H[0]
can = [1]
for i in range(1, N):
    if a > H[i]:
        continue
    elif a < H[i]:
        a = H[i]
        can.append(i+1)
    else:
        can.append(i+1)
print(len(can))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	int p[246913];
	for(int i=2;i<=246912;i++){
		p[i]=1;
	}
	for(int i=2;i<246913;i++){
		if(i>2&&i%2==0){
			p[i]=0;
		}
		else if(i>3&&i%3==0){
			p[i]=0;
		}
		else{
			int ii=i/12;
			for(int j=1;j<ii+2;j++){
				if(i%(6*j+1)==0){
					p[i]=0;
					break;
				}
				else if(i%(6*j-1)==0){
					p[i]=0;
					break;
				}
			}
		}
		p[5]=1;
		p[7]=1;
		p[13]=1;
	}
	int n;
	while(cin>>n){
		if(n==0) break;
		int c=0;
		for(int i=n+1;i<=2*n;i++){
			c=c+p[i];
		}
		cout<<c<<endl;
	}
    return 0;
}

Measured memory_bytes: 2124
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

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

struct Edge{
  int to,distance,thief;
  Edge(int t,int d,int th):to(t),distance(d),thief(th){}
};

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  while(true){
    int n,m,l;
    cin>>n>>m>>l;
    if(n==0) break;

    std::vector<Edge> node[101];
    for(int i=0;i<m;i++){
      int a,b,d,e;
      cin>>a>>b>>d>>e;
      node[a].push_back(Edge(b,d,e));
      node[b].push_back(Edge(a,d,e));
    }

    int dp[101][101];
    const int INF=INT32_MAX/2;
    for(int r=0;r<=n;r++){
      for(int c=0;c<=l;c++){
        dp[r][c]=INF;
      }
    }
    dp[1][l]=0;

    for(int loop=0;loop<n;loop++){
      for(int from=1;from<=n;from++){
        for(auto e:node[from]){
          for(int cost_from=0;cost_from<=l;cost_from++){
            if(dp[from][cost_from]==INF) continue;
            //お金を払う
            if(cost_from-e.distance>=0){
              dp[e.to][cost_from-e.distance]=std::min(
                  dp[e.to][cost_from-e.distance],
                  dp[from][cost_from]
              );
            }
            dp[e.to][cost_from]=std::min(
                dp[e.to][cost_from],
                dp[from][cost_from]+e.thief
            );
          }
        }
      }
    }

    int result=INF;
    for(int i=0;i<=l;i++){
      result=std::min(result,dp[n][i]);
    }
    cout<<result<<endl;
  }







  return 0;
}


Measured memory_bytes: 3320
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;   
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)2e5 + 5;
const int MAXM = (int)1e6 + 5;
const int MOD = 998244353;

int arr[MAXN];

int cnt[MAXM];

int occ[MAXM];

int n, ans;

int addMod(int a, int b, int m = MOD) {
	a += b;

	if (m <= a) {
		a -= m;
	}

	return a;
}

int mulMod(int a, int b, int m = MOD) {
	return a * 1ll * b % m;
}

int binPow(int a, int b, int m = MOD) {
	int ret = 1;

	while (b > 0) {
		if (b & 1) {
			ret = mulMod(ret, a);
		}

		a = mulMod(a, a);
		b >>= 1;
	}

	return ret;
}

void solve() {
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) {
		scanf("%d", &arr[i]);
		++cnt[arr[i]];
	}

	for (int g = MAXM - 1; g > 0; --g) {
		int sum = 0;         

		for (int ng = g; ng < MAXM; ng += g) {
			if (ng > g) {
				occ[g] = addMod(occ[g], MOD - occ[ng]);
			}

			int cur = mulMod(ng, cnt[ng]);
			sum = addMod(sum, cur);
			occ[g] = addMod(occ[g], MOD - mulMod(cur, ng));
		}

		occ[g] = addMod(occ[g], mulMod(sum, sum));
		ans = addMod(ans, mulMod(occ[g], binPow(2 * g, MOD - 2)));		      
	}    

	printf("%d\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int flag=0;
        while(a>0 && c>0){
            c-=b;
            if(c<=0 ){
                cout<<"Yes";
                flag=1;
            }
            a-=d;
            if(a<=0 && flag==0){
                cout<<"No";
                
            }
            
        }
    }
    return 0;
}
    

Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>

double pow2(double x);

int main(void)
{
    double x1, y1, x2, y2, x3, y3;

    double xx1, yy1, xx2, yy2, xx3, yy3;
    double a1, b1, c1, a2, b2, c2;

    double xp, yp;
    double r;

    int n;
    scanf("%d", &n);

    int i;
    for (i = 1; i <= n; i++) {
        scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
        xx1 = pow2(x1);
        yy1 = pow2(y1);
        xx2 = pow2(x2);
        yy2 = pow2(y2);
        xx3 = pow2(x3);
        yy3 = pow2(y3);

        a1 = 2 * (x2 - x1);
        b1 = 2 * (y2 - y1);
        c1 = xx1 - xx2 + yy1 - yy2;
        a2 = 2 * (x3 - x1);
        b2 = 2 * (y3 - y1);
        c2 = xx1 - xx3 + yy1 - yy3;

        xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
        yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
        r = sqrt(pow2(xp - x1) + pow2(yp - y1));

        printf("%.3f %.3f %.3f\n", xp, yp, r);
    }

    return 0;
}

double pow2(double x)
{
    return x * x;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#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;
  string s; cin >> s;
  int r = 0;
  int b = 0;
  rep(i, 0, N) {
    if(s[i] == 'R') r++;
    else b++;
  }
  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int ans[100100][13];
int m[100200];
	
int main(){
	string s; cin >> s;
	int n = s.l_ength();
	reverse( s.begin(), s.end() );
	ll cnt = 0;
	m[0] = 1;
	for( int i = 0; i <= 100100; ++i ){
		m[i+1] = (m[i]*10)%13;
	}
	ans[0][0] = 1;
	/* if( s[0] != '?' ){
		ans[0][(s[0]-'0')%13] += 1;
	} */
	for( int i = 0; i < n; ++i ){
		char c = s[i];
		if( c == '?' ){
			for( int p = 0; p <= 12; ++p ){
				for( int d = 0; d <= 9; ++d ){
					ans[i+1][(d*m[i]+p)%13] += ans[i][p];
					ans[i+1][(d*m[i]+p)%13] %= mod;
				}
			}
		} else {
			int k = c-'0';
			for( int p = 0; p <= 12; ++p ){
				ans[i+1][(k*m[i]+p)%13] += ans[i][p];
				ans[i+1][(k*m[i]+p)%13] %= mod;
			}
		}
	}
	cout << ans[n][5] << endl;
	return 0;
}

Measured memory_bytes: 5888
import heapq
n,m=map(int,input().split())
edges=[[] for _ in range(n)]
ABC=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    edges[a].append((b,c))
    edges[b].append((a,c))
    ABC.append([a,b,c])

def dijkstra(x,route):
    d=[float('inf')]*n
    d[x]=0
    visited={x}
    hq=[(0,x)]
    while hq:
        u=heapq.heappop(hq)[1]
        visited.add(u)
        for node,cost in route[u]:
            if (node not in visited) and d[node]>d[u]+cost:
                d[node]=d[u]+cost
                heapq.heappush(hq,(d[node],node))
    return d

dist=[[] for _ in range(n)]
for i in range(n):
    dist[i]=dijkstra(i,edges)
ans=0
for a,b,c in ABC:
    if dist[a][b]!=c:
        ans+=1
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
#include <unistd.h>
using namespace std;

#define int long long

signed main(){
	int n;
	int paid = 0;
	cin >> n;
	while(paid < n){
		paid += 1000;
	}
	cout << paid - n << endl;
	return 0;
}

Measured memory_bytes: 3632
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;

int main() {
	string s;
	cin >> s;
	stack <char> st;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S')st.push('S');
		else if (st.empty() || st.top() == 'T')st.push('T');
		else st.pop();
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 644
def abc_exp(a,b,c):
	print(str(a) + ' ' + str(b) + ' ' + str(c) )
	
def exchange(a,b,remain):
	while True:
		if remain >= 4 and a - 4 >= 0:
			b = b + 8
			a = a - 4
			remain = remain - 4
		else: 
			break
	return a,b
	

N,Y = map(int,input().split())

a = int(Y/10000)
b = int((Y - a * 10000)/5000)
c = int((Y - a * 10000 - b * 5000)/1000)

max_bills = int(Y/1000)

if (max_bills < N) or (N < a + b + c):
	print('-1 -1 -1')
	
else:
	remain = N - a - b - c
	a = a - (remain % 4)
	b = b + 2 * (remain % 4)
	
	a , b = exchange(a,b,remain)
	remain = N - a - b - c
	if b - remain/4 >= 0:
		b = b - int(remain / 4)
		c = c + int(remain / 4) * 5
		abc_exp(a,b,c)
	
	else:
		print('-1 -1 -1')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef vector<int> vi;

int main() {
	int N,M,Dsum=0;
	cin >> N>>M;
	vector<int> X(M),D(M-1);
	rep(i,M)cin>>X[i];
	sort(all(X));
	rep(i,M-1){
		D[i] = X[i+1] - X[i];
		Dsum += D[i];
	}
	sort(all(D));
	if(N<M){
		rep(i,N-1){
			Dsum-=D[M-2-i];
		}
	}
	else Dsum = 0;
	cout << Dsum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

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

    rep (i, T.size()) { if (T[i] == '?') { T[i] = 'D'; } }

    cout << T << endl;

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int A, B;
void input() {
  cin >> N >> A >> B;
  va.resize(N + 1);
  rep(i, 1, N) { cin >> va[i]; };
  ;
}
void solve() {
  int ans = 0;
  rep(i, 1, N - 1) { ans += min((va[i + 1] - va[i]) * A, B); }
  cout << ans;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    string s;
    cin >> s;
    vector<bool> c(4,false);
    int cur = 0;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] == 'R'){
            cur = (cur + 1)%4;
            c[cur] = true;
        }else{
            c[cur] = false;
            cur = (4 + cur - 1)%4;
        }
        //cout << i << " " << cur << endl;
        //rep(i,4)cout << " " << c[i];
        //cout << endl;
        if(c[0] && c[1] && c[2] && c[3] && cur == 0){
            //cout << "! " << cur << endl;
            ans++;
            c[0] = c[1] = c[2] = c[3] = false;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3200
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int B2 = 2 * B;
		System.out.println((int)Math.max(A - B2, 0));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  string s;
  cin>>s;
  ll n=s.size();
  Pool(i,1,n){
    bool check=true;
    loop(j,n-i+1){
      check=true;
      Loop(k,j,j+i)if(s[k]!='A'&&s[k]!='C'&&s[k]!='G'&&s[k]!='T')check=false;
      if(check)break;
    }
    if(check){
      putout(i);
      return 0;
    }
  }
  putout(0);
}

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

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){ 
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> pena(N);
    int acs = 0;
    ll penas = 0;
    for (int i : irange(0, M)) {
        int p;
        string S;
        cin >> p >> S;
        --p;
        if (pena[p] >= 0) {
            if (S == "AC") {
                acs++;
                penas += pena[p];
                pena[p] = -1;
            } else {
                pena[p]++;
            }
        }
    }
    cout << acs << " " << penas << LN;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int N, ret=0;
    string S;
    cin >> N >> S;
    for(int i=0; i<N-1; i++){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ret++;
    }
    cout << ret << endl;

    return 0;
}

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

int main(){
    long long int a, b, k, c;
    cin >> a >> b >> k;
    c = b - (k - a);
        if(c < 0){
            c = 0;
        }
    if(a - k > 0){
        cout << a - k << " " << b << endl;
    }
    else{
        cout << 0 << " " << c << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import dropwhile

n = int(input())
D = list(map(int, input().split()))
DIV = 998244353

dist = [0]*n

for i in D:
    dist[i] += 1

dist.reverse()
ddist = list(dropwhile(lambda x: x == 0, dist))
ddist.reverse()

ans = 1
for i in range(len(ddist) - 1):
    ans *= ddist[i] ** ddist[i+1]

if ddist[0] != 1 or D[0] != 0:
    ans = 0

print(ans%DIV)

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

using namespace std;

int main()
{
int n;
cin >> n;
int now;
for (int i=0; i<n; i++)
{   cin >> now;
    if (now%2==0) if (now%3!=0 && now%5!=0){ cout << "DENIED"; return 0;}
}
cout << "APPROVED";
}
//1 -5 6


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

long long a(int n) {
	long long a = 4;
	return (a << n) - 3;
}

long long p(int n) {
	long long p = 2;
	return (p << n) - 1;
}

long long f(int n, long long k) {
	if (k == 1)
		return n == 0;
	if (k <= a(n - 1) + 1)
		return f(n - 1, k - 1);
	if (k == a(n - 1) + 2)
		return p(n - 1) + 1;
	if (k <= a(n) - 1)
		return p(n - 1) + 1 + f(n - 1, k - a(n - 1) - 2);
	else
		return p(n);
}

int main() {
	int n;
	long long k;
	cin >> n >> k;
	cout << f(n, k) << endl;
}


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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

const int INF = 1e9;

int h, n;
int dp[20003];
int A[20003], B[20003];

int main()
{
	// freopen("input.in", "r", stdin);

	for(int i = 0; i <= 20000; i++) dp[i] = INF;

	scanf("%d %d", &h, &n);
	for(int i = 0; i < n; i++)
		scanf("%d %d", &A[i], &B[i]);

	dp[0] = 0;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < n; j++)
		{
			dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j]);
		}
	}
	int res = INF;
	for(int i = h; i <= 20000; i++)
		res = min(res, dp[i]);

	printf("%d\n", res);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <ctype.h>

int main() {
    std::string s;
    std::cin >> s;

    bool flag1 = (s[0] == 'A') ? true : false;
    int num_c = 0;
    int pos_c = 0;
    for (int i=2; i<s.length()-1; i++) {
        if (s[i] == 'C') {
            num_c ++;
            pos_c = i;
        }
    }
    bool flag2 = (num_c == 1) ? true : false;
    bool flag3 = true;
    for (int i=0; i<s.length(); i++) {
        if (i == 0 || i == pos_c) {
            continue;
        }
        if (!islower(s[i])) {
            flag3 = false;
        }
    }
    if (flag1 && flag2 && flag3) {
        std::cout << "AC" << "\n";
    } else {
        std::cout << "WA" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		while(n!=0){
			int[] l = new int[n];
			routine(n,-1, 0, l);
			n = scan.nextInt();
		}
	}
	
	private static void routine(int n, int m, int depth, int[] l){
		if(n==0){
			for(int j=0; j<depth; j++){
				System.out.print(l[j]);
				if(j!=depth-1)	System.out.print(" ");
			}
			System.out.println();
			return;
		}else{
			for(int i=n; i>0; i--){
				if(i>m && m!=-1)	continue;
				l[depth] = i;
				routine(n-i, i, depth+1, l);
			}
		}
	}

}

Measured memory_bytes: 12000
def solve(string):
    a, b = map(int, string.split())

    def f(a):
        if a % 4 == 1:
            return 1
        if a % 4 == 2:
            return a + 1
        if a % 4 == 3 or a == 0:
            return 0
        return a

    return str(f(a - 1) ^ f(b))


if __name__ == '__main__':
    print(solve(input()))

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {
    
    ll a, b, c;
    cin >> a >> b >> c;
    
    vector<ll > ans = {a+b, a+c, b+c};
    sort(ans.begin(), ans.end());
    
    cout << ans[0] << endl;
    

}

Measured memory_bytes: 256
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------


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

    int K = 1;
    while (((K*X) % 360) != 0) K++;
    cout << K << endl;

    return 0;
}



Measured memory_bytes: 3632
import math
from statistics import mean
# a=int(input())
#b=int(input())
# c=[]
# for i in b:
#     c.append(i)
e1,e2 = map(int,input().split())
#f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
h = []
for i in range(e1):
    h.append(list(map(int,input().split())))
r=[]
count=0
for i in range(e1):
    if h[i][1]<=e2:
         r.append(h[i][0])

if len(r)>0:
    print(min(r))
else:
    print("TLE")




Measured memory_bytes: 10932
package main

import (
	"fmt"
	"math"
)

func main() {

	var a, b, C float64
	var S, L, h float64

	fmt.Scan(&a, &b, &C)

	theta := C/180.0 * math.Pi
	S = 0.5 * a * b * math.Sin(theta)
	L = math.Sqrt(a*a + b*b - 2*a*b*math.Cos(theta)) + a + b
	h = b*math.Sin(theta)

	fmt.Println(S)
	fmt.Println(L)
	fmt.Println(h)
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dist[333][333];
ll ori[333][333];
ll n;
void warshall_floyd(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>dist[i][j];
      ori[i][j] = dist[i][j];
    }
  }
  warshall_floyd();
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if(ori[i][j] != dist[i][j]){
	cout<<-1<<endl;
	return 0;
      }
    }
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      bool fl=true;
      for(int k=0;k<n;k++){
	if(i == k || j == k)continue;
	if(dist[i][j] == dist[i][k] + dist[k][j])
	  fl = false;
      }
      if(fl){
	ans += dist[i][j];
      }
    }
  }

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


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    
    ll maxx = X;
    ll miny = Y;

    REP(i, N){
        ll x;
        cin >> x;
        maxx = max(maxx, x);
    }
    REP(i, M){
        ll y;
        cin >> y;
        miny = min(miny, y);
    }

    if(maxx < miny){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		Deque<Integer> q = new ArrayDeque<Integer>();
		if(n % 2 == 0) {
			for(int i = 0 ; i < n ; i++) {
				a[i] = sc.nextInt();
				if(i % 2 == 0) {
					q.addLast(a[i]);
				} else {
					q.addFirst(a[i]);
				}
			}
		} else {
			for(int i = 0 ; i < n ; i++) {
				a[i] = sc.nextInt();
				if(i % 2 == 0) {
					q.addFirst(a[i]);
				} else {
					q.addLast(a[i]);
				}
			}
		}
		for(int i = 0 ; i < n ; i++) {
			if(i != n - 1) {
				System.out.print(q.removeFirst() + " ");
			} else {
				System.out.println(q.removeFirst());
			}
		}
	}
}


Measured memory_bytes: 96192
module ABC088

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public  :: ABC088_A


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC088_A

		! variables for this <subroutine>
		character( len=3, kind=1 ) :: stat
		integer( kind= INT16 )     :: N, A

		! STEP.01
		! read out the target positive integers
		read *, N
		read *, A

		! STEP.02
		! judge whether the target integer is the multiplie of 4 or not
		if( mod( N, 500 ) .le. A ) then
			stat = 'Yes'
		else
			stat = 'No'
		end if

		! STEP.03
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(A)', advance='yes' ) trim( stat )

		! STEP.END
		return

	end subroutine ABC088_A

end module ABC088


program main

	! <module>s to import
	use, non_intrinsic :: ABC088

	! require all variables to be explicitly declared
	implicit none

	call ABC088_A


end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    set<int> s;
    int a, b, c;
    cin >> a >> b >> c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;
    repi(i, n / r + 1, 0)
    {
        repi(j, n / g + 1, 0)
        {
            if ((n - j * g - i * r) % b == 0 && n - j * g - i * r >= 0)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int i,n;cin>>n;
int a[n];for(i=0;i<n;i++) cin>>a[i];
int f=1;
for(i=0;i<n;i++)
{
	if(a[i]%2==0)
	{
		if(a[i]%3!=0 && a[i]%5!=0)
		{
			f=0;break;
		}
	}
}
if(f) cout<<"APPROVED";
else cout<<"DENIED";

return 0;
}

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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

char t[10][10];
int w = 8;
int h = 8;

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

bool check(int y,int x,int kind){
  for(int i=0;i<4;i++){
    int nx = x + dx[kind][i];
    int ny = y + dy[kind][i];
    if(nx>=0 && nx<w && ny>=0 && ny<h){
        if(t[ny][nx] != '1'){
          return false;
        }
    }
      else{
        return false;
        }
  }
    return true;
}

void solve(){
  rep(i,h){
    rep(j,w){
      rep(k,7){
        int tmp = check(i,j,k);
        if(tmp){
          cout<<(char)('A'+k)<<endl;
          return;
        }
      }
    }
  }
}

int main(){
  while(1){
    rep(i,h){
      if(!(cin>>t[i])) return 0;
    }
    solve();
  }
}

Measured memory_bytes: 0
import sys

def gcd(a, b): return gcd(b, a % b) if b else abs(a)
def lcm(a, b): return abs(a // gcd(a, b) * b)

a, b, c, d = map(int, sys.stdin.readline().split())

def count(n):
    return n - (n // c + n // d - n // lcm(c, d))

def main():
    print(count(b) - count(a-1))
    
if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 105
using namespace std;

typedef long long ll;
ll n, mx, a[N], v[N];

void f(ll p, ll q) {
	int i, t[N];
	if (p > n) {mx = max(mx, q); return;}
	f(p + 1, q + a[p]);
	if (a[p] < 0) {
		for (i = p; i <= n; i += p) t[i] = a[i], a[i] = 0;
		f(p + 1, q);
		for (i = p; i <= n; i += p) a[i] = t[i];
	}
}

int main()
{
	ll i, j, t;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for (i = n; i > n / 6; i--) {
		for (j = i, t = 0; j <= n; j += i) t += a[j];
		if (t < 0) for (j = i; j <= n; j += i) a[j] = 0;
	}
	f(1, 0);
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int m, f, r;
    while(cin >> m >> f >> r){
        string g;
        int sum = m + f;
        if(m==-1&f==-1&r==-1){
            break;
        }
        else if(m==-1||f==-1){
            g = "F";
        }
        else if(sum>=80){
            g = "A";
        }
        else if(sum>=65){
            g = "B";
        }
        else if(sum>=50){
            g = "C";
        }
        else if(sum>=30){
            if(r>=50){
                g = "C";
            }
            else{
                g = "D";
            }
        }
        else{
            g = "F";
        }
    
            
        cout << g << endl;
    }
}


Measured memory_bytes: 3144
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int x[10][10];

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, d;
  cin >> n >> d;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      ll t = 0;
      for(int k = 0; k < d; k++) {
        t += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      ll g = 0;
      for(g = 0; g * g < t; g++);
      if(g * g == t) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool f =false;
    rep2(i,a,b+1){
        if(i%k==0)f=true;
    }
    if(f)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    }

Measured memory_bytes: 3636