akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

LL black[200002] = {0};
LL white[200002] = {0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	string S;
	cin >> N;
	cin >> S;

	while(true){
		if(S[S.size()-1] == '#'){
			S.pop_back();
		}
		else{
			break;
		}
	}

	int bfound = 0;
	string U;
	for(int i=0; i<S.size(); i++){
		if(S[i] == '#'){
			bfound = 1;
		}
		if(bfound){
			U.push_back(S[i]);
		}
	}
	LL w=0, b=0;
	for(int i=0; i<U.size(); i++){
		if(U[i] == '#'){
			b++;
		}
		else{
			w++;
		}
		black[i] = b;
		white[i] = w;
	}

	LL ans1 = (1LL<<62);
	for(int i=0; i<U.size(); i++){
		LL ul = black[i];
		LL ur = w - white[i];
		if(ans1 > ul + ur){
			ans1 = ul + ur;
		}
	}

	LL ans = min(min(b, w), ans1);
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 6984
n=int(input())-1
table=[list(map(int, input().split())) for _ in range(n)]

# 最初の駅から順に考えていく
for i in range(n):
    time=0
    for j in range(i,n):
        
        if time<table[j][1]: # 今いる駅の最初の出発がまだの時
            time=table[j][1]
        
        elif time%table[j][2]==0: # 次の出発時間ちょうどに到着している時
            pass
        
        else: # 次の出発まで時間がある時
            time+=table[j][2]-(time%table[j][2])
        
        time+=table[j][0] # 次の駅に向かう
    print(time)
print(0)
    

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

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	int a=in(),b=in(),c=in(),ans=0,ta,tb,tc;
	if(a==b&&b==c&&a%2==0){
		puts("-1");
		return 0;
	}
	while(1){
		ta=b/2+c/2;
		tb=c/2+a/2;
		tc=a/2+b/2;
		if(2*ta!=b+c){
			break;
		}
		if(2*tb!=c+a){
			break;
		}
		if(2*tc!=a+b){
			break;
		}
		ans++;
		a=ta;
		b=tb;
		c=tc;
	}
	print(ans);
	return 0;
}

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

int main() {
	int c500, c100, c50, total, res = 0;
	cin >> c500 >> c100 >> c50 >> total;
	for (int i = 0; i < c500 + 1; i++) {
		for (int j = 0; j < c100 + 1; j++) {
			for (int k = 0; k < c50 + 1; k++) {
				if (500 * i + 100 * j + 50 * k == total) {
					res++;
				}
			}
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
		sc.close();
		if (A + B >= C) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define map map<ll ,ll>
#define umap unordered_map<ll , ll>
#define endl "\n"
#define set set<ll> 
#define setC set<char>
#define all(x) x.begin() , x.end()
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)
#define ll long long int
const ll INF = 1e13+7;
const ll mod = 1e9+7;

vvll graph;
vll dp;

ll doSome(ll curr){

    if(dp[curr] != -1)
        return dp[curr];

    
    bool leaf = 1;
    ll ans = 0;


    for(auto x : graph[curr]){
        leaf = 0;
        ans = max(doSome(x) , ans);
    }

    return dp[curr] = (leaf ? 0 : 1 + ans);

}

void solv(){
    ll n  , m;
    cin >> n >> m ;

    graph.assign(n+1 , vll());    

    FOR(i , 1 , m){
        ll a , b ;
        cin >>a >> b ;
        graph[a].push_back(b);
    }

    dp.assign(n+1 , -1) ;

    ll ans = 0;
    FOR(i , 1 , n){
        ans = max(ans , doSome(i) );
    }
    cout << ans << endl;
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}




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

typedef long long ll;

using namespace std;

int main(){
    int n;
    ll ans = 0;
    string s;
    cin >> n >> s;
    map<char,int> left;
    left['R'] = left['G'] = left['B'] = 0;
    map<char,int> right;
    right['R'] = right['G'] = right['B'] = 0;
    left[s[0]]++;
    for(int i = 2; i < s.length() ; i++) right[s[i]]++;
    for(int j = 1; j < s.length()-1; j++){
        if(s[j] == 'G') ans += left['R']*right['B'] + left['B']*right['R'];
        if(s[j] == 'R') ans += left['G']*right['B'] + left['B']*right['G'];
        if(s[j] == 'B') ans += left['R']*right['G'] + left['G']*right['R'];
        int dif = 1, i = j , k = j, dame = 0;
        while(i - dif >= 0 && k + dif <= s.length()-1){
            if(s[j] != s[i-dif] && s[j] != s[k+dif] && s[i-dif] != s[k+dif]) dame++;
            dif++;
        }
        ans -= dame;
        left[s[j]]++;
        right[s[j+1]]--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
n = gets.to_i               # 単一整数
ary = gets.chomp.split.map(&:to_i)  # スペースで区切られた複数の整数
ary.sort!

fl = 1		#フラグ

for num in 0..n-1 do
  if ary[num] % 2 == 0 then
    if (ary[num] % 3 == 0) || (ary[num] % 5 == 0) then
      fl = 1
    else
      fl = 0
      break
    end    
  end
end

if fl == 0 then
  puts "DENIED"
elsif fl == 1 then
  puts "APPROVED"
else
  puts "APPROVED"
end

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int n;
	cin >> n;
	vdef p(n, 0);
	for (int i = 0; i < n; ++i) cin >> p[i];

	int c = 0;
	for (int i = 1; i < n - 1; ++i)
	{
		int l = p[i - 1];
		int r = p[i + 1];
		if ((l < p[i] && p[i] < r) || (r < p[i] && p[i] < l)) ++c;
	}

	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << "\n"
using namespace std;
template <class T>
string to_binary(T n)//returns string by converting n into its binary form
{
	string binaryNum;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template <class T>
string to_string(T n)
{
	string str;
	while(n>0)
	{
		int r=n%10;
		n/=10;
		str.pb((r)+'0');
	}
	reverse(str.begin(),str.end());
	return str;
}
template<class T>
bool perfectSq(T n)   //Checks if n is a perfect square
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void print(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int a[3],c,k,i,sum=0,b[3]={1,0,-1},mul;
    cin>>a[0]>>a[1]>>a[2]>>k;
    for(i=0;i<3;i++)
    {
    	if(a[i]>k)
    	{
    		sum+=k*b[i];
    		k-=k;
		}
		else
		{
			sum+=a[i]*b[i];
			k-=a[i];
		}
		if(k<=0)
		   break;
	}
	cout<<sum;
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;

	if (SZ(S) == 2)
	{
		cout << S << endl;
	}
	else
	{
		reverse(all(S));
		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int> t(n+2);
   vector<int> x(n+2);
   vector<int> y(n+2);
   for(int i=1;i<=n;i++){
      cin>>t[i]>>x[i]>>y[i];
   }
   t[0]=x[0]=y[0]=0;
   for(int i=1;i<=n;i++){
      if(t[i]-t[i-1]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1])){
         cout<<"No"<<endl;
         return 0;
      }
      if((t[i]-t[i-1])%2!=(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2){
         cout<<"No"<<endl;
         return 0;
      }
   }
   cout<<"Yes"<<endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;

bool cmp(const pair<lli, lli> left, const pair<lli, lli> right) {
    if(left.second == right.second)return left.first > right.first;
  	return left.second< right.second;
}

int main(){
    int n;
    cin >> n;
    vector<pair<lli,lli>> vec;
    rep0(i,n){
        int x,l;
        cin >> x >> l;
        vec.emplace_back(x-l,x+l);
    }
    sort(all(vec), cmp);

    deque<int> dq;
    dq.push_back(0);

    rep1(i,n-1){
        int x=dq.front();
        if(vec[i].first>= vec[x].second){
            dq.push_front(i);
        }
    }

    cout << dq.size();

}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

ll nCr(ll n, ll k){
    ll res = 1;
    ll resd = 1;
    if ( k > n - k )
        k = n - k;
    for (ll i = 0; i < k; ++i){
        res *= (n - i);
        resd *= (i + 1);
    }
    return divi(res, resd);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll n, k;
	cin>>n>>k;
	ll ans = 0;
	ll x =0;
	ll maxs=0;
	for(int i=0;i<k;i++){
		x+=i;
		maxs+=(n-i);
	}
	for(int i=k; i<=n+1;i++){

		ans = add(ans,(maxs + 1 - x+mod)%mod);
		x+=i;
		maxs+=(n-i);
	}
	cout<<ans%mod;
	
	return 0;
}


Measured memory_bytes: 3608
mod = 998244353
n,k = map(int,input().split())
K = [list(map(int,input().split())) for i in range(k)]

dp = [0]*(n+5)
dp[1] = 1
dp2 = [0]*(n+5)
for i in range(1,n+1):
    dp[i] = (dp[i]+dp2[i]+dp2[i-1])%mod
    dp2[i] = (dp2[i]+dp2[i-1])%mod
    for l,r in K:
        dp2[min(i+l,n+2)] += dp[i]
        dp2[min(i+l,n+2)] %= mod
        dp2[min(i+r+1,n+2)] -= dp[i]
        dp2[min(i+r+1,n+2)] %= mod
print(dp[n]%mod)


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a[10002], b[10002];

int main(){
	cin >> n;
	Int c = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++){
		cin >> b[i];
		if(a[i] < b[i]){
			c += (b[i] - a[i])/2;
		}
		else
			c -= a[i] - b[i];
	}
	if(c >= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 384
let S = stdin.ReadLine().ToCharArray()
let T = Array.zeroCreate<int> (S.Length + 1)
let MOD = 2019

let rec solver m n =
    if n = -1 then ()
    else
        T.[n] <- (T.[n + 1] + m * (int S.[n] - int '0')) % MOD
        solver (m * 10 % MOD) (n - 1)

solver 1 (T.Length - 2)

T
|> Array.countBy id
|> Array.sumBy (fun x -> snd x * (snd x - 1) / 2)
|> printfn "%A"


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

struct SegmentTree {
    vector<int> data;
    int N;
    
    SegmentTree(vector<int> v) {
        int n = v.size();
        N = 1; while(N < n) N *= 2;
        data.resize(2 * N - 1, numeric_limits<int>::max());

        for(int i = 0; i < n; i++) {
            data[i + N - 1] = v[i];
        }
        for(int i = N - 2; i >= 0; i--) {
            data[i] = min(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    void update(int x, int val) {
        x += N - 1;
        data[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            data[x] = min(data[2 * x + 1], data[2 * x + 2]);
        }
    }

    int getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = N;
        if (r <= a || b <= l) return numeric_limits<int>::max();
        if (a <= l && r <= b) return data[k];
        int val_l = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
        int val_r = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(val_l, val_r);
    }
};


void solve() {
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N, numeric_limits<int>::max());
    SegmentTree seg(A);
    for(int i = 0; i < Q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.update(x, y);
        } else {
            cout << seg.getmin(x, y + 1) << endl;
        }
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    map<char,int> mp;
    rep(i,4){
        char c; cin >> c;
        mp[c]++;
    }
    bool is_res = true;
    for(auto c:mp){
        if(c.second != 2)is_res = false;
    }
    cout << (is_res?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define ll long long int
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};
int main() {
	string s;
	cin>>s;
	int z=0,o=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0')z++;
		else o++;
	}
	cout<<min(o,z)*2;
	return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    int i, n;
    int x[100];
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	
	for(i=1;i<=n;i++){
    printf("%d",x[n-i]);
    if(i==n)
      printf("\n");
    else
      printf(" ");
  }
	
	return 0;
}



Measured memory_bytes: 2052
#include <iostream>

int main(int argc, char* argv[] ){
	int input;
	std::cin>> input;
	int hour = input / 3600;
	int min  = (input - hour*3600) /60;
	int sec  = input - hour*3600 - min*60;
	
	std::cout << hour << ":"<<min<<":"<<sec<<std::endl;
	
	}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n,a[100000],b[100000];
bool used[100100],flg=true;

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

	cin>>n;
	REP(i,n) {
		cin>>a[i];
	}
	REP(i,n) {
		cin>>b[i];
	}
	REP(i,n) {
		if(used[b[i]]==false) used[b[i]]=true;
		else flg=false;
	}

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

	cout<<"No"<<endl;

	REP(i,n) cout<<1<<(i==n-1?'\n':' ');
	REP(i,n) cout<<(used[a[i]]?1:2)<<(i==n-1?'\n':' ');
}



Measured memory_bytes: 4100
import sys
sys.setrecursionlimit(10**7)
h, w = [int(item) for item in input().split()]
field = []
for i in range(h):
    field.append(input().rstrip())

black = 0; white = 0
visited = [[0] * w for _ in range(h)]

def dfs(is_black, i, j):
    global black
    global white
    visited[i][j] = 1
    for x, y in [[1,0], [0,1], [0,-1], [-1,0]]:
        if i+x < 0 or i+x >= h or j+y < 0 or j+y >= w:
            continue
        if visited[i + x][j + y] != 0:
            continue
        if is_black:
            if field[i+x][j+y] == ".":
                white += 1
                dfs(False, i+x, j+y)
        if not is_black:
            if field[i+x][j+y] == "#":
                black += 1
                dfs(True, i+x, j+y)

ans = 0
for i in range(h):
    for j in range(w):
        if visited[i][j] != 0:
            continue
        if field[i][j] == "#":
            white = 0; black = 1
            dfs(True, i, j)
        else:
            white = 1; black = 0
            dfs(False, i, j)
        ans += white * black

print(ans)

Measured memory_bytes: 227676
from sys import stdin

N, L = [int(x) for x in stdin.readline().rstrip().split()]

apples = [L + i for i in range(N)]
apples_minus = sorted([x for x in apples if x <= 0], reverse=True)
apples_minus.append(-10 ** 8)
apples_plus = sorted([x for x in apples if x >= 0])
apples_plus.append(10 ** 8)
eat = 0
if abs(apples_minus[0]) <= abs(apples_plus[0]):
    eat = apples_minus[0]
else:
    eat = apples_plus[0]
print(sum(apples) - eat)


Measured memory_bytes: 38256
n, m, c = map(int, input().split(" "))
b = list(map(int, input().split(" ")))
a = [list(map(int, input().split(" "))) for i in range(n)]
ans = len([x for x in a if sum([x[i] * b[i] for i in range(m)]) + c > 0])
print(ans)


Measured memory_bytes: 3060
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 10**9 +7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]








n,k = li()
l = li() + [float('inf')]*(k + 1)

if n == 1:
    print(0)
    exit()
elif n == 2:
    print(abs(l[0] - l[1]))
    exit()
ans = [float('inf')]*(n + k)
ans[0] = 0
for i in range(n):
    for j in range(1,k + 1):
        ans[i + j] = min(ans[i  + j],ans[i] + abs(l[i] - l[i + j]))
print(ans[n-1])

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

int main(){
  int a, b, x;
  scanf("%d %d %d", &a, &b, &x);
  double half = a * a * b / 2.0;
  double ans;
  if(x > half){
    ans = atan(2.0 * (a * a * b - x) / (a * a * a));
  }else{
    ans = atan((a * b * b * 1.0) / (2.0 * x));
  }
  ans = ans * 180.0 / 3.1415926535;
  printf("%.12f\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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 vpii = vector<pii>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  if(!((B-A)%(ll)2)) cout << (B-A)/(ll)2 << endl;
  else {
    ll X=min(A-1,N-B);
    cout << X+1+(B-A-1)/(ll)2 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    int64_t f = min(a, min(b, min(c, min(d, e))));
    cout << (n + f - 1) / f + 4 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
  int m,f,r;

  while (1){
    
    scanf("%d%d%d",&m ,&f ,&r);
    
    if (m == -1 && f == -1 && r == -1) break;

  if (m == -1 || f == -1) printf("F\n");
  else if(m + f >= 80 ) printf("A\n");
  else if(m + f >= 65 ) printf("B\n");
  else if(m + f >= 50 ) printf("C\n");
  else if(m + f >= 30 ){
    if (r >= 50) printf("C\n");
    else printf("D\n");
}
  else printf("F\n");
  }
  
  return 0;
}



Measured memory_bytes: 2060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] homework = scanner.nextLine().split(" ");
        String[] days =scanner.nextLine().split(" ");
        int daySum = Arrays.stream(days).mapToInt(Integer::parseInt).sum();
        int d = Integer.parseInt(homework[0]) - daySum;
        if (d < 0) {
            System.out.println(-1);
        }else {
            System.out.println(d);
        }
    }
}


Measured memory_bytes: 39408
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int kinds[] = new int[M];  

        for (int i = 0; i < N; i++){

            int K = sc.nextInt();
            
          for (int j = 0; j < K; j++){
              int tmp = sc.nextInt() - 1;
              kinds[tmp]++;
            }

        }

        int count = 0;

        for (int i = 0; i < M; i++){

            if (kinds[i] == N) {
                count++;
            }

        }
        System.out.println(count);
     }
}

Measured memory_bytes: 22356
#include <iostream>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int h, n;   cin >> h >> n;
    int sum = 0;
    rep(i, n){
        int a;  cin >> a;
        sum += a;
    }  
    if(sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
b=[0]*n
for i,a in enumerate(map(int,input().split())):
    if n%2:
        b[n//2+-~i//2*[-1,1][i%2]]=a
    else:
        b[n//2+-~i//2*[1,-1][i%2]]=a
print(*b)

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

ll N, K;
vector<int> u, v;

int main()
{
    ll ans = 1e18;
    cin >> N >> K;
    vector<ll> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    for (int i = 0; i + K - 1 < N; i++)
    {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 ll check  = 1e18;
 ll a[100001] ;
void solve()
{
	long long a , b , c  ; 
	scanf("%lld %lld.%lld",&a,&b,&c);
	long long fac =(a*c - ( a*c)%100)/100;
    long long ans = a*b + fac;
    cout<<ans;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main()
{
	int n,i;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	cout << abs(a[0]-a[n-1]) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;
 
int main(){
    float a,b,c;
    cin >> a >> b >> c;
    
    // cout << sin(c/180*M_PI)*a*b/2 << endl << a + b +sqrt(a*a+b*b-2*cos(c/180*M_PI)*a*b) << endl << b*sin(c/180*M_PI) << endl;
    printf("%.8lf\n%.8lf\n%.8lf\n", a*b/2*sin(M_PI*c/180), a + b +sqrt(a*a+b*b-2*cos(M_PI*c/180)*a*b), b*sin(M_PI*c/180));
}


Measured memory_bytes: 3392
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
 
#define endl "\n"
 
const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
 
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    ll n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(i,x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
const int maxn=106;
int a[maxn],n,num[maxn];
bool vis[maxn];
int main(){
    n=read();
    rep(i,1,n)a[i]=read();
    rep(i,1,n){
        int num=0;
        rep(j,1,i-1)if(a[j]<=a[i])num++;
        if(num+1<a[i]){puts("-1");return 0;}
    }
    rep(i,1,n){
        num[0]=0;
        rep(j,1,n)num[j]=num[j-1]+vis[j];
        dep(j,n,1)
            if(!vis[j]&&num[j-1]+1==a[j]){
                vis[j]=1;
                cout<<a[j]<<endl;
                break;
            }
    }
    return 0;
}

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

int main() {
  int n,d,x;
  cin >>n>>d>>x;
  vector<int> a(n);
  for (int i=0;i<n;i++) cin >>a.at(i);
  
  int eaten=0;
  for (int i=0;i<n;i++) {
	for (int j=1;j<=d;j+=a.at(i)) eaten++;
  }
  cout << eaten+x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2005
#define PAIR pair<int,int>
#define oo (1<<30)
using namespace std;
int n,ans=oo,lw,l[N],r[N]; char a[N],b[N],c[N]; PAIR w[N];
void flip()
{
	int i,j,Max;
	for(i=1;i<=n;i++){
		for(j=i;j>=1;j--)
			if(b[j]=='1') break;
		if(!j){
			for(j=n;j>=i;j--)
				if(b[j]=='1') break;
			l[i]=i+n-j;
		  }
		else l[i]=i-j;
		for(j=i;j<=n;j++)
			if(b[j]=='1') break;
		if(j>n){
			for(j=1;j<=i;j++)
				if(b[j]=='1') break;
			r[i]=n-i+j;
		  }
		else r[i]=j-i;
	  }
	for(i=0;i<2*n;i++){
		lw=Max=0;
		for(j=1;j<=n;j++)
			if(a[j]!=b[(j+i-1)%n+1])
				w[++lw]=PAIR(r[j],l[j]);
		sort(w+1,w+lw+1);
		for(j=lw;j>=0;j--)
			ans=min(ans,lw+w[j].first+Max*2+abs(w[j].first-i)),Max=max(Max,w[j].second);
	  }
}
int main()
{
	int i;
	scanf("%s",a+1);
	scanf("%s",b+1);
	n = strlen(a+1);
	for(i=1;i<=n;i++)
		if(b[i]=='1') break;
	if(i>n){
		for(i=1;i<=n;i++)
			if(a[i]=='1') break;
		if(i<=n){ printf("-1"); return 0;}
		else{ printf("0"); return 0;}
	  }
	flip();
	for(i=1;i<=n/2;i++) swap(a[i],a[n-i+1]);
	for(i=1;i<=n/2;i++) swap(b[i],b[n-i+1]);
	flip();
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    int a,b,c,k,w;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    
    if(a<c){
        w=a;
        a=c;
        c=w;
    }
    if(a<b){
        w=b;
        b=a;
        a=w;
    }
    if(b<c){
        w=b;
        b=c;
        c=w;
    }
    for(int i=0; i<k; i++)
        a*=2;

    printf("%d",a+b+c);
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, FiniteField x) { s << x.Value(); return s; }

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  int64 d_1, d_2;
  cin >> d_1 >> d_2;

  vector<int64> vs(n + 1);
  vs[0] = -2E18;
  for (int i = 1; i <= n; i++) {
    cin >> vs[i];
  }

  vector<FiniteField> dp_1(n);
  vector<FiniteField> dp_2(n);
  vector<FiniteField> cs_1(n);
  vector<FiniteField> cs_2(n);
  int z_1 = 0;
  int z_2 = 0;
  dp_1[0] = 1;
  dp_2[0] = 1;
  cs_1[0] = 1;
  cs_2[0] = 1;

  for (int k = 2; k <= n; k++) {
    int i_1 = distance(vs.begin(), upper_bound(vs.begin(), vs.end(), vs[k] - d_1));
    i_1 = min(i_1, k - 1);
    if (i_1 > z_2) {
      if (i_1 > 0) dp_1[k - 1] += cs_2[i_1 - 1];
      if (z_2 > 0) dp_1[k - 1] -= cs_2[z_2 - 1];
    }
    cs_1[k - 1] += cs_1[k - 2] + dp_1[k - 1];

    int i_2 = distance(vs.begin(), upper_bound(vs.begin(), vs.end(), vs[k] - d_2));
    i_2 = min(i_2, k - 1);
    if (i_2 > z_1) {
      if (i_2 > 0) dp_2[k - 1] += cs_1[i_2 - 1];
      if (z_1 > 0) dp_2[k - 1] -= cs_1[z_1 - 1];
    }
    cs_2[k - 1] += cs_2[k - 2] + dp_2[k - 1];

    if (vs[k] - vs[k - 1] < d_1) {
      z_1 = k - 1;
    }
    if (vs[k] - vs[k - 1] < d_2) {
      z_2 = k - 1;
    }
    // cout << "k: " << k << endl;
    // cout << "i_1: " << i_1 << endl;
    // cout << "i_2: " << i_2 << endl;
    // cout << "dp_1: " << dp_1 << endl;
    // cout << "cs_1: " << cs_1 << endl;
    // cout << "z_1: " << z_1 << endl;
    // cout << "dp_2: " << dp_2 << endl;
    // cout << "cs_2: " << cs_2 << endl;
    // cout << "z_2: " << z_2 << endl;
  }

  FiniteField ans = 0;
  ans += cs_1[n - 1];
  if (z_1 > 0) ans -= cs_1[z_1 - 1];
  ans += cs_2[n - 1];
  if (z_2 > 0) ans -= cs_2[z_2 - 1];
  cout << ans << endl;
}

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

int main() {
  long long n;
  cin >> n;
  
  long long ans = 0;
  for(long long i = 1; i * i <= n; ++i){
    long long k = n;
    if(k % i) continue;
    if(i == 1){
      ans++;
      continue;
    }
    while(k % i == 0) k /= i;
    if(k % i == 1) ans++;
    k = n;
    if(i * i == k) continue;
    long long d = n / i;
    while(k % d == 0) k /= d;
    if(k % d == 1) ans++;
  }
  for(long long i = 1; i * i < n; ++i){
    long long k = n - 1;
    if(k == 1) break;
    if(k % i) continue;
    if(i == 1 || i * i == k){
      ++ans;
      continue;
    }
    ans += 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

	int member[25][25] = { 0 };
	int min = 999999999;
	int ans = 0;

	int x = 0;
	int y = 0;

	cin >> x >> y;

	for (int i = 0; i < x; i++){

		for (int u = 0; u < y; u++){

			cin >> member[i][u];

		}

	}

	for (int i = 0; i < x; i++){

		for (int u = 0; u < y; u++){

			ans = 0;

			for (int X = 0; X < x; X++){

				for (int Y = 0; Y < y; Y++){

					if (abs(i - X) <= abs(u - Y)){

						ans += member[X][Y] * abs(i - X);

					}
					else{

						ans += member[X][Y] * abs(u - Y);

					}

				}

			}

			if (min > ans){

				min = ans;

			}

		}

	}

	cout << min << endl;

}


Measured memory_bytes: 3116
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    from collections import defaultdict as dd
    d = dd(lambda : 0)
    n = int(input())
    a = list(map(int , input().split()))

    for idx , i in enumerate(a):
        d[idx + 1 - i] += 1
    
    cnt = 0
    for idx , i in enumerate(a):
        cnt += d[i + idx + 1]
    
    print(cnt)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 61572
#include <stdio.h>

long long int fact(long long int n)
{
        if(n == 0)
                return 1;
        else
                return n * fact(n-1);
}

int main()
{
        long long int n;
        scanf("%lld", &n);
        printf("%lld\n", fact(n));
        return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <list>
using namespace std;

int main(){
    int n;cin>>n;
    vector<long long> sequence(n);for (int i=0;i<n;i++){cin>>sequence[i];}
    list<long long> output;
    for(int i=0;i<n;i++){
        if (i%2==0){
            if (n%2==0){
                output.push_back(sequence[i]);
            } else {
                output.push_front(sequence[i]);
            }
        } else {
            if (n%2==0){
                output.push_front(sequence[i]);
            } else {
                output.push_back(sequence[i]);
            }
        }
    }
    for (auto a: output){
        cout << a << " ";
    }

    return 0;
}


Measured memory_bytes: 9984
using System;

namespace ABC078
{
    public class Problem_B
    {
        public static void Main(string[] args)
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int x = inputs[0], y = inputs[1], z = inputs[2];
            var ans = (x - z) / (y + z);
            Console.WriteLine($"{ans}");
        }
    }
}


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

using namespace std;

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

    int N, M; cin>>N>>M;
    std::vector<int> graph[N];
    for (int i = 0; i < M; i++) {
        int u, v; cin>>u>>v;
        u--, v--;
        graph[u].push_back(v);
    }
    int S, T; cin>>S>>T;
    S--,T--;

    struct Expr {
        int t;
        int dist;
    };
    queue<Expr> qs;
    qs.push({S, 0});
    vector<array<bool, 3>> visited(N, {0,0,0});
    bool ans = false;
    long min_dist = numeric_limits<long>::max();
    while (not qs.empty()) {
        auto q = qs.front(); qs.pop();
        int eo = q.dist%3;
        if (q.t == T and eo == 0) {
            ans = true;
            min_dist = (q.dist)/3;
            break;
        }
        if (visited[q.t][eo])
            continue;
        visited[q.t][eo] = true;
        for (auto tar : graph[q.t])
            qs.push({tar, q.dist+1});
    }
    cout << (ans ? min_dist : -1) << endl;
	
    return 0;
}


Measured memory_bytes: 6016
fun main(args: Array<String>) {
    val (a, b, t) = readLine()!!.split(" ").map { it.toInt() }

    var sum = 0
    var c = 1
    var ans = 0

    while(true){
        sum += a*c
        if(t+0.5 <= sum) break
        ans += b
    }

    println(ans)
}


Measured memory_bytes: 37780
import sys

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())
constraints = []
for _ in range(M):
    s, c = input().split()
    constraints.append((int(s) - 1, c))

for i in range(0, 1000):
    x = str(i)
    if len(x) == N and all(x[s] == c for s, c in constraints):
        print(x)
        exit(0)

print(-1)


Measured memory_bytes: 38256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int px = 0; int py = 0; int pt = 0;

		for (int i = 0; i < N; i++) {
			int t = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int dt = t - pt;
			int dist = Math.abs(px - x) + Math.abs(py - y);

			if (dt >= dist && dt % 2 == dist % 2) {
				px = x;
				py = y;
				pt = t;
				continue;
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 87556
N = int(input())
S = [input() for _ in range(N)]

AB = 0
lastA = 0
firstB = 0
both = 0
for s in S:
  if s[-1] == 'A' and s[0] == 'B':
    both += 1
  else:
    if s[-1] == 'A':
      lastA += 1
    if s[0] == 'B':
      firstB += 1
  for i in range(len(s)-1):
    if s[i:i+2] == 'AB':
      AB += 1
x = min(lastA, firstB)
y = abs(lastA - firstB)
if x >= both:
  print(AB + both * 2 + x - both)
else:
  print(AB + both-1 + int(lastA>0) + int(firstB>0) + max(0, x-1))

Measured memory_bytes: 3700
# -*- coding: utf-8 -*-
import unittest

MOD = 10**9 + 7

def func(s):
    abc = "ABC"
    n = len(s)
    dp =[[0 for _ in range(3+1)] for _ in range(n+1)]
    dp[n][3] = 1

    for i in range(n-1,-1,-1):
        for j in range(3,-1,-1):
            if j==3:
                if s[i]=="?":
                    dp[i][j] = (dp[i+1][j]*3)%MOD
                else:
                    dp[i][j] = dp[i+1][j]
            else:
                m1 = 3 if s[i]=="?" else 1
                m2 = 1 if s[i]=="?" or s[i]==abc[j] else 0
                dp[i][j] = ((m1*dp[i+1][j])%MOD + (m2*dp[i+1][j+1])%MOD)%MOD
    return dp[0][0]

class Test(unittest.TestCase):
    def test(self):
        self.assertEqual(func("A??C"), 8)
        self.assertEqual(func("ABCBC"), 3)
        self.assertEqual(func("????C?????B??????A???????"), 979596887
)

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


Measured memory_bytes: 30104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int l, r;
    int n = s.size();
    rep(i, n){
        if(s[i] == 'Z') r = i;
        if(s[n - i - 1] == 'A') l = n - i - 1;
    }
    cout << r - l + 1 << endl;
}

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

int main(){
  long long n,a,b; cin>>n>>a>>b;
  long long min_v=a*(n-1)+b;
  long long max_v=b*(n-1)+a;
  cout<<(max_v-min_v+1>=0 ? max_v-min_v+1:0)<<endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, X;
  cin >> N >> X;
  vll V(N);
  REP(i, 0, N) {
    cin >> V[i];
  }
  sort(V.begin(), V.end(), less<>());

  if (N == 1) {
    cout << abs(X - V[0]) << endl;
    return 0;
  }

  ll m = abs(X - V[0]);
  REP(i, 0, N) {
    m = gcd(m, abs(X - V[i]));
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 3956
N = int(input())
A = [int(input()) for i in range(N)]

def insertion_sort(A, N, diff, cnt):
    for i in range(diff, N):
        tmp_num = A[i]
        j = i - diff
        while j >= 0 and A[j] > tmp_num:
            A[j+diff] = A[j]
            j = j - diff
            cnt += 1
        A[j+diff] = tmp_num
    return cnt

if __name__ == "__main__":
    cnt = 0
    diffs = []
    h = 1
    while h <= N:
        diffs.append(h)
        h = h*3 + 1
    diffs.reverse()
    diffs_cnt = len(diffs)
    for diff in diffs:
        cnt = insertion_sort(A, N, diff, cnt)
    print(diffs_cnt)
    print(" ".join(map(str, diffs)))
    print(cnt)
    for num in A:
        print(num)



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

void solve(){
	
	ll h,w ; 
	cin>>h>>w ;

	ll ans=h*w ;

	if(h==1||w==1){
		cout<<1 ;
		return ;
	}


	if(ans%2==0)
		cout<<ans/2 ;
	else
		cout<<(ans+1)/2 ;
	

}	

int main(){


	
	int y ;

	y=1 ;
	//cin>>y ;

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

}

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

using namespace std;

int main(){
        string s;
        cin>>s;
        int K;
        cin>>K;
        vector <string> a;
        for(int i=1;i<=min(5, (int)s.length());i++){
                for(int j=0;j<=(int)s.length()-i;j++){
                        string ss=s.substr(j, i);
                        bool flag=false;
                        for(int k=0;k<(int)a.size();k++){
                                if(ss==a[k]){
                                        flag=true;
                                        break;
                                }
                        }
                        if(flag){
                                continue;
                        }
                        if(a.size()<10){
                                a.push_back(ss);
                        }
                        else{
                                sort(a.begin(), a.end());
                                a[9]=ss;
                        }
                }
        }
        sort(a.begin(), a.end());
        /*for(int i=0;i<(int)a.size();i++){
                cout<<a[i]<<endl;
        }*/
        cout<<a[K-1]<<endl;
        return 0;
}


Measured memory_bytes: 256